@wormhole-foundation/wormhole-connect 3.0.0-beta.4-development → 3.0.0-beta.6-development
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/main.js +48 -48
- package/dist/src/config/tokens.d.ts +10 -3
- package/dist/src/config/tokens.d.ts.map +1 -1
- package/dist/src/exports/executor.d.ts +1 -1
- package/dist/src/exports/executor.d.ts.map +1 -1
- package/dist/src/utils/coingecko.d.ts.map +1 -1
- package/dist/src/utils/sdkv2.d.ts +1 -1
- package/dist/src/utils/sdkv2.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/AssetPicker/TokenList.d.ts +0 -2
- package/dist/src/views/v2/Bridge/AssetPicker/TokenList.d.ts.map +1 -1
- package/lib/{account-CKUCmcgT.mjs → account-BK8xMTUI.mjs} +1 -1
- package/lib/{address-Cj96wodd.mjs → address-BWXkejmE.mjs} +1 -1
- package/lib/{address-Drr_9OcK.mjs → address-CBux52Na.mjs} +2 -2
- package/lib/{address-B9anhmbU.mjs → address-DKHa7TFU.mjs} +1 -1
- package/lib/{aptos-DPIwkCrX.mjs → aptos-C180o9od.mjs} +7 -7
- package/lib/{aptos-CUrw_CM5.js → aptos-C2O9KvSO.js} +1 -1
- package/lib/{aptos-CMqi9xnz.mjs → aptos-Tbz2BmSl.mjs} +3 -3
- package/lib/{base64-BcnUThiU.mjs → base64-Dmj19Uvu.mjs} +1 -1
- package/lib/{blake2b-CnkNeJT4.mjs → blake2b-CgbIfNRX.mjs} +1 -1
- package/lib/{browser-ponyfill-oWZrCgRw.mjs → browser-ponyfill-BecG2Lnb.mjs} +1 -1
- package/lib/{ccip-DjEPg__u.mjs → ccip--upk5QVD.mjs} +1 -1
- package/lib/{ccip-tbJnHDO1.js → ccip-C1fv-O-z.js} +1 -1
- package/lib/{chain-CNVMEdrk.mjs → chain-sKZNJgPZ.mjs} +1 -1
- package/lib/{chunk-IMTC3J2M-B7fKwIuX.mjs → chunk-IMTC3J2M-DKLPKqnP.mjs} +3 -3
- package/lib/constants-5BAG78ih.js +1 -0
- package/lib/{constants-uvbe2N_4.mjs → constants-DokEy4aZ.mjs} +1 -1
- package/lib/{contract-DANWVftx.mjs → contract-BVaUamai.mjs} +1 -1
- package/lib/{create-B9LwWha4.mjs → create-CQ6n4Ga8.mjs} +1 -1
- package/lib/{evm-C51GRwXY.mjs → evm-8qap-w_A.mjs} +9 -9
- package/lib/{evm-B552wdhN.mjs → evm-C-aa4dBG.mjs} +9 -9
- package/lib/{evm-D-QB4hVf.js → evm-DEyDcOVJ.js} +3 -3
- package/lib/executor.js +1 -1
- package/lib/executor.mjs +226 -212
- package/lib/hosted.js +1 -1
- package/lib/hosted.mjs +1 -1
- package/lib/{index-Dw7INWis.mjs → index-07cEoDZD.mjs} +4 -4
- package/lib/{index-DoFo485M.mjs → index-B36we0ml.mjs} +7 -7
- package/lib/{index-CKg04pdA.mjs → index-B5XhLD_L.mjs} +5 -5
- package/lib/{index-CUZbT8Rs.js → index-B8P7Hgys.js} +79 -79
- package/lib/{index-BR4w3fuE.mjs → index-B9hin5U8.mjs} +5 -5
- package/lib/{index-CGHEayyy.mjs → index-BRWDo8jM.mjs} +7869 -7853
- package/lib/{index-CEXcD8Mw.mjs → index-BUfjw4S2.mjs} +4 -4
- package/lib/{index-DHAgduQ-.mjs → index-BUlzgqNa.mjs} +4 -4
- package/lib/{index-4UEV-pyS.js → index-B__hvnhZ.js} +1 -1
- package/lib/{index-BlJpOhTM.mjs → index-Batb-GTa.mjs} +5 -5
- package/lib/{index-CT2-qOL1.mjs → index-Bb8InrQU.mjs} +2 -2
- package/lib/{index-xc0U6vWT.js → index-CHRRy38m.js} +1 -1
- package/lib/{index-B4NYDFvU.mjs → index-CKaF7Gzs.mjs} +5 -5
- package/lib/{index-CYdhveYx.mjs → index-CLy98PXT.mjs} +6 -6
- package/lib/{index-DSSOE7Me.mjs → index-CjroDahP.mjs} +2 -2
- package/lib/{index-DD-AZ3hI.mjs → index-CrB-LSo2.mjs} +5 -5
- package/lib/{index-BO0DC-jc.mjs → index-Cry2AYTm.mjs} +3 -3
- package/lib/{index-pN0Dgjjf.mjs → index-CsdQttEt.mjs} +5 -5
- package/lib/{index-C9XIIFQK.mjs → index-Cu7gFSJv.mjs} +1 -1
- package/lib/{index-mXHkgOxH.mjs → index-Cx-ODuWg.mjs} +4 -4
- package/lib/{index-C7eKFnUC.mjs → index-D2Qb4LZn.mjs} +5 -5
- package/lib/{index-DQ5bBanH.js → index-D9a8BHae.js} +1 -1
- package/lib/{index-CM_IP492.mjs → index-DDBLdcME.mjs} +6 -6
- package/lib/{index-BAuH_G93.mjs → index-DNcx7dMI.mjs} +5 -5
- package/lib/{index-l0sxQXRT.mjs → index-DRleG63r.mjs} +1 -1
- package/lib/{index-DlREYA36.mjs → index-DcdFOYPU.mjs} +2 -2
- package/lib/{index-CfC3_uPF.mjs → index-DdvRmaTh.mjs} +7 -7
- package/lib/{index-BQ0RlDhv.mjs → index-DgIxcujP.mjs} +6 -6
- package/lib/{index-CCRPy0B_.mjs → index-DyvQhGPY.mjs} +2 -2
- package/lib/{index-B1XGfrNH.mjs → index-aA-2Ygs3.mjs} +1 -1
- package/lib/{index-2f5GRlqp.mjs → index-rAnJYuJr.mjs} +1 -1
- package/lib/{index.es-BmrEYzpc.js → index.es-DV3kw9DJ.js} +1 -1
- package/lib/{index.es-CWb9-nuQ.mjs → index.es-r3IXysvk.mjs} +7 -7
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/mayan.mjs +10 -10
- package/lib/{mint-DVxIczlI.mjs → mint-C3SdQH_S.mjs} +2 -2
- package/lib/ntt.mjs +10 -10
- package/lib/{platform-D-nUFU0e.mjs → platform-CUeBR_i4.mjs} +4 -4
- package/lib/{platform-PaIJsXKV.mjs → platform-Czq0KkFa.mjs} +4 -4
- package/lib/{platform-CbDx4hex.mjs → platform-Droe0nZu.mjs} +4 -4
- package/lib/{provider-jsonrpc-C_IZFSfB.mjs → provider-jsonrpc-CVWSLk8g.mjs} +2 -2
- package/lib/{sha3-DQQvDwj1.mjs → sha3-BMK6V2DM.mjs} +1 -1
- package/lib/{signer-CsMX8mEc.mjs → signer-CYkXKdE1.mjs} +2 -2
- package/lib/solana-Bs7_C3BS.mjs +18 -0
- package/lib/{solana-CdLrMjvN.mjs → solana-C6mhiYEU.mjs} +6 -6
- package/lib/{solana-Bo3NnEnJ.js → solana-CodmCaKY.js} +1 -1
- package/lib/{solanaEmbed.esm-CYlp6Icj.js → solanaEmbed.esm-CM5KEZzA.js} +1 -1
- package/lib/{solanaEmbed.esm-DiWgOIVr.mjs → solanaEmbed.esm-RbUXbhhE.mjs} +3 -3
- package/lib/src/config/tokens.d.ts +10 -3
- package/lib/src/config/tokens.d.ts.map +1 -1
- package/lib/src/exports/executor.d.ts +1 -1
- package/lib/src/exports/executor.d.ts.map +1 -1
- package/lib/src/utils/coingecko.d.ts.map +1 -1
- package/lib/src/utils/sdkv2.d.ts +1 -1
- package/lib/src/utils/sdkv2.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/AssetPicker/TokenList.d.ts +0 -2
- package/lib/src/views/v2/Bridge/AssetPicker/TokenList.d.ts.map +1 -1
- package/lib/{sui-BSLo7-bI.mjs → sui-BJsKaZg2.mjs} +8 -8
- package/lib/{sui-z1y1QOrV.js → sui-CL39dOHl.js} +1 -1
- package/lib/{sui-CXBd6k8g.mjs → sui-CNae24HH.mjs} +3 -3
- package/lib/{tokens-C9OdyBk_.js → tokens-BnT3LJzY.js} +1 -1
- package/lib/{tokens-GzwBLIsP.mjs → tokens-Bz4eEen0.mjs} +4 -4
- package/lib/{units-DP5zqyxn.mjs → units-YkCOGDr9.mjs} +2 -2
- package/lib/{unsignedTransaction-fSrwDjHx.mjs → unsignedTransaction-C0WXQMmv.mjs} +3 -3
- package/lib/{web3-DCo8oN-v.mjs → web3-B3Usc-Qj.mjs} +1 -1
- package/package.json +2 -2
- package/lib/constants-D8PkP8FD.js +0 -1
- package/lib/solana-C_0khyJw.mjs +0 -18
package/lib/executor.mjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (e, n, t) =>
|
|
4
|
-
import { az as
|
|
5
|
-
import { r as M } from "./chain-
|
|
6
|
-
import { l as oe } from "./chunk-IMTC3J2M-
|
|
7
|
-
import { A as
|
|
8
|
-
import { A as
|
|
9
|
-
import { A as
|
|
10
|
-
import { E as ce } from "./platform-
|
|
11
|
-
import { C as
|
|
12
|
-
import { E as
|
|
13
|
-
import { b as de, T as
|
|
14
|
-
import { suiCircleObjects as
|
|
15
|
-
import { S as
|
|
16
|
-
import { S as
|
|
17
|
-
import { createDepositForBurnInstruction as
|
|
18
|
-
import { P as
|
|
19
|
-
import { p as ue, u as Ae, b as
|
|
20
|
-
import { a as
|
|
21
|
-
import { d as
|
|
22
|
-
const
|
|
1
|
+
var Me = Object.defineProperty;
|
|
2
|
+
var Ie = (e, n, t) => n in e ? Me(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var c = (e, n, t) => Ie(e, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { az as O, aP as C, aJ as Be, E as w, b4 as P, aF as ze, aR as Te, aU as te, aV as Ue, aW as Re, v as _e, ae as p, ar as be, aG as re, au as we, d as D, an as Ne, as as Ce, b1 as N, b2 as $e, ao as ke, a_ as $, aX as Oe, b3 as Ge, A as Le, D as se, F as Qe, W as S, u as qe, _ as We, aN as je, a3 as ne, y as Ve, f as R, af as Ke, z as Xe, T as _, i as ae, aj as ie, B as Je, C as He, e as Ze } from "./address-CBux52Na.mjs";
|
|
5
|
+
import { r as M } from "./chain-sKZNJgPZ.mjs";
|
|
6
|
+
import { l as oe } from "./chunk-IMTC3J2M-DKLPKqnP.mjs";
|
|
7
|
+
import { A as Ye } from "./platform-Czq0KkFa.mjs";
|
|
8
|
+
import { A as et, _ as tt } from "./address-BWXkejmE.mjs";
|
|
9
|
+
import { A as rt } from "./unsignedTransaction-BDOQhqcZ.mjs";
|
|
10
|
+
import { E as ce } from "./platform-CUeBR_i4.mjs";
|
|
11
|
+
import { C as st } from "./contract-BVaUamai.mjs";
|
|
12
|
+
import { E as nt } from "./unsignedTransaction-C0V0UbsS.mjs";
|
|
13
|
+
import { b as de, T as at, a as it, _ as ot } from "./platform-Droe0nZu.mjs";
|
|
14
|
+
import { suiCircleObjects as ct } from "./index-Cry2AYTm.mjs";
|
|
15
|
+
import { S as dt, R as ut } from "./address-DKHa7TFU.mjs";
|
|
16
|
+
import { S as ft } from "./unsignedTransaction-BD81leu1.mjs";
|
|
17
|
+
import { createDepositForBurnInstruction as mt } from "./index-B9hin5U8.mjs";
|
|
18
|
+
import { P as ht } from "./index-DRleG63r.mjs";
|
|
19
|
+
import { p as ue, u as Ae, b as lt } from "./web3-B3Usc-Qj.mjs";
|
|
20
|
+
import { a as gt, S as pt } from "./unsignedTransaction-C0WXQMmv.mjs";
|
|
21
|
+
import { d as bt } from "./account-BK8xMTUI.mjs";
|
|
22
|
+
const G = {
|
|
23
23
|
Testnet: "https://executor-testnet.labsapis.com",
|
|
24
24
|
Mainnet: "https://executor.labsapis.com"
|
|
25
|
-
},
|
|
25
|
+
}, L = {
|
|
26
26
|
Testnet: {
|
|
27
27
|
Aptos: "0x14a12d1fd6ef371b70c2113155534ec152ec7f779e281b54866c796c9a4a58d3",
|
|
28
28
|
Avalanche: "0x2cfEC91B50f657Cc86Ec693542527ac3e03bF742",
|
|
@@ -50,7 +50,7 @@ const k = {
|
|
|
50
50
|
executorId: "0xdb0fe8bb1e2b5be628adbea0636063325073e1070ee11e4281457dfd7f158235",
|
|
51
51
|
executorRequestsId: "0xc030df7a3eed1494fa4b64aa8ab63a79041cf1114f4ff2b7ab5aca1c684a21a7"
|
|
52
52
|
}
|
|
53
|
-
},
|
|
53
|
+
}, wt = {
|
|
54
54
|
Testnet: "execXUrAsMnqMmTHj5m7N1YQgsDz3cwGLYCYyuDRciV",
|
|
55
55
|
Mainnet: "execXUrAsMnqMmTHj5m7N1YQgsDz3cwGLYCYyuDRciV"
|
|
56
56
|
}, Ct = 5001n, At = {
|
|
@@ -74,7 +74,7 @@ const k = {
|
|
|
74
74
|
Solana: 250000n,
|
|
75
75
|
Sui: 8000000n
|
|
76
76
|
}
|
|
77
|
-
},
|
|
77
|
+
}, yt = {
|
|
78
78
|
Testnet: {
|
|
79
79
|
Aptos: "0x23b54f6e29bba7f4123d088f4cfcd83f5e23a049de15895b119ce5a6cb5faa91",
|
|
80
80
|
Avalanche: "0x8F26A0025dcCc6Cfc07A7d38756280a10E295ad7",
|
|
@@ -96,22 +96,22 @@ const k = {
|
|
|
96
96
|
Unichain: "0xF11e0efF8b11Ce382645dd75352fC16b3aB3551E"
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
var
|
|
99
|
+
var A;
|
|
100
100
|
(function(e) {
|
|
101
101
|
e.Pending = "pending", e.Failed = "failed", e.Unsupported = "unsupported", e.Submitted = "submitted", e.Underpaid = "underpaid", e.Aborted = "aborted";
|
|
102
|
-
})(
|
|
103
|
-
async function
|
|
104
|
-
const n = `${
|
|
102
|
+
})(A || (A = {}));
|
|
103
|
+
async function xt(e) {
|
|
104
|
+
const n = `${G[e]}/v0/capabilities`;
|
|
105
105
|
try {
|
|
106
|
-
return (await
|
|
106
|
+
return (await O.get(n)).data;
|
|
107
107
|
} catch {
|
|
108
108
|
throw new Error(`Failed to fetch capabilities for network: ${e}.`);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
async function Et(e, n, t, r) {
|
|
112
|
-
const s = `${
|
|
112
|
+
const s = `${G[e]}/v0/quote`;
|
|
113
113
|
try {
|
|
114
|
-
return (await
|
|
114
|
+
return (await O.post(s, {
|
|
115
115
|
srcChain: C(n),
|
|
116
116
|
dstChain: C(t),
|
|
117
117
|
relayInstructions: r
|
|
@@ -120,10 +120,10 @@ async function Et(e, n, t, r) {
|
|
|
120
120
|
throw new Error("Failed to fetch signed quote.");
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
async function
|
|
124
|
-
const r = `${
|
|
123
|
+
async function me(e, n, t) {
|
|
124
|
+
const r = `${G[e]}/v0/status/tx`;
|
|
125
125
|
try {
|
|
126
|
-
return (await
|
|
126
|
+
return (await O.post(r, {
|
|
127
127
|
txHash: n,
|
|
128
128
|
chainId: C(t)
|
|
129
129
|
})).data;
|
|
@@ -141,35 +141,38 @@ function vt(e, n) {
|
|
|
141
141
|
}
|
|
142
142
|
return { referrerFee: 0n, remainingAmount: e };
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
function Ft(e) {
|
|
145
|
+
return new Promise((n) => setTimeout(n, e));
|
|
146
|
+
}
|
|
147
|
+
const Dt = [
|
|
145
148
|
{ name: "gasLimit", binary: "uint", size: 16 },
|
|
146
149
|
{ name: "msgValue", binary: "uint", size: 16 }
|
|
147
|
-
],
|
|
150
|
+
], Pt = [
|
|
148
151
|
{ name: "dropOff", binary: "uint", size: 16 },
|
|
149
152
|
{ name: "recipient", ...Be }
|
|
150
|
-
],
|
|
153
|
+
], Mt = [
|
|
151
154
|
{
|
|
152
155
|
name: "request",
|
|
153
156
|
binary: "switch",
|
|
154
157
|
idSize: 1,
|
|
155
158
|
idTag: "type",
|
|
156
159
|
layouts: [
|
|
157
|
-
[[1, "GasInstruction"],
|
|
158
|
-
[[2, "GasDropOffInstruction"],
|
|
160
|
+
[[1, "GasInstruction"], Dt],
|
|
161
|
+
[[2, "GasDropOffInstruction"], Pt]
|
|
159
162
|
]
|
|
160
163
|
}
|
|
161
|
-
],
|
|
164
|
+
], he = [
|
|
162
165
|
{
|
|
163
166
|
name: "requests",
|
|
164
167
|
binary: "array",
|
|
165
|
-
layout:
|
|
168
|
+
layout: Mt
|
|
166
169
|
}
|
|
167
170
|
];
|
|
168
|
-
var
|
|
171
|
+
var le;
|
|
169
172
|
(function(e) {
|
|
170
173
|
e.ERM1 = "ERM1", e.ERV1 = "ERV1", e.ERN1 = "ERN1", e.ERC1 = "ERC1";
|
|
171
|
-
})(
|
|
172
|
-
const
|
|
174
|
+
})(le || (le = {}));
|
|
175
|
+
const It = {
|
|
173
176
|
to: (e) => new Date(Number(e * 1000n)),
|
|
174
177
|
from: (e) => BigInt(e.getTime()) / 1000n
|
|
175
178
|
}, Bt = [
|
|
@@ -198,7 +201,7 @@ const Mt = {
|
|
|
198
201
|
name: "expiryTime",
|
|
199
202
|
binary: "uint",
|
|
200
203
|
size: 8,
|
|
201
|
-
custom:
|
|
204
|
+
custom: It
|
|
202
205
|
},
|
|
203
206
|
{ name: "baseFee", binary: "uint", size: 8 },
|
|
204
207
|
{ name: "dstGasPrice", binary: "uint", size: 8 },
|
|
@@ -208,11 +211,11 @@ const Mt = {
|
|
|
208
211
|
]
|
|
209
212
|
]
|
|
210
213
|
}
|
|
211
|
-
],
|
|
214
|
+
], ye = [
|
|
212
215
|
...Bt,
|
|
213
216
|
{ name: "signature", binary: "bytes", size: 65 }
|
|
214
217
|
];
|
|
215
|
-
class
|
|
218
|
+
class Q {
|
|
216
219
|
constructor(n, t, r, s) {
|
|
217
220
|
c(this, "network");
|
|
218
221
|
c(this, "chain");
|
|
@@ -222,49 +225,49 @@ class L {
|
|
|
222
225
|
c(this, "shimContract");
|
|
223
226
|
var o;
|
|
224
227
|
if (this.network = n, this.chain = t, this.provider = r, this.contracts = s, n === "Devnet")
|
|
225
|
-
throw new Error("
|
|
226
|
-
const a =
|
|
228
|
+
throw new Error("CCTPExecutor not supported on Devnet");
|
|
229
|
+
const a = w.get(this.network, this.chain);
|
|
227
230
|
if (!a)
|
|
228
231
|
throw new Error(`No USDC contract configured for network=${this.network} chain=${this.chain}`);
|
|
229
232
|
this.usdcId = a;
|
|
230
|
-
const i = (o =
|
|
233
|
+
const i = (o = L[n]) == null ? void 0 : o[t];
|
|
231
234
|
if (!i)
|
|
232
235
|
throw new Error(`Shim contract for ${t} not found`);
|
|
233
236
|
this.shimContract = i;
|
|
234
237
|
}
|
|
235
238
|
static async fromRpc(n, t) {
|
|
236
|
-
const [r, s] = await
|
|
239
|
+
const [r, s] = await Ye.chainFromRpc(n), a = t[s];
|
|
237
240
|
if (!a)
|
|
238
241
|
throw new Error(`No config found for ${s}`);
|
|
239
242
|
if (a.network !== r)
|
|
240
243
|
throw new Error(`Network mismatch: ${a.network} != ${r}`);
|
|
241
|
-
return new
|
|
244
|
+
return new Q(r, s, n, a.contracts);
|
|
242
245
|
}
|
|
243
246
|
async *transfer(n, t, r) {
|
|
244
|
-
const s = new
|
|
247
|
+
const s = new et(n).unwrap(), a = oe.from(t.address.toUniversalAddress().toUint8Array()), i = oe.from(this.usdcId), o = r.remainingAmount + r.referrerFee, d = P.get(this.network, t.chain), u = s, m = s, l = [
|
|
245
248
|
o,
|
|
246
249
|
d,
|
|
247
250
|
a.toString(),
|
|
248
251
|
i.toString(),
|
|
249
252
|
r.estimatedCost,
|
|
250
253
|
C(t.chain),
|
|
251
|
-
|
|
254
|
+
u,
|
|
252
255
|
r.signedQuote,
|
|
253
256
|
r.relayInstructions,
|
|
254
257
|
r.referrerFeeDbps,
|
|
255
258
|
m
|
|
256
|
-
],
|
|
259
|
+
], f = {
|
|
257
260
|
function: `${this.shimContract}::cctp_v1_with_executor::deposit_for_burn_entry`,
|
|
258
|
-
functionArguments:
|
|
261
|
+
functionArguments: l
|
|
259
262
|
};
|
|
260
|
-
yield this.createUnsignedTx(
|
|
263
|
+
yield this.createUnsignedTx(f, "AtposCCTPExecutor.Transfer");
|
|
261
264
|
}
|
|
262
265
|
createUnsignedTx(n, t, r = !1) {
|
|
263
|
-
return new
|
|
266
|
+
return new rt(n, this.network, this.chain, t, r);
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
|
-
M(
|
|
267
|
-
class
|
|
269
|
+
M(tt, "CCTPExecutor", Q);
|
|
270
|
+
class q {
|
|
268
271
|
constructor(n, t, r, s) {
|
|
269
272
|
c(this, "network");
|
|
270
273
|
c(this, "chain");
|
|
@@ -274,9 +277,9 @@ class Q {
|
|
|
274
277
|
c(this, "shimContract");
|
|
275
278
|
var i;
|
|
276
279
|
if (this.network = n, this.chain = t, this.provider = r, this.contracts = s, n === "Devnet")
|
|
277
|
-
throw new Error("
|
|
278
|
-
this.chainId =
|
|
279
|
-
const a = (i =
|
|
280
|
+
throw new Error("CCTPExecutor not supported on Devnet");
|
|
281
|
+
this.chainId = ze.get(n, t);
|
|
282
|
+
const a = (i = L[n]) == null ? void 0 : i[t];
|
|
280
283
|
if (!a)
|
|
281
284
|
throw new Error(`Shim contract for ${t} not found`);
|
|
282
285
|
this.shimContract = a;
|
|
@@ -285,17 +288,17 @@ class Q {
|
|
|
285
288
|
const [r, s] = await ce.chainFromRpc(n), a = t[s];
|
|
286
289
|
if (a.network !== r)
|
|
287
290
|
throw new Error(`Network mismatch: ${a.network} != ${r}`);
|
|
288
|
-
return new
|
|
291
|
+
return new q(r, s, n, a.contracts);
|
|
289
292
|
}
|
|
290
293
|
async *transfer(n, t, r) {
|
|
291
|
-
const s = new
|
|
294
|
+
const s = new Te(n).toString(), a = t.address.toUniversalAddress().toUint8Array(), i = r.remainingAmount + r.referrerFee, o = w.get(this.network, this.chain), d = ce.getTokenImplementation(this.provider, o);
|
|
292
295
|
if (await d.allowance(s, this.shimContract) < i) {
|
|
293
|
-
const
|
|
294
|
-
yield this.createUnsignedTx(te(
|
|
296
|
+
const g = await d.approve.populateTransaction(this.shimContract, i);
|
|
297
|
+
yield this.createUnsignedTx(te(g, s), "ERC20.approve of EvmCCTPExecutor", !1);
|
|
295
298
|
}
|
|
296
299
|
const m = [
|
|
297
300
|
"function depositForBurn(uint256 amount, uint16 destinationChain, uint32 destinationDomain, bytes32 mintRecipient, address burnToken, (address refundAddress, bytes signedQuote, bytes instructions) executorArgs, (uint16 dbps, address payee) feeArgs) external payable returns (uint64 nonce)"
|
|
298
|
-
],
|
|
301
|
+
], f = await new st(this.shimContract, m, this.provider).getFunction("depositForBurn").populateTransaction(i, C(t.chain), P.get(this.network, t.chain), a, o, {
|
|
299
302
|
refundAddress: s,
|
|
300
303
|
signedQuote: r.signedQuote,
|
|
301
304
|
instructions: r.relayInstructions
|
|
@@ -303,14 +306,14 @@ class Q {
|
|
|
303
306
|
dbps: r.referrerFeeDbps,
|
|
304
307
|
payee: r.referrer.address.toString()
|
|
305
308
|
});
|
|
306
|
-
|
|
309
|
+
f.value = r.estimatedCost, yield this.createUnsignedTx(te(f, s), "EvmCCTPExecutor.depositForBurn");
|
|
307
310
|
}
|
|
308
311
|
createUnsignedTx(n, t, r = !1) {
|
|
309
|
-
return new
|
|
312
|
+
return new nt(Ue(n, this.chainId), this.network, this.chain, t, r);
|
|
310
313
|
}
|
|
311
314
|
}
|
|
312
|
-
M(
|
|
313
|
-
class
|
|
315
|
+
M(Re, "CCTPExecutor", q);
|
|
316
|
+
class W {
|
|
314
317
|
constructor(n, t, r, s) {
|
|
315
318
|
c(this, "network");
|
|
316
319
|
c(this, "chain");
|
|
@@ -324,44 +327,44 @@ class q {
|
|
|
324
327
|
c(this, "messageTransmitterStateId");
|
|
325
328
|
c(this, "executorId");
|
|
326
329
|
c(this, "executorRequestsId");
|
|
327
|
-
var
|
|
330
|
+
var u, m, l, f;
|
|
328
331
|
if (this.network = n, this.chain = t, this.provider = r, this.contracts = s, n === "Devnet")
|
|
329
|
-
throw new Error("
|
|
330
|
-
const a = (
|
|
331
|
-
if (!
|
|
332
|
-
throw new Error(
|
|
333
|
-
return
|
|
332
|
+
throw new Error("CCTPExecutor not supported on Devnet");
|
|
333
|
+
const a = (g, h) => {
|
|
334
|
+
if (!g)
|
|
335
|
+
throw new Error(h);
|
|
336
|
+
return g;
|
|
334
337
|
};
|
|
335
|
-
this.usdcId = a(
|
|
336
|
-
const { tokenMessengerState: i, messageTransmitterState: o, usdcTreasury: d } =
|
|
337
|
-
this.usdcTreasuryId = d, this.tokenMessengerId = a((
|
|
338
|
+
this.usdcId = a(w.get(this.network, this.chain), `No USDC contract configured for network=${this.network} chain=${this.chain}`);
|
|
339
|
+
const { tokenMessengerState: i, messageTransmitterState: o, usdcTreasury: d } = ct(n);
|
|
340
|
+
this.usdcTreasuryId = d, this.tokenMessengerId = a((u = s.cctp) == null ? void 0 : u.tokenMessenger, `Circle Token Messenger contract for domain ${t} not found`), this.messageTransmitterId = a((m = s.cctp) == null ? void 0 : m.messageTransmitter, `Circle Message Transmitter contract for domain ${t} not found`), this.tokenMessengerStateId = i, this.messageTransmitterStateId = o, this.executorId = a((l = fe[n]) == null ? void 0 : l.executorId, `Executor contract for ${n} not found`), this.executorRequestsId = a((f = fe[n]) == null ? void 0 : f.executorRequestsId, `Executor requests contract for ${n} not found`);
|
|
338
341
|
}
|
|
339
342
|
static async fromRpc(n, t) {
|
|
340
343
|
const [r, s] = await de.chainFromRpc(n), a = t[s];
|
|
341
344
|
if (a.network !== r)
|
|
342
345
|
throw new Error(`Network mismatch: ${a.network} != ${r}`);
|
|
343
|
-
return new
|
|
346
|
+
return new W(r, s, n, a.contracts);
|
|
344
347
|
}
|
|
345
348
|
async *transfer(n, t, r) {
|
|
346
|
-
const s = new
|
|
349
|
+
const s = new at(), a = new dt(n).unwrap(), i = P.get(this.network, t.chain), [o, ...d] = await de.getCoins(this.provider, n, this.usdcId);
|
|
347
350
|
if (o === void 0)
|
|
348
351
|
throw new Error("No USDC in wallet");
|
|
349
|
-
const
|
|
350
|
-
d.length > 0 && s.mergeCoins(
|
|
352
|
+
const u = s.object(o.coinObjectId);
|
|
353
|
+
d.length > 0 && s.mergeCoins(u, d.map((b) => s.object(b.coinObjectId)));
|
|
351
354
|
let m;
|
|
352
355
|
if (r.referrerFee > 0n) {
|
|
353
|
-
const [
|
|
356
|
+
const [b, E] = s.splitCoins(u, [
|
|
354
357
|
r.remainingAmount,
|
|
355
358
|
r.referrerFee
|
|
356
359
|
]);
|
|
357
|
-
m =
|
|
360
|
+
m = b, s.transferObjects([E], _e(r.referrer));
|
|
358
361
|
} else {
|
|
359
|
-
const [
|
|
362
|
+
const [b] = s.splitCoins(u, [
|
|
360
363
|
r.remainingAmount
|
|
361
364
|
]);
|
|
362
|
-
m =
|
|
365
|
+
m = b;
|
|
363
366
|
}
|
|
364
|
-
const [
|
|
367
|
+
const [l, f] = s.moveCall({
|
|
365
368
|
target: `${this.tokenMessengerId}::deposit_for_burn::deposit_for_burn`,
|
|
366
369
|
arguments: [
|
|
367
370
|
m,
|
|
@@ -379,23 +382,23 @@ class q {
|
|
|
379
382
|
// treasury object Treasury<USDC>
|
|
380
383
|
],
|
|
381
384
|
typeArguments: [this.usdcId]
|
|
382
|
-
}), [
|
|
385
|
+
}), [g] = s.moveCall({
|
|
383
386
|
target: `${this.messageTransmitterId}::message::source_domain`,
|
|
384
|
-
arguments: [
|
|
385
|
-
}), [
|
|
387
|
+
arguments: [f]
|
|
388
|
+
}), [h] = s.moveCall({
|
|
386
389
|
target: `${this.messageTransmitterId}::message::nonce`,
|
|
387
|
-
arguments: [
|
|
390
|
+
arguments: [f]
|
|
388
391
|
}), [y] = s.moveCall({
|
|
389
392
|
target: `${this.executorRequestsId}::executor_requests::make_cctp_v1_request`,
|
|
390
|
-
arguments: [
|
|
391
|
-
}), [
|
|
393
|
+
arguments: [g, h]
|
|
394
|
+
}), [x] = s.splitCoins(s.gas, [
|
|
392
395
|
s.pure.u64(r.estimatedCost)
|
|
393
396
|
]);
|
|
394
397
|
s.moveCall({
|
|
395
398
|
target: `${this.executorId}::executor::request_execution`,
|
|
396
399
|
arguments: [
|
|
397
|
-
|
|
398
|
-
s.object(
|
|
400
|
+
x,
|
|
401
|
+
s.object(it),
|
|
399
402
|
s.pure.u16(C(t.chain)),
|
|
400
403
|
s.pure.address("0x0"),
|
|
401
404
|
s.pure.address(a),
|
|
@@ -403,38 +406,38 @@ class q {
|
|
|
403
406
|
y,
|
|
404
407
|
s.pure.vector("u8", r.relayInstructions)
|
|
405
408
|
]
|
|
406
|
-
}), yield this.createUnsignedTx(s, "
|
|
409
|
+
}), yield this.createUnsignedTx(s, "SuiCCTPExecutor.Transfer");
|
|
407
410
|
}
|
|
408
411
|
createUnsignedTx(n, t, r = !1) {
|
|
409
|
-
return new
|
|
412
|
+
return new ft(n, this.network, this.chain, t, r);
|
|
410
413
|
}
|
|
411
414
|
}
|
|
412
|
-
M(
|
|
413
|
-
const
|
|
414
|
-
new
|
|
415
|
-
const j = new
|
|
416
|
-
new
|
|
417
|
-
new
|
|
418
|
-
class
|
|
415
|
+
M(ot, "CCTPExecutor", W);
|
|
416
|
+
const I = new p("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
417
|
+
new p("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
418
|
+
const j = new p("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
419
|
+
new p("So11111111111111111111111111111111111111112");
|
|
420
|
+
new p("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");
|
|
421
|
+
class zt extends Error {
|
|
419
422
|
constructor(n) {
|
|
420
423
|
super(n);
|
|
421
424
|
}
|
|
422
425
|
}
|
|
423
|
-
class
|
|
426
|
+
class Tt extends zt {
|
|
424
427
|
constructor() {
|
|
425
428
|
super(...arguments), this.name = "TokenOwnerOffCurveError";
|
|
426
429
|
}
|
|
427
430
|
}
|
|
428
|
-
var
|
|
431
|
+
var k;
|
|
429
432
|
(function(e) {
|
|
430
433
|
e[e.InitializeMint = 0] = "InitializeMint", e[e.InitializeAccount = 1] = "InitializeAccount", e[e.InitializeMultisig = 2] = "InitializeMultisig", e[e.Transfer = 3] = "Transfer", e[e.Approve = 4] = "Approve", e[e.Revoke = 5] = "Revoke", e[e.SetAuthority = 6] = "SetAuthority", e[e.MintTo = 7] = "MintTo", e[e.Burn = 8] = "Burn", e[e.CloseAccount = 9] = "CloseAccount", e[e.FreezeAccount = 10] = "FreezeAccount", e[e.ThawAccount = 11] = "ThawAccount", e[e.TransferChecked = 12] = "TransferChecked", e[e.ApproveChecked = 13] = "ApproveChecked", e[e.MintToChecked = 14] = "MintToChecked", e[e.BurnChecked = 15] = "BurnChecked", e[e.InitializeAccount2 = 16] = "InitializeAccount2", e[e.SyncNative = 17] = "SyncNative", e[e.InitializeAccount3 = 18] = "InitializeAccount3", e[e.InitializeMultisig2 = 19] = "InitializeMultisig2", e[e.InitializeMint2 = 20] = "InitializeMint2", e[e.GetAccountDataSize = 21] = "GetAccountDataSize", e[e.InitializeImmutableOwner = 22] = "InitializeImmutableOwner", e[e.AmountToUiAmount = 23] = "AmountToUiAmount", e[e.UiAmountToAmount = 24] = "UiAmountToAmount", e[e.InitializeMintCloseAuthority = 25] = "InitializeMintCloseAuthority", e[e.TransferFeeExtension = 26] = "TransferFeeExtension", e[e.ConfidentialTransferExtension = 27] = "ConfidentialTransferExtension", e[e.DefaultAccountStateExtension = 28] = "DefaultAccountStateExtension", e[e.Reallocate = 29] = "Reallocate", e[e.MemoTransferExtension = 30] = "MemoTransferExtension", e[e.CreateNativeMint = 31] = "CreateNativeMint", e[e.InitializeNonTransferableMint = 32] = "InitializeNonTransferableMint", e[e.InterestBearingMintExtension = 33] = "InterestBearingMintExtension", e[e.CpiGuardExtension = 34] = "CpiGuardExtension", e[e.InitializePermanentDelegate = 35] = "InitializePermanentDelegate", e[e.TransferHookExtension = 36] = "TransferHookExtension", e[e.MetadataPointerExtension = 39] = "MetadataPointerExtension";
|
|
431
|
-
})(
|
|
432
|
-
function
|
|
434
|
+
})(k || (k = {}));
|
|
435
|
+
function Ut(e, n, t) {
|
|
433
436
|
if (t.length) {
|
|
434
437
|
e.push({ pubkey: n, isSigner: !1, isWritable: !1 });
|
|
435
438
|
for (const r of t)
|
|
436
439
|
e.push({
|
|
437
|
-
pubkey: r instanceof
|
|
440
|
+
pubkey: r instanceof p ? r : r.publicKey,
|
|
438
441
|
isSigner: !0,
|
|
439
442
|
isWritable: !1
|
|
440
443
|
});
|
|
@@ -442,32 +445,32 @@ function Tt(e, n, t) {
|
|
|
442
445
|
e.push({ pubkey: n, isSigner: !0, isWritable: !1 });
|
|
443
446
|
return e;
|
|
444
447
|
}
|
|
445
|
-
const
|
|
448
|
+
const Rt = be([
|
|
446
449
|
re("mintAuthorityOption"),
|
|
447
450
|
ue("mintAuthority"),
|
|
448
451
|
Ae("supply"),
|
|
449
|
-
|
|
450
|
-
|
|
452
|
+
we("decimals"),
|
|
453
|
+
lt("isInitialized"),
|
|
451
454
|
re("freezeAuthorityOption"),
|
|
452
455
|
ue("freezeAuthority")
|
|
453
456
|
]);
|
|
454
|
-
|
|
455
|
-
function
|
|
456
|
-
if (!t && !
|
|
457
|
-
throw new
|
|
458
|
-
const [a] =
|
|
457
|
+
Rt.span;
|
|
458
|
+
function ge(e, n, t = !1, r = I, s = j) {
|
|
459
|
+
if (!t && !p.isOnCurve(n.toBuffer()))
|
|
460
|
+
throw new Tt();
|
|
461
|
+
const [a] = p.findProgramAddressSync([n.toBuffer(), r.toBuffer(), e.toBuffer()], s);
|
|
459
462
|
return a;
|
|
460
463
|
}
|
|
461
|
-
function
|
|
462
|
-
return
|
|
464
|
+
function _t(e, n, t, r, s = I, a = j) {
|
|
465
|
+
return Nt(e, n, t, r, D.Buffer.from([1]), s, a);
|
|
463
466
|
}
|
|
464
|
-
function
|
|
467
|
+
function Nt(e, n, t, r, s, a = I, i = j) {
|
|
465
468
|
const o = [
|
|
466
469
|
{ pubkey: e, isSigner: !0, isWritable: !0 },
|
|
467
470
|
{ pubkey: n, isSigner: !1, isWritable: !0 },
|
|
468
471
|
{ pubkey: t, isSigner: !1, isWritable: !1 },
|
|
469
472
|
{ pubkey: r, isSigner: !1, isWritable: !1 },
|
|
470
|
-
{ pubkey:
|
|
473
|
+
{ pubkey: Ne.programId, isSigner: !1, isWritable: !1 },
|
|
471
474
|
{ pubkey: a, isSigner: !1, isWritable: !1 }
|
|
472
475
|
];
|
|
473
476
|
return new Ce({
|
|
@@ -476,18 +479,18 @@ function _t(e, n, t, r, s, a = B, i = j) {
|
|
|
476
479
|
data: s
|
|
477
480
|
});
|
|
478
481
|
}
|
|
479
|
-
const
|
|
480
|
-
function
|
|
481
|
-
const i =
|
|
482
|
+
const pe = be([we("instruction"), Ae("amount")]);
|
|
483
|
+
function $t(e, n, t, r, s = [], a = I) {
|
|
484
|
+
const i = Ut([
|
|
482
485
|
{ pubkey: e, isSigner: !1, isWritable: !0 },
|
|
483
486
|
{ pubkey: n, isSigner: !1, isWritable: !0 }
|
|
484
|
-
], t, s), o = D.Buffer.alloc(
|
|
485
|
-
return
|
|
486
|
-
instruction:
|
|
487
|
+
], t, s), o = D.Buffer.alloc(pe.span);
|
|
488
|
+
return pe.encode({
|
|
489
|
+
instruction: k.Transfer,
|
|
487
490
|
amount: BigInt(r)
|
|
488
491
|
}, o), new Ce({ keys: i, programId: a, data: o });
|
|
489
492
|
}
|
|
490
|
-
const
|
|
493
|
+
const kt = {
|
|
491
494
|
version: "0.1.0",
|
|
492
495
|
name: "example_cctp_with_executor",
|
|
493
496
|
instructions: [
|
|
@@ -569,60 +572,60 @@ class V {
|
|
|
569
572
|
c(this, "executorProgramId");
|
|
570
573
|
var i, o, d;
|
|
571
574
|
if (this.network = n, this.chain = t, this.connection = r, this.contracts = s, n === "Devnet")
|
|
572
|
-
throw new Error("
|
|
573
|
-
const a = (
|
|
574
|
-
if (!
|
|
575
|
+
throw new Error("CCTPExecutor not supported on Devnet");
|
|
576
|
+
const a = (u, m) => {
|
|
577
|
+
if (!u)
|
|
575
578
|
throw new Error(m);
|
|
576
|
-
return new
|
|
579
|
+
return new p(u);
|
|
577
580
|
};
|
|
578
|
-
this.tokenMessengerProgramId = a((i = s.cctp) == null ? void 0 : i.tokenMessenger, `Circle Token Messenger contract for domain ${t} not found`), this.messageTransmitterProgramId = a((o = s.cctp) == null ? void 0 : o.messageTransmitter, `Circle Message Transmitter contract for domain ${t} not found`), this.shimProgramId = a((d =
|
|
581
|
+
this.tokenMessengerProgramId = a((i = s.cctp) == null ? void 0 : i.tokenMessenger, `Circle Token Messenger contract for domain ${t} not found`), this.messageTransmitterProgramId = a((o = s.cctp) == null ? void 0 : o.messageTransmitter, `Circle Message Transmitter contract for domain ${t} not found`), this.shimProgramId = a((d = L[n]) == null ? void 0 : d[t], `Shim contract for ${t} not found`), this.executorProgramId = a(wt[n], `Executor contract for ${n} not found`);
|
|
579
582
|
}
|
|
580
583
|
static async fromRpc(n, t) {
|
|
581
|
-
const [r, s] = await
|
|
584
|
+
const [r, s] = await gt.chainFromRpc(n), a = t[s];
|
|
582
585
|
if (a.network !== r)
|
|
583
586
|
throw new Error(`Network mismatch: ${a.network} != ${r}`);
|
|
584
587
|
return new V(r, s, n, a.contracts);
|
|
585
588
|
}
|
|
586
589
|
async *transfer(n, t, r) {
|
|
587
|
-
const s = new
|
|
590
|
+
const s = new p(w.get(this.network, this.chain)), a = new N(n).unwrap(), i = ge(s, a), o = new N(r.referrer.address).unwrap(), d = new $e();
|
|
588
591
|
if (d.feePayer = a, r.referrerFee > 0n) {
|
|
589
|
-
const y =
|
|
590
|
-
await this.connection.getAccountInfo(y) || d.add(
|
|
592
|
+
const y = ge(s, o);
|
|
593
|
+
await this.connection.getAccountInfo(y) || d.add(_t(a, y, o, s)), d.add($t(i, y, a, r.referrerFee));
|
|
591
594
|
}
|
|
592
|
-
const
|
|
593
|
-
d.add(await
|
|
594
|
-
const
|
|
595
|
-
d.add(await
|
|
595
|
+
const u = P.get(this.network, t.chain), m = t.address.toUniversalAddress(), l = ke.generate();
|
|
596
|
+
d.add(await mt(this.messageTransmitterProgramId, this.tokenMessengerProgramId, s, u, a, i, m, r.remainingAmount, l.publicKey));
|
|
597
|
+
const f = new ht(kt, this.shimProgramId, { connection: null }), g = $(ye, r.signedQuote), h = bt("message_transmitter", this.messageTransmitterProgramId);
|
|
598
|
+
d.add(await f.methods.relayLastMessage({
|
|
596
599
|
execAmount: new Oe(r.estimatedCost.toString()),
|
|
597
600
|
recipientChain: C(t.chain),
|
|
598
601
|
signedQuoteBytes: D.Buffer.from(r.signedQuote),
|
|
599
602
|
relayInstructions: D.Buffer.from(r.relayInstructions)
|
|
600
603
|
}).accounts({
|
|
601
604
|
payer: a,
|
|
602
|
-
messageTransmitter:
|
|
603
|
-
payee: new g
|
|
605
|
+
messageTransmitter: h,
|
|
606
|
+
payee: new p(g.quote.payeeAddress),
|
|
604
607
|
executorProgram: this.executorProgramId
|
|
605
|
-
}).instruction()), yield this.createUnsignedTx({ transaction: d, signers: [
|
|
608
|
+
}).instruction()), yield this.createUnsignedTx({ transaction: d, signers: [l] }, "SvmCCTPExecutor.Transfer");
|
|
606
609
|
}
|
|
607
610
|
createUnsignedTx(n, t, r = !1) {
|
|
608
|
-
return new
|
|
611
|
+
return new pt(n, this.network, this.chain, t, r);
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
|
-
M(
|
|
614
|
+
M(Ge, "CCTPExecutor", V);
|
|
612
615
|
let v;
|
|
613
|
-
function
|
|
616
|
+
function ir(e) {
|
|
614
617
|
if (e.referrerFeeDbps < 0 || e.referrerFeeDbps > 65535n)
|
|
615
618
|
throw new Error("Referrer fee must be between 0 and 65535");
|
|
616
619
|
class n extends F {
|
|
617
620
|
}
|
|
618
621
|
return c(n, "config", e), n;
|
|
619
622
|
}
|
|
620
|
-
class F extends
|
|
623
|
+
class F extends Le {
|
|
621
624
|
constructor() {
|
|
622
625
|
super(...arguments);
|
|
623
626
|
// @ts-ignore
|
|
624
627
|
// Since we set the config on the static class, access it with this param
|
|
625
|
-
// the
|
|
628
|
+
// the CCTPExecutorRoute.config will always be empty
|
|
626
629
|
c(this, "staticConfig", this.constructor.config);
|
|
627
630
|
}
|
|
628
631
|
static supportedNetworks() {
|
|
@@ -632,12 +635,12 @@ class F extends ke {
|
|
|
632
635
|
return se.has(t) ? se.get(t) : [];
|
|
633
636
|
}
|
|
634
637
|
static async supportedDestinationTokens(t, r, s) {
|
|
635
|
-
const a =
|
|
636
|
-
if (!(a &&
|
|
638
|
+
const a = w.get(r.network, r.chain);
|
|
639
|
+
if (!(a && Qe(t, S.tokenId(r.chain, a))))
|
|
637
640
|
return [];
|
|
638
641
|
const { network: i, chain: o } = s;
|
|
639
|
-
return
|
|
640
|
-
S.chainAddress(o,
|
|
642
|
+
return w.has(i, o) ? [
|
|
643
|
+
S.chainAddress(o, w.get(i, o))
|
|
641
644
|
] : [];
|
|
642
645
|
}
|
|
643
646
|
getDefaultOptions() {
|
|
@@ -662,69 +665,69 @@ class F extends ke {
|
|
|
662
665
|
async quote(t, r) {
|
|
663
666
|
var Z, Y;
|
|
664
667
|
const { fromChain: s, toChain: a } = t;
|
|
665
|
-
if (!
|
|
668
|
+
if (!w.get(s.network, s.chain))
|
|
666
669
|
throw new Error("Invalid transfer, no USDC contract on source");
|
|
667
|
-
const o =
|
|
670
|
+
const o = w.get(a.network, a.chain);
|
|
668
671
|
if (!o)
|
|
669
672
|
throw new Error("Invalid transfer, no USDC contract on destination");
|
|
670
|
-
const d = (Z =
|
|
673
|
+
const d = (Z = yt[s.network]) == null ? void 0 : Z[s.chain];
|
|
671
674
|
if (!d)
|
|
672
675
|
return {
|
|
673
676
|
success: !1,
|
|
674
677
|
error: new Error("No referrer address found")
|
|
675
678
|
};
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
679
|
+
const u = S.chainAddress(s.chain, d), m = this.staticConfig.referrerFeeDbps, { referrerFee: l, remainingAmount: f } = vt(qe(r.normalizedParams.amount), this.staticConfig.referrerFeeDbps);
|
|
680
|
+
if (f <= 0n)
|
|
678
681
|
return {
|
|
679
682
|
success: !1,
|
|
680
683
|
error: new Error("Amount after fee <= 0")
|
|
681
684
|
};
|
|
682
|
-
const
|
|
683
|
-
if (!
|
|
685
|
+
const g = (Y = At[s.network]) == null ? void 0 : Y[a.chain];
|
|
686
|
+
if (!g)
|
|
684
687
|
return {
|
|
685
688
|
success: !1,
|
|
686
689
|
error: new Error("Gas limit not found")
|
|
687
690
|
};
|
|
688
|
-
const
|
|
689
|
-
if (!
|
|
691
|
+
const h = await xt(s.network);
|
|
692
|
+
if (!h[C(s.chain)])
|
|
690
693
|
return {
|
|
691
694
|
success: !1,
|
|
692
695
|
error: new Error("Unsupported source chain")
|
|
693
696
|
};
|
|
694
|
-
const
|
|
695
|
-
if (!
|
|
697
|
+
const x = h[C(a.chain)];
|
|
698
|
+
if (!x || !x.requestPrefixes.includes("ERC1"))
|
|
696
699
|
return {
|
|
697
700
|
success: !1,
|
|
698
701
|
error: new Error("Unsupported destination chain")
|
|
699
702
|
};
|
|
700
|
-
const { recipient:
|
|
701
|
-
let
|
|
702
|
-
if (
|
|
703
|
-
const
|
|
704
|
-
|
|
703
|
+
const { recipient: b } = t;
|
|
704
|
+
let E = !0;
|
|
705
|
+
if (b && a.chain === "Solana") {
|
|
706
|
+
const De = S.parseAddress("Solana", o), Pe = await a.getTokenAccount(b.address, De), ee = await a.getRpc();
|
|
707
|
+
E = await ee.getAccountInfo(new N(Pe.address).unwrap()) !== null, !E && !v && (v = BigInt(await ee.getMinimumBalanceForRentExemption(165)));
|
|
705
708
|
}
|
|
706
|
-
let
|
|
707
|
-
a.chain === "Solana" && (
|
|
709
|
+
let B = 0n;
|
|
710
|
+
a.chain === "Solana" && (B += Ct, !E && v && (B += v));
|
|
708
711
|
const z = [];
|
|
709
712
|
z.push({
|
|
710
713
|
request: {
|
|
711
714
|
type: "GasInstruction",
|
|
712
|
-
gasLimit:
|
|
713
|
-
msgValue:
|
|
715
|
+
gasLimit: g,
|
|
716
|
+
msgValue: B
|
|
714
717
|
}
|
|
715
718
|
});
|
|
716
|
-
const K = BigInt(
|
|
717
|
-
(T > 0n || !
|
|
719
|
+
const K = BigInt(x.gasDropOffLimit), T = r.options.nativeGas && K > 0n ? BigInt(Math.round(r.options.nativeGas * 100)) * K / 100n : 0n;
|
|
720
|
+
(T > 0n || !E) && z.push({
|
|
718
721
|
request: {
|
|
719
722
|
type: "GasDropOffInstruction",
|
|
720
723
|
dropOff: T,
|
|
721
724
|
// If the recipient is undefined (e.g. the user hasn’t connected their wallet yet),
|
|
722
725
|
// we temporarily use a dummy address to fetch a quote.
|
|
723
726
|
// The recipient address is validated later in the `initiate` method, which will throw if it's still missing.
|
|
724
|
-
recipient:
|
|
727
|
+
recipient: b ? b.address.toUniversalAddress() : new We(new Uint8Array(32))
|
|
725
728
|
}
|
|
726
729
|
});
|
|
727
|
-
const X =
|
|
730
|
+
const X = je(he, {
|
|
728
731
|
requests: z
|
|
729
732
|
}), U = await Et(s.network, s.chain, a.chain, ne.encode(X, !0));
|
|
730
733
|
if (!U.estimatedCost)
|
|
@@ -732,15 +735,15 @@ class F extends ke {
|
|
|
732
735
|
success: !1,
|
|
733
736
|
error: new Error("No estimated cost")
|
|
734
737
|
};
|
|
735
|
-
const J = ne.decode(U.signedQuote),
|
|
738
|
+
const J = ne.decode(U.signedQuote), xe = $(ye, J), Ee = s.chain === "Polygon" ? 2e3 * 200 : Ve(s.chain) + 1e3, H = BigInt(U.estimatedCost), Se = {
|
|
736
739
|
signedQuote: J,
|
|
737
740
|
relayInstructions: X,
|
|
738
741
|
estimatedCost: H,
|
|
739
|
-
referrer:
|
|
740
|
-
referrerFee:
|
|
741
|
-
remainingAmount:
|
|
742
|
+
referrer: u,
|
|
743
|
+
referrerFee: l,
|
|
744
|
+
remainingAmount: f,
|
|
742
745
|
referrerFeeDbps: m
|
|
743
|
-
}, [
|
|
746
|
+
}, [ve, Fe] = await Promise.all([
|
|
744
747
|
s.getDecimals("native"),
|
|
745
748
|
a.getDecimals("native")
|
|
746
749
|
]);
|
|
@@ -753,37 +756,48 @@ class F extends ke {
|
|
|
753
756
|
},
|
|
754
757
|
destinationToken: {
|
|
755
758
|
token: t.destination.id,
|
|
756
|
-
amount: R(
|
|
759
|
+
amount: R(f, t.destination.decimals)
|
|
757
760
|
},
|
|
758
761
|
relayFee: {
|
|
759
|
-
token:
|
|
760
|
-
amount: R(H,
|
|
762
|
+
token: Ke(s.chain),
|
|
763
|
+
amount: R(H, ve)
|
|
761
764
|
},
|
|
762
|
-
destinationNativeGas: R(T,
|
|
765
|
+
destinationNativeGas: R(T, Fe),
|
|
763
766
|
eta: Ee,
|
|
764
|
-
expires:
|
|
765
|
-
details:
|
|
767
|
+
expires: xe.quote.expiryTime,
|
|
768
|
+
details: Se
|
|
766
769
|
};
|
|
767
770
|
}
|
|
768
771
|
async initiate(t, r, s, a) {
|
|
769
772
|
if (!s.details)
|
|
770
773
|
throw new Error("Missing quote details");
|
|
771
|
-
$(
|
|
772
|
-
if (
|
|
774
|
+
$(he, s.details.relayInstructions).requests.forEach(({ request: h }) => {
|
|
775
|
+
if (h.type === "GasDropOffInstruction" && !h.recipient.equals(a.address.toUniversalAddress()))
|
|
773
776
|
throw new Error("Gas drop-off recipient does not match");
|
|
774
777
|
});
|
|
775
|
-
const o = await t.fromChain.getProtocol("
|
|
776
|
-
let
|
|
778
|
+
const o = await t.fromChain.getProtocol("CCTPExecutor"), d = S.parseAddress(r.chain(), r.address());
|
|
779
|
+
let u = a;
|
|
777
780
|
if (a.chain === "Solana") {
|
|
778
|
-
const
|
|
779
|
-
|
|
781
|
+
const h = S.parseAddress("Solana", w.get(t.toChain.network, t.toChain.chain));
|
|
782
|
+
u = await t.toChain.getTokenAccount(a.address, h);
|
|
780
783
|
}
|
|
781
|
-
const m = await o.transfer(d,
|
|
782
|
-
|
|
784
|
+
const m = await o.transfer(d, u, s.details), l = await Xe(t.fromChain, m, r);
|
|
785
|
+
let f = 0;
|
|
786
|
+
return (async () => {
|
|
787
|
+
for (; f < 20; ) {
|
|
788
|
+
try {
|
|
789
|
+
const [h] = await me(this.wh.network, l.at(-1).txid, t.fromChain.chain);
|
|
790
|
+
if (h)
|
|
791
|
+
break;
|
|
792
|
+
} catch {
|
|
793
|
+
}
|
|
794
|
+
f++, await Ft(2e3);
|
|
795
|
+
}
|
|
796
|
+
})(), {
|
|
783
797
|
from: t.fromChain.chain,
|
|
784
798
|
to: t.toChain.chain,
|
|
785
799
|
state: _.SourceInitiated,
|
|
786
|
-
originTxs:
|
|
800
|
+
originTxs: l
|
|
787
801
|
};
|
|
788
802
|
}
|
|
789
803
|
async *track(t, r) {
|
|
@@ -792,20 +806,20 @@ class F extends ke {
|
|
|
792
806
|
let s = r || 60 * 60 * 1e3;
|
|
793
807
|
for (; s > 0; ) {
|
|
794
808
|
const a = Date.now();
|
|
795
|
-
if (
|
|
809
|
+
if (Je(t) || He(t) || Ze(t))
|
|
796
810
|
try {
|
|
797
|
-
const [i] = await
|
|
811
|
+
const [i] = await me(this.wh.network, t.originTxs.at(-1).txid, t.from);
|
|
798
812
|
if (!i)
|
|
799
813
|
throw new Error("No transaction status found");
|
|
800
814
|
const o = i == null ? void 0 : i.status;
|
|
801
|
-
if ((o ===
|
|
802
|
-
o ===
|
|
803
|
-
o ===
|
|
804
|
-
o ===
|
|
815
|
+
if ((o === A.Failed || // this could happen if simulation fails
|
|
816
|
+
o === A.Underpaid || // only happens if you don't pay at least the costEstimate
|
|
817
|
+
o === A.Unsupported || // capabilities check didn't pass
|
|
818
|
+
o === A.Aborted) && (t = {
|
|
805
819
|
...t,
|
|
806
820
|
state: _.Failed,
|
|
807
|
-
error: new
|
|
808
|
-
}), o ===
|
|
821
|
+
error: new ut(`Relay failed with status: ${o}`)
|
|
822
|
+
}), o === A.Submitted && (t = {
|
|
809
823
|
...t,
|
|
810
824
|
state: _.DestinationFinalized,
|
|
811
825
|
attestation: { id: i.id, attestation: {} }
|
|
@@ -820,9 +834,9 @@ class F extends ke {
|
|
|
820
834
|
}
|
|
821
835
|
}
|
|
822
836
|
c(F, "NATIVE_GAS_DROPOFF_SUPPORTED", !0), c(F, "config", { referrerFeeDbps: 0n }), c(F, "meta", {
|
|
823
|
-
name: "
|
|
824
|
-
provider: "
|
|
837
|
+
name: "CCTPExecutorRoute",
|
|
838
|
+
provider: "Circle"
|
|
825
839
|
});
|
|
826
840
|
export {
|
|
827
|
-
|
|
841
|
+
ir as cctpExecutorRoute
|
|
828
842
|
};
|