@aptos-labs/cross-chain-core 6.0.0 → 6.1.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/dist/CrossChainCore.d.ts +2 -2
- package/dist/CrossChainCore.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/mainnet/chains.d.ts +1 -1
- package/dist/config/mainnet/chains.d.ts.map +1 -1
- package/dist/config/mainnet/tokens.d.ts +1 -1
- package/dist/config/mainnet/tokens.d.ts.map +1 -1
- package/dist/config/testnet/chains.d.ts +1 -1
- package/dist/config/testnet/chains.d.ts.map +1 -1
- package/dist/config/testnet/tokens.d.ts +1 -1
- package/dist/config/testnet/tokens.d.ts.map +1 -1
- package/dist/config/types.d.ts +1 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1366 -1297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1377 -1302
- package/dist/index.mjs.map +1 -1
- package/dist/providers/wormhole/index.d.ts +4 -4
- package/dist/providers/wormhole/index.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts +5 -5
- package/dist/providers/wormhole/signers/AptosLocalSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/AptosSigner.d.ts +6 -6
- package/dist/providers/wormhole/signers/AptosSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/EthereumSigner.d.ts +3 -3
- package/dist/providers/wormhole/signers/EthereumSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/Signer.d.ts +6 -6
- package/dist/providers/wormhole/signers/Signer.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/SolanaLocalSigner.d.ts +4 -4
- package/dist/providers/wormhole/signers/SolanaLocalSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/SolanaSigner.d.ts +8 -9
- package/dist/providers/wormhole/signers/SolanaSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/SuiSigner.d.ts +3 -3
- package/dist/providers/wormhole/signers/SuiSigner.d.ts.map +1 -1
- package/dist/providers/wormhole/signers/solanaUtils.d.ts +1 -1
- package/dist/providers/wormhole/signers/solanaUtils.d.ts.map +1 -1
- package/dist/providers/wormhole/types.d.ts +10 -4
- package/dist/providers/wormhole/types.d.ts.map +1 -1
- package/dist/providers/wormhole/utils.d.ts +2 -2
- package/dist/providers/wormhole/utils.d.ts.map +1 -1
- package/dist/providers/wormhole/wormhole.d.ts +3 -3
- package/dist/providers/wormhole/wormhole.d.ts.map +1 -1
- package/dist/utils/getUsdcBalance.d.ts +1 -1
- package/dist/utils/getUsdcBalance.d.ts.map +1 -1
- package/dist/utils/receiptSerialization.d.ts +1 -1
- package/dist/utils/receiptSerialization.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +6 -8
- package/src/CrossChainCore.ts +15 -17
- package/src/config/index.ts +1 -1
- package/src/config/mainnet/chains.ts +1 -1
- package/src/config/mainnet/tokens.ts +1 -1
- package/src/config/testnet/chains.ts +1 -1
- package/src/config/testnet/tokens.ts +1 -1
- package/src/config/types.ts +1 -1
- package/src/index.ts +1 -1
- package/src/providers/wormhole/index.ts +4 -4
- package/src/providers/wormhole/signers/AptosLocalSigner.ts +12 -16
- package/src/providers/wormhole/signers/AptosSigner.ts +29 -22
- package/src/providers/wormhole/signers/EthereumSigner.ts +6 -6
- package/src/providers/wormhole/signers/Signer.ts +20 -22
- package/src/providers/wormhole/signers/SolanaLocalSigner.ts +7 -7
- package/src/providers/wormhole/signers/SolanaSigner.ts +13 -14
- package/src/providers/wormhole/signers/SuiSigner.ts +8 -8
- package/src/providers/wormhole/signers/solanaUtils.ts +43 -25
- package/src/providers/wormhole/types.ts +28 -16
- package/src/providers/wormhole/utils.ts +3 -4
- package/src/providers/wormhole/wormhole.ts +50 -48
- package/src/utils/getUsdcBalance.ts +8 -10
- package/src/utils/receiptSerialization.ts +2 -3
- package/src/version.ts +1 -1
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
GasStationClient,
|
|
3
|
+
GasStationTransactionSubmitter,
|
|
4
|
+
} from "@aptos-labs/gas-station-client";
|
|
5
|
+
import {
|
|
6
|
+
type Account,
|
|
3
7
|
AccountAddress,
|
|
4
|
-
AccountAuthenticator,
|
|
5
|
-
AnyRawTransaction,
|
|
8
|
+
type AccountAuthenticator,
|
|
9
|
+
type AnyRawTransaction,
|
|
6
10
|
Aptos,
|
|
7
11
|
AptosConfig,
|
|
8
|
-
Network as AptosNetwork,
|
|
12
|
+
type Network as AptosNetwork,
|
|
9
13
|
Deserializer,
|
|
10
|
-
InputGenerateTransactionPayloadData,
|
|
11
|
-
ScriptFunctionArgumentTypes,
|
|
14
|
+
type InputGenerateTransactionPayloadData,
|
|
15
|
+
type ScriptFunctionArgumentTypes,
|
|
12
16
|
} from "@aptos-labs/ts-sdk";
|
|
13
|
-
import { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
17
|
+
import type { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
18
|
+
import { UserResponseStatus } from "@aptos-labs/wallet-standard";
|
|
19
|
+
import type { Network } from "@wormhole-foundation/sdk";
|
|
20
|
+
import type {
|
|
16
21
|
AptosChains,
|
|
17
22
|
AptosUnsignedTransaction,
|
|
18
23
|
} from "@wormhole-foundation/sdk-aptos";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { GasStationClient, GasStationTransactionSubmitter } from "@aptos-labs/gas-station-client";
|
|
22
|
-
import { CrossChainCore } from "../../../CrossChainCore";
|
|
24
|
+
import type { CrossChainCore } from "../../../CrossChainCore";
|
|
25
|
+
import { type GasStationApiKey, validateExpireTimestamp } from "..";
|
|
23
26
|
|
|
24
27
|
export async function signAndSendTransaction(
|
|
25
28
|
request: AptosUnsignedTransaction<Network, AptosChains>,
|
|
@@ -44,7 +47,6 @@ export async function signAndSendTransaction(
|
|
|
44
47
|
}
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
|
|
48
50
|
// Configure Aptos client based on sponsor type
|
|
49
51
|
let aptosConfig: AptosConfig;
|
|
50
52
|
const useGasStation = sponsorAccount && !isAccount(sponsorAccount);
|
|
@@ -53,10 +55,15 @@ export async function signAndSendTransaction(
|
|
|
53
55
|
// Gas station flow - configure with plugin upfront
|
|
54
56
|
const gasStationClient = new GasStationClient({
|
|
55
57
|
network: dappNetwork,
|
|
56
|
-
apiKey:
|
|
58
|
+
apiKey:
|
|
59
|
+
sponsorAccount[
|
|
60
|
+
dappNetwork as AptosNetwork.TESTNET | AptosNetwork.MAINNET
|
|
61
|
+
],
|
|
57
62
|
});
|
|
58
|
-
const transactionSubmitter = new GasStationTransactionSubmitter(
|
|
59
|
-
|
|
63
|
+
const transactionSubmitter = new GasStationTransactionSubmitter(
|
|
64
|
+
gasStationClient,
|
|
65
|
+
);
|
|
66
|
+
|
|
60
67
|
aptosConfig = new AptosConfig({
|
|
61
68
|
network: dappNetwork,
|
|
62
69
|
pluginSettings: {
|
|
@@ -99,9 +106,9 @@ export async function signAndSendTransaction(
|
|
|
99
106
|
const txnToSign = await aptos.transaction.build.simple({
|
|
100
107
|
data: transactionData,
|
|
101
108
|
sender: (
|
|
102
|
-
await wallet.features["aptos:account"]?.account()
|
|
109
|
+
(await wallet.features["aptos:account"]?.account()) as any
|
|
103
110
|
).address.toString(),
|
|
104
|
-
withFeePayer: sponsorAccount
|
|
111
|
+
withFeePayer: !!sponsorAccount,
|
|
105
112
|
...(typeof expireTimestamp !== "undefined"
|
|
106
113
|
? { options: { expireTimestamp } }
|
|
107
114
|
: {}),
|
|
@@ -123,8 +130,8 @@ export async function signAndSendTransaction(
|
|
|
123
130
|
senderAuthenticator: response.args,
|
|
124
131
|
};
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
// Only sign as fee payer if it's an Account (not gas station)
|
|
134
|
+
if (sponsorAccount && isAccount(sponsorAccount)) {
|
|
128
135
|
const feePayerSignerAuthenticator = aptos.transaction.signAsFeePayer({
|
|
129
136
|
signer: sponsorAccount,
|
|
130
137
|
transaction: txnToSign,
|
|
@@ -166,5 +173,5 @@ function extractFunctionArguments(
|
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
export function isAccount(obj: Account | GasStationApiKey): obj is Account {
|
|
169
|
-
return
|
|
176
|
+
return "accountAddress" in obj;
|
|
170
177
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { EIP1193DerivedWallet } from "@aptos-labs/derived-wallet-ethereum";
|
|
2
|
+
import type { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
3
|
+
import type { Network } from "@wormhole-foundation/sdk";
|
|
4
|
+
import type {
|
|
3
5
|
EvmChains,
|
|
6
|
+
EvmUnsignedTransaction,
|
|
4
7
|
} from "@wormhole-foundation/sdk-evm";
|
|
5
|
-
import { Network } from "@wormhole-foundation/sdk";
|
|
6
8
|
import { ethers, getBigInt } from "ethers";
|
|
7
|
-
import { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
8
|
-
import { EIP1193DerivedWallet } from "@aptos-labs/derived-wallet-ethereum";
|
|
9
9
|
|
|
10
10
|
export async function signAndSendTransaction(
|
|
11
11
|
request: EvmUnsignedTransaction<Network, EvmChains>,
|
|
@@ -23,7 +23,7 @@ export async function signAndSendTransaction(
|
|
|
23
23
|
});
|
|
24
24
|
const actualChainId = parseInt(chainId, 16);
|
|
25
25
|
|
|
26
|
-
if (!actualChainId) throw new Error(
|
|
26
|
+
if (!actualChainId) throw new Error(`No signer found for chain${chainName}`);
|
|
27
27
|
const expectedChainId = request.transaction.chainId
|
|
28
28
|
? getBigInt(request.transaction.chainId)
|
|
29
29
|
: undefined;
|
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Account } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import type { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
3
|
+
import type {
|
|
4
4
|
Chain,
|
|
5
|
-
|
|
5
|
+
Network,
|
|
6
6
|
SignAndSendSigner,
|
|
7
|
+
TxHash,
|
|
8
|
+
UnsignedTransaction,
|
|
7
9
|
} from "@wormhole-foundation/sdk";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
EvmUnsignedTransaction,
|
|
10
|
+
import type { AptosChains } from "@wormhole-foundation/sdk-aptos/dist/cjs/types";
|
|
11
|
+
import type { AptosUnsignedTransaction } from "@wormhole-foundation/sdk-aptos/dist/cjs/unsignedTransaction";
|
|
12
|
+
import type {
|
|
12
13
|
EvmChains,
|
|
14
|
+
EvmUnsignedTransaction,
|
|
13
15
|
} from "@wormhole-foundation/sdk-evm";
|
|
14
|
-
import {
|
|
16
|
+
import type { SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
|
|
17
|
+
import type {
|
|
15
18
|
SuiChains,
|
|
16
19
|
SuiUnsignedTransaction,
|
|
17
20
|
} from "@wormhole-foundation/sdk-sui";
|
|
21
|
+
import type { CrossChainCore } from "../../../CrossChainCore";
|
|
18
22
|
|
|
19
|
-
import
|
|
20
|
-
import
|
|
23
|
+
import type { ChainConfig } from "../../../config";
|
|
24
|
+
import type { GasStationApiKey, OnTransactionSigned } from "../types";
|
|
21
25
|
import * as aptosSigner from "./AptosSigner";
|
|
26
|
+
import * as ethereumSigner from "./EthereumSigner";
|
|
27
|
+
import * as solanaSigner from "./SolanaSigner";
|
|
22
28
|
import * as suiSigner from "./SuiSigner";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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, OnTransactionSigned } from "../types";
|
|
29
|
-
import { Account } from "@aptos-labs/ts-sdk";
|
|
30
|
-
export class Signer<
|
|
31
|
-
N extends Network,
|
|
32
|
-
C extends Chain,
|
|
33
|
-
> implements SignAndSendSigner<N, C> {
|
|
29
|
+
export class Signer<N extends Network, C extends Chain>
|
|
30
|
+
implements SignAndSendSigner<N, C>
|
|
31
|
+
{
|
|
34
32
|
_chain: ChainConfig;
|
|
35
33
|
_address: string;
|
|
36
34
|
_options: any;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Connection,
|
|
3
|
-
Keypair,
|
|
4
|
-
Transaction,
|
|
5
2
|
type Commitment,
|
|
3
|
+
type Connection,
|
|
4
|
+
type Keypair,
|
|
5
|
+
Transaction,
|
|
6
6
|
} from "@solana/web3.js";
|
|
7
|
-
import {
|
|
7
|
+
import type {
|
|
8
8
|
Chain,
|
|
9
9
|
Network,
|
|
10
10
|
SignAndSendSigner,
|
|
11
11
|
TxHash,
|
|
12
12
|
UnsignedTransaction,
|
|
13
13
|
} from "@wormhole-foundation/sdk";
|
|
14
|
+
import type { OnTransactionSigned } from "../types";
|
|
14
15
|
import {
|
|
15
16
|
addPriorityFeeInstructions,
|
|
16
|
-
PriorityFeeConfig,
|
|
17
|
+
type PriorityFeeConfig,
|
|
17
18
|
sendAndConfirmTransaction,
|
|
18
19
|
} from "./solanaUtils";
|
|
19
|
-
import { OnTransactionSigned } from "../types";
|
|
20
20
|
|
|
21
21
|
export interface SolanaLocalSignerConfig {
|
|
22
22
|
/** The Solana keypair to sign transactions with */
|
|
@@ -162,7 +162,7 @@ export class SolanaLocalSigner<N extends Network, C extends Chain>
|
|
|
162
162
|
if (this.verbose || this.priorityFeeConfig) {
|
|
163
163
|
console.warn(
|
|
164
164
|
"SolanaLocalSigner: Versioned transaction detected — priority fees are not applied. " +
|
|
165
|
-
|
|
165
|
+
"Consider using legacy transactions if priority fees are required.",
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
unsignedTx.sign([this.keypair]);
|
|
@@ -4,30 +4,29 @@
|
|
|
4
4
|
* and resending the transaction if it hasn't been confirmed after the specified interval.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { SolanaDerivedWallet } from "@aptos-labs/derived-wallet-solana";
|
|
8
|
+
import type { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
7
9
|
import {
|
|
8
|
-
ConfirmOptions,
|
|
10
|
+
type ConfirmOptions,
|
|
11
|
+
Connection,
|
|
9
12
|
Transaction,
|
|
10
|
-
VersionedTransaction,
|
|
13
|
+
type VersionedTransaction,
|
|
11
14
|
} from "@solana/web3.js";
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
|
|
16
|
-
import { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
17
|
-
import { CrossChainCore } from "../../../CrossChainCore";
|
|
18
|
-
import { SolanaDerivedWallet } from "@aptos-labs/derived-wallet-solana";
|
|
15
|
+
import type { Network } from "@wormhole-foundation/sdk";
|
|
16
|
+
import type { SolanaUnsignedTransaction } from "@wormhole-foundation/sdk-solana";
|
|
17
|
+
import type { CrossChainCore } from "../../../CrossChainCore";
|
|
19
18
|
import {
|
|
20
19
|
addPriorityFeeInstructions,
|
|
20
|
+
type PriorityFeeConfig,
|
|
21
21
|
sendAndConfirmTransaction,
|
|
22
|
-
PriorityFeeConfig,
|
|
23
22
|
} from "./solanaUtils";
|
|
24
23
|
|
|
25
24
|
// Re-export types for backwards compatibility
|
|
26
|
-
export type {
|
|
25
|
+
export type { PriorityFeeConfig, SolanaRpcProvider } from "./solanaUtils";
|
|
27
26
|
export {
|
|
28
|
-
sleep,
|
|
29
|
-
isEmptyObject,
|
|
30
27
|
determineRpcProvider,
|
|
28
|
+
isEmptyObject,
|
|
29
|
+
sleep,
|
|
31
30
|
} from "./solanaUtils";
|
|
32
31
|
|
|
33
32
|
// See https://docs.triton.one/chains/solana/sending-txs for more information
|
|
@@ -48,7 +47,7 @@ export async function signAndSendTransaction(
|
|
|
48
47
|
// Solana rpc should come from dapp config
|
|
49
48
|
const connection = new Connection(
|
|
50
49
|
crossChainCore?._dappConfig?.solanaConfig?.rpc ??
|
|
51
|
-
crossChainCore?.CHAINS
|
|
50
|
+
crossChainCore?.CHAINS.Solana?.defaultRpc ??
|
|
52
51
|
"https://api.devnet.solana.com", // Last resort fallback
|
|
53
52
|
);
|
|
54
53
|
const { blockhash, lastValidBlockHeight } =
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
SuiChains,
|
|
5
|
-
SuiUnsignedTransaction,
|
|
6
|
-
} from "@wormhole-foundation/sdk-sui";
|
|
7
|
-
import { SuiDerivedWallet } from "@aptos-labs/derived-wallet-sui";
|
|
8
|
-
import {
|
|
1
|
+
import type { SuiDerivedWallet } from "@aptos-labs/derived-wallet-sui";
|
|
2
|
+
import type { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
3
|
+
import type {
|
|
9
4
|
SuiSignAndExecuteTransactionInput,
|
|
10
5
|
SuiSignAndExecuteTransactionOutput,
|
|
11
6
|
} from "@mysten/wallet-standard";
|
|
7
|
+
import type { Network } from "@wormhole-foundation/sdk";
|
|
8
|
+
import type {
|
|
9
|
+
SuiChains,
|
|
10
|
+
SuiUnsignedTransaction,
|
|
11
|
+
} from "@wormhole-foundation/sdk-sui";
|
|
12
12
|
|
|
13
13
|
export async function signAndSendTransaction(
|
|
14
14
|
request: SuiUnsignedTransaction<Network, SuiChains>,
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
+
type Commitment,
|
|
7
8
|
ComputeBudgetProgram,
|
|
8
|
-
Connection,
|
|
9
|
+
type Connection,
|
|
9
10
|
LAMPORTS_PER_SOL,
|
|
10
|
-
RpcResponseAndContext,
|
|
11
|
-
SignatureResult,
|
|
12
|
-
SimulatedTransactionResponse,
|
|
13
|
-
Transaction,
|
|
14
|
-
TransactionInstruction,
|
|
15
|
-
VersionedTransaction,
|
|
16
|
-
type Commitment,
|
|
11
|
+
type RpcResponseAndContext,
|
|
12
|
+
type SignatureResult,
|
|
13
|
+
type SimulatedTransactionResponse,
|
|
14
|
+
type Transaction,
|
|
15
|
+
type TransactionInstruction,
|
|
16
|
+
type VersionedTransaction,
|
|
17
17
|
} from "@solana/web3.js";
|
|
18
18
|
import {
|
|
19
19
|
determinePriorityFee,
|
|
@@ -67,7 +67,12 @@ export async function sendAndConfirmTransaction(
|
|
|
67
67
|
lastValidBlockHeight: number,
|
|
68
68
|
config: SendAndConfirmConfig,
|
|
69
69
|
): Promise<string> {
|
|
70
|
-
const {
|
|
70
|
+
const {
|
|
71
|
+
connection,
|
|
72
|
+
commitment,
|
|
73
|
+
retryIntervalMs = 5000,
|
|
74
|
+
verbose = false,
|
|
75
|
+
} = config;
|
|
71
76
|
|
|
72
77
|
const sendOptions = {
|
|
73
78
|
skipPreflight: true,
|
|
@@ -75,7 +80,10 @@ export async function sendAndConfirmTransaction(
|
|
|
75
80
|
preflightCommitment: commitment,
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
const signature = await connection.sendRawTransaction(
|
|
83
|
+
const signature = await connection.sendRawTransaction(
|
|
84
|
+
serializedTx,
|
|
85
|
+
sendOptions,
|
|
86
|
+
);
|
|
79
87
|
|
|
80
88
|
const confirmTransactionPromise = connection.confirmTransaction(
|
|
81
89
|
{ signature, blockhash, lastValidBlockHeight },
|
|
@@ -150,9 +158,8 @@ export async function sendAndConfirmTransaction(
|
|
|
150
158
|
export function formatTransactionError(err: unknown): string {
|
|
151
159
|
if (typeof err === "object" && err !== null) {
|
|
152
160
|
try {
|
|
153
|
-
return `Transaction failed: ${JSON.stringify(
|
|
154
|
-
|
|
155
|
-
(_key, value) => (typeof value === "bigint" ? value.toString() : value),
|
|
161
|
+
return `Transaction failed: ${JSON.stringify(err, (_key, value) =>
|
|
162
|
+
typeof value === "bigint" ? value.toString() : value,
|
|
156
163
|
)}`;
|
|
157
164
|
} catch {
|
|
158
165
|
// Circular reference or other stringify error
|
|
@@ -186,7 +193,9 @@ export async function addPriorityFeeInstructions(
|
|
|
186
193
|
ix.programId.toString() !== "ComputeBudget111111111111111111111111111111";
|
|
187
194
|
|
|
188
195
|
// Remove existing compute budget instructions if they were added by the SDK
|
|
189
|
-
transaction.instructions = transaction.instructions.filter(
|
|
196
|
+
transaction.instructions = transaction.instructions.filter(
|
|
197
|
+
computeBudgetIxFilter,
|
|
198
|
+
);
|
|
190
199
|
|
|
191
200
|
const instructions = await createPriorityFeeInstructions(
|
|
192
201
|
connection,
|
|
@@ -266,8 +275,10 @@ async function simulateAndGetComputeUnits(
|
|
|
266
275
|
let unitsUsed = 200_000;
|
|
267
276
|
let simulationAttempts = 0;
|
|
268
277
|
|
|
269
|
-
|
|
270
|
-
const response = await connection.simulateTransaction(
|
|
278
|
+
while (true) {
|
|
279
|
+
const response = await connection.simulateTransaction(
|
|
280
|
+
transaction as Transaction,
|
|
281
|
+
);
|
|
271
282
|
|
|
272
283
|
if (response.value.err) {
|
|
273
284
|
if (checkKnownSimulationError(response.value)) {
|
|
@@ -275,13 +286,13 @@ async function simulateAndGetComputeUnits(
|
|
|
275
286
|
if (simulationAttempts < 5) {
|
|
276
287
|
simulationAttempts++;
|
|
277
288
|
await sleep(1000);
|
|
278
|
-
continue
|
|
289
|
+
continue;
|
|
279
290
|
}
|
|
280
291
|
} else if (simulationAttempts < 3) {
|
|
281
292
|
// Number of attempts will be at most 3 for unknown errors
|
|
282
293
|
simulationAttempts++;
|
|
283
294
|
await sleep(1000);
|
|
284
|
-
continue
|
|
295
|
+
continue;
|
|
285
296
|
}
|
|
286
297
|
|
|
287
298
|
// Still failing after multiple attempts
|
|
@@ -358,12 +369,14 @@ async function calculatePriorityFee(
|
|
|
358
369
|
/**
|
|
359
370
|
* Checks response logs for known simulation errors that can be retried.
|
|
360
371
|
*/
|
|
361
|
-
function checkKnownSimulationError(
|
|
372
|
+
function checkKnownSimulationError(
|
|
373
|
+
response: SimulatedTransactionResponse,
|
|
374
|
+
): boolean {
|
|
362
375
|
const errors: Record<string, string> = {};
|
|
363
376
|
|
|
364
377
|
// This error occurs when the blockhash included in a transaction is not deemed to be valid
|
|
365
378
|
if (response.err === "BlockhashNotFound") {
|
|
366
|
-
errors
|
|
379
|
+
errors.BlockhashNotFound =
|
|
367
380
|
"Blockhash not found during simulation. Trying again.";
|
|
368
381
|
}
|
|
369
382
|
|
|
@@ -371,12 +384,12 @@ function checkKnownSimulationError(response: SimulatedTransactionResponse): bool
|
|
|
371
384
|
if (response.logs) {
|
|
372
385
|
for (const line of response.logs) {
|
|
373
386
|
if (line.includes("SlippageToleranceExceeded")) {
|
|
374
|
-
errors
|
|
387
|
+
errors.SlippageToleranceExceeded =
|
|
375
388
|
"Slippage failure during simulation. Trying again.";
|
|
376
389
|
}
|
|
377
390
|
|
|
378
391
|
if (line.includes("RequireGteViolated")) {
|
|
379
|
-
errors
|
|
392
|
+
errors.RequireGteViolated =
|
|
380
393
|
"Swap instruction failure during simulation. Trying again.";
|
|
381
394
|
}
|
|
382
395
|
}
|
|
@@ -406,9 +419,15 @@ export function determineRpcProvider(endpoint: string): SolanaRpcProvider {
|
|
|
406
419
|
try {
|
|
407
420
|
const url = new URL(endpoint);
|
|
408
421
|
const hostname = url.hostname;
|
|
409
|
-
if (
|
|
422
|
+
if (
|
|
423
|
+
isHostOrSubdomainOf(hostname, "rpcpool.com") ||
|
|
424
|
+
isHostOrSubdomainOf(hostname, "triton.one")
|
|
425
|
+
) {
|
|
410
426
|
return "triton";
|
|
411
|
-
} else if (
|
|
427
|
+
} else if (
|
|
428
|
+
isHostOrSubdomainOf(hostname, "helius-rpc.com") ||
|
|
429
|
+
isHostOrSubdomainOf(hostname, "helius.xyz")
|
|
430
|
+
) {
|
|
412
431
|
return "helius";
|
|
413
432
|
} else if (isHostOrSubdomainOf(hostname, "ankr.com")) {
|
|
414
433
|
return "ankr";
|
|
@@ -443,4 +462,3 @@ export const isEmptyObject = (value: object | null | undefined): boolean => {
|
|
|
443
462
|
|
|
444
463
|
return true;
|
|
445
464
|
};
|
|
446
|
-
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { Account, AccountAddressInput, Network } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import type { AdapterWallet } from "@aptos-labs/wallet-adapter-core";
|
|
3
|
+
import type {
|
|
4
|
+
AttestationReceipt,
|
|
5
|
+
routes,
|
|
6
|
+
} from "@wormhole-foundation/sdk/dist/cjs";
|
|
7
|
+
import type { AptosAccount, Chain } from "../..";
|
|
5
8
|
|
|
6
9
|
export type WormholeRouteResponse = routes.Route<
|
|
7
10
|
"Mainnet" | "Testnet",
|
|
@@ -26,7 +29,9 @@ export interface WormholeQuoteRequest {
|
|
|
26
29
|
type: "transfer" | "withdraw";
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
export type GasStationApiKey = Partial<
|
|
32
|
+
export type GasStationApiKey = Partial<
|
|
33
|
+
Record<Network.TESTNET | Network.MAINNET, string>
|
|
34
|
+
>;
|
|
30
35
|
|
|
31
36
|
export interface WormholeTransferRequest {
|
|
32
37
|
sourceChain: Chain;
|
|
@@ -40,9 +45,9 @@ export interface WormholeTransferRequest {
|
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
export type WithdrawPhase =
|
|
43
|
-
| "initiating"
|
|
44
|
-
| "tracking"
|
|
45
|
-
| "claiming";
|
|
48
|
+
| "initiating" // User signing Aptos burn transaction
|
|
49
|
+
| "tracking" // Waiting for Wormhole attestation (~60s)
|
|
50
|
+
| "claiming"; // Claiming on destination chain
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* Callback fired before and after each individual transaction is signed
|
|
@@ -54,7 +59,10 @@ export type WithdrawPhase =
|
|
|
54
59
|
* @param txId - `null` when called *before* signing; the on-chain
|
|
55
60
|
* transaction hash when called *after* signing.
|
|
56
61
|
*/
|
|
57
|
-
export type OnTransactionSigned = (
|
|
62
|
+
export type OnTransactionSigned = (
|
|
63
|
+
description: string,
|
|
64
|
+
txId: string | null,
|
|
65
|
+
) => void;
|
|
58
66
|
|
|
59
67
|
export interface WormholeWithdrawRequest {
|
|
60
68
|
/**
|
|
@@ -137,13 +145,20 @@ export interface WormholeClaimWithdrawRequest {
|
|
|
137
145
|
wallet?: AdapterWallet;
|
|
138
146
|
/** Optional callback fired before and after each individual transaction is signed. */
|
|
139
147
|
onTransactionSigned?: OnTransactionSigned;
|
|
148
|
+
/**
|
|
149
|
+
* When true, skip the server-side claim path (serverClaimUrl) and instead
|
|
150
|
+
* perform a client-side wallet-signed claim. Useful as a fallback when the
|
|
151
|
+
* server endpoint is unreachable. Requires `wallet` to be provided.
|
|
152
|
+
*/
|
|
153
|
+
skipServerClaim?: boolean;
|
|
140
154
|
}
|
|
141
155
|
|
|
142
156
|
export interface WormholeClaimWithdrawResponse {
|
|
143
157
|
destinationChainTxnId: string;
|
|
144
158
|
}
|
|
145
159
|
|
|
146
|
-
export interface RetryWithdrawClaimRequest
|
|
160
|
+
export interface RetryWithdrawClaimRequest
|
|
161
|
+
extends WormholeClaimWithdrawRequest {
|
|
147
162
|
/** Maximum number of retry attempts (default: 5). */
|
|
148
163
|
maxRetries?: number;
|
|
149
164
|
/** Initial delay in ms before the first retry (default: 2000). */
|
|
@@ -152,7 +167,8 @@ export interface RetryWithdrawClaimRequest extends WormholeClaimWithdrawRequest
|
|
|
152
167
|
backoffMultiplier?: number;
|
|
153
168
|
}
|
|
154
169
|
|
|
155
|
-
export interface RetryWithdrawClaimResponse
|
|
170
|
+
export interface RetryWithdrawClaimResponse
|
|
171
|
+
extends WormholeClaimWithdrawResponse {
|
|
156
172
|
/** Number of retry attempts that were needed (0 means first attempt succeeded). */
|
|
157
173
|
retriesUsed: number;
|
|
158
174
|
}
|
|
@@ -191,11 +207,7 @@ export class TransferError extends Error {
|
|
|
191
207
|
*/
|
|
192
208
|
readonly cause?: unknown;
|
|
193
209
|
|
|
194
|
-
constructor(
|
|
195
|
-
message: string,
|
|
196
|
-
originChainTxnId: string,
|
|
197
|
-
cause?: unknown,
|
|
198
|
-
) {
|
|
210
|
+
constructor(message: string, originChainTxnId: string, cause?: unknown) {
|
|
199
211
|
super(message);
|
|
200
212
|
this.name = "TransferError";
|
|
201
213
|
this.originChainTxnId = originChainTxnId;
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
import {
|
|
7
7
|
chainToPlatform,
|
|
8
8
|
routes,
|
|
9
|
+
type TokenId,
|
|
9
10
|
Wormhole,
|
|
10
|
-
TokenId,
|
|
11
11
|
} from "@wormhole-foundation/sdk";
|
|
12
|
-
import { Chain } from "../../CrossChainCore";
|
|
13
|
-
import { TokenConfig } from "../../config";
|
|
12
|
+
import type { Chain } from "../../CrossChainCore";
|
|
13
|
+
import type { TokenConfig } from "../../config";
|
|
14
14
|
|
|
15
15
|
export interface CCTPRouteResult {
|
|
16
16
|
route: routes.ManualRoute<"Mainnet" | "Testnet">;
|
|
@@ -69,4 +69,3 @@ export async function createCCTPRoute(
|
|
|
69
69
|
|
|
70
70
|
return { route: cctpRoute, request };
|
|
71
71
|
}
|
|
72
|
-
|