agentwallet-sdk 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/index.d.ts +213 -284
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/ap2/index.d.ts +0 -185
- package/dist/ap2/index.d.ts.map +0 -1
- package/dist/ap2/index.js +0 -255
- package/dist/ap2/index.js.map +0 -1
- package/dist/bridge/unified.d.ts +0 -101
- package/dist/bridge/unified.d.ts.map +0 -1
- package/dist/bridge/unified.js +0 -284
- package/dist/bridge/unified.js.map +0 -1
- package/dist/chains.d.ts +0 -62
- package/dist/chains.d.ts.map +0 -1
- package/dist/chains.js +0 -108
- package/dist/chains.js.map +0 -1
- package/dist/fiat/index.d.ts +0 -10
- package/dist/fiat/index.d.ts.map +0 -1
- package/dist/fiat/index.js +0 -9
- package/dist/fiat/index.js.map +0 -1
- package/dist/fiat/onramp.d.ts +0 -101
- package/dist/fiat/onramp.d.ts.map +0 -1
- package/dist/fiat/onramp.js +0 -155
- package/dist/fiat/onramp.js.map +0 -1
- package/dist/fiat/providers/index.d.ts +0 -16
- package/dist/fiat/providers/index.d.ts.map +0 -1
- package/dist/fiat/providers/index.js +0 -30
- package/dist/fiat/providers/index.js.map +0 -1
- package/dist/fiat/providers/moonpay.d.ts +0 -22
- package/dist/fiat/providers/moonpay.d.ts.map +0 -1
- package/dist/fiat/providers/moonpay.js +0 -107
- package/dist/fiat/providers/moonpay.js.map +0 -1
- package/dist/fiat/providers/stripe.d.ts +0 -26
- package/dist/fiat/providers/stripe.d.ts.map +0 -1
- package/dist/fiat/providers/stripe.js +0 -135
- package/dist/fiat/providers/stripe.js.map +0 -1
- package/dist/fiat/providers/transak.d.ts +0 -26
- package/dist/fiat/providers/transak.d.ts.map +0 -1
- package/dist/fiat/providers/transak.js +0 -119
- package/dist/fiat/providers/transak.js.map +0 -1
- package/dist/fiat/types.d.ts +0 -106
- package/dist/fiat/types.d.ts.map +0 -1
- package/dist/fiat/types.js +0 -13
- package/dist/fiat/types.js.map +0 -1
- package/dist/flash/executor.d.ts +0 -119
- package/dist/flash/executor.d.ts.map +0 -1
- package/dist/flash/executor.js +0 -195
- package/dist/flash/executor.js.map +0 -1
- package/dist/flash/index.d.ts +0 -28
- package/dist/flash/index.d.ts.map +0 -1
- package/dist/flash/index.js +0 -29
- package/dist/flash/index.js.map +0 -1
- package/dist/flash/scanner.d.ts +0 -133
- package/dist/flash/scanner.d.ts.map +0 -1
- package/dist/flash/scanner.js +0 -212
- package/dist/flash/scanner.js.map +0 -1
- package/dist/flash/types.d.ts +0 -136
- package/dist/flash/types.d.ts.map +0 -1
- package/dist/flash/types.js +0 -23
- package/dist/flash/types.js.map +0 -1
- package/dist/gas/index.d.ts +0 -4
- package/dist/gas/index.d.ts.map +0 -1
- package/dist/gas/index.js +0 -3
- package/dist/gas/index.js.map +0 -1
- package/dist/gas/sponsor.d.ts +0 -70
- package/dist/gas/sponsor.d.ts.map +0 -1
- package/dist/gas/sponsor.js +0 -193
- package/dist/gas/sponsor.js.map +0 -1
- package/dist/gas/types.d.ts +0 -76
- package/dist/gas/types.d.ts.map +0 -1
- package/dist/gas/types.js +0 -21
- package/dist/gas/types.js.map +0 -1
- package/dist/identity/agent-identity.d.ts +0 -276
- package/dist/identity/agent-identity.d.ts.map +0 -1
- package/dist/identity/agent-identity.js +0 -300
- package/dist/identity/agent-identity.js.map +0 -1
- package/dist/identity/erc6551.d.ts +0 -441
- package/dist/identity/erc6551.d.ts.map +0 -1
- package/dist/identity/erc6551.js +0 -517
- package/dist/identity/erc6551.js.map +0 -1
- package/dist/mev/index.d.ts +0 -4
- package/dist/mev/index.d.ts.map +0 -1
- package/dist/mev/index.js +0 -8
- package/dist/mev/index.js.map +0 -1
- package/dist/mev/protection.d.ts +0 -54
- package/dist/mev/protection.d.ts.map +0 -1
- package/dist/mev/protection.js +0 -185
- package/dist/mev/protection.js.map +0 -1
- package/dist/mev/risk.d.ts +0 -19
- package/dist/mev/risk.d.ts.map +0 -1
- package/dist/mev/risk.js +0 -95
- package/dist/mev/risk.js.map +0 -1
- package/dist/mev/types.d.ts +0 -49
- package/dist/mev/types.d.ts.map +0 -1
- package/dist/mev/types.js +0 -2
- package/dist/mev/types.js.map +0 -1
- package/dist/settlement/index.d.ts +0 -4
- package/dist/settlement/index.d.ts.map +0 -1
- package/dist/settlement/index.js +0 -3
- package/dist/settlement/index.js.map +0 -1
- package/dist/settlement/types.d.ts +0 -66
- package/dist/settlement/types.d.ts.map +0 -1
- package/dist/settlement/types.js +0 -37
- package/dist/settlement/types.js.map +0 -1
- package/dist/settlement/verifier.d.ts +0 -75
- package/dist/settlement/verifier.d.ts.map +0 -1
- package/dist/settlement/verifier.js +0 -354
- package/dist/settlement/verifier.js.map +0 -1
- package/dist/solana/bridge.d.ts +0 -144
- package/dist/solana/bridge.d.ts.map +0 -1
- package/dist/solana/bridge.js +0 -352
- package/dist/solana/bridge.js.map +0 -1
- package/dist/solana/index.d.ts +0 -8
- package/dist/solana/index.d.ts.map +0 -1
- package/dist/solana/index.js +0 -6
- package/dist/solana/index.js.map +0 -1
- package/dist/solana/swap.d.ts +0 -85
- package/dist/solana/swap.d.ts.map +0 -1
- package/dist/solana/swap.js +0 -173
- package/dist/solana/swap.js.map +0 -1
- package/dist/solana/types.d.ts +0 -126
- package/dist/solana/types.d.ts.map +0 -1
- package/dist/solana/types.js +0 -10
- package/dist/solana/types.js.map +0 -1
- package/dist/solana/wallet.d.ts +0 -83
- package/dist/solana/wallet.d.ts.map +0 -1
- package/dist/solana/wallet.js +0 -164
- package/dist/solana/wallet.js.map +0 -1
- package/dist/solana/x402.d.ts +0 -69
- package/dist/solana/x402.d.ts.map +0 -1
- package/dist/solana/x402.js +0 -154
- package/dist/solana/x402.js.map +0 -1
- package/dist/solver/adapter.d.ts +0 -47
- package/dist/solver/adapter.d.ts.map +0 -1
- package/dist/solver/adapter.js +0 -146
- package/dist/solver/adapter.js.map +0 -1
- package/dist/solver/analyzer.d.ts +0 -48
- package/dist/solver/analyzer.d.ts.map +0 -1
- package/dist/solver/analyzer.js +0 -171
- package/dist/solver/analyzer.js.map +0 -1
- package/dist/solver/builder.d.ts +0 -31
- package/dist/solver/builder.d.ts.map +0 -1
- package/dist/solver/builder.js +0 -60
- package/dist/solver/builder.js.map +0 -1
- package/dist/solver/index.d.ts +0 -22
- package/dist/solver/index.d.ts.map +0 -1
- package/dist/solver/index.js +0 -25
- package/dist/solver/index.js.map +0 -1
- package/dist/solver/types.d.ts +0 -115
- package/dist/solver/types.d.ts.map +0 -1
- package/dist/solver/types.js +0 -10
- package/dist/solver/types.js.map +0 -1
- package/dist/spend-guard/index.d.ts +0 -125
- package/dist/spend-guard/index.d.ts.map +0 -1
- package/dist/spend-guard/index.js +0 -150
- package/dist/spend-guard/index.js.map +0 -1
- package/dist/swap/router/cache.d.ts +0 -13
- package/dist/swap/router/cache.d.ts.map +0 -1
- package/dist/swap/router/cache.js +0 -30
- package/dist/swap/router/cache.js.map +0 -1
- package/dist/swap/router/flashbots.d.ts +0 -10
- package/dist/swap/router/flashbots.d.ts.map +0 -1
- package/dist/swap/router/flashbots.js +0 -43
- package/dist/swap/router/flashbots.js.map +0 -1
- package/dist/swap/router/health.d.ts +0 -17
- package/dist/swap/router/health.d.ts.map +0 -1
- package/dist/swap/router/health.js +0 -38
- package/dist/swap/router/health.js.map +0 -1
- package/dist/swap/router/index.d.ts +0 -10
- package/dist/swap/router/index.d.ts.map +0 -1
- package/dist/swap/router/index.js +0 -10
- package/dist/swap/router/index.js.map +0 -1
- package/dist/swap/router/providers/cowswap.d.ts +0 -11
- package/dist/swap/router/providers/cowswap.d.ts.map +0 -1
- package/dist/swap/router/providers/cowswap.js +0 -79
- package/dist/swap/router/providers/cowswap.js.map +0 -1
- package/dist/swap/router/providers/index.d.ts +0 -20
- package/dist/swap/router/providers/index.d.ts.map +0 -1
- package/dist/swap/router/providers/index.js +0 -32
- package/dist/swap/router/providers/index.js.map +0 -1
- package/dist/swap/router/providers/jupiter.d.ts +0 -12
- package/dist/swap/router/providers/jupiter.d.ts.map +0 -1
- package/dist/swap/router/providers/jupiter.js +0 -73
- package/dist/swap/router/providers/jupiter.js.map +0 -1
- package/dist/swap/router/providers/lifi.d.ts +0 -11
- package/dist/swap/router/providers/lifi.d.ts.map +0 -1
- package/dist/swap/router/providers/lifi.js +0 -123
- package/dist/swap/router/providers/lifi.js.map +0 -1
- package/dist/swap/router/providers/oneinch.d.ts +0 -13
- package/dist/swap/router/providers/oneinch.d.ts.map +0 -1
- package/dist/swap/router/providers/oneinch.js +0 -71
- package/dist/swap/router/providers/oneinch.js.map +0 -1
- package/dist/swap/router/providers/paraswap.d.ts +0 -11
- package/dist/swap/router/providers/paraswap.d.ts.map +0 -1
- package/dist/swap/router/providers/paraswap.js +0 -73
- package/dist/swap/router/providers/paraswap.js.map +0 -1
- package/dist/swap/router/providers/uniswap.d.ts +0 -31
- package/dist/swap/router/providers/uniswap.d.ts.map +0 -1
- package/dist/swap/router/providers/uniswap.js +0 -237
- package/dist/swap/router/providers/uniswap.js.map +0 -1
- package/dist/swap/router/providers/zerox.d.ts +0 -13
- package/dist/swap/router/providers/zerox.d.ts.map +0 -1
- package/dist/swap/router/providers/zerox.js +0 -94
- package/dist/swap/router/providers/zerox.js.map +0 -1
- package/dist/swap/router/router.d.ts +0 -86
- package/dist/swap/router/router.d.ts.map +0 -1
- package/dist/swap/router/router.js +0 -224
- package/dist/swap/router/router.js.map +0 -1
- package/dist/swap/router/rsi/engine.d.ts +0 -60
- package/dist/swap/router/rsi/engine.d.ts.map +0 -1
- package/dist/swap/router/rsi/engine.js +0 -483
- package/dist/swap/router/rsi/engine.js.map +0 -1
- package/dist/swap/router/rsi/index.d.ts +0 -3
- package/dist/swap/router/rsi/index.d.ts.map +0 -1
- package/dist/swap/router/rsi/index.js +0 -3
- package/dist/swap/router/rsi/index.js.map +0 -1
- package/dist/swap/router/rsi/types.d.ts +0 -106
- package/dist/swap/router/rsi/types.d.ts.map +0 -1
- package/dist/swap/router/rsi/types.js +0 -3
- package/dist/swap/router/rsi/types.js.map +0 -1
- package/dist/swap/router/types.d.ts +0 -120
- package/dist/swap/router/types.d.ts.map +0 -1
- package/dist/swap/router/types.js +0 -16
- package/dist/swap/router/types.js.map +0 -1
- package/dist/tax/engine.d.ts +0 -131
- package/dist/tax/engine.d.ts.map +0 -1
- package/dist/tax/engine.js +0 -307
- package/dist/tax/engine.js.map +0 -1
- package/dist/tax/index.d.ts +0 -9
- package/dist/tax/index.d.ts.map +0 -1
- package/dist/tax/index.js +0 -12
- package/dist/tax/index.js.map +0 -1
- package/dist/tax/lots.d.ts +0 -60
- package/dist/tax/lots.d.ts.map +0 -1
- package/dist/tax/lots.js +0 -129
- package/dist/tax/lots.js.map +0 -1
- package/dist/tax/types.d.ts +0 -113
- package/dist/tax/types.d.ts.map +0 -1
- package/dist/tax/types.js +0 -18
- package/dist/tax/types.js.map +0 -1
- package/dist/yield/index.d.ts +0 -26
- package/dist/yield/index.d.ts.map +0 -1
- package/dist/yield/index.js +0 -29
- package/dist/yield/index.js.map +0 -1
- package/dist/yield/rates.d.ts +0 -114
- package/dist/yield/rates.d.ts.map +0 -1
- package/dist/yield/rates.js +0 -351
- package/dist/yield/rates.js.map +0 -1
- package/dist/yield/types.d.ts +0 -134
- package/dist/yield/types.d.ts.map +0 -1
- package/dist/yield/types.js +0 -24
- package/dist/yield/types.js.map +0 -1
- package/dist/yield/vault.d.ts +0 -112
- package/dist/yield/vault.d.ts.map +0 -1
- package/dist/yield/vault.js +0 -264
- package/dist/yield/vault.js.map +0 -1
package/dist/ap2/index.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AP2Client — ISO 20022 / AP2 European Payment Module for agentwallet-sdk
|
|
3
|
-
*
|
|
4
|
-
* Non-custodial AI agent bridge for AP2 payments:
|
|
5
|
-
* - Parse ISO 20022 pacs.008 XML → bridge quote
|
|
6
|
-
* - Sign x402 payment header locally (private key never leaves agent)
|
|
7
|
-
* - Execute USDC → EUR settlement via CCTP V2 (Base → EUR off-ramp)
|
|
8
|
-
*
|
|
9
|
-
* AP2 context:
|
|
10
|
-
* Nexi + Google Cloud MoU (2026): AP2 processes ~2.9T EUR/year across Europe.
|
|
11
|
-
* ISO 20022 is the wire standard. This module makes AI agents first-class
|
|
12
|
-
* European payment participants — non-custodially.
|
|
13
|
-
*
|
|
14
|
-
* @module ap2
|
|
15
|
-
*/
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
// Constants
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
/** USDC decimals (6) */
|
|
20
|
-
const USDC_DECIMALS = 6n;
|
|
21
|
-
const USDC_MULTIPLIER = 10n ** USDC_DECIMALS;
|
|
22
|
-
/** EUR → USDC rate (fallback; production uses Chainlink oracle) */
|
|
23
|
-
const EUR_TO_USDC_RATE = 1.08;
|
|
24
|
-
/** Default facilitator URL */
|
|
25
|
-
const DEFAULT_FACILITATOR_URL = 'http://localhost:8420';
|
|
26
|
-
/** Estimated CCTP V2 settlement time (~20 min) */
|
|
27
|
-
const ESTIMATED_SETTLEMENT_SECONDS = 1200;
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// ISO 20022 pacs.008 XML Builder
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
/**
|
|
32
|
-
* Build a valid ISO 20022 pacs.008 (FIToFICstmrCdtTrf) XML string
|
|
33
|
-
* from simple agent-friendly parameters.
|
|
34
|
-
*
|
|
35
|
-
* @param params - Payment parameters
|
|
36
|
-
* @returns ISO 20022 pacs.008 XML string
|
|
37
|
-
*/
|
|
38
|
-
function buildPacs008(params) {
|
|
39
|
-
const now = params.creationDateTime ?? new Date().toISOString().replace(/\.\d+Z$/, '+00:00');
|
|
40
|
-
const currency = params.currency ?? 'EUR';
|
|
41
|
-
const e2eId = params.endToEndId ?? params.messageId;
|
|
42
|
-
const amount = params.amount.toFixed(2);
|
|
43
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
44
|
-
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08">
|
|
45
|
-
<FIToFICstmrCdtTrf>
|
|
46
|
-
<GrpHdr>
|
|
47
|
-
<MsgId>${escapeXml(params.messageId)}</MsgId>
|
|
48
|
-
<CreDtTm>${escapeXml(now)}</CreDtTm>
|
|
49
|
-
<NbOfTxs>1</NbOfTxs>
|
|
50
|
-
<SttlmInf>
|
|
51
|
-
<SttlmMtd>CLRG</SttlmMtd>
|
|
52
|
-
</SttlmInf>
|
|
53
|
-
</GrpHdr>
|
|
54
|
-
<CdtTrfTxInf>
|
|
55
|
-
<PmtId>
|
|
56
|
-
<EndToEndId>${escapeXml(e2eId)}</EndToEndId>
|
|
57
|
-
</PmtId>
|
|
58
|
-
<IntrBkSttlmAmt Ccy="${escapeXml(currency)}">${amount}</IntrBkSttlmAmt>
|
|
59
|
-
<ChrgBr>SHAR</ChrgBr>
|
|
60
|
-
<Dbtr>
|
|
61
|
-
<Nm>${escapeXml(params.debtorName)}</Nm>
|
|
62
|
-
</Dbtr>
|
|
63
|
-
<DbtrAcct>
|
|
64
|
-
<Id>
|
|
65
|
-
<IBAN>${escapeXml(params.debtorIban.replace(/\s/g, '').toUpperCase())}</IBAN>
|
|
66
|
-
</Id>
|
|
67
|
-
</DbtrAcct>
|
|
68
|
-
<DbtrAgt>
|
|
69
|
-
<FinInstnId>
|
|
70
|
-
<BICFI>${escapeXml(params.debtorBic.toUpperCase())}</BICFI>
|
|
71
|
-
</FinInstnId>
|
|
72
|
-
</DbtrAgt>
|
|
73
|
-
<Cdtr>
|
|
74
|
-
<Nm>${escapeXml(params.creditorName)}</Nm>
|
|
75
|
-
</Cdtr>
|
|
76
|
-
<CdtrAcct>
|
|
77
|
-
<Id>
|
|
78
|
-
<IBAN>${escapeXml(params.creditorIban.replace(/\s/g, '').toUpperCase())}</IBAN>
|
|
79
|
-
</Id>
|
|
80
|
-
</CdtrAcct>
|
|
81
|
-
<CdtrAgt>
|
|
82
|
-
<FinInstnId>
|
|
83
|
-
<BICFI>${escapeXml(params.creditorBic.toUpperCase())}</BICFI>
|
|
84
|
-
</FinInstnId>
|
|
85
|
-
</CdtrAgt>${params.purposeCode ? `
|
|
86
|
-
<Purp>
|
|
87
|
-
<Cd>${escapeXml(params.purposeCode)}</Cd>
|
|
88
|
-
</Purp>` : ''}${params.remittanceInfo ? `
|
|
89
|
-
<RmtInf>
|
|
90
|
-
<Ustrd>${escapeXml(params.remittanceInfo)}</Ustrd>
|
|
91
|
-
</RmtInf>` : ''}
|
|
92
|
-
</CdtTrfTxInf>
|
|
93
|
-
</FIToFICstmrCdtTrf>
|
|
94
|
-
</Document>`;
|
|
95
|
-
}
|
|
96
|
-
/** Escape XML special characters. */
|
|
97
|
-
function escapeXml(str) {
|
|
98
|
-
return str
|
|
99
|
-
.replace(/&/g, '&')
|
|
100
|
-
.replace(/</g, '<')
|
|
101
|
-
.replace(/>/g, '>')
|
|
102
|
-
.replace(/"/g, '"')
|
|
103
|
-
.replace(/'/g, ''');
|
|
104
|
-
}
|
|
105
|
-
/** Convert a decimal USDC string to bigint μUSDC. */
|
|
106
|
-
function usdcToBigInt(usdcStr) {
|
|
107
|
-
const [whole, frac = ''] = usdcStr.split('.');
|
|
108
|
-
const fracPadded = frac.padEnd(Number(USDC_DECIMALS), '0').slice(0, Number(USDC_DECIMALS));
|
|
109
|
-
return BigInt(whole) * USDC_MULTIPLIER + BigInt(fracPadded);
|
|
110
|
-
}
|
|
111
|
-
// ---------------------------------------------------------------------------
|
|
112
|
-
// AP2Client
|
|
113
|
-
// ---------------------------------------------------------------------------
|
|
114
|
-
/**
|
|
115
|
-
* AP2Client — Non-custodial ISO 20022 / AP2 payment client for AI agents.
|
|
116
|
-
*
|
|
117
|
-
* Connects to the AP2 facilitator (ap2_handler.py FastAPI service) to
|
|
118
|
-
* get bridge quotes and execute payments via CCTP V2 / x402.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* const client = new AP2Client({ facilitatorUrl: 'http://localhost:8420' });
|
|
123
|
-
*
|
|
124
|
-
* const xml = AP2Client.buildPacs008({
|
|
125
|
-
* messageId: 'MSG-2026-0001',
|
|
126
|
-
* amount: 1000,
|
|
127
|
-
* debtorName: 'Agent Zero',
|
|
128
|
-
* debtorIban: 'DE89370400440532013000',
|
|
129
|
-
* debtorBic: 'COBADEFFXXX',
|
|
130
|
-
* creditorName: 'Acme GmbH',
|
|
131
|
-
* creditorIban: 'FR7630006000011234567890189',
|
|
132
|
-
* creditorBic: 'BNPAFRPPXXX',
|
|
133
|
-
* });
|
|
134
|
-
*
|
|
135
|
-
* const quote = await client.quote(xml);
|
|
136
|
-
* const receipt = await client.pay(xml);
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
export class AP2Client {
|
|
140
|
-
constructor(config = {}) {
|
|
141
|
-
this.facilitatorUrl = (config.facilitatorUrl ?? DEFAULT_FACILITATOR_URL).replace(/\/$/, '');
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Parse ISO 20022 pacs.008 XML and get a bridge quote from the facilitator.
|
|
145
|
-
*
|
|
146
|
-
* @param iso20022Xml - Raw pacs.008 XML string
|
|
147
|
-
* @returns AP2Quote with USDC amounts and x402 calldata
|
|
148
|
-
* @throws Error if the facilitator returns an error or the XML is invalid
|
|
149
|
-
*/
|
|
150
|
-
async quote(iso20022Xml) {
|
|
151
|
-
const response = await fetch(`${this.facilitatorUrl}/ap2/payment`, {
|
|
152
|
-
method: 'POST',
|
|
153
|
-
headers: { 'Content-Type': 'application/xml' },
|
|
154
|
-
body: iso20022Xml,
|
|
155
|
-
});
|
|
156
|
-
if (!response.ok) {
|
|
157
|
-
const body = await response.text();
|
|
158
|
-
throw new AP2Error(`Quote failed (${response.status}): ${body}`);
|
|
159
|
-
}
|
|
160
|
-
const json = (await response.json());
|
|
161
|
-
const bq = json.bridge_quote;
|
|
162
|
-
const payment = json.payment;
|
|
163
|
-
return {
|
|
164
|
-
messageId: payment.message_id,
|
|
165
|
-
creditorIban: payment.creditor.iban,
|
|
166
|
-
amountEur: parseFloat(payment.amount),
|
|
167
|
-
usdcRequired: usdcToBigInt(bq.usdc_amount),
|
|
168
|
-
bridgeFeeUsdc: usdcToBigInt(bq.bridge_fee_usdc),
|
|
169
|
-
estimatedSettlementSeconds: ESTIMATED_SETTLEMENT_SECONDS,
|
|
170
|
-
x402PaymentHeader: bq.x402_payment_header,
|
|
171
|
-
agentWalletCalldata: bq.agent_wallet_calldata,
|
|
172
|
-
expiresAt: bq.expires_at,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Execute the full AP2 payment: sign x402 header + bridge USDC + settle.
|
|
177
|
-
*
|
|
178
|
-
* Calls the /ap2/execute endpoint on the facilitator, which:
|
|
179
|
-
* 1. Parses the XML
|
|
180
|
-
* 2. Signs x402 header with agent's private key (server-side in this flow)
|
|
181
|
-
* 3. Submits USDC to CCTP V2 bridge
|
|
182
|
-
* 4. Returns receipt
|
|
183
|
-
*
|
|
184
|
-
* @param iso20022Xml - Raw pacs.008 XML string
|
|
185
|
-
* @returns AP2Receipt with txHash and SEPA reference
|
|
186
|
-
* @throws AP2Error on execution failure
|
|
187
|
-
*/
|
|
188
|
-
async pay(iso20022Xml) {
|
|
189
|
-
const response = await fetch(`${this.facilitatorUrl}/ap2/execute`, {
|
|
190
|
-
method: 'POST',
|
|
191
|
-
headers: { 'Content-Type': 'application/xml' },
|
|
192
|
-
body: iso20022Xml,
|
|
193
|
-
});
|
|
194
|
-
if (!response.ok) {
|
|
195
|
-
const body = await response.text();
|
|
196
|
-
throw new AP2Error(`Execution failed (${response.status}): ${body}`);
|
|
197
|
-
}
|
|
198
|
-
const json = (await response.json());
|
|
199
|
-
const r = json.receipt;
|
|
200
|
-
return {
|
|
201
|
-
messageId: r.message_id,
|
|
202
|
-
txHash: r.tx_hash,
|
|
203
|
-
usdcBridged: usdcToBigInt(r.usdc_bridged),
|
|
204
|
-
sepaReference: r.sepa_reference,
|
|
205
|
-
status: r.status,
|
|
206
|
-
dryRun: r.dry_run,
|
|
207
|
-
x402Signature: r.x402_signature,
|
|
208
|
-
agentAddress: r.agent_address,
|
|
209
|
-
nonce: r.nonce,
|
|
210
|
-
executedAt: r.executed_at,
|
|
211
|
-
creditorIban: r.creditor_iban,
|
|
212
|
-
bridgeFeeUsdc: usdcToBigInt(r.bridge_fee_usdc),
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Generate a valid ISO 20022 pacs.008 XML string from simple parameters.
|
|
217
|
-
*
|
|
218
|
-
* Handles XML escaping, IBAN normalization, and timestamp formatting.
|
|
219
|
-
* Makes AP2 payments agent-friendly — no ISO 20022 expertise required.
|
|
220
|
-
*
|
|
221
|
-
* @param params - Simple payment parameters
|
|
222
|
-
* @returns Valid pacs.008 XML string
|
|
223
|
-
*/
|
|
224
|
-
static buildPacs008(params) {
|
|
225
|
-
return buildPacs008(params);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Estimate USDC required for a given EUR amount.
|
|
229
|
-
*
|
|
230
|
-
* Uses the default EUR/USDC rate. For accurate quotes, call quote() instead.
|
|
231
|
-
*
|
|
232
|
-
* @param amountEur - Amount in EUR
|
|
233
|
-
* @returns Estimated USDC amount as bigint (μUSDC, 6 decimals)
|
|
234
|
-
*/
|
|
235
|
-
static estimateUsdc(amountEur) {
|
|
236
|
-
const usdc = amountEur * EUR_TO_USDC_RATE;
|
|
237
|
-
return BigInt(Math.round(usdc * Number(USDC_MULTIPLIER)));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// ---------------------------------------------------------------------------
|
|
241
|
-
// Error class
|
|
242
|
-
// ---------------------------------------------------------------------------
|
|
243
|
-
/** AP2-specific error with structured context. */
|
|
244
|
-
export class AP2Error extends Error {
|
|
245
|
-
constructor(message, context) {
|
|
246
|
-
super(message);
|
|
247
|
-
this.context = context;
|
|
248
|
-
this.name = 'AP2Error';
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// ---------------------------------------------------------------------------
|
|
252
|
-
// Re-export builder as standalone function
|
|
253
|
-
// ---------------------------------------------------------------------------
|
|
254
|
-
export { buildPacs008 };
|
|
255
|
-
//# sourceMappingURL=index.js.map
|
package/dist/ap2/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ap2/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiIH,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,wBAAwB;AACxB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,eAAe,GAAG,GAAG,IAAI,aAAa,CAAC;AAE7C,mEAAmE;AACnE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAExD,kDAAkD;AAClD,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAE1C,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,MAAwB;IAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7F,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC;IACpD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAExC,OAAO;;;;eAIM,SA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ACxC,MAAM,EAAE,CAAC,CAAC,OAAO;YACjB,aAAa,EAAE,CAAC,CAAC,cAAc;YAC/B,YAAY,EAAE,CAAC,CAAC,aAAa;YAC7B,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,UAAU,EAAE,CAAC,CAAC,WAAW;YACzB,YAAY,EAAE,CAAC,CAAC,aAAa;YAC7B,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC;SAC/C,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,YAAY,CAAC,MAAwB;QAC1C,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAiB;QACnC,MAAM,IAAI,GAAG,SAAS,GAAG,gBAAgB,CAAC;QAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF;AAED,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,kDAAkD;AAClD,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,YAAY,OAAe,EAAkB,OAAiC;QAC5E,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,YAAO,GAAP,OAAO,CAA0B;QAE5E,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,8EAA8E;AAC9E,2CAA2C;AAC3C,8EAA8E;AAE9E,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/bridge/unified.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { WalletClient } from 'viem';
|
|
2
|
-
import type { Keypair } from '@solana/web3.js';
|
|
3
|
-
import { BridgeError } from './client.js';
|
|
4
|
-
import type { BridgeChain, BridgeResult } from './types.js';
|
|
5
|
-
import { type CCTPSupportedChain, type BridgeQuote, CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee } from './types.js';
|
|
6
|
-
import { SolanaBridgeError } from '../solana/bridge.js';
|
|
7
|
-
export interface UnifiedBridgeConfig {
|
|
8
|
-
/** EVM wallet client (required for any EVM source chain) */
|
|
9
|
-
evmSigner?: WalletClient;
|
|
10
|
-
/** Solana keypair (required when Solana is source) */
|
|
11
|
-
solanaWallet?: Keypair;
|
|
12
|
-
/** Solana RPC URL (default: mainnet-beta public) */
|
|
13
|
-
solanaRpcUrl?: string;
|
|
14
|
-
/** Override EVM RPC URLs per chain */
|
|
15
|
-
evmRpcOverrides?: Partial<Record<BridgeChain, string>>;
|
|
16
|
-
/** Circle attestation API override */
|
|
17
|
-
attestationApiUrl?: string;
|
|
18
|
-
/** Platform fee wallet address (future: fee collection) */
|
|
19
|
-
feeWallet?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface UnifiedBridgeParams {
|
|
22
|
-
/** USDC amount in base units (6 decimals). 1 USDC = 1_000_000 */
|
|
23
|
-
amount: bigint;
|
|
24
|
-
/** Source chain */
|
|
25
|
-
sourceChain: CCTPSupportedChain;
|
|
26
|
-
/** Destination chain */
|
|
27
|
-
destinationChain: CCTPSupportedChain;
|
|
28
|
-
/** Recipient address (hex for EVM, base58 for Solana destination) */
|
|
29
|
-
destinationAddress: string;
|
|
30
|
-
/** Finality: 0 = fast (~20s), 1000 = finalized (~15min) */
|
|
31
|
-
minFinalityThreshold?: number;
|
|
32
|
-
/** Apply 0.1% platform fee (default: true) */
|
|
33
|
-
applyPlatformFee?: boolean;
|
|
34
|
-
/** Override destination RPC URL */
|
|
35
|
-
destinationRpcUrl?: string;
|
|
36
|
-
}
|
|
37
|
-
export type { BridgeResult, BridgeQuote, CCTPSupportedChain };
|
|
38
|
-
/**
|
|
39
|
-
* UnifiedBridge — Cross-chain USDC bridge across all 17 CCTP V2 supported chains.
|
|
40
|
-
*
|
|
41
|
-
* Routing:
|
|
42
|
-
* - EVM → EVM: BridgeModule (approve → burn → attest → mint)
|
|
43
|
-
* - EVM → Solana: BridgeModule burn + SolanaCCTPBridge receive
|
|
44
|
-
* - Solana → EVM: SolanaCCTPBridge burn + EVM receiveMessage
|
|
45
|
-
* - Solana → Solana: throws (use native Solana transfer instead)
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* import { UnifiedBridge } from 'agentwallet-sdk';
|
|
50
|
-
* import { createWalletClient } from 'viem';
|
|
51
|
-
*
|
|
52
|
-
* const bridge = new UnifiedBridge({ evmSigner });
|
|
53
|
-
*
|
|
54
|
-
* // Bridge 1 USDC from Base to Polygon
|
|
55
|
-
* const result = await bridge.bridge({
|
|
56
|
-
* amount: 1_000_000n,
|
|
57
|
-
* sourceChain: 'base',
|
|
58
|
-
* destinationChain: 'polygon',
|
|
59
|
-
* destinationAddress: '0x...',
|
|
60
|
-
* });
|
|
61
|
-
* console.log(bridge.getSupportedChains()); // 17 chains!
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export declare class UnifiedBridge {
|
|
65
|
-
private readonly config;
|
|
66
|
-
private readonly solanaConnection;
|
|
67
|
-
constructor(config?: UnifiedBridgeConfig);
|
|
68
|
-
/**
|
|
69
|
-
* Bridge USDC between any two CCTP V2 supported chains.
|
|
70
|
-
* Routes automatically based on source/destination chain types.
|
|
71
|
-
*/
|
|
72
|
-
bridge(params: UnifiedBridgeParams): Promise<BridgeResult>;
|
|
73
|
-
/**
|
|
74
|
-
* Get all supported chains (16 EVM + Solana = 17 total).
|
|
75
|
-
*/
|
|
76
|
-
getSupportedChains(): CCTPSupportedChain[];
|
|
77
|
-
/**
|
|
78
|
-
* Get a bridge quote: fee breakdown + estimated time.
|
|
79
|
-
*/
|
|
80
|
-
getQuote(params: {
|
|
81
|
-
amount: bigint;
|
|
82
|
-
sourceChain: CCTPSupportedChain;
|
|
83
|
-
destinationChain: CCTPSupportedChain;
|
|
84
|
-
}): BridgeQuote;
|
|
85
|
-
/**
|
|
86
|
-
* Check if a route is supported.
|
|
87
|
-
*/
|
|
88
|
-
isRouteSupported(source: CCTPSupportedChain, destination: CCTPSupportedChain): boolean;
|
|
89
|
-
private bridgeEvmToEvm;
|
|
90
|
-
private bridgeSolanaToEvm;
|
|
91
|
-
private bridgeEvmToSolana;
|
|
92
|
-
private validateParams;
|
|
93
|
-
/**
|
|
94
|
-
* Convert a Solana base58 address to a 32-byte hex string for EVM mintRecipient.
|
|
95
|
-
* Per Circle docs: hex-encoded USDC token account address.
|
|
96
|
-
*/
|
|
97
|
-
private solanaAddressToHex;
|
|
98
|
-
}
|
|
99
|
-
export { BridgeError, SolanaBridgeError };
|
|
100
|
-
export { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee, };
|
|
101
|
-
//# sourceMappingURL=unified.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/bridge/unified.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAgB,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EAEf,aAAa,EAGd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAoB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAA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AiB;YA4EjB,iBAAiB;IAoF/B,OAAO,CAAC,cAAc;IAsCtB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAkB3B;AAID,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,CAAC"}
|
package/dist/bridge/unified.js
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
// [MAX-ADDED] UnifiedBridge — Single interface for CCTP V2 transfers across all 17 chains
|
|
2
|
-
// Routes EVM↔EVM, EVM→Solana, and Solana→EVM via BridgeModule + SolanaCCTPBridge.
|
|
3
|
-
//
|
|
4
|
-
// Supported: 16 EVM chains + Solana (17 total)
|
|
5
|
-
// Fee: 0.1% platform fee on bridged amount
|
|
6
|
-
//
|
|
7
|
-
// Usage:
|
|
8
|
-
// const bridge = new UnifiedBridge({ evmSigner: walletClient, solanaWallet: keypair });
|
|
9
|
-
// await bridge.bridge({ amount: 1_000_000n, sourceChain: 'base', destinationChain: 'polygon', destinationAddress: '0x...' });
|
|
10
|
-
import { Connection } from '@solana/web3.js';
|
|
11
|
-
import { BridgeModule, BridgeError } from './client.js';
|
|
12
|
-
import { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee, getEstimatedBridgeSeconds, FAST_TRANSFER_CHAINS, } from './types.js';
|
|
13
|
-
import { SolanaCCTPBridge, SolanaBridgeError } from '../solana/bridge.js';
|
|
14
|
-
// ─── UnifiedBridge ───
|
|
15
|
-
/**
|
|
16
|
-
* UnifiedBridge — Cross-chain USDC bridge across all 17 CCTP V2 supported chains.
|
|
17
|
-
*
|
|
18
|
-
* Routing:
|
|
19
|
-
* - EVM → EVM: BridgeModule (approve → burn → attest → mint)
|
|
20
|
-
* - EVM → Solana: BridgeModule burn + SolanaCCTPBridge receive
|
|
21
|
-
* - Solana → EVM: SolanaCCTPBridge burn + EVM receiveMessage
|
|
22
|
-
* - Solana → Solana: throws (use native Solana transfer instead)
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { UnifiedBridge } from 'agentwallet-sdk';
|
|
27
|
-
* import { createWalletClient } from 'viem';
|
|
28
|
-
*
|
|
29
|
-
* const bridge = new UnifiedBridge({ evmSigner });
|
|
30
|
-
*
|
|
31
|
-
* // Bridge 1 USDC from Base to Polygon
|
|
32
|
-
* const result = await bridge.bridge({
|
|
33
|
-
* amount: 1_000_000n,
|
|
34
|
-
* sourceChain: 'base',
|
|
35
|
-
* destinationChain: 'polygon',
|
|
36
|
-
* destinationAddress: '0x...',
|
|
37
|
-
* });
|
|
38
|
-
* console.log(bridge.getSupportedChains()); // 17 chains!
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export class UnifiedBridge {
|
|
42
|
-
constructor(config = {}) {
|
|
43
|
-
this.config = config;
|
|
44
|
-
this.solanaConnection = new Connection(config.solanaRpcUrl ?? 'https://api.mainnet-beta.solana.com', 'confirmed');
|
|
45
|
-
}
|
|
46
|
-
// ─── Public API ───
|
|
47
|
-
/**
|
|
48
|
-
* Bridge USDC between any two CCTP V2 supported chains.
|
|
49
|
-
* Routes automatically based on source/destination chain types.
|
|
50
|
-
*/
|
|
51
|
-
async bridge(params) {
|
|
52
|
-
const { amount, sourceChain, destinationChain, destinationAddress, minFinalityThreshold = 0, applyPlatformFee = true, destinationRpcUrl, } = params;
|
|
53
|
-
// Validate before routing (catches unsupported chains, zero amount)
|
|
54
|
-
// Check Solana→Solana before generic same-chain to give the right error code
|
|
55
|
-
const isSolanaSource = sourceChain === 'solana';
|
|
56
|
-
const isSolanaDestination = destinationChain === 'solana';
|
|
57
|
-
if (isSolanaSource && isSolanaDestination) {
|
|
58
|
-
throw new BridgeError('UNSUPPORTED_ROUTE', 'Solana → Solana bridging is not supported. Use native Solana transfers instead.');
|
|
59
|
-
}
|
|
60
|
-
this.validateParams(amount, sourceChain, destinationChain);
|
|
61
|
-
if (!isSolanaSource && !isSolanaDestination) {
|
|
62
|
-
// EVM → EVM
|
|
63
|
-
return this.bridgeEvmToEvm({
|
|
64
|
-
amount,
|
|
65
|
-
sourceChain: sourceChain,
|
|
66
|
-
destinationChain: destinationChain,
|
|
67
|
-
destinationAddress,
|
|
68
|
-
minFinalityThreshold,
|
|
69
|
-
applyPlatformFee,
|
|
70
|
-
destinationRpcUrl,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (isSolanaSource && !isSolanaDestination) {
|
|
74
|
-
// Solana → EVM
|
|
75
|
-
return this.bridgeSolanaToEvm({
|
|
76
|
-
amount,
|
|
77
|
-
destinationChain: destinationChain,
|
|
78
|
-
destinationAddress,
|
|
79
|
-
minFinalityThreshold,
|
|
80
|
-
applyPlatformFee,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
// EVM → Solana
|
|
84
|
-
return this.bridgeEvmToSolana({
|
|
85
|
-
amount,
|
|
86
|
-
sourceChain: sourceChain,
|
|
87
|
-
destinationAddress,
|
|
88
|
-
minFinalityThreshold,
|
|
89
|
-
applyPlatformFee,
|
|
90
|
-
destinationRpcUrl,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get all supported chains (16 EVM + Solana = 17 total).
|
|
95
|
-
*/
|
|
96
|
-
getSupportedChains() {
|
|
97
|
-
return Object.keys(CCTP_DOMAIN_IDS);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get a bridge quote: fee breakdown + estimated time.
|
|
101
|
-
*/
|
|
102
|
-
getQuote(params) {
|
|
103
|
-
const { amount, sourceChain, destinationChain } = params;
|
|
104
|
-
if (amount <= 0n) {
|
|
105
|
-
throw new BridgeError('INVALID_AMOUNT', 'Quote amount must be > 0');
|
|
106
|
-
}
|
|
107
|
-
const platformFee = calcBridgeFee(amount);
|
|
108
|
-
const outputAmount = amount - platformFee;
|
|
109
|
-
const estimatedTimeSeconds = getEstimatedBridgeSeconds(sourceChain);
|
|
110
|
-
const fastTransferAvailable = FAST_TRANSFER_CHAINS.has(sourceChain);
|
|
111
|
-
return {
|
|
112
|
-
inputAmount: amount,
|
|
113
|
-
platformFee,
|
|
114
|
-
outputAmount,
|
|
115
|
-
fromChain: sourceChain,
|
|
116
|
-
toChain: destinationChain,
|
|
117
|
-
estimatedTimeSeconds,
|
|
118
|
-
fastTransferAvailable,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Check if a route is supported.
|
|
123
|
-
*/
|
|
124
|
-
isRouteSupported(source, destination) {
|
|
125
|
-
if (source === destination)
|
|
126
|
-
return false;
|
|
127
|
-
if (source === 'solana' && destination === 'solana')
|
|
128
|
-
return false;
|
|
129
|
-
return source in CCTP_DOMAIN_IDS && destination in CCTP_DOMAIN_IDS;
|
|
130
|
-
}
|
|
131
|
-
// ─── Internal Routing ───
|
|
132
|
-
async bridgeEvmToEvm(params) {
|
|
133
|
-
const { sourceChain, destinationChain } = params;
|
|
134
|
-
if (!this.config.evmSigner) {
|
|
135
|
-
throw new BridgeError('NO_WALLET_CLIENT', `EVM wallet client required for EVM→EVM bridge (${sourceChain} → ${destinationChain}). ` +
|
|
136
|
-
`Pass evmSigner to UnifiedBridge constructor.`);
|
|
137
|
-
}
|
|
138
|
-
const rpcOverride = this.config.evmRpcOverrides?.[sourceChain];
|
|
139
|
-
const bridge = new BridgeModule(this.config.evmSigner, sourceChain, { rpcUrl: rpcOverride });
|
|
140
|
-
return bridge.bridge(params.amount, destinationChain, {
|
|
141
|
-
destinationAddress: params.destinationAddress,
|
|
142
|
-
minFinalityThreshold: params.minFinalityThreshold,
|
|
143
|
-
applyPlatformFee: params.applyPlatformFee,
|
|
144
|
-
destinationRpcUrl: params.destinationRpcUrl ?? this.config.evmRpcOverrides?.[destinationChain],
|
|
145
|
-
attestationApiUrl: this.config.attestationApiUrl,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
async bridgeSolanaToEvm(params) {
|
|
149
|
-
const startMs = Date.now();
|
|
150
|
-
if (!this.config.solanaWallet) {
|
|
151
|
-
throw new SolanaBridgeError('NO_SOLANA_WALLET', 'Solana keypair required for Solana→EVM bridge. ' +
|
|
152
|
-
'Pass solanaWallet to UnifiedBridge constructor.');
|
|
153
|
-
}
|
|
154
|
-
if (!this.config.evmSigner) {
|
|
155
|
-
throw new BridgeError('NO_WALLET_CLIENT', 'EVM wallet client required to receive on destination EVM chain. ' +
|
|
156
|
-
'Pass evmSigner to UnifiedBridge constructor.');
|
|
157
|
-
}
|
|
158
|
-
const applyFee = params.applyPlatformFee !== false;
|
|
159
|
-
const platformFee = applyFee ? calcBridgeFee(params.amount) : 0n;
|
|
160
|
-
const bridgeAmount = params.amount - platformFee;
|
|
161
|
-
// Phase 1: Burn on Solana
|
|
162
|
-
const solanaBridge = new SolanaCCTPBridge({
|
|
163
|
-
connection: this.solanaConnection,
|
|
164
|
-
payer: this.config.solanaWallet,
|
|
165
|
-
});
|
|
166
|
-
const burnResult = await solanaBridge.depositForBurn({
|
|
167
|
-
amount: bridgeAmount,
|
|
168
|
-
destinationChain: params.destinationChain,
|
|
169
|
-
destinationAddress: params.destinationAddress,
|
|
170
|
-
minFinalityThreshold: params.minFinalityThreshold,
|
|
171
|
-
});
|
|
172
|
-
// Phase 2: Poll attestation (Solana uses same IRIS API)
|
|
173
|
-
const attestation = await solanaBridge.waitForAttestation(burnResult.messageHash, this.config.attestationApiUrl);
|
|
174
|
-
// Phase 3: Mint on EVM destination
|
|
175
|
-
const rpcOverride = this.config.evmRpcOverrides?.[params.destinationChain];
|
|
176
|
-
const evmBridge = new BridgeModule(this.config.evmSigner, params.destinationChain, // use dest as source for the receive-only operation
|
|
177
|
-
{ rpcUrl: rpcOverride });
|
|
178
|
-
const evmMintTxHash = await evmBridge.mint(burnResult.messageBytes, attestation, params.destinationChain, rpcOverride);
|
|
179
|
-
return {
|
|
180
|
-
burnTxHash: burnResult.signature,
|
|
181
|
-
mintTxHash: evmMintTxHash,
|
|
182
|
-
amount: bridgeAmount,
|
|
183
|
-
platformFee,
|
|
184
|
-
fromChain: 'solana',
|
|
185
|
-
toChain: params.destinationChain,
|
|
186
|
-
recipient: params.destinationAddress,
|
|
187
|
-
nonce: burnResult.nonce,
|
|
188
|
-
elapsedMs: Date.now() - startMs,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
async bridgeEvmToSolana(params) {
|
|
192
|
-
const startMs = Date.now();
|
|
193
|
-
if (!this.config.evmSigner) {
|
|
194
|
-
throw new BridgeError('NO_WALLET_CLIENT', `EVM wallet client required for ${params.sourceChain}→Solana bridge.`);
|
|
195
|
-
}
|
|
196
|
-
if (!this.config.solanaWallet) {
|
|
197
|
-
throw new SolanaBridgeError('NO_SOLANA_WALLET', 'Solana keypair required to receive USDC on Solana. ' +
|
|
198
|
-
'Pass solanaWallet to UnifiedBridge constructor.');
|
|
199
|
-
}
|
|
200
|
-
const applyFee = params.applyPlatformFee !== false;
|
|
201
|
-
const platformFee = applyFee ? calcBridgeFee(params.amount) : 0n;
|
|
202
|
-
const bridgeAmount = params.amount - platformFee;
|
|
203
|
-
// Solana destination: mintRecipient must be hex of USDC ATA on Solana
|
|
204
|
-
// The caller passes a base58 Solana address; we convert to hex for EVM depositForBurn
|
|
205
|
-
const solanaAddressHex = this.solanaAddressToHex(params.destinationAddress);
|
|
206
|
-
// Phase 1: Burn on EVM (using CCTP domain 5 for Solana)
|
|
207
|
-
const rpcOverride = this.config.evmRpcOverrides?.[params.sourceChain];
|
|
208
|
-
const evmBridge = new BridgeModule(this.config.evmSigner, params.sourceChain, { rpcUrl: rpcOverride });
|
|
209
|
-
const burnResult = await evmBridge.burn(bridgeAmount, 'solana', {
|
|
210
|
-
destinationAddress: solanaAddressHex,
|
|
211
|
-
minFinalityThreshold: params.minFinalityThreshold,
|
|
212
|
-
applyPlatformFee: false, // already deducted
|
|
213
|
-
attestationApiUrl: this.config.attestationApiUrl,
|
|
214
|
-
});
|
|
215
|
-
// Phase 2: Attestation
|
|
216
|
-
const attestation = await evmBridge.waitForAttestation(burnResult.messageHash, this.config.attestationApiUrl);
|
|
217
|
-
// Phase 3: Receive on Solana
|
|
218
|
-
const solanaBridge = new SolanaCCTPBridge({
|
|
219
|
-
connection: this.solanaConnection,
|
|
220
|
-
payer: this.config.solanaWallet,
|
|
221
|
-
});
|
|
222
|
-
// Ensure recipient USDC ATA exists
|
|
223
|
-
const recipientUsdcAta = await solanaBridge.ensureUsdcAta();
|
|
224
|
-
const solanaMintSig = await solanaBridge.receiveMessage({
|
|
225
|
-
message: burnResult.messageBytes,
|
|
226
|
-
attestation,
|
|
227
|
-
recipientUsdcAccount: recipientUsdcAta.toString(),
|
|
228
|
-
});
|
|
229
|
-
return {
|
|
230
|
-
burnTxHash: burnResult.burnTxHash,
|
|
231
|
-
mintTxHash: solanaMintSig,
|
|
232
|
-
amount: bridgeAmount,
|
|
233
|
-
platformFee,
|
|
234
|
-
fromChain: params.sourceChain,
|
|
235
|
-
toChain: 'solana',
|
|
236
|
-
recipient: params.destinationAddress,
|
|
237
|
-
nonce: burnResult.nonce,
|
|
238
|
-
elapsedMs: Date.now() - startMs,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
// ─── Validation ───
|
|
242
|
-
validateParams(amount, sourceChain, destinationChain) {
|
|
243
|
-
if (amount <= 0n) {
|
|
244
|
-
throw new BridgeError('INVALID_AMOUNT', `Amount must be > 0. Got ${amount}. Use USDC base units (1 USDC = 1_000_000).`);
|
|
245
|
-
}
|
|
246
|
-
if (!(sourceChain in CCTP_DOMAIN_IDS)) {
|
|
247
|
-
throw new BridgeError('UNSUPPORTED_CHAIN', `Source chain '${sourceChain}' is not supported. ` +
|
|
248
|
-
`Supported: ${Object.keys(CCTP_DOMAIN_IDS).join(', ')}`);
|
|
249
|
-
}
|
|
250
|
-
if (!(destinationChain in CCTP_DOMAIN_IDS)) {
|
|
251
|
-
throw new BridgeError('UNSUPPORTED_CHAIN', `Destination chain '${destinationChain}' is not supported. ` +
|
|
252
|
-
`Supported: ${Object.keys(CCTP_DOMAIN_IDS).join(', ')}`);
|
|
253
|
-
}
|
|
254
|
-
if (sourceChain === destinationChain) {
|
|
255
|
-
throw new BridgeError('SAME_CHAIN', `Source and destination must differ. Both set to '${sourceChain}'.`);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
// ─── Helpers ───
|
|
259
|
-
/**
|
|
260
|
-
* Convert a Solana base58 address to a 32-byte hex string for EVM mintRecipient.
|
|
261
|
-
* Per Circle docs: hex-encoded USDC token account address.
|
|
262
|
-
*/
|
|
263
|
-
solanaAddressToHex(base58Address) {
|
|
264
|
-
// bs58 decode → hex encode
|
|
265
|
-
// Import dynamically to avoid requiring bs58 for EVM-only users
|
|
266
|
-
try {
|
|
267
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
268
|
-
const bs58 = require('bs58');
|
|
269
|
-
const decoded = bs58.decode(base58Address);
|
|
270
|
-
return '0x' + Buffer.from(decoded).toString('hex').padStart(64, '0');
|
|
271
|
-
}
|
|
272
|
-
catch {
|
|
273
|
-
// If bs58 not available, assume it's already hex
|
|
274
|
-
if (base58Address.startsWith('0x'))
|
|
275
|
-
return base58Address;
|
|
276
|
-
throw new BridgeError('UNSUPPORTED_CHAIN', `Could not convert Solana address to hex: ${base58Address}. ` +
|
|
277
|
-
`Pass the USDC ATA address (base58) for Solana destination.`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
// ─── Re-exports ───
|
|
282
|
-
export { BridgeError, SolanaBridgeError };
|
|
283
|
-
export { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee, };
|
|
284
|
-
//# sourceMappingURL=unified.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/bridge/unified.ts"],"names":[],"mappings":"AAAA,0FAA0F;AA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