@fastxyz/allset-sdk 0.1.0 → 0.1.2
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 +1 -1
- package/README.md +58 -44
- package/data/networks.json +37 -0
- package/dist/bridge.d.ts +48 -5
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +392 -252
- package/dist/bridge.js.map +1 -1
- package/dist/config.d.ts +48 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +67 -0
- package/dist/config.js.map +1 -0
- package/dist/evm-executor.d.ts +56 -0
- package/dist/evm-executor.d.ts.map +1 -1
- package/dist/evm-executor.js +114 -1
- package/dist/evm-executor.js.map +1 -1
- package/dist/index.d.ts +49 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -4
- package/dist/index.js.map +1 -1
- package/dist/intents.d.ts +94 -0
- package/dist/intents.d.ts.map +1 -0
- package/dist/intents.js +128 -0
- package/dist/intents.js.map +1 -0
- package/dist/provider.d.ts +162 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +276 -0
- package/dist/provider.js.map +1 -0
- package/dist/types.d.ts +79 -36
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -4
- package/dist/fast-compat.d.ts +0 -13
- package/dist/fast-compat.d.ts.map +0 -1
- package/dist/fast-compat.js +0 -22
- package/dist/fast-compat.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,65 +1,79 @@
|
|
|
1
1
|
# AllSet SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bridge tokens between Fast network and EVM chains.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Install
|
|
5
|
+
## Installation
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
npm install @fastxyz/allset-sdk
|
|
8
|
+
npm install @fastxyz/sdk @fastxyz/allset-sdk
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install
|
|
17
|
-
```
|
|
11
|
+
## Quick Start
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
```ts
|
|
14
|
+
import { FastProvider, FastWallet } from '@fastxyz/sdk';
|
|
15
|
+
import { AllSetProvider, createEvmExecutor, createEvmWallet } from '@fastxyz/allset-sdk';
|
|
16
|
+
|
|
17
|
+
// Setup
|
|
18
|
+
const fastProvider = new FastProvider({ network: 'testnet' });
|
|
19
|
+
const allset = new AllSetProvider({ network: 'testnet' });
|
|
20
|
+
const fastWallet = await FastWallet.fromKeyfile('~/.fast/keys/default.json', fastProvider);
|
|
21
|
+
const evmWallet = createEvmWallet('~/.allset/.evm/keys/default.json');
|
|
22
|
+
|
|
23
|
+
// Deposit: EVM → Fast
|
|
24
|
+
const evmExecutor = createEvmExecutor(evmWallet.privateKey, 'https://sepolia-rollup.arbitrum.io/rpc', 421614);
|
|
25
|
+
await allset.sendToFast({
|
|
26
|
+
chain: 'arbitrum',
|
|
27
|
+
token: 'USDC',
|
|
28
|
+
amount: '1000000',
|
|
29
|
+
from: evmWallet.address,
|
|
30
|
+
to: fastWallet.address,
|
|
31
|
+
evmExecutor,
|
|
32
|
+
});
|
|
20
33
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
// Withdraw: Fast → EVM
|
|
35
|
+
await allset.sendToExternal({
|
|
36
|
+
chain: 'arbitrum',
|
|
37
|
+
token: 'fastUSDC',
|
|
38
|
+
amount: '1000000',
|
|
39
|
+
from: fastWallet.address,
|
|
40
|
+
to: evmWallet.address,
|
|
41
|
+
fastWallet,
|
|
42
|
+
});
|
|
26
43
|
```
|
|
27
44
|
|
|
28
|
-
##
|
|
45
|
+
## Advanced: Custom Intents
|
|
29
46
|
|
|
30
47
|
```ts
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const result = await omnisetProvider.bridge({
|
|
40
|
-
fromChain: 'arbitrum',
|
|
41
|
-
toChain: 'fast',
|
|
42
|
-
fromToken: 'USDC',
|
|
43
|
-
toToken: 'fastUSDC',
|
|
44
|
-
fromDecimals: 6,
|
|
48
|
+
import { buildTransferIntent, buildExecuteIntent } from '@fastxyz/allset-sdk';
|
|
49
|
+
|
|
50
|
+
// Execute custom intents on EVM chain
|
|
51
|
+
await allset.executeIntent({
|
|
52
|
+
chain: 'arbitrum',
|
|
53
|
+
fastWallet,
|
|
54
|
+
token: 'fastUSDC',
|
|
45
55
|
amount: '1000000',
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
intents: [
|
|
57
|
+
buildTransferIntent(USDC_ADDRESS, '0xRecipient'),
|
|
58
|
+
// Add more intents: swaps, protocol calls, etc.
|
|
59
|
+
],
|
|
49
60
|
});
|
|
50
|
-
|
|
51
|
-
console.log(result);
|
|
52
61
|
```
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
For intents without a transfer recipient or execute target, pass `externalAddress` so the relayer has an explicit EVM target.
|
|
64
|
+
|
|
65
|
+
## Supported Networks
|
|
66
|
+
|
|
67
|
+
| Network | Chain | Status |
|
|
68
|
+
|---------|-------|--------|
|
|
69
|
+
| Testnet | Arbitrum Sepolia | ✅ |
|
|
70
|
+
| Testnet | Ethereum Sepolia | ✅ |
|
|
71
|
+
| Mainnet | Coming soon | 🔜 |
|
|
55
72
|
|
|
56
|
-
|
|
57
|
-
- Fast to EVM and EVM to Fast flows only
|
|
58
|
-
- EVM executor support for Ethereum Sepolia (`11155111`) and Arbitrum Sepolia (`421614`)
|
|
59
|
-
- Current token registry maps Arbitrum Sepolia `USDC` and `fastUSDC`
|
|
73
|
+
## Documentation
|
|
60
74
|
|
|
61
|
-
|
|
75
|
+
See [SKILL.md](./SKILL.md) for detailed API documentation.
|
|
62
76
|
|
|
63
|
-
##
|
|
77
|
+
## License
|
|
64
78
|
|
|
65
|
-
|
|
79
|
+
MIT
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testnet": {
|
|
3
|
+
"crossSignUrl": "https://testnet.cross-sign.allset.fast.xyz",
|
|
4
|
+
"chains": {
|
|
5
|
+
"ethereum": {
|
|
6
|
+
"chainId": 11155111,
|
|
7
|
+
"bridgeContract": "0x96A2a48Eb19144b01a23ec5B52085D848e1344F5",
|
|
8
|
+
"fastBridgeAddress": "fast1fxtkgpwcy7hnakw96gg7relph4wxx7ghrukm723p3l9adxuxljzsc6f958",
|
|
9
|
+
"relayerUrl": "https://testnet.allset.fast.xyz/ethereum-sepolia/relayer/relay",
|
|
10
|
+
"tokens": {
|
|
11
|
+
"USDC": {
|
|
12
|
+
"evmAddress": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
13
|
+
"fastTokenId": "9c52fe9465f57bc526c11aa0c048fd8709aa46abc06d15c80cbed9263d4d4df8",
|
|
14
|
+
"decimals": 6
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"arbitrum": {
|
|
19
|
+
"chainId": 421614,
|
|
20
|
+
"bridgeContract": "0x00d6aE842Bb6e13457b241e69d542560EdDAF224",
|
|
21
|
+
"fastBridgeAddress": "fast1tkmtqxulhnzeeg9zhuwxy3x95wr7waytm9cq40ndf7tkuwwcc6jseg24j8",
|
|
22
|
+
"relayerUrl": "https://testnet.allset.fast.xyz/arbitrum-sepolia/relayer/relay",
|
|
23
|
+
"tokens": {
|
|
24
|
+
"USDC": {
|
|
25
|
+
"evmAddress": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
|
|
26
|
+
"fastTokenId": "9c52fe9465f57bc526c11aa0c048fd8709aa46abc06d15c80cbed9263d4d4df8",
|
|
27
|
+
"decimals": 6
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"mainnet": {
|
|
34
|
+
"crossSignUrl": "https://cross-sign.allset.fast.xyz",
|
|
35
|
+
"chains": {}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,12 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* bridge.ts —
|
|
2
|
+
* bridge.ts — AllSet bridge provider
|
|
3
3
|
*
|
|
4
|
-
* Bridges between Fast
|
|
4
|
+
* Bridges between Fast network and the SDK's supported EVM routes.
|
|
5
5
|
*
|
|
6
6
|
* Two directions:
|
|
7
7
|
* Deposit (EVM → Fast): call bridge.deposit(token, amount, receiver) on the EVM bridge contract
|
|
8
|
-
* Withdraw (Fast → EVM): transfer on Fast
|
|
8
|
+
* Withdraw (Fast → EVM): transfer on Fast network + submit ExternalClaim intent + POST to relayer
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
|
|
10
|
+
import type { BridgeParams, BridgeResult, ExecuteIntentParams } from './types.js';
|
|
11
|
+
import { type ChainConfig, type TokenConfig } from './config.js';
|
|
12
|
+
interface BridgeProviderConfig {
|
|
13
|
+
network: 'testnet' | 'mainnet';
|
|
14
|
+
crossSignUrl?: string;
|
|
15
|
+
getChainConfig(chain: string): ChainConfig | null;
|
|
16
|
+
getTokenConfig(chain: string, token: string): TokenConfig | null;
|
|
17
|
+
getNetworkConfig?(): {
|
|
18
|
+
chains: Record<string, ChainConfig>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface EvmSignResult {
|
|
22
|
+
transaction: number[];
|
|
23
|
+
signature: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Request EVM cross-signing for a Fast network certificate.
|
|
27
|
+
*
|
|
28
|
+
* This is an AllSet-specific operation that requests the AllSet committee
|
|
29
|
+
* to sign a certificate for verification on EVM chains.
|
|
30
|
+
*
|
|
31
|
+
* @param certificate - The certificate from a FastWallet.send() or FastWallet.submit() call
|
|
32
|
+
* @param crossSignUrl - Optional custom cross-sign service URL
|
|
33
|
+
* @returns The signed transaction bytes and signature for relayer submission
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const result = await fastWallet.send({ to: bridgeAddress, amount: '1000000', token: 'fastUSDC' });
|
|
38
|
+
* const signed = await evmSign(result.certificate);
|
|
39
|
+
* // Use signed.transaction and signed.signature with the relayer
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function evmSign(certificate: unknown, crossSignUrl?: string): Promise<EvmSignResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Execute a bridge operation with optional provider configuration.
|
|
45
|
+
* Called by AllSetProvider.bridge() or directly for low-level usage.
|
|
46
|
+
*/
|
|
47
|
+
export declare function executeBridge(params: BridgeParams, provider?: BridgeProviderConfig): Promise<BridgeResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Execute intents on an EVM chain after transferring tokens from Fast network.
|
|
50
|
+
* This is the core function used by sendToExternal and can be used directly for
|
|
51
|
+
* advanced use cases like swaps, multi-step operations, etc.
|
|
52
|
+
*/
|
|
53
|
+
export declare function executeIntent(params: ExecuteIntentParams, provider?: BridgeProviderConfig): Promise<BridgeResult>;
|
|
54
|
+
export {};
|
|
12
55
|
//# sourceMappingURL=bridge.d.ts.map
|
package/dist/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAsC,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,EAAoD,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AA0CnH,UAAU,oBAAoB;IAC5B,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IAClD,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IACjE,gBAAgB,CAAC,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;KAAE,CAAC;CAC9D;AA+HD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,OAAO,CAC3B,WAAW,EAAE,OAAO,EACpB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,CA2CxB;AAID;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAiChH;AAgID;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAqLvB"}
|