@usewhisk/cctp 0.0.0 → 0.1.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/LICENSE +21 -0
- package/README.md +218 -0
- package/dist/abi.cjs +239 -0
- package/dist/abi.cjs.map +1 -0
- package/dist/abi.d.cts +401 -0
- package/dist/abi.d.ts +401 -0
- package/dist/abi.js +234 -0
- package/dist/abi.js.map +1 -0
- package/dist/attestation-D52iUV0y.d.cts +188 -0
- package/dist/attestation-D52iUV0y.d.ts +188 -0
- package/dist/chains.cjs +1621 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.cts +2 -0
- package/dist/chains.d.ts +2 -0
- package/dist/chains.js +1514 -0
- package/dist/chains.js.map +1 -0
- package/dist/index-BIerSvES.d.cts +4070 -0
- package/dist/index-O0Ms-Fa5.d.ts +4070 -0
- package/dist/index.cjs +4018 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +947 -0
- package/dist/index.d.ts +947 -0
- package/dist/index.js +3799 -0
- package/dist/index.js.map +1 -0
- package/dist/iris.cjs +557 -0
- package/dist/iris.cjs.map +1 -0
- package/dist/iris.d.cts +205 -0
- package/dist/iris.d.ts +205 -0
- package/dist/iris.js +538 -0
- package/dist/iris.js.map +1 -0
- package/package.json +85 -10
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
import { I as InvalidInputError } from './index-BIerSvES.cjs';
|
|
2
|
+
export { A as Arbitrum, a as ArbitrumSepolia, b as Arc, c as ArcTestnet, d as Avalanche, e as AvalancheFuji, B as Base, f as BaseSepolia, C as CCTP_FORWARDER_STELLAR_MAINNET, g as CCTP_FORWARDER_STELLAR_TESTNET, h as CCTP_USDC_DECIMALS, i as CHAINS, j as CctpError, k as CctpErrorCode, l as ChainId, m as Codex, n as CodexTestnet, o as Cronos, p as CronosTestnet, E as EVM_MAINNET_CHAINS, q as EVM_TESTNET_CHAINS, r as Edge, s as EdgeTestnet, t as Ethereum, u as EthereumSepolia, H as HyperEVM, v as HyperEVMTestnet, w as Injective, x as InjectiveTestnet, y as Ink, z as InkTestnet, D as IrisAbortedError, F as IrisError, G as IrisHttpError, J as IrisNetworkError, K as IrisParseError, L as IrisRateLimitedError, M as Linea, N as LineaSepolia, O as MESSAGE_TRANSMITTER_STELLAR_MAINNET, P as MESSAGE_TRANSMITTER_STELLAR_TESTNET, Q as MESSAGE_TRANSMITTER_V2_EVM_MAINNET, R as MESSAGE_TRANSMITTER_V2_EVM_TESTNET, S as MESSAGE_TRANSMITTER_V2_SOLANA, T as MESSAGE_TRANSMITTER_V2_STARKNET_MAINNET, U as MESSAGE_TRANSMITTER_V2_STARKNET_SEPOLIA, V as Monad, W as MonadTestnet, X as Morph, Y as MorphTestnet, Z as Optimism, _ as OptimismSepolia, $ as Pharos, a0 as PharosTestnet, a1 as Plasma, a2 as PlasmaTestnet, a3 as Plume, a4 as PlumeTestnet, a5 as Polygon, a6 as PolygonAmoyTestnet, a7 as ProtocolError, a8 as SOLANA_CCTP_DOMAIN, a9 as STARKNET_CCTP_DOMAIN, aa as STARKNET_CHAIN_ID_MAINNET, ab as STARKNET_CHAIN_ID_SEPOLIA, ac as STELLAR_CCTP_DOMAIN, ad as STELLAR_NETWORK_PASSPHRASE_MAINNET, ae as STELLAR_NETWORK_PASSPHRASE_TESTNET, af as STELLAR_USDC_DECIMALS, ag as Sei, ah as SeiTestnet, ai as Solana, aj as SolanaDevnet, ak as Sonic, al as SonicTestnet, am as Starknet, an as StarknetSepolia, ao as Stellar, ap as StellarTestnet, aq as TOKEN_MESSENGER_MINTER_STELLAR_MAINNET, ar as TOKEN_MESSENGER_MINTER_STELLAR_TESTNET, as as TOKEN_MESSENGER_MINTER_V2_SOLANA, at as TOKEN_MESSENGER_MINTER_V2_STARKNET_MAINNET, au as TOKEN_MESSENGER_MINTER_V2_STARKNET_SEPOLIA, av as TOKEN_MESSENGER_V2_EVM_MAINNET, aw as TOKEN_MESSENGER_V2_EVM_TESTNET, ax as TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET, ay as TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET, az as USDC_ISSUER_STELLAR_MAINNET, aA as USDC_ISSUER_STELLAR_TESTNET, aB as USDC_SPL_DEVNET, aC as USDC_SPL_MAINNET, aD as USDC_STARKNET_MAINNET, aE as USDC_STARKNET_SEPOLIA, aF as Unichain, aG as UnichainSepolia, aH as UnknownChainError, aI as UnsupportedError, aJ as WorldChain, aK as WorldChainSepolia, aL as XDC, aM as XDCApothem, aN as XLayer, aO as XLayerTestnet, aP as chainByDomain, aQ as chainByEvmChainId, aR as chainsByNetwork, aS as explorerAddressUrl, aT as explorerTxUrl, aU as getChain, aV as isCctpError, aW as isChainId, aX as isEvmChain, aY as isSolanaChain, aZ as isStarknetChain, a_ as isStellarChain, a$ as tryChainByEvmChainId } from './index-BIerSvES.cjs';
|
|
3
|
+
import { E as EvmChain, S as StarknetChain, a as StellarChain, A as Address, B as BurnFeeTier, F as ForwarderFeeTier, C as CctpChain, b as FinalityThreshold, c as StarknetFelt, d as SolanaChain } from './attestation-D52iUV0y.cjs';
|
|
4
|
+
export { e as CctpDomain, f as ChainCapabilities, g as Ecosystem, h as EvmChainId, i as FINALITY_FAST, j as FINALITY_STANDARD, k as ForwardState, G as GetMessagesQuery, I as IrisAttestationStatus, l as IrisDelayReason, m as IrisMessage, n as IrisMessagesResponse, N as Network, o as SecondsRange, p as SolanaCluster, q as SolanaPubkey, r as StarknetNetwork, s as StellarNetwork, t as StellarStrkey, T as TransferSpeed, u as attestationSeconds } from './attestation-D52iUV0y.cjs';
|
|
5
|
+
export { messageTransmitterV2Abi, tokenMessengerV2Abi, tokenMessengerWithFeesAbi, usdcAbi } from './abi.cjs';
|
|
6
|
+
export { FetchJsonOptions, GetBurnFeesOptions, GetMessagesOptions, IRIS_MAINNET_URL, IRIS_SANDBOX_URL, IrisLimiter, IrisLimiterOptions, PollMessageOptions, ReattestOptions, SignedBurnQuote, SignedBurnQuoteRequest, SignedQuoteExpiry, UpfrontFeeType, createIrisLimiter, defaultIrisLimiter, fetchIrisJson, getBurnFees, getFastBurnAllowance, getMessages, getSignedBurnQuote, irisBaseUrl, isForwardDone, pickFeeTier, pickForwarderFee, pollBudget, pollMessages, reattest } from './iris.cjs';
|
|
7
|
+
import { xdr } from '@stellar/stellar-sdk';
|
|
8
|
+
import { PublicKey, AccountMeta, TransactionInstruction } from '@solana/web3.js';
|
|
9
|
+
|
|
10
|
+
type RpcOptions = {
|
|
11
|
+
/** Tried in order before the chain's default RPCs. */
|
|
12
|
+
rpcUrls?: readonly string[];
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
};
|
|
15
|
+
/** `eth_gasPrice`, in wei. */
|
|
16
|
+
declare function getGasPrice(chain: EvmChain, options?: RpcOptions): Promise<bigint>;
|
|
17
|
+
declare function getBlockNumber(chain: EvmChain, options?: RpcOptions): Promise<bigint>;
|
|
18
|
+
/**
|
|
19
|
+
* Whether `MessageTransmitterV2.usedNonces(nonce)` is set: the message was
|
|
20
|
+
* already received on this chain and minting it again would revert.
|
|
21
|
+
*/
|
|
22
|
+
declare function isNonceUsed(chain: EvmChain, nonce: `0x${string}`, options?: RpcOptions): Promise<boolean>;
|
|
23
|
+
type TransactionStatus = "success" | "reverted" | "unknown";
|
|
24
|
+
/** `unknown` until the transaction is mined, or if the node never saw it. */
|
|
25
|
+
declare function getTransactionStatus(chain: EvmChain, hash: `0x${string}`, options?: RpcOptions): Promise<TransactionStatus>;
|
|
26
|
+
/** The USDC ERC-20 balance of `owner`, in subunits. */
|
|
27
|
+
declare function getUsdcBalance(chain: EvmChain, owner: `0x${string}`, options?: RpcOptions): Promise<bigint>;
|
|
28
|
+
|
|
29
|
+
/** `MessageTransmitter.is_nonce_used(u256)` on Starknet. */
|
|
30
|
+
declare function isStarknetNonceUsed(chain: StarknetChain, nonce: `0x${string}`, options?: RpcOptions): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* `MessageTransmitter.is_nonce_used(BytesN<32>)` on Stellar, read by
|
|
33
|
+
* simulating the call. Simulation needs a source account but no signature,
|
|
34
|
+
* so the USDC issuer, which always exists, stands in.
|
|
35
|
+
*/
|
|
36
|
+
declare function isStellarNonceUsed(chain: StellarChain, nonce: `0x${string}`, options?: RpcOptions): Promise<boolean>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The class hash of the contract at `address`, or `null` when nothing is
|
|
40
|
+
* deployed there. An account that has not been deployed yet still holds
|
|
41
|
+
* tokens sent to it, but only its owner's wallet can tell that it is one.
|
|
42
|
+
*/
|
|
43
|
+
declare function getStarknetClassHashAt(chain: StarknetChain, address: string, options?: RpcOptions): Promise<string | null>;
|
|
44
|
+
|
|
45
|
+
/** `pending` until the sequencer has accepted the transaction on L2. */
|
|
46
|
+
type StarknetTransactionStatus = {
|
|
47
|
+
state: "pending";
|
|
48
|
+
} | {
|
|
49
|
+
state: "success" | "reverted";
|
|
50
|
+
blockNumber: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Reads the receipt over plain JSON-RPC. starknet.js refuses nodes on a spec
|
|
54
|
+
* version it does not know, and public nodes move ahead of it, so the
|
|
55
|
+
* receipt is read here instead. The fields used are the same from 0.8 to 0.10.
|
|
56
|
+
*/
|
|
57
|
+
declare function getStarknetTransactionStatus(chain: StarknetChain, hash: string, options?: RpcOptions): Promise<StarknetTransactionStatus>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Forwarder hookData.
|
|
61
|
+
*
|
|
62
|
+
* Including this 32-byte hookData in `depositForBurnWithHook` tells
|
|
63
|
+
* Circle's Orbit relayer to fetch the attestation and submit the
|
|
64
|
+
* destination mint on the user's behalf.
|
|
65
|
+
*
|
|
66
|
+
* Layout:
|
|
67
|
+
* bytes 0..11: ASCII "cctp-forward"
|
|
68
|
+
* bytes 12..23: zero pad
|
|
69
|
+
* bytes 24..27: uint32 BE version (0)
|
|
70
|
+
* bytes 28..31: uint32 BE payload length (0 for basic forwarding)
|
|
71
|
+
*/
|
|
72
|
+
/** Static hex string used for every Whisk bridge with forwarder enabled. */
|
|
73
|
+
declare const CCTP_FORWARD_HOOK_DATA: `0x${string}`;
|
|
74
|
+
declare const CCTP_FORWARD_HOOK_DATA_LENGTH = 32;
|
|
75
|
+
/**
|
|
76
|
+
* Encodes the same bytes as `CCTP_FORWARD_HOOK_DATA` field by field. Stellar
|
|
77
|
+
* destinations need a payload and use `buildStellarForwarderHookData`.
|
|
78
|
+
*/
|
|
79
|
+
declare function buildForwarderHookData(): `0x${string}`;
|
|
80
|
+
/** True when `hex` starts with the 32-byte basic forwarder hookData. */
|
|
81
|
+
declare function isForwarderHookData(hex: string): boolean;
|
|
82
|
+
/** bytes32(0) as `destinationCaller` lets anyone submit the mint. */
|
|
83
|
+
declare const ANY_DESTINATION_CALLER$1: `0x${string}`;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Address encoding for CCTP message fields.
|
|
87
|
+
*
|
|
88
|
+
* CCTP uses 32-byte (`bytes32`) values for `mintRecipient` and
|
|
89
|
+
* `destinationCaller` so it can carry both 20-byte EVM addresses and
|
|
90
|
+
* 32-byte non-EVM addresses. The encoders here are EVM only.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
declare class InvalidAddressError extends InvalidInputError {
|
|
94
|
+
constructor(input: string);
|
|
95
|
+
}
|
|
96
|
+
declare class InvalidBytes32Error extends InvalidInputError {
|
|
97
|
+
constructor(input: string);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Left-pad a 20-byte EVM address to 32 bytes for use as a CCTP
|
|
101
|
+
* `bytes32` field.
|
|
102
|
+
*
|
|
103
|
+
* 0xabcd...1234 → 0x000000000000000000000000abcd...1234
|
|
104
|
+
*
|
|
105
|
+
* Output is lowercase; `getAddress(fromBytes32(value))` restores the
|
|
106
|
+
* checksum.
|
|
107
|
+
*/
|
|
108
|
+
declare function toBytes32(address: Address | string): `0x${string}`;
|
|
109
|
+
/**
|
|
110
|
+
* Reverse of `toBytes32`. Strips the 12-byte zero pad and returns a
|
|
111
|
+
* lowercase 20-byte address.
|
|
112
|
+
*
|
|
113
|
+
* Throws if the upper 12 bytes are not zero (i.e. the value isn't an
|
|
114
|
+
* EVM address). Callers can use `tryFromBytes32` for a non-throwing
|
|
115
|
+
* variant.
|
|
116
|
+
*/
|
|
117
|
+
declare function fromBytes32(value: `0x${string}` | string): Address;
|
|
118
|
+
declare function tryFromBytes32(value: string): Address | undefined;
|
|
119
|
+
declare function isAddress(value: string): value is Address;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Fee math for CCTP V2 bridges.
|
|
123
|
+
*
|
|
124
|
+
* Two protocol-level fees stack on a Fast Transfer + Forwarder bridge:
|
|
125
|
+
*
|
|
126
|
+
* 1. Burn fee: a rate on the transfer amount, charged by CCTP. Iris
|
|
127
|
+
* returns `minimumFee` in basis points with up to two decimals
|
|
128
|
+
* (`1.3` is 0.013%). Whisk holds it as hundredths of a basis
|
|
129
|
+
* point, so `1.3` becomes `130n`.
|
|
130
|
+
*
|
|
131
|
+
* 2. Forwarder fee: a flat USDC fee that pays for destination gas
|
|
132
|
+
* and the relayer. Iris returns low, med and high levels in USDC
|
|
133
|
+
* subunits. Whisk defaults to `med`.
|
|
134
|
+
*
|
|
135
|
+
* `maxFee` on `depositForBurnWithHook` must cover both. Every step
|
|
136
|
+
* rounds up: a `maxFee` one subunit short turns a Fast transfer into a
|
|
137
|
+
* Standard one.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/** Iris's `minimumFee` as hundredths of a basis point: `1.3` is `130n`. */
|
|
141
|
+
declare function parseFeeBps(raw: unknown): bigint;
|
|
142
|
+
/** An Iris forwarder fee in USDC subunits, rounded up. */
|
|
143
|
+
declare function parseForwarderFee(raw: unknown): bigint;
|
|
144
|
+
/**
|
|
145
|
+
* The CCTP burn fee on `amount` subunits at `feeCentiBps` hundredths of
|
|
146
|
+
* a basis point, rounded up.
|
|
147
|
+
*/
|
|
148
|
+
declare function computeBurnFee(amount: bigint, feeCentiBps: bigint): bigint;
|
|
149
|
+
/** The forwarder fee for a level, in USDC subunits. */
|
|
150
|
+
declare function selectForwarderFee(tier: BurnFeeTier, level?: keyof ForwarderFeeTier): bigint;
|
|
151
|
+
type ComputeMaxFeeInput = {
|
|
152
|
+
/** Transfer amount in USDC subunits. */
|
|
153
|
+
amount: bigint;
|
|
154
|
+
/** Selected tier (Fast or Standard). */
|
|
155
|
+
tier: BurnFeeTier;
|
|
156
|
+
/** Forwarder fee level; defaults to `"med"`. */
|
|
157
|
+
forwarderLevel?: keyof ForwarderFeeTier;
|
|
158
|
+
/**
|
|
159
|
+
* Whole basis points added to the forwarder fee (0 to 10000). Iris's
|
|
160
|
+
* `high` level already carries a buffer, so this defaults to 0.
|
|
161
|
+
*/
|
|
162
|
+
forwarderBufferBps?: number;
|
|
163
|
+
/** Whether to include the forwarder fee. Defaults to `true`. */
|
|
164
|
+
includeForwarder?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Whole basis points added to the protocol fee in `maxFee` only. Circle
|
|
167
|
+
* takes the fee it executes, so the buffer is a ceiling, not a charge.
|
|
168
|
+
*/
|
|
169
|
+
burnFeeBufferBps?: number;
|
|
170
|
+
/** The on-chain minimum from `getMinFeeAmount`, in USDC subunits. */
|
|
171
|
+
minBurnFee?: bigint;
|
|
172
|
+
};
|
|
173
|
+
type ComputeMaxFeeResult = {
|
|
174
|
+
/** The protocol fee, raised to `minBurnFee` if lower, before any buffer. */
|
|
175
|
+
burnFee: bigint;
|
|
176
|
+
forwarderFee: bigint;
|
|
177
|
+
/** Total cap to pass as `maxFee` on `depositForBurnWithHook`. */
|
|
178
|
+
maxFee: bigint;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* maxFee = burnFee (+ buffer) + forwarderFee (+ buffer)
|
|
182
|
+
*
|
|
183
|
+
* The result is a cap; the actual deducted fee can be less.
|
|
184
|
+
*/
|
|
185
|
+
declare function computeMaxFee(input: ComputeMaxFeeInput): ComputeMaxFeeResult;
|
|
186
|
+
|
|
187
|
+
type GetStandardMinFeeOptions = RpcOptions;
|
|
188
|
+
/**
|
|
189
|
+
* `TokenMessengerV2.getMinFeeAmount(amount)`: the least `maxFee` a Standard
|
|
190
|
+
* burn of `amount` may carry on a chain with Circle's fee switch.
|
|
191
|
+
*/
|
|
192
|
+
declare function getStandardMinFee(chain: EvmChain, amount: bigint, options?: GetStandardMinFeeOptions): Promise<bigint>;
|
|
193
|
+
|
|
194
|
+
/** A CCTP V2 message carrying a burn, read from the attested bytes. */
|
|
195
|
+
type DecodedBurnMessage = {
|
|
196
|
+
version: number;
|
|
197
|
+
sourceDomain: number;
|
|
198
|
+
destinationDomain: number;
|
|
199
|
+
nonce: `0x${string}`;
|
|
200
|
+
sender: `0x${string}`;
|
|
201
|
+
recipient: `0x${string}`;
|
|
202
|
+
destinationCaller: `0x${string}`;
|
|
203
|
+
minFinalityThreshold: number;
|
|
204
|
+
finalityThresholdExecuted: number;
|
|
205
|
+
body: {
|
|
206
|
+
version: number;
|
|
207
|
+
burnToken: `0x${string}`;
|
|
208
|
+
mintRecipient: `0x${string}`;
|
|
209
|
+
amount: bigint;
|
|
210
|
+
messageSender: `0x${string}`;
|
|
211
|
+
maxFee: bigint;
|
|
212
|
+
feeExecuted: bigint;
|
|
213
|
+
/** In the destination chain's own height; `0n` once finalized. */
|
|
214
|
+
expirationBlock: bigint;
|
|
215
|
+
hookData: `0x${string}`;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Splits a message into its fields. Every address is the 32-byte form CCTP
|
|
220
|
+
* carries; an EVM address is its last 20 bytes.
|
|
221
|
+
*/
|
|
222
|
+
declare function decodeBurnMessage(message: `0x${string}`): DecodedBurnMessage;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A burn intent is the chain-bound call(s) the wallet adapter signs
|
|
226
|
+
* and submits. It contains no transaction-level data (gas, nonce);
|
|
227
|
+
* the adapter fills those in.
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* One on-chain call. A bridge is usually an `approve` followed by the burn;
|
|
232
|
+
* the wallet adapter may batch them via EIP-5792 when supported.
|
|
233
|
+
*/
|
|
234
|
+
type EvmCall = {
|
|
235
|
+
to: Address;
|
|
236
|
+
data: `0x${string}`;
|
|
237
|
+
/** Always `0n`: USDC burns carry no native value. */
|
|
238
|
+
value: bigint;
|
|
239
|
+
};
|
|
240
|
+
type BurnIntent = {
|
|
241
|
+
source: CctpChain;
|
|
242
|
+
destination: CctpChain;
|
|
243
|
+
/** Executed in order. */
|
|
244
|
+
calls: EvmCall[];
|
|
245
|
+
/** USDC subunits, 6 decimals. */
|
|
246
|
+
amount: bigint;
|
|
247
|
+
/** `maxFee` cap that was packed into the burn call. */
|
|
248
|
+
maxFee: bigint;
|
|
249
|
+
/** Computed protocol fee, for a fee breakdown. */
|
|
250
|
+
burnFee: bigint;
|
|
251
|
+
/** Computed forwarder fee. `0n` when the forwarder is off. */
|
|
252
|
+
forwarderFee: bigint;
|
|
253
|
+
mintRecipientBytes32: `0x${string}`;
|
|
254
|
+
/** Whether the burn call set `hookData` for Forwarder use. */
|
|
255
|
+
withForwarder: boolean;
|
|
256
|
+
finalityThreshold: FinalityThreshold;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
type BuildBurnIntentInput = {
|
|
260
|
+
source: CctpChain;
|
|
261
|
+
destination: CctpChain;
|
|
262
|
+
/** USDC subunits (6 decimals). Must be > 0 and ≤ 10M USDC. */
|
|
263
|
+
amount: bigint;
|
|
264
|
+
/**
|
|
265
|
+
* Recipient in the destination's format: a 20-byte EVM address, a base58
|
|
266
|
+
* Solana pubkey, or 0x-prefixed 32-byte hex for Stellar and Starknet.
|
|
267
|
+
*/
|
|
268
|
+
mintRecipient: Address | string;
|
|
269
|
+
/**
|
|
270
|
+
* Restrict who can call `receiveMessage` on the destination. Defaults
|
|
271
|
+
* to `bytes32(0)` (any caller) so the forwarder can mint without
|
|
272
|
+
* extra coordination. Pass a specific 32-byte value if you need to
|
|
273
|
+
* lock the mint down.
|
|
274
|
+
*/
|
|
275
|
+
destinationCaller?: `0x${string}`;
|
|
276
|
+
/**
|
|
277
|
+
* Approve allowance to set on USDC. Defaults to `amount`. Set higher
|
|
278
|
+
* to skip the approve call across multiple bridges (allowance
|
|
279
|
+
* caching).
|
|
280
|
+
*/
|
|
281
|
+
approveAmount?: bigint;
|
|
282
|
+
/**
|
|
283
|
+
* If `true`, skip the approve call entirely (the wallet already has
|
|
284
|
+
* sufficient allowance). Defaults to `false`.
|
|
285
|
+
*/
|
|
286
|
+
skipApprove?: boolean;
|
|
287
|
+
/**
|
|
288
|
+
* Trigger Circle's Orbit forwarder by including the
|
|
289
|
+
* `cctp-forward` hookData. Defaults to `true`. Set to `false` to
|
|
290
|
+
* make the user mint manually on the destination chain.
|
|
291
|
+
*/
|
|
292
|
+
withForwarder?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Override the hookData. When `withForwarder` is true and this is
|
|
295
|
+
* unset, the EVM-side `cctp-forward` magic bytes are used (Circle's
|
|
296
|
+
* Orbit relayer). For Stellar destinations, pass the Stellar
|
|
297
|
+
* `CctpForwarder` hookData instead. The EVM relayer is irrelevant
|
|
298
|
+
* because the Stellar Forwarder is what reads this field on chain.
|
|
299
|
+
*/
|
|
300
|
+
customHookData?: `0x${string}`;
|
|
301
|
+
/** Fee math inputs. See `computeMaxFee`. */
|
|
302
|
+
fee: Pick<ComputeMaxFeeInput, "tier" | "forwarderLevel" | "forwarderBufferBps"> & {
|
|
303
|
+
/**
|
|
304
|
+
* Burn with exactly this cap instead of one computed from the tier. Pass
|
|
305
|
+
* the `maxFee` the payer confirmed.
|
|
306
|
+
*/
|
|
307
|
+
maxFee?: bigint;
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
declare function buildBurnIntent(input: BuildBurnIntentInput): BurnIntent;
|
|
311
|
+
|
|
312
|
+
type BuildBurnWithFeesIntentInput = {
|
|
313
|
+
source: CctpChain;
|
|
314
|
+
destination: CctpChain;
|
|
315
|
+
/** Exactly the amount the signed quote was requested for. */
|
|
316
|
+
amount: bigint;
|
|
317
|
+
/** The quote's USDC fee, collected by the contract on top of `amount`. */
|
|
318
|
+
fee: bigint;
|
|
319
|
+
mintRecipient: Address | string;
|
|
320
|
+
signedQuote: `0x${string}`;
|
|
321
|
+
/** Reserved by Circle for refunds it does not make today. */
|
|
322
|
+
refundAddress: Address | string;
|
|
323
|
+
/** Defaults to `amount + fee`. */
|
|
324
|
+
approveAmount?: bigint;
|
|
325
|
+
};
|
|
326
|
+
type BurnWithFeesIntent = {
|
|
327
|
+
calls: EvmCall[];
|
|
328
|
+
amount: bigint;
|
|
329
|
+
fee: bigint;
|
|
330
|
+
mintRecipientBytes32: `0x${string}`;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Approve and `depositForBurnWithFees` calls for a burn whose Fast and
|
|
334
|
+
* forwarding fees were paid upfront from a signed quote. The contract adds
|
|
335
|
+
* Circle's forwarding hook itself when the quote includes a `FORWARD` fee.
|
|
336
|
+
*/
|
|
337
|
+
declare function buildBurnWithFeesIntent(input: BuildBurnWithFeesIntentInput): BurnWithFeesIntent;
|
|
338
|
+
|
|
339
|
+
type MintIntent = {
|
|
340
|
+
destination: CctpChain;
|
|
341
|
+
call: EvmCall;
|
|
342
|
+
};
|
|
343
|
+
type BuildMintIntentInput = {
|
|
344
|
+
destination: CctpChain;
|
|
345
|
+
/** Raw 0x-prefixed CCTP message bytes from Iris. */
|
|
346
|
+
message: `0x${string}`;
|
|
347
|
+
/** Raw 0x-prefixed attestation bytes from Iris. */
|
|
348
|
+
attestation: `0x${string}`;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* `receiveMessage` on the destination's `MessageTransmitterV2`. EVM
|
|
352
|
+
* destinations only. Whoever submits the call pays destination gas.
|
|
353
|
+
*/
|
|
354
|
+
declare function buildMintIntent(input: BuildMintIntentInput): MintIntent;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Starknet address / mintRecipient helpers.
|
|
358
|
+
*
|
|
359
|
+
* Starknet uses 252-bit field elements, but CCTP messages carry 32-byte
|
|
360
|
+
* `mintRecipient` / `destinationCaller` fields. Whisk normalizes to two
|
|
361
|
+
* forms:
|
|
362
|
+
*
|
|
363
|
+
* - bytes32 hex (`0x` + 64 hex): what other ecosystems pack into the
|
|
364
|
+
* CCTP message envelope.
|
|
365
|
+
* - u256 bigint: what Starknet's `deposit_for_burn` expects in
|
|
366
|
+
* calldata.
|
|
367
|
+
*
|
|
368
|
+
* Conversion is just zero-extending the felt to 32 bytes or reading the
|
|
369
|
+
* bigint back from it.
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
declare function isValidStarknetFelt(s: string): boolean;
|
|
373
|
+
/** Throws on a malformed felt. */
|
|
374
|
+
declare function assertStarknetFelt(s: string): StarknetFelt;
|
|
375
|
+
/**
|
|
376
|
+
* Zero-pads a felt to 0x-prefixed 32-byte hex. Used for `mintRecipient`
|
|
377
|
+
* when bridging to Starknet from another ecosystem.
|
|
378
|
+
*/
|
|
379
|
+
declare function feltToBytes32Hex(felt: StarknetFelt): `0x${string}`;
|
|
380
|
+
/** Leading zeros are stripped. */
|
|
381
|
+
declare function bytes32HexToFelt(hex: `0x${string}` | string): StarknetFelt;
|
|
382
|
+
/** For packing into u256 calldata args. */
|
|
383
|
+
declare function feltToBigInt(felt: StarknetFelt): bigint;
|
|
384
|
+
|
|
385
|
+
/** Encode a u256 as `[lo, hi]` felt strings (decimal). */
|
|
386
|
+
declare function u256ToFelts(value: bigint): [string, string];
|
|
387
|
+
/** Encode a u32 / u64 / felt252 as a single felt string (decimal). */
|
|
388
|
+
declare function feltToString(value: number | bigint | string): string;
|
|
389
|
+
/**
|
|
390
|
+
* Encode a `ByteArray` from raw bytes.
|
|
391
|
+
*
|
|
392
|
+
* Cairo `ByteArray` calldata serialization:
|
|
393
|
+
*
|
|
394
|
+
* [ data.length: u32,
|
|
395
|
+
* ...data: felt252 (31 bytes each, big-endian),
|
|
396
|
+
* pending_word: felt252 (< 31 bytes, big-endian),
|
|
397
|
+
* pending_word_len: u32 ]
|
|
398
|
+
*
|
|
399
|
+
* Each 31-byte block becomes one felt whose value is the big-endian
|
|
400
|
+
* integer of those bytes. The trailing (bytes.length % 31) bytes go
|
|
401
|
+
* into `pending_word`, again as a big-endian integer of exactly that
|
|
402
|
+
* many bytes.
|
|
403
|
+
*
|
|
404
|
+
* starknet.js's `byteArray.byteArrayFromString` is no substitute: it
|
|
405
|
+
* treats the input as a UTF-8 string, which mangles raw bytes like
|
|
406
|
+
* CCTP attestation blobs.
|
|
407
|
+
*/
|
|
408
|
+
declare function bytesToByteArrayFelts(bytes: Uint8Array): string[];
|
|
409
|
+
/** Encode a 0x-prefixed hex blob (any length) as a Cairo ByteArray. */
|
|
410
|
+
declare function hexToByteArrayFelts(hex: string): string[];
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Starknet CCTP V2 `deposit_for_burn` / `deposit_for_burn_with_hook`
|
|
414
|
+
* Call builder.
|
|
415
|
+
*
|
|
416
|
+
* Cairo signatures (from `circlefin/starknet-cctp`):
|
|
417
|
+
*
|
|
418
|
+
* fn deposit_for_burn(
|
|
419
|
+
* amount: u256,
|
|
420
|
+
* destination_domain: u32,
|
|
421
|
+
* mint_recipient: u256,
|
|
422
|
+
* burn_token: ContractAddress,
|
|
423
|
+
* destination_caller: u256,
|
|
424
|
+
* max_fee: u256,
|
|
425
|
+
* min_finality_threshold: u32,
|
|
426
|
+
* )
|
|
427
|
+
*
|
|
428
|
+
* fn deposit_for_burn_with_hook(
|
|
429
|
+
* ...same...
|
|
430
|
+
* hook_data: ByteArray,
|
|
431
|
+
* )
|
|
432
|
+
*
|
|
433
|
+
* USDC on Starknet behaves like ERC-20: burn pulls funds via
|
|
434
|
+
* `transferFrom`, so the caller must `approve(TMM, amount)` first with
|
|
435
|
+
* `buildStarknetApproveCall`.
|
|
436
|
+
*/
|
|
437
|
+
|
|
438
|
+
type StarknetCall = {
|
|
439
|
+
contractAddress: StarknetFelt;
|
|
440
|
+
/** Cairo function name (snake_case). */
|
|
441
|
+
entrypoint: string;
|
|
442
|
+
/** Pre-serialized calldata as a flat felt array (decimal strings). */
|
|
443
|
+
calldata: string[];
|
|
444
|
+
};
|
|
445
|
+
type BuildStarknetBurnIntentInput = {
|
|
446
|
+
source: StarknetChain;
|
|
447
|
+
destinationDomain: number;
|
|
448
|
+
/** USDC subunits (6 decimals), the canonical CCTP amount. */
|
|
449
|
+
amount: bigint;
|
|
450
|
+
/** `maxFee` cap in 6-decimal subunits. */
|
|
451
|
+
maxFee: bigint;
|
|
452
|
+
/**
|
|
453
|
+
* 32-byte mintRecipient, packed by Starknet into a single u256. The
|
|
454
|
+
* caller is responsible for encoding correctly:
|
|
455
|
+
* - EVM 20-byte address left-padded to 32 bytes
|
|
456
|
+
* - Solana recipient USDC ATA pubkey (32 bytes raw)
|
|
457
|
+
* - Stellar CctpForwarder strkey decoded to 32 bytes
|
|
458
|
+
* - Starknet contract felt
|
|
459
|
+
*/
|
|
460
|
+
mintRecipient: bigint;
|
|
461
|
+
/** `destinationCaller` u256. Zero = any caller. */
|
|
462
|
+
destinationCaller: bigint;
|
|
463
|
+
/** Optional hookData; when set, builds `deposit_for_burn_with_hook`. */
|
|
464
|
+
hookData?: Uint8Array;
|
|
465
|
+
/** Take it from the fee tier. */
|
|
466
|
+
minFinalityThreshold: FinalityThreshold;
|
|
467
|
+
};
|
|
468
|
+
type StarknetBurnIntent = {
|
|
469
|
+
source: StarknetChain;
|
|
470
|
+
destinationDomain: number;
|
|
471
|
+
amount: bigint;
|
|
472
|
+
maxFee: bigint;
|
|
473
|
+
call: StarknetCall;
|
|
474
|
+
withHook: boolean;
|
|
475
|
+
};
|
|
476
|
+
declare function buildStarknetBurnIntent(input: BuildStarknetBurnIntentInput): StarknetBurnIntent;
|
|
477
|
+
/**
|
|
478
|
+
* Starknet's USDC follows the standard ERC-20 / SNIP-2 interface:
|
|
479
|
+
* `approve(spender, amount: u256)`.
|
|
480
|
+
*/
|
|
481
|
+
declare function buildStarknetApproveCall(args: {
|
|
482
|
+
source: StarknetChain;
|
|
483
|
+
spender: StarknetFelt;
|
|
484
|
+
amount: bigint;
|
|
485
|
+
}): StarknetCall;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Starknet CCTP V2 `receive_message` Call builder.
|
|
489
|
+
*
|
|
490
|
+
* Cairo signature:
|
|
491
|
+
*
|
|
492
|
+
* fn receive_message(message: ByteArray, attestation: ByteArray) -> bool
|
|
493
|
+
*
|
|
494
|
+
* Same two-byte-array shape as EVM's `receiveMessage`. The recipient
|
|
495
|
+
* (or any third party) signs this on the destination side after Iris
|
|
496
|
+
* attests the burn.
|
|
497
|
+
*/
|
|
498
|
+
|
|
499
|
+
type BuildStarknetReceiveIntentInput = {
|
|
500
|
+
destination: StarknetChain;
|
|
501
|
+
/** 0x-prefixed CCTP message bytes from Iris. */
|
|
502
|
+
message: `0x${string}`;
|
|
503
|
+
/** 0x-prefixed attestation bytes from Iris. */
|
|
504
|
+
attestation: `0x${string}`;
|
|
505
|
+
};
|
|
506
|
+
type StarknetReceiveIntent = {
|
|
507
|
+
destination: StarknetChain;
|
|
508
|
+
call: StarknetCall;
|
|
509
|
+
};
|
|
510
|
+
declare function buildStarknetReceiveIntent(input: BuildStarknetReceiveIntentInput): StarknetReceiveIntent;
|
|
511
|
+
|
|
512
|
+
type StellarStrkeyType = "G" | "M" | "C";
|
|
513
|
+
declare function isValidStellarStrkey(s: string): boolean;
|
|
514
|
+
/** Throws if `s` is not a valid strkey. */
|
|
515
|
+
declare function strkeyType(s: string): StellarStrkeyType;
|
|
516
|
+
/** The raw 32-byte payload of a G, M or C strkey, as CCTP carries it. */
|
|
517
|
+
declare function decodeStrkeyToBytes32(s: string): Uint8Array;
|
|
518
|
+
/** Encode a 32-byte payload as a contract strkey (C…). */
|
|
519
|
+
declare function encodeContractStrkey(bytes: Uint8Array): string;
|
|
520
|
+
/**
|
|
521
|
+
* Convert a Stellar contract strkey (C…) to its 0x-prefixed bytes32
|
|
522
|
+
* hex form. Used when an EVM `depositForBurn` needs to encode a
|
|
523
|
+
* Stellar contract as `mintRecipient` / `destinationCaller`.
|
|
524
|
+
*/
|
|
525
|
+
declare function contractStrkeyToBytes32Hex(s: string): `0x${string}`;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Convert from Stellar's 7-decimal subunit amount to CCTP's 6-decimal
|
|
529
|
+
* canonical amount. Drops the 7th decimal (rounds toward zero). The
|
|
530
|
+
* dust stays on Stellar; it's not lost in the bridge.
|
|
531
|
+
*
|
|
532
|
+
* @returns 6-decimal subunits (canonical amount for the CCTP message)
|
|
533
|
+
*/
|
|
534
|
+
declare function stellarSubunitsToCanonical(stellarSubunits: bigint): bigint;
|
|
535
|
+
/**
|
|
536
|
+
* Convert from CCTP's 6-decimal canonical amount to Stellar's 7-decimal
|
|
537
|
+
* subunit amount. Scales by 10, as the inbound mint does.
|
|
538
|
+
*
|
|
539
|
+
* @returns 7-decimal subunits (the on-chain amount minted on Stellar)
|
|
540
|
+
*/
|
|
541
|
+
declare function canonicalToStellarSubunits(canonicalSubunits: bigint): bigint;
|
|
542
|
+
/**
|
|
543
|
+
* The fractional 7th decimal that a burn from Stellar drops and leaves
|
|
544
|
+
* in the sender's account.
|
|
545
|
+
*/
|
|
546
|
+
declare function stellarBurnDust(stellarSubunits: bigint): bigint;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @param forwardRecipientStrkey - Stellar strkey of the final recipient
|
|
550
|
+
* (G…, C…, or M… address). The Forwarder will atomically transfer
|
|
551
|
+
* minted USDC to this address after the on-chain mint.
|
|
552
|
+
* @param integratorPayload - Optional extra bytes appended after the
|
|
553
|
+
* strkey. Whisk doesn't use it.
|
|
554
|
+
* @returns 0x-prefixed hex string ready for the EVM/Solana burn call.
|
|
555
|
+
*/
|
|
556
|
+
declare function buildStellarForwarderHookData(forwardRecipientStrkey: string, integratorPayload?: Uint8Array): `0x${string}`;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Stellar CCTP V2 `deposit_for_burn` invocation builder.
|
|
560
|
+
*
|
|
561
|
+
* Soroban contract entry points (from `circlefin/stellar-cctp`):
|
|
562
|
+
*
|
|
563
|
+
* deposit_for_burn(
|
|
564
|
+
* caller: Address,
|
|
565
|
+
* amount: i128, // 7-decimal subunits (local USDC)
|
|
566
|
+
* destination_domain: u32,
|
|
567
|
+
* mint_recipient: BytesN<32>,
|
|
568
|
+
* burn_token: Address, // USDC SAC contract
|
|
569
|
+
* destination_caller: BytesN<32>,
|
|
570
|
+
* max_fee: i128, // 7-decimal subunits
|
|
571
|
+
* min_finality_threshold: u32,
|
|
572
|
+
* )
|
|
573
|
+
*
|
|
574
|
+
* deposit_for_burn_with_hook(
|
|
575
|
+
* ...same as above plus...
|
|
576
|
+
* hook_data: Bytes,
|
|
577
|
+
* )
|
|
578
|
+
*
|
|
579
|
+
* The contract internally normalizes 7-decimal local amounts to
|
|
580
|
+
* 6-decimal canonical for the message. Dust below 0.0000001 USDC stays
|
|
581
|
+
* on the user's Stellar balance.
|
|
582
|
+
*
|
|
583
|
+
* `amount` and `max_fee` here are expressed in Stellar's 7-decimal
|
|
584
|
+
* subunits: multiply 6-decimal CCTP amounts by 10 before passing in.
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
type StellarInvocation = {
|
|
588
|
+
ecosystem: "stellar";
|
|
589
|
+
contractId: string;
|
|
590
|
+
functionName: string;
|
|
591
|
+
args: xdr.ScVal[];
|
|
592
|
+
/** Pre-built XDR operation the adapter wraps in a Soroban transaction. */
|
|
593
|
+
operation: xdr.Operation;
|
|
594
|
+
};
|
|
595
|
+
type BuildStellarBurnIntentInput = {
|
|
596
|
+
source: StellarChain;
|
|
597
|
+
destinationDomain: number;
|
|
598
|
+
/**
|
|
599
|
+
* `mintRecipient` 32-byte payload as encoded into the CCTP message.
|
|
600
|
+
* The caller is responsible for encoding it correctly:
|
|
601
|
+
* - EVM 20-byte address left-padded to 32 bytes
|
|
602
|
+
* - Solana recipient USDC ATA pubkey (32 bytes raw)
|
|
603
|
+
* - Starknet felt zero-padded to 32 bytes
|
|
604
|
+
*/
|
|
605
|
+
mintRecipientBytes32: Uint8Array;
|
|
606
|
+
/** Amount in 7-decimal Stellar USDC subunits. */
|
|
607
|
+
amount: bigint;
|
|
608
|
+
/** Max fee in 7-decimal Stellar USDC subunits. */
|
|
609
|
+
maxFee: bigint;
|
|
610
|
+
/**
|
|
611
|
+
* `destinationCaller` 32-byte payload. For Stellar destinations this
|
|
612
|
+
* MUST equal the `CctpForwarder` decoded to bytes32; for other
|
|
613
|
+
* destinations this is typically 32 zero bytes (any caller).
|
|
614
|
+
*/
|
|
615
|
+
destinationCallerBytes32: Uint8Array;
|
|
616
|
+
/** Caller strkey (G or C). The wallet that authorizes the burn. */
|
|
617
|
+
caller: string;
|
|
618
|
+
/**
|
|
619
|
+
* Optional hookData. When set, the builder targets
|
|
620
|
+
* `deposit_for_burn_with_hook`; when unset, it targets the plain
|
|
621
|
+
* `deposit_for_burn`.
|
|
622
|
+
*/
|
|
623
|
+
hookData?: Uint8Array;
|
|
624
|
+
/** 2000 on Stellar, which has no Fast Transfer. Take it from the fee tier. */
|
|
625
|
+
minFinalityThreshold: FinalityThreshold;
|
|
626
|
+
};
|
|
627
|
+
type StellarBurnIntent = {
|
|
628
|
+
source: StellarChain;
|
|
629
|
+
destinationDomain: number;
|
|
630
|
+
amount: bigint;
|
|
631
|
+
maxFee: bigint;
|
|
632
|
+
invocation: StellarInvocation;
|
|
633
|
+
withHook: boolean;
|
|
634
|
+
};
|
|
635
|
+
declare function buildStellarBurnIntent(input: BuildStellarBurnIntentInput): StellarBurnIntent;
|
|
636
|
+
/** The 32-byte payload of a strkey, as CCTP message fields carry it. */
|
|
637
|
+
declare function strkeyTo32Bytes(strkey: string): Uint8Array;
|
|
638
|
+
|
|
639
|
+
type BuildStellarApproveInvocationInput = {
|
|
640
|
+
source: StellarChain;
|
|
641
|
+
/** Owner strkey (G/M/C): the wallet authorizing TMM to spend USDC. */
|
|
642
|
+
owner: string;
|
|
643
|
+
/** Usually the chain's TMM contract (C...). */
|
|
644
|
+
spender: string;
|
|
645
|
+
/** Amount in 7-decimal Stellar USDC subunits. */
|
|
646
|
+
amount: bigint;
|
|
647
|
+
/**
|
|
648
|
+
* Ledger sequence at which the allowance expires. The SAC rejects a
|
|
649
|
+
* nonzero allowance that expires before the current ledger, so pass the
|
|
650
|
+
* latest ledger plus a short window.
|
|
651
|
+
*/
|
|
652
|
+
expirationLedger: number;
|
|
653
|
+
};
|
|
654
|
+
declare function buildStellarApproveInvocation(input: BuildStellarApproveInvocationInput): StellarInvocation;
|
|
655
|
+
|
|
656
|
+
type BuildStellarMintIntentInput = {
|
|
657
|
+
destination: StellarChain;
|
|
658
|
+
/** Raw CCTP message bytes from Iris. */
|
|
659
|
+
message: Uint8Array;
|
|
660
|
+
/** Raw attestation bytes from Iris. */
|
|
661
|
+
attestation: Uint8Array;
|
|
662
|
+
};
|
|
663
|
+
type StellarMintIntent = {
|
|
664
|
+
destination: StellarChain;
|
|
665
|
+
invocation: StellarInvocation;
|
|
666
|
+
};
|
|
667
|
+
declare function buildStellarMintIntent(input: BuildStellarMintIntentInput): StellarMintIntent;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Program-Derived Address (PDA) helpers for CCTP V2 on Solana.
|
|
671
|
+
*
|
|
672
|
+
* Seed conventions verified against Circle's
|
|
673
|
+
* `circlefin/solana-cctp-contracts` (programs/v2). Two key gotchas:
|
|
674
|
+
*
|
|
675
|
+
* - `remote_token_messenger` uses the destination domain encoded as
|
|
676
|
+
* its *decimal string* bytes, NOT u32 LE. So domain 0 →
|
|
677
|
+
* `Buffer.from("0", "utf8")`, not `Buffer.from([0, 0, 0, 0])`.
|
|
678
|
+
* - `token_pair` uses the source domain as decimal string too,
|
|
679
|
+
* plus the 32-byte source-token pubkey (left-padded EVM address
|
|
680
|
+
* for non-Solana sources).
|
|
681
|
+
*/
|
|
682
|
+
|
|
683
|
+
/** Seed prefix bytes for each PDA we need. */
|
|
684
|
+
declare const SEEDS: {
|
|
685
|
+
readonly tokenMessenger: Uint8Array<ArrayBuffer>;
|
|
686
|
+
readonly tokenMinter: Uint8Array<ArrayBuffer>;
|
|
687
|
+
readonly senderAuthority: Uint8Array<ArrayBuffer>;
|
|
688
|
+
readonly remoteTokenMessenger: Uint8Array<ArrayBuffer>;
|
|
689
|
+
readonly localToken: Uint8Array<ArrayBuffer>;
|
|
690
|
+
readonly tokenPair: Uint8Array<ArrayBuffer>;
|
|
691
|
+
readonly custody: Uint8Array<ArrayBuffer>;
|
|
692
|
+
readonly denylistAccount: Uint8Array<ArrayBuffer>;
|
|
693
|
+
readonly messageTransmitter: Uint8Array<ArrayBuffer>;
|
|
694
|
+
readonly messageTransmitterAuthority: Uint8Array<ArrayBuffer>;
|
|
695
|
+
readonly usedNonce: Uint8Array<ArrayBuffer>;
|
|
696
|
+
readonly eventAuthority: Uint8Array<ArrayBuffer>;
|
|
697
|
+
};
|
|
698
|
+
/** `token_messenger` PDA on the TokenMessengerMinter program. */
|
|
699
|
+
declare function deriveTokenMessenger(tokenMessengerMinterProgram: PublicKey): PublicKey;
|
|
700
|
+
/** `token_minter` PDA on the TokenMessengerMinter program. */
|
|
701
|
+
declare function deriveTokenMinter(tokenMessengerMinterProgram: PublicKey): PublicKey;
|
|
702
|
+
/** `sender_authority` PDA on the TokenMessengerMinter program. */
|
|
703
|
+
declare function deriveSenderAuthority(tokenMessengerMinterProgram: PublicKey): PublicKey;
|
|
704
|
+
/**
|
|
705
|
+
* `remote_token_messenger` PDA, keyed by the **destination domain**
|
|
706
|
+
* as its decimal string representation (Circle's convention).
|
|
707
|
+
*/
|
|
708
|
+
declare function deriveRemoteTokenMessenger(tokenMessengerMinterProgram: PublicKey, domain: number): PublicKey;
|
|
709
|
+
/** `local_token` PDA, keyed by the local USDC SPL mint. */
|
|
710
|
+
declare function deriveLocalToken(tokenMessengerMinterProgram: PublicKey, mint: PublicKey): PublicKey;
|
|
711
|
+
/**
|
|
712
|
+
* `token_pair` PDA, used on the receive (mint) side to map a
|
|
713
|
+
* (source domain, source token) pair to the local mint. Source token
|
|
714
|
+
* is 32 bytes (left-padded for EVM sources).
|
|
715
|
+
*/
|
|
716
|
+
declare function deriveTokenPair(tokenMessengerMinterProgram: PublicKey, sourceDomain: number, sourceTokenBytes32: Uint8Array): PublicKey;
|
|
717
|
+
/** `custody` token account PDA, keyed by the local USDC mint. */
|
|
718
|
+
declare function deriveCustodyTokenAccount(tokenMessengerMinterProgram: PublicKey, mint: PublicKey): PublicKey;
|
|
719
|
+
/**
|
|
720
|
+
* `denylist_account` PDA, owner-keyed. Burn fails if this PDA exists
|
|
721
|
+
* with data; the user's denylist record is "absence of data."
|
|
722
|
+
*/
|
|
723
|
+
declare function deriveDenylistAccount(tokenMessengerMinterProgram: PublicKey, owner: PublicKey): PublicKey;
|
|
724
|
+
/** `message_transmitter` config PDA on the MessageTransmitter program. */
|
|
725
|
+
declare function deriveMessageTransmitter(messageTransmitterProgram: PublicKey): PublicKey;
|
|
726
|
+
/**
|
|
727
|
+
* `message_transmitter_authority` PDA, keyed by the *receiver*
|
|
728
|
+
* program. For CCTP burns, the receiver is the TokenMessengerMinter.
|
|
729
|
+
*/
|
|
730
|
+
declare function deriveMessageTransmitterAuthority(messageTransmitterProgram: PublicKey, receiverProgram: PublicKey): PublicKey;
|
|
731
|
+
/**
|
|
732
|
+
* `used_nonce` PDA, seeded by the 32-byte nonce in the CCTP message
|
|
733
|
+
* header: `message[12..44]` per Circle's `Message::NONCE_INDEX` /
|
|
734
|
+
* `Message::SENDER_INDEX` layout.
|
|
735
|
+
*/
|
|
736
|
+
declare function deriveUsedNonce(messageTransmitterProgram: PublicKey, messageBytes: Uint8Array): PublicKey;
|
|
737
|
+
/** `__event_authority` PDA, used by Anchor's `#[event_cpi]`. */
|
|
738
|
+
declare function deriveEventAuthority(programId: PublicKey): PublicKey;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Snake-case the name as the Rust function declares it
|
|
742
|
+
* (`deposit_for_burn`, not `depositForBurn`).
|
|
743
|
+
*
|
|
744
|
+
* Uses `@noble/hashes` because this runs at module load in browser
|
|
745
|
+
* bundles, where `node:crypto` isn't available.
|
|
746
|
+
*/
|
|
747
|
+
declare function anchorDiscriminator(snakeCaseName: string): Uint8Array;
|
|
748
|
+
/** TokenMessengerMinterV2 `deposit_for_burn` (no hook data). */
|
|
749
|
+
declare const DISCRIMINATOR_DEPOSIT_FOR_BURN: Uint8Array;
|
|
750
|
+
/** TokenMessengerMinterV2 `deposit_for_burn_with_hook`. */
|
|
751
|
+
declare const DISCRIMINATOR_DEPOSIT_FOR_BURN_WITH_HOOK: Uint8Array;
|
|
752
|
+
/** MessageTransmitterV2 `receive_message`. */
|
|
753
|
+
declare const DISCRIMINATOR_RECEIVE_MESSAGE: Uint8Array;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Solana CCTP V2 `deposit_for_burn` / `deposit_for_burn_with_hook`
|
|
757
|
+
* instruction builder.
|
|
758
|
+
*
|
|
759
|
+
* Account list verified against
|
|
760
|
+
* `circlefin/solana-cctp-contracts/programs/v2/token-messenger-minter-v2`:
|
|
761
|
+
*
|
|
762
|
+
* 1. owner (signer, ro)
|
|
763
|
+
* 2. event_rent_payer (signer, writable)
|
|
764
|
+
* 3. sender_authority_pda (ro) PDA["sender_authority"] on TMM
|
|
765
|
+
* 4. burn_token_account (writable) user's USDC ATA
|
|
766
|
+
* 5. denylist_account (ro) PDA["denylist_account", owner] on TMM
|
|
767
|
+
* 6. message_transmitter (writable) PDA["message_transmitter"] on MT
|
|
768
|
+
* 7. token_messenger (ro) PDA["token_messenger"] on TMM
|
|
769
|
+
* 8. remote_token_messenger (ro) PDA["remote_token_messenger", destDomain.toString()] on TMM
|
|
770
|
+
* 9. token_minter (ro) PDA["token_minter"] on TMM
|
|
771
|
+
* 10. local_token (writable) PDA["local_token", burnTokenMint] on TMM
|
|
772
|
+
* 11. burn_token_mint (writable)
|
|
773
|
+
* 12. message_sent_event_data (signer, writable) fresh keypair, generated client-side
|
|
774
|
+
* 13. message_transmitter_program (ro)
|
|
775
|
+
* 14. token_messenger_minter_program (ro)
|
|
776
|
+
* 15. token_program (ro)
|
|
777
|
+
* 16. system_program (ro)
|
|
778
|
+
* 17. event_authority (ro) PDA["__event_authority"] on TMM (added by #[event_cpi])
|
|
779
|
+
* 18. program (ro) TMM program ID (added by #[event_cpi])
|
|
780
|
+
*
|
|
781
|
+
* Encoding (Borsh):
|
|
782
|
+
* amount: u64 LE
|
|
783
|
+
* destination_domain: u32 LE
|
|
784
|
+
* mint_recipient: Pubkey (32 bytes)
|
|
785
|
+
* destination_caller: Pubkey (32 bytes)
|
|
786
|
+
* max_fee: u64 LE
|
|
787
|
+
* min_finality_threshold: u32 LE
|
|
788
|
+
* hook_data: Vec<u8> [only for deposit_for_burn_with_hook]
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
declare const ANY_DESTINATION_CALLER: PublicKey;
|
|
792
|
+
type BuildSolanaBurnIntentInput = {
|
|
793
|
+
source: SolanaChain;
|
|
794
|
+
/** Destination chain CCTP domain (0=Eth, 1=Avax, 3=Arb, 6=Base, etc.). */
|
|
795
|
+
destinationDomain: number;
|
|
796
|
+
/** USDC subunits (6 decimals). Must be > 0 and ≤ 10M USDC. */
|
|
797
|
+
amount: bigint;
|
|
798
|
+
/**
|
|
799
|
+
* Recipient on the destination chain, as 32 bytes (bytes32-encoded).
|
|
800
|
+
* EVM addresses are left-padded; Solana addresses pass through.
|
|
801
|
+
*/
|
|
802
|
+
mintRecipientBytes32: Uint8Array;
|
|
803
|
+
/** USDC subunits; caps the protocol + forwarder fees. */
|
|
804
|
+
maxFee: bigint;
|
|
805
|
+
owner: PublicKey;
|
|
806
|
+
/** Fresh keypair pubkey for `message_sent_event_data`. */
|
|
807
|
+
messageSentEventDataKey: PublicKey;
|
|
808
|
+
/** User's USDC ATA on the source chain. */
|
|
809
|
+
ownerUsdcAta: PublicKey;
|
|
810
|
+
/** `destinationCaller` as bytes32. Defaults to any caller. */
|
|
811
|
+
destinationCallerBytes32?: Uint8Array;
|
|
812
|
+
/**
|
|
813
|
+
* Non-empty bytes (the `cctp-forward` hookData, or the Stellar
|
|
814
|
+
* Forwarder's) select `deposit_for_burn_with_hook`. Leave unset for
|
|
815
|
+
* the plain burn.
|
|
816
|
+
*/
|
|
817
|
+
hookData?: Uint8Array;
|
|
818
|
+
/** Take it from the fee tier. */
|
|
819
|
+
minFinalityThreshold: FinalityThreshold;
|
|
820
|
+
};
|
|
821
|
+
type SolanaInstruction = {
|
|
822
|
+
programId: PublicKey;
|
|
823
|
+
keys: AccountMeta[];
|
|
824
|
+
data: Buffer;
|
|
825
|
+
ecosystem: "solana";
|
|
826
|
+
};
|
|
827
|
+
type SolanaBurnIntent = {
|
|
828
|
+
source: SolanaChain;
|
|
829
|
+
destinationDomain: number;
|
|
830
|
+
amount: bigint;
|
|
831
|
+
maxFee: bigint;
|
|
832
|
+
instruction: SolanaInstruction;
|
|
833
|
+
/** Pubkey the caller must include as a fresh signer. */
|
|
834
|
+
messageSentEventDataKey: PublicKey;
|
|
835
|
+
withHook: boolean;
|
|
836
|
+
};
|
|
837
|
+
declare function buildSolanaBurnIntent(input: BuildSolanaBurnIntentInput): SolanaBurnIntent;
|
|
838
|
+
/**
|
|
839
|
+
* Convenience: build a `TransactionInstruction` directly from the
|
|
840
|
+
* intent. Most callers will want this; the raw `instruction` shape
|
|
841
|
+
* keeps the type stable across `@solana/web3.js` minor versions.
|
|
842
|
+
*/
|
|
843
|
+
declare function burnIntentToTransactionInstruction(intent: SolanaBurnIntent): TransactionInstruction;
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Solana CCTP V2 `receive_message` instruction builder.
|
|
847
|
+
*
|
|
848
|
+
* `receive_message` is dispatched on `MessageTransmitterV2`. It does
|
|
849
|
+
* its own attestation verification, opens a `used_nonce` PDA, then
|
|
850
|
+
* CPIs into the receiver program (TokenMessengerMinterV2) via
|
|
851
|
+
* `handle_receive_finalized_message`. All accounts the receiver needs
|
|
852
|
+
* are appended after MessageTransmitter's own.
|
|
853
|
+
*
|
|
854
|
+
* Account list verified against
|
|
855
|
+
* `circlefin/solana-cctp-contracts/programs/v2`:
|
|
856
|
+
*
|
|
857
|
+
* MessageTransmitterV2 ReceiveMessageContext (with #[event_cpi]):
|
|
858
|
+
* 1. payer (signer, writable)
|
|
859
|
+
* 2. caller (signer, ro)
|
|
860
|
+
* 3. authority_pda (ro)
|
|
861
|
+
* 4. message_transmitter (ro)
|
|
862
|
+
* 5. used_nonce (writable, init)
|
|
863
|
+
* 6. receiver (ro) TMM program
|
|
864
|
+
* 7. system_program (ro)
|
|
865
|
+
* 8. event_authority (MT) (ro)
|
|
866
|
+
* 9. program (MT) (ro)
|
|
867
|
+
*
|
|
868
|
+
* Remaining accounts, from TokenMessengerMinterV2's
|
|
869
|
+
* HandleReceiveMessageContext (with #[event_cpi]):
|
|
870
|
+
* 10. token_messenger (ro)
|
|
871
|
+
* 11. remote_token_messenger (ro)
|
|
872
|
+
* 12. token_minter (writable)
|
|
873
|
+
* 13. local_token (writable)
|
|
874
|
+
* 14. token_pair (ro)
|
|
875
|
+
* 15. fee_recipient_token_account (writable)
|
|
876
|
+
* 16. recipient_token_account (writable)
|
|
877
|
+
* 17. custody_token_account (writable)
|
|
878
|
+
* 18. token_program (ro)
|
|
879
|
+
* 19. event_authority (TMM) (ro)
|
|
880
|
+
* 20. program (TMM) (ro)
|
|
881
|
+
*/
|
|
882
|
+
|
|
883
|
+
type BuildSolanaReceiveIntentInput = {
|
|
884
|
+
destination: SolanaChain;
|
|
885
|
+
/** Raw CCTP message bytes from Iris. */
|
|
886
|
+
message: Uint8Array;
|
|
887
|
+
/** Raw attestation bytes from Iris. */
|
|
888
|
+
attestation: Uint8Array;
|
|
889
|
+
/** Source CCTP domain (the chain the burn came from). */
|
|
890
|
+
sourceDomain: number;
|
|
891
|
+
/** Source-chain USDC token, 32-byte left-padded. */
|
|
892
|
+
sourceTokenBytes32: Uint8Array;
|
|
893
|
+
/** The `fee_recipient` ATA, read from the on-chain TokenMessenger state. */
|
|
894
|
+
feeRecipientUsdcAta: PublicKey;
|
|
895
|
+
/** End-recipient's USDC ATA on Solana. Must be pre-created. */
|
|
896
|
+
recipientUsdcAta: PublicKey;
|
|
897
|
+
/** Pays for and signs the receive. Also passed as `caller`. */
|
|
898
|
+
payer: PublicKey;
|
|
899
|
+
};
|
|
900
|
+
type SolanaReceiveIntent = {
|
|
901
|
+
destination: SolanaChain;
|
|
902
|
+
instruction: {
|
|
903
|
+
programId: PublicKey;
|
|
904
|
+
keys: AccountMeta[];
|
|
905
|
+
data: Buffer;
|
|
906
|
+
ecosystem: "solana";
|
|
907
|
+
};
|
|
908
|
+
};
|
|
909
|
+
declare function buildSolanaReceiveIntent(input: BuildSolanaReceiveIntentInput): SolanaReceiveIntent;
|
|
910
|
+
/** Convenience: produce a `TransactionInstruction` from the intent. */
|
|
911
|
+
declare function receiveIntentToTransactionInstruction(intent: SolanaReceiveIntent): TransactionInstruction;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Solana CCTP on-chain state parsing.
|
|
915
|
+
*
|
|
916
|
+
* The TokenMessenger account holds the `fee_recipient` pubkey that
|
|
917
|
+
* `receive_message` requires as a remaining-account constraint. The
|
|
918
|
+
* account isn't derived: it's an arbitrary owner-configured pubkey
|
|
919
|
+
* stored in state, so the executor must read it from chain.
|
|
920
|
+
*
|
|
921
|
+
* Account layout (Anchor, verified against Circle's
|
|
922
|
+
* `programs/v2/token-messenger-minter/src/token_messenger/state.rs`):
|
|
923
|
+
*
|
|
924
|
+
* 0..8 discriminator
|
|
925
|
+
* 8..40 denylister Pubkey
|
|
926
|
+
* 40..72 owner Pubkey
|
|
927
|
+
* 72..104 pending_owner Pubkey
|
|
928
|
+
* 104..108 message_body_version u32 LE
|
|
929
|
+
* 108..109 authority_bump u8
|
|
930
|
+
* 109..141 fee_recipient Pubkey
|
|
931
|
+
* 141..173 min_fee_controller Pubkey
|
|
932
|
+
* 173..177 min_fee u32 LE
|
|
933
|
+
*/
|
|
934
|
+
|
|
935
|
+
/** Throws if the account data ends before `fee_recipient` does. */
|
|
936
|
+
declare function parseTokenMessengerFeeRecipient(accountData: Uint8Array): PublicKey;
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* CCTP V2 protocol layer.
|
|
940
|
+
*
|
|
941
|
+
* Owns the direct integration with CCTP V2 contracts and Circle's Iris
|
|
942
|
+
* attestation API. Pure protocol builders and HTTP client; no wallet
|
|
943
|
+
* state, no transaction submission.
|
|
944
|
+
*/
|
|
945
|
+
declare const VERSION = "0.1.0";
|
|
946
|
+
|
|
947
|
+
export { ANY_DESTINATION_CALLER$1 as ANY_DESTINATION_CALLER, Address, type BuildBurnIntentInput, type BuildBurnWithFeesIntentInput, type BuildMintIntentInput, type BuildSolanaBurnIntentInput, type BuildSolanaReceiveIntentInput, type BuildStarknetBurnIntentInput, type BuildStarknetReceiveIntentInput, type BuildStellarBurnIntentInput, type BuildStellarMintIntentInput, BurnFeeTier, type BurnIntent, type BurnWithFeesIntent, CCTP_FORWARD_HOOK_DATA, CCTP_FORWARD_HOOK_DATA_LENGTH, CctpChain, type ComputeMaxFeeInput, type ComputeMaxFeeResult, DISCRIMINATOR_DEPOSIT_FOR_BURN, DISCRIMINATOR_DEPOSIT_FOR_BURN_WITH_HOOK, DISCRIMINATOR_RECEIVE_MESSAGE, type DecodedBurnMessage, type EvmCall, EvmChain, FinalityThreshold, ForwarderFeeTier, type GetStandardMinFeeOptions, InvalidAddressError, InvalidBytes32Error, InvalidInputError, type MintIntent, type RpcOptions, ANY_DESTINATION_CALLER as SOLANA_ANY_DESTINATION_CALLER, SEEDS as SOLANA_CCTP_PDA_SEEDS, type SolanaBurnIntent, SolanaChain, type SolanaInstruction, type SolanaReceiveIntent, type StarknetBurnIntent, type StarknetCall, StarknetChain, StarknetFelt, type StarknetReceiveIntent, type StarknetTransactionStatus, type StellarBurnIntent, StellarChain, type StellarInvocation, type StellarMintIntent, type StellarStrkeyType, type TransactionStatus, VERSION, anchorDiscriminator, assertStarknetFelt, buildBurnIntent, buildBurnWithFeesIntent, buildForwarderHookData, buildMintIntent, buildSolanaBurnIntent, buildSolanaReceiveIntent, buildStarknetApproveCall, buildStarknetBurnIntent, buildStarknetReceiveIntent, buildStellarApproveInvocation, buildStellarBurnIntent, buildStellarForwarderHookData, buildStellarMintIntent, burnIntentToTransactionInstruction, bytes32HexToFelt, bytesToByteArrayFelts, canonicalToStellarSubunits, computeBurnFee, computeMaxFee, contractStrkeyToBytes32Hex, decodeBurnMessage, decodeStrkeyToBytes32, deriveCustodyTokenAccount, deriveDenylistAccount, deriveEventAuthority, deriveLocalToken, deriveMessageTransmitter, deriveMessageTransmitterAuthority, deriveRemoteTokenMessenger, deriveSenderAuthority, deriveTokenMessenger, deriveTokenMinter, deriveTokenPair, deriveUsedNonce, encodeContractStrkey, feltToBigInt, feltToBytes32Hex, fromBytes32, getBlockNumber, getGasPrice, getStandardMinFee, getStarknetClassHashAt, getStarknetTransactionStatus, getTransactionStatus, getUsdcBalance, hexToByteArrayFelts, isAddress, isForwarderHookData, isNonceUsed, isStarknetNonceUsed, isStellarNonceUsed, isValidStarknetFelt, isValidStellarStrkey, parseFeeBps, parseForwarderFee, parseTokenMessengerFeeRecipient, receiveIntentToTransactionInstruction, selectForwarderFee, feltToString as starknetFeltToString, stellarBurnDust, stellarSubunitsToCanonical, strkeyTo32Bytes, strkeyType, toBytes32, tryFromBytes32, u256ToFelts };
|