agentwallet-sdk 2.3.0 → 2.4.1
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/dist/bridge/__tests__/bridge.test.d.ts +2 -0
- package/dist/bridge/__tests__/bridge.test.d.ts.map +1 -0
- package/dist/bridge/__tests__/bridge.test.js +508 -0
- package/dist/bridge/__tests__/bridge.test.js.map +1 -0
- package/dist/bridge/abis.d.ts +187 -0
- package/dist/bridge/abis.d.ts.map +1 -0
- package/dist/bridge/abis.js +129 -0
- package/dist/bridge/abis.js.map +1 -0
- package/dist/bridge/client.d.ts +106 -0
- package/dist/bridge/client.d.ts.map +1 -0
- package/dist/bridge/client.js +393 -0
- package/dist/bridge/client.js.map +1 -0
- package/dist/bridge/index.d.ts +4 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +4 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/types.d.ts +107 -0
- package/dist/bridge/types.d.ts.map +1 -0
- package/dist/bridge/types.js +58 -0
- package/dist/bridge/types.js.map +1 -0
- package/dist/index.d.ts +504 -213
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/swap/SwapModule.d.ts +75 -0
- package/dist/swap/SwapModule.d.ts.map +1 -0
- package/dist/swap/SwapModule.js +267 -0
- package/dist/swap/SwapModule.js.map +1 -0
- package/dist/swap/__tests__/swap.test.d.ts +2 -0
- package/dist/swap/__tests__/swap.test.d.ts.map +1 -0
- package/dist/swap/__tests__/swap.test.js +272 -0
- package/dist/swap/__tests__/swap.test.js.map +1 -0
- package/dist/swap/abi.d.ts +169 -0
- package/dist/swap/abi.d.ts.map +1 -0
- package/dist/swap/abi.js +118 -0
- package/dist/swap/abi.js.map +1 -0
- package/dist/swap/index.d.ts +5 -0
- package/dist/swap/index.d.ts.map +1 -0
- package/dist/swap/index.js +5 -0
- package/dist/swap/index.js.map +1 -0
- package/dist/swap/types.d.ts +79 -0
- package/dist/swap/types.d.ts.map +1 -0
- package/dist/swap/types.js +18 -0
- package/dist/swap/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CCTP V2 TokenMessengerV2 ABI (source chain)
|
|
3
|
+
* Key function: depositForBurn — burns USDC and emits a MessageSent event
|
|
4
|
+
*/
|
|
5
|
+
export declare const TokenMessengerV2Abi: readonly [{
|
|
6
|
+
readonly name: "depositForBurn";
|
|
7
|
+
readonly type: "function";
|
|
8
|
+
readonly stateMutability: "nonpayable";
|
|
9
|
+
readonly inputs: readonly [{
|
|
10
|
+
readonly name: "amount";
|
|
11
|
+
readonly type: "uint256";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "destinationDomain";
|
|
14
|
+
readonly type: "uint32";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "mintRecipient";
|
|
17
|
+
readonly type: "bytes32";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "burnToken";
|
|
20
|
+
readonly type: "address";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "destinationCaller";
|
|
23
|
+
readonly type: "bytes32";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "maxFee";
|
|
26
|
+
readonly type: "uint256";
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "minFinalityThreshold";
|
|
29
|
+
readonly type: "uint32";
|
|
30
|
+
}];
|
|
31
|
+
readonly outputs: readonly [{
|
|
32
|
+
readonly name: "nonce";
|
|
33
|
+
readonly type: "uint64";
|
|
34
|
+
}];
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "depositForBurnWithHook";
|
|
37
|
+
readonly type: "function";
|
|
38
|
+
readonly stateMutability: "nonpayable";
|
|
39
|
+
readonly inputs: readonly [{
|
|
40
|
+
readonly name: "amount";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "destinationDomain";
|
|
44
|
+
readonly type: "uint32";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "mintRecipient";
|
|
47
|
+
readonly type: "bytes32";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "burnToken";
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "destinationCaller";
|
|
53
|
+
readonly type: "bytes32";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "maxFee";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "minFinalityThreshold";
|
|
59
|
+
readonly type: "uint32";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "hookData";
|
|
62
|
+
readonly type: "bytes";
|
|
63
|
+
}];
|
|
64
|
+
readonly outputs: readonly [{
|
|
65
|
+
readonly name: "nonce";
|
|
66
|
+
readonly type: "uint64";
|
|
67
|
+
}];
|
|
68
|
+
}, {
|
|
69
|
+
readonly name: "localMessageTransmitter";
|
|
70
|
+
readonly type: "function";
|
|
71
|
+
readonly stateMutability: "view";
|
|
72
|
+
readonly inputs: readonly [];
|
|
73
|
+
readonly outputs: readonly [{
|
|
74
|
+
readonly name: "";
|
|
75
|
+
readonly type: "address";
|
|
76
|
+
}];
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "localDomain";
|
|
79
|
+
readonly type: "function";
|
|
80
|
+
readonly stateMutability: "view";
|
|
81
|
+
readonly inputs: readonly [];
|
|
82
|
+
readonly outputs: readonly [{
|
|
83
|
+
readonly name: "";
|
|
84
|
+
readonly type: "uint32";
|
|
85
|
+
}];
|
|
86
|
+
}];
|
|
87
|
+
/**
|
|
88
|
+
* CCTP V2 MessageTransmitterV2 ABI (destination chain)
|
|
89
|
+
* Key function: receiveMessage — mints USDC using attested message
|
|
90
|
+
*/
|
|
91
|
+
export declare const MessageTransmitterV2Abi: readonly [{
|
|
92
|
+
readonly name: "receiveMessage";
|
|
93
|
+
readonly type: "function";
|
|
94
|
+
readonly stateMutability: "nonpayable";
|
|
95
|
+
readonly inputs: readonly [{
|
|
96
|
+
readonly name: "message";
|
|
97
|
+
readonly type: "bytes";
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "attestation";
|
|
100
|
+
readonly type: "bytes";
|
|
101
|
+
}];
|
|
102
|
+
readonly outputs: readonly [{
|
|
103
|
+
readonly name: "success";
|
|
104
|
+
readonly type: "bool";
|
|
105
|
+
}];
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "usedNonces";
|
|
108
|
+
readonly type: "function";
|
|
109
|
+
readonly stateMutability: "view";
|
|
110
|
+
readonly inputs: readonly [{
|
|
111
|
+
readonly name: "";
|
|
112
|
+
readonly type: "bytes32";
|
|
113
|
+
}];
|
|
114
|
+
readonly outputs: readonly [{
|
|
115
|
+
readonly name: "";
|
|
116
|
+
readonly type: "uint256";
|
|
117
|
+
}];
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "localDomain";
|
|
120
|
+
readonly type: "function";
|
|
121
|
+
readonly stateMutability: "view";
|
|
122
|
+
readonly inputs: readonly [];
|
|
123
|
+
readonly outputs: readonly [{
|
|
124
|
+
readonly name: "";
|
|
125
|
+
readonly type: "uint32";
|
|
126
|
+
}];
|
|
127
|
+
}];
|
|
128
|
+
/**
|
|
129
|
+
* Minimal ERC20 ABI — approve + allowance + balanceOf
|
|
130
|
+
*/
|
|
131
|
+
export declare const ERC20BridgeAbi: readonly [{
|
|
132
|
+
readonly name: "approve";
|
|
133
|
+
readonly type: "function";
|
|
134
|
+
readonly stateMutability: "nonpayable";
|
|
135
|
+
readonly inputs: readonly [{
|
|
136
|
+
readonly name: "spender";
|
|
137
|
+
readonly type: "address";
|
|
138
|
+
}, {
|
|
139
|
+
readonly name: "amount";
|
|
140
|
+
readonly type: "uint256";
|
|
141
|
+
}];
|
|
142
|
+
readonly outputs: readonly [{
|
|
143
|
+
readonly name: "";
|
|
144
|
+
readonly type: "bool";
|
|
145
|
+
}];
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "allowance";
|
|
148
|
+
readonly type: "function";
|
|
149
|
+
readonly stateMutability: "view";
|
|
150
|
+
readonly inputs: readonly [{
|
|
151
|
+
readonly name: "owner";
|
|
152
|
+
readonly type: "address";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "spender";
|
|
155
|
+
readonly type: "address";
|
|
156
|
+
}];
|
|
157
|
+
readonly outputs: readonly [{
|
|
158
|
+
readonly name: "";
|
|
159
|
+
readonly type: "uint256";
|
|
160
|
+
}];
|
|
161
|
+
}, {
|
|
162
|
+
readonly name: "balanceOf";
|
|
163
|
+
readonly type: "function";
|
|
164
|
+
readonly stateMutability: "view";
|
|
165
|
+
readonly inputs: readonly [{
|
|
166
|
+
readonly name: "account";
|
|
167
|
+
readonly type: "address";
|
|
168
|
+
}];
|
|
169
|
+
readonly outputs: readonly [{
|
|
170
|
+
readonly name: "";
|
|
171
|
+
readonly type: "uint256";
|
|
172
|
+
}];
|
|
173
|
+
}];
|
|
174
|
+
/**
|
|
175
|
+
* MessageTransmitter MessageSent event ABI — emitted during depositForBurn
|
|
176
|
+
* Used to extract the CCTP message bytes and hash for attestation polling.
|
|
177
|
+
*/
|
|
178
|
+
export declare const MessageSentEventAbi: readonly [{
|
|
179
|
+
readonly name: "MessageSent";
|
|
180
|
+
readonly type: "event";
|
|
181
|
+
readonly inputs: readonly [{
|
|
182
|
+
readonly name: "message";
|
|
183
|
+
readonly type: "bytes";
|
|
184
|
+
readonly indexed: false;
|
|
185
|
+
}];
|
|
186
|
+
}];
|
|
187
|
+
//# sourceMappingURL=abis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../../src/bridge/abis.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB1B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BjB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;EAQtB,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// [MAX-ADDED] CCTP V2 Contract ABIs — Circle Cross-Chain Transfer Protocol V2
|
|
2
|
+
// Sources: https://developers.circle.com/stablecoins/cctp-protocol-contract
|
|
3
|
+
/**
|
|
4
|
+
* CCTP V2 TokenMessengerV2 ABI (source chain)
|
|
5
|
+
* Key function: depositForBurn — burns USDC and emits a MessageSent event
|
|
6
|
+
*/
|
|
7
|
+
export const TokenMessengerV2Abi = [
|
|
8
|
+
{
|
|
9
|
+
name: 'depositForBurn',
|
|
10
|
+
type: 'function',
|
|
11
|
+
stateMutability: 'nonpayable',
|
|
12
|
+
inputs: [
|
|
13
|
+
{ name: 'amount', type: 'uint256' },
|
|
14
|
+
{ name: 'destinationDomain', type: 'uint32' },
|
|
15
|
+
{ name: 'mintRecipient', type: 'bytes32' },
|
|
16
|
+
{ name: 'burnToken', type: 'address' },
|
|
17
|
+
{ name: 'destinationCaller', type: 'bytes32' },
|
|
18
|
+
{ name: 'maxFee', type: 'uint256' },
|
|
19
|
+
{ name: 'minFinalityThreshold', type: 'uint32' },
|
|
20
|
+
],
|
|
21
|
+
outputs: [{ name: 'nonce', type: 'uint64' }],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'depositForBurnWithHook',
|
|
25
|
+
type: 'function',
|
|
26
|
+
stateMutability: 'nonpayable',
|
|
27
|
+
inputs: [
|
|
28
|
+
{ name: 'amount', type: 'uint256' },
|
|
29
|
+
{ name: 'destinationDomain', type: 'uint32' },
|
|
30
|
+
{ name: 'mintRecipient', type: 'bytes32' },
|
|
31
|
+
{ name: 'burnToken', type: 'address' },
|
|
32
|
+
{ name: 'destinationCaller', type: 'bytes32' },
|
|
33
|
+
{ name: 'maxFee', type: 'uint256' },
|
|
34
|
+
{ name: 'minFinalityThreshold', type: 'uint32' },
|
|
35
|
+
{ name: 'hookData', type: 'bytes' },
|
|
36
|
+
],
|
|
37
|
+
outputs: [{ name: 'nonce', type: 'uint64' }],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'localMessageTransmitter',
|
|
41
|
+
type: 'function',
|
|
42
|
+
stateMutability: 'view',
|
|
43
|
+
inputs: [],
|
|
44
|
+
outputs: [{ name: '', type: 'address' }],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'localDomain',
|
|
48
|
+
type: 'function',
|
|
49
|
+
stateMutability: 'view',
|
|
50
|
+
inputs: [],
|
|
51
|
+
outputs: [{ name: '', type: 'uint32' }],
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* CCTP V2 MessageTransmitterV2 ABI (destination chain)
|
|
56
|
+
* Key function: receiveMessage — mints USDC using attested message
|
|
57
|
+
*/
|
|
58
|
+
export const MessageTransmitterV2Abi = [
|
|
59
|
+
{
|
|
60
|
+
name: 'receiveMessage',
|
|
61
|
+
type: 'function',
|
|
62
|
+
stateMutability: 'nonpayable',
|
|
63
|
+
inputs: [
|
|
64
|
+
{ name: 'message', type: 'bytes' },
|
|
65
|
+
{ name: 'attestation', type: 'bytes' },
|
|
66
|
+
],
|
|
67
|
+
outputs: [{ name: 'success', type: 'bool' }],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'usedNonces',
|
|
71
|
+
type: 'function',
|
|
72
|
+
stateMutability: 'view',
|
|
73
|
+
inputs: [{ name: '', type: 'bytes32' }],
|
|
74
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'localDomain',
|
|
78
|
+
type: 'function',
|
|
79
|
+
stateMutability: 'view',
|
|
80
|
+
inputs: [],
|
|
81
|
+
outputs: [{ name: '', type: 'uint32' }],
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
/**
|
|
85
|
+
* Minimal ERC20 ABI — approve + allowance + balanceOf
|
|
86
|
+
*/
|
|
87
|
+
export const ERC20BridgeAbi = [
|
|
88
|
+
{
|
|
89
|
+
name: 'approve',
|
|
90
|
+
type: 'function',
|
|
91
|
+
stateMutability: 'nonpayable',
|
|
92
|
+
inputs: [
|
|
93
|
+
{ name: 'spender', type: 'address' },
|
|
94
|
+
{ name: 'amount', type: 'uint256' },
|
|
95
|
+
],
|
|
96
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'allowance',
|
|
100
|
+
type: 'function',
|
|
101
|
+
stateMutability: 'view',
|
|
102
|
+
inputs: [
|
|
103
|
+
{ name: 'owner', type: 'address' },
|
|
104
|
+
{ name: 'spender', type: 'address' },
|
|
105
|
+
],
|
|
106
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'balanceOf',
|
|
110
|
+
type: 'function',
|
|
111
|
+
stateMutability: 'view',
|
|
112
|
+
inputs: [{ name: 'account', type: 'address' }],
|
|
113
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
/**
|
|
117
|
+
* MessageTransmitter MessageSent event ABI — emitted during depositForBurn
|
|
118
|
+
* Used to extract the CCTP message bytes and hash for attestation polling.
|
|
119
|
+
*/
|
|
120
|
+
export const MessageSentEventAbi = [
|
|
121
|
+
{
|
|
122
|
+
name: 'MessageSent',
|
|
123
|
+
type: 'event',
|
|
124
|
+
inputs: [
|
|
125
|
+
{ name: 'message', type: 'bytes', indexed: false },
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
//# sourceMappingURL=abis.js.map
|
|
@@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C;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;SACnD;KACF;CACO,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type Hash, type Hex, type WalletClient } from 'viem';
|
|
2
|
+
import type { BridgeChain, BridgeOptions, BurnResult, BridgeResult } from './types.js';
|
|
3
|
+
import { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, USDC_CONTRACT, TOKEN_MESSENGER_V2, MESSAGE_TRANSMITTER_V2, FINALITY_THRESHOLD } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* BridgeModule — CCTP V2 cross-chain USDC bridge.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```ts
|
|
9
|
+
* const bridge = new BridgeModule(walletClient, 'base', { rpcUrl: '...' });
|
|
10
|
+
* const result = await bridge.bridge(1_000_000n, 'optimism');
|
|
11
|
+
* console.log('Minted on Optimism:', result.mintTxHash);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class BridgeModule {
|
|
15
|
+
private readonly walletClient;
|
|
16
|
+
private readonly publicClient;
|
|
17
|
+
private readonly fromChain;
|
|
18
|
+
private readonly fromRpcUrl;
|
|
19
|
+
constructor(walletClient: WalletClient, fromChain?: BridgeChain, options?: {
|
|
20
|
+
rpcUrl?: string;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Bridge USDC from the source chain to the destination chain.
|
|
24
|
+
*
|
|
25
|
+
* This is the primary method. It orchestrates the full CCTP V2 flow:
|
|
26
|
+
* approve → burn → attest → mint.
|
|
27
|
+
*
|
|
28
|
+
* @param amount - Amount in USDC base units (6 decimals). e.g. 1_000_000n = 1 USDC
|
|
29
|
+
* @param toChain - Destination chain ('ethereum' | 'optimism' | 'arbitrum')
|
|
30
|
+
* @param options - Optional overrides (finality, fees, destination address)
|
|
31
|
+
*
|
|
32
|
+
* @throws BridgeError with actionable message if anything fails
|
|
33
|
+
*/
|
|
34
|
+
bridge(amount: bigint, toChain: BridgeChain, options?: BridgeOptions): Promise<BridgeResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Step 1 of 3: Burn USDC on the source chain.
|
|
37
|
+
* Returns the burn result including message bytes needed for minting.
|
|
38
|
+
* Use this for manual/split-phase bridging.
|
|
39
|
+
*/
|
|
40
|
+
burn(amount: bigint, toChain: BridgeChain, options?: BridgeOptions): Promise<BurnResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Step 2 of 3: Poll Circle IRIS API for attestation.
|
|
43
|
+
* Returns the attestation bytes once Circle confirms the message.
|
|
44
|
+
*/
|
|
45
|
+
waitForAttestation(messageHash: Hex, apiUrl?: string): Promise<Hex>;
|
|
46
|
+
/**
|
|
47
|
+
* Step 3 of 3: Mint USDC on the destination chain using the attestation.
|
|
48
|
+
*/
|
|
49
|
+
mint(messageBytes: Hex, attestation: Hex, toChain: BridgeChain, destinationRpcUrl?: string): Promise<Hash>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetch the current USDC balance on the source chain for the signer's address.
|
|
52
|
+
*/
|
|
53
|
+
getUsdcBalance(): Promise<bigint>;
|
|
54
|
+
/**
|
|
55
|
+
* Fetch the current USDC allowance for the TokenMessengerV2 on source chain.
|
|
56
|
+
*/
|
|
57
|
+
getUsdcAllowance(): Promise<bigint>;
|
|
58
|
+
/**
|
|
59
|
+
* Approve TokenMessengerV2 to spend USDC on behalf of the signer.
|
|
60
|
+
* Skips if existing allowance is sufficient.
|
|
61
|
+
*/
|
|
62
|
+
private approveUsdc;
|
|
63
|
+
/**
|
|
64
|
+
* Call TokenMessengerV2.depositForBurn and extract MessageSent data.
|
|
65
|
+
*/
|
|
66
|
+
private depositForBurn;
|
|
67
|
+
/**
|
|
68
|
+
* Extract the CCTP MessageSent event from a transaction receipt.
|
|
69
|
+
* The MessageTransmitter emits this event during depositForBurn.
|
|
70
|
+
*/
|
|
71
|
+
private extractMessageSent;
|
|
72
|
+
/**
|
|
73
|
+
* Poll the Circle IRIS API until the attestation is ready.
|
|
74
|
+
* Fast finality: ~12 seconds. Full finality: ~15 minutes on Ethereum.
|
|
75
|
+
*/
|
|
76
|
+
private pollForAttestation;
|
|
77
|
+
/**
|
|
78
|
+
* Call MessageTransmitterV2.receiveMessage on the destination chain to mint USDC.
|
|
79
|
+
*/
|
|
80
|
+
private receiveMessage;
|
|
81
|
+
private validateBridgeParams;
|
|
82
|
+
private sleep;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Structured bridge error with actionable messages and error codes.
|
|
86
|
+
*/
|
|
87
|
+
export declare class BridgeError extends Error {
|
|
88
|
+
readonly code: string;
|
|
89
|
+
constructor(code: string, message: string);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a BridgeModule from an existing AgentWallet object.
|
|
93
|
+
* Convenience wrapper for wallet.bridge() integration.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const bridge = createBridge(wallet.walletClient, 'base', { rpcUrl: BASE_RPC });
|
|
98
|
+
* const result = await bridge.bridge(5_000_000n, 'optimism');
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function createBridge(walletClient: WalletClient, fromChain?: BridgeChain, options?: {
|
|
102
|
+
rpcUrl?: string;
|
|
103
|
+
}): BridgeModule;
|
|
104
|
+
export type { BridgeChain, BridgeOptions, BurnResult, BridgeResult };
|
|
105
|
+
export { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, USDC_CONTRACT, TOKEN_MESSENGER_V2, MESSAGE_TRANSMITTER_V2, FINALITY_THRESHOLD, };
|
|
106
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/bridge/client.ts"],"names":[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