@wormhole-foundation/wormhole-connect 3.0.0-beta.0-development → 3.0.0-beta.1-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.
Files changed (135) hide show
  1. package/dist/main.js +49 -49
  2. package/dist/src/components/SampleApp/index.d.ts.map +1 -1
  3. package/dist/src/config/index.d.ts.map +1 -1
  4. package/dist/src/config/types.d.ts +2 -0
  5. package/dist/src/config/types.d.ts.map +1 -1
  6. package/dist/src/exports/executor.d.ts +2 -0
  7. package/dist/src/exports/executor.d.ts.map +1 -0
  8. package/dist/src/hooks/useFetchSupportedRoutes.d.ts.map +1 -1
  9. package/dist/src/utils/index.d.ts +1 -0
  10. package/dist/src/utils/index.d.ts.map +1 -1
  11. package/dist/src/utils/sdkv2.d.ts +0 -1
  12. package/dist/src/utils/sdkv2.d.ts.map +1 -1
  13. package/dist/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
  14. package/dist/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
  15. package/dist/src/views/v2/Redeem/index.d.ts.map +1 -1
  16. package/lib/account-CKUCmcgT.mjs +30 -0
  17. package/lib/account-QG_Hi4er.js +1 -0
  18. package/lib/address-B-_yHNB2.js +1 -0
  19. package/lib/{address-D74XlMdi.mjs → address-B9anhmbU.mjs} +5 -5
  20. package/lib/address-Cj96wodd.mjs +64 -0
  21. package/lib/{address-DXFbgyJW.mjs → address-Drr_9OcK.mjs} +93 -93
  22. package/lib/aptos-BZ2mcuTd.js +2 -0
  23. package/lib/aptos-DPIwkCrX.mjs +68 -0
  24. package/lib/{aptos-WhWqMfkU.js → aptos-Da6iqpC-.js} +1 -1
  25. package/lib/{aptos-BckWT_Pe.mjs → aptos-Dz4Js3_d.mjs} +3 -3
  26. package/lib/{base64-DPCMLrON.mjs → base64-BcnUThiU.mjs} +1 -1
  27. package/lib/{blake2b-BmQx89Cf.mjs → blake2b-CnkNeJT4.mjs} +1 -1
  28. package/lib/{browser-ponyfill-Zjbs5ehD.mjs → browser-ponyfill-oWZrCgRw.mjs} +1 -1
  29. package/lib/{ccip-DiNEz9KN.js → ccip-Bb-IPrNA.js} +1 -1
  30. package/lib/{ccip-B45dpIhp.mjs → ccip-Ceg_B70t.mjs} +1 -1
  31. package/lib/{chain-DaAd2Ztf.mjs → chain-CNVMEdrk.mjs} +1 -1
  32. package/lib/{chunk-IMTC3J2M-Bn3rs7tb.mjs → chunk-IMTC3J2M-B7fKwIuX.mjs} +3 -3
  33. package/lib/{constants-CbKC2uxb.mjs → constants-Ba9GwEM1.mjs} +1 -1
  34. package/lib/constants-BqqwmYZc.js +1 -0
  35. package/lib/{contract-BI_HDILr.mjs → contract-DANWVftx.mjs} +1 -1
  36. package/lib/{create-CzWSWmF_.mjs → create-B9LwWha4.mjs} +1 -1
  37. package/lib/{evm-DFyxDQ-x.js → evm-1T5rGzcO.js} +3 -3
  38. package/lib/{evm-DgG5biHb.mjs → evm-B552wdhN.mjs} +9 -9
  39. package/lib/{evm-Es3E89UO.mjs → evm-DarNu22s.mjs} +9 -9
  40. package/lib/executor.d.ts +2 -0
  41. package/lib/executor.js +1 -0
  42. package/lib/executor.mjs +828 -0
  43. package/lib/hosted.js +1 -1
  44. package/lib/hosted.mjs +1 -1
  45. package/lib/index-2f5GRlqp.mjs +46 -0
  46. package/lib/{index-Blt9MjZK.mjs → index-B1XGfrNH.mjs} +1 -1
  47. package/lib/{index-DUiyW0v6.js → index-B40ktVOy.js} +1 -1
  48. package/lib/{index-jfL73ugq.mjs → index-B4NYDFvU.mjs} +5 -5
  49. package/lib/{index--QOOnO1S.mjs → index-BAuH_G93.mjs} +5 -5
  50. package/lib/{index-C9ZemP81.mjs → index-BHMN5Px3.mjs} +2 -2
  51. package/lib/{index-CGbZMLbJ.mjs → index-BO0DC-jc.mjs} +3 -3
  52. package/lib/{index-BziywkBj.mjs → index-BQ0RlDhv.mjs} +246 -272
  53. package/lib/{index-Cuu-xM0U.mjs → index-BR4w3fuE.mjs} +5 -5
  54. package/lib/{index-DnOkd5VL.js → index-BTNmmLkb.js} +1 -1
  55. package/lib/{index-BQwsEzas.mjs → index-BlJpOhTM.mjs} +5 -5
  56. package/lib/{index-CjL3WbDp.js → index-Blzzdktm.js} +1 -1
  57. package/lib/{index-Bc7EWiox.js → index-Bn1o04G7.js} +80 -80
  58. package/lib/index-C2Pe6i5V.js +1 -0
  59. package/lib/{index-5xE5bjpW.mjs → index-C9XIIFQK.mjs} +1 -1
  60. package/lib/{index-XFRw6zfV.mjs → index-CCRPy0B_.mjs} +2 -2
  61. package/lib/index-CE0rxdUf.js +1 -0
  62. package/lib/{index-Bu6LLuxH.mjs → index-CEXcD8Mw.mjs} +4 -4
  63. package/lib/{index-BLYjmYmu.mjs → index-CKg04pdA.mjs} +5 -5
  64. package/lib/{index-CxW1HjrT.mjs → index-CM_IP492.mjs} +14 -14
  65. package/lib/{index-pjyIirVB.mjs → index-CT2-qOL1.mjs} +2 -2
  66. package/lib/{index-DFHQnDR7.mjs → index-CYdhveYx.mjs} +6 -6
  67. package/lib/{index-COkWxUoe.mjs → index-Cda4HnP1.mjs} +5 -5
  68. package/lib/{index-BYzONVwG.mjs → index-CfC3_uPF.mjs} +7 -7
  69. package/lib/index-DC1ot7tO.js +1 -0
  70. package/lib/{index-v0MO46Zl.mjs → index-DHAgduQ-.mjs} +4 -4
  71. package/lib/{index-DQjqwKVk.mjs → index-DSSOE7Me.mjs} +2 -2
  72. package/lib/{index-BbCcdl9J.mjs → index-DoFo485M.mjs} +73 -72
  73. package/lib/{index-BNjB0Q50.mjs → index-DvxmZnxH.mjs} +5 -5
  74. package/lib/{index-ju2wtFjy.mjs → index-Dw7INWis.mjs} +7 -7
  75. package/lib/{index-t94-e3qG.js → index-VhcNuaP6.js} +1 -1
  76. package/lib/index-dpkTW-H8.js +1 -0
  77. package/lib/index-f_27F6WX.js +1 -0
  78. package/lib/{index-BkHLwIMc.mjs → index-l0sxQXRT.mjs} +1 -1
  79. package/lib/{index-CdOqWihR.mjs → index-mXHkgOxH.mjs} +4 -4
  80. package/lib/{index-C2jOUiub.mjs → index-pN0Dgjjf.mjs} +5 -5
  81. package/lib/{index-B7U-me-L.mjs → index-pNqQSm4p.mjs} +6628 -6659
  82. package/lib/{index.es-BYLVcsBS.js → index.es-_N4sKEIC.js} +1 -1
  83. package/lib/{index.es-BrgiiIYV.mjs → index.es-rEir51oG.mjs} +7 -7
  84. package/lib/index.js +1 -1
  85. package/lib/index.mjs +5 -5
  86. package/lib/mayan.mjs +10 -10
  87. package/lib/{mint-BjwZUbPm.mjs → mint-DVxIczlI.mjs} +2 -2
  88. package/lib/ntt.js +1 -1
  89. package/lib/ntt.mjs +10 -10
  90. package/lib/{platform-pi9E7cPR.mjs → platform-CbDx4hex.mjs} +4 -4
  91. package/lib/platform-CyTWPtDR.js +1 -0
  92. package/lib/{platform-C-edrCmf.mjs → platform-D-nUFU0e.mjs} +6 -6
  93. package/lib/platform-PaIJsXKV.mjs +118 -0
  94. package/lib/{provider-jsonrpc-BjcoR80W.mjs → provider-jsonrpc-C_IZFSfB.mjs} +2 -2
  95. package/lib/{sha3-B1KxiAa7.mjs → sha3-DQQvDwj1.mjs} +1 -1
  96. package/lib/{signer-CgLO7fBA.mjs → signer-CsMX8mEc.mjs} +6 -6
  97. package/lib/{solana-DA48rYUK.js → solana-BRQmi9BN.js} +1 -1
  98. package/lib/solana-C_0khyJw.mjs +18 -0
  99. package/lib/{solana-Pjpx_PkM.js → solana-CrjSp_Zk.js} +1 -1
  100. package/lib/{solana-CvaeYBIB.mjs → solana-SQhnN3yB.mjs} +6 -6
  101. package/lib/{solanaEmbed.esm-jxAhxZ9V.js → solanaEmbed.esm-B7IRXgnI.js} +1 -1
  102. package/lib/{solanaEmbed.esm-Gti-Nr19.mjs → solanaEmbed.esm-Din0Z51P.mjs} +3 -3
  103. package/lib/src/components/SampleApp/index.d.ts.map +1 -1
  104. package/lib/src/config/index.d.ts.map +1 -1
  105. package/lib/src/config/types.d.ts +2 -0
  106. package/lib/src/config/types.d.ts.map +1 -1
  107. package/lib/src/exports/executor.d.ts +2 -0
  108. package/lib/src/exports/executor.d.ts.map +1 -0
  109. package/lib/src/hooks/useFetchSupportedRoutes.d.ts.map +1 -1
  110. package/lib/src/utils/index.d.ts +1 -0
  111. package/lib/src/utils/index.d.ts.map +1 -1
  112. package/lib/src/utils/sdkv2.d.ts +0 -1
  113. package/lib/src/utils/sdkv2.d.ts.map +1 -1
  114. package/lib/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
  115. package/lib/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
  116. package/lib/src/views/v2/Redeem/index.d.ts.map +1 -1
  117. package/lib/{sui-CuwmPzXZ.mjs → sui-BSLo7-bI.mjs} +14 -14
  118. package/lib/{sui-Bi1J0W_P.mjs → sui-BePFnRSc.mjs} +3 -3
  119. package/lib/{sui-uSCH-o_h.js → sui-C7KPm3kD.js} +1 -1
  120. package/lib/{tokens-DcqY0jHv.js → tokens-CChVRIuE.js} +1 -1
  121. package/lib/{tokens-DOx4hiaR.mjs → tokens-CyKAZUN-.mjs} +4 -4
  122. package/lib/{units-YO78Cq5F.mjs → units-DP5zqyxn.mjs} +9 -9
  123. package/lib/{unsignedTransaction-Cj476rGh.mjs → unsignedTransaction-fSrwDjHx.mjs} +9 -9
  124. package/lib/{web3--AtxvLIy.mjs → web3-DCo8oN-v.mjs} +4 -4
  125. package/package.json +16 -1
  126. package/lib/aptos-VwYOwtQy.mjs +0 -179
  127. package/lib/aptos-hc5GrCHO.js +0 -2
  128. package/lib/constants-Cib4VRZO.js +0 -1
  129. package/lib/index-BlzRxQ82.js +0 -1
  130. package/lib/index-CJXmILJz.js +0 -1
  131. package/lib/index-C_dsyQjC.mjs +0 -46
  132. package/lib/index-CpuzvBlL.js +0 -1
  133. package/lib/index-Cxg2C7RE.js +0 -1
  134. package/lib/index-DDAGOrv0.js +0 -1
  135. package/lib/solana-qHqB-cdc.mjs +0 -18
@@ -1,11 +1,11 @@
1
1
  var B = Object.defineProperty;
2
2
  var P = (o, t, n) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[t] = n;
3
3
  var d = (o, t, n) => P(o, typeof t != "symbol" ? t + "" : t, n);
4
- import { b1 as w, ae as l, b3 as y, br as E, ad as S, W as N, bX as R, a5 as I, k as p, bt as x, bu as D } from "./address-DXFbgyJW.mjs";
5
- import { C as L, P as O } from "./chain-DaAd2Ztf.mjs";
4
+ import { b1 as w, ae as l, b3 as y, bs as E, ad as S, W as N, bY as R, a5 as I, k as p, bu as x, bv as D } from "./address-Drr_9OcK.mjs";
5
+ import { C as L, P as O } from "./chain-CNVMEdrk.mjs";
6
6
  class W extends L {
7
7
  async getTokenAccount(t, n) {
8
- const { getAssociatedTokenAddress: e } = await import("./index-CdOqWihR.mjs"), i = new w(n).unwrap(), s = new w(t).unwrap(), r = await e(i, s);
8
+ const { getAssociatedTokenAddress: e } = await import("./index-mXHkgOxH.mjs"), i = new w(n).unwrap(), s = new w(t).unwrap(), r = await e(i, s);
9
9
  return {
10
10
  chain: this.chain,
11
11
  address: new w(r.toString())
@@ -70,8 +70,8 @@ const c = class c extends O {
70
70
  if (p(a))
71
71
  return { native: s };
72
72
  const u = new w(a).toString(), m = (b = (T = (k = (f = r.find((g) => {
73
- var A, C;
74
- return ((C = (A = g == null ? void 0 : g.account.data.parsed) == null ? void 0 : A.info) == null ? void 0 : C.mint) === a.toString();
73
+ var A, v;
74
+ return ((v = (A = g == null ? void 0 : g.account.data.parsed) == null ? void 0 : A.info) == null ? void 0 : v.mint) === a.toString();
75
75
  })) == null ? void 0 : f.account.data.parsed) == null ? void 0 : k.info) == null ? void 0 : T.tokenAmount) == null ? void 0 : b.amount;
76
76
  return m ? { [u]: BigInt(m) } : { [u]: null };
77
77
  }).reduce((a, u) => Object.assign(a, u), {});
@@ -138,7 +138,7 @@ const c = class c extends O {
138
138
  }
139
139
  };
140
140
  d(c, "_platform", y);
141
- let v = c;
141
+ let C = c;
142
142
  class K {
143
143
  constructor(t, n, e, i, s = !1) {
144
144
  d(this, "transaction");
@@ -149,15 +149,15 @@ class K {
149
149
  this.transaction = t, this.network = n, this.chain = e, this.description = i, this.parallelizable = s;
150
150
  }
151
151
  }
152
- function X(o) {
152
+ function M(o) {
153
153
  return o.signatures !== void 0 && o.message !== void 0;
154
154
  }
155
155
  export {
156
156
  H as A,
157
157
  K as S,
158
158
  F as T,
159
- v as a,
159
+ C as a,
160
160
  W as b,
161
161
  G as c,
162
- X as i
162
+ M as i
163
163
  };
@@ -1,4 +1,4 @@
1
- import { av as b, cp as f, d as p, cq as y, au as l, ae as L } from "./address-DXFbgyJW.mjs";
1
+ import { av as b, cq as f, d as y, cr as l, au as p, ae as L } from "./address-Drr_9OcK.mjs";
2
2
  const a = (e) => {
3
3
  const t = e.decode.bind(e), r = e.encode.bind(e);
4
4
  return { decode: t, encode: r };
@@ -6,13 +6,13 @@ const a = (e) => {
6
6
  const r = b(e, t), { encode: u, decode: s } = a(r), o = r;
7
7
  return o.decode = (c, n) => {
8
8
  const d = s(c, n);
9
- return f(p.Buffer.from(d));
9
+ return f(y.Buffer.from(d));
10
10
  }, o.encode = (c, n, d) => {
11
- const i = y(c, e);
11
+ const i = l(c, e);
12
12
  return u(i, n, d);
13
13
  }, o;
14
14
  }, I = m(8), K = (e) => {
15
- const t = l(e), { encode: r, decode: u } = a(t), s = t;
15
+ const t = p(e), { encode: r, decode: u } = a(t), s = t;
16
16
  return s.decode = (o, c) => !!u(o, c), s.encode = (o, c, n) => {
17
17
  const d = Number(o);
18
18
  return r(d, c, n);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wormhole-foundation/wormhole-connect",
3
- "version": "3.0.0-beta.0-development",
3
+ "version": "3.0.0-beta.1-development",
4
4
  "repository": "github:wormhole-foundation/wormhole-connect",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.mjs",
@@ -25,6 +25,11 @@
25
25
  "require": "./lib/hosted.js",
26
26
  "import": "./lib/hosted.mjs",
27
27
  "types": "./lib/hosted.d.ts"
28
+ },
29
+ "./executor": {
30
+ "require": "./lib/executor.js",
31
+ "import": "./lib/executor.mjs",
32
+ "types": "./lib/executor.d.ts"
28
33
  }
29
34
  },
30
35
  "files": [
@@ -61,6 +66,7 @@
61
66
  "@wormhole-foundation/sdk-icons": "^1.0.0",
62
67
  "@wormhole-foundation/sdk-route-ntt": "^0.7.1",
63
68
  "@wormhole-foundation/sdk-solana-ntt": "^0.7.1",
69
+ "@wormhole-labs/cctp-executor-route": "0.0.1",
64
70
  "@xlabs-libs/wallet-aggregator-aptos": "1.0.0-alpha.2",
65
71
  "@xlabs-libs/wallet-aggregator-core": "0.0.1-alpha.23",
66
72
  "@xlabs-libs/wallet-aggregator-evm": "0.0.2-alpha.6",
@@ -207,6 +213,15 @@
207
213
  "@wormhole-foundation/sdk-solana": "1.17.0",
208
214
  "@wormhole-foundation/sdk-solana-core": "1.17.0"
209
215
  },
216
+ "@wormhole-labs/cctp-executor-route": {
217
+ "@wormhole-foundation/sdk-aptos": "1.17.0",
218
+ "@wormhole-foundation/sdk-connect": "1.17.0",
219
+ "@wormhole-foundation/sdk-evm": "1.17.0",
220
+ "@wormhole-foundation/sdk-solana": "1.17.0",
221
+ "@wormhole-foundation/sdk-solana-cctp": "1.17.0",
222
+ "@wormhole-foundation/sdk-sui": "1.17.0",
223
+ "@wormhole-foundation/sdk-sui-cctp": "1.17.0"
224
+ },
210
225
  "@wormhole-foundation/wormhole-connect": {
211
226
  "aptos": "1.5.2"
212
227
  },
@@ -1,179 +0,0 @@
1
- var _ = Object.defineProperty;
2
- var w = (e, t, n) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var h = (e, t, n) => w(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { C as y, P as b } from "./chain-DaAd2Ztf.mjs";
5
- import { e as d, s as C, t as S, o as T, z as v } from "./chunk-IMTC3J2M-Bn3rs7tb.mjs";
6
- import { br as A, W as N, a5 as k, k as p, bt as I, bu as x, a1 as B, bq as F } from "./address-DXFbgyJW.mjs";
7
- import { _ as g, A as l, a as E } from "./index-B7U-me-L.mjs";
8
- class f extends y {
9
- }
10
- const c = class c extends b {
11
- constructor(t, n) {
12
- super(t, n ?? A(t, c._platform));
13
- }
14
- getRpc(t) {
15
- if (t in this.config) {
16
- const n = this.network === "Mainnet" ? d.MAINNET : d.TESTNET, a = new C({ fullnode: this.config[t].rpc, network: n });
17
- return new S(a);
18
- }
19
- throw new Error("No configuration available for chain: " + t);
20
- }
21
- getChain(t, n) {
22
- if (t in this.config)
23
- return new f(t, this);
24
- throw new Error("No configuration available for chain: " + t);
25
- }
26
- static nativeTokenId(t, n) {
27
- if (!this.isSupportedChain(n))
28
- throw new Error(`invalid chain: ${n}`);
29
- return N.tokenId(n, l);
30
- }
31
- static isNativeTokenId(t, n, a) {
32
- return !this.isSupportedChain(n) || a.chain !== n ? !1 : this.nativeTokenId(t, n) == a;
33
- }
34
- static isSupportedChain(t) {
35
- return k(t) === c._platform;
36
- }
37
- static async getDecimals(t, n, a) {
38
- if (p(a) || a === l)
39
- return I(c._platform);
40
- const s = a.toString();
41
- return (await n.getFungibleAssetMetadataByAssetType({ assetType: s })).decimals;
42
- }
43
- static async getBalance(t, n, a, s) {
44
- var o;
45
- const r = p(s) ? l : s.toString();
46
- try {
47
- return ((o = (await n.getCurrentFungibleAssetBalances({
48
- options: {
49
- where: {
50
- owner_address: { _eq: a },
51
- asset_type: { _eq: r }
52
- }
53
- }
54
- }))[0]) == null ? void 0 : o.amount) ?? null;
55
- } catch (i) {
56
- if (i.status === 404)
57
- return null;
58
- throw i;
59
- }
60
- }
61
- static async getBalances(t, n, a, s) {
62
- try {
63
- const r = await n.getCurrentFungibleAssetBalances({
64
- options: {
65
- where: {
66
- owner_address: { _eq: a }
67
- }
68
- }
69
- });
70
- let o = {};
71
- for (const i of r)
72
- if (i.asset_type) {
73
- let m = i.asset_type === "0x1::aptos_coin::AptosCoin" ? "native" : i.asset_type;
74
- o[m] = i.amount;
75
- }
76
- return o;
77
- } catch (r) {
78
- if (r.status === 404)
79
- return {};
80
- throw r;
81
- }
82
- }
83
- static async sendWait(t, n, a) {
84
- const s = [];
85
- for (const r of a) {
86
- const o = await n.transaction.submit.simple(r.transaction), i = await n.waitForTransaction({
87
- transactionHash: o.hash
88
- });
89
- s.push(i.hash);
90
- }
91
- return s;
92
- }
93
- static async getLatestBlock(t) {
94
- const n = await t.getLedgerInfo();
95
- return Number(n.block_height);
96
- }
97
- static async getLatestFinalizedBlock(t) {
98
- const n = await t.getLedgerInfo();
99
- return Number(n.block_height);
100
- }
101
- static chainFromChainId(t) {
102
- const n = x(c._platform, BigInt(t));
103
- if (!n)
104
- throw new Error(`No matching chainId to determine network and chain: ${t}`);
105
- const [a, s] = n;
106
- return [a, s];
107
- }
108
- static async chainFromRpc(t) {
109
- const n = await t.getLedgerInfo();
110
- return this.chainFromChainId(n.chain_id.toString());
111
- }
112
- };
113
- h(c, "_platform", g);
114
- let u = c;
115
- async function P(e, t) {
116
- const [n, a] = await u.chainFromRpc(e), s = T.fromPrivateKey({
117
- // TODO: support secp256k1
118
- privateKey: new v(B.decode(t))
119
- });
120
- return new $(a, s, e);
121
- }
122
- class $ {
123
- constructor(t, n, a, s) {
124
- h(this, "_chain");
125
- h(this, "_account");
126
- h(this, "_rpc");
127
- h(this, "_debug");
128
- this._chain = t, this._account = n, this._rpc = a, this._debug = s;
129
- }
130
- chain() {
131
- return this._chain;
132
- }
133
- address() {
134
- return this._account.accountAddress.toString();
135
- }
136
- async signAndSend(t) {
137
- const n = [];
138
- for (const a of t) {
139
- const { description: s, transaction: r } = a;
140
- this._debug && console.log(`Signing: ${s} for ${this.address()}`);
141
- const o = await this._rpc.transaction.build.simple({
142
- sender: this._account.accountAddress,
143
- data: r
144
- }), { hash: i } = await this._simSignSend(o);
145
- n.push(i);
146
- }
147
- return n;
148
- }
149
- async _simSignSend(t) {
150
- return await this._rpc.transaction.simulate.simple({
151
- signerPublicKey: this._account.publicKey,
152
- transaction: t
153
- }).then((n) => n.forEach((a) => {
154
- if (!a.success)
155
- throw new Error(`Transaction failed: ${a.vm_status}
156
- ${JSON.stringify(a, null, 2)}`);
157
- })), this._rpc.signAndSubmitTransaction({ signer: this._account, transaction: t }).then((n) => this._rpc.waitForTransaction({ transactionHash: n.hash }));
158
- }
159
- }
160
- const O = {
161
- Address: E,
162
- Platform: u,
163
- getSigner: P,
164
- protocols: {
165
- WormholeCore: () => import("./index-v0MO46Zl.mjs"),
166
- TokenBridge: () => import("./index-ju2wtFjy.mjs"),
167
- CircleBridge: () => import("./index-Bu6LLuxH.mjs")
168
- },
169
- getChain: (e, t, n) => new f(t, new u(e, F(e, g, {
170
- [t]: n
171
- })))
172
- }, z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
173
- __proto__: null,
174
- default: O
175
- }, Symbol.toStringTag, { value: "Module" }));
176
- export {
177
- u as A,
178
- z as a
179
- };
@@ -1,2 +0,0 @@
1
- "use strict";var m=Object.defineProperty;var w=(s,t,n)=>t in s?m(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var u=(s,t,n)=>w(s,typeof t!="symbol"?t+"":t,n);const f=require("./chain-itK5uGYL.js"),l=require("./chunk-IMTC3J2M-D-un3eDX.js"),c=require("./address-RcMobNYE.js"),d=require("./index-Bc7EWiox.js");class p extends f.ChainContext{}const h=class h extends f.PlatformContext{constructor(t,n){super(t,n??c.networkPlatformConfigs(t,h._platform))}getRpc(t){if(t in this.config){const n=this.network==="Mainnet"?l.e.MAINNET:l.e.TESTNET,e=new l.s({fullnode:this.config[t].rpc,network:n});return new l.t(e)}throw new Error("No configuration available for chain: "+t)}getChain(t,n){if(t in this.config)return new p(t,this);throw new Error("No configuration available for chain: "+t)}static nativeTokenId(t,n){if(!this.isSupportedChain(n))throw new Error(`invalid chain: ${n}`);return c.Wormhole.tokenId(n,d.APTOS_COIN)}static isNativeTokenId(t,n,e){return!this.isSupportedChain(n)||e.chain!==n?!1:this.nativeTokenId(t,n)==e}static isSupportedChain(t){return c.chainToPlatform(t)===h._platform}static async getDecimals(t,n,e){if(c.isNative(e)||e===d.APTOS_COIN)return c.nativeDecimals(h._platform);const a=e.toString();return(await n.getFungibleAssetMetadataByAssetType({assetType:a})).decimals}static async getBalance(t,n,e,a){var o;const r=c.isNative(a)?d.APTOS_COIN:a.toString();try{return((o=(await n.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:e},asset_type:{_eq:r}}}}))[0])==null?void 0:o.amount)??null}catch(i){if(i.status===404)return null;throw i}}static async getBalances(t,n,e,a){try{const r=await n.getCurrentFungibleAssetBalances({options:{where:{owner_address:{_eq:e}}}});let o={};for(const i of r)if(i.asset_type){let _=i.asset_type==="0x1::aptos_coin::AptosCoin"?"native":i.asset_type;o[_]=i.amount}return o}catch(r){if(r.status===404)return{};throw r}}static async sendWait(t,n,e){const a=[];for(const r of e){const o=await n.transaction.submit.simple(r.transaction),i=await n.waitForTransaction({transactionHash:o.hash});a.push(i.hash)}return a}static async getLatestBlock(t){const n=await t.getLedgerInfo();return Number(n.block_height)}static async getLatestFinalizedBlock(t){const n=await t.getLedgerInfo();return Number(n.block_height)}static chainFromChainId(t){const n=c.platformNativeChainIdToNetworkChain(h._platform,BigInt(t));if(!n)throw new Error(`No matching chainId to determine network and chain: ${t}`);const[e,a]=n;return[e,a]}static async chainFromRpc(t){const n=await t.getLedgerInfo();return this.chainFromChainId(n.chain_id.toString())}};u(h,"_platform",d._platform);let g=h;async function y(s,t){const[n,e]=await g.chainFromRpc(s),a=l.o.fromPrivateKey({privateKey:new l.z(c.hex.decode(t))});return new C(e,a,s)}class C{constructor(t,n,e,a){u(this,"_chain");u(this,"_account");u(this,"_rpc");u(this,"_debug");this._chain=t,this._account=n,this._rpc=e,this._debug=a}chain(){return this._chain}address(){return this._account.accountAddress.toString()}async signAndSend(t){const n=[];for(const e of t){const{description:a,transaction:r}=e;this._debug&&console.log(`Signing: ${a} for ${this.address()}`);const o=await this._rpc.transaction.build.simple({sender:this._account.accountAddress,data:r}),{hash:i}=await this._simSignSend(o);n.push(i)}return n}async _simSignSend(t){return await this._rpc.transaction.simulate.simple({signerPublicKey:this._account.publicKey,transaction:t}).then(n=>n.forEach(e=>{if(!e.success)throw new Error(`Transaction failed: ${e.vm_status}
2
- ${JSON.stringify(e,null,2)}`)})),this._rpc.signAndSubmitTransaction({signer:this._account,transaction:t}).then(n=>this._rpc.waitForTransaction({transactionHash:n.hash}))}}const S={Address:d.AptosAddress,Platform:g,getSigner:y,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-BlzRxQ82.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-CJXmILJz.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-Cxg2C7RE.js"))},getChain:(s,t,n)=>new p(t,new g(s,c.applyChainsConfigConfigOverrides(s,d._platform,{[t]:n})))},b=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"}));exports.AptosPlatform=g;exports.aptos=b;
@@ -1 +0,0 @@
1
- "use strict";const e="https://wormholescan.io/#/",o="3.0.0-beta.0-development",n="b0b2c3f88c0be596a3c642533ef666e747640f1f",t=["Ethereum","Solana","Arbitrum","Base","Sui","Bsc","Optimism","Unichain","Fantom","Polygon","Avalanche","Celo","Moonbeam","Klaytn","Scroll","Evmos","Mantle","Berachain","Mezo"];exports.CHAIN_ORDER=t;exports.CONNECT_GIT_HASH=n;exports.CONNECT_VERSION=o;exports.WORMSCAN=e;
@@ -1 +0,0 @@
1
- "use strict";var h=Object.defineProperty;var m=(a,e,t)=>e in a?h(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>m(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./address-RcMobNYE.js"),w=require("./aptos-hc5GrCHO.js"),g=require("./create-DO_-1_Hb.js"),u=require("./chain-itK5uGYL.js");class i{constructor(e,t,r,s){o(this,"network");o(this,"chain");o(this,"connection");o(this,"contracts");o(this,"chainId");o(this,"coreBridge");this.network=e,this.chain=t,this.connection=r,this.contracts=s,this.chainId=c.toChainId(t);const n=s.coreBridge;if(!n)throw new Error(`CoreBridge contract Address for chain ${t} not found`);this.coreBridge=n}getGuardianSet(e){throw new Error("Method not implemented.")}getGuardianSetIndex(){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,t){const[r,s]=await w.AptosPlatform.chainFromRpc(e),n=t[s];if(n.network!==r)throw new Error(`Network mismatch: ${n.network} !== ${r}`);return new i(r,s,e,n.contracts)}async*publishMessage(e,t){throw new Error("Method not implemented.")}async*verifyMessage(e,t){throw new Error("Not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(r=>({chain:r.emitterChain,emitter:r.emitterAddress,sequence:r.sequence}))}async parseMessages(e){const t=await this.connection.getTransactionByHash({transactionHash:e});if(t.type!=="user_transaction")throw new Error(`${e} is not a user_transaction`);const r=t.events.filter(s=>s.type.endsWith("WormholeMessage"));if(!r||r.length===0)throw new Error(`WormholeMessage not found for ${e}`);return r.map(s=>{const n=s.data,d=new c.UniversalAddress(BigInt(n.sender).toString(16).padStart(64,"0"));return g.createVAA("Uint8Array",{guardianSet:0,emitterChain:this.chain,emitterAddress:d,sequence:BigInt(n.sequence),timestamp:Number(n.timestamp),consistencyLevel:n.consistency_level,nonce:Number(n.nonce),signatures:[],payload:c.hex.decode(n.payload)})})}}u.registerProtocol("Aptos","WormholeCore",i);exports.AptosWormholeCore=i;
@@ -1 +0,0 @@
1
- "use strict";var y=Object.defineProperty;var g=(o,e,t)=>e in o?y(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var d=(o,e,t)=>g(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./address-RcMobNYE.js"),i=require("./index-Bc7EWiox.js"),f=require("./unsignedTransaction-C1YeEl4G.js"),w=require("./aptos-hc5GrCHO.js"),T=require("./chain-itK5uGYL.js"),m=[{name:"tokenBridgeAddress",...r.universalAddressItem},{name:"chain",...r.chainItem()},{name:"domainSeparator",binary:"bytes",custom:r.bytes.encode(i.APTOS_SEPARATOR),omit:!0},{name:"tokenId",...r.universalAddressItem},{name:"domainSeparator",binary:"bytes",custom:new Uint8Array([255]),omit:!0}],k=o=>r.serialize$1(m,o);class c{constructor(e,t,s,n){d(this,"network");d(this,"chain");d(this,"connection");d(this,"contracts");d(this,"chainId");d(this,"tokenBridgeAddress");this.network=e,this.chain=t,this.connection=s,this.contracts=n,this.chainId=r.toChainId(t);const a=n.tokenBridge;if(!a)throw new Error(`TokenBridge contract Address for chain ${t} not found`);this.tokenBridgeAddress=a}static async fromRpc(e,t){const[s,n]=await w.AptosPlatform.chainFromRpc(e),a=t[n];if(a.network!==s)throw new Error("Network mismatch "+a.network+" !== "+s);return new c(s,n,e,a.contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{return!1}}async getOriginalAsset(e){const t=e.toString().split(i.APTOS_SEPARATOR),s=await this.connection.getAccountResource({accountAddress:t[0],resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`});if(!s)throw r.ErrNotWrapped(e.toString());const n=r.toChain(parseInt(s.token_chain.number)),a=new r.UniversalAddress(s.token_address.external_address);return{chain:n,address:a}}async getTokenUniversalAddress(e){return new r.UniversalAddress(r.hex.encode(r.sha3_256(e.toString()),!0))}async getTokenNativeAddress(e,t){const s=e===this.chain?await this.getTypeFromExternalAddress(t.toString()):await this.getAssetFullyQualifiedType({chain:e,address:t});if(!s)throw new Error("Invalid asset address.");return new i.AptosAddress(s)}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(r.isNative(e.address))throw new Error("native asset cannot be a wrapped asset");const t=await this.getAssetFullyQualifiedType(e);if(!t)throw new Error("Invalid asset address.");return await this.connection.getAccountResource({accountAddress:i.coalesceModuleAddress(t),resourceType:`${this.tokenBridgeAddress}::state::OriginInfo`}),r.toNative(this.chain,t)}async isTransferCompleted(e){const s=(await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`})).consumed_vaas.elems.handle;try{return await this.connection.getTableItem({handle:s,data:{key_type:"vector<u8>",value_type:"u8",key:`0x${r.dist.Buffer.from(r.keccak_256(e.hash)).toString("hex")}`}}),!0}catch{return!1}}async getWrappedNative(){return r.toNative(this.chain,i.APTOS_COIN)}async*createAttestation(e,t){const s={chain:this.chain,address:new i.AptosAddress(e)},n=await this.getAssetFullyQualifiedType(s);if(!n)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::attest_token::attest_token_entry`,typeArguments:[n],functionArguments:[]},"Aptos.AttestToken")}async*submitAttestation(e,t){yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin_type`,typeArguments:[],functionArguments:[r.serialize(e)]},"Aptos.CreateWrappedCoinType");const s=await this.getAssetFullyQualifiedType(e.payload.token);if(!s)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::wrapped::create_wrapped_coin`,typeArguments:[s],functionArguments:[r.serialize(e)]},"Aptos.CreateWrappedCoin")}async*transfer(e,t,s,n,a){const l=0n,h=0n,u=r.isNative(s)?i.APTOS_COIN:s.toString(),A=t.address.toUniversalAddress().toUint8Array(),p=r.toChainId(t.chain);a?yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_with_payload_entry`,typeArguments:[u],functionArguments:[n,p,A,h,a]},"Aptos.TransferTokensWithPayload"):yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::transfer_tokens::transfer_tokens_entry`,typeArguments:[u],functionArguments:[n,p,A,l,h]},"Aptos.TransferTokens")}async*redeem(e,t,s=!0){const n=t.payload.token.chain===this.chain?await this.getTypeFromExternalAddress(t.payload.token.address.toString()):await this.getAssetFullyQualifiedType(t.payload.token);if(!n)throw new Error("Invalid asset address.");yield this.createUnsignedTx({function:`${this.tokenBridgeAddress}::complete_transfer::submit_vaa_and_register_entry`,typeArguments:[n],functionArguments:[r.serialize(t)]},"Aptos.CompleteTransfer")}async getAssetFullyQualifiedType(e){return e.chain===this.chain?i.isValidAptosType(e.address.toString())?e.address.toString():null:`${c.getForeignAssetAddress(this.chain,this.tokenBridgeAddress,e)}::coin::T`}async getTypeFromExternalAddress(e){try{const t=await this.connection.getAccountResource({accountAddress:this.tokenBridgeAddress,resourceType:`${this.tokenBridgeAddress}::state::State`}),{handle:s}=t.native_infos,n=await this.connection.getTableItem({handle:s,data:{key_type:`${this.tokenBridgeAddress}::token_hash::TokenHash`,value_type:"0x1::type_info::TypeInfo",key:{hash:e}}});return n?[n.account_address,String.fromCharCode(...r.hex.decode(n.module_name)),String.fromCharCode(...r.hex.decode(n.struct_name))].join(i.APTOS_SEPARATOR):null}catch{return null}}static getForeignAssetAddress(e,t,s){if(r.isNative(s.address))throw new Error("Invalid token address");const n=k({chain:s.chain,tokenBridgeAddress:new i.AptosAddress(t).toUniversalAddress(),tokenId:s.address.toUniversalAddress()});return r.hex.encode(r.sha3_256(n),!0)}createUnsignedTx(e,t,s=!1){return new f.AptosUnsignedTransaction(e,this.network,this.chain,t,s)}}T.registerProtocol("Aptos","TokenBridge",c);exports.AptosTokenBridge=c;
@@ -1,46 +0,0 @@
1
- import { ce as L, cn as g, co as F, b$ as w, c2 as h, bw as P, bx as T } from "./address-DXFbgyJW.mjs";
2
- function D(n, t, e, s) {
3
- g(n);
4
- const a = F({ dkLen: 32, asyncTick: 10 }, s), { c: u, dkLen: c, asyncTick: o } = a;
5
- if (w(u), w(c), w(o), u < 1)
6
- throw new Error("PBKDF2: iterations (c) should be >= 1");
7
- const d = h(t), i = h(e), f = new Uint8Array(c), l = P.create(n, d), r = l._cloneInto().update(i);
8
- return { c: u, dkLen: c, asyncTick: o, DK: f, PRF: l, PRFSalt: r };
9
- }
10
- function K(n, t, e, s, a) {
11
- return n.destroy(), t.destroy(), s && s.destroy(), a.fill(0), e;
12
- }
13
- function R(n, t, e, s) {
14
- const { c: a, dkLen: u, DK: c, PRF: o, PRFSalt: d } = D(n, t, e, s);
15
- let i;
16
- const f = new Uint8Array(4), l = L(f), r = new Uint8Array(o.outputLen);
17
- for (let k = 1, p = 0; p < u; k++, p += o.outputLen) {
18
- const m = c.subarray(p, p + o.outputLen);
19
- l.setInt32(0, k, !1), (i = d._cloneInto(i)).update(f).digestInto(r), m.set(r.subarray(0, m.length));
20
- for (let b = 1; b < a; b++) {
21
- o._cloneInto(i).update(r).digestInto(r);
22
- for (let y = 0; y < m.length; y++)
23
- m[y] ^= r[y];
24
- }
25
- }
26
- return K(o, d, c, i, r);
27
- }
28
- /*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
29
- function I(n) {
30
- if (typeof n != "string")
31
- throw new TypeError("invalid mnemonic type: " + typeof n);
32
- return n.normalize("NFKD");
33
- }
34
- function S(n) {
35
- const t = I(n), e = t.split(" ");
36
- if (![12, 15, 18, 21, 24].includes(e.length))
37
- throw new Error("Invalid mnemonic");
38
- return { nfkd: t, words: e };
39
- }
40
- const v = (n) => I("mnemonic" + n);
41
- function E(n, t = "") {
42
- return R(T, S(n).nfkd, v(t), { c: 2048, dkLen: 64 });
43
- }
44
- export {
45
- E as m
46
- };
@@ -1 +0,0 @@
1
- "use strict";var Ee=Object.defineProperty;var Pe=(r,e,t)=>e in r?Ee(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>Pe(r,typeof e!="symbol"?e+"":e,t);const i=require("./address-RcMobNYE.js"),l=require("./index-FCA-cXcS.js"),Z=require("./unsignedTransaction-DFUF8DSp.js"),Be=require("./create-DO_-1_Hb.js"),xe=require("./chain-itK5uGYL.js"),ee=r=>typeof r=="string"?i.dist.Buffer.from(r):r;function S(r,e){return i.PublicKey.findProgramAddressSync(Array.isArray(r)?r.map(ee):[ee(r)],new i.PublicKey(e))[0]}function Ke(r,e){return{pubkey:new i.PublicKey(r),isWritable:!0,isSigner:e}}function Le(r,e){return{pubkey:new i.PublicKey(r),isWritable:!1,isSigner:e}}function K(r){if(r===null)throw Error("account info is null");return r.data}const Y=new i.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111");function re(r){return S([new i.PublicKey(r).toBuffer()],Y)}class Ue extends Error{constructor(e){super(e),this.name="IdlError"}}function N(r,e){switch(e.type.kind){case"struct":return e.type.fields.map(t=>M(r,t.type)).reduce((t,n)=>t+n,0);case"enum":{const t=e.type.variants.map(n=>n.fields?n.fields.map(s=>typeof s=="object"&&"name"in s?M(r,s.type):M(r,s)).reduce((s,a)=>s+a,0):0);return Math.max(...t)+1}case"alias":return M(r,e.type.value)}}function M(r,e){var t;switch(e){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"publicKey":return 32;default:if("vec"in e)return 1;if("option"in e)return 1+M(r,e.option);if("coption"in e)return 4+M(r,e.coption);if("defined"in e){const n=((t=r.types)==null?void 0:t.filter(a=>a.name===e.defined))??[];if(n.length!==1)throw new Ue(`Type not found: ${JSON.stringify(e)}`);let s=n[0];return N(r,s)}if("array"in e){let n=e.array[0],s=e.array[1];return M(r,n)*s}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}function U(r){return r.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toLowerCase():e.toUpperCase()}).replace(/[\s\-_]+/g,"")}function Ce(r){return r.charAt(0).toUpperCase()+r.slice(1)}const se=[{name:"discriminator",binary:"bytes",size:4},{name:"consistencyLevel",binary:"uint",size:1,endianness:"little"},{name:"emitterAuthority",...i.universalAddressItem},{name:"messageStatus",binary:"uint",size:1,endianness:"little"},{name:"gap",binary:"uint",size:3},{name:"timestamp",binary:"uint",size:4,endianness:"little"},{name:"nonce",binary:"uint",size:4,endianness:"little"},{name:"sequence",binary:"uint",size:8,endianness:"little"},{name:"emitterChain",binary:"uint",size:2,endianness:"little"},{name:"emitterAddress",...i.universalAddressItem},{name:"payloadLength",binary:"uint",size:4,endianness:"little"},{name:"payload",binary:"bytes"}];function ie(r){return i.deserialize$1(se,r)}function E(r,e,t,n){const s=typeof e=="string"?i.dist.Buffer.from(e,"hex"):i.dist.Buffer.from(e);if(s.length!=32)throw Error("address.length != 32");const a=i.dist.Buffer.alloc(8);return a.writeBigUInt64BE(typeof n=="number"?BigInt(n):n),S([s,(()=>{const o=i.dist.Buffer.alloc(2);return o.writeUInt16BE(t),o})(),a],r)}async function ae(r,e,t,n,s,a){return r.getAccountInfo(E(e,t,n,s),a).then(o=>!!K(o)[0])}function p(r){return S([i.dist.Buffer.from("Bridge")],r)}async function oe(r,e,t){return r.getAccountInfo(p(e),t).then(n=>z.deserialize(K(n)))}class k{constructor(e,t){c(this,"guardianSetExpirationTime");c(this,"fee");this.guardianSetExpirationTime=e,this.fee=t}static deserialize(e){if(e.length!=12)throw new Error("data.length != 12");const t=e.readUInt32LE(0),n=e.readBigUInt64LE(4);return new k(t,n)}}class z{constructor(e,t,n){c(this,"guardianSetIndex");c(this,"lastLamports");c(this,"config");this.guardianSetIndex=e,this.lastLamports=t,this.config=n}static deserialize(e){if(e.length!=24)throw new Error("data.length != 24");const t=e.readUInt32LE(0),n=e.readBigUInt64LE(4),s=k.deserialize(e.subarray(12));return new z(t,n,s)}}function _(r,e){return S([i.dist.Buffer.from("Sequence"),new i.PublicKey(r).toBytes()],e)}async function ue(r,e,t,n){return r.getAccountInfo(_(e,t),n).then(s=>q.deserialize(K(s)))}class q{constructor(e,t,n){c(this,"sequence");c(this,"bump");c(this,"emitterType");this.sequence=e,this.bump=t,this.emitterType=n}static deserialize(e){if(e.length!==8&&e.length!==10)throw new Error("data.length != 8 or data.length != 10");let t,n;const s=e.readBigUInt64LE(0);return e.length===10&&(t=e[8],n=e[9]),new q(s,t,n)}value(){return this.sequence}}function V(r){return S([i.dist.Buffer.from("emitter")],r)}function G(r,e){const t=V(r);return{emitter:t,sequence:_(t,e)}}async function ce(r,e,t,n){return ue(r,V(e),t,n)}function P(r){return S([i.dist.Buffer.from("fee_collector")],r)}const te=65,C=20;function _e(r,e,t){return new i.TransactionInstruction({keys:[],programId:i.Secp256k1Program.programId,data:Te.serialize(r,e,t)})}class Te{static serialize(e,t,n){if(e.length==0)throw Error("signatures.length == 0");if(e.length!=t.length)throw Error("signatures.length != keys.length");if(n.length!=32)throw Error("message.length != 32");const s=e.length,a=11,o=1+s*a,u=te+C,d=o+s*u,f=32,g=i.dist.Buffer.alloc(d+f);g.writeUInt8(s,0),g.write(n.toString("hex"),d,"hex");for(let m=0;m<s;++m){const y=e.at(m);if((y==null?void 0:y.length)!=te)throw Error(`signatures[${m}].length != 65`);const h=t.at(m);if((h==null?void 0:h.length)!=C)throw Error(`keys[${m}].length != 20`);const A=o+u*m,L=A+65;g.writeUInt16LE(A,1+m*a),g.writeUInt8(0,3+m*a),g.writeUInt16LE(L,4+m*a),g.writeUInt8(0,6+m*a),g.writeUInt16LE(d,7+m*a),g.writeUInt16LE(f,9+m*a),g.writeUInt8(0,10+m*a),g.write(y.toString("hex"),A,"hex"),g.write(h.toString("hex"),L,"hex")}return g}}function I(r,e){return S([i.dist.Buffer.from("GuardianSet"),(()=>{const t=i.dist.Buffer.alloc(4);return t.writeUInt32BE(e),t})()],r)}async function $(r,e,t,n){return r.getAccountInfo(I(e,t),n).then(s=>F.deserialize(K(s)))}class F{constructor(e,t,n,s){c(this,"index");c(this,"keys");c(this,"creationTime");c(this,"expirationTime");this.index=e,this.keys=t,this.creationTime=n,this.expirationTime=s}static deserialize(e){const t=e.readUInt32LE(0),n=e.readUInt32LE(4),s=8+n*C,a=e.readUInt32LE(s),o=e.readUInt32LE(4+s),u=[];for(let d=0;d<n;++d){const f=8+d*C;u.push(e.subarray(f,f+C))}return new F(t,u,a,o)}}function b(r,e){return S([i.dist.Buffer.from("PostedVAA"),e],r)}async function ve(r,e,t){return r.getAccountInfo(new i.PublicKey(e),t).then(n=>R.deserialize(K(n)))}class R{constructor(e,t,n){c(this,"signatures");c(this,"hash");c(this,"guardianSetIndex");this.signatures=e,this.hash=t,this.guardianSetIndex=n}static deserialize(e){const t=e.readUInt32LE(0),n=[...e.subarray(4,4+t)].map(u=>u!=0),s=4+t,a=e.subarray(s,s+32),o=e.readUInt32LE(s+32);return new R(n,a,o)}}function W(r){return S([i.dist.Buffer.from("upgrade")],r)}function j(r,e,t){return i.SystemProgram.transfer({fromPubkey:new i.PublicKey(e),toPubkey:P(r),lamports:t})}class ke{constructor(e){c(this,"idl");this.idl=e}async encode(e,t){switch(e){default:throw new Error(`Invalid account name: ${e}`)}}decode(e,t){return this.decodeUnchecked(e,t)}decodeUnchecked(e,t){switch(e){default:throw new Error(`Invalid account name: ${e}`)}}memcmp(e,t){switch(e){case"postVaa":return{dataSize:56};default:throw new Error(`Invalid account name: ${e}`)}}size(e){return N(this.idl,e)??0}}class ze{constructor(e){}decode(e){throw new Error("Wormhole program does not have events")}}class B{static fieldLayout(e,t){const n=e.name!==void 0?U(e.name):void 0;switch(e.type){case"bool":return l.dist.bool(n);case"u8":return l.dist.u8(n);case"i8":return l.dist.i8(n);case"u16":return l.dist.u16(n);case"i16":return l.dist.i16(n);case"u32":return l.dist.u32(n);case"i32":return l.dist.i32(n);case"f32":return l.dist.f32(n);case"u64":return l.dist.u64(n);case"i64":return l.dist.i64(n);case"f64":return l.dist.f64(n);case"u128":return l.dist.u128(n);case"i128":return l.dist.i128(n);case"u256":return l.dist.u256(n);case"i256":return l.dist.i256(n);case"bytes":return l.dist.vecU8(n);case"string":return l.dist.str(n);case"publicKey":return l.dist.publicKey(n);default:{if("vec"in e.type)return l.dist.vec(B.fieldLayout({name:void 0,type:e.type.vec},t),n);if("option"in e.type)return l.dist.option(B.fieldLayout({name:void 0,type:e.type.option},t),n);if("array"in e.type){let s=e.type.array[0],a=e.type.array[1],o=B.fieldLayout({name:void 0,type:s},t);return l.dist.array(o,a,n)}else throw new Error(`Not yet implemented: ${e}`)}}}}class H{constructor(e){c(this,"ixLayout");this.ixLayout=H.parseIxLayout(e)}static parseIxLayout(e){const n=(e.instructions?e.instructions:[]).map(s=>{let a=s.args.map(u=>B.fieldLayout(u,Array.from([...e.accounts??[],...e.types??[]])));const o=U(s.name);return[o,l.dist.struct(a,o)]}).concat(e.instructions.map(s=>{let a=s.args.map(u=>B.fieldLayout(u,Array.from([...e.accounts??[],...e.types??[]])));const o=U(s.name);return[o,l.dist.struct(a,o)]}));return new Map(n)}encode(e,t){const n=i.dist.Buffer.alloc(1e3),s=U(e),a=this.ixLayout.get(s);if(!a)throw new Error(`Unknown method: ${s}`);const o=a.encode(t,n),u=n.slice(0,o);return qe(v[Ce(s)],u)}encodeState(e,t){throw new Error("Wormhole program does not have state")}decode(e,t="hex"){var u;typeof e=="string"&&(e=t==="hex"?i.dist.Buffer.from(e,"hex"):i.b58.decode(e));let n=i.dist.Buffer.from(e.slice(0,1)).readInt8(),s=i.dist.Buffer.from(e.slice(1)),a=U(v[n]??"");return this.ixLayout.get(a)?{data:(u=this.ixLayout.get(a))==null?void 0:u.decode(s),name:a}:null}}var v;(function(r){r[r.Initialize=0]="Initialize",r[r.PostMessage=1]="PostMessage",r[r.PostVaa=2]="PostVaa",r[r.SetFees=3]="SetFees",r[r.TransferFees=4]="TransferFees",r[r.UpgradeContract=5]="UpgradeContract",r[r.UpgradeGuardianSet=6]="UpgradeGuardianSet",r[r.VerifySignatures=7]="VerifySignatures",r[r.PostMessageUnreliable=8]="PostMessageUnreliable"})(v||(v={}));function qe(r,e){const t=i.dist.Buffer.alloc(1+(e===void 0?0:e.length));return t.writeUInt8(r,0),e!==void 0&&t.write(e.toString("hex"),1,"hex"),t}class Ve{constructor(e){}encode(e,t){throw new Error("Wormhole program does not have state")}decode(e){throw new Error("Wormhole program does not have state")}}class Fe{constructor(e){}encode(e,t){throw new Error("Wormhole program does not have user-defined types")}decode(e,t){throw new Error("Wormhole program does not have user-defined types")}}class Re{constructor(e){c(this,"instruction");c(this,"accounts");c(this,"state");c(this,"events");c(this,"types");this.instruction=new H(e),this.accounts=new ke(e),this.state=new Ve(e),this.events=new ze(e),this.types=new Fe(e)}}const J={version:"0.1.0",name:"wormhole",instructions:[{name:"initialize",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"guardianSet",isMut:!0,isSigner:!1},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"guardianSetExpirationTime",type:"u32"},{name:"fee",type:"u64"},{name:"initialGuardians",type:{vec:{array:["u8",20]}}}]},{name:"postMessage",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"message",isMut:!0,isSigner:!0},{name:"emitter",isMut:!1,isSigner:!0},{name:"sequence",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"payload",type:"bytes"},{name:"consistencyLevel",type:"u8"}]},{name:"postVaa",accounts:[{name:"guardianSet",isMut:!1,isSigner:!1},{name:"bridge",isMut:!1,isSigner:!1},{name:"signatureSet",isMut:!1,isSigner:!1},{name:"vaa",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"version",type:"u8"},{name:"guardianSetIndex",type:"u32"},{name:"timestamp",type:"u32"},{name:"nonce",type:"u32"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"sequence",type:"u64"},{name:"consistencyLevel",type:"u8"},{name:"payload",type:"bytes"}]},{name:"setFees",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"transferFees",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"recipient",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeContract",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"upgradeAuthority",isMut:!1,isSigner:!1},{name:"spill",isMut:!0,isSigner:!1},{name:"implementation",isMut:!0,isSigner:!1},{name:"programData",isMut:!0,isSigner:!1},{name:"wormholeProgram",isMut:!0,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"bpfLoaderUpgradeable",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"upgradeGuardianSet",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"bridge",isMut:!0,isSigner:!1},{name:"vaa",isMut:!1,isSigner:!1},{name:"claim",isMut:!0,isSigner:!1},{name:"guardianSetOld",isMut:!0,isSigner:!1},{name:"guardianSetNew",isMut:!0,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[]},{name:"verifySignatures",accounts:[{name:"payer",isMut:!0,isSigner:!0},{name:"guardianSet",isMut:!1,isSigner:!1},{name:"signatureSet",isMut:!0,isSigner:!0},{name:"instructions",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"signatureStatus",type:{array:["i8",19]}}]},{name:"postMessageUnreliable",accounts:[{name:"bridge",isMut:!0,isSigner:!1},{name:"message",isMut:!0,isSigner:!0},{name:"emitter",isMut:!1,isSigner:!0},{name:"sequence",isMut:!0,isSigner:!1},{name:"payer",isMut:!0,isSigner:!0},{name:"feeCollector",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"nonce",type:"u32"},{name:"payload",type:"bytes"},{name:"consistencyLevel",type:"u8"}]}],accounts:[{name:"PostedMessage",type:{kind:"struct",fields:[{name:"vaaVersion",type:"u8"},{name:"consistencyLevel",type:"u8"},{name:"vaaTime",type:"u32"},{name:"vaaSignatureAccount",type:"publicKey"},{name:"submissionTime",type:"u32"},{name:"nonce",type:"u32"},{name:"sequence",type:"u64"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"payload",type:"bytes"}]}},{name:"PostedVAA",type:{kind:"struct",fields:[{name:"vaaVersion",type:"u8"},{name:"consistencyLevel",type:"u8"},{name:"vaaTime",type:"u32"},{name:"vaaSignatureAccount",type:"publicKey"},{name:"submissionTime",type:"u32"},{name:"nonce",type:"u32"},{name:"sequence",type:"u64"},{name:"emitterChain",type:"u16"},{name:"emitterAddress",type:{array:["u8",32]}},{name:"payload",type:"bytes"}]}}]};function de(r,e){return new l.Program(J,new i.PublicKey(r),e===void 0?{connection:null}:e,ge())}function w(r,e){return de(r,l.createReadOnlyProvider(e))}function ge(){return new Re(J)}function De(r,e,t,n){const s=w(e,r).methods.setFees();return s._ixFn(...s._args,{accounts:fe(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function fe(r,e,t){return{payer:new i.PublicKey(e),bridge:p(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),systemProgram:i.SystemProgram.programId}}function Oe(r,e,t,n,s){const a=w(e,r).methods.transferFees();return a._ixFn(...a._args,{accounts:le(e,t,n,s),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function le(r,e,t,n){return{payer:new i.PublicKey(e),bridge:p(r),vaa:b(r,i.dist.Buffer.from(n.hash)),claim:E(r,n.emitterAddress.toString(),i.toChainId(n.emitterChain),n.sequence),feeCollector:P(r),recipient:new i.PublicKey(t),rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function Ye(r,e,t,n){const s=w(e,r).methods.upgradeGuardianSet();return s._ixFn(...s._args,{accounts:me(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function me(r,e,t){return{payer:new i.PublicKey(e),bridge:p(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),guardianSetOld:I(r,t.guardianSet),guardianSetNew:I(r,t.guardianSet+1),systemProgram:i.SystemProgram.programId}}function Ne(r,e,t,n){const s=w(e,r).methods.upgradeContract();return s._ixFn(...s._args,{accounts:ye(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function ye(r,e,t,n){const{newContract:s}=t.payload.actionArgs;return{payer:new i.PublicKey(e),bridge:p(r),vaa:b(r,i.dist.Buffer.from(t.hash)),claim:E(r,t.emitterAddress.toString(),i.toChainId(t.emitterChain),t.sequence),upgradeAuthority:W(r),spill:new i.PublicKey(n===void 0?e:n),implementation:new i.SolanaAddress(s).unwrap(),programData:re(r),wormholeProgram:new i.PublicKey(r),rent:i.SYSVAR_RENT_PUBKEY,clock:i.SYSVAR_CLOCK_PUBKEY,bpfLoaderUpgradeable:Y,systemProgram:i.SystemProgram.programId}}function Ge(r,e,t,n,s,a){const o=w(e,r).methods.initialize(n,new i.BN(s.toString()),[...a.map(u=>[...new Uint8Array(u)])]);return o._ixFn(...o._args,{accounts:pe(e,t),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function pe(r,e){return{bridge:p(r),guardianSet:I(r,0),feeCollector:P(r),payer:new i.PublicKey(e),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function he(r,e,t,n,s,a,o){const u=w(e,r).methods.postMessage(a,i.dist.Buffer.from(s),o);return u._ixFn(...u._args,{accounts:D(e,t,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function D(r,e,t,n){let s;return n?{emitter:n,sequence:s}=G(n,r):(n=e,s=_(n,r)),{bridge:p(r),message:new i.PublicKey(t),emitter:new i.PublicKey(n),sequence:s,payer:new i.PublicKey(e),feeCollector:P(r),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function Se(r,e,t,n,s){const a=w(e,r).methods.postVaa(1,n.guardianSet,n.timestamp,n.nonce,i.toChainId(n.emitterChain),[...n.emitterAddress.toUint8Array()],new i.BN(n.sequence.toString()),n.consistencyLevel,i.dist.Buffer.from(i.serializePayload(n.payloadLiteral,n.payload)));return a._ixFn(...a._args,{accounts:we(e,t,s,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function we(r,e,t,n){return{guardianSet:I(r,n.guardianSet),bridge:p(r),signatureSet:new i.PublicKey(t),vaa:b(r,i.dist.Buffer.from(n.hash)),payer:new i.PublicKey(e),clock:i.SYSVAR_CLOCK_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}const $e=19;async function Ae(r,e,t,n,s,a){const o=n.guardianSet,u=await $(r,e,o,a),d=n.signatures,f=u.keys,g=7,m=[];for(let y=0;y<Math.ceil(d.length/g);++y){const h=y*g,A=Math.min(d.length,(y+1)*g),L=new Array($e).fill(-1),Q=[],X=[];for(let T=0;T<A-h;++T){const O=d.at(T+h);Q.push(i.dist.Buffer.from(O.signature.encode())),X.push(f.at(O.guardianIndex)),L[O.guardianIndex]=T}m.push(_e(Q,X,i.dist.Buffer.from(n.hash))),m.push(We(r,e,t,n,s,L))}return m}function We(r,e,t,n,s,a){const o=w(e,r).methods.verifySignatures(a);return o._ixFn(...o._args,{accounts:be(e,t,s,n),signers:void 0,remainingAccounts:void 0,preInstructions:void 0,postInstructions:void 0})}function be(r,e,t,n){return{payer:new i.PublicKey(e),guardianSet:I(r,n.guardianSet),signatureSet:new i.PublicKey(t),instructions:i.SYSVAR_INSTRUCTIONS_PUBKEY,rent:i.SYSVAR_RENT_PUBKEY,systemProgram:i.SystemProgram.programId}}function Me(r,e){const{emitter:t,sequence:n}=G(r,e);return{wormholeBridge:p(e),wormholeEmitter:t,wormholeSequence:n,wormholeFeeCollector:P(e)}}function Ie(r,e,t,n){const s=D(e,t,n,r);return{payer:s.payer,wormholeBridge:s.bridge,wormholeMessage:s.message,wormholeEmitter:s.emitter,wormholeSequence:s.sequence,wormholeFeeCollector:s.feeCollector,clock:s.clock,rent:s.rent,systemProgram:s.systemProgram}}const je=Object.freeze(Object.defineProperty({__proto__:null,BridgeConfig:k,BridgeData:z,GuardianSetData:F,SequenceTracker:q,SignatureSetData:R,coder:ge,createBridgeFeeTransferInstruction:j,createInitializeInstruction:Ge,createPostMessageInstruction:he,createPostVaaInstruction:Se,createReadOnlyWormholeProgramInterface:w,createSetFeesInstruction:De,createTransferFeesInstruction:Oe,createUpgradeContractInstruction:Ne,createUpgradeGuardianSetInstruction:Ye,createVerifySignaturesInstructions:Ae,createWormholeProgramInterface:de,deriveClaimKey:E,deriveEmitterSequenceKey:_,deriveFeeCollectorKey:P,deriveGuardianSetKey:I,derivePostedVaaKey:b,deriveUpgradeAuthorityKey:W,deriveWormholeBridgeDataKey:p,deriveWormholeEmitterKey:V,getClaim:ae,getEmitterKeys:G,getGuardianSet:$,getInitializeAccounts:pe,getPostMessageAccounts:D,getPostMessageCpiAccounts:Ie,getPostVaaAccounts:we,getProgramSequenceTracker:ce,getSequenceTracker:ue,getSetFeesAccounts:fe,getSignatureSetData:ve,getTransferFeesAccounts:le,getUpgradeContractAccounts:ye,getUpgradeGuardianSetAccounts:me,getVerifySignatureAccounts:be,getWormholeBridgeData:oe,getWormholeDerivedAccounts:Me},Symbol.toStringTag,{value:"Module"})),ne="Program log: Sequence: ";class x{constructor(e,t,n,s){c(this,"network");c(this,"chain");c(this,"connection");c(this,"contracts");c(this,"chainId");c(this,"coreBridge");c(this,"address");c(this,"bridgeData");this.network=e,this.chain=t,this.connection=n,this.contracts=s,this.chainId=i.toChainId(t);const a=s.coreBridge;if(!a)throw new Error(`CoreBridge contract Address for chain ${t} not found`);this.address=a,this.coreBridge=w(a,n)}async getGuardianSet(e){const t=await $(this.connection,this.coreBridge.programId,e);return{index:t.index,keys:t.keys.map(n=>n.toString("hex")),expiry:BigInt(t.expirationTime)}}static async fromRpc(e,t){const[n,s]=await Z.SolanaPlatform.chainFromRpc(e),a=t[s];if(a.network!==n)throw new Error(`Network mismatch for chain ${s}: ${a.network} != ${n}`);return new x(n,s,e,t[s].contracts)}async ensureBridgeConfig(){this.bridgeData||(this.bridgeData=await oe(this.connection,this.coreBridge.programId))}async getMessageFee(){return await this.ensureBridgeConfig(),this.bridgeData.config.fee}async getGuardianSetIndex(){return await this.ensureBridgeConfig(),this.bridgeData.guardianSetIndex}async*publishMessage(e,t,n,s){const a=i.Keypair.generate(),o=new i.SolanaAddress(e).unwrap(),u=he(this.connection,this.coreBridge.programId,o,a.publicKey,t,n,s),d=await this.getMessageFee(),f=j(this.coreBridge.programId,o,d),g=new i.Transaction;g.feePayer=o,g.add(f,u),yield this.createUnsignedTx({transaction:g,signers:[a]},"Core.PublishMessage")}async*verifyMessage(e,t){yield*this.postVaa(e,t)}async*postVaa(e,t){const n=b(this.coreBridge.programId,i.dist.Buffer.from(t.hash));if(await this.connection.getAccountInfo(n))return;const a=new i.SolanaAddress(e).unwrap(),o=i.Keypair.generate(),u=await Ae(this.connection,this.coreBridge.programId,a,t,o.publicKey);for(let f=0;f<u.length;f+=2){const g=new i.Transaction().add(...u.slice(f,f+2));g.feePayer=a,yield this.createUnsignedTx({transaction:g,signers:[o]},"Core.VerifySignature",!0)}const d=new i.Transaction().add(Se(this.connection,this.coreBridge.programId,a,t,o.publicKey));d.feePayer=a,yield this.createUnsignedTx({transaction:d},"Core.PostVAA")}static parseSequenceFromLog(e,t){var d,f,g,m;const{meta:n,transaction:{message:s}}=t;if(!((d=n==null?void 0:n.innerInstructions)!=null&&d.length))return[];const a=s.staticAccountKeys;if(a.filter(y=>y.toString()===e).length===0)return[];const o=(m=(g=(f=n==null?void 0:n.logMessages)==null?void 0:f.filter(y=>y.startsWith(ne)))==null?void 0:g[0])==null?void 0:m.replace(ne,"");if(!o)return[];const u=[];for(const y of n==null?void 0:n.innerInstructions){const h=y.instructions;u.push(...h.filter(A=>A.programIdIndex in a&&a[A.programIdIndex].toString()===e))}return u.length<1?[]:a.length<3?[]:u.map(y=>[new i.SolanaAddress(a[y.accounts[2]]).toUniversalAddress(),BigInt(o)]).filter(y=>y!==null)}async getMessageAccountKeys(e){let t;if(typeof e.transaction.message.version!="string")if(e.meta.loadedAddresses)t=e.transaction.message.getAccountKeys({accountKeysFromLookups:e.meta.loadedAddresses});else{const n=await Promise.all(e.transaction.message.addressTableLookups.map(async s=>{const a=await this.connection.getAddressLookupTable(s.accountKey);if(!a||!a.value)throw new Error("Could not resolve lookup table: "+s.accountKey.toBase58());return a.value}));t=e.transaction.message.getAccountKeys({addressLookupTableAccounts:n})}else t=e.transaction.message.getAccountKeys();return t}async findInstructions(e,t){var d;const{meta:n,transaction:{message:s}}=t,a=this.coreBridge.programId,o=(d=n.innerInstructions)==null?void 0:d.flatMap(f=>f.instructions.filter(g=>a.toString()===e.get(g.programIdIndex).toString())).map(f=>({programIdIndex:f.programIdIndex,accountKeyIndexes:f.accounts})),u=s.compiledInstructions.filter(f=>a.toString()===e.get(f.programIdIndex).toString());return[...o,...u]}async parsePostMessageAccount(e){const t=await this.connection.getAccountInfo(e);if(!(t!=null&&t.data))throw new Error("No data found in message account");const{timestamp:n,emitterAddress:s,emitterChain:a,consistencyLevel:o,sequence:u,nonce:d,payload:f}=ie(new Uint8Array(t==null?void 0:t.data));return Be.createVAA("Uint8Array",{guardianSet:await this.getGuardianSetIndex(),emitterChain:i.toChain(a),timestamp:n,emitterAddress:s,consistencyLevel:o,sequence:u,nonce:d,payload:f,signatures:[]})}async parseTransaction(e){const t=await this.connection.getTransaction(e,{maxSupportedTransactionVersion:0});if(!t||!t.meta||!t.meta.innerInstructions)throw new Error("transaction not found");try{const o=x.parseSequenceFromLog(this.coreBridge.programId.toBase58(),t);if(o.length>0){const[u,d]=o[0];return[{chain:this.chain,emitter:u,sequence:d}]}}catch{}const n=await this.getMessageAccountKeys(t),s=await this.findInstructions(n,t);if(!s||s.length===0)throw new Error("no bridge messages found");const a=s.map(async o=>{const u=n.get(o.accountKeyIndexes[1]),d=await this.parsePostMessageAccount(u);return{chain:d.emitterChain,emitter:d.emitterAddress,sequence:d.sequence}});return await Promise.all(a)}async parseMessages(e){const t=await this.connection.getTransaction(e,{maxSupportedTransactionVersion:0});if(!t||!t.meta||!t.meta.innerInstructions)throw new Error("transaction not found");const n=await this.getMessageAccountKeys(t),s=await this.findInstructions(n,t);if(!s||s.length===0)throw new Error("no bridge messages found");const a=s.map(async o=>{const u=n.get(o.accountKeyIndexes[1]);return await this.parsePostMessageAccount(u)});return await Promise.all(a)}createUnsignedTx(e,t,n=!1){return new Z.SolanaUnsignedTransaction(e,this.network,this.chain,t,n)}}xe.registerProtocol(i._platform$1,"WormholeCore",x);const He=Object.freeze(Object.defineProperty({__proto__:null,IDL:J,SolanaWormholeCore:x,deserializePostMessage:ie,postMessageLayout:se,utils:je},Symbol.toStringTag,{value:"Module"}));exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID=Y;exports.SolanaWormholeCore=x;exports.accountSize=N;exports.createBridgeFeeTransferInstruction=j;exports.deriveAddress=S;exports.deriveClaimKey=E;exports.deriveEmitterSequenceKey=_;exports.deriveFeeCollectorKey=P;exports.derivePostedVaaKey=b;exports.deriveProgramDataAddress=re;exports.deriveUpgradeAuthorityKey=W;exports.deriveWormholeBridgeDataKey=p;exports.deriveWormholeEmitterKey=V;exports.getAccountData=K;exports.getClaim=ae;exports.getPostMessageAccounts=D;exports.getPostMessageCpiAccounts=Ie;exports.getProgramSequenceTracker=ce;exports.getWormholeDerivedAccounts=Me;exports.index=He;exports.newAccountMeta=Ke;exports.newReadOnlyAccountMeta=Le;
@@ -1 +0,0 @@
1
- "use strict";var v=Object.defineProperty;var y=(b,e,t)=>e in b?v(b,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):b[e]=t;var i=(b,e,t)=>y(b,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./chunk-IMTC3J2M-D-un3eDX.js"),c=require("./address-RcMobNYE.js"),k=require("./aptos-hc5GrCHO.js"),M=require("./unsignedTransaction-C1YeEl4G.js"),x=require("./chain-itK5uGYL.js"),B=[["Mainnet",{depositForBurn:"0xa11ceb0b0700000a0701000802080e031614042a04052e30075e870108e5014000000001000201030004000001050701000100060b0001070304010801020805060108010309080900010002010205060c030e05050208000b010108020108020105010b0101090003060c0b01010900030108000004060c08000e0501030e66756e6769626c655f6173736574066f626a656374167072696d6172795f66756e6769626c655f73746f72650f746f6b656e5f6d657373656e6765720d46756e6769626c654173736574064f626a656374084d6574616461746111616464726573735f746f5f6f626a656374087769746864726177106465706f7369745f666f725f6275726e00000000000000000000000000000000000000000000000000000000000000019bce6734f7b63e835108e3bd8c36743d4709fe435f44791918801d0989640a9d0000010f0b0438000c060a000b060b0138010c050b000b050b020b0311020102",handleReceiveMessage:"0xa11ceb0b0700000a0601000402040403080c051416072a53087d40000001010002000000030203000101040304000103060c0a020a020003060c060a02060a020108000101136d6573736167655f7472616e736d69747465720f746f6b656e5f6d657373656e67657207526563656970740f726563656976655f6d6573736167651668616e646c655f726563656976655f6d657373616765177e17751820e4b4371873ca8c30279be63bdea63b88ed0f2239c2eea10f17729bce6734f7b63e835108e3bd8c36743d4709fe435f44791918801d0989640a9d000001070b000e010e02110011010102"}],["Testnet",{depositForBurn:"0xa11ceb0b0700000a0701000802080e031614042a04052e30075e870108e5014000000001000201030004000001050701000100060b0001070304010801020805060108010309080900010002010205060c030e05050208000b010108020108020105010b0101090003060c0b01010900030108000004060c08000e0501030e66756e6769626c655f6173736574066f626a656374167072696d6172795f66756e6769626c655f73746f72650f746f6b656e5f6d657373656e6765720d46756e6769626c654173736574064f626a656374084d6574616461746111616464726573735f746f5f6f626a656374087769746864726177106465706f7369745f666f725f6275726e00000000000000000000000000000000000000000000000000000000000000015f9b937419dda90aa06c1836b7847f65bbbe3f1217567758dc2488be31a477b90000010f0b0438000c060a000b060b0138010c050b000b050b020b0311020102",handleReceiveMessage:"0xa11ceb0b0700000a0601000402040403080c051416072a53087d40000001010002000000030203000101040304000103060c0a020a020003060c060a02060a020108000101136d6573736167655f7472616e736d69747465720f746f6b656e5f6d657373656e67657207526563656970740f726563656976655f6d6573736167651668616e646c655f726563656976655f6d657373616765081e86cebf457a0c6004f35bd648a2794698f52e0dde09a48619dcd3d4cc23d95f9b937419dda90aa06c1836b7847f65bbbe3f1217567758dc2488be31a477b9000001070b000e010e02110011010102"}]],u=c.constMap(B,[0,1]);class h{constructor(e,t,n,s){i(this,"network");i(this,"chain");i(this,"provider");i(this,"contracts");i(this,"usdcId");i(this,"tokenMessengerId");i(this,"messageTransmitterId");i(this,"moveScripts");var a,f,o;if(this.network=e,this.chain=t,this.provider=n,this.contracts=s,e==="Devnet")throw new Error("CircleBridge not supported on Devnet");const r=c.usdcContract.get(this.network,this.chain);if(!r)throw new Error(`No USDC contract configured for network=${this.network} chain=${this.chain}`);if(!((a=s.cctp)!=null&&a.tokenMessenger))throw new Error(`Circle Token Messenger contract for domain ${t} not found`);if(!((f=s.cctp)!=null&&f.messageTransmitter))throw new Error(`Circle Message Transmitter contract for domain ${t} not found`);if(!u.has(e))throw new Error("No Aptos CCTP move scripts found");this.usdcId=r,this.tokenMessengerId=(o=s.cctp)==null?void 0:o.tokenMessenger,this.messageTransmitterId=s.cctp.messageTransmitter,this.moveScripts=u.get(e)}async*transfer(e,t,n){const s=new d.y$2(c.circleChainId.get(this.network,t.chain)),r=d.l.from(this.usdcId),a=d.l.from(t.address.toUniversalAddress().toUint8Array()),f=[new d.m$1(n),s,a,r],o={bytecode:this.moveScripts.depositForBurn,functionArguments:f};yield this.createUnsignedTx(o,"Aptos.CircleBridge.Transfer")}async isTransferCompleted(e){const t=new d.y$2(e.sourceDomain).bcsToBytes(),n=new d.m$1(e.nonce).bcsToBytes(),s=c.keccak_256(new Uint8Array([...t,45,...n])),r=c.hex.encode(s);return(await this.provider.view({payload:{function:`${this.messageTransmitterId}::message_transmitter::is_nonce_used`,functionArguments:[r]}}))[0]}async*redeem(e,t,n){const s=[d.t$4.U8(c.CircleBridge.serialize(t)),d.t$4.U8(c.hex.decode(n))],r={bytecode:this.moveScripts.handleReceiveMessage,functionArguments:s};yield this.createUnsignedTx(r,"Aptos.CircleBridge.Redeem")}async parseTransactionDetails(e){var g;const t=await this.provider.getTransactionByHash({transactionHash:e}),n=this.messageTransmitterId.replace(/^0x0+/,"0x"),s=(g=t.events)==null?void 0:g.find(C=>C.type===`${n}::message_transmitter::MessageSent`);if(!s)throw new Error("No MessageSent event found");const r=c.hex.decode(s.data.message),[a,f]=c.CircleBridge.deserialize(r),{payload:o}=a,p=o.messageSender,l=o.mintRecipient,m=c.toCircleChain(this.network,a.sourceDomain),w=c.toCircleChain(this.network,a.destinationDomain),T={chain:m,address:o.burnToken};return{from:{chain:m,address:p},to:{chain:w,address:l},token:T,amount:o.amount,message:a,id:{hash:f}}}static async fromRpc(e,t){const[n,s]=await k.AptosPlatform.chainFromRpc(e),r=t[s];if(r.network!==n)throw new Error(`Network mismatch: ${r.network} != ${n}`);return new h(n,s,e,r.contracts)}createUnsignedTx(e,t,n=!1){return new M.AptosUnsignedTransaction(e,this.network,this.chain,t,n)}}x.registerProtocol("Aptos","CircleBridge",h);exports.AptosCircleBridge=h;