@aptos-labs/cross-chain-core 4.25.0 → 5.0.1

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 (40) hide show
  1. package/README.md +11 -0
  2. package/dist/CrossChainCore.d.ts +3 -3
  3. package/dist/CrossChainCore.d.ts.map +1 -1
  4. package/dist/config/mainnet/chains.d.ts +0 -14
  5. package/dist/config/mainnet/chains.d.ts.map +1 -1
  6. package/dist/config/mainnet/tokens.d.ts +0 -1
  7. package/dist/config/mainnet/tokens.d.ts.map +1 -1
  8. package/dist/config/testnet/chains.d.ts +0 -16
  9. package/dist/config/testnet/chains.d.ts.map +1 -1
  10. package/dist/config/testnet/tokens.d.ts +0 -1
  11. package/dist/config/testnet/tokens.d.ts.map +1 -1
  12. package/dist/index.js +272 -92
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +263 -73
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts.map +1 -1
  17. package/dist/providers/wormhole/signers/AptosSigner.d.ts +7 -0
  18. package/dist/providers/wormhole/signers/AptosSigner.d.ts.map +1 -0
  19. package/dist/providers/wormhole/signers/Signer.d.ts +7 -2
  20. package/dist/providers/wormhole/signers/Signer.d.ts.map +1 -1
  21. package/dist/providers/wormhole/types.d.ts +14 -3
  22. package/dist/providers/wormhole/types.d.ts.map +1 -1
  23. package/dist/providers/wormhole/wormhole.d.ts +7 -9
  24. package/dist/providers/wormhole/wormhole.d.ts.map +1 -1
  25. package/dist/utils/getUsdcBalance.d.ts.map +1 -1
  26. package/dist/version.d.ts +1 -1
  27. package/dist/version.d.ts.map +1 -1
  28. package/package.json +9 -9
  29. package/src/CrossChainCore.ts +18 -19
  30. package/src/config/mainnet/chains.ts +15 -15
  31. package/src/config/mainnet/tokens.ts +10 -11
  32. package/src/config/testnet/chains.ts +15 -16
  33. package/src/config/testnet/tokens.ts +10 -11
  34. package/src/providers/wormhole/signers/AptosLocalSigner.ts +4 -3
  35. package/src/providers/wormhole/signers/AptosSigner.ts +139 -0
  36. package/src/providers/wormhole/signers/Signer.ts +26 -2
  37. package/src/providers/wormhole/types.ts +16 -3
  38. package/src/providers/wormhole/wormhole.ts +165 -29
  39. package/src/utils/getUsdcBalance.ts +9 -11
  40. package/src/version.ts +1 -1
@@ -1,11 +1,13 @@
1
1
  import { Account, Network } from "@aptos-labs/ts-sdk";
2
2
 
3
3
  import {
4
- WormholeInitiateTransferRequest,
5
- WormholeInitiateTransferResponse,
4
+ WormholeTransferRequest,
5
+ WormholeTransferResponse,
6
6
  WormholeProvider,
7
7
  WormholeQuoteRequest,
8
8
  WormholeQuoteResponse,
9
+ WormholeWithdrawRequest,
10
+ WormholeWithdrawResponse,
9
11
  } from "./providers/wormhole";
10
12
 
11
13
  import {
@@ -15,8 +17,6 @@ import {
15
17
  mainnetChains,
16
18
  mainnetTokens,
17
19
  TokenConfig,
18
- AptosTestnetUSDCToken,
19
- AptosMainnetUSDCToken,
20
20
  } from "./config";
21
21
  import {
22
22
  getAptosWalletUSDCBalance,
@@ -48,13 +48,14 @@ export type CCTPProviders = "Wormhole";
48
48
  export interface CrossChainProvider<
49
49
  TQuoteRequest = any,
50
50
  TQuoteResponse = any,
51
- TInitiateTransferRequest = any,
52
- TInitiateTransferResponse = any,
51
+ TTransferRequest = any,
52
+ TTransferResponse = any,
53
+ TWithdrawRequest = any,
54
+ TWithdrawResponse = any,
53
55
  > {
54
56
  getQuote(params: TQuoteRequest): Promise<TQuoteResponse>;
55
- initiateCCTPTransfer(
56
- params: TInitiateTransferRequest,
57
- ): Promise<TInitiateTransferResponse>;
57
+ transfer(params: TTransferRequest): Promise<TTransferResponse>;
58
+ withdraw(params: TWithdrawRequest): Promise<TWithdrawResponse>;
58
59
  }
59
60
 
60
61
  export class CrossChainCore {
@@ -65,18 +66,14 @@ export class CrossChainCore {
65
66
  readonly CHAINS: ChainsConfig = testnetChains;
66
67
  readonly TOKENS: Record<string, TokenConfig> = testnetTokens;
67
68
 
68
- readonly APTOS_TOKEN: TokenConfig = AptosTestnetUSDCToken;
69
-
70
69
  constructor(args: { dappConfig: CrossChainDappConfig }) {
71
70
  this._dappConfig = args.dappConfig;
72
71
  if (args.dappConfig?.aptosNetwork === Network.MAINNET) {
73
72
  this.CHAINS = mainnetChains;
74
73
  this.TOKENS = mainnetTokens;
75
- this.APTOS_TOKEN = AptosMainnetUSDCToken;
76
74
  } else {
77
75
  this.CHAINS = testnetChains;
78
76
  this.TOKENS = testnetTokens;
79
- this.APTOS_TOKEN = AptosTestnetUSDCToken;
80
77
  }
81
78
  }
82
79
 
@@ -86,8 +83,10 @@ export class CrossChainCore {
86
83
  return new WormholeProvider(this) as CrossChainProvider<
87
84
  WormholeQuoteRequest,
88
85
  WormholeQuoteResponse,
89
- WormholeInitiateTransferRequest,
90
- WormholeInitiateTransferResponse
86
+ WormholeTransferRequest,
87
+ WormholeTransferResponse,
88
+ WormholeWithdrawRequest,
89
+ WormholeWithdrawResponse
91
90
  >;
92
91
  default:
93
92
  throw new Error(`Unknown provider: ${providerType}`);
@@ -96,12 +95,12 @@ export class CrossChainCore {
96
95
 
97
96
  async getWalletUSDCBalance(
98
97
  walletAddress: string,
99
- sourceChain: Chain,
98
+ sourceChain: Chain
100
99
  ): Promise<string> {
101
100
  if (sourceChain === "Aptos") {
102
101
  return await getAptosWalletUSDCBalance(
103
102
  walletAddress,
104
- this._dappConfig.aptosNetwork,
103
+ this._dappConfig.aptosNetwork
105
104
  );
106
105
  }
107
106
  if (!this.CHAINS[sourceChain]) {
@@ -113,7 +112,7 @@ export class CrossChainCore {
113
112
  walletAddress,
114
113
  this._dappConfig.aptosNetwork,
115
114
  this._dappConfig?.solanaConfig?.rpc ??
116
- this.CHAINS[sourceChain].defaultRpc,
115
+ this.CHAINS[sourceChain].defaultRpc
117
116
  );
118
117
  case "Ethereum":
119
118
  case "Sepolia":
@@ -121,7 +120,7 @@ export class CrossChainCore {
121
120
  walletAddress,
122
121
  this._dappConfig.aptosNetwork,
123
122
  // TODO: maybe let the user config it
124
- this.CHAINS[sourceChain].defaultRpc,
123
+ this.CHAINS[sourceChain].defaultRpc
125
124
  );
126
125
  default:
127
126
  throw new Error(`Unsupported chain: ${sourceChain}`);
@@ -31,6 +31,21 @@ export const mainnetChains: ChainsConfig = {
31
31
  symbol: "SOL",
32
32
  defaultRpc: "https://solana-mainnet.rpc.extrnode.com",
33
33
  },
34
+ Aptos: {
35
+ key: "Aptos",
36
+ id: 22,
37
+ context: Context.APTOS,
38
+ finalityThreshold: 0,
39
+ displayName: "Aptos",
40
+ explorerUrl: "https://explorer.aptoslabs.com/",
41
+ explorerName: "Aptos Explorer",
42
+ gasToken: "APT",
43
+ chainId: 0,
44
+ icon: "Aptos",
45
+ maxBlockSearch: 0,
46
+ symbol: "APT",
47
+ defaultRpc: "https://fullnode.mainnet.aptos.dev",
48
+ },
34
49
  // Sui: {
35
50
  // key: "Sui",
36
51
  // id: 21,
@@ -47,18 +62,3 @@ export const mainnetChains: ChainsConfig = {
47
62
  // symbol: "SUI",
48
63
  // },
49
64
  };
50
-
51
- export const AptosMainnetChain = {
52
- key: "Aptos",
53
- id: 22,
54
- context: "Aptos",
55
- finalityThreshold: 0,
56
- displayName: "Aptos",
57
- explorerUrl: "https://explorer.aptoslabs.com/",
58
- explorerName: "Aptos Explorer",
59
- gasToken: "APT",
60
- chainId: 0,
61
- icon: "Aptos",
62
- maxBlockSearch: 0,
63
- symbol: "APT",
64
- };
@@ -19,6 +19,16 @@ export const mainnetTokens: Record<string, TokenConfig> = {
19
19
  icon: "USDC",
20
20
  decimals: 6,
21
21
  },
22
+ Aptos: {
23
+ symbol: "USDC",
24
+ decimals: 6,
25
+ tokenId: {
26
+ chain: "Aptos",
27
+ address:
28
+ "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
29
+ },
30
+ icon: "USDC",
31
+ },
22
32
  // Sui: {
23
33
  // symbol: "USDC",
24
34
  // decimals: 6,
@@ -30,14 +40,3 @@ export const mainnetTokens: Record<string, TokenConfig> = {
30
40
  // icon: "USDC",
31
41
  // },
32
42
  };
33
-
34
- export const AptosMainnetUSDCToken: TokenConfig = {
35
- symbol: "USDC",
36
- tokenId: {
37
- chain: "Aptos",
38
- address:
39
- "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b",
40
- },
41
- icon: "USDC",
42
- decimals: 6,
43
- };
@@ -35,6 +35,21 @@ export const testnetChains: ChainsConfig = {
35
35
  defaultRpc: "https://api.devnet.solana.com",
36
36
  wrappedGasToken: "So11111111111111111111111111111111111111112",
37
37
  },
38
+ Aptos: {
39
+ key: "Aptos",
40
+ id: 22,
41
+ context: Context.APTOS,
42
+ finalityThreshold: 0,
43
+ displayName: "Aptos",
44
+ explorerUrl: "https://explorer.aptoslabs.com?network=testnet",
45
+ explorerName: "Aptos Explorer",
46
+ gasToken: "APT",
47
+ chainId: 0,
48
+ icon: "Aptos",
49
+ maxBlockSearch: 0,
50
+ symbol: "APT",
51
+ defaultRpc: "https://fullnode.testnet.aptos.dev",
52
+ },
38
53
  // Sui: {
39
54
  // key: "Sui",
40
55
  // id: 21,
@@ -51,19 +66,3 @@ export const testnetChains: ChainsConfig = {
51
66
  // sdkName: "Sui",
52
67
  // },
53
68
  };
54
-
55
- export const AptosTestnetChain = {
56
- key: "Aptos",
57
- id: 22,
58
- context: Context.APTOS,
59
- finalityThreshold: 0,
60
- displayName: "Aptos",
61
- explorerUrl: "https://explorer.aptoslabs.com?network=testnet",
62
- explorerName: "Aptos Explorer",
63
- gasToken: "APT",
64
- chainId: 0,
65
- icon: "Aptos",
66
- maxBlockSearch: 0,
67
- symbol: "APT",
68
- sdkName: "Aptos",
69
- };
@@ -19,6 +19,16 @@ export const testnetTokens: Record<string, TokenConfig> = {
19
19
  icon: "USDC",
20
20
  decimals: 6,
21
21
  },
22
+ Aptos: {
23
+ symbol: "USDC",
24
+ decimals: 6,
25
+ tokenId: {
26
+ chain: "Aptos",
27
+ address:
28
+ "0x69091fbab5f7d635ee7ac5098cf0c1efbe31d68fec0f2cd565e8d168daf52832",
29
+ },
30
+ icon: "USDC",
31
+ },
22
32
  // Sui: {
23
33
  // symbol: "USDC",
24
34
  // tokenId: {
@@ -30,14 +40,3 @@ export const testnetTokens: Record<string, TokenConfig> = {
30
40
  // decimals: 6,
31
41
  // },
32
42
  };
33
-
34
- export const AptosTestnetUSDCToken: TokenConfig = {
35
- symbol: "USDC",
36
- decimals: 6,
37
- tokenId: {
38
- chain: "Aptos",
39
- address:
40
- "0x69091fbab5f7d635ee7ac5098cf0c1efbe31d68fec0f2cd565e8d168daf52832",
41
- },
42
- icon: "USDC",
43
- };
@@ -33,7 +33,7 @@ export class AptosLocalSigner<N extends Network, C extends Chain>
33
33
  chain: C,
34
34
  options: any,
35
35
  wallet: Account,
36
- feePayerAccount: Account | GasStationApiKey | undefined,
36
+ feePayerAccount: Account | GasStationApiKey | undefined
37
37
  ) {
38
38
  this._chain = chain;
39
39
  this._options = options;
@@ -61,7 +61,7 @@ export class AptosLocalSigner<N extends Network, C extends Chain>
61
61
  const txId = await signAndSendTransaction(
62
62
  tx as AptosUnsignedTransaction<Network, AptosChains>,
63
63
  this._wallet,
64
- this._sponsorAccount,
64
+ this._sponsorAccount
65
65
  );
66
66
  txHashes.push(txId);
67
67
  this._claimedTransactionHashes = txId;
@@ -73,7 +73,7 @@ export class AptosLocalSigner<N extends Network, C extends Chain>
73
73
  export async function signAndSendTransaction(
74
74
  request: UnsignedTransaction<Network, AptosChains>,
75
75
  wallet: Account,
76
- sponsorAccount: Account | GasStationApiKey | undefined,
76
+ sponsorAccount: Account | GasStationApiKey | undefined
77
77
  ) {
78
78
  if (!wallet) {
79
79
  throw new Error("Wallet is undefined");
@@ -101,6 +101,7 @@ export async function signAndSendTransaction(
101
101
  sender: wallet.accountAddress.toString(),
102
102
  withFeePayer: sponsorAccount ? true : false,
103
103
  });
104
+
104
105
  const senderAuthenticator = await aptos.transaction.sign({
105
106
  signer: wallet,
106
107
  transaction: txnToSign,
@@ -0,0 +1,139 @@
1
+ import {
2
+ Account,
3
+ AccountAddress,
4
+ AccountAuthenticator,
5
+ AnyRawTransaction,
6
+ Aptos,
7
+ AptosConfig,
8
+ Network as AptosNetwork,
9
+ Deserializer,
10
+ EntryFunctionArgumentTypes,
11
+ InputGenerateTransactionPayloadData,
12
+ ScriptFunctionArgumentTypes,
13
+ Serializer,
14
+ SimpleEntryFunctionArgumentTypes,
15
+ U64,
16
+ } from "@aptos-labs/ts-sdk";
17
+ import { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
18
+ import { Network } from "@wormhole-foundation/sdk";
19
+ import {
20
+ AptosChains,
21
+ AptosUnsignedTransaction,
22
+ } from "@wormhole-foundation/sdk-aptos";
23
+ import { GasStationApiKey } from "..";
24
+ import { UserResponseStatus } from "@aptos-labs/wallet-standard";
25
+
26
+ export async function signAndSendTransaction(
27
+ request: AptosUnsignedTransaction<Network, AptosChains>,
28
+ wallet: AdapterWallet,
29
+ sponsorAccount: Account | GasStationApiKey | undefined
30
+ ) {
31
+ if (!wallet) {
32
+ throw new Error("wallet.sendTransaction is undefined").message;
33
+ }
34
+
35
+ const payload = request.transaction;
36
+ // The wallets do not handle Uint8Array serialization
37
+ payload.functionArguments = payload.functionArguments.map((a: any) => {
38
+ if (a instanceof Uint8Array) {
39
+ return Array.from(a);
40
+ } else if (typeof a === "bigint") {
41
+ return a.toString();
42
+ } else {
43
+ return a;
44
+ }
45
+ });
46
+
47
+ const aptosConfig = new AptosConfig({
48
+ network: AptosNetwork.TESTNET,
49
+ });
50
+ const aptos = new Aptos(aptosConfig);
51
+
52
+ // TODO: handle mainnet
53
+ const contractAddress = AptosNetwork.TESTNET
54
+ ? "0x5e2d961f06cd27aa07554a39d55f5ce1e58dff35d803c3529b1cd5c4fa3ab584"
55
+ : "0x1";
56
+
57
+ // Wormhole resturns a script function transaction payload, but due to a ts-sdk version mismatch,
58
+ // linter complains on different types - so need to first convert to unknown and then to ScriptFunctionArgumentTypes.
59
+ // Also, tranfering the arguments as it brings some errors (which not sure if bug or not), so we first extract them
60
+ // and then tranform them into the functionArguments.
61
+ const functionArguments = extractFunctionArguments(
62
+ payload.functionArguments as unknown as ScriptFunctionArgumentTypes[]
63
+ );
64
+
65
+ const transactionData: InputGenerateTransactionPayloadData = {
66
+ // a custom function to withdraw tokens from the aptos chain, published here on testnet:
67
+ // https://explorer.aptoslabs.com/account/0x5e2d961f06cd27aa07554a39d55f5ce1e58dff35d803c3529b1cd5c4fa3ab584/modules/code/withdraw?network=testnet
68
+ function: `${contractAddress}::withdraw::deposit_for_burn`,
69
+ functionArguments,
70
+ };
71
+
72
+ const txnToSign = await aptos.transaction.build.simple({
73
+ data: transactionData,
74
+ sender: (
75
+ await wallet.features["aptos:account"]?.account()
76
+ ).address.toString(),
77
+ withFeePayer: sponsorAccount ? true : false,
78
+ });
79
+
80
+ const response =
81
+ await wallet.features["aptos:signTransaction"]?.signTransaction(txnToSign);
82
+
83
+ if (response?.status === UserResponseStatus.REJECTED) {
84
+ throw new Error("User has rejected the request");
85
+ }
86
+
87
+ const txnToSubmit: {
88
+ transaction: AnyRawTransaction;
89
+ senderAuthenticator: AccountAuthenticator;
90
+ feePayerAuthenticator?: AccountAuthenticator;
91
+ } = {
92
+ transaction: txnToSign,
93
+ senderAuthenticator: response.args,
94
+ };
95
+
96
+ if (sponsorAccount) {
97
+ if (typeof sponsorAccount === "string") {
98
+ // TODO: handle gas station integration here
99
+ } else {
100
+ const feePayerSignerAuthenticator = aptos.transaction.signAsFeePayer({
101
+ signer: sponsorAccount as Account,
102
+ transaction: txnToSign,
103
+ });
104
+ txnToSubmit.feePayerAuthenticator = feePayerSignerAuthenticator;
105
+ }
106
+ }
107
+
108
+ const txnSubmitted = await aptos.transaction.submit.simple(txnToSubmit);
109
+
110
+ const tx = await aptos.waitForTransaction({
111
+ transactionHash: txnSubmitted.hash,
112
+ });
113
+
114
+ return tx.hash;
115
+ }
116
+
117
+ /**
118
+ * Extracts the function arguments from the function arguments array and tranform them into types the sdk can ready.
119
+ *
120
+ * Note: we assume the argument types are always [U64, U32, accountAddress, accountAddress] - even tho we use
121
+ * Wormhole fix version in the package.json, if wormhole changes this, we need to update this function.
122
+ * @param functionArguments - The function arguments array.
123
+ * @returns The function arguments.
124
+ */
125
+ function extractFunctionArguments(
126
+ functionArguments: ScriptFunctionArgumentTypes[]
127
+ ) {
128
+ const deserializer1 = new Deserializer(functionArguments[0].bcsToBytes());
129
+ const amount = deserializer1.deserializeU64();
130
+
131
+ const deserializer2 = new Deserializer(functionArguments[1].bcsToBytes());
132
+ const destination_domain = deserializer2.deserializeU32();
133
+
134
+ const mint_recipient = new AccountAddress(functionArguments[2].bcsToBytes());
135
+
136
+ const burn_token = new AccountAddress(functionArguments[3].bcsToBytes());
137
+
138
+ return [amount, destination_domain, mint_recipient, burn_token];
139
+ }
@@ -14,6 +14,7 @@ import {
14
14
 
15
15
  import * as solanaSigner from "./SolanaSigner";
16
16
  import * as ethereumSigner from "./EthereumSigner";
17
+ import * as aptosSigner from "./AptosSigner";
17
18
  // import {
18
19
  // SuiChains,
19
20
  // SuiUnsignedTransaction,
@@ -22,6 +23,10 @@ import * as ethereumSigner from "./EthereumSigner";
22
23
 
23
24
  import { ChainConfig } from "../../../config";
24
25
  import { CrossChainCore } from "../../../CrossChainCore";
26
+ import { AptosChains } from "@wormhole-foundation/sdk-aptos/dist/cjs/types";
27
+ import { AptosUnsignedTransaction } from "@wormhole-foundation/sdk-aptos/dist/cjs/unsignedTransaction";
28
+ import { GasStationApiKey } from "../types";
29
+ import { Account } from "@aptos-labs/ts-sdk";
25
30
  export class Signer<N extends Network, C extends Chain>
26
31
  implements SignAndSendSigner<N, C>
27
32
  {
@@ -30,6 +35,8 @@ export class Signer<N extends Network, C extends Chain>
30
35
  _options: any;
31
36
  _wallet: AdapterWallet;
32
37
  _crossChainCore?: CrossChainCore;
38
+ _sponsorAccount: Account | GasStationApiKey | undefined;
39
+ _claimedTransactionHashes: string;
33
40
 
34
41
  constructor(
35
42
  chain: ChainConfig,
@@ -37,12 +44,15 @@ export class Signer<N extends Network, C extends Chain>
37
44
  options: any,
38
45
  wallet: AdapterWallet,
39
46
  crossChainCore?: CrossChainCore,
47
+ sponsorAccount?: Account | GasStationApiKey | undefined
40
48
  ) {
41
49
  this._chain = chain;
42
50
  this._address = address;
43
51
  this._options = options;
44
52
  this._wallet = wallet;
45
53
  this._crossChainCore = crossChainCore;
54
+ this._sponsorAccount = sponsorAccount;
55
+ this._claimedTransactionHashes = "";
46
56
  }
47
57
 
48
58
  chain(): C {
@@ -52,6 +62,10 @@ export class Signer<N extends Network, C extends Chain>
52
62
  return this._address;
53
63
  }
54
64
 
65
+ claimedTransactionHashes(): string {
66
+ return this._claimedTransactionHashes;
67
+ }
68
+
55
69
  async signAndSend(txs: UnsignedTransaction<N, C>[]): Promise<TxHash[]> {
56
70
  const txHashes: TxHash[] = [];
57
71
 
@@ -62,8 +76,10 @@ export class Signer<N extends Network, C extends Chain>
62
76
  this._wallet,
63
77
  this._options,
64
78
  this._crossChainCore,
79
+ this._sponsorAccount
65
80
  );
66
81
  txHashes.push(txId);
82
+ this._claimedTransactionHashes = txId;
67
83
  }
68
84
  return txHashes;
69
85
  }
@@ -75,6 +91,7 @@ export const signAndSendTransaction = async (
75
91
  wallet: AdapterWallet,
76
92
  options: any = {},
77
93
  crossChainCore?: CrossChainCore,
94
+ sponsorAccount?: Account | GasStationApiKey | undefined
78
95
  ): Promise<string> => {
79
96
  if (!wallet) {
80
97
  throw new Error("wallet is undefined");
@@ -85,7 +102,7 @@ export const signAndSendTransaction = async (
85
102
  request as SolanaUnsignedTransaction<Network>,
86
103
  wallet,
87
104
  options,
88
- crossChainCore,
105
+ crossChainCore
89
106
  );
90
107
  return signature;
91
108
  } else if (chain.context === "Ethereum") {
@@ -93,7 +110,14 @@ export const signAndSendTransaction = async (
93
110
  request as EvmUnsignedTransaction<Network, EvmChains>,
94
111
  wallet,
95
112
  chain.displayName,
96
- options,
113
+ options
114
+ );
115
+ return tx;
116
+ } else if (chain.context === "Aptos") {
117
+ const tx = await aptosSigner.signAndSendTransaction(
118
+ request as AptosUnsignedTransaction<Network, AptosChains>,
119
+ wallet,
120
+ sponsorAccount
97
121
  );
98
122
  return tx;
99
123
  } else {
@@ -22,12 +22,13 @@ export type WormholeQuoteResponse = routes.Quote<
22
22
 
23
23
  export interface WormholeQuoteRequest {
24
24
  amount: string;
25
- sourceChain: Chain;
25
+ originChain: Chain;
26
+ type: "transfer" | "withdraw";
26
27
  }
27
28
 
28
29
  export type GasStationApiKey = string;
29
30
 
30
- export interface WormholeInitiateTransferRequest {
31
+ export interface WormholeTransferRequest {
31
32
  sourceChain: Chain;
32
33
  wallet: AdapterWallet;
33
34
  destinationAddress: AccountAddressInput;
@@ -36,6 +37,13 @@ export interface WormholeInitiateTransferRequest {
36
37
  sponsorAccount?: Account | GasStationApiKey;
37
38
  }
38
39
 
40
+ export interface WormholeWithdrawRequest {
41
+ sourceChain: Chain;
42
+ wallet: AdapterWallet;
43
+ destinationAddress: AccountAddressInput;
44
+ sponsorAccount?: Account | GasStationApiKey;
45
+ }
46
+
39
47
  export interface WormholeSubmitTransferRequest {
40
48
  sourceChain: Chain;
41
49
  wallet: AdapterWallet;
@@ -48,7 +56,12 @@ export interface WormholeClaimTransferRequest {
48
56
  sponsorAccount?: AptosAccount | GasStationApiKey;
49
57
  }
50
58
 
51
- export interface WormholeInitiateTransferResponse {
59
+ export interface WormholeTransferResponse {
60
+ destinationChainTxnId: string;
61
+ originChainTxnId: string;
62
+ }
63
+
64
+ export interface WormholeWithdrawResponse {
52
65
  destinationChainTxnId: string;
53
66
  originChainTxnId: string;
54
67
  }