@aptos-labs/cross-chain-core 5.8.2 → 5.9.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.
Files changed (48) hide show
  1. package/README.md +26 -0
  2. package/dist/CrossChainCore.d.ts +20 -0
  3. package/dist/CrossChainCore.d.ts.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +580 -275
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +583 -274
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/providers/wormhole/index.d.ts +2 -0
  11. package/dist/providers/wormhole/index.d.ts.map +1 -1
  12. package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts +1 -1
  13. package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts.map +1 -1
  14. package/dist/providers/wormhole/signers/Signer.d.ts +1 -1
  15. package/dist/providers/wormhole/signers/Signer.d.ts.map +1 -1
  16. package/dist/providers/wormhole/signers/SolanaLocalSigner.d.ts +65 -0
  17. package/dist/providers/wormhole/signers/SolanaLocalSigner.d.ts.map +1 -0
  18. package/dist/providers/wormhole/signers/SolanaSigner.d.ts +12 -20
  19. package/dist/providers/wormhole/signers/SolanaSigner.d.ts.map +1 -1
  20. package/dist/providers/wormhole/signers/solanaUtils.d.ts +68 -0
  21. package/dist/providers/wormhole/signers/solanaUtils.d.ts.map +1 -0
  22. package/dist/providers/wormhole/types.d.ts +43 -0
  23. package/dist/providers/wormhole/types.d.ts.map +1 -1
  24. package/dist/providers/wormhole/utils.d.ts +26 -0
  25. package/dist/providers/wormhole/utils.d.ts.map +1 -0
  26. package/dist/providers/wormhole/wormhole.d.ts +36 -6
  27. package/dist/providers/wormhole/wormhole.d.ts.map +1 -1
  28. package/dist/utils/receiptSerialization.d.ts +38 -0
  29. package/dist/utils/receiptSerialization.d.ts.map +1 -0
  30. package/dist/version.d.ts +1 -1
  31. package/package.json +2 -2
  32. package/src/CrossChainCore.ts +20 -0
  33. package/src/config/mainnet/chains.ts +2 -2
  34. package/src/config/testnet/chains.ts +2 -2
  35. package/src/index.ts +1 -0
  36. package/src/providers/wormhole/index.ts +2 -0
  37. package/src/providers/wormhole/signers/AptosLocalSigner.ts +4 -4
  38. package/src/providers/wormhole/signers/AptosSigner.ts +1 -1
  39. package/src/providers/wormhole/signers/EthereumSigner.ts +3 -3
  40. package/src/providers/wormhole/signers/Signer.ts +4 -4
  41. package/src/providers/wormhole/signers/SolanaLocalSigner.ts +243 -0
  42. package/src/providers/wormhole/signers/SolanaSigner.ts +45 -337
  43. package/src/providers/wormhole/signers/solanaUtils.ts +422 -0
  44. package/src/providers/wormhole/types.ts +68 -0
  45. package/src/providers/wormhole/utils.ts +72 -0
  46. package/src/providers/wormhole/wormhole.ts +182 -120
  47. package/src/utils/receiptSerialization.ts +141 -0
  48. package/src/version.ts +1 -1
@@ -0,0 +1,65 @@
1
+ import { Connection, Keypair, type Commitment } from "@solana/web3.js";
2
+ import { Chain, Network, SignAndSendSigner, TxHash, UnsignedTransaction } from "@wormhole-foundation/sdk";
3
+ import { PriorityFeeConfig } from "./solanaUtils";
4
+ export interface SolanaLocalSignerConfig {
5
+ /** The Solana keypair to sign transactions with */
6
+ keypair: Keypair;
7
+ /** The Solana RPC connection */
8
+ connection: Connection;
9
+ /** Transaction confirmation commitment level (default: "finalized") */
10
+ commitment?: Commitment;
11
+ /** Retry interval in ms when transaction is not confirmed (default: 5000) */
12
+ retryIntervalMs?: number;
13
+ /** Priority fee configuration for faster transaction landing */
14
+ priorityFeeConfig?: PriorityFeeConfig;
15
+ /** Enable verbose logging (default: false) */
16
+ verbose?: boolean;
17
+ }
18
+ /**
19
+ * Server-side Solana signer for programmatic transaction signing.
20
+ * Use this when you want to sign Solana transactions without user wallet interaction,
21
+ * such as for server-side claim operations.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { SolanaLocalSigner } from "@aptos-labs/cross-chain-core";
26
+ * import { Connection, Keypair } from "@solana/web3.js";
27
+ * import bs58 from "bs58";
28
+ *
29
+ * const keypair = Keypair.fromSecretKey(bs58.decode(process.env.SOLANA_CLAIM_SIGNER_KEY));
30
+ * const connection = new Connection("https://api.mainnet-beta.solana.com");
31
+ *
32
+ * const signer = new SolanaLocalSigner({
33
+ * keypair,
34
+ * connection,
35
+ * // Optional: configure priority fees for faster landing
36
+ * priorityFeeConfig: {
37
+ * percentile: 0.9,
38
+ * min: 100_000,
39
+ * max: 1_000_000,
40
+ * },
41
+ * });
42
+ * await cctpRoute.complete(signer, receipt);
43
+ * ```
44
+ */
45
+ export declare class SolanaLocalSigner<N extends Network, C extends Chain> implements SignAndSendSigner<N, C> {
46
+ private keypair;
47
+ private connection;
48
+ private commitment;
49
+ private retryIntervalMs;
50
+ private priorityFeeConfig?;
51
+ private verbose;
52
+ private _claimedTransactionHashes;
53
+ constructor(config: SolanaLocalSignerConfig);
54
+ chain(): C;
55
+ address(): string;
56
+ /**
57
+ * Returns all transaction hashes from the most recent signAndSend call,
58
+ * joined by comma. If only one transaction was signed, returns a single hash string.
59
+ */
60
+ claimedTransactionHashes(): string;
61
+ signAndSend(txs: UnsignedTransaction<N, C>[]): Promise<TxHash[]>;
62
+ private signAndSendTransaction;
63
+ }
64
+ export type { PriorityFeeConfig };
65
+ //# sourceMappingURL=SolanaLocalSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolanaLocalSigner.d.ts","sourceRoot":"","sources":["../../../../src/providers/wormhole/signers/SolanaLocalSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EAEP,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,MAAM,EACN,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,iBAAiB,EAElB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,uBAAuB;IACtC,mDAAmD;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,uEAAuE;IACvE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,KAAK,CAC/D,YAAW,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;IAElC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,yBAAyB,CAAgB;gBAErC,MAAM,EAAE,uBAAuB;IAS3C,KAAK,IAAI,CAAC;IAIV,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,wBAAwB,IAAI,MAAM;IAI5B,WAAW,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAYxD,sBAAsB;CAkIrC;AAGD,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,28 +1,20 @@
1
- import { ConfirmOptions, VersionedTransaction } from "@solana/web3.js";
2
- import { Transaction } from "@solana/web3.js";
3
- import { SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
1
+ /**
2
+ * Client-side Solana signer for wallet-based transaction signing.
3
+ * This function signs and sends the transaction while constantly checking for confirmation
4
+ * and resending the transaction if it hasn't been confirmed after the specified interval.
5
+ */
6
+ import { ConfirmOptions, Transaction, VersionedTransaction } from "@solana/web3.js";
4
7
  import { Connection } from "@solana/web3.js";
5
8
  import { Network } from "@wormhole-foundation/sdk";
9
+ import { SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
6
10
  import { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
7
11
  import { CrossChainCore } from "../../../CrossChainCore";
8
- export type SolanaRpcProvider = "triton" | "helius" | "ankr" | "unknown";
12
+ import { PriorityFeeConfig } from "./solanaUtils";
13
+ export type { SolanaRpcProvider, PriorityFeeConfig } from "./solanaUtils";
14
+ export { sleep, isEmptyObject, determineRpcProvider, } from "./solanaUtils";
9
15
  export declare function signAndSendTransaction(request: SolanaUnsignedTransaction<Network>, wallet: AdapterWallet | undefined, options?: ConfirmOptions, crossChainCore?: CrossChainCore): Promise<string>;
10
- export declare function setPriorityFeeInstructions(connection: Connection, blockhash: string, lastValidBlockHeight: number, request: SolanaUnsignedTransaction<Network>, crossChainCore?: CrossChainCore): Promise<Transaction | VersionedTransaction>;
11
- export declare function sleep(timeout: number): Promise<unknown>;
12
16
  /**
13
- * Checks whether an object is empty.
14
- *
15
- * isEmptyObject(null)
16
- * // => true
17
- *
18
- * isEmptyObject(undefined)
19
- * // => true
20
- *
21
- * isEmptyObject({})
22
- * // => true
23
- *
24
- * isEmptyObject({ 'a': 1 })
25
- * // => false
17
+ * Prepares a transaction with priority fee instructions.
26
18
  */
27
- export declare const isEmptyObject: (value: object | null | undefined) => boolean;
19
+ export declare function setPriorityFeeInstructions(connection: Connection, blockhash: string, lastValidBlockHeight: number, request: SolanaUnsignedTransaction<Network>, priorityFeeConfig?: PriorityFeeConfig): Promise<Transaction | VersionedTransaction>;
28
20
  //# sourceMappingURL=SolanaSigner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SolanaSigner.d.ts","sourceRoot":"","sources":["../../../../src/providers/wormhole/signers/SolanaSigner.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,cAAc,EAId,oBAAoB,EAC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AAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAGL,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EACL,KAAK,EACL,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,EAC3C,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,OAAO,CAAC,EAAE,cAAc,EACxB,cAAc,CAAC,EAAE,cAAc,mBAuDhC;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,EAC3C,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,WAAW,GAAG,oBAAoB,CAAC,CAe7C"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Shared utilities for Solana transaction handling.
3
+ * Used by both SolanaLocalSigner (server-side) and SolanaSigner (client-side).
4
+ */
5
+ import { Connection, Transaction, TransactionInstruction, VersionedTransaction, type Commitment } from "@solana/web3.js";
6
+ /** Configuration for priority fees */
7
+ export interface PriorityFeeConfig {
8
+ /** Percentile of recent fees to use (default: 0.9) */
9
+ percentile?: number;
10
+ /** Multiplier for the percentile fee (default: 1) */
11
+ percentileMultiple?: number;
12
+ /** Minimum fee in microlamports (default: 100_000) */
13
+ min?: number;
14
+ /** Maximum fee in microlamports (default: 100_000_000) */
15
+ max?: number;
16
+ }
17
+ /** Configuration for sending and confirming transactions */
18
+ export interface SendAndConfirmConfig {
19
+ connection: Connection;
20
+ commitment: Commitment;
21
+ retryIntervalMs?: number;
22
+ /** Enable verbose logging (default: false) */
23
+ verbose?: boolean;
24
+ }
25
+ /** RPC provider type for priority fee calculation */
26
+ export type SolanaRpcProvider = "triton" | "helius" | "ankr" | "unknown";
27
+ /**
28
+ * Sends a serialized transaction and waits for confirmation with automatic retries.
29
+ *
30
+ * @param serializedTx - The serialized transaction bytes
31
+ * @param blockhash - The recent blockhash used in the transaction
32
+ * @param lastValidBlockHeight - The last valid block height for the transaction
33
+ * @param config - Configuration for sending and confirming
34
+ * @returns The transaction signature
35
+ */
36
+ export declare function sendAndConfirmTransaction(serializedTx: Buffer | Uint8Array, blockhash: string, lastValidBlockHeight: number, config: SendAndConfirmConfig): Promise<string>;
37
+ /**
38
+ * Formats a transaction error into a readable string.
39
+ */
40
+ export declare function formatTransactionError(err: unknown): string;
41
+ /**
42
+ * Adds priority fee instructions to a transaction.
43
+ * Simulates the transaction to determine compute units and calculates optimal fees.
44
+ *
45
+ * @param connection - Solana RPC connection
46
+ * @param transaction - The transaction to add priority fees to
47
+ * @param priorityFeeConfig - Configuration for priority fees
48
+ * @param verbose - Enable verbose logging
49
+ * @returns The transaction with priority fee instructions added
50
+ */
51
+ export declare function addPriorityFeeInstructions(connection: Connection, transaction: Transaction, priorityFeeConfig?: PriorityFeeConfig, verbose?: boolean): Promise<Transaction>;
52
+ /**
53
+ * Creates priority fee instructions based on simulation and fee estimation.
54
+ */
55
+ export declare function createPriorityFeeInstructions(connection: Connection, transaction: Transaction | VersionedTransaction, priorityFeeConfig?: PriorityFeeConfig, verbose?: boolean): Promise<TransactionInstruction[]>;
56
+ /**
57
+ * Determines the RPC provider from the endpoint URL.
58
+ */
59
+ export declare function determineRpcProvider(endpoint: string): SolanaRpcProvider;
60
+ /**
61
+ * Sleep for a specified duration.
62
+ */
63
+ export declare function sleep(timeout: number): Promise<void>;
64
+ /**
65
+ * Checks whether an object is empty.
66
+ */
67
+ export declare const isEmptyObject: (value: object | null | undefined) => boolean;
68
+ //# sourceMappingURL=solanaUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../../../src/providers/wormhole/signers/solanaUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,UAAU,EAKV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAUzB,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAMzE;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,MAAM,GAAG,UAAU,EACjC,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAoDjB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAa3D;AAMD;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,GAAG,oBAAoB,EAC/C,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA8CnC;AAiJD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAgBxE;AAED;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,OAYhE,CAAC"}
@@ -19,11 +19,14 @@ export interface WormholeTransferRequest {
19
19
  amount?: string;
20
20
  sponsorAccount?: Account;
21
21
  }
22
+ export type WithdrawPhase = "initiating" | "tracking" | "claiming";
22
23
  export interface WormholeWithdrawRequest {
23
24
  sourceChain: Chain;
24
25
  wallet: AdapterWallet;
25
26
  destinationAddress: AccountAddressInput;
26
27
  sponsorAccount?: Account | GasStationApiKey;
28
+ /** Optional callback fired when the withdraw progresses to a new phase. */
29
+ onPhaseChange?: (phase: WithdrawPhase) => void;
27
30
  }
28
31
  export interface WormholeSubmitTransferRequest {
29
32
  sourceChain: Chain;
@@ -47,4 +50,44 @@ export interface WormholeStartTransferResponse {
47
50
  originChainTxnId: string;
48
51
  receipt: routes.Receipt<AttestationReceipt>;
49
52
  }
53
+ export interface WormholeInitiateWithdrawRequest {
54
+ wallet: AdapterWallet;
55
+ destinationAddress: AccountAddressInput;
56
+ sponsorAccount?: Account | GasStationApiKey;
57
+ }
58
+ export interface WormholeInitiateWithdrawResponse {
59
+ originChainTxnId: string;
60
+ receipt: routes.Receipt<AttestationReceipt>;
61
+ }
62
+ export interface WormholeClaimWithdrawRequest {
63
+ sourceChain: Chain;
64
+ destinationAddress: string;
65
+ receipt: routes.Receipt<AttestationReceipt>;
66
+ wallet?: AdapterWallet;
67
+ }
68
+ export interface WormholeClaimWithdrawResponse {
69
+ destinationChainTxnId: string;
70
+ }
71
+ /**
72
+ * Error thrown when the withdraw flow fails *after* the Aptos burn
73
+ * transaction has already been submitted (i.e. during attestation tracking
74
+ * or destination-chain claiming).
75
+ *
76
+ * Consumers should check `instanceof WithdrawError` in their catch block
77
+ * to recover the `originChainTxnId` and display an explorer link so the
78
+ * user can verify their burn on-chain.
79
+ */
80
+ export declare class WithdrawError extends Error {
81
+ /** Aptos burn transaction hash — always available when this error is thrown. */
82
+ readonly originChainTxnId: string;
83
+ /** The withdraw phase that failed ("tracking" or "claiming"). */
84
+ readonly phase: WithdrawPhase;
85
+ /**
86
+ * The underlying error that caused this failure.
87
+ * Mirrors ES2022 Error.cause — declared explicitly because the project's
88
+ * TypeScript lib target does not include ES2022 ErrorOptions.
89
+ */
90
+ readonly cause?: unknown;
91
+ constructor(message: string, originChainTxnId: string, phase: WithdrawPhase, cause?: unknown);
92
+ }
50
93
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/wormhole/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAC9C,SAAS,GAAG,SAAS,EACrB,MAAM,CAAC,OAAO,EACd,MAAM,CA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MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC7C;AAID,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,aAAa,CAAC;IACtB,kBAAkB,EAAE,mBAAmB,CAAC;IACxC,cAAc,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CAC7C;AAED,MAAM,WAAW,gCAAgC;IAC/C,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,KAAK,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAG5C,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,6BAA6B;IAC5C,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,gFAAgF;IAChF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;gBAGvB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,aAAa,EACpB,KAAK,CAAC,EAAE,OAAO;CAQlB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Utility functions for Wormhole CCTP route creation.
3
+ * These helpers can be used both by WormholeProvider and server-side claim endpoints.
4
+ */
5
+ import { routes, Wormhole } from "@wormhole-foundation/sdk";
6
+ import { Chain } from "../../CrossChainCore";
7
+ import { TokenConfig } from "../../config";
8
+ export interface CCTPRouteResult {
9
+ route: routes.ManualRoute<"Mainnet" | "Testnet">;
10
+ request: routes.RouteTransferRequest<"Mainnet" | "Testnet">;
11
+ }
12
+ /**
13
+ * Creates a CCTP route for transferring USDC between two chains.
14
+ *
15
+ * This is a standalone helper that can be used both by WormholeProvider
16
+ * (client-side) and server-side claim endpoints to avoid code duplication.
17
+ *
18
+ * @param wh - Initialized Wormhole context
19
+ * @param sourceChain - Source chain (e.g., "Aptos")
20
+ * @param destChain - Destination chain (e.g., "Solana")
21
+ * @param tokens - Token configuration mapping (mainnetTokens or testnetTokens)
22
+ * @returns The CCTP route and request for completing transfers
23
+ * @throws Error if no valid CCTP route is found
24
+ */
25
+ export declare function createCCTPRoute(wh: Wormhole<"Mainnet" | "Testnet">, sourceChain: Chain, destChain: Chain, tokens: Record<string, TokenConfig>): Promise<CCTPRouteResult>;
26
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/providers/wormhole/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,MAAM,EACN,QAAQ,EAET,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC,oBAAoB,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC,EACnC,WAAW,EAAE,KAAK,EAClB,SAAS,EAAE,KAAK,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAClC,OAAO,CAAC,eAAe,CAAC,CAiC1B"}
@@ -1,13 +1,14 @@
1
- import { TokenId, Wormhole } from "@wormhole-foundation/sdk";
1
+ import { routes, Wormhole } from "@wormhole-foundation/sdk";
2
2
  import { Chain, CrossChainProvider, CrossChainCore } from "../../CrossChainCore";
3
3
  import { ChainConfig } from "../../config";
4
- import { WormholeQuoteRequest, WormholeQuoteResponse, WormholeTransferRequest, WormholeTransferResponse, WormholeSubmitTransferRequest, WormholeStartTransferResponse, WormholeClaimTransferRequest, WormholeWithdrawRequest, WormholeWithdrawResponse } from "./types";
4
+ import { WormholeQuoteRequest, WormholeQuoteResponse, WormholeTransferRequest, WormholeTransferResponse, WormholeSubmitTransferRequest, WormholeStartTransferResponse, WormholeClaimTransferRequest, WormholeWithdrawRequest, WormholeWithdrawResponse, WormholeInitiateWithdrawRequest, WormholeInitiateWithdrawResponse, WormholeClaimWithdrawRequest, WormholeClaimWithdrawResponse } from "./types";
5
5
  export declare class WormholeProvider implements CrossChainProvider<WormholeQuoteRequest, WormholeQuoteResponse, WormholeTransferRequest, WormholeTransferResponse, WormholeWithdrawRequest, WormholeWithdrawResponse> {
6
6
  private crossChainCore;
7
7
  private _wormholeContext;
8
8
  private wormholeRoute;
9
9
  private wormholeRequest;
10
10
  private wormholeQuote;
11
+ private destinationChain?;
11
12
  constructor(core: CrossChainCore);
12
13
  get wormholeContext(): Wormhole<"Mainnet" | "Testnet"> | undefined;
13
14
  private setWormholeContext;
@@ -23,11 +24,40 @@ export declare class WormholeProvider implements CrossChainProvider<WormholeQuot
23
24
  * @returns
24
25
  */
25
26
  transfer(input: WormholeTransferRequest): Promise<WormholeTransferResponse>;
27
+ /**
28
+ * Phase 1: Initiates a withdraw by burning USDC on Aptos.
29
+ * The user signs the Aptos burn transaction via their wallet.
30
+ * Returns a receipt that can be tracked and later claimed.
31
+ */
32
+ initiateWithdraw(input: WormholeInitiateWithdrawRequest): Promise<WormholeInitiateWithdrawResponse>;
33
+ /**
34
+ * Phase 2: Tracks a withdraw receipt until attestation is ready.
35
+ * This polls Wormhole and returns once the receipt reaches the Attested state.
36
+ */
37
+ trackWithdraw(receipt: routes.Receipt): Promise<routes.Receipt>;
38
+ /**
39
+ * Phase 3: Claims the withdraw on the destination chain.
40
+ *
41
+ * If the destination is Solana and `solanaConfig.serverClaimUrl` is configured
42
+ * in the dapp config, the SDK automatically POSTs the attested receipt to that
43
+ * URL — no wallet popup required. The dapp's server endpoint handles signing
44
+ * and submitting the claim transaction.
45
+ *
46
+ * Otherwise falls back to the wallet-based Signer (triggers wallet popup).
47
+ */
48
+ claimWithdraw(input: WormholeClaimWithdrawRequest): Promise<WormholeClaimWithdrawResponse>;
49
+ /**
50
+ * Withdraws USDC from Aptos to a destination chain.
51
+ * Orchestrates all three phases internally:
52
+ * 1. Initiate — user signs the Aptos burn transaction
53
+ * 2. Track — wait for Wormhole attestation
54
+ * 3. Claim — if serverClaimUrl is configured for Solana, delegates to
55
+ * the server; otherwise uses the wallet-based signer.
56
+ *
57
+ * The optional `onPhaseChange` callback lets the dapp update its UI
58
+ * as the flow progresses.
59
+ */
26
60
  withdraw(input: WormholeWithdrawRequest): Promise<WormholeWithdrawResponse>;
27
61
  getChainConfig(chain: Chain): ChainConfig;
28
- getTokenInfo(sourceChain: Chain, destinationChain: Chain): {
29
- sourceToken: TokenId;
30
- destToken: TokenId;
31
- };
32
62
  }
33
63
  //# sourceMappingURL=wormhole.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wormhole.d.ts","sourceRoot":"","sources":["../../../src/providers/wormhole/wormhole.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,EACP,QAAQ,EAIT,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,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AC;IA0BpC;;;;OAIG;IACG,gBAAgB,CACpB,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,gCAAgC,CAAC;IA0C5C;;;OAGG;IACG,aAAa,CACjB,OAAO,EAAE,MAAM,CAAC,OAAO,GACtB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;IA8B1B;;;;;;;;;OASG;IACG,aAAa,CACjB,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,6BAA6B,CAAC;IAgEzC;;;;;;;;;;OAUG;IACG,QAAQ,CACZ,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IAwCpC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW;CAU1C"}
@@ -0,0 +1,38 @@
1
+ import { routes, AttestationReceipt } from "@wormhole-foundation/sdk";
2
+ /**
3
+ * Serializes a Wormhole receipt for JSON transport.
4
+ *
5
+ * JSON doesn't natively support BigInt, Uint8Array, or class instances.
6
+ * This function converts these types to a serializable format with type markers
7
+ * that can be reconstructed by `deserializeReceipt`.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { serializeReceipt } from "@aptos-labs/cross-chain-core";
12
+ *
13
+ * // On the client side, before sending to server
14
+ * const serialized = serializeReceipt(receipt);
15
+ * await fetch("/api/claim", {
16
+ * method: "POST",
17
+ * body: JSON.stringify({ receipt: serialized }),
18
+ * });
19
+ * ```
20
+ */
21
+ export declare function serializeReceipt(receipt: routes.Receipt<AttestationReceipt>): unknown;
22
+ /**
23
+ * Deserializes a Wormhole receipt from JSON transport format.
24
+ *
25
+ * Reconstructs BigInt, Uint8Array, and UniversalAddress instances from
26
+ * the serialized format produced by `serializeReceipt`.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { deserializeReceipt, SolanaLocalSigner } from "@aptos-labs/cross-chain-core";
31
+ *
32
+ * // On the server side, after receiving from client
33
+ * const receipt = deserializeReceipt(body.receipt);
34
+ * await cctpRoute.complete(signer, receipt);
35
+ * ```
36
+ */
37
+ export declare function deserializeReceipt(obj: unknown): routes.Receipt<AttestationReceipt>;
38
+ //# sourceMappingURL=receiptSerialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receiptSerialization.d.ts","sourceRoot":"","sources":["../../src/utils/receiptSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAoBlC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAC1C,OAAO,CAuBT;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,GACX,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAoDpC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const CROSS_CHAIN_CORE_VERSION = "5.8.2";
1
+ export declare const CROSS_CHAIN_CORE_VERSION = "5.9.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/cross-chain-core",
3
- "version": "5.8.2",
3
+ "version": "5.9.0",
4
4
  "description": "Aptos Cross Chain Core",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -59,7 +59,7 @@
59
59
  "@aptos-labs/derived-wallet-ethereum": "0.9.0",
60
60
  "@aptos-labs/derived-wallet-solana": "0.12.0",
61
61
  "@aptos-labs/derived-wallet-sui": "0.2.0",
62
- "@aptos-labs/wallet-adapter-core": "8.3.0"
62
+ "@aptos-labs/wallet-adapter-core": "8.4.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@aptos-labs/ts-sdk": "^5.1.1"
@@ -37,6 +37,26 @@ export interface CrossChainDappConfig {
37
37
  min?: number;
38
38
  max?: number;
39
39
  };
40
+ /**
41
+ * URL of a server-side API endpoint that claims withdraw transactions on Solana.
42
+ * When set, the SDK will POST the attested receipt to this URL instead of
43
+ * asking the user's wallet to sign the claim transaction.
44
+ *
45
+ * Expected request body: { serializedReceipt: string, destinationAddress: string, sourceChain: string }
46
+ * Expected response: { destinationChainTxnId: string }
47
+ * Check out the SERVERSIDE_SOLANA_SIGNER.md file for more details.
48
+ *
49
+ * @example
50
+ * const crossChainCore = new CrossChainCore({
51
+ * dappConfig: {
52
+ * aptosNetwork: Network.TESTNET,
53
+ * solanaConfig: {
54
+ * serverClaimUrl: "/api/claim-withdraw",
55
+ * },
56
+ * },
57
+ * });
58
+ */
59
+ serverClaimUrl?: string;
40
60
  };
41
61
  }
42
62
  export type { AccountAddressInput } from "@aptos-labs/ts-sdk";
@@ -16,8 +16,8 @@ export const mainnetChains: ChainsConfig = {
16
16
  key: "Solana",
17
17
  context: Context.SOLANA,
18
18
  displayName: "Solana",
19
- explorerUrl: "https://explorer.solana.com/",
20
- explorerName: "Solana Explorer",
19
+ explorerUrl: "https://solscan.io",
20
+ explorerName: "Solscan",
21
21
  chainId: 0,
22
22
  icon: "Solana",
23
23
  symbol: "SOL",
@@ -61,8 +61,8 @@ export const testnetChains: ChainsConfig = {
61
61
  key: "Solana",
62
62
  context: Context.SOLANA,
63
63
  displayName: "Solana",
64
- explorerUrl: "https://explorer.solana.com/",
65
- explorerName: "Solana Explorer",
64
+ explorerUrl: "https://solscan.io",
65
+ explorerName: "Solscan",
66
66
  chainId: 0,
67
67
  icon: "Solana",
68
68
  symbol: "SOL",
package/src/index.ts CHANGED
@@ -2,4 +2,5 @@ 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";
@@ -1,4 +1,6 @@
1
1
  export * from "./wormhole";
2
2
  export * from "./types";
3
+ export * from "./utils";
3
4
  export * from "./signers/AptosLocalSigner";
5
+ export * from "./signers/SolanaLocalSigner";
4
6
  export * from "../../config";
@@ -29,7 +29,7 @@ export class AptosLocalSigner<
29
29
  _options: any;
30
30
  _wallet: Account;
31
31
  _sponsorAccount: Account | GasStationApiKey | undefined;
32
- _claimedTransactionHashes: string;
32
+ _claimedTransactionHashes: string[] = [];
33
33
  _dappNetwork: AptosNetwork;
34
34
  constructor(
35
35
  chain: C,
@@ -42,7 +42,6 @@ export class AptosLocalSigner<
42
42
  this._options = options;
43
43
  this._wallet = wallet;
44
44
  this._sponsorAccount = feePayerAccount;
45
- this._claimedTransactionHashes = "";
46
45
  this._dappNetwork = dappNetwork;
47
46
  }
48
47
 
@@ -54,11 +53,12 @@ export class AptosLocalSigner<
54
53
  }
55
54
 
56
55
  claimedTransactionHashes(): string {
57
- return this._claimedTransactionHashes;
56
+ return this._claimedTransactionHashes.join(",");
58
57
  }
59
58
 
60
59
  async signAndSend(txs: UnsignedTransaction<N, C>[]): Promise<TxHash[]> {
61
60
  const txHashes: TxHash[] = [];
61
+ this._claimedTransactionHashes = [];
62
62
 
63
63
  for (const tx of txs) {
64
64
  const txId = await signAndSendTransaction(
@@ -68,7 +68,7 @@ export class AptosLocalSigner<
68
68
  this._dappNetwork,
69
69
  );
70
70
  txHashes.push(txId);
71
- this._claimedTransactionHashes = txId;
71
+ this._claimedTransactionHashes.push(txId);
72
72
  }
73
73
  return txHashes;
74
74
  }
@@ -27,7 +27,7 @@ export async function signAndSendTransaction(
27
27
  dappNetwork: AptosNetwork,
28
28
  ) {
29
29
  if (!wallet) {
30
- throw new Error("wallet.sendTransaction is undefined").message;
30
+ throw new Error("wallet.sendTransaction is undefined");
31
31
  }
32
32
 
33
33
  const payload = request.transaction;
@@ -13,7 +13,7 @@ export async function signAndSendTransaction(
13
13
  options: any,
14
14
  ): Promise<string> {
15
15
  if (!wallet) {
16
- throw new Error("wallet.sendTransaction is undefined").message;
16
+ throw new Error("wallet.sendTransaction is undefined");
17
17
  }
18
18
  // Ensure the signer is connected to the correct chain
19
19
  const chainId = await (
@@ -24,7 +24,7 @@ export async function signAndSendTransaction(
24
24
  const actualChainId = parseInt(chainId, 16);
25
25
 
26
26
  if (!actualChainId)
27
- throw new Error("No signer found for chain" + chainName).message;
27
+ throw new Error("No signer found for chain" + chainName);
28
28
  const expectedChainId = request.transaction.chainId
29
29
  ? getBigInt(request.transaction.chainId)
30
30
  : undefined;
@@ -35,7 +35,7 @@ export async function signAndSendTransaction(
35
35
  ) {
36
36
  throw new Error(
37
37
  `Signer is not connected to the right chain. Expected ${expectedChainId}, got ${actualChainId}`,
38
- ).message;
38
+ );
39
39
  }
40
40
 
41
41
  const provider = new ethers.BrowserProvider(
@@ -37,7 +37,7 @@ export class Signer<
37
37
  _wallet: AdapterWallet;
38
38
  _crossChainCore: CrossChainCore;
39
39
  _sponsorAccount: Account | GasStationApiKey | undefined;
40
- _claimedTransactionHashes: string;
40
+ _claimedTransactionHashes: string[] = [];
41
41
 
42
42
  constructor(
43
43
  chain: ChainConfig,
@@ -53,7 +53,6 @@ export class Signer<
53
53
  this._wallet = wallet;
54
54
  this._crossChainCore = crossChainCore;
55
55
  this._sponsorAccount = sponsorAccount;
56
- this._claimedTransactionHashes = "";
57
56
  }
58
57
 
59
58
  chain(): C {
@@ -64,11 +63,12 @@ export class Signer<
64
63
  }
65
64
 
66
65
  claimedTransactionHashes(): string {
67
- return this._claimedTransactionHashes;
66
+ return this._claimedTransactionHashes.join(",");
68
67
  }
69
68
 
70
69
  async signAndSend(txs: UnsignedTransaction<N, C>[]): Promise<TxHash[]> {
71
70
  const txHashes: TxHash[] = [];
71
+ this._claimedTransactionHashes = [];
72
72
 
73
73
  for (const tx of txs) {
74
74
  const txId = await signAndSendTransaction(
@@ -80,7 +80,7 @@ export class Signer<
80
80
  this._sponsorAccount,
81
81
  );
82
82
  txHashes.push(txId);
83
- this._claimedTransactionHashes = txId;
83
+ this._claimedTransactionHashes.push(txId);
84
84
  }
85
85
  return txHashes;
86
86
  }