@wormhole-labs/cctp-executor-route 0.4.0 → 0.5.0-beta.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 +1 -1
- package/dist/cjs/aptos/executor.d.ts +1 -1
- package/dist/cjs/aptos/executor.d.ts.map +1 -1
- package/dist/cjs/aptos/executor.js +1 -1
- package/dist/cjs/aptos/executor.js.map +1 -1
- package/dist/cjs/consts.d.ts +22 -1
- package/dist/cjs/consts.d.ts.map +1 -1
- package/dist/cjs/consts.js +223 -5
- package/dist/cjs/consts.js.map +1 -1
- package/dist/cjs/evm/executor.d.ts +1 -1
- package/dist/cjs/evm/executor.d.ts.map +1 -1
- package/dist/cjs/evm/executor.js +1 -1
- package/dist/cjs/evm/executor.js.map +1 -1
- package/dist/cjs/evm/executorV2.d.ts +25 -0
- package/dist/cjs/evm/executorV2.d.ts.map +1 -0
- package/dist/cjs/evm/executorV2.js +100 -0
- package/dist/cjs/evm/executorV2.js.map +1 -0
- package/dist/cjs/evm/index.d.ts +1 -0
- package/dist/cjs/evm/index.d.ts.map +1 -1
- package/dist/cjs/evm/index.js +3 -0
- package/dist/cjs/evm/index.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -91
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +15 -334
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/layouts/circle.d.ts +161 -0
- package/dist/cjs/layouts/circle.d.ts.map +1 -0
- package/dist/cjs/layouts/circle.js +48 -0
- package/dist/cjs/layouts/circle.js.map +1 -0
- package/dist/cjs/layouts/index.d.ts +1 -1
- package/dist/cjs/layouts/index.d.ts.map +1 -1
- package/dist/cjs/layouts/index.js +1 -1
- package/dist/cjs/layouts/index.js.map +1 -1
- package/dist/cjs/routes/cctpV1.d.ts +92 -0
- package/dist/cjs/routes/cctpV1.d.ts.map +1 -0
- package/dist/cjs/routes/cctpV1.js +190 -0
- package/dist/cjs/routes/cctpV1.js.map +1 -0
- package/dist/cjs/routes/cctpV2Base.d.ts +57 -0
- package/dist/cjs/routes/cctpV2Base.d.ts.map +1 -0
- package/dist/cjs/routes/cctpV2Base.js +179 -0
- package/dist/cjs/routes/cctpV2Base.js.map +1 -0
- package/dist/cjs/routes/cctpV2Fast.d.ts +42 -0
- package/dist/cjs/routes/cctpV2Fast.d.ts.map +1 -0
- package/dist/cjs/routes/cctpV2Fast.js +138 -0
- package/dist/cjs/routes/cctpV2Fast.js.map +1 -0
- package/dist/cjs/routes/cctpV2Standard.d.ts +42 -0
- package/dist/cjs/routes/cctpV2Standard.d.ts.map +1 -0
- package/dist/cjs/routes/cctpV2Standard.js +126 -0
- package/dist/cjs/routes/cctpV2Standard.js.map +1 -0
- package/dist/cjs/routes/helpers.d.ts +12 -0
- package/dist/cjs/routes/helpers.d.ts.map +1 -0
- package/dist/cjs/routes/helpers.js +181 -0
- package/dist/cjs/routes/helpers.js.map +1 -0
- package/dist/cjs/routes/index.d.ts +5 -0
- package/dist/cjs/routes/index.d.ts.map +1 -0
- package/dist/cjs/routes/index.js +21 -0
- package/dist/cjs/routes/index.js.map +1 -0
- package/dist/cjs/sui/executor.d.ts +1 -1
- package/dist/cjs/sui/executor.d.ts.map +1 -1
- package/dist/cjs/svm/executor.d.ts +1 -1
- package/dist/cjs/svm/executor.d.ts.map +1 -1
- package/dist/cjs/svm/executor.js +1 -1
- package/dist/cjs/svm/executor.js.map +1 -1
- package/dist/cjs/types.d.ts +8 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/utils.d.ts +20 -1
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/cjs/utils.js +86 -2
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/aptos/executor.d.ts +1 -1
- package/dist/esm/aptos/executor.d.ts.map +1 -1
- package/dist/esm/aptos/executor.js +2 -2
- package/dist/esm/aptos/executor.js.map +1 -1
- package/dist/esm/consts.d.ts +22 -1
- package/dist/esm/consts.d.ts.map +1 -1
- package/dist/esm/consts.js +216 -4
- package/dist/esm/consts.js.map +1 -1
- package/dist/esm/evm/executor.d.ts +1 -1
- package/dist/esm/evm/executor.d.ts.map +1 -1
- package/dist/esm/evm/executor.js +2 -2
- package/dist/esm/evm/executor.js.map +1 -1
- package/dist/esm/evm/executorV2.d.ts +25 -0
- package/dist/esm/evm/executorV2.d.ts.map +1 -0
- package/dist/esm/evm/executorV2.js +96 -0
- package/dist/esm/evm/executorV2.js.map +1 -0
- package/dist/esm/evm/index.d.ts +1 -0
- package/dist/esm/evm/index.d.ts.map +1 -1
- package/dist/esm/evm/index.js +3 -0
- package/dist/esm/evm/index.js.map +1 -1
- package/dist/esm/index.d.ts +1 -91
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -331
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layouts/circle.d.ts +161 -0
- package/dist/esm/layouts/circle.d.ts.map +1 -0
- package/dist/esm/layouts/circle.js +43 -0
- package/dist/esm/layouts/circle.js.map +1 -0
- package/dist/esm/layouts/index.d.ts +1 -1
- package/dist/esm/layouts/index.d.ts.map +1 -1
- package/dist/esm/layouts/index.js +1 -1
- package/dist/esm/layouts/index.js.map +1 -1
- package/dist/esm/routes/cctpV1.d.ts +92 -0
- package/dist/esm/routes/cctpV1.d.ts.map +1 -0
- package/dist/esm/routes/cctpV1.js +185 -0
- package/dist/esm/routes/cctpV1.js.map +1 -0
- package/dist/esm/routes/cctpV2Base.d.ts +57 -0
- package/dist/esm/routes/cctpV2Base.d.ts.map +1 -0
- package/dist/esm/routes/cctpV2Base.js +175 -0
- package/dist/esm/routes/cctpV2Base.js.map +1 -0
- package/dist/esm/routes/cctpV2Fast.d.ts +42 -0
- package/dist/esm/routes/cctpV2Fast.d.ts.map +1 -0
- package/dist/esm/routes/cctpV2Fast.js +133 -0
- package/dist/esm/routes/cctpV2Fast.js.map +1 -0
- package/dist/esm/routes/cctpV2Standard.d.ts +42 -0
- package/dist/esm/routes/cctpV2Standard.d.ts.map +1 -0
- package/dist/esm/routes/cctpV2Standard.js +121 -0
- package/dist/esm/routes/cctpV2Standard.js.map +1 -0
- package/dist/esm/routes/helpers.d.ts +12 -0
- package/dist/esm/routes/helpers.d.ts.map +1 -0
- package/dist/esm/routes/helpers.js +177 -0
- package/dist/esm/routes/helpers.js.map +1 -0
- package/dist/esm/routes/index.d.ts +5 -0
- package/dist/esm/routes/index.d.ts.map +1 -0
- package/dist/esm/routes/index.js +5 -0
- package/dist/esm/routes/index.js.map +1 -0
- package/dist/esm/sui/executor.d.ts +1 -1
- package/dist/esm/sui/executor.d.ts.map +1 -1
- package/dist/esm/svm/executor.d.ts +1 -1
- package/dist/esm/svm/executor.d.ts.map +1 -1
- package/dist/esm/svm/executor.js +2 -2
- package/dist/esm/svm/executor.js.map +1 -1
- package/dist/esm/types.d.ts +8 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +20 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js +83 -3
- package/dist/esm/utils.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/dist/cjs/layouts/requestForExecution.d.ts +0 -18
- package/dist/cjs/layouts/requestForExecution.d.ts.map +0 -1
- package/dist/cjs/layouts/requestForExecution.js +0 -15
- package/dist/cjs/layouts/requestForExecution.js.map +0 -1
- package/dist/esm/layouts/requestForExecution.d.ts +0 -18
- package/dist/esm/layouts/requestForExecution.d.ts.map +0 -1
- package/dist/esm/layouts/requestForExecution.js +0 -12
- package/dist/esm/layouts/requestForExecution.js.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { encoding, nativeChainIds, toChainId, } from "@wormhole-foundation/sdk-connect";
|
|
2
|
+
import { EvmAddress, EvmPlatform, EvmUnsignedTransaction, addChainId, addFrom, } from "@wormhole-foundation/sdk-evm";
|
|
3
|
+
import { Contract } from "ethers";
|
|
4
|
+
import { circleV2Contracts, getCircleV2Domain, shimContractsV2, usdcContracts, } from "../consts";
|
|
5
|
+
import { serializeCircleV2Message } from "../layouts";
|
|
6
|
+
export class EvmCCTPv2Executor {
|
|
7
|
+
network;
|
|
8
|
+
chain;
|
|
9
|
+
provider;
|
|
10
|
+
contracts;
|
|
11
|
+
chainId;
|
|
12
|
+
shimContract;
|
|
13
|
+
messageTransmitter;
|
|
14
|
+
usdcContract;
|
|
15
|
+
constructor(network, chain, provider, contracts) {
|
|
16
|
+
this.network = network;
|
|
17
|
+
this.chain = chain;
|
|
18
|
+
this.provider = provider;
|
|
19
|
+
this.contracts = contracts;
|
|
20
|
+
if (network === "Devnet")
|
|
21
|
+
throw new Error("CCTPv2Executor not supported on Devnet");
|
|
22
|
+
this.chainId = nativeChainIds.networkChainToNativeChainId.get(network, chain);
|
|
23
|
+
const shimContract = shimContractsV2[network]?.[chain];
|
|
24
|
+
if (!shimContract)
|
|
25
|
+
throw new Error(`Shim contract for ${chain} not found`);
|
|
26
|
+
this.shimContract = shimContract;
|
|
27
|
+
const messageTransmitter = circleV2Contracts[network]?.[chain]?.messageTransmitterV2;
|
|
28
|
+
if (!messageTransmitter)
|
|
29
|
+
throw new Error(`MessageTransmitter contract for ${chain} not found`);
|
|
30
|
+
this.messageTransmitter = messageTransmitter;
|
|
31
|
+
const usdcContract = usdcContracts[network]?.[chain];
|
|
32
|
+
if (!usdcContract)
|
|
33
|
+
throw new Error(`USDC contract for ${chain} not found`);
|
|
34
|
+
this.usdcContract = usdcContract;
|
|
35
|
+
}
|
|
36
|
+
static async fromRpc(provider, config) {
|
|
37
|
+
const [network, chain] = await EvmPlatform.chainFromRpc(provider);
|
|
38
|
+
const conf = config[chain];
|
|
39
|
+
if (conf.network !== network)
|
|
40
|
+
throw new Error(`Network mismatch: ${conf.network} != ${network}`);
|
|
41
|
+
return new EvmCCTPv2Executor(network, chain, provider, conf.contracts);
|
|
42
|
+
}
|
|
43
|
+
async *transfer(sender, recipient, details) {
|
|
44
|
+
const senderAddress = new EvmAddress(sender).toString();
|
|
45
|
+
const recipientAddress = recipient.address
|
|
46
|
+
.toUniversalAddress()
|
|
47
|
+
.toUint8Array();
|
|
48
|
+
const amount = details.remainingAmount + details.referrerFee;
|
|
49
|
+
const tokenContract = EvmPlatform.getTokenImplementation(this.provider, this.usdcContract);
|
|
50
|
+
const allowance = await tokenContract.allowance(senderAddress, this.shimContract);
|
|
51
|
+
if (allowance < amount) {
|
|
52
|
+
const txReq = await tokenContract.approve.populateTransaction(this.shimContract, amount);
|
|
53
|
+
yield this.createUnsignedTx(addFrom(txReq, senderAddress), "ERC20.approve of EvmCCTPv2Executor", false);
|
|
54
|
+
}
|
|
55
|
+
// TODO: type safety. typechain brings in so much boilerplate code and is soft deprecated. use viem?
|
|
56
|
+
const shimAbi = [
|
|
57
|
+
"function depositForBurn(uint256 amount, uint16 destinationChain, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, bytes32 destinationCaller, uint256 maxFee, uint32 minFinalityThreshold, (address refundAddress, bytes signedQuote, bytes instructions) executorArgs, (uint16 dbps, address payee) feeArgs) external payable returns (uint64 nonce)",
|
|
58
|
+
];
|
|
59
|
+
// If equal to bytes32(0), any address can call receiveMessage() on destination domain.
|
|
60
|
+
const destinationCaller = new Uint8Array(32);
|
|
61
|
+
const shim = new Contract(this.shimContract, shimAbi, this.provider);
|
|
62
|
+
const destinationCircleDomain = getCircleV2Domain(this.network, recipient.chain);
|
|
63
|
+
const txReq = await shim.getFunction("depositForBurn").populateTransaction(amount, toChainId(recipient.chain), destinationCircleDomain, recipientAddress, this.usdcContract, destinationCaller, details.fastTransferMaxFee, details.minFinalityThreshold, {
|
|
64
|
+
refundAddress: senderAddress,
|
|
65
|
+
signedQuote: details.signedQuote,
|
|
66
|
+
instructions: details.relayInstructions,
|
|
67
|
+
}, {
|
|
68
|
+
dbps: details.referrerFeeDbps,
|
|
69
|
+
payee: details.referrer.address.toString(),
|
|
70
|
+
});
|
|
71
|
+
txReq.value = details.estimatedCost;
|
|
72
|
+
yield this.createUnsignedTx(addFrom(txReq, senderAddress), "EvmCCTPv2Executor.depositForBurn");
|
|
73
|
+
}
|
|
74
|
+
async isTransferCompleted(message) {
|
|
75
|
+
const contract = new Contract(this.messageTransmitter, ["function usedNonces(bytes32) public view returns (uint256)"], this.provider);
|
|
76
|
+
const result = await contract
|
|
77
|
+
.getFunction("usedNonces")
|
|
78
|
+
.staticCall(message.nonce);
|
|
79
|
+
return result === 1n;
|
|
80
|
+
}
|
|
81
|
+
async *redeem(sender, message, attestation) {
|
|
82
|
+
const senderAddr = new EvmAddress(sender).toString();
|
|
83
|
+
const contract = new Contract(this.messageTransmitter, ["function receiveMessage(bytes message, bytes attestation)"], this.provider);
|
|
84
|
+
const txReq = await contract
|
|
85
|
+
.getFunction("receiveMessage")
|
|
86
|
+
.populateTransaction(serializeCircleV2Message(message), encoding.hex.decode(attestation));
|
|
87
|
+
yield this.createUnsignedTx(addFrom(txReq, senderAddr), "MessageTransmitterV2.receiveMessage");
|
|
88
|
+
}
|
|
89
|
+
async getCurrentBlock() {
|
|
90
|
+
return BigInt(await this.provider.getBlockNumber());
|
|
91
|
+
}
|
|
92
|
+
createUnsignedTx(txReq, description, parallelizable = false) {
|
|
93
|
+
return new EvmUnsignedTransaction(addChainId(txReq, this.chainId), this.network, this.chain, description, parallelizable);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=executorV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executorV2.js","sourceRoot":"","sources":["../../../src/evm/executorV2.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,EACR,cAAc,EACd,SAAS,GACV,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EACL,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,UAAU,EACV,OAAO,GACR,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC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m/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/evm/index.ts"],"names":[],"mappings":"AAKA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
package/dist/esm/evm/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { registerProtocol } from "@wormhole-foundation/sdk-definitions";
|
|
2
2
|
import { _platform } from "@wormhole-foundation/sdk-evm";
|
|
3
3
|
import { EvmCCTPExecutor } from "./executor";
|
|
4
|
+
import { EvmCCTPv2Executor } from "./executorV2";
|
|
4
5
|
export * from "./executor";
|
|
6
|
+
export * from "./executorV2";
|
|
5
7
|
registerProtocol(_platform, "CCTPExecutor", EvmCCTPExecutor);
|
|
8
|
+
registerProtocol(_platform, "CCTPv2Executor", EvmCCTPv2Executor);
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAE7B,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;AAC7D,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,96 +1,6 @@
|
|
|
1
|
-
import type { Chain, Network } from "@wormhole-foundation/sdk-base";
|
|
2
|
-
import { amount } from "@wormhole-foundation/sdk-base";
|
|
3
|
-
import { EmptyPlatformMap, type ChainAddress, type ChainContext, type Signer, type TokenId } from "@wormhole-foundation/sdk-definitions";
|
|
4
|
-
import { routes, Wormhole } from "@wormhole-foundation/sdk-connect";
|
|
5
|
-
import { CCTPExecutor } from "./types";
|
|
6
1
|
import "./aptos/index.js";
|
|
7
2
|
import "./evm/index.js";
|
|
8
3
|
import "./sui/index.js";
|
|
9
4
|
import "./svm/index.js";
|
|
10
|
-
export
|
|
11
|
-
type Options = {
|
|
12
|
-
nativeGas?: number;
|
|
13
|
-
};
|
|
14
|
-
type NormalizedParams = {
|
|
15
|
-
amount: amount.Amount;
|
|
16
|
-
};
|
|
17
|
-
interface ValidatedParams extends routes.ValidatedTransferParams<Options> {
|
|
18
|
-
normalizedParams: NormalizedParams;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
type Op = CCTPExecutorRoute.Options;
|
|
22
|
-
type Vp = CCTPExecutorRoute.ValidatedParams;
|
|
23
|
-
type Tp = routes.TransferParams<Op>;
|
|
24
|
-
type Vr = routes.ValidationResult<Op>;
|
|
25
|
-
export type QuoteDetails = {
|
|
26
|
-
signedQuote: Uint8Array;
|
|
27
|
-
relayInstructions: Uint8Array;
|
|
28
|
-
estimatedCost: bigint;
|
|
29
|
-
referrer: ChainAddress;
|
|
30
|
-
referrerFee: bigint;
|
|
31
|
-
remainingAmount: bigint;
|
|
32
|
-
referrerFeeDbps: bigint;
|
|
33
|
-
};
|
|
34
|
-
type Q = routes.Quote<Op, Vp, QuoteDetails>;
|
|
35
|
-
type QR = routes.QuoteResult<Op, Vp>;
|
|
36
|
-
type AT = {
|
|
37
|
-
id: string;
|
|
38
|
-
attestation: {};
|
|
39
|
-
};
|
|
40
|
-
type R = routes.Receipt<AT>;
|
|
41
|
-
export declare namespace CCTPExecutorRoute {
|
|
42
|
-
type Config = {
|
|
43
|
-
referrerFeeDbps: bigint;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export declare function cctpExecutorRoute(config?: CCTPExecutorRoute.Config): {
|
|
47
|
-
new <N extends Network>(wh: Wormhole<N>): {
|
|
48
|
-
readonly staticConfig: any;
|
|
49
|
-
getDefaultOptions(): Op;
|
|
50
|
-
validate(request: routes.RouteTransferRequest<N>, params: Tp): Promise<Vr>;
|
|
51
|
-
quote(request: routes.RouteTransferRequest<N>, params: Vp): Promise<QR>;
|
|
52
|
-
initiate(request: routes.RouteTransferRequest<N>, signer: Signer, quote: Q, to: ChainAddress): Promise<R>;
|
|
53
|
-
track(receipt: R, timeout?: number): AsyncGenerator<import("@wormhole-foundation/sdk-connect").SourceInitiatedTransferReceipt<"Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").FailedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").SourceFinalizedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").AttestedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").CompletedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia">, R, unknown>;
|
|
54
|
-
wh: Wormhole<N>;
|
|
55
|
-
transferUrl(txid: string): string;
|
|
56
|
-
};
|
|
57
|
-
config: CCTPExecutorRoute.Config;
|
|
58
|
-
NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
|
|
59
|
-
meta: {
|
|
60
|
-
name: string;
|
|
61
|
-
provider: string;
|
|
62
|
-
};
|
|
63
|
-
supportedNetworks(): Network[];
|
|
64
|
-
supportedChains(network: Network): Chain[];
|
|
65
|
-
supportedDestinationTokens<N extends Network>(sourceToken: TokenId, fromChain: ChainContext<N>, toChain: ChainContext<N>): Promise<TokenId[]>;
|
|
66
|
-
IS_AUTOMATIC: boolean;
|
|
67
|
-
};
|
|
68
|
-
export declare class CCTPExecutorRoute<N extends Network> extends routes.AutomaticRoute<N, Op, Vp, R> implements routes.StaticRouteMethods<typeof CCTPExecutorRoute> {
|
|
69
|
-
static NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
|
|
70
|
-
readonly staticConfig: any;
|
|
71
|
-
static config: CCTPExecutorRoute.Config;
|
|
72
|
-
static meta: {
|
|
73
|
-
name: string;
|
|
74
|
-
provider: string;
|
|
75
|
-
};
|
|
76
|
-
static supportedNetworks(): Network[];
|
|
77
|
-
static supportedChains(network: Network): Chain[];
|
|
78
|
-
static supportedDestinationTokens<N extends Network>(sourceToken: TokenId, fromChain: ChainContext<N>, toChain: ChainContext<N>): Promise<TokenId[]>;
|
|
79
|
-
getDefaultOptions(): Op;
|
|
80
|
-
validate(request: routes.RouteTransferRequest<N>, params: Tp): Promise<Vr>;
|
|
81
|
-
quote(request: routes.RouteTransferRequest<N>, params: Vp): Promise<QR>;
|
|
82
|
-
initiate(request: routes.RouteTransferRequest<N>, signer: Signer, quote: Q, to: ChainAddress): Promise<R>;
|
|
83
|
-
track(receipt: R, timeout?: number): AsyncGenerator<import("@wormhole-foundation/sdk-connect").SourceInitiatedTransferReceipt<"Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").FailedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").SourceFinalizedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").AttestedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia"> | import("@wormhole-foundation/sdk-connect").CompletedTransferReceipt<AT, "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia", "Solana" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Algorand" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Near" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Sui" | "Aptos" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Btc" | "Base" | "Sei" | "Scroll" | "Mantle" | "Blast" | "Xlayer" | "Linea" | "Berachain" | "Seievm" | "Snaxchain" | "Unichain" | "Worldchain" | "Ink" | "HyperEVM" | "Monad" | "Mezo" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Neutron" | "Celestia" | "Stargaze" | "Seda" | "Dymension" | "Provenance" | "Noble" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" | "PolygonSepolia">, R, unknown>;
|
|
84
|
-
}
|
|
85
|
-
declare module "@wormhole-foundation/sdk-definitions" {
|
|
86
|
-
namespace WormholeRegistry {
|
|
87
|
-
interface ProtocolToInterfaceMapping<N, C> {
|
|
88
|
-
CCTPExecutor: CCTPExecutor<N, C>;
|
|
89
|
-
}
|
|
90
|
-
interface ProtocolToPlatformMapping {
|
|
91
|
-
CCTPExecutor: EmptyPlatformMap<"CCTPExecutor">;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
export {};
|
|
5
|
+
export * from "./routes";
|
|
96
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,gBAAgB,CAAC;AACxB,OAAO,gBAAgB,CAAC;AACxB,OAAO,gBAAgB,CAAC;AAExB,cAAc,UAAU,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,337 +1,7 @@
|
|
|
1
|
-
import { amount, circle, contracts, deserializeLayout, encoding, finality, serializeLayout, toChainId, } from "@wormhole-foundation/sdk-base";
|
|
2
|
-
import { isSameToken, nativeTokenId, UniversalAddress, } from "@wormhole-foundation/sdk-definitions";
|
|
3
|
-
import { isAttested, isCompleted, isFailed, isSourceFinalized, isSourceInitiated, routes, signSendWait, TransferState, Wormhole, } from "@wormhole-foundation/sdk-connect";
|
|
4
|
-
import { calculateReferrerFee, fetchCapabilities, fetchSignedQuote, fetchStatus as fetchTxStatus, RelayStatus, sleep, } from "./utils";
|
|
5
|
-
import { relayInstructionsLayout, signedQuoteLayout } from "./layouts";
|
|
6
|
-
import { gasLimits, referrers, SOLANA_MSG_VALUE_BASE_FEE } from "./consts";
|
|
7
|
-
import { SolanaAddress } from "@wormhole-foundation/sdk-solana";
|
|
8
1
|
// IMPORTANT: register the platform specific implementations of the protocol
|
|
9
2
|
import "./aptos/index.js";
|
|
10
3
|
import "./evm/index.js";
|
|
11
4
|
import "./sui/index.js";
|
|
12
5
|
import "./svm/index.js";
|
|
13
|
-
|
|
14
|
-
// cache it here to avoid fetching it from the Solana RPC
|
|
15
|
-
let ataMinRentAmount = undefined;
|
|
16
|
-
// Use this function to create a new CCTPExecutorRoute with custom config
|
|
17
|
-
export function cctpExecutorRoute(config = { referrerFeeDbps: 0n }) {
|
|
18
|
-
if (config.referrerFeeDbps < 0 || config.referrerFeeDbps > 65535n) {
|
|
19
|
-
throw new Error("Referrer fee must be between 0 and 65535");
|
|
20
|
-
}
|
|
21
|
-
class CCTPExecutorRouteImpl extends CCTPExecutorRoute {
|
|
22
|
-
static config = config;
|
|
23
|
-
}
|
|
24
|
-
return CCTPExecutorRouteImpl;
|
|
25
|
-
}
|
|
26
|
-
export class CCTPExecutorRoute extends routes.AutomaticRoute {
|
|
27
|
-
static NATIVE_GAS_DROPOFF_SUPPORTED = true;
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
// Since we set the config on the static class, access it with this param
|
|
30
|
-
// the CCTPExecutorRoute.config will always be empty
|
|
31
|
-
staticConfig = this.constructor.config;
|
|
32
|
-
static config = { referrerFeeDbps: 0n };
|
|
33
|
-
static meta = {
|
|
34
|
-
name: "CCTPExecutorRoute",
|
|
35
|
-
provider: "Circle",
|
|
36
|
-
};
|
|
37
|
-
static supportedNetworks() {
|
|
38
|
-
return ["Mainnet", "Testnet"];
|
|
39
|
-
}
|
|
40
|
-
static supportedChains(network) {
|
|
41
|
-
if (contracts.circleContractChains.has(network)) {
|
|
42
|
-
return contracts.circleContractChains.get(network);
|
|
43
|
-
}
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
static async supportedDestinationTokens(sourceToken, fromChain, toChain) {
|
|
47
|
-
// Ensure the source token is USDC
|
|
48
|
-
const sourceChainUsdcContract = circle.usdcContract.get(fromChain.network, fromChain.chain);
|
|
49
|
-
if (!(sourceChainUsdcContract &&
|
|
50
|
-
isSameToken(sourceToken, Wormhole.tokenId(fromChain.chain, sourceChainUsdcContract)))) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const { network, chain } = toChain;
|
|
54
|
-
if (!circle.usdcContract.has(network, chain))
|
|
55
|
-
return [];
|
|
56
|
-
return [
|
|
57
|
-
Wormhole.chainAddress(chain, circle.usdcContract.get(network, chain)),
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
getDefaultOptions() {
|
|
61
|
-
return {
|
|
62
|
-
nativeGas: 0,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
async validate(request, params) {
|
|
66
|
-
if (params.options?.nativeGas &&
|
|
67
|
-
(params.options.nativeGas < 0 || params.options.nativeGas > 1)) {
|
|
68
|
-
return {
|
|
69
|
-
valid: false,
|
|
70
|
-
error: new Error("Invalid native gas percentage"),
|
|
71
|
-
params,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
const validatedParams = {
|
|
75
|
-
normalizedParams: {
|
|
76
|
-
amount: request.parseAmount(params.amount),
|
|
77
|
-
},
|
|
78
|
-
options: params.options ?? this.getDefaultOptions(),
|
|
79
|
-
...params,
|
|
80
|
-
};
|
|
81
|
-
return { valid: true, params: validatedParams };
|
|
82
|
-
}
|
|
83
|
-
async quote(request, params) {
|
|
84
|
-
const { fromChain, toChain } = request;
|
|
85
|
-
const srcUsdcAddress = circle.usdcContract.get(fromChain.network, fromChain.chain);
|
|
86
|
-
if (!srcUsdcAddress) {
|
|
87
|
-
throw new Error("Invalid transfer, no USDC contract on source");
|
|
88
|
-
}
|
|
89
|
-
const dstUsdcAddress = circle.usdcContract.get(toChain.network, toChain.chain);
|
|
90
|
-
if (!dstUsdcAddress) {
|
|
91
|
-
throw new Error("Invalid transfer, no USDC contract on destination");
|
|
92
|
-
}
|
|
93
|
-
const referrerAddress = referrers[fromChain.network]?.[fromChain.chain];
|
|
94
|
-
if (!referrerAddress) {
|
|
95
|
-
return {
|
|
96
|
-
success: false,
|
|
97
|
-
error: new Error("No referrer address found"),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const referrer = Wormhole.chainAddress(fromChain.chain, referrerAddress);
|
|
101
|
-
const referrerFeeDbps = this.staticConfig.referrerFeeDbps;
|
|
102
|
-
const { referrerFee, remainingAmount } = calculateReferrerFee(amount.units(params.normalizedParams.amount), this.staticConfig.referrerFeeDbps);
|
|
103
|
-
if (remainingAmount <= 0n) {
|
|
104
|
-
return {
|
|
105
|
-
success: false,
|
|
106
|
-
error: new Error("Amount after fee <= 0"),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
const gasLimit = gasLimits[fromChain.network]?.[toChain.chain];
|
|
110
|
-
if (!gasLimit) {
|
|
111
|
-
return {
|
|
112
|
-
success: false,
|
|
113
|
-
error: new Error("Gas limit not found"),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const capabilities = await fetchCapabilities(fromChain.network);
|
|
117
|
-
const srcCapabilities = capabilities[toChainId(fromChain.chain)];
|
|
118
|
-
if (!srcCapabilities) {
|
|
119
|
-
return {
|
|
120
|
-
success: false,
|
|
121
|
-
error: new Error("Unsupported source chain"),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const dstCapabilities = capabilities[toChainId(toChain.chain)];
|
|
125
|
-
if (!dstCapabilities || !dstCapabilities.requestPrefixes.includes("ERC1")) {
|
|
126
|
-
return {
|
|
127
|
-
success: false,
|
|
128
|
-
error: new Error("Unsupported destination chain"),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const { recipient } = request;
|
|
132
|
-
let tokenAccountExists = true;
|
|
133
|
-
// Check if the associated token account (ATA) exists on Solana.
|
|
134
|
-
// If it doesn't, include a gas drop-off instruction so the relayer can create it.
|
|
135
|
-
// Note: There's a potential race condition — the account might exist during this check,
|
|
136
|
-
// but could be closed before the transfer completes.
|
|
137
|
-
if (recipient && toChain.chain === "Solana") {
|
|
138
|
-
const usdcAddress = Wormhole.parseAddress("Solana", dstUsdcAddress);
|
|
139
|
-
const ata = await toChain.getTokenAccount(recipient.address, usdcAddress);
|
|
140
|
-
const connection = await toChain.getRpc();
|
|
141
|
-
const ataAccount = await connection.getAccountInfo(new SolanaAddress(ata.address).unwrap());
|
|
142
|
-
tokenAccountExists = ataAccount !== null;
|
|
143
|
-
if (!tokenAccountExists && !ataMinRentAmount) {
|
|
144
|
-
ataMinRentAmount = BigInt(await connection.getMinimumBalanceForRentExemption(165));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
let msgValue = 0n;
|
|
148
|
-
if (toChain.chain === "Solana") {
|
|
149
|
-
msgValue += SOLANA_MSG_VALUE_BASE_FEE;
|
|
150
|
-
if (!tokenAccountExists && ataMinRentAmount) {
|
|
151
|
-
msgValue += ataMinRentAmount;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const relayRequests = [];
|
|
155
|
-
// Add the gas instruction
|
|
156
|
-
relayRequests.push({
|
|
157
|
-
request: {
|
|
158
|
-
type: "GasInstruction",
|
|
159
|
-
gasLimit,
|
|
160
|
-
msgValue,
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
// Calculate the gas dropOff value
|
|
164
|
-
const gasDropOffLimit = BigInt(dstCapabilities.gasDropOffLimit);
|
|
165
|
-
const dropOff = params.options.nativeGas && gasDropOffLimit > 0n
|
|
166
|
-
? (BigInt(Math.round(params.options.nativeGas * 100)) *
|
|
167
|
-
gasDropOffLimit) /
|
|
168
|
-
100n
|
|
169
|
-
: 0n;
|
|
170
|
-
// Add the gas drop-off instruction if applicable
|
|
171
|
-
if (dropOff > 0n || !tokenAccountExists) {
|
|
172
|
-
relayRequests.push({
|
|
173
|
-
request: {
|
|
174
|
-
type: "GasDropOffInstruction",
|
|
175
|
-
dropOff,
|
|
176
|
-
// If the recipient is undefined (e.g. the user hasn’t connected their wallet yet),
|
|
177
|
-
// we temporarily use a dummy address to fetch a quote.
|
|
178
|
-
// The recipient address is validated later in the `initiate` method, which will throw if it's still missing.
|
|
179
|
-
recipient: recipient
|
|
180
|
-
? recipient.address.toUniversalAddress()
|
|
181
|
-
: new UniversalAddress(new Uint8Array(32)),
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
const relayInstructions = serializeLayout(relayInstructionsLayout, {
|
|
186
|
-
requests: relayRequests,
|
|
187
|
-
});
|
|
188
|
-
const quote = await fetchSignedQuote(fromChain.network, fromChain.chain, toChain.chain, encoding.hex.encode(relayInstructions, true));
|
|
189
|
-
if (!quote.estimatedCost) {
|
|
190
|
-
return {
|
|
191
|
-
success: false,
|
|
192
|
-
error: new Error("No estimated cost"),
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
const signedQuoteBytes = encoding.hex.decode(quote.signedQuote);
|
|
196
|
-
const signedQuote = deserializeLayout(signedQuoteLayout, signedQuoteBytes);
|
|
197
|
-
// https://developers.circle.com/stablecoins/docs/required-block-confirmations
|
|
198
|
-
const eta = fromChain.chain === "Polygon"
|
|
199
|
-
? 2_000 * 200
|
|
200
|
-
: finality.estimateFinalityTime(fromChain.chain) + 1_000; // buffer for the relayer
|
|
201
|
-
const estimatedCost = BigInt(quote.estimatedCost);
|
|
202
|
-
const details = {
|
|
203
|
-
signedQuote: signedQuoteBytes,
|
|
204
|
-
relayInstructions: relayInstructions,
|
|
205
|
-
estimatedCost,
|
|
206
|
-
referrer,
|
|
207
|
-
referrerFee,
|
|
208
|
-
remainingAmount,
|
|
209
|
-
referrerFeeDbps,
|
|
210
|
-
};
|
|
211
|
-
const [srcNativeDecimals, dstNativeDecimals] = await Promise.all([
|
|
212
|
-
fromChain.getDecimals("native"),
|
|
213
|
-
toChain.getDecimals("native"),
|
|
214
|
-
]);
|
|
215
|
-
return {
|
|
216
|
-
success: true,
|
|
217
|
-
params,
|
|
218
|
-
sourceToken: {
|
|
219
|
-
token: request.source.id,
|
|
220
|
-
amount: params.normalizedParams.amount,
|
|
221
|
-
},
|
|
222
|
-
destinationToken: {
|
|
223
|
-
token: request.destination.id,
|
|
224
|
-
amount: amount.fromBaseUnits(remainingAmount, request.destination.decimals),
|
|
225
|
-
},
|
|
226
|
-
relayFee: {
|
|
227
|
-
token: nativeTokenId(fromChain.chain),
|
|
228
|
-
amount: amount.fromBaseUnits(estimatedCost, srcNativeDecimals),
|
|
229
|
-
},
|
|
230
|
-
destinationNativeGas: amount.fromBaseUnits(dropOff, dstNativeDecimals),
|
|
231
|
-
eta,
|
|
232
|
-
expires: signedQuote.quote.expiryTime,
|
|
233
|
-
details,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
async initiate(request, signer, quote, to) {
|
|
237
|
-
if (!quote.details) {
|
|
238
|
-
throw new Error("Missing quote details");
|
|
239
|
-
}
|
|
240
|
-
const relayInstructions = deserializeLayout(relayInstructionsLayout, quote.details.relayInstructions);
|
|
241
|
-
// Make sure that the gas drop-off recipient matches the actual recipient
|
|
242
|
-
relayInstructions.requests.forEach(({ request }) => {
|
|
243
|
-
if (request.type === "GasDropOffInstruction" &&
|
|
244
|
-
!request.recipient.equals(to.address.toUniversalAddress())) {
|
|
245
|
-
throw new Error("Gas drop-off recipient does not match");
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
const executor = await request.fromChain.getProtocol("CCTPExecutor");
|
|
249
|
-
const sender = Wormhole.parseAddress(signer.chain(), signer.address());
|
|
250
|
-
// When transferring to Solana, the recipient address is the ATA for CCTP transfers
|
|
251
|
-
let cctpRecipient = to;
|
|
252
|
-
if (to.chain === "Solana") {
|
|
253
|
-
const usdcAddress = Wormhole.parseAddress("Solana", circle.usdcContract.get(request.toChain.network, request.toChain.chain));
|
|
254
|
-
cctpRecipient = await request.toChain.getTokenAccount(to.address, usdcAddress);
|
|
255
|
-
}
|
|
256
|
-
const xfer = await executor.transfer(sender, cctpRecipient, quote.details);
|
|
257
|
-
const txids = await signSendWait(request.fromChain, xfer, signer);
|
|
258
|
-
// Status the transfer immediately before returning
|
|
259
|
-
let statusAttempts = 0;
|
|
260
|
-
const statusTransferImmediately = async () => {
|
|
261
|
-
while (statusAttempts < 20) {
|
|
262
|
-
try {
|
|
263
|
-
const [txStatus] = await fetchTxStatus(this.wh.network, txids.at(-1).txid, request.fromChain.chain);
|
|
264
|
-
if (txStatus) {
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
catch (_) {
|
|
269
|
-
// is ok we just try again!
|
|
270
|
-
}
|
|
271
|
-
statusAttempts++;
|
|
272
|
-
await sleep(2_000);
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
// Spawn a loop in the background that will status this transfer until
|
|
276
|
-
// the API gives a successful response. We don't await the result
|
|
277
|
-
// here because we don't need it for the return value.
|
|
278
|
-
statusTransferImmediately();
|
|
279
|
-
return {
|
|
280
|
-
from: request.fromChain.chain,
|
|
281
|
-
to: request.toChain.chain,
|
|
282
|
-
state: TransferState.SourceInitiated,
|
|
283
|
-
originTxs: txids,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
async *track(receipt, timeout) {
|
|
287
|
-
if (isCompleted(receipt) || isFailed(receipt))
|
|
288
|
-
return receipt;
|
|
289
|
-
let leftover = timeout ? timeout : 60 * 60 * 1000;
|
|
290
|
-
while (leftover > 0) {
|
|
291
|
-
const start = Date.now();
|
|
292
|
-
if (isSourceInitiated(receipt) ||
|
|
293
|
-
isSourceFinalized(receipt) ||
|
|
294
|
-
isAttested(receipt)) {
|
|
295
|
-
try {
|
|
296
|
-
const [txStatus] = await fetchTxStatus(this.wh.network, receipt.originTxs.at(-1).txid, receipt.from);
|
|
297
|
-
if (!txStatus) {
|
|
298
|
-
throw new Error("No transaction status found");
|
|
299
|
-
}
|
|
300
|
-
const relayStatus = txStatus?.status;
|
|
301
|
-
if (relayStatus === RelayStatus.Failed || // this could happen if simulation fails
|
|
302
|
-
relayStatus === RelayStatus.Underpaid || // only happens if you don't pay at least the costEstimate
|
|
303
|
-
relayStatus === RelayStatus.Unsupported || // capabilities check didn't pass
|
|
304
|
-
relayStatus === RelayStatus.Aborted // An unrecoverable error indicating the attempt should stop (bad data, pre-flight checks failed, or chain-specific conditions)
|
|
305
|
-
) {
|
|
306
|
-
receipt = {
|
|
307
|
-
...receipt,
|
|
308
|
-
state: TransferState.Failed,
|
|
309
|
-
error: new routes.RelayFailedError(`Relay failed with status: ${relayStatus}`),
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
if (relayStatus === RelayStatus.Submitted) {
|
|
313
|
-
receipt = {
|
|
314
|
-
...receipt,
|
|
315
|
-
state: TransferState.DestinationFinalized,
|
|
316
|
-
attestation: { id: txStatus.id, attestation: {} },
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
// Important to yield before checking for completion
|
|
320
|
-
// so the caller can update the receipt state
|
|
321
|
-
yield receipt;
|
|
322
|
-
if (isCompleted(receipt) || isFailed(receipt)) {
|
|
323
|
-
return receipt;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
catch (error) {
|
|
327
|
-
console.error(`Error fetching transaction status: ${error.message || error}`);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
// Sleep so we don't spam the endpoint
|
|
331
|
-
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
332
|
-
leftover -= Date.now() - start;
|
|
333
|
-
}
|
|
334
|
-
return receipt;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
6
|
+
export * from "./routes";
|
|
337
7
|
//# sourceMappingURL=index.js.map
|