@fastxyz/allset-sdk 0.1.1 → 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/README.md CHANGED
@@ -1,111 +1,78 @@
1
1
  # AllSet SDK
2
2
 
3
- Official TypeScript SDK for the AllSet bridge. Bridge tokens between Fast network and supported EVM routes, with the current branch focused on Arbitrum Sepolia and Fast testnet flows.
3
+ Bridge tokens between Fast network and EVM chains.
4
4
 
5
- ## Install
5
+ ## Installation
6
6
 
7
7
  ```bash
8
- npm install @fastxyz/allset-sdk
8
+ npm install @fastxyz/sdk @fastxyz/allset-sdk
9
9
  ```
10
10
 
11
11
  ## Quick Start
12
12
 
13
- ### Deposit (EVM → Fast)
14
-
15
13
  ```ts
16
- import { createEvmExecutor, allsetProvider } from '@fastxyz/allset-sdk';
17
-
18
- const evmExecutor = createEvmExecutor(
19
- process.env.EVM_PRIVATE_KEY!,
20
- 'https://sepolia-rollup.arbitrum.io/rpc',
21
- 421614
22
- );
23
-
24
- const result = await allsetProvider.bridge({
25
- fromChain: 'arbitrum',
26
- toChain: 'fast',
27
- fromToken: 'USDC',
28
- toToken: 'fastUSDC',
29
- fromDecimals: 6,
30
- amount: '1000000', // 1 USDC (6 decimals)
31
- senderAddress: '0xYourEvmAddress',
32
- receiverAddress: 'fast1yourfastaddress',
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,
33
31
  evmExecutor,
34
32
  });
35
33
 
36
- console.log(result.txHash);
37
- ```
38
-
39
- ### Withdraw (Fast → EVM)
40
-
41
- ```ts
42
- import { createFastWallet } from '@fastxyz/allset-sdk';
43
-
44
- const wallet = createFastWallet();
45
- console.log(wallet.address);
46
- // Persist wallet.privateKey and wallet.publicKey securely.
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
+ });
47
43
  ```
48
44
 
49
- Store that keypair securely, then use it with `createFastClient()`:
45
+ ## Advanced: Custom Intents
50
46
 
51
47
  ```ts
52
- import { createFastClient, allsetProvider } from '@fastxyz/allset-sdk';
53
-
54
- const fastClient = createFastClient({
55
- privateKey: process.env.FAST_PRIVATE_KEY!, // 32-byte hex
56
- publicKey: process.env.FAST_PUBLIC_KEY!, // 32-byte hex
57
- });
58
-
59
- const result = await allsetProvider.bridge({
60
- fromChain: 'fast',
61
- toChain: 'arbitrum',
62
- fromToken: 'fastUSDC',
63
- toToken: 'USDC',
64
- fromDecimals: 6,
65
- amount: '1000000', // 1 USDC (6 decimals)
66
- senderAddress: fastClient.address!,
67
- receiverAddress: '0xYourEvmAddress',
68
- fastClient,
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',
55
+ amount: '1000000',
56
+ intents: [
57
+ buildTransferIntent(USDC_ADDRESS, '0xRecipient'),
58
+ // Add more intents: swaps, protocol calls, etc.
59
+ ],
69
60
  });
70
-
71
- console.log(result.txHash);
72
- // { txHash: '0x...', orderId: '0x...', estimatedTime: '1-5 minutes' }
73
61
  ```
74
62
 
75
- Best practice: generate the Fast wallet once, store the private/public keys in your secret manager or environment, and pass those stored values into `createFastClient()`. Do not generate a fresh wallet on every app start unless that is explicitly what you want.
76
-
77
- ## Features
78
-
79
- - **Deposit** - Bridge USDC from EVM chains to fastUSDC on Fast
80
- - **Withdraw** - Bridge fastUSDC from Fast to USDC on EVM chains
81
- - **EVM Executor** - Built-in viem-based transaction executor
82
- - **Fast Client** - Built-in Fast network client for withdrawals
83
- - **Fast Wallet Generator** - Generate a Fast keypair and address without another SDK
63
+ For intents without a transfer recipient or execute target, pass `externalAddress` so the relayer has an explicit EVM target.
84
64
 
85
65
  ## Supported Networks
86
66
 
87
- Current SDK implementation in this branch:
88
-
89
- - Testnet-only bridge flows
90
- - Arbitrum Sepolia (`421614`) + Fast testnet
91
- - Token mapping for `USDC` <-> `fastUSDC`
92
-
93
- Environment target matrix for AllSet deployments:
94
-
95
- - Mainnet: Polygon, Arbitrum, Base with `USDC` -> `fastUSDC`
96
- - Testnet: Sepolia, Arbitrum Sepolia, Tempo with testnet `USDC` -> `testUSDC`
67
+ | Network | Chain | Status |
68
+ |---------|-------|--------|
69
+ | Testnet | Arbitrum Sepolia | ✅ |
70
+ | Testnet | Ethereum Sepolia | |
71
+ | Mainnet | Coming soon | 🔜 |
97
72
 
98
73
  ## Documentation
99
74
 
100
- See [SKILL.md](./SKILL.md) for detailed API documentation and troubleshooting.
101
-
102
- ## Development
103
-
104
- ```bash
105
- npm install
106
- npm run build
107
- npm test
108
- ```
75
+ See [SKILL.md](./SKILL.md) for detailed API documentation.
109
76
 
110
77
  ## License
111
78
 
@@ -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
@@ -7,6 +7,49 @@
7
7
  * Deposit (EVM → Fast): call bridge.deposit(token, amount, receiver) on the EVM bridge contract
8
8
  * Withdraw (Fast → EVM): transfer on Fast network + submit ExternalClaim intent + POST to relayer
9
9
  */
10
- import type { BridgeProvider } from './types.js';
11
- export declare const allsetProvider: BridgeProvider;
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
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAsC,MAAM,YAAY,CAAC;AAuFrF,eAAO,MAAM,cAAc,EAAE,cA4S5B,CAAC"}
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA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