@fastxyz/allset-sdk 0.1.12 → 1.0.0

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.
Files changed (44) hide show
  1. package/README.md +339 -266
  2. package/dist/index.d.ts +658 -5
  3. package/dist/index.js +927 -7
  4. package/package.json +21 -47
  5. package/dist/browser/index.d.ts +0 -2
  6. package/dist/browser/index.d.ts.map +0 -1
  7. package/dist/browser/index.js +0 -1
  8. package/dist/core/address.d.ts +0 -5
  9. package/dist/core/address.d.ts.map +0 -1
  10. package/dist/core/address.js +0 -29
  11. package/dist/core/deposit.d.ts +0 -59
  12. package/dist/core/deposit.d.ts.map +0 -1
  13. package/dist/core/deposit.js +0 -92
  14. package/dist/core/index.d.ts +0 -6
  15. package/dist/core/index.d.ts.map +0 -1
  16. package/dist/core/index.js +0 -3
  17. package/dist/default-config.d.ts +0 -78
  18. package/dist/default-config.d.ts.map +0 -1
  19. package/dist/default-config.js +0 -78
  20. package/dist/index.d.ts.map +0 -1
  21. package/dist/intents.d.ts +0 -94
  22. package/dist/intents.d.ts.map +0 -1
  23. package/dist/intents.js +0 -119
  24. package/dist/node/bridge.d.ts +0 -38
  25. package/dist/node/bridge.d.ts.map +0 -1
  26. package/dist/node/bridge.js +0 -519
  27. package/dist/node/config.d.ts +0 -45
  28. package/dist/node/config.d.ts.map +0 -1
  29. package/dist/node/config.js +0 -48
  30. package/dist/node/eip7702.d.ts +0 -54
  31. package/dist/node/eip7702.d.ts.map +0 -1
  32. package/dist/node/eip7702.js +0 -275
  33. package/dist/node/evm-executor.d.ts +0 -130
  34. package/dist/node/evm-executor.d.ts.map +0 -1
  35. package/dist/node/evm-executor.js +0 -160
  36. package/dist/node/index.d.ts +0 -15
  37. package/dist/node/index.d.ts.map +0 -1
  38. package/dist/node/index.js +0 -17
  39. package/dist/node/provider.d.ts +0 -162
  40. package/dist/node/provider.d.ts.map +0 -1
  41. package/dist/node/provider.js +0 -272
  42. package/dist/node/types.d.ts +0 -110
  43. package/dist/node/types.d.ts.map +0 -1
  44. package/dist/node/types.js +0 -4
package/dist/index.d.ts CHANGED
@@ -1,8 +1,661 @@
1
+ import { Hex, Address, Hash, Chain, Account, WalletClient, PublicClient } from 'viem';
2
+ import { Signer, FastProvider } from '@fastxyz/sdk';
3
+
4
+ declare function fastAddressToBytes(address: string): Uint8Array;
5
+ declare function fastAddressToBytes32(address: string): Hex;
6
+
1
7
  /**
2
- * @fastxyz/allset-sdkbrowser-safe core helpers
8
+ * intents.tsIntent builders for AllSet external execution
3
9
  *
4
- * Root exports are pure helpers only. Use `@fastxyz/allset-sdk/node` for
5
- * provider, executor, wallet, bridge execution, and file-backed config APIs.
10
+ * Intents define what actions to perform on EVM chains after
11
+ * transferring tokens from Fast network.
6
12
  */
7
- export * from './core/index.js';
8
- //# sourceMappingURL=index.d.ts.map
13
+ /**
14
+ * Intent action types supported by AllSet bridge.
15
+ */
16
+ declare enum IntentAction {
17
+ /** Generic contract call */
18
+ Execute = 0,
19
+ /** ERC-20 transfer to address */
20
+ DynamicTransfer = 1,
21
+ /** Deposit tokens back to Fast network */
22
+ DynamicDeposit = 2,
23
+ /** Cancel/revoke pending intent */
24
+ Revoke = 3
25
+ }
26
+ /**
27
+ * An intent to execute on an EVM chain.
28
+ */
29
+ interface Intent {
30
+ /** The action type */
31
+ action: IntentAction;
32
+ /** ABI-encoded payload for the action */
33
+ payload: `0x${string}`;
34
+ /** Native token value (ETH) to send, 0 for ERC-20 operations */
35
+ value: bigint;
36
+ }
37
+ /**
38
+ * Build a transfer intent to send ERC-20 tokens to an address.
39
+ *
40
+ * @param token - ERC-20 token contract address
41
+ * @param receiver - Recipient EVM address
42
+ * @returns Intent for DynamicTransfer action
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const intent = buildTransferIntent(
47
+ * '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', // USDC
48
+ * '0xRecipientAddress'
49
+ * );
50
+ * ```
51
+ */
52
+ declare function buildTransferIntent(token: string, receiver: string): Intent;
53
+ /**
54
+ * Build a generic execute intent for arbitrary contract calls.
55
+ *
56
+ * @param target - Target contract address
57
+ * @param calldata - ABI-encoded function call data
58
+ * @param value - Native token value to send (default: 0)
59
+ * @returns Intent for Execute action
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * // Call a contract function
64
+ * const calldata = encodeFunctionData({
65
+ * abi: contractAbi,
66
+ * functionName: 'someFunction',
67
+ * args: [arg1, arg2],
68
+ * });
69
+ * const intent = buildExecuteIntent('0xContractAddress', calldata);
70
+ * ```
71
+ */
72
+ declare function buildExecuteIntent(target: string, calldata: string, value?: bigint): Intent;
73
+ /**
74
+ * Build an intent to deposit tokens back to Fast network.
75
+ *
76
+ * @param token - ERC-20 token contract address on EVM
77
+ * @param fastReceiver - Fast network recipient address (fast1...)
78
+ * @returns Intent for DynamicDeposit action
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const intent = buildDepositBackIntent(
83
+ * '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', // USDC
84
+ * 'fast1recipientaddress...'
85
+ * );
86
+ * ```
87
+ */
88
+ declare function buildDepositBackIntent(token: string, fastReceiver: string): Intent;
89
+ /**
90
+ * Build a revoke intent to cancel pending operations.
91
+ *
92
+ * @returns Intent for Revoke action
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const intent = buildRevokeIntent();
97
+ * ```
98
+ */
99
+ declare function buildRevokeIntent(): Intent;
100
+
101
+ /**
102
+ * claims.ts — Claim encoding and ID extraction for AllSet bridge
103
+ *
104
+ * Provides standalone functions for encoding TransferClaim and IntentClaim
105
+ * structures, building intent claim bytes for submitClaim(), and extracting
106
+ * claim IDs from cross-sign results.
107
+ *
108
+ * These were previously inlined in bridge.ts executeIntent().
109
+ */
110
+
111
+ interface TransferClaimParams {
112
+ /** Sender address (will be lowercased) */
113
+ from: string;
114
+ /** Transaction nonce */
115
+ nonce: number | bigint;
116
+ /** Asset identifier (e.g. token symbol or address) */
117
+ asset: string;
118
+ /** Amount in smallest units */
119
+ amount: bigint;
120
+ /** Recipient address */
121
+ to: string;
122
+ }
123
+ /**
124
+ * ABI-encode a TransferClaim struct.
125
+ *
126
+ * @returns ABI-encoded hex string
127
+ */
128
+ declare function encodeTransferClaim(params: TransferClaimParams): Hex;
129
+ /**
130
+ * Compute the keccak256 hash of a TransferClaim (used as claim ID in some flows).
131
+ *
132
+ * @returns 0x-prefixed keccak256 hash
133
+ */
134
+ declare function hashTransferClaim(params: TransferClaimParams): Hex;
135
+ interface IntentClaimParams {
136
+ /** Transfer transaction ID (bytes32 hex) */
137
+ transferFastTxId: string;
138
+ /** Unix timestamp deadline */
139
+ deadline: bigint;
140
+ /** Array of intents to execute on EVM */
141
+ intents: Intent[];
142
+ }
143
+ /**
144
+ * ABI-encode an IntentClaim struct.
145
+ *
146
+ * @returns ABI-encoded hex string
147
+ */
148
+ declare function encodeIntentClaim(params: IntentClaimParams): Hex;
149
+ /**
150
+ * Build the intent claim bytes for use with `window.fastset.submitClaim()` or
151
+ * `TransactionBuilder.addExternalClaim()`.
152
+ *
153
+ * This is a convenience function that constructs an IntentClaim with the given
154
+ * parameters and returns it as a Uint8Array ready for submission.
155
+ *
156
+ * @param transferFastTxId - The transfer transaction ID (bytes32 hex from cross-sign)
157
+ * @param intents - Array of intents to execute on EVM
158
+ * @param deadline - Optional Unix timestamp deadline (defaults to 1 hour from now)
159
+ * @returns Uint8Array of ABI-encoded IntentClaim
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * const intentBytes = buildIntentClaimBytes({
164
+ * transferFastTxId: '0xabc...',
165
+ * intents: [buildTransferIntent(tokenAddr, receiverAddr)],
166
+ * });
167
+ *
168
+ * // Use with browser wallet
169
+ * await window.fastset.submitClaim({
170
+ * claimData: Array.from(intentBytes),
171
+ * recipient: bridgeAddress,
172
+ * account: currentAccount,
173
+ * });
174
+ * ```
175
+ */
176
+ declare function buildIntentClaimBytes(params: {
177
+ transferFastTxId: string;
178
+ intents: Intent[];
179
+ deadline?: bigint;
180
+ }): Uint8Array;
181
+ /**
182
+ * Extract the claim ID (Fast transaction hash) from an evmSign cross-sign result.
183
+ *
184
+ * The cross-sign service returns transaction bytes where bytes[32:64] contain
185
+ * the canonical Fast network transaction hash.
186
+ *
187
+ * @param crossSignTransaction - The `transaction` field from an `EvmSignResult`
188
+ * @returns 0x-prefixed hex string of the claim ID
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * const crossSign = await evmSign(certificate, crossSignUrl);
193
+ * const claimId = extractClaimId(crossSign.transaction);
194
+ * // claimId === '0xabc123...'
195
+ * ```
196
+ */
197
+ declare function extractClaimId(crossSignTransaction: number[]): Hex;
198
+
199
+ interface BuildDepositTransactionParams {
200
+ chainId: number;
201
+ bridgeContract: `0x${string}`;
202
+ tokenAddress: `0x${string}`;
203
+ isNative?: boolean;
204
+ amount: bigint;
205
+ /** Receiver Fast address (fast1...) */
206
+ receiver: string;
207
+ }
208
+ interface EncodeDepositCalldataParams {
209
+ tokenAddress: string;
210
+ amount: bigint;
211
+ receiverBytes32: `0x${string}`;
212
+ }
213
+ interface DepositTransactionPlan {
214
+ chainId: number;
215
+ to: `0x${string}`;
216
+ data: `0x${string}`;
217
+ value: bigint;
218
+ receiverBytes32: `0x${string}`;
219
+ }
220
+ /**
221
+ * Encode calldata for the bridge deposit(token, amount, receiver) call.
222
+ */
223
+ declare function encodeDepositCalldata(params: EncodeDepositCalldataParams): `0x${string}`;
224
+ /**
225
+ * Build a deposit transaction plan for bridging tokens from EVM to Fast network.
226
+ *
227
+ * All configuration values (chainId, bridgeContract, tokenAddress) must be
228
+ * provided by the caller — this function contains no embedded config.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * const plan = buildDepositTransaction({
233
+ * chainId: 421614,
234
+ * bridgeContract: '0xb536...',
235
+ * tokenAddress: '0x75fa...',
236
+ * amount: 1000000n,
237
+ * receiver: 'fast1abc...',
238
+ * });
239
+ * // plan.to, plan.data, plan.value are ready to send via viem walletClient
240
+ * ```
241
+ */
242
+ declare function buildDepositTransaction(params: BuildDepositTransactionParams): DepositTransactionPlan;
243
+
244
+ /**
245
+ * eip7702.ts — EIP-7702 smartDeposit via AllSet Portal relay
246
+ *
247
+ * Flow:
248
+ * 1. Check ERC-20 balance; throw InsufficientBalanceError if < amount
249
+ * 2. POST /userop/prepare → backend assembles UserOp + paymasterData (3 retries)
250
+ * 3. Pin delegate address against TRUSTED_DELEGATES allowlist
251
+ * 4. Sign EIP-7702 authorization (re-delegate EOA to v0.8 impl)
252
+ * 5. Sign UserOperation (EIP-712, v0.8)
253
+ * 6. POST /userop/submit → backend calls Pimlico eth_sendUserOperation
254
+ *
255
+ * Private key never leaves the SDK.
256
+ * Pimlico API key never touches the SDK.
257
+ * Gas is paid in USDC via ERC-20 Paymaster.
258
+ * Chain is inferred from rpcUrl (backend calls eth_chainId) — no hardcoded chain list.
259
+ */
260
+
261
+ interface SmartDepositParams {
262
+ /**
263
+ * EOA private key — stays local, never sent to backend.
264
+ * The EOA should be quiescent during this call: do not send other
265
+ * transactions from this key concurrently. EIP-7702 authorization
266
+ * signing binds to the account nonce, and a concurrent tx from
267
+ * another process will silently invalidate the delegation.
268
+ */
269
+ privateKey: Hex;
270
+ /** EVM JSON-RPC URL — used for balance check and forwarded to backend for chainId detection */
271
+ rpcUrl: string;
272
+ /** AllSet Portal backend base URL, e.g. https://api.allset.xyz */
273
+ allsetApiUrl: string;
274
+ /** ERC-20 token to deposit (e.g. USDC on Base) */
275
+ tokenAddress: Address;
276
+ /** Exact token amount to deposit (raw, with decimals); throws if balance is insufficient */
277
+ amount: bigint;
278
+ /** AllSet bridge contract address */
279
+ bridgeAddress: Address;
280
+ /** Encoded bridge.deposit(...) calldata from encodeDepositCalldata() */
281
+ depositCalldata: Hex;
282
+ /** Per-request HTTP timeout in ms for backend POSTs (default: 60000) */
283
+ requestTimeoutMs?: number;
284
+ }
285
+ interface SmartDepositResult {
286
+ txHash: Hash;
287
+ userOpHash: Hash;
288
+ userAddress: Address;
289
+ }
290
+ declare class InsufficientBalanceError extends Error {
291
+ readonly balance: bigint;
292
+ readonly required: bigint;
293
+ readonly tokenAddress: Address;
294
+ constructor(balance: bigint, required: bigint, tokenAddress: Address);
295
+ }
296
+ declare function smartDeposit(params: SmartDepositParams): Promise<SmartDepositResult>;
297
+
298
+ /**
299
+ * Account-compatible wallet returned by createEvmWallet().
300
+ *
301
+ * Includes the normalized private key so generated accounts can be persisted
302
+ * or reconstructed by the caller.
303
+ */
304
+ type EvmAccount = Account & {
305
+ privateKey: `0x${string}`;
306
+ };
307
+ /**
308
+ * Create an EVM wallet from an optional private key.
309
+ *
310
+ * @param privateKey - Optional. If omitted, generates a new random wallet.
311
+ * Accepts a hex private key (64 chars, with or without 0x prefix).
312
+ *
313
+ * @returns Account-compatible object with viem signing methods and `privateKey`
314
+ *
315
+ * @example
316
+ * ```ts
317
+ * // Generate new wallet
318
+ * const account = createEvmWallet();
319
+ * console.log(account.address); // 0x...
320
+ * console.log(account.privateKey); // persist this to reuse the wallet
321
+ *
322
+ * // Restore from private key
323
+ * const account = createEvmWallet('0x1234...64hexchars');
324
+ * ```
325
+ */
326
+ declare function createEvmWallet(privateKey?: string): EvmAccount;
327
+ /** ERC20 ABI for allowance, approve, and balanceOf */
328
+ declare const ERC20_ABI: readonly [{
329
+ readonly name: "approve";
330
+ readonly type: "function";
331
+ readonly stateMutability: "nonpayable";
332
+ readonly inputs: readonly [{
333
+ readonly type: "address";
334
+ readonly name: "spender";
335
+ }, {
336
+ readonly type: "uint256";
337
+ readonly name: "amount";
338
+ }];
339
+ readonly outputs: readonly [{
340
+ readonly type: "bool";
341
+ }];
342
+ }, {
343
+ readonly name: "allowance";
344
+ readonly type: "function";
345
+ readonly stateMutability: "view";
346
+ readonly inputs: readonly [{
347
+ readonly type: "address";
348
+ readonly name: "owner";
349
+ }, {
350
+ readonly type: "address";
351
+ readonly name: "spender";
352
+ }];
353
+ readonly outputs: readonly [{
354
+ readonly type: "uint256";
355
+ }];
356
+ }, {
357
+ readonly name: "balanceOf";
358
+ readonly type: "function";
359
+ readonly stateMutability: "view";
360
+ readonly inputs: readonly [{
361
+ readonly type: "address";
362
+ readonly name: "owner";
363
+ }];
364
+ readonly outputs: readonly [{
365
+ readonly type: "uint256";
366
+ }];
367
+ }];
368
+ /** Bundled supported chain mappings */
369
+ declare const CHAIN_MAP: Record<number, Chain>;
370
+ /**
371
+ * EVM clients returned by createEvmExecutor.
372
+ */
373
+ interface EvmClients {
374
+ walletClient: WalletClient;
375
+ publicClient: PublicClient;
376
+ }
377
+ /**
378
+ * Create viem wallet and public clients for EVM operations.
379
+ *
380
+ * @param account - viem Account from createEvmWallet() or privateKeyToAccount()
381
+ * @param rpcUrl - RPC endpoint URL
382
+ * @param chainOrId - A viem Chain object, or a chain ID number (looked up in CHAIN_MAP).
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * import { arbitrumSepolia } from 'viem/chains';
387
+ *
388
+ * const account = createEvmWallet('0xabc123...');
389
+ * // Pass a Chain object directly (preferred — no hardcoded map):
390
+ * const { walletClient, publicClient } = createEvmExecutor(account, rpcUrl, arbitrumSepolia);
391
+ * // Or pass a chain ID (uses built-in CHAIN_MAP):
392
+ * const { walletClient, publicClient } = createEvmExecutor(account, rpcUrl, 421614);
393
+ * ```
394
+ */
395
+ declare function createEvmExecutor(account: Account, rpcUrl: string, chainOrId: Chain | number): EvmClients;
396
+ /**
397
+ * Get the ERC-20 token balance of an EVM address.
398
+ *
399
+ * @param rpcUrl - EVM RPC endpoint
400
+ * @param tokenAddress - ERC-20 contract address
401
+ * @param ownerAddress - Account to query
402
+ * @returns Raw balance as bigint (in token's smallest unit)
403
+ */
404
+ declare function getEvmErc20Balance(rpcUrl: string, tokenAddress: string, ownerAddress: string): Promise<bigint>;
405
+ /**
406
+ * Get the native token (ETH / gas token) balance of an EVM address.
407
+ *
408
+ * @param rpcUrl - EVM RPC endpoint
409
+ * @param address - Account to query
410
+ * @returns Balance in wei as bigint
411
+ */
412
+ declare function getEvmNativeBalance(rpcUrl: string, address: string): Promise<bigint>;
413
+
414
+ interface BridgeResult {
415
+ txHash: string;
416
+ orderId: string;
417
+ estimatedTime?: string;
418
+ }
419
+ interface ExecuteDepositParams {
420
+ /** EVM chain ID */
421
+ chainId: number;
422
+ /** AllSet bridge contract address on EVM */
423
+ bridgeContract: `0x${string}`;
424
+ /** ERC-20 token contract address on EVM (ignored when isNative is true) */
425
+ tokenAddress: `0x${string}`;
426
+ /** Set to true for native ETH deposits */
427
+ isNative?: boolean;
428
+ /** Amount in smallest units (e.g., '1000000' for 1 USDC) */
429
+ amount: string;
430
+ /** Receiver Fast address (fast1...) */
431
+ receiverAddress: string;
432
+ /** viem clients from createEvmExecutor() */
433
+ evmClients: EvmClients;
434
+ }
435
+ interface ExecuteIntentParams {
436
+ /** AllSet bridge address on the Fast network (fast1...) */
437
+ fastBridgeAddress: string;
438
+ /** AllSet relayer URL for the destination EVM chain */
439
+ relayerUrl: string;
440
+ /** AllSet cross-sign service URL */
441
+ crossSignUrl: string;
442
+ /** Token contract address on EVM (used in relayer payload) */
443
+ tokenEvmAddress: string;
444
+ /** Token ID on the Fast network (hex string, without 0x) */
445
+ tokenFastTokenId: string;
446
+ /** Amount in smallest units (e.g., '1000000' for 1 USDC) */
447
+ amount: string;
448
+ /** Intents to execute on EVM chain after bridge */
449
+ intents: Intent[];
450
+ /**
451
+ * EVM address for the relayer target.
452
+ * Required when intents do not include a transfer recipient or execute target
453
+ * (e.g., for buildDepositBackIntent or buildRevokeIntent flows).
454
+ */
455
+ externalAddress?: string;
456
+ /** Deadline in seconds from now (default: 3600) */
457
+ deadlineSeconds?: number;
458
+ /** Ed25519 signer from @fastxyz/sdk */
459
+ signer: Signer;
460
+ /** Fast RPC provider from @fastxyz/sdk */
461
+ provider: FastProvider;
462
+ /** Fast network ID (e.g. 'fast:testnet', 'fast:mainnet') */
463
+ networkId: string;
464
+ }
465
+ interface ExecuteWithdrawParams {
466
+ /** AllSet bridge address on the Fast network (fast1...) */
467
+ fastBridgeAddress: string;
468
+ /** AllSet relayer URL for the destination EVM chain */
469
+ relayerUrl: string;
470
+ /** AllSet cross-sign service URL */
471
+ crossSignUrl: string;
472
+ /** Token contract address on EVM */
473
+ tokenEvmAddress: string;
474
+ /** Token ID on the Fast network (hex string, without 0x) */
475
+ tokenFastTokenId: string;
476
+ /** Amount in smallest units (e.g., '1000000' for 1 USDC) */
477
+ amount: string;
478
+ /** EVM address to receive the withdrawn tokens */
479
+ receiverEvmAddress: string;
480
+ /** Deadline in seconds from now (default: 3600) */
481
+ deadlineSeconds?: number;
482
+ /** Ed25519 signer from @fastxyz/sdk */
483
+ signer: Signer;
484
+ /** Fast RPC provider from @fastxyz/sdk */
485
+ provider: FastProvider;
486
+ /** Fast network ID (e.g. 'fast:testnet', 'fast:mainnet') */
487
+ networkId: string;
488
+ }
489
+
490
+ interface EvmSignResult {
491
+ transaction: number[];
492
+ signature: string;
493
+ }
494
+ /**
495
+ * Request EVM cross-signing for a Fast network certificate.
496
+ *
497
+ * @param certificate - Certificate from fastWallet.submit()
498
+ * @param crossSignUrl - AllSet cross-sign service URL (required)
499
+ */
500
+ declare function evmSign(certificate: unknown, crossSignUrl: string): Promise<EvmSignResult>;
501
+ /**
502
+ * Execute a deposit from an EVM chain to the Fast network.
503
+ *
504
+ * All configuration values must be provided by the caller.
505
+ *
506
+ * @example
507
+ * ```ts
508
+ * const result = await executeDeposit({
509
+ * chainId: 421614,
510
+ * bridgeContract: '0xb536...',
511
+ * tokenAddress: '0x75fa...',
512
+ * amount: '1000000',
513
+ * receiverAddress: 'fast1abc...',
514
+ * evmClients,
515
+ * });
516
+ * ```
517
+ */
518
+ declare function executeDeposit(params: ExecuteDepositParams): Promise<BridgeResult>;
519
+ /**
520
+ * Execute intents on an EVM chain after transferring tokens from the Fast network.
521
+ *
522
+ * This is the core function for all Fast→EVM flows:
523
+ * - Simple withdrawal: use buildTransferIntent + executeIntent (or use executeWithdraw)
524
+ * - Custom contract call: use buildExecuteIntent + executeIntent
525
+ * - Deposit back to Fast: use buildDepositBackIntent + executeIntent
526
+ *
527
+ * All configuration values must be provided by the caller.
528
+ *
529
+ * @example
530
+ * ```ts
531
+ * import { Signer, FastProvider } from '@fastxyz/sdk';
532
+ *
533
+ * const signer = new Signer(privateKeyHex);
534
+ * const provider = new FastProvider({ rpcUrl: 'https://proxy.fast.xyz' });
535
+ *
536
+ * const intent = buildTransferIntent(tokenEvmAddress, receiverEvmAddress);
537
+ * const result = await executeIntent({
538
+ * fastBridgeAddress: 'fast1...',
539
+ * relayerUrl: 'https://...',
540
+ * crossSignUrl: 'https://...',
541
+ * tokenEvmAddress: '0x...',
542
+ * tokenFastTokenId: 'abc123...',
543
+ * amount: '1000000',
544
+ * intents: [intent],
545
+ * signer,
546
+ * provider,
547
+ * networkId: 'fast:testnet',
548
+ * });
549
+ * ```
550
+ */
551
+ declare function executeIntent(params: ExecuteIntentParams): Promise<BridgeResult>;
552
+ /**
553
+ * Withdraw tokens from the Fast network to an EVM address.
554
+ *
555
+ * This is a convenience wrapper around executeIntent that builds a
556
+ * DynamicTransfer intent automatically.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * import { Signer, FastProvider } from '@fastxyz/sdk';
561
+ *
562
+ * const signer = new Signer(privateKeyHex);
563
+ * const provider = new FastProvider({ rpcUrl: 'https://proxy.fast.xyz' });
564
+ *
565
+ * const result = await executeWithdraw({
566
+ * fastBridgeAddress: 'fast1...',
567
+ * relayerUrl: 'https://...',
568
+ * crossSignUrl: 'https://...',
569
+ * tokenEvmAddress: '0x...',
570
+ * tokenFastTokenId: 'abc123...',
571
+ * amount: '1000000',
572
+ * receiverEvmAddress: '0xRecipient...',
573
+ * signer,
574
+ * provider,
575
+ * networkId: 'fast:testnet',
576
+ * });
577
+ * ```
578
+ */
579
+ declare function executeWithdraw(params: ExecuteWithdrawParams): Promise<BridgeResult>;
580
+
581
+ /**
582
+ * relay.ts — Standalone relayer submission for AllSet bridge
583
+ *
584
+ * Extracted from the bridge execution flow so Portal and other consumers
585
+ * can call the relayer independently (e.g. for step-by-step UI, retry, revoke).
586
+ */
587
+ /**
588
+ * Parameters for submitting a relay request to the AllSet relayer.
589
+ */
590
+ interface RelayParams {
591
+ /** AllSet relayer URL for the destination EVM chain */
592
+ relayerUrl: string;
593
+ /** Cross-signed transfer claim bytes (from evmSign result) */
594
+ encodedTransferClaim: number[];
595
+ /** EVM signature proof for the transfer claim */
596
+ transferProof: string;
597
+ /** Fast network transaction ID for the transfer */
598
+ transferFastTxId: string;
599
+ /** Fast network sender address (fast1...) */
600
+ fastsetAddress: string;
601
+ /** EVM recipient/target address (0x...) */
602
+ externalAddress: string;
603
+ /** Cross-signed intent claim bytes (from evmSign result) */
604
+ encodedIntentClaim?: number[];
605
+ /** EVM signature proof for the intent claim */
606
+ intentProof?: string;
607
+ /** Fast network transaction ID for the intent */
608
+ intentFastTxId?: string;
609
+ /** Claim ID for the intent (may differ from intentFastTxId) */
610
+ intentClaimId?: string;
611
+ /** Token contract address on the destination EVM chain */
612
+ externalTokenAddress?: string;
613
+ }
614
+ /**
615
+ * Result from a successful relay submission.
616
+ */
617
+ interface RelayResult {
618
+ /** Whether the relayer accepted the request */
619
+ success: boolean;
620
+ }
621
+ /**
622
+ * Submit a relay request to the AllSet relayer service.
623
+ *
624
+ * The relayer executes the bridged operation on the destination EVM chain
625
+ * (e.g. ERC-20 transfer, contract call, deposit back, or revoke).
626
+ *
627
+ * @example
628
+ * ```ts
629
+ * await relayExecute({
630
+ * relayerUrl: 'https://relayer.allset.xyz',
631
+ * encodedTransferClaim: Array.from(transferCrossSign.transaction),
632
+ * transferProof: transferCrossSign.signature,
633
+ * transferFastTxId: '0x...',
634
+ * fastsetAddress: 'fast1...',
635
+ * externalAddress: '0xRecipient...',
636
+ * encodedIntentClaim: Array.from(intentCrossSign.transaction),
637
+ * intentProof: intentCrossSign.signature,
638
+ * intentFastTxId: '0x...',
639
+ * externalTokenAddress: '0xToken...',
640
+ * });
641
+ * ```
642
+ */
643
+ declare function relayExecute(params: RelayParams): Promise<RelayResult>;
644
+
645
+ /**
646
+ * errors.ts — Structured error codes for AllSet SDK.
647
+ *
648
+ * Every throwable error from the SDK is a FastError with a machine-readable
649
+ * `code`. Agents can switch on `code` instead of parsing message strings.
650
+ */
651
+ type FastErrorCode = 'INSUFFICIENT_BALANCE' | 'NETWORK_NOT_CONFIGURED' | 'TX_FAILED' | 'INVALID_ADDRESS' | 'TOKEN_NOT_FOUND' | 'INVALID_PARAMS' | 'UNSUPPORTED_OPERATION' | 'KEYFILE_NOT_FOUND';
652
+ declare class FastError extends Error {
653
+ readonly code: FastErrorCode;
654
+ readonly note: string;
655
+ constructor(code: FastErrorCode, message: string, opts?: {
656
+ note?: string;
657
+ });
658
+ toJSON(): Record<string, unknown>;
659
+ }
660
+
661
+ export { type BridgeResult, type BuildDepositTransactionParams, CHAIN_MAP, type DepositTransactionPlan, ERC20_ABI, type EncodeDepositCalldataParams, type EvmAccount, type EvmClients, type EvmSignResult, type ExecuteDepositParams, type ExecuteIntentParams, type ExecuteWithdrawParams, FastError, type FastErrorCode, InsufficientBalanceError, type Intent, IntentAction, type IntentClaimParams, type RelayParams, type RelayResult, type SmartDepositParams, type SmartDepositResult, type TransferClaimParams, buildDepositBackIntent, buildDepositTransaction, buildExecuteIntent, buildIntentClaimBytes, buildRevokeIntent, buildTransferIntent, createEvmExecutor, createEvmWallet, encodeDepositCalldata, encodeIntentClaim, encodeTransferClaim, evmSign, executeDeposit, executeIntent, executeWithdraw, extractClaimId, fastAddressToBytes, fastAddressToBytes32, getEvmErc20Balance, getEvmNativeBalance, hashTransferClaim, relayExecute, smartDeposit };