@aptos-labs/cross-chain-core 5.8.2 → 6.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 +26 -0
- package/dist/CrossChainCore.d.ts +95 -0
- package/dist/CrossChainCore.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +908 -404
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +914 -409
- package/dist/index.mjs.map +1 -1
- package/dist/providers/wormhole/index.d.ts +2 -0
- package/dist/providers/wormhole/index.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts +9 -7
- package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/AptosSigner.d.ts +2 -1
- package/dist/providers/wormhole/signers/AptosSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/EthereumSigner.d.ts +1 -1
- package/dist/providers/wormhole/signers/EthereumSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/Signer.d.ts +11 -3
- package/dist/providers/wormhole/signers/Signer.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/SolanaLocalSigner.d.ts +69 -0
- package/dist/providers/wormhole/signers/SolanaLocalSigner.d.ts.map +1 -0
- package/dist/providers/wormhole/signers/SolanaSigner.d.ts +12 -20
- package/dist/providers/wormhole/signers/SolanaSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/solanaUtils.d.ts +68 -0
- package/dist/providers/wormhole/signers/solanaUtils.d.ts.map +1 -0
- package/dist/providers/wormhole/types.d.ts +120 -0
- package/dist/providers/wormhole/types.d.ts.map +1 -1
- package/dist/providers/wormhole/utils.d.ts +26 -0
- package/dist/providers/wormhole/utils.d.ts.map +1 -0
- package/dist/providers/wormhole/wormhole.d.ts +62 -6
- package/dist/providers/wormhole/wormhole.d.ts.map +1 -1
- package/dist/utils/receiptSerialization.d.ts +38 -0
- package/dist/utils/receiptSerialization.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/CrossChainCore.ts +110 -3
- package/src/config/mainnet/chains.ts +2 -2
- package/src/config/testnet/chains.ts +2 -2
- package/src/index.ts +1 -0
- package/src/providers/wormhole/index.ts +2 -0
- package/src/providers/wormhole/signers/AptosLocalSigner.ts +31 -18
- package/src/providers/wormhole/signers/AptosSigner.ts +11 -2
- package/src/providers/wormhole/signers/EthereumSigner.ts +59 -8
- package/src/providers/wormhole/signers/Signer.ts +23 -6
- package/src/providers/wormhole/signers/SolanaLocalSigner.ts +250 -0
- package/src/providers/wormhole/signers/SolanaSigner.ts +49 -338
- package/src/providers/wormhole/signers/solanaUtils.ts +446 -0
- package/src/providers/wormhole/types.ts +167 -0
- package/src/providers/wormhole/utils.ts +72 -0
- package/src/providers/wormhole/wormhole.ts +309 -137
- package/src/utils/receiptSerialization.ts +141 -0
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -296,6 +296,32 @@ console.log(`Destination TX: ${destinationChainTxnId}`);
|
|
|
296
296
|
- `originChainTxnId`: Transaction hash on Aptos
|
|
297
297
|
- `destinationChainTxnId`: Transaction hash on the destination chain
|
|
298
298
|
|
|
299
|
+
### Server-Side Solana Claim (Optional)
|
|
300
|
+
|
|
301
|
+
When withdrawing USDC from Aptos to Solana, the claim transaction on Solana requires a signature. By default, the user's wallet signs this transaction. However, for a smoother user experience, you can configure a **server-side claim** where your backend signs the Solana claim transaction instead.
|
|
302
|
+
|
|
303
|
+
**Benefits:**
|
|
304
|
+
- Users only sign once (the Aptos burn transaction)
|
|
305
|
+
- No second wallet popup after the ~60 second attestation wait
|
|
306
|
+
- Seamless one-click withdrawal flow
|
|
307
|
+
|
|
308
|
+
To enable server-side claiming, configure `serverClaimUrl` in your `solanaConfig`:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
const crossChainCore = new CrossChainCore({
|
|
312
|
+
dappConfig: {
|
|
313
|
+
aptosNetwork: Network.MAINNET,
|
|
314
|
+
solanaConfig: {
|
|
315
|
+
serverClaimUrl: "/api/claim-withdraw", // Your API endpoint
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
When configured, the SDK will automatically POST the attestation receipt to your server endpoint after the Aptos burn transaction is confirmed and attested. Your server then signs and submits the Solana claim transaction using a funded keypair.
|
|
322
|
+
|
|
323
|
+
📖 **See [SERVERSIDE_SOLANA_SIGNER.md](./SERVERSIDE_SOLANA_SIGNER.md) for complete implementation guide.**
|
|
324
|
+
|
|
299
325
|
## Chain ID Mappings
|
|
300
326
|
|
|
301
327
|
The SDK provides mappings from Ethereum chain IDs to chain configurations:
|
package/dist/CrossChainCore.d.ts
CHANGED
|
@@ -3,6 +3,17 @@ import { ChainsConfig, TokenConfig, ChainConfig } from "./config";
|
|
|
3
3
|
export interface CrossChainDappConfig {
|
|
4
4
|
aptosNetwork: Network;
|
|
5
5
|
disableTelemetry?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Returns an epoch-second timestamp used as `expireTimestamp` when building
|
|
8
|
+
* Aptos transactions. Called at transaction-build time so that each
|
|
9
|
+
* transaction in a multi-step bridge flow gets a fresh expiration window.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* getExpireTimestamp: () => Math.floor(Date.now() / 1000) + 120 // 2 minutes
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
getExpireTimestamp?: () => number;
|
|
6
17
|
solanaConfig?: {
|
|
7
18
|
rpc?: string;
|
|
8
19
|
priorityFeeConfig?: {
|
|
@@ -11,12 +22,89 @@ export interface CrossChainDappConfig {
|
|
|
11
22
|
min?: number;
|
|
12
23
|
max?: number;
|
|
13
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* URL of a server-side API endpoint that claims withdraw transactions on Solana.
|
|
27
|
+
* When set, the SDK will POST the attested receipt to this URL instead of
|
|
28
|
+
* asking the user's wallet to sign the claim transaction.
|
|
29
|
+
*
|
|
30
|
+
* Expected request body: { serializedReceipt: string, destinationAddress: string, sourceChain: string }
|
|
31
|
+
* Expected response: { destinationChainTxnId: string }
|
|
32
|
+
* Check out the SERVERSIDE_SOLANA_SIGNER.md file for more details.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const crossChainCore = new CrossChainCore({
|
|
36
|
+
* dappConfig: {
|
|
37
|
+
* aptosNetwork: Network.TESTNET,
|
|
38
|
+
* solanaConfig: {
|
|
39
|
+
* serverClaimUrl: "/api/claim-withdraw",
|
|
40
|
+
* },
|
|
41
|
+
* },
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
44
|
+
serverClaimUrl?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Solana transaction confirmation commitment level.
|
|
47
|
+
*
|
|
48
|
+
* - `"finalized"` (default) — waits for supermajority finalization (~30 s).
|
|
49
|
+
* - `"confirmed"` — waits for supermajority confirmation (~0.5 s).
|
|
50
|
+
*
|
|
51
|
+
* For bridge flows `"confirmed"` is usually sufficient because Wormhole
|
|
52
|
+
* guardians independently verify finality before issuing attestations.
|
|
53
|
+
*
|
|
54
|
+
* @default "finalized"
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const crossChainCore = new CrossChainCore({
|
|
58
|
+
* dappConfig: {
|
|
59
|
+
* aptosNetwork: Network.MAINNET,
|
|
60
|
+
* solanaConfig: {
|
|
61
|
+
* commitment: "confirmed", // ~0.5 s vs ~30 s
|
|
62
|
+
* },
|
|
63
|
+
* },
|
|
64
|
+
* });
|
|
65
|
+
*/
|
|
66
|
+
commitment?: "confirmed" | "finalized";
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Custom RPC endpoints for EVM chains. When provided, these override the
|
|
70
|
+
* built-in `defaultRpc` values for balance lookups and Wormhole SDK
|
|
71
|
+
* initialization.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* evmConfig: {
|
|
76
|
+
* Ethereum: { rpc: "https://rpc.ankr.com/eth/MY_KEY" },
|
|
77
|
+
* Base: { rpc: "https://rpc.ankr.com/base/MY_KEY" },
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
evmConfig?: Partial<Record<EvmChainName, {
|
|
82
|
+
rpc: string;
|
|
83
|
+
}>>;
|
|
84
|
+
/**
|
|
85
|
+
* Custom RPC endpoint for the Sui chain. When provided, overrides the
|
|
86
|
+
* built-in `defaultRpc` for balance lookups and Wormhole SDK initialization.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* suiConfig: { rpc: "https://fullnode.mainnet.sui.io" }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
suiConfig?: {
|
|
94
|
+
rpc?: string;
|
|
14
95
|
};
|
|
15
96
|
}
|
|
16
97
|
export type { AccountAddressInput } from "@aptos-labs/ts-sdk";
|
|
17
98
|
export { NetworkToChainId, NetworkToNodeAPI } from "@aptos-labs/ts-sdk";
|
|
18
99
|
export type AptosAccount = Account;
|
|
19
100
|
export type Chain = "Solana" | "Ethereum" | "Sepolia" | "Aptos" | "BaseSepolia" | "ArbitrumSepolia" | "Avalanche" | "Base" | "Arbitrum" | "PolygonSepolia" | "Polygon" | "Sui";
|
|
101
|
+
/**
|
|
102
|
+
* EVM chain names supported by the SDK — derived from {@link Chain} by
|
|
103
|
+
* excluding the non-EVM ecosystems. Adding a new EVM chain to `Chain`
|
|
104
|
+
* automatically makes it a valid key in `evmConfig`.
|
|
105
|
+
*/
|
|
106
|
+
export type EvmChainName = Exclude<Chain, "Solana" | "Aptos" | "Sui">;
|
|
107
|
+
export declare const EVM_CHAIN_NAMES: EvmChainName[];
|
|
20
108
|
export declare const EthereumChainIdToTestnetChain: Record<string, ChainConfig>;
|
|
21
109
|
export declare const EthereumChainIdToMainnetChain: Record<string, ChainConfig>;
|
|
22
110
|
export type CCTPProviders = "Wormhole";
|
|
@@ -29,6 +117,13 @@ export declare class CrossChainCore {
|
|
|
29
117
|
readonly _dappConfig: CrossChainDappConfig;
|
|
30
118
|
readonly CHAINS: ChainsConfig;
|
|
31
119
|
readonly TOKENS: Record<string, TokenConfig>;
|
|
120
|
+
/**
|
|
121
|
+
* Last known source-chain transaction ID, set by signers immediately after
|
|
122
|
+
* a transaction is submitted. Acts as a recovery side-channel so that
|
|
123
|
+
* callers can retrieve the tx hash even when the orchestration layer throws
|
|
124
|
+
* before returning it (e.g. claim failure after a successful burn).
|
|
125
|
+
*/
|
|
126
|
+
_lastSourceChainTxId: string | undefined;
|
|
32
127
|
constructor(args: {
|
|
33
128
|
dappConfig: CrossChainDappConfig;
|
|
34
129
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrossChainCore.d.ts","sourceRoot":"","sources":["../src/CrossChainCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAYtD,OAAO,EACL,YAAY,EAKZ,WAAW,EACX,WAAW,EACZ,MAAM,UAAU,CAAC;AAQlB,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,iBAAiB,CAAC,EAAE;YAClB,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;YAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;
|
|
1
|
+
{"version":3,"file":"CrossChainCore.d.ts","sourceRoot":"","sources":["../src/CrossChainCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAYtD,OA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-2,5 +2,6 @@ export * from "./CrossChainCore";
|
|
|
2
2
|
export * from "./config";
|
|
3
3
|
export * from "./providers/wormhole/index";
|
|
4
4
|
export * from "./providers/wormhole/types";
|
|
5
|
+
export * from "./utils/receiptSerialization";
|
|
5
6
|
export { Network } from "@aptos-labs/ts-sdk";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|