@fastxyz/allset-sdk 0.1.11 → 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.
- package/README.md +339 -266
- package/dist/index.d.ts +658 -5
- package/dist/index.js +927 -7
- package/package.json +21 -47
- package/dist/browser/index.d.ts +0 -2
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js +0 -1
- package/dist/core/address.d.ts +0 -5
- package/dist/core/address.d.ts.map +0 -1
- package/dist/core/address.js +0 -29
- package/dist/core/deposit.d.ts +0 -59
- package/dist/core/deposit.d.ts.map +0 -1
- package/dist/core/deposit.js +0 -92
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -3
- package/dist/default-config.d.ts +0 -78
- package/dist/default-config.d.ts.map +0 -1
- package/dist/default-config.js +0 -78
- package/dist/index.d.ts.map +0 -1
- package/dist/intents.d.ts +0 -94
- package/dist/intents.d.ts.map +0 -1
- package/dist/intents.js +0 -119
- package/dist/node/bridge.d.ts +0 -38
- package/dist/node/bridge.d.ts.map +0 -1
- package/dist/node/bridge.js +0 -519
- package/dist/node/config.d.ts +0 -45
- package/dist/node/config.d.ts.map +0 -1
- package/dist/node/config.js +0 -48
- package/dist/node/eip7702.d.ts +0 -47
- package/dist/node/eip7702.d.ts.map +0 -1
- package/dist/node/eip7702.js +0 -189
- package/dist/node/evm-executor.d.ts +0 -130
- package/dist/node/evm-executor.d.ts.map +0 -1
- package/dist/node/evm-executor.js +0 -160
- package/dist/node/index.d.ts +0 -15
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js +0 -17
- package/dist/node/provider.d.ts +0 -162
- package/dist/node/provider.d.ts.map +0 -1
- package/dist/node/provider.js +0 -272
- package/dist/node/types.d.ts +0 -110
- package/dist/node/types.d.ts.map +0 -1
- package/dist/node/types.js +0 -4
package/dist/node/provider.d.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* provider.ts — AllSetProvider for bridge configuration and operations
|
|
3
|
-
*
|
|
4
|
-
* Similar to FastProvider, AllSetProvider manages network configuration
|
|
5
|
-
* and provides the bridge() method for bridging tokens.
|
|
6
|
-
*/
|
|
7
|
-
import type { NetworkConfig, ChainConfig, TokenConfig, AllNetworksConfig } from './config.js';
|
|
8
|
-
import type { BridgeResult, SendToFastParams, SendToExternalParams, ExecuteIntentParams } from './types.js';
|
|
9
|
-
export interface AllSetProviderOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Network to use: 'testnet' or 'mainnet'
|
|
12
|
-
* @default 'testnet'
|
|
13
|
-
*/
|
|
14
|
-
network?: 'testnet' | 'mainnet';
|
|
15
|
-
/**
|
|
16
|
-
* Custom path to networks.json config file.
|
|
17
|
-
* If not provided, loads from:
|
|
18
|
-
* 1. ~/.allset/networks.json (user override)
|
|
19
|
-
* 2. Embedded package defaults
|
|
20
|
-
*/
|
|
21
|
-
configPath?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Custom cross-sign URL (overrides config)
|
|
24
|
-
*/
|
|
25
|
-
crossSignUrl?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* AllSetProvider manages AllSet bridge configuration.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* // Default testnet configuration
|
|
33
|
-
* const provider = new AllSetProvider();
|
|
34
|
-
*
|
|
35
|
-
* // Mainnet configuration
|
|
36
|
-
* const provider = new AllSetProvider({ network: 'mainnet' });
|
|
37
|
-
*
|
|
38
|
-
* // Custom config file
|
|
39
|
-
* const provider = new AllSetProvider({ configPath: './my-config.json' });
|
|
40
|
-
*
|
|
41
|
-
* // Access configuration
|
|
42
|
-
* const chainConfig = provider.getChainConfig('arbitrum-sepolia');
|
|
43
|
-
* const tokenConfig = provider.getTokenConfig('arbitrum-sepolia', 'USDC');
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export declare class AllSetProvider {
|
|
47
|
-
private readonly _network;
|
|
48
|
-
private readonly _config;
|
|
49
|
-
private readonly _networkConfig;
|
|
50
|
-
private readonly _crossSignUrl;
|
|
51
|
-
constructor(options?: AllSetProviderOptions);
|
|
52
|
-
/**
|
|
53
|
-
* Get the current network name.
|
|
54
|
-
*/
|
|
55
|
-
get network(): 'testnet' | 'mainnet';
|
|
56
|
-
/**
|
|
57
|
-
* Get the cross-sign service URL.
|
|
58
|
-
*/
|
|
59
|
-
get crossSignUrl(): string;
|
|
60
|
-
/**
|
|
61
|
-
* Get list of supported chain names.
|
|
62
|
-
*/
|
|
63
|
-
get chains(): string[];
|
|
64
|
-
/**
|
|
65
|
-
* Get configuration for a specific chain.
|
|
66
|
-
*/
|
|
67
|
-
getChainConfig(chain: string): ChainConfig | null;
|
|
68
|
-
/**
|
|
69
|
-
* Get token configuration for a chain.
|
|
70
|
-
* Handles testUSDC -> USDC normalization for testnet.
|
|
71
|
-
*/
|
|
72
|
-
getTokenConfig(chain: string, token: string): TokenConfig | null;
|
|
73
|
-
/**
|
|
74
|
-
* Get the full network configuration.
|
|
75
|
-
*/
|
|
76
|
-
getNetworkConfig(): NetworkConfig;
|
|
77
|
-
/**
|
|
78
|
-
* Get the raw config (both testnet and mainnet).
|
|
79
|
-
*/
|
|
80
|
-
getRawConfig(): AllNetworksConfig;
|
|
81
|
-
/**
|
|
82
|
-
* Deposit tokens from EVM chain to Fast network.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* const result = await allset.sendToFast({
|
|
87
|
-
* chain: 'arbitrum-sepolia',
|
|
88
|
-
* token: 'USDC',
|
|
89
|
-
* amount: '1000000',
|
|
90
|
-
* from: '0xYourEvmAddress',
|
|
91
|
-
* to: 'fast1receiveraddress',
|
|
92
|
-
* evmClients,
|
|
93
|
-
* });
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
sendToFast(params: SendToFastParams): Promise<BridgeResult>;
|
|
97
|
-
/**
|
|
98
|
-
* Withdraw tokens from Fast network to EVM chain.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* const result = await allset.sendToExternal({
|
|
103
|
-
* chain: 'base',
|
|
104
|
-
* token: 'USDC',
|
|
105
|
-
* amount: '1000000',
|
|
106
|
-
* from: fastWallet.address,
|
|
107
|
-
* to: '0xReceiverEvmAddress',
|
|
108
|
-
* fastWallet,
|
|
109
|
-
* });
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
sendToExternal(params: SendToExternalParams): Promise<BridgeResult>;
|
|
113
|
-
/**
|
|
114
|
-
* Execute custom intents on an EVM chain.
|
|
115
|
-
*
|
|
116
|
-
* This is the advanced API for composing custom operations like swaps,
|
|
117
|
-
* multi-step transactions, or protocol integrations.
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```ts
|
|
121
|
-
* import { buildTransferIntent, buildExecuteIntent } from '@fastxyz/allset-sdk';
|
|
122
|
-
*
|
|
123
|
-
* // Simple transfer
|
|
124
|
-
* const result = await allset.executeIntent({
|
|
125
|
-
* chain: 'base',
|
|
126
|
-
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
127
|
-
* token: 'USDC',
|
|
128
|
-
* amount: '1000000',
|
|
129
|
-
* intents: [buildTransferIntent(USDC_ADDRESS, '0xRecipient')],
|
|
130
|
-
* });
|
|
131
|
-
*
|
|
132
|
-
* // Custom contract call
|
|
133
|
-
* const result = await allset.executeIntent({
|
|
134
|
-
* chain: 'base',
|
|
135
|
-
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
136
|
-
* token: 'USDC',
|
|
137
|
-
* amount: '1000000',
|
|
138
|
-
* intents: [buildExecuteIntent(CONTRACT, calldata)],
|
|
139
|
-
* externalAddress: CONTRACT,
|
|
140
|
-
* });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
executeIntent(params: ExecuteIntentParams): Promise<BridgeResult>;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Get the AllSet home directory (~/.allset).
|
|
147
|
-
*/
|
|
148
|
-
export declare function getAllSetDir(): string;
|
|
149
|
-
/**
|
|
150
|
-
* Get the EVM keys directory (~/.allset/.evm/keys).
|
|
151
|
-
*/
|
|
152
|
-
export declare function getEvmKeysDir(): string;
|
|
153
|
-
/**
|
|
154
|
-
* Ensure the AllSet directory structure exists.
|
|
155
|
-
*/
|
|
156
|
-
export declare function ensureAllSetDirs(): void;
|
|
157
|
-
/**
|
|
158
|
-
* Initialize user config by writing the embedded defaults to ~/.allset/.
|
|
159
|
-
* Does nothing if user config already exists.
|
|
160
|
-
*/
|
|
161
|
-
export declare function initUserConfig(): string;
|
|
162
|
-
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/node/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAa5G,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAEhC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA4CD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,OAAO,GAAE,qBAA0B;IAY/C;;OAEG;IACH,IAAI,OAAO,IAAI,SAAS,GAAG,SAAS,CAEnC;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAIjD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAehE;;OAEG;IACH,gBAAgB,IAAI,aAAa;IAIjC;;OAEG;IACH,YAAY,IAAI,iBAAiB;IAIjC;;;;;;;;;;;;;;OAcG;IACG,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBjE;;;;;;;;;;;;;;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"}
|
package/dist/node/provider.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* provider.ts — AllSetProvider for bridge configuration and operations
|
|
3
|
-
*
|
|
4
|
-
* Similar to FastProvider, AllSetProvider manages network configuration
|
|
5
|
-
* and provides the bridge() method for bridging tokens.
|
|
6
|
-
*/
|
|
7
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
8
|
-
import { join } from 'node:path';
|
|
9
|
-
import { DEFAULT_NETWORKS_CONFIG } from '../default-config.js';
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
// Constants
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
const ALLSET_DIR = join(process.env.HOME || process.env.USERPROFILE || '', '.allset');
|
|
14
|
-
const EVM_KEYS_DIR = join(ALLSET_DIR, '.evm', 'keys');
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Helper Functions
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
function expandHome(path) {
|
|
19
|
-
if (path.startsWith('~/')) {
|
|
20
|
-
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
21
|
-
return path.replace('~', home);
|
|
22
|
-
}
|
|
23
|
-
return path;
|
|
24
|
-
}
|
|
25
|
-
function getUserConfigPath() {
|
|
26
|
-
return join(ALLSET_DIR, 'networks.json');
|
|
27
|
-
}
|
|
28
|
-
function loadConfig(customPath) {
|
|
29
|
-
// Priority: customPath > ~/.allset/networks.json > embedded default config
|
|
30
|
-
const paths = [
|
|
31
|
-
customPath,
|
|
32
|
-
getUserConfigPath(),
|
|
33
|
-
].filter((p) => !!p);
|
|
34
|
-
for (const configPath of paths) {
|
|
35
|
-
const resolved = expandHome(configPath);
|
|
36
|
-
if (existsSync(resolved)) {
|
|
37
|
-
try {
|
|
38
|
-
const raw = readFileSync(resolved, 'utf-8');
|
|
39
|
-
return JSON.parse(raw);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
// Continue to next path
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return structuredClone(DEFAULT_NETWORKS_CONFIG);
|
|
47
|
-
}
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
49
|
-
// AllSetProvider Class
|
|
50
|
-
// ---------------------------------------------------------------------------
|
|
51
|
-
/**
|
|
52
|
-
* AllSetProvider manages AllSet bridge configuration.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* // Default testnet configuration
|
|
57
|
-
* const provider = new AllSetProvider();
|
|
58
|
-
*
|
|
59
|
-
* // Mainnet configuration
|
|
60
|
-
* const provider = new AllSetProvider({ network: 'mainnet' });
|
|
61
|
-
*
|
|
62
|
-
* // Custom config file
|
|
63
|
-
* const provider = new AllSetProvider({ configPath: './my-config.json' });
|
|
64
|
-
*
|
|
65
|
-
* // Access configuration
|
|
66
|
-
* const chainConfig = provider.getChainConfig('arbitrum-sepolia');
|
|
67
|
-
* const tokenConfig = provider.getTokenConfig('arbitrum-sepolia', 'USDC');
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export class AllSetProvider {
|
|
71
|
-
_network;
|
|
72
|
-
_config;
|
|
73
|
-
_networkConfig;
|
|
74
|
-
_crossSignUrl;
|
|
75
|
-
constructor(options = {}) {
|
|
76
|
-
this._network = options.network ?? 'testnet';
|
|
77
|
-
this._config = loadConfig(options.configPath);
|
|
78
|
-
this._networkConfig = this._config[this._network];
|
|
79
|
-
if (!this._networkConfig) {
|
|
80
|
-
throw new Error(`Network "${this._network}" not found in config`);
|
|
81
|
-
}
|
|
82
|
-
this._crossSignUrl = options.crossSignUrl ?? this._networkConfig.crossSignUrl;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Get the current network name.
|
|
86
|
-
*/
|
|
87
|
-
get network() {
|
|
88
|
-
return this._network;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get the cross-sign service URL.
|
|
92
|
-
*/
|
|
93
|
-
get crossSignUrl() {
|
|
94
|
-
return this._crossSignUrl;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Get list of supported chain names.
|
|
98
|
-
*/
|
|
99
|
-
get chains() {
|
|
100
|
-
return Object.keys(this._networkConfig.chains);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get configuration for a specific chain.
|
|
104
|
-
*/
|
|
105
|
-
getChainConfig(chain) {
|
|
106
|
-
return this._networkConfig.chains[chain] ?? null;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Get token configuration for a chain.
|
|
110
|
-
* Handles testUSDC -> USDC normalization for testnet.
|
|
111
|
-
*/
|
|
112
|
-
getTokenConfig(chain, token) {
|
|
113
|
-
const chainConfig = this.getChainConfig(chain);
|
|
114
|
-
if (!chainConfig)
|
|
115
|
-
return null;
|
|
116
|
-
// Normalize: testUSDC on Fast testnet maps to USDC on EVM
|
|
117
|
-
const lowerToken = token.toLowerCase();
|
|
118
|
-
const normalizedToken = lowerToken === 'fastusdc' || lowerToken === 'testusdc' ? 'USDC' : token;
|
|
119
|
-
return (chainConfig.tokens[normalizedToken] ??
|
|
120
|
-
chainConfig.tokens[normalizedToken.toUpperCase()] ??
|
|
121
|
-
null);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Get the full network configuration.
|
|
125
|
-
*/
|
|
126
|
-
getNetworkConfig() {
|
|
127
|
-
return this._networkConfig;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get the raw config (both testnet and mainnet).
|
|
131
|
-
*/
|
|
132
|
-
getRawConfig() {
|
|
133
|
-
return this._config;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Deposit tokens from EVM chain to Fast network.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* const result = await allset.sendToFast({
|
|
141
|
-
* chain: 'arbitrum-sepolia',
|
|
142
|
-
* token: 'USDC',
|
|
143
|
-
* amount: '1000000',
|
|
144
|
-
* from: '0xYourEvmAddress',
|
|
145
|
-
* to: 'fast1receiveraddress',
|
|
146
|
-
* evmClients,
|
|
147
|
-
* });
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
async sendToFast(params) {
|
|
151
|
-
const normalizedToken = params.token.toLowerCase();
|
|
152
|
-
// Map USDC to the correct Fast token: USDC for mainnet, testUSDC for testnet
|
|
153
|
-
const fastToken = normalizedToken === 'usdc'
|
|
154
|
-
? (this._network === 'mainnet' ? 'USDC' : 'testUSDC')
|
|
155
|
-
: params.token;
|
|
156
|
-
const { executeBridge } = await import('./bridge.js');
|
|
157
|
-
return executeBridge({
|
|
158
|
-
fromChain: params.chain,
|
|
159
|
-
toChain: 'fast',
|
|
160
|
-
fromToken: params.token,
|
|
161
|
-
toToken: fastToken,
|
|
162
|
-
fromDecimals: 6,
|
|
163
|
-
amount: params.amount,
|
|
164
|
-
senderAddress: params.from,
|
|
165
|
-
receiverAddress: params.to,
|
|
166
|
-
evmClients: params.evmClients,
|
|
167
|
-
}, this);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Withdraw tokens from Fast network to EVM chain.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* const result = await allset.sendToExternal({
|
|
175
|
-
* chain: 'base',
|
|
176
|
-
* token: 'USDC',
|
|
177
|
-
* amount: '1000000',
|
|
178
|
-
* from: fastWallet.address,
|
|
179
|
-
* to: '0xReceiverEvmAddress',
|
|
180
|
-
* fastWallet,
|
|
181
|
-
* });
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
async sendToExternal(params) {
|
|
185
|
-
const normalizedToken = params.token.toLowerCase();
|
|
186
|
-
const { executeBridge } = await import('./bridge.js');
|
|
187
|
-
return executeBridge({
|
|
188
|
-
fromChain: 'fast',
|
|
189
|
-
toChain: params.chain,
|
|
190
|
-
fromToken: params.token,
|
|
191
|
-
toToken: normalizedToken === 'fastusdc' || normalizedToken === 'testusdc' ? 'USDC' : params.token,
|
|
192
|
-
fromDecimals: 6,
|
|
193
|
-
amount: params.amount,
|
|
194
|
-
senderAddress: params.from,
|
|
195
|
-
receiverAddress: params.to,
|
|
196
|
-
fastWallet: params.fastWallet,
|
|
197
|
-
}, this);
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Execute custom intents on an EVM chain.
|
|
201
|
-
*
|
|
202
|
-
* This is the advanced API for composing custom operations like swaps,
|
|
203
|
-
* multi-step transactions, or protocol integrations.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* ```ts
|
|
207
|
-
* import { buildTransferIntent, buildExecuteIntent } from '@fastxyz/allset-sdk';
|
|
208
|
-
*
|
|
209
|
-
* // Simple transfer
|
|
210
|
-
* const result = await allset.executeIntent({
|
|
211
|
-
* chain: 'base',
|
|
212
|
-
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
213
|
-
* token: 'USDC',
|
|
214
|
-
* amount: '1000000',
|
|
215
|
-
* intents: [buildTransferIntent(USDC_ADDRESS, '0xRecipient')],
|
|
216
|
-
* });
|
|
217
|
-
*
|
|
218
|
-
* // Custom contract call
|
|
219
|
-
* const result = await allset.executeIntent({
|
|
220
|
-
* chain: 'base',
|
|
221
|
-
* fastWallet, // Compatible Fast wallet, e.g. FastWallet from @fastxyz/sdk
|
|
222
|
-
* token: 'USDC',
|
|
223
|
-
* amount: '1000000',
|
|
224
|
-
* intents: [buildExecuteIntent(CONTRACT, calldata)],
|
|
225
|
-
* externalAddress: CONTRACT,
|
|
226
|
-
* });
|
|
227
|
-
* ```
|
|
228
|
-
*/
|
|
229
|
-
async executeIntent(params) {
|
|
230
|
-
const { executeIntent: execIntent } = await import('./bridge.js');
|
|
231
|
-
return execIntent(params, this);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// ---------------------------------------------------------------------------
|
|
235
|
-
// Directory Utilities
|
|
236
|
-
// ---------------------------------------------------------------------------
|
|
237
|
-
/**
|
|
238
|
-
* Get the AllSet home directory (~/.allset).
|
|
239
|
-
*/
|
|
240
|
-
export function getAllSetDir() {
|
|
241
|
-
return ALLSET_DIR;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Get the EVM keys directory (~/.allset/.evm/keys).
|
|
245
|
-
*/
|
|
246
|
-
export function getEvmKeysDir() {
|
|
247
|
-
return EVM_KEYS_DIR;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Ensure the AllSet directory structure exists.
|
|
251
|
-
*/
|
|
252
|
-
export function ensureAllSetDirs() {
|
|
253
|
-
if (!existsSync(ALLSET_DIR)) {
|
|
254
|
-
mkdirSync(ALLSET_DIR, { recursive: true, mode: 0o700 });
|
|
255
|
-
}
|
|
256
|
-
if (!existsSync(EVM_KEYS_DIR)) {
|
|
257
|
-
mkdirSync(EVM_KEYS_DIR, { recursive: true, mode: 0o700 });
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Initialize user config by writing the embedded defaults to ~/.allset/.
|
|
262
|
-
* Does nothing if user config already exists.
|
|
263
|
-
*/
|
|
264
|
-
export function initUserConfig() {
|
|
265
|
-
ensureAllSetDirs();
|
|
266
|
-
const userConfigPath = getUserConfigPath();
|
|
267
|
-
if (existsSync(userConfigPath)) {
|
|
268
|
-
return userConfigPath;
|
|
269
|
-
}
|
|
270
|
-
writeFileSync(userConfigPath, `${JSON.stringify(DEFAULT_NETWORKS_CONFIG, null, 2)}\n`, { mode: 0o600 });
|
|
271
|
-
return userConfigPath;
|
|
272
|
-
}
|
package/dist/node/types.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* types.ts — AllSet SDK types
|
|
3
|
-
*/
|
|
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
|
-
claim: Record<string, unknown>;
|
|
10
|
-
}): Promise<{
|
|
11
|
-
txHash: string;
|
|
12
|
-
certificate: unknown;
|
|
13
|
-
}>;
|
|
14
|
-
}
|
|
15
|
-
export interface BridgeProvider {
|
|
16
|
-
name: string;
|
|
17
|
-
chains: string[];
|
|
18
|
-
networks?: Array<'testnet' | 'mainnet'>;
|
|
19
|
-
bridge(params: BridgeParams): Promise<BridgeResult>;
|
|
20
|
-
}
|
|
21
|
-
export interface BridgeParams {
|
|
22
|
-
fromChain: string;
|
|
23
|
-
fromChainId?: number;
|
|
24
|
-
toChain: string;
|
|
25
|
-
toChainId?: number;
|
|
26
|
-
fromToken: string;
|
|
27
|
-
toToken: string;
|
|
28
|
-
fromDecimals: number;
|
|
29
|
-
amount: string;
|
|
30
|
-
senderAddress: string;
|
|
31
|
-
receiverAddress: string;
|
|
32
|
-
/** EVM clients from createEvmExecutor() — required for deposits (EVM → Fast) */
|
|
33
|
-
evmClients?: EvmClients;
|
|
34
|
-
/** Compatible Fast wallet — required for withdrawals (Fast → EVM) */
|
|
35
|
-
fastWallet?: FastWalletLike;
|
|
36
|
-
}
|
|
37
|
-
export interface BridgeResult {
|
|
38
|
-
txHash: string;
|
|
39
|
-
orderId: string;
|
|
40
|
-
estimatedTime?: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Parameters for sendToFast (EVM → Fast deposit)
|
|
44
|
-
*/
|
|
45
|
-
export interface SendToFastParams {
|
|
46
|
-
/** Source EVM chain, for example 'ethereum-sepolia', 'arbitrum-sepolia', or 'base' */
|
|
47
|
-
chain: string;
|
|
48
|
-
/** Token symbol (e.g., 'USDC') */
|
|
49
|
-
token: string;
|
|
50
|
-
/** Amount in smallest units (e.g., '1000000' for 1 USDC) */
|
|
51
|
-
amount: string;
|
|
52
|
-
/** Sender's EVM address (0x...) */
|
|
53
|
-
from: string;
|
|
54
|
-
/** Receiver's Fast address (fast1...) */
|
|
55
|
-
to: string;
|
|
56
|
-
/** EVM clients from createEvmExecutor() */
|
|
57
|
-
evmClients: EvmClients;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Parameters for sendToExternal (Fast → EVM withdrawal)
|
|
61
|
-
*/
|
|
62
|
-
export interface SendToExternalParams {
|
|
63
|
-
/** Destination EVM chain, for example 'ethereum-sepolia', 'arbitrum-sepolia', or 'base' */
|
|
64
|
-
chain: string;
|
|
65
|
-
/** Token symbol (e.g., 'USDC' for mainnet, 'testUSDC' for testnet) */
|
|
66
|
-
token: string;
|
|
67
|
-
/** Amount in smallest units (e.g., '1000000' for 1 USDC) */
|
|
68
|
-
amount: string;
|
|
69
|
-
/** Sender's Fast address (fast1...) */
|
|
70
|
-
from: string;
|
|
71
|
-
/** Receiver's EVM address (0x...) */
|
|
72
|
-
to: string;
|
|
73
|
-
/** Compatible Fast wallet, for example FastWallet from @fastxyz/sdk */
|
|
74
|
-
fastWallet: FastWalletLike;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Parameters for executeIntent (advanced intent execution)
|
|
78
|
-
*/
|
|
79
|
-
export interface ExecuteIntentParams {
|
|
80
|
-
/** Destination EVM chain, for example 'ethereum-sepolia', 'arbitrum-sepolia', or 'base' */
|
|
81
|
-
chain: string;
|
|
82
|
-
/** Compatible Fast wallet, for example FastWallet from @fastxyz/sdk */
|
|
83
|
-
fastWallet: FastWalletLike;
|
|
84
|
-
/** Token to transfer to bridge (e.g., 'USDC') */
|
|
85
|
-
token: string;
|
|
86
|
-
/** Amount in smallest units */
|
|
87
|
-
amount: string;
|
|
88
|
-
/** Array of intents to execute on EVM chain */
|
|
89
|
-
intents: import('../intents.js').Intent[];
|
|
90
|
-
/**
|
|
91
|
-
* Optional EVM address for the relayer target.
|
|
92
|
-
* Required when intents do not include a transfer recipient or execute target.
|
|
93
|
-
*/
|
|
94
|
-
externalAddress?: string;
|
|
95
|
-
/** Deadline in seconds from now (default: 3600 = 1 hour) */
|
|
96
|
-
deadlineSeconds?: number;
|
|
97
|
-
}
|
|
98
|
-
export interface AllSetChainConfig {
|
|
99
|
-
chainId: number;
|
|
100
|
-
bridgeContract: string;
|
|
101
|
-
fastsetBridgeAddress: string;
|
|
102
|
-
relayerUrl: string;
|
|
103
|
-
}
|
|
104
|
-
export interface AllSetTokenInfo {
|
|
105
|
-
evmAddress: string;
|
|
106
|
-
fastsetTokenId: Uint8Array;
|
|
107
|
-
decimals: number;
|
|
108
|
-
isNative: boolean;
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/node/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/node/types.ts"],"names":[],"mappings":"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"}
|
package/dist/node/types.js
DELETED