@fastxyz/allset-sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -14
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/core/address.d.ts +4 -0
- package/dist/core/address.d.ts.map +1 -0
- package/dist/core/address.js +27 -0
- package/dist/core/address.js.map +1 -0
- package/dist/core/deposit.d.ts +59 -0
- package/dist/core/deposit.d.ts.map +1 -0
- package/dist/core/deposit.js +93 -0
- package/dist/core/deposit.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/default-config.d.ts +51 -0
- package/dist/default-config.d.ts.map +1 -0
- package/dist/default-config.js +52 -0
- package/dist/default-config.js.map +1 -0
- package/dist/index.d.ts +4 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -48
- package/dist/index.js.map +1 -1
- package/dist/intents.d.ts.map +1 -1
- package/dist/intents.js +1 -9
- package/dist/intents.js.map +1 -1
- package/dist/node/bridge.d.ts.map +1 -0
- package/dist/{bridge.js → node/bridge.js} +129 -72
- package/dist/node/bridge.js.map +1 -0
- package/dist/{config.d.ts → node/config.d.ts} +2 -5
- package/dist/node/config.d.ts.map +1 -0
- package/dist/{config.js → node/config.js} +5 -23
- package/dist/node/config.js.map +1 -0
- package/dist/node/evm-executor.d.ts +130 -0
- package/dist/node/evm-executor.d.ts.map +1 -0
- package/dist/node/evm-executor.js +159 -0
- package/dist/node/evm-executor.js.map +1 -0
- package/dist/node/index.d.ts +14 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +17 -0
- package/dist/node/index.js.map +1 -0
- package/dist/{provider.d.ts → node/provider.d.ts} +6 -6
- package/dist/node/provider.d.ts.map +1 -0
- package/dist/{provider.js → node/provider.js} +18 -25
- package/dist/node/provider.js.map +1 -0
- package/dist/{types.d.ts → node/types.d.ts} +19 -19
- package/dist/node/types.d.ts.map +1 -0
- package/dist/node/types.js.map +1 -0
- package/package.json +22 -6
- package/data/networks.json +0 -37
- package/dist/bridge.d.ts.map +0 -1
- package/dist/bridge.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/evm-executor.d.ts +0 -64
- package/dist/evm-executor.d.ts.map +0 -1
- package/dist/evm-executor.js +0 -181
- package/dist/evm-executor.js.map +0 -1
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- /package/dist/{bridge.d.ts → node/bridge.d.ts} +0 -0
- /package/dist/{types.js → node/types.js} +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evm-executor.ts — EVM client utilities using viem
|
|
3
|
+
*
|
|
4
|
+
* Provides createEvmExecutor() to create viem wallet and public clients,
|
|
5
|
+
* and createEvmWallet() to generate or load EVM wallets.
|
|
6
|
+
*
|
|
7
|
+
* Wallet keyfiles are managed by the user at ~/.evm/keys/ or custom paths.
|
|
8
|
+
* Expected format: { "privateKey": "...", "address": "..." (optional) }
|
|
9
|
+
*/
|
|
10
|
+
import { type Account, type Chain, type PublicClient, type WalletClient } from 'viem';
|
|
11
|
+
/**
|
|
12
|
+
* Account-compatible wallet returned by createEvmWallet().
|
|
13
|
+
*
|
|
14
|
+
* Includes the normalized private key so generated accounts can be persisted
|
|
15
|
+
* or reconstructed by the caller.
|
|
16
|
+
*/
|
|
17
|
+
export type EvmAccount = Account & {
|
|
18
|
+
privateKey: `0x${string}`;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Get the default EVM keys directory (~/.evm/keys).
|
|
22
|
+
*/
|
|
23
|
+
export declare function getEvmKeysDir(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Create or load an EVM wallet and return an Account-compatible object.
|
|
26
|
+
*
|
|
27
|
+
* @param keyOrPath - Optional. Can be:
|
|
28
|
+
* - Omitted: generates a new random wallet
|
|
29
|
+
* - Private key (64 hex chars, with or without 0x): derives account from it
|
|
30
|
+
* - File path (contains `/` or `~`, or ends with `.json`): loads from JSON keyfile
|
|
31
|
+
*
|
|
32
|
+
* The keyfile must be a JSON file containing:
|
|
33
|
+
* - `privateKey` (required): hex string, with or without 0x prefix
|
|
34
|
+
* - `address` (optional): for user reference only
|
|
35
|
+
*
|
|
36
|
+
* It is the user's responsibility to create and manage keyfiles.
|
|
37
|
+
* Generated accounts expose `privateKey` so callers can persist them.
|
|
38
|
+
*
|
|
39
|
+
* @returns Account-compatible object with viem signing methods and `privateKey`
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* // Generate new wallet
|
|
44
|
+
* const account = createEvmWallet();
|
|
45
|
+
* console.log(account.address); // 0x...
|
|
46
|
+
* console.log(account.privateKey); // persist this if you generated the wallet
|
|
47
|
+
*
|
|
48
|
+
* // Derive from private key
|
|
49
|
+
* const account = createEvmWallet('0x1234...64hexchars');
|
|
50
|
+
*
|
|
51
|
+
* // Load from keyfile
|
|
52
|
+
* const account = createEvmWallet('~/.evm/keys/default.json');
|
|
53
|
+
*
|
|
54
|
+
* // Use with createEvmExecutor
|
|
55
|
+
* const { walletClient, publicClient } = createEvmExecutor(account, rpcUrl, chainId);
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Keyfile format
|
|
59
|
+
* ```json
|
|
60
|
+
* {
|
|
61
|
+
* "privateKey": "abc123...64hexchars",
|
|
62
|
+
* "address": "0x..." // optional, for reference
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function createEvmWallet(keyOrPath?: string): EvmAccount;
|
|
67
|
+
/** ERC20 ABI for allowance and approve */
|
|
68
|
+
export declare const ERC20_ABI: readonly [{
|
|
69
|
+
readonly name: "approve";
|
|
70
|
+
readonly type: "function";
|
|
71
|
+
readonly stateMutability: "nonpayable";
|
|
72
|
+
readonly inputs: readonly [{
|
|
73
|
+
readonly type: "address";
|
|
74
|
+
readonly name: "spender";
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
readonly name: "amount";
|
|
78
|
+
}];
|
|
79
|
+
readonly outputs: readonly [{
|
|
80
|
+
readonly type: "bool";
|
|
81
|
+
}];
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "allowance";
|
|
84
|
+
readonly type: "function";
|
|
85
|
+
readonly stateMutability: "view";
|
|
86
|
+
readonly inputs: readonly [{
|
|
87
|
+
readonly type: "address";
|
|
88
|
+
readonly name: "owner";
|
|
89
|
+
}, {
|
|
90
|
+
readonly type: "address";
|
|
91
|
+
readonly name: "spender";
|
|
92
|
+
}];
|
|
93
|
+
readonly outputs: readonly [{
|
|
94
|
+
readonly type: "uint256";
|
|
95
|
+
}];
|
|
96
|
+
}];
|
|
97
|
+
/** Supported chain mappings */
|
|
98
|
+
export declare const CHAIN_MAP: Record<number, Chain>;
|
|
99
|
+
/**
|
|
100
|
+
* EVM clients returned by createEvmExecutor.
|
|
101
|
+
*/
|
|
102
|
+
export interface EvmClients {
|
|
103
|
+
walletClient: WalletClient;
|
|
104
|
+
publicClient: PublicClient;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create viem wallet and public clients for EVM operations.
|
|
108
|
+
*
|
|
109
|
+
* @param account - viem Account from createEvmWallet() or privateKeyToAccount()
|
|
110
|
+
* @param rpcUrl - RPC endpoint URL
|
|
111
|
+
* @param chainId - Chain ID (11155111 for Sepolia, 421614 for Arbitrum Sepolia)
|
|
112
|
+
* @returns Object with walletClient and publicClient
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* // Using Account from createEvmWallet (loads from keyfile)
|
|
117
|
+
* const account = createEvmWallet('~/.evm/keys/default.json');
|
|
118
|
+
* const { walletClient, publicClient } = createEvmExecutor(account, 'https://sepolia-rollup.arbitrum.io/rpc', 421614);
|
|
119
|
+
*
|
|
120
|
+
* // Using viem's privateKeyToAccount directly
|
|
121
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
122
|
+
* const account = privateKeyToAccount('0xabc123...');
|
|
123
|
+
* const { walletClient, publicClient } = createEvmExecutor(account, rpcUrl, chainId);
|
|
124
|
+
*
|
|
125
|
+
* // Use clients for bridge deposit
|
|
126
|
+
* await allset.sendToFast({ ..., evmClients: { walletClient, publicClient } });
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export declare function createEvmExecutor(account: Account, rpcUrl: string, chainId: number): EvmClients;
|
|
130
|
+
//# sourceMappingURL=evm-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-executor.d.ts","sourceRoot":"","sources":["../../src/node/evm-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAId;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG;IACjC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;CAC3B,CAAC;AASF;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAwBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAwB9D;AAED,0CAA0C;AAC1C,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGpB,CAAC;AAEH,+BAA+B;AAC/B,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAI3C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,UAAU,CAoBZ"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evm-executor.ts — EVM client utilities using viem
|
|
3
|
+
*
|
|
4
|
+
* Provides createEvmExecutor() to create viem wallet and public clients,
|
|
5
|
+
* and createEvmWallet() to generate or load EVM wallets.
|
|
6
|
+
*
|
|
7
|
+
* Wallet keyfiles are managed by the user at ~/.evm/keys/ or custom paths.
|
|
8
|
+
* Expected format: { "privateKey": "...", "address": "..." (optional) }
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { createPublicClient, createWalletClient, http, parseAbi, } from 'viem';
|
|
13
|
+
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
14
|
+
import { arbitrumSepolia, base, sepolia } from 'viem/chains';
|
|
15
|
+
// Default EVM keys directory
|
|
16
|
+
const DEFAULT_EVM_KEYS_DIR = join(process.env.HOME || process.env.USERPROFILE || '', '.evm', 'keys');
|
|
17
|
+
/**
|
|
18
|
+
* Get the default EVM keys directory (~/.evm/keys).
|
|
19
|
+
*/
|
|
20
|
+
export function getEvmKeysDir() {
|
|
21
|
+
return DEFAULT_EVM_KEYS_DIR;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Expand ~ to home directory
|
|
25
|
+
*/
|
|
26
|
+
function expandPath(path) {
|
|
27
|
+
if (path.startsWith('~/')) {
|
|
28
|
+
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
29
|
+
return path.replace('~', home);
|
|
30
|
+
}
|
|
31
|
+
return path;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Detect if a string is a file path (vs a private key)
|
|
35
|
+
*/
|
|
36
|
+
function isFilePath(input) {
|
|
37
|
+
return input.includes('/') || input.startsWith('~') || input.endsWith('.json');
|
|
38
|
+
}
|
|
39
|
+
function normalizePrivateKey(privateKey) {
|
|
40
|
+
return (privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create or load an EVM wallet and return an Account-compatible object.
|
|
44
|
+
*
|
|
45
|
+
* @param keyOrPath - Optional. Can be:
|
|
46
|
+
* - Omitted: generates a new random wallet
|
|
47
|
+
* - Private key (64 hex chars, with or without 0x): derives account from it
|
|
48
|
+
* - File path (contains `/` or `~`, or ends with `.json`): loads from JSON keyfile
|
|
49
|
+
*
|
|
50
|
+
* The keyfile must be a JSON file containing:
|
|
51
|
+
* - `privateKey` (required): hex string, with or without 0x prefix
|
|
52
|
+
* - `address` (optional): for user reference only
|
|
53
|
+
*
|
|
54
|
+
* It is the user's responsibility to create and manage keyfiles.
|
|
55
|
+
* Generated accounts expose `privateKey` so callers can persist them.
|
|
56
|
+
*
|
|
57
|
+
* @returns Account-compatible object with viem signing methods and `privateKey`
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Generate new wallet
|
|
62
|
+
* const account = createEvmWallet();
|
|
63
|
+
* console.log(account.address); // 0x...
|
|
64
|
+
* console.log(account.privateKey); // persist this if you generated the wallet
|
|
65
|
+
*
|
|
66
|
+
* // Derive from private key
|
|
67
|
+
* const account = createEvmWallet('0x1234...64hexchars');
|
|
68
|
+
*
|
|
69
|
+
* // Load from keyfile
|
|
70
|
+
* const account = createEvmWallet('~/.evm/keys/default.json');
|
|
71
|
+
*
|
|
72
|
+
* // Use with createEvmExecutor
|
|
73
|
+
* const { walletClient, publicClient } = createEvmExecutor(account, rpcUrl, chainId);
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example Keyfile format
|
|
77
|
+
* ```json
|
|
78
|
+
* {
|
|
79
|
+
* "privateKey": "abc123...64hexchars",
|
|
80
|
+
* "address": "0x..." // optional, for reference
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function createEvmWallet(keyOrPath) {
|
|
85
|
+
let key;
|
|
86
|
+
if (!keyOrPath) {
|
|
87
|
+
// Generate new wallet
|
|
88
|
+
key = generatePrivateKey();
|
|
89
|
+
}
|
|
90
|
+
else if (isFilePath(keyOrPath)) {
|
|
91
|
+
// Load from file
|
|
92
|
+
const fullPath = expandPath(keyOrPath);
|
|
93
|
+
if (!existsSync(fullPath)) {
|
|
94
|
+
throw new Error(`Wallet file not found: ${keyOrPath}`);
|
|
95
|
+
}
|
|
96
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
97
|
+
const data = JSON.parse(content);
|
|
98
|
+
if (!data.privateKey) {
|
|
99
|
+
throw new Error(`Invalid wallet file: missing privateKey`);
|
|
100
|
+
}
|
|
101
|
+
key = normalizePrivateKey(data.privateKey);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Treat as private key
|
|
105
|
+
key = normalizePrivateKey(keyOrPath);
|
|
106
|
+
}
|
|
107
|
+
return Object.assign(privateKeyToAccount(key), { privateKey: key });
|
|
108
|
+
}
|
|
109
|
+
/** ERC20 ABI for allowance and approve */
|
|
110
|
+
export const ERC20_ABI = parseAbi([
|
|
111
|
+
'function approve(address spender, uint256 amount) returns (bool)',
|
|
112
|
+
'function allowance(address owner, address spender) view returns (uint256)',
|
|
113
|
+
]);
|
|
114
|
+
/** Supported chain mappings */
|
|
115
|
+
export const CHAIN_MAP = {
|
|
116
|
+
11155111: sepolia,
|
|
117
|
+
421614: arbitrumSepolia,
|
|
118
|
+
8453: base,
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Create viem wallet and public clients for EVM operations.
|
|
122
|
+
*
|
|
123
|
+
* @param account - viem Account from createEvmWallet() or privateKeyToAccount()
|
|
124
|
+
* @param rpcUrl - RPC endpoint URL
|
|
125
|
+
* @param chainId - Chain ID (11155111 for Sepolia, 421614 for Arbitrum Sepolia)
|
|
126
|
+
* @returns Object with walletClient and publicClient
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* // Using Account from createEvmWallet (loads from keyfile)
|
|
131
|
+
* const account = createEvmWallet('~/.evm/keys/default.json');
|
|
132
|
+
* const { walletClient, publicClient } = createEvmExecutor(account, 'https://sepolia-rollup.arbitrum.io/rpc', 421614);
|
|
133
|
+
*
|
|
134
|
+
* // Using viem's privateKeyToAccount directly
|
|
135
|
+
* import { privateKeyToAccount } from 'viem/accounts';
|
|
136
|
+
* const account = privateKeyToAccount('0xabc123...');
|
|
137
|
+
* const { walletClient, publicClient } = createEvmExecutor(account, rpcUrl, chainId);
|
|
138
|
+
*
|
|
139
|
+
* // Use clients for bridge deposit
|
|
140
|
+
* await allset.sendToFast({ ..., evmClients: { walletClient, publicClient } });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export function createEvmExecutor(account, rpcUrl, chainId) {
|
|
144
|
+
const chain = CHAIN_MAP[chainId];
|
|
145
|
+
if (!chain) {
|
|
146
|
+
throw new Error(`Unsupported EVM chain ID: ${chainId}. Supported: ${Object.keys(CHAIN_MAP).join(', ')}`);
|
|
147
|
+
}
|
|
148
|
+
const walletClient = createWalletClient({
|
|
149
|
+
account,
|
|
150
|
+
chain,
|
|
151
|
+
transport: http(rpcUrl),
|
|
152
|
+
});
|
|
153
|
+
const publicClient = createPublicClient({
|
|
154
|
+
chain,
|
|
155
|
+
transport: http(rpcUrl),
|
|
156
|
+
});
|
|
157
|
+
return { walletClient, publicClient };
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=evm-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm-executor.js","sourceRoot":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C/B,MAAM,CAAC,MAAM,SAAS,GAA0B;IAC9C,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,IAAI;CACX,CAAC;AAUF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAgB,EAChB,MAAc,EACd,OAAe;IAEf,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,6BAA6B,OAAO,gBAAgB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxF,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAAG,kBAAkB,CAAC;QACtC,OAAO;QACP,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC;KACxB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,kBAAkB,CAAC;QACtC,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC;KACxB,CAAC,CAAC;IAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from '../core/index.js';
|
|
2
|
+
export { AllSetProvider, getAllSetDir, getEvmKeysDir as getAllSetEvmKeysDir, ensureAllSetDirs, initUserConfig, } from './provider.js';
|
|
3
|
+
export { createEvmExecutor, createEvmWallet, getEvmKeysDir, } from './evm-executor.js';
|
|
4
|
+
export { loadNetworksConfig, getNetworkConfig, getChainConfig, getTokenConfig, clearConfigCache, } from './config.js';
|
|
5
|
+
export type { BridgeProvider, BridgeParams, BridgeResult, FastWalletLike, AllSetChainConfig, AllSetTokenInfo, SendToFastParams, SendToExternalParams, ExecuteIntentParams, } from './types.js';
|
|
6
|
+
export type { Intent } from '../intents.js';
|
|
7
|
+
export type { EvmSignResult } from './bridge.js';
|
|
8
|
+
export type { EvmAccount, EvmClients } from './evm-executor.js';
|
|
9
|
+
export type { NetworkConfig, ChainConfig, TokenConfig, AllNetworksConfig } from './config.js';
|
|
10
|
+
export type { AllSetProviderOptions } from './provider.js';
|
|
11
|
+
export declare function evmSign(...args: Parameters<typeof import('./bridge.js').evmSign>): ReturnType<typeof import('./bridge.js').evmSign>;
|
|
12
|
+
export declare function executeBridge(...args: Parameters<typeof import('./bridge.js').executeBridge>): ReturnType<typeof import('./bridge.js').executeBridge>;
|
|
13
|
+
export declare function executeIntent(...args: Parameters<typeof import('./bridge.js').executeIntent>): ReturnType<typeof import('./bridge.js').executeIntent>;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,IAAI,mBAAmB,EACpC,gBAAgB,EAChB,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9F,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,wBAAsB,OAAO,CAC3B,GAAG,IAAI,EAAE,UAAU,CAAC,cAAc,aAAa,EAAE,OAAO,CAAC,GACxD,UAAU,CAAC,cAAc,aAAa,EAAE,OAAO,CAAC,CAGlD;AAED,wBAAsB,aAAa,CACjC,GAAG,IAAI,EAAE,UAAU,CAAC,cAAc,aAAa,EAAE,aAAa,CAAC,GAC9D,UAAU,CAAC,cAAc,aAAa,EAAE,aAAa,CAAC,CAGxD;AAED,wBAAsB,aAAa,CACjC,GAAG,IAAI,EAAE,UAAU,CAAC,cAAc,aAAa,EAAE,aAAa,CAAC,GAC9D,UAAU,CAAC,cAAc,aAAa,EAAE,aAAa,CAAC,CAGxD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from '../core/index.js';
|
|
2
|
+
export { AllSetProvider, getAllSetDir, getEvmKeysDir as getAllSetEvmKeysDir, ensureAllSetDirs, initUserConfig, } from './provider.js';
|
|
3
|
+
export { createEvmExecutor, createEvmWallet, getEvmKeysDir, } from './evm-executor.js';
|
|
4
|
+
export { loadNetworksConfig, getNetworkConfig, getChainConfig, getTokenConfig, clearConfigCache, } from './config.js';
|
|
5
|
+
export async function evmSign(...args) {
|
|
6
|
+
const mod = await import('./bridge.js');
|
|
7
|
+
return mod.evmSign(...args);
|
|
8
|
+
}
|
|
9
|
+
export async function executeBridge(...args) {
|
|
10
|
+
const mod = await import('./bridge.js');
|
|
11
|
+
return mod.executeBridge(...args);
|
|
12
|
+
}
|
|
13
|
+
export async function executeIntent(...args) {
|
|
14
|
+
const mod = await import('./bridge.js');
|
|
15
|
+
return mod.executeIntent(...args);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,IAAI,mBAAmB,EACpC,gBAAgB,EAChB,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAoBrB,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,GAAG,IAAsD;IAEzD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAG,IAA4D;IAE/D,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAG,IAA4D;IAE/D,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -16,7 +16,7 @@ export interface AllSetProviderOptions {
|
|
|
16
16
|
* Custom path to networks.json config file.
|
|
17
17
|
* If not provided, loads from:
|
|
18
18
|
* 1. ~/.allset/networks.json (user override)
|
|
19
|
-
* 2.
|
|
19
|
+
* 2. Embedded package defaults
|
|
20
20
|
*/
|
|
21
21
|
configPath?: string;
|
|
22
22
|
/**
|
|
@@ -67,7 +67,7 @@ export declare class AllSetProvider {
|
|
|
67
67
|
getChainConfig(chain: string): ChainConfig | null;
|
|
68
68
|
/**
|
|
69
69
|
* Get token configuration for a chain.
|
|
70
|
-
* Handles fastUSDC -> USDC normalization.
|
|
70
|
+
* Handles fastUSDC/testUSDC -> USDC normalization.
|
|
71
71
|
*/
|
|
72
72
|
getTokenConfig(chain: string, token: string): TokenConfig | null;
|
|
73
73
|
/**
|
|
@@ -89,7 +89,7 @@ export declare class AllSetProvider {
|
|
|
89
89
|
* amount: '1000000',
|
|
90
90
|
* from: '0xYourEvmAddress',
|
|
91
91
|
* to: 'fast1receiveraddress',
|
|
92
|
-
*
|
|
92
|
+
* evmClients,
|
|
93
93
|
* });
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
@@ -123,7 +123,7 @@ export declare class AllSetProvider {
|
|
|
123
123
|
* // Simple transfer
|
|
124
124
|
* const result = await allset.executeIntent({
|
|
125
125
|
* chain: 'arbitrum',
|
|
126
|
-
* fastWallet,
|
|
126
|
+
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
127
127
|
* token: 'fastUSDC',
|
|
128
128
|
* amount: '1000000',
|
|
129
129
|
* intents: [buildTransferIntent(USDC_ADDRESS, '0xRecipient')],
|
|
@@ -132,7 +132,7 @@ export declare class AllSetProvider {
|
|
|
132
132
|
* // Custom contract call
|
|
133
133
|
* const result = await allset.executeIntent({
|
|
134
134
|
* chain: 'arbitrum',
|
|
135
|
-
* fastWallet,
|
|
135
|
+
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
136
136
|
* token: 'fastUSDC',
|
|
137
137
|
* amount: '1000000',
|
|
138
138
|
* intents: [buildExecuteIntent(CONTRACT, calldata)],
|
|
@@ -155,7 +155,7 @@ export declare function getEvmKeysDir(): string;
|
|
|
155
155
|
*/
|
|
156
156
|
export declare function ensureAllSetDirs(): void;
|
|
157
157
|
/**
|
|
158
|
-
* Initialize user config by
|
|
158
|
+
* Initialize user config by writing the embedded defaults to ~/.allset/.
|
|
159
159
|
* Does nothing if user config already exists.
|
|
160
160
|
*/
|
|
161
161
|
export declare function initUserConfig(): string;
|
|
@@ -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AAgB,GAAG,OAAO,CAAC,YAAY,CAAC;IAgBjE;;;;;;;;;;;;;;OAcG;IACG,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC;IAgBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;CAKxE;AAMD;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAevC"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and provides the bridge() method for bridging tokens.
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { DEFAULT_NETWORKS_CONFIG } from '../default-config.js';
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
// Constants
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
@@ -22,20 +22,14 @@ function expandHome(path) {
|
|
|
22
22
|
}
|
|
23
23
|
return path;
|
|
24
24
|
}
|
|
25
|
-
function getPackageDataDir() {
|
|
26
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
27
|
-
const __dirname = dirname(__filename);
|
|
28
|
-
return join(__dirname, '..', 'data');
|
|
29
|
-
}
|
|
30
25
|
function getUserConfigPath() {
|
|
31
26
|
return join(ALLSET_DIR, 'networks.json');
|
|
32
27
|
}
|
|
33
28
|
function loadConfig(customPath) {
|
|
34
|
-
// Priority: customPath > ~/.allset/networks.json >
|
|
29
|
+
// Priority: customPath > ~/.allset/networks.json > embedded default config
|
|
35
30
|
const paths = [
|
|
36
31
|
customPath,
|
|
37
32
|
getUserConfigPath(),
|
|
38
|
-
join(getPackageDataDir(), 'networks.json'),
|
|
39
33
|
].filter((p) => !!p);
|
|
40
34
|
for (const configPath of paths) {
|
|
41
35
|
const resolved = expandHome(configPath);
|
|
@@ -49,7 +43,7 @@ function loadConfig(customPath) {
|
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
}
|
|
52
|
-
|
|
46
|
+
return structuredClone(DEFAULT_NETWORKS_CONFIG);
|
|
53
47
|
}
|
|
54
48
|
// ---------------------------------------------------------------------------
|
|
55
49
|
// AllSetProvider Class
|
|
@@ -113,14 +107,15 @@ export class AllSetProvider {
|
|
|
113
107
|
}
|
|
114
108
|
/**
|
|
115
109
|
* Get token configuration for a chain.
|
|
116
|
-
* Handles fastUSDC -> USDC normalization.
|
|
110
|
+
* Handles fastUSDC/testUSDC -> USDC normalization.
|
|
117
111
|
*/
|
|
118
112
|
getTokenConfig(chain, token) {
|
|
119
113
|
const chainConfig = this.getChainConfig(chain);
|
|
120
114
|
if (!chainConfig)
|
|
121
115
|
return null;
|
|
122
|
-
// Normalize: fastUSDC on Fast maps to USDC on EVM
|
|
123
|
-
const
|
|
116
|
+
// Normalize: fastUSDC/testUSDC on Fast maps to USDC on EVM
|
|
117
|
+
const lowerToken = token.toLowerCase();
|
|
118
|
+
const normalizedToken = lowerToken === 'fastusdc' || lowerToken === 'testusdc' ? 'USDC' : token;
|
|
124
119
|
return (chainConfig.tokens[normalizedToken] ??
|
|
125
120
|
chainConfig.tokens[normalizedToken.toUpperCase()] ??
|
|
126
121
|
null);
|
|
@@ -148,22 +143,23 @@ export class AllSetProvider {
|
|
|
148
143
|
* amount: '1000000',
|
|
149
144
|
* from: '0xYourEvmAddress',
|
|
150
145
|
* to: 'fast1receiveraddress',
|
|
151
|
-
*
|
|
146
|
+
* evmClients,
|
|
152
147
|
* });
|
|
153
148
|
* ```
|
|
154
149
|
*/
|
|
155
150
|
async sendToFast(params) {
|
|
151
|
+
const normalizedToken = params.token.toLowerCase();
|
|
156
152
|
const { executeBridge } = await import('./bridge.js');
|
|
157
153
|
return executeBridge({
|
|
158
154
|
fromChain: params.chain,
|
|
159
155
|
toChain: 'fast',
|
|
160
156
|
fromToken: params.token,
|
|
161
|
-
toToken:
|
|
157
|
+
toToken: normalizedToken === 'usdc' ? 'fastUSDC' : params.token,
|
|
162
158
|
fromDecimals: 6,
|
|
163
159
|
amount: params.amount,
|
|
164
160
|
senderAddress: params.from,
|
|
165
161
|
receiverAddress: params.to,
|
|
166
|
-
|
|
162
|
+
evmClients: params.evmClients,
|
|
167
163
|
}, this);
|
|
168
164
|
}
|
|
169
165
|
/**
|
|
@@ -182,12 +178,13 @@ export class AllSetProvider {
|
|
|
182
178
|
* ```
|
|
183
179
|
*/
|
|
184
180
|
async sendToExternal(params) {
|
|
181
|
+
const normalizedToken = params.token.toLowerCase();
|
|
185
182
|
const { executeBridge } = await import('./bridge.js');
|
|
186
183
|
return executeBridge({
|
|
187
184
|
fromChain: 'fast',
|
|
188
185
|
toChain: params.chain,
|
|
189
186
|
fromToken: params.token,
|
|
190
|
-
toToken:
|
|
187
|
+
toToken: normalizedToken === 'fastusdc' || normalizedToken === 'testusdc' ? 'USDC' : params.token,
|
|
191
188
|
fromDecimals: 6,
|
|
192
189
|
amount: params.amount,
|
|
193
190
|
senderAddress: params.from,
|
|
@@ -208,7 +205,7 @@ export class AllSetProvider {
|
|
|
208
205
|
* // Simple transfer
|
|
209
206
|
* const result = await allset.executeIntent({
|
|
210
207
|
* chain: 'arbitrum',
|
|
211
|
-
* fastWallet,
|
|
208
|
+
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
212
209
|
* token: 'fastUSDC',
|
|
213
210
|
* amount: '1000000',
|
|
214
211
|
* intents: [buildTransferIntent(USDC_ADDRESS, '0xRecipient')],
|
|
@@ -217,7 +214,7 @@ export class AllSetProvider {
|
|
|
217
214
|
* // Custom contract call
|
|
218
215
|
* const result = await allset.executeIntent({
|
|
219
216
|
* chain: 'arbitrum',
|
|
220
|
-
* fastWallet,
|
|
217
|
+
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
221
218
|
* token: 'fastUSDC',
|
|
222
219
|
* amount: '1000000',
|
|
223
220
|
* intents: [buildExecuteIntent(CONTRACT, calldata)],
|
|
@@ -257,7 +254,7 @@ export function ensureAllSetDirs() {
|
|
|
257
254
|
}
|
|
258
255
|
}
|
|
259
256
|
/**
|
|
260
|
-
* Initialize user config by
|
|
257
|
+
* Initialize user config by writing the embedded defaults to ~/.allset/.
|
|
261
258
|
* Does nothing if user config already exists.
|
|
262
259
|
*/
|
|
263
260
|
export function initUserConfig() {
|
|
@@ -266,11 +263,7 @@ export function initUserConfig() {
|
|
|
266
263
|
if (existsSync(userConfigPath)) {
|
|
267
264
|
return userConfigPath;
|
|
268
265
|
}
|
|
269
|
-
|
|
270
|
-
if (existsSync(bundledPath)) {
|
|
271
|
-
const content = readFileSync(bundledPath, 'utf-8');
|
|
272
|
-
writeFileSync(userConfigPath, content, { mode: 0o600 });
|
|
273
|
-
}
|
|
266
|
+
writeFileSync(userConfigPath, `${JSON.stringify(DEFAULT_NETWORKS_CONFIG, null, 2)}\n`, { mode: 0o600 });
|
|
274
267
|
return userConfigPath;
|
|
275
268
|
}
|
|
276
269
|
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/node/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAI/D,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,UAAU,GAAG,IAAI,CAAC,OAA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C;QAC9B,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,gBAAgB,EAAE,CAAC;IAEnB,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAC3C,IAAI,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,aAAa,CACX,cAAc,EACd,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EACvD,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* types.ts — AllSet SDK types
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import type { EvmClients } from './evm-executor.js';
|
|
5
|
+
export interface FastWalletLike {
|
|
6
|
+
/** Sender Fast address (fast1...) */
|
|
7
|
+
readonly address: string;
|
|
8
|
+
submit(params: {
|
|
9
|
+
recipient: string;
|
|
10
|
+
claim: Record<string, unknown>;
|
|
10
11
|
}): Promise<{
|
|
11
12
|
txHash: string;
|
|
12
|
-
|
|
13
|
+
certificate: unknown;
|
|
13
14
|
}>;
|
|
14
|
-
checkAllowance(token: string, spender: string, owner: string): Promise<bigint>;
|
|
15
|
-
approveErc20(token: string, spender: string, amount: string): Promise<string>;
|
|
16
15
|
}
|
|
17
16
|
export interface BridgeProvider {
|
|
18
17
|
name: string;
|
|
@@ -31,9 +30,10 @@ export interface BridgeParams {
|
|
|
31
30
|
amount: string;
|
|
32
31
|
senderAddress: string;
|
|
33
32
|
receiverAddress: string;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
/** EVM clients from createEvmExecutor() — required for deposits (EVM → Fast) */
|
|
34
|
+
evmClients?: EvmClients;
|
|
35
|
+
/** Compatible Fast wallet — required for withdrawals (Fast → EVM) */
|
|
36
|
+
fastWallet?: FastWalletLike;
|
|
37
37
|
}
|
|
38
38
|
export interface BridgeResult {
|
|
39
39
|
txHash: string;
|
|
@@ -54,8 +54,8 @@ export interface SendToFastParams {
|
|
|
54
54
|
from: string;
|
|
55
55
|
/** Receiver's Fast address (fast1...) */
|
|
56
56
|
to: string;
|
|
57
|
-
/** EVM
|
|
58
|
-
|
|
57
|
+
/** EVM clients from createEvmExecutor() */
|
|
58
|
+
evmClients: EvmClients;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Parameters for sendToExternal (Fast → EVM withdrawal)
|
|
@@ -71,8 +71,8 @@ export interface SendToExternalParams {
|
|
|
71
71
|
from: string;
|
|
72
72
|
/** Receiver's EVM address (0x...) */
|
|
73
73
|
to: string;
|
|
74
|
-
/** FastWallet from @fastxyz/sdk */
|
|
75
|
-
fastWallet:
|
|
74
|
+
/** Compatible Fast wallet, for example FastWallet from @fastxyz/sdk */
|
|
75
|
+
fastWallet: FastWalletLike;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Parameters for executeIntent (advanced intent execution)
|
|
@@ -80,14 +80,14 @@ export interface SendToExternalParams {
|
|
|
80
80
|
export interface ExecuteIntentParams {
|
|
81
81
|
/** Destination EVM chain: 'ethereum' or 'arbitrum' */
|
|
82
82
|
chain: string;
|
|
83
|
-
/** FastWallet from @fastxyz/sdk */
|
|
84
|
-
fastWallet:
|
|
83
|
+
/** Compatible Fast wallet, for example FastWallet from @fastxyz/sdk */
|
|
84
|
+
fastWallet: FastWalletLike;
|
|
85
85
|
/** Token to transfer to bridge (e.g., 'fastUSDC') */
|
|
86
86
|
token: string;
|
|
87
87
|
/** Amount in smallest units */
|
|
88
88
|
amount: string;
|
|
89
89
|
/** Array of intents to execute on EVM chain */
|
|
90
|
-
intents: import('
|
|
90
|
+
intents: import('../intents.js').Intent[];
|
|
91
91
|
/**
|
|
92
92
|
* Optional EVM address for the relayer target.
|
|
93
93
|
* Required when intents do not include a transfer recipient or execute target.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,MAAM,EAAE;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC,GAAG,OAAO,CAAC;QACV,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IACxC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,UAAU,C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