@wormhole-foundation/wormhole-connect 2.5.0-beta.0-development → 2.5.0-beta.2-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 (133) hide show
  1. package/dist/assets/{aptos-t5JANz4b.js → aptos-BGyyK8mz.js} +3 -3
  2. package/dist/assets/{aptos-DvAOSqnD.js → aptos-Cepohe0c.js} +1 -1
  3. package/dist/assets/{blake2b-CzqSqyTv.js → blake2b-BwI-z5NJ.js} +1 -1
  4. package/dist/assets/{ccip-4EBcfi6P.js → ccip-BpjdU5zN.js} +1 -1
  5. package/dist/assets/{chunk-IMTC3J2M-Cms0K4gx.js → chunk-IMTC3J2M-CWE1FuDc.js} +1 -1
  6. package/dist/assets/events-6PekJgMN.js +1 -0
  7. package/dist/assets/{evm-8e-eySdo.js → evm-DS7RCBlt.js} +2 -2
  8. package/dist/assets/{evm-CYjbe4kH.js → evm-DvDOQf0K.js} +4 -4
  9. package/dist/assets/{index-M2j4uONF.js → index-5kmPKAJ_.js} +1 -1
  10. package/dist/assets/{index-DALVDBZq.js → index-BP8gdgNH.js} +1 -1
  11. package/dist/assets/{index-BgVVAYar.js → index-BXRb91Mn.js} +1 -1
  12. package/dist/assets/{index-SO_H3W5I.js → index-Bbr14gKC.js} +1 -1
  13. package/dist/assets/index-BjVbgKwL.js +1 -0
  14. package/dist/assets/{index-JtvUouOr.js → index-BwPu1wGj.js} +1 -1
  15. package/dist/assets/{index-CwGBYrGm.js → index-BxXKtU8j.js} +1 -1
  16. package/dist/assets/{index-BKj7Inys.js → index-BzNSt2uL.js} +1 -1
  17. package/dist/assets/{index-CSHmWPOV.js → index-C1f05Vbe.js} +1 -1
  18. package/dist/assets/{index-BcX-2q-J.js → index-C74fy0qh.js} +1 -1
  19. package/dist/assets/{index-Dl17aI3S.js → index-CCOom38X.js} +1 -1
  20. package/dist/assets/{index-C0rvraea.js → index-CHnF49kB.js} +1 -1
  21. package/dist/assets/{index-DmaqQuhH.js → index-CyxmcHOs.js} +1 -1
  22. package/dist/assets/{index-Chd_bwGM.js → index-D1MoRUWm.js} +1 -1
  23. package/dist/assets/{index-CqA1lXp5.js → index-D54DXHBu.js} +1 -1
  24. package/dist/assets/index-D8nnAO88.js +1 -0
  25. package/dist/assets/index-DpMc0uqY.js +1 -0
  26. package/dist/assets/{index-Ced_GF9G.js → index-FNyibGfB.js} +2 -2
  27. package/dist/assets/{index-D9U4BOHM.js → index-X7Qc-hll.js} +1 -1
  28. package/dist/assets/{index-CcMXeWAX.js → index-YqzS8F8M.js} +2 -2
  29. package/dist/assets/{index.es-Bzsluoyw.js → index.es-B2WvD5Rz.js} +6 -6
  30. package/dist/assets/{solana-BHeUantu.js → solana-Dj3oh4lV.js} +2 -2
  31. package/dist/assets/solana-DseaNtL0.js +2 -0
  32. package/dist/assets/solanaEmbed.esm-xl7iC7nm.js +37 -0
  33. package/dist/assets/sui-BdOrw1dc.js +2 -0
  34. package/dist/assets/{sui-CLrvrAHM.js → sui-Ck-FZzH_.js} +1 -1
  35. package/dist/assets/unsignedTransaction-arVvzoJx.js +1 -0
  36. package/dist/main.js +102 -102
  37. package/dist/src/AppRouter.d.ts.map +1 -1
  38. package/dist/src/utils/coingecko.d.ts.map +1 -1
  39. package/lib/{aptos-By3qLiAP.js → aptos-BHFBFxf9.js} +1 -1
  40. package/lib/{aptos-C3Ph4uY9.mjs → aptos-BusONhYq.mjs} +5 -5
  41. package/lib/{aptos-Cs46Nns5.mjs → aptos-DS0eK_De.mjs} +2 -2
  42. package/lib/{aptos-D7X5GMcO.js → aptos-Dqp93_ct.js} +2 -2
  43. package/lib/{base64-B-n8C-1n.js → base64-Cjk6rii_.js} +1 -1
  44. package/lib/{base64-DxqKuhqD.mjs → base64-Vgzj53Io.mjs} +1 -1
  45. package/lib/{ccip-BoG9ZHRV.js → ccip-BLUli_Dz.js} +1 -1
  46. package/lib/{ccip-DgwbitdX.mjs → ccip-FbY2UZlg.mjs} +1 -1
  47. package/lib/{chunk-IMTC3J2M-DfLEkM5Z.js → chunk-IMTC3J2M-6yduhw0s.js} +1 -1
  48. package/lib/{chunk-IMTC3J2M-w136PyXJ.mjs → chunk-IMTC3J2M-AkEA0_z6.mjs} +3 -3
  49. package/lib/{evm-Bta1KBsb.js → evm-BB0d_Gf4.js} +2 -2
  50. package/lib/{evm--NPB9x1d.mjs → evm-DAHEa0cY.mjs} +5 -5
  51. package/lib/{evm-BwXOj4Er.js → evm-DZww7tTt.js} +3 -3
  52. package/lib/{evm-OXQXmbRf.mjs → evm-gEzFFEsO.mjs} +6 -6
  53. package/lib/{index-C2jvFfvC.js → index-6m6Q8Vsa.js} +1 -1
  54. package/lib/{index-0m16n7L7.js → index-8STuBnQE.js} +1 -1
  55. package/lib/{index-hFtbBndd.js → index-B5i1j7Dy.js} +1 -1
  56. package/lib/{index-CoEGiDGu.js → index-BZh72NtL.js} +1 -1
  57. package/lib/{index-C86P0A0Y.mjs → index-BaMrMiTv.mjs} +1 -1
  58. package/lib/{index-BEHglvs0.js → index-BbxXJYWg.js} +1 -1
  59. package/lib/{index-ByicGRKs.mjs → index-Bcl7n3KD.mjs} +2 -2
  60. package/lib/{index-Bi6PAFR8.mjs → index-BeYO1LV3.mjs} +2 -2
  61. package/lib/{index-wsfzS6PN.js → index-Bhgci81L.js} +120 -120
  62. package/lib/{index-CWffCIQl.js → index-BuPKwE_4.js} +1 -1
  63. package/lib/{index-C5tynAhb.mjs → index-C27ZY3oS.mjs} +1 -1
  64. package/lib/{index-bDliG7yg.mjs → index-C6YOw6gB.mjs} +4 -4
  65. package/lib/{index-1WX3nZoM.mjs → index-CA09NOzo.mjs} +3 -3
  66. package/lib/index-CHaex8L3.mjs +75 -0
  67. package/lib/{index-B5z5oFY1.js → index-CSK3DRpf.js} +1 -1
  68. package/lib/{index-Cslbrg97.js → index-CT45reKG.js} +1 -1
  69. package/lib/{index-PnMJX4OC.mjs → index-CkXJo6xD.mjs} +1 -1
  70. package/lib/{index-FGc8swXY.mjs → index-Cs1dlfzD.mjs} +1 -1
  71. package/lib/{index-CKtZvS3X.mjs → index-CxTd6N-A.mjs} +2 -2
  72. package/lib/{index-CGbtcED2.mjs → index-D9hjnIst.mjs} +2 -2
  73. package/lib/{index-CksJcNrV.mjs → index-DDZaEBsC.mjs} +3 -3
  74. package/lib/{index-CDwpyfnd.mjs → index-DR-fv3uE.mjs} +2 -2
  75. package/lib/{index-BGqNMVpQ.js → index-DUC1gOTG.js} +1 -1
  76. package/lib/{index-Bpx_Rf1J.js → index-DUZnVNwZ.js} +1 -1
  77. package/lib/{index-DLiQpgMj.js → index-DXzXHly-.js} +1 -1
  78. package/lib/{index-MytorfyK.mjs → index-D_PIxJ0d.mjs} +2 -2
  79. package/lib/index-D_XBMeuk.js +1 -0
  80. package/lib/{index-DSejRtdA.js → index-DcYZkDfF.js} +1 -1
  81. package/lib/{index-cyTUScMF.js → index-DhR1_nfh.js} +1 -1
  82. package/lib/index-DhowVYVk.mjs +191 -0
  83. package/lib/{index-BLxoZ8qT.js → index-DlNp9VMO.js} +1 -1
  84. package/lib/{index-zMaT9P4V.mjs → index-DpeIjsSi.mjs} +1 -1
  85. package/lib/{index-B3smMSuW.js → index-Ds5QMWJr.js} +1 -1
  86. package/lib/{index-BXc3l4Br.mjs → index-Ds6Q5qfX.mjs} +2 -2
  87. package/lib/{index-DlW1-aGm.js → index-DtjJKYjA.js} +1 -1
  88. package/lib/{index-ILKgpNXM.js → index-FoZ3qnSm.js} +1 -1
  89. package/lib/{index-CoX_24Ky.mjs → index-GSQqQOXb.mjs} +1 -1
  90. package/lib/{index-m0543tB2.mjs → index-LdDD7AAy.mjs} +20959 -32801
  91. package/lib/index-OqOcvaDE.mjs +654 -0
  92. package/lib/{index-50mhIuON.mjs → index-QCqnETT_.mjs} +2 -2
  93. package/lib/index-j8CdhHvQ.js +1 -0
  94. package/lib/{index-Dt0J9sau.js → index-pWRTEePn.js} +1 -1
  95. package/lib/{index-DPM7TGSv.mjs → index-pg4EQbm-.mjs} +11 -2
  96. package/lib/index-s9pQs8eO.js +1 -0
  97. package/lib/{index-CANn2DFq.mjs → index-tI4rmxN8.mjs} +1 -1
  98. package/lib/{index-NTAse-vE.js → index-u05I0QmU.js} +1 -1
  99. package/lib/{index.es-DIL345_I.js → index.es-BeAVotPr.js} +2 -2
  100. package/lib/{index.es-Bh1QXm67.mjs → index.es-Z5ZsZIyC.mjs} +5 -5
  101. package/lib/index.js +1 -1
  102. package/lib/index.mjs +19 -19
  103. package/lib/{signer-CeNONJjb.mjs → signer-B0f07_6U.mjs} +1 -1
  104. package/lib/{signer-Br2-fgMa.js → signer-yr6Zpc2i.js} +1 -1
  105. package/lib/{solana-C5lAA_Eh.mjs → solana-C-LeRjT-.mjs} +4 -4
  106. package/lib/solana-Ci7N1M7R.js +1 -0
  107. package/lib/solana-DCefclYK.mjs +17 -0
  108. package/lib/{solana-Bwwk-8HE.js → solana-DWYDxAWP.js} +1 -1
  109. package/lib/{solanaEmbed.esm-_NPc8tZC.mjs → solanaEmbed.esm-CEtmCHNm.mjs} +1 -1
  110. package/lib/{solanaEmbed.esm-BMTrlSVI.js → solanaEmbed.esm-D5pFIuXZ.js} +1 -1
  111. package/lib/src/AppRouter.d.ts.map +1 -1
  112. package/lib/src/utils/coingecko.d.ts.map +1 -1
  113. package/lib/sui-756LVCZm.js +1 -0
  114. package/lib/{sui-zLYQBpSC.js → sui-BIUo4whG.js} +1 -1
  115. package/lib/sui-BuI3_sI0.mjs +585 -0
  116. package/lib/{sui-X62i5q3_.mjs → sui-naAV3r83.mjs} +1 -1
  117. package/package.json +17 -17
  118. package/dist/assets/index-BRtMY3at.js +0 -1
  119. package/dist/assets/index-BUlVFUMr.js +0 -1
  120. package/dist/assets/index-RBS_ALc7.js +0 -1
  121. package/dist/assets/solana-BEFCVrXa.js +0 -2
  122. package/dist/assets/solanaEmbed.esm-B7A7qKmk.js +0 -37
  123. package/dist/assets/sui-C1wbtvIC.js +0 -2
  124. package/lib/index-CNkTJOH_.js +0 -1
  125. package/lib/index-DN6dWOSB.js +0 -1
  126. package/lib/index-DUOnxuE_.mjs +0 -252
  127. package/lib/index-DqFY4i5u.js +0 -1
  128. package/lib/index-Eomc9IwB.mjs +0 -936
  129. package/lib/index-fkzogQYE.mjs +0 -376
  130. package/lib/solana-4Qcfxe9o.js +0 -1
  131. package/lib/solana-DM9nG3cQ.mjs +0 -17
  132. package/lib/sui-BvJu9wTN.mjs +0 -701
  133. package/lib/sui-pGBefbTJ.js +0 -1
@@ -0,0 +1,585 @@
1
+ var j = Object.defineProperty;
2
+ var Y = (r, e, t) => e in r ? j(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var w = (r, e, t) => Y(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ab as S, ac as m, ad as x, ae as X, af as J, ag as Q, ah as W, ai as R, aj as ee, ak as H, al as M, am as te, an as d, ao as k, ap as re, aq as ne, U as se, ar as ie } from "./index-LdDD7AAy.mjs";
5
+ import { m as oe } from "./index-tI4rmxN8.mjs";
6
+ var E = {};
7
+ Object.defineProperty(E, "__esModule", { value: !0 });
8
+ E.bech32m = b = E.bech32 = void 0;
9
+ const K = "qpzry9x8gf2tvdw0s3jn54khce6mua7l", z = {};
10
+ for (let r = 0; r < K.length; r++) {
11
+ const e = K.charAt(r);
12
+ z[e] = r;
13
+ }
14
+ function y(r) {
15
+ const e = r >> 25;
16
+ return (r & 33554431) << 5 ^ -(e >> 0 & 1) & 996825010 ^ -(e >> 1 & 1) & 642813549 ^ -(e >> 2 & 1) & 513874426 ^ -(e >> 3 & 1) & 1027748829 ^ -(e >> 4 & 1) & 705979059;
17
+ }
18
+ function U(r) {
19
+ let e = 1;
20
+ for (let t = 0; t < r.length; ++t) {
21
+ const n = r.charCodeAt(t);
22
+ if (n < 33 || n > 126)
23
+ return "Invalid prefix (" + r + ")";
24
+ e = y(e) ^ n >> 5;
25
+ }
26
+ e = y(e);
27
+ for (let t = 0; t < r.length; ++t) {
28
+ const n = r.charCodeAt(t);
29
+ e = y(e) ^ n & 31;
30
+ }
31
+ return e;
32
+ }
33
+ function I(r, e, t, n) {
34
+ let i = 0, o = 0;
35
+ const s = (1 << t) - 1, c = [];
36
+ for (let a = 0; a < r.length; ++a)
37
+ for (i = i << e | r[a], o += e; o >= t; )
38
+ o -= t, c.push(i >> o & s);
39
+ if (n)
40
+ o > 0 && c.push(i << t - o & s);
41
+ else {
42
+ if (o >= e)
43
+ return "Excess padding";
44
+ if (i << t - o & s)
45
+ return "Non-zero padding";
46
+ }
47
+ return c;
48
+ }
49
+ function ce(r) {
50
+ return I(r, 8, 5, !0);
51
+ }
52
+ function ae(r) {
53
+ const e = I(r, 5, 8, !1);
54
+ if (Array.isArray(e))
55
+ return e;
56
+ }
57
+ function ue(r) {
58
+ const e = I(r, 5, 8, !1);
59
+ if (Array.isArray(e))
60
+ return e;
61
+ throw new Error(e);
62
+ }
63
+ function F(r) {
64
+ let e;
65
+ r === "bech32" ? e = 1 : e = 734539939;
66
+ function t(s, c, a) {
67
+ if (a = a || 90, s.length + 7 + c.length > a)
68
+ throw new TypeError("Exceeds length limit");
69
+ s = s.toLowerCase();
70
+ let l = U(s);
71
+ if (typeof l == "string")
72
+ throw new Error(l);
73
+ let f = s + "1";
74
+ for (let u = 0; u < c.length; ++u) {
75
+ const h = c[u];
76
+ if (h >> 5)
77
+ throw new Error("Non 5-bit word");
78
+ l = y(l) ^ h, f += K.charAt(h);
79
+ }
80
+ for (let u = 0; u < 6; ++u)
81
+ l = y(l);
82
+ l ^= e;
83
+ for (let u = 0; u < 6; ++u) {
84
+ const h = l >> (5 - u) * 5 & 31;
85
+ f += K.charAt(h);
86
+ }
87
+ return f;
88
+ }
89
+ function n(s, c) {
90
+ if (c = c || 90, s.length < 8)
91
+ return s + " too short";
92
+ if (s.length > c)
93
+ return "Exceeds length limit";
94
+ const a = s.toLowerCase(), l = s.toUpperCase();
95
+ if (s !== a && s !== l)
96
+ return "Mixed-case string " + s;
97
+ s = a;
98
+ const f = s.lastIndexOf("1");
99
+ if (f === -1)
100
+ return "No separator character for " + s;
101
+ if (f === 0)
102
+ return "Missing prefix for " + s;
103
+ const u = s.slice(0, f), h = s.slice(f + 1);
104
+ if (h.length < 6)
105
+ return "Data too short";
106
+ let p = U(u);
107
+ if (typeof p == "string")
108
+ return p;
109
+ const C = [];
110
+ for (let v = 0; v < h.length; ++v) {
111
+ const D = h.charAt(v), _ = z[D];
112
+ if (_ === void 0)
113
+ return "Unknown character " + D;
114
+ p = y(p) ^ _, !(v + 6 >= h.length) && C.push(_);
115
+ }
116
+ return p !== e ? "Invalid checksum for " + s : { prefix: u, words: C };
117
+ }
118
+ function i(s, c) {
119
+ const a = n(s, c);
120
+ if (typeof a == "object")
121
+ return a;
122
+ }
123
+ function o(s, c) {
124
+ const a = n(s, c);
125
+ if (typeof a == "object")
126
+ return a;
127
+ throw new Error(a);
128
+ }
129
+ return {
130
+ decodeUnsafe: i,
131
+ decode: o,
132
+ encode: t,
133
+ toWords: ce,
134
+ fromWordsUnsafe: ae,
135
+ fromWords: ue
136
+ };
137
+ }
138
+ var b = E.bech32 = F("bech32");
139
+ E.bech32m = F("bech32m");
140
+ function O(r, e) {
141
+ return S.IntentMessage(S.fixedArray(e.length, S.u8())).serialize({
142
+ intent: {
143
+ scope: { [r]: !0 },
144
+ version: { V0: !0 },
145
+ appId: { Sui: !0 }
146
+ },
147
+ value: e
148
+ }).toBytes();
149
+ }
150
+ const B = {
151
+ ED25519: 0,
152
+ Secp256k1: 1,
153
+ Secp256r1: 2,
154
+ MultiSig: 3,
155
+ ZkLogin: 5,
156
+ Passkey: 6
157
+ }, le = {
158
+ ED25519: 32,
159
+ Secp256k1: 33,
160
+ Secp256r1: 33
161
+ }, V = {
162
+ 0: "ED25519",
163
+ 1: "Secp256k1",
164
+ 2: "Secp256r1",
165
+ 3: "MultiSig",
166
+ 5: "ZkLogin",
167
+ 6: "Passkey"
168
+ };
169
+ function $(r, e) {
170
+ if (r === e) return !0;
171
+ if (r.length !== e.length)
172
+ return !1;
173
+ for (let t = 0; t < r.length; t++)
174
+ if (r[t] !== e[t])
175
+ return !1;
176
+ return !0;
177
+ }
178
+ class he {
179
+ /**
180
+ * Checks if two public keys are equal
181
+ */
182
+ equals(e) {
183
+ return $(this.toRawBytes(), e.toRawBytes());
184
+ }
185
+ /**
186
+ * Return the base-64 representation of the public key
187
+ */
188
+ toBase64() {
189
+ return m(this.toRawBytes());
190
+ }
191
+ toString() {
192
+ throw new Error(
193
+ "`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead."
194
+ );
195
+ }
196
+ /**
197
+ * Return the Sui representation of the public key encoded in
198
+ * base-64. A Sui public key is formed by the concatenation
199
+ * of the scheme flag with the raw bytes of the public key
200
+ */
201
+ toSuiPublicKey() {
202
+ const e = this.toSuiBytes();
203
+ return m(e);
204
+ }
205
+ verifyWithIntent(e, t, n) {
206
+ const i = O(n, e), o = x(i, { dkLen: 32 });
207
+ return this.verify(o, t);
208
+ }
209
+ /**
210
+ * Verifies that the signature is valid for for the provided PersonalMessage
211
+ */
212
+ verifyPersonalMessage(e, t) {
213
+ return this.verifyWithIntent(
214
+ S.vector(S.u8()).serialize(e).toBytes(),
215
+ t,
216
+ "PersonalMessage"
217
+ );
218
+ }
219
+ /**
220
+ * Verifies that the signature is valid for for the provided Transaction
221
+ */
222
+ verifyTransaction(e, t) {
223
+ return this.verifyWithIntent(e, t, "TransactionData");
224
+ }
225
+ /**
226
+ * Verifies that the public key is associated with the provided address
227
+ */
228
+ verifyAddress(e) {
229
+ return this.toSuiAddress() === e;
230
+ }
231
+ /**
232
+ * Returns the bytes representation of the public key
233
+ * prefixed with the signature scheme flag
234
+ */
235
+ toSuiBytes() {
236
+ const e = this.toRawBytes(), t = new Uint8Array(e.length + 1);
237
+ return t.set([this.flag()]), t.set(e, 1), t;
238
+ }
239
+ /**
240
+ * Return the Sui address associated with this Ed25519 public key
241
+ */
242
+ toSuiAddress() {
243
+ return X(
244
+ J(x(this.toSuiBytes(), { dkLen: 32 })).slice(0, Q * 2)
245
+ );
246
+ }
247
+ }
248
+ function de(r) {
249
+ const e = W(r), t = V[e[0]];
250
+ switch (t) {
251
+ case "ED25519":
252
+ case "Secp256k1":
253
+ case "Secp256r1":
254
+ const n = le[t], i = e.slice(1, e.length - n), o = e.slice(1 + i.length);
255
+ return {
256
+ serializedSignature: r,
257
+ signatureScheme: t,
258
+ signature: i,
259
+ publicKey: o,
260
+ bytes: e
261
+ };
262
+ default:
263
+ throw new Error("Unsupported signature scheme");
264
+ }
265
+ }
266
+ function fe({
267
+ signature: r,
268
+ signatureScheme: e,
269
+ publicKey: t
270
+ }) {
271
+ if (!t)
272
+ throw new Error("`publicKey` is required");
273
+ const n = t.toRawBytes(), i = new Uint8Array(1 + r.length + n.length);
274
+ return i.set([B[e]]), i.set(r, 1), i.set(n, 1 + r.length), m(i);
275
+ }
276
+ const A = 32, q = "suiprivkey";
277
+ class ge {
278
+ /**
279
+ * Sign messages with a specific intent. By combining the message bytes with the intent before hashing and signing,
280
+ * it ensures that a signed message is tied to a specific purpose and domain separator is provided
281
+ */
282
+ async signWithIntent(e, t) {
283
+ const n = O(t, e), i = x(n, { dkLen: 32 });
284
+ return {
285
+ signature: fe({
286
+ signature: await this.sign(i),
287
+ signatureScheme: this.getKeyScheme(),
288
+ publicKey: this.getPublicKey()
289
+ }),
290
+ bytes: m(e)
291
+ };
292
+ }
293
+ /**
294
+ * Signs provided transaction by calling `signWithIntent()` with a `TransactionData` provided as intent scope
295
+ */
296
+ async signTransaction(e) {
297
+ return this.signWithIntent(e, "TransactionData");
298
+ }
299
+ /**
300
+ * Signs provided personal message by calling `signWithIntent()` with a `PersonalMessage` provided as intent scope
301
+ */
302
+ async signPersonalMessage(e) {
303
+ const { signature: t } = await this.signWithIntent(
304
+ R.vector(R.u8()).serialize(e).toBytes(),
305
+ "PersonalMessage"
306
+ );
307
+ return {
308
+ bytes: m(e),
309
+ signature: t
310
+ };
311
+ }
312
+ toSuiAddress() {
313
+ return this.getPublicKey().toSuiAddress();
314
+ }
315
+ }
316
+ class ye extends ge {
317
+ }
318
+ function pe(r) {
319
+ const { prefix: e, words: t } = b.decode(r);
320
+ if (e !== q)
321
+ throw new Error("invalid private key prefix");
322
+ const n = new Uint8Array(b.fromWords(t)), i = n.slice(1);
323
+ return {
324
+ schema: V[n[0]],
325
+ secretKey: i
326
+ };
327
+ }
328
+ function we(r, e) {
329
+ if (r.length !== A)
330
+ throw new Error("Invalid bytes length");
331
+ const t = B[e], n = new Uint8Array(r.length + 1);
332
+ return n.set([t]), n.set(r, 1), b.encode(q, b.toWords(n));
333
+ }
334
+ function T(r) {
335
+ return !!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(r);
336
+ }
337
+ function Se(r) {
338
+ return oe(r, "");
339
+ }
340
+ function me(r) {
341
+ return ee(Se(r));
342
+ }
343
+ const Ee = "ed25519 seed", be = 2147483648, ve = new RegExp("^m(\\/[0-9]+')+$"), G = (r) => r.replace("'", ""), Ae = (r) => {
344
+ const t = H.create(M, Ee).update(te(r)).digest(), n = t.slice(0, 32), i = t.slice(32);
345
+ return {
346
+ key: n,
347
+ chainCode: i
348
+ };
349
+ }, Ke = ({ key: r, chainCode: e }, t) => {
350
+ const n = new ArrayBuffer(4);
351
+ new DataView(n).setUint32(0, t);
352
+ const o = new Uint8Array(1 + r.length + n.byteLength);
353
+ o.set(new Uint8Array(1).fill(0)), o.set(r, 1), o.set(new Uint8Array(n, 0, n.byteLength), r.length + 1);
354
+ const s = H.create(M, e).update(o).digest(), c = s.slice(0, 32), a = s.slice(32);
355
+ return {
356
+ key: c,
357
+ chainCode: a
358
+ };
359
+ }, _e = (r) => ve.test(r) ? !r.split("/").slice(1).map(G).some(
360
+ isNaN
361
+ /* ts T_T*/
362
+ ) : !1, L = (r, e, t = be) => {
363
+ if (!_e(r))
364
+ throw new Error("Invalid derivation path");
365
+ const { key: n, chainCode: i } = Ae(e);
366
+ return r.split("/").slice(1).map(G).map((s) => parseInt(s, 10)).reduce((s, c) => Ke(s, c + t), {
367
+ key: n,
368
+ chainCode: i
369
+ });
370
+ }, P = 32;
371
+ class Z extends he {
372
+ /**
373
+ * Create a new Ed25519PublicKey object
374
+ * @param value ed25519 public key as buffer or base-64 encoded string
375
+ */
376
+ constructor(e) {
377
+ if (super(), typeof e == "string" ? this.data = W(e) : e instanceof Uint8Array ? this.data = e : this.data = Uint8Array.from(e), this.data.length !== P)
378
+ throw new Error(
379
+ `Invalid public key input. Expected ${P} bytes, got ${this.data.length}`
380
+ );
381
+ }
382
+ /**
383
+ * Checks if two Ed25519 public keys are equal
384
+ */
385
+ equals(e) {
386
+ return super.equals(e);
387
+ }
388
+ /**
389
+ * Return the byte array representation of the Ed25519 public key
390
+ */
391
+ toRawBytes() {
392
+ return this.data;
393
+ }
394
+ /**
395
+ * Return the Sui address associated with this Ed25519 public key
396
+ */
397
+ flag() {
398
+ return B.ED25519;
399
+ }
400
+ /**
401
+ * Verifies that the signature is valid for for the provided message
402
+ */
403
+ async verify(e, t) {
404
+ let n;
405
+ if (typeof t == "string") {
406
+ const i = de(t);
407
+ if (i.signatureScheme !== "ED25519")
408
+ throw new Error("Invalid signature scheme");
409
+ if (!$(this.toRawBytes(), i.publicKey))
410
+ throw new Error("Signature does not match public key");
411
+ n = i.signature;
412
+ } else
413
+ n = t;
414
+ return d.verify(n, e, this.toRawBytes());
415
+ }
416
+ }
417
+ Z.SIZE = P;
418
+ const N = "m/44'/784'/0'/0'/0'";
419
+ class g extends ye {
420
+ /**
421
+ * Create a new Ed25519 keypair instance.
422
+ * Generate random keypair if no {@link Ed25519Keypair} is provided.
423
+ *
424
+ * @param keypair Ed25519 keypair
425
+ */
426
+ constructor(e) {
427
+ if (super(), e)
428
+ this.keypair = {
429
+ publicKey: e.publicKey,
430
+ secretKey: e.secretKey.slice(0, 32)
431
+ };
432
+ else {
433
+ const t = d.utils.randomPrivateKey();
434
+ this.keypair = {
435
+ publicKey: d.getPublicKey(t),
436
+ secretKey: t
437
+ };
438
+ }
439
+ }
440
+ /**
441
+ * Get the key scheme of the keypair ED25519
442
+ */
443
+ getKeyScheme() {
444
+ return "ED25519";
445
+ }
446
+ /**
447
+ * Generate a new random Ed25519 keypair
448
+ */
449
+ static generate() {
450
+ const e = d.utils.randomPrivateKey();
451
+ return new g({
452
+ publicKey: d.getPublicKey(e),
453
+ secretKey: e
454
+ });
455
+ }
456
+ /**
457
+ * Create a Ed25519 keypair from a raw secret key byte array, also known as seed.
458
+ * This is NOT the private scalar which is result of hashing and bit clamping of
459
+ * the raw secret key.
460
+ *
461
+ * @throws error if the provided secret key is invalid and validation is not skipped.
462
+ *
463
+ * @param secretKey secret key as a byte array or Bech32 secret key string
464
+ * @param options: skip secret key validation
465
+ */
466
+ static fromSecretKey(e, t) {
467
+ if (typeof e == "string") {
468
+ const o = pe(e);
469
+ if (o.schema !== "ED25519")
470
+ throw new Error(`Expected a ED25519 keypair, got ${o.schema}`);
471
+ return this.fromSecretKey(o.secretKey, t);
472
+ }
473
+ const n = e.length;
474
+ if (n !== A)
475
+ throw new Error(
476
+ `Wrong secretKey size. Expected ${A} bytes, got ${n}.`
477
+ );
478
+ const i = {
479
+ publicKey: d.getPublicKey(e),
480
+ secretKey: e
481
+ };
482
+ if (!t || !t.skipValidation) {
483
+ const s = new TextEncoder().encode("sui validation"), c = d.sign(s, e);
484
+ if (!d.verify(c, s, i.publicKey))
485
+ throw new Error("provided secretKey is invalid");
486
+ }
487
+ return new g(i);
488
+ }
489
+ /**
490
+ * The public key for this Ed25519 keypair
491
+ */
492
+ getPublicKey() {
493
+ return new Z(this.keypair.publicKey);
494
+ }
495
+ /**
496
+ * The Bech32 secret key string for this Ed25519 keypair
497
+ */
498
+ getSecretKey() {
499
+ return we(
500
+ this.keypair.secretKey.slice(0, A),
501
+ this.getKeyScheme()
502
+ );
503
+ }
504
+ /**
505
+ * Return the signature for the provided data using Ed25519.
506
+ */
507
+ async sign(e) {
508
+ return d.sign(e, this.keypair.secretKey);
509
+ }
510
+ /**
511
+ * Derive Ed25519 keypair from mnemonics and path. The mnemonics must be normalized
512
+ * and validated against the english wordlist.
513
+ *
514
+ * If path is none, it will default to m/44'/784'/0'/0'/0', otherwise the path must
515
+ * be compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
516
+ */
517
+ static deriveKeypair(e, t) {
518
+ if (t == null && (t = N), !T(t))
519
+ throw new Error("Invalid derivation path");
520
+ const { key: n } = L(t, me(e));
521
+ return g.fromSecretKey(n);
522
+ }
523
+ /**
524
+ * Derive Ed25519 keypair from mnemonicSeed and path.
525
+ *
526
+ * If path is none, it will default to m/44'/784'/0'/0'/0', otherwise the path must
527
+ * be compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
528
+ */
529
+ static deriveKeypairFromSeed(e, t) {
530
+ if (t == null && (t = N), !T(t))
531
+ throw new Error("Invalid derivation path");
532
+ const { key: n } = L(t, e);
533
+ return g.fromSecretKey(n);
534
+ }
535
+ }
536
+ async function xe(r, e) {
537
+ const [, t] = await k.chainFromRpc(r);
538
+ return new ke(t, r, g.deriveKeypair(e, "m/44'/784'/0'/0'/0'"));
539
+ }
540
+ class ke {
541
+ constructor(e, t, n, i) {
542
+ w(this, "_chain");
543
+ w(this, "_client");
544
+ w(this, "_signer");
545
+ w(this, "_debug");
546
+ this._chain = e, this._client = t, this._signer = n, this._debug = i;
547
+ }
548
+ chain() {
549
+ return this._chain;
550
+ }
551
+ address() {
552
+ return this._signer.toSuiAddress();
553
+ }
554
+ async signAndSend(e) {
555
+ const t = [];
556
+ for (const n of e) {
557
+ const { description: i, transaction: o } = n;
558
+ this._debug && console.log(`Signing ${i} for ${this.address()}`);
559
+ try {
560
+ const s = await this._client.signAndExecuteTransaction({
561
+ transaction: o,
562
+ signer: this._signer
563
+ });
564
+ t.push(s.digest);
565
+ } catch (s) {
566
+ throw s;
567
+ }
568
+ }
569
+ return t;
570
+ }
571
+ }
572
+ const Ce = {
573
+ Address: ne,
574
+ Platform: k,
575
+ getSigner: xe,
576
+ protocols: {
577
+ WormholeCore: () => import("./index-CHaex8L3.mjs"),
578
+ TokenBridge: () => import("./index-OqOcvaDE.mjs"),
579
+ CircleBridge: () => import("./index-DhowVYVk.mjs")
580
+ },
581
+ getChain: (r, e, t) => new re(e, new k(r, se(r, ie, { [e]: t })))
582
+ };
583
+ export {
584
+ Ce as default
585
+ };
@@ -3,7 +3,7 @@ var On = (e, t, r) => t in e ? zn(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var k = (e, t, r) => On(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { g as br } from "./wallets-B2tqS5lZ.mjs";
5
5
  import { R as Bn } from "./util--bw7gFPs.mjs";
6
- import { au as Pn, at as Rn, b2 as tr, b3 as Un, ad as Gn, aw as Qn, az as rr, b4 as nr, ax as Yn, aF as _e } from "./index-m0543tB2.mjs";
6
+ import { au as Pn, at as Rn, b2 as tr, b3 as Un, ad as Gn, aw as Qn, az as rr, b4 as nr, ax as Yn, aF as _e } from "./index-LdDD7AAy.mjs";
7
7
  function Wn(e) {
8
8
  return Uint8Array.from(atob(e), (t) => t.charCodeAt(0));
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wormhole-foundation/wormhole-connect",
3
- "version": "2.5.0-beta.0-development",
3
+ "version": "2.5.0-beta.2-development",
4
4
  "repository": "github:wormhole-foundation/wormhole-connect",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.mjs",
@@ -39,8 +39,8 @@
39
39
  "@solana/spl-token": "0.4.0",
40
40
  "@solana/wallet-adapter-wallets": "0.19.32",
41
41
  "@solana/web3.js": "1.98.0",
42
- "@wormhole-foundation/sdk": "1.15.0-beta.2",
43
- "@wormhole-foundation/sdk-definitions": "1.15.0-beta.2",
42
+ "@wormhole-foundation/sdk": "1.15.3",
43
+ "@wormhole-foundation/sdk-definitions": "1.15.3",
44
44
  "@wormhole-foundation/sdk-definitions-ntt": "^0.7.1",
45
45
  "@wormhole-foundation/sdk-evm-ntt": "^0.7.1",
46
46
  "@wormhole-foundation/sdk-icons": "^1.0.0",
@@ -169,28 +169,28 @@
169
169
  "axios": "1.4.0"
170
170
  },
171
171
  "@mayanfinance/wormhole-sdk-route": {
172
- "@wormhole-foundation/sdk-connect": "1.15.0-beta.2",
173
- "@wormhole-foundation/sdk-evm": "1.15.0-beta.2",
174
- "@wormhole-foundation/sdk-solana": "1.15.0-beta.2"
172
+ "@wormhole-foundation/sdk-connect": "1.15.3",
173
+ "@wormhole-foundation/sdk-evm": "1.15.3",
174
+ "@wormhole-foundation/sdk-solana": "1.15.3"
175
175
  },
176
176
  "@wormhole-foundation/sdk-definitions-ntt": {
177
- "@wormhole-foundation/sdk-base": "1.15.0-beta.2",
178
- "@wormhole-foundation/sdk-definitions": "1.15.0-beta.2"
177
+ "@wormhole-foundation/sdk-base": "1.15.3",
178
+ "@wormhole-foundation/sdk-definitions": "1.15.3"
179
179
  },
180
180
  "@wormhole-foundation/sdk-evm-ntt": {
181
- "@wormhole-foundation/sdk-base": "1.15.0-beta.2",
182
- "@wormhole-foundation/sdk-definitions": "1.15.0-beta.2",
183
- "@wormhole-foundation/sdk-evm": "1.15.0-beta.2",
184
- "@wormhole-foundation/sdk-evm-core": "1.15.0-beta.2"
181
+ "@wormhole-foundation/sdk-base": "1.15.3",
182
+ "@wormhole-foundation/sdk-definitions": "1.15.3",
183
+ "@wormhole-foundation/sdk-evm": "1.15.3",
184
+ "@wormhole-foundation/sdk-evm-core": "1.15.3"
185
185
  },
186
186
  "@wormhole-foundation/sdk-route-ntt": {
187
- "@wormhole-foundation/sdk-connect": "1.15.0-beta.2"
187
+ "@wormhole-foundation/sdk-connect": "1.15.3"
188
188
  },
189
189
  "@wormhole-foundation/sdk-solana-ntt": {
190
- "@wormhole-foundation/sdk-base": "1.15.0-beta.2",
191
- "@wormhole-foundation/sdk-definitions": "1.15.0-beta.2",
192
- "@wormhole-foundation/sdk-solana": "1.15.0-beta.2",
193
- "@wormhole-foundation/sdk-solana-core": "1.15.0-beta.2"
190
+ "@wormhole-foundation/sdk-base": "1.15.3",
191
+ "@wormhole-foundation/sdk-definitions": "1.15.3",
192
+ "@wormhole-foundation/sdk-solana": "1.15.3",
193
+ "@wormhole-foundation/sdk-solana-core": "1.15.3"
194
194
  },
195
195
  "@wormhole-foundation/wormhole-connect": {
196
196
  "aptos": "1.5.2"
@@ -1 +0,0 @@
1
- var S=Object.defineProperty;var k=(a,t,e)=>t in a?S(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var o=(a,t,e)=>k(a,typeof t!="symbol"?t+"":t,e);import{S as I}from"./sui-C1wbtvIC.js";import{cz as f,aM as d,dh as B,dr as x,aN as A,bp as E,aO as b,aQ as T,aR as N,aT as U,aU as w,aV as M,aX as $,cb as F,di as P,cn as O}from"../main.js";import"./blake2b-CzqSqyTv.js";import"./index-DmaqQuhH.js";const g="::",C="0x2::sui::SUI",R=a=>/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(a);function y(a){return a=a.startsWith("0x")?a.slice(2):a,a=a.length%2===0?a:"0"+a,`0x${a.length===64?a:d.encode(B.zpad(d.decode(a),32))}`}const u=class u{constructor(t){o(this,"address");o(this,"module");if(u.instanceof(t))this.address=t.address,this.module=t.module;else if(f.instanceof(t))this.address=t.toUint8Array();else if(typeof t=="string"){if(R(t)){const e=t.split(g);this.module=e.slice(1).join(g),t=e[0]}if(t=y(t),!d.valid(t))throw new Error("Invalid Sui address: "+t);this.address=d.decode(t)}else this.address=t}unwrap(){const t=this.getPackageId(),e=this.module?g+this.module:"";return`${t}${e}`}toString(){return this.unwrap()}toNative(){return this}toUint8Array(){return this.address}toUniversalAddress(){return new f(this.toUint8Array())}getPackageId(){return y(d.encode(this.address))}getCoinType(){if(this.module==="sui::SUI")return C;if(!this.module)throw new Error("No module present in Sui token address");return this.unwrap()}static instanceof(t){return t.constructor.platform===u.platform}equals(t){return u.instanceof(t)?t.unwrap()===this.unwrap():this.toUniversalAddress().equals(t)}};o(u,"byteSize",32),o(u,"platform","Sui");let h=u;x("Sui",h);class q extends A{}const v="Sui",z=a=>{var e;const t=(e=a.data)==null?void 0:e.content;return t&&t.dataType==="moveObject"?t.fields:null},W=async(a,t)=>{if(!E(t))throw new Error(`Invalid object ID: ${t}`);const e=await a.getObject({id:t,options:{showContent:!0}});return z(e)},c=class c extends b{constructor(t,e){super(t,e??T(t,c._platform))}getRpc(t){if(t in this.config)return new I({url:this.config[t].rpc});throw new Error("No configuration available for chain: "+t)}getChain(t){if(t in this.config)return new q(t,this);throw new Error("No configuration available for chain: "+t)}static nativeTokenId(t,e){if(!c.isSupportedChain(e))throw new Error(`invalid chain for ${v}: ${e}`);return N.tokenId(e,C)}static isNativeTokenId(t,e,n){return!c.isSupportedChain(e)||n.chain!==e?!1:this.nativeTokenId(t,e)===n}static isSupportedChain(t){return U(t)===c._platform}static async getDecimals(t,e,n){if(w(n))return M(c._platform);const r=new h(n);try{const i=await W(e,r.toString());if(i&&"decimals"in i)return i.decimals}catch{}const s=await e.getCoinMetadata({coinType:r.toString()});if(s===null)throw new Error(`Can't fetch decimals for token ${r.toString()}`);return s.decimals}static async getCoins(t,e,n){let r=[],s=null;const i=new h(e).toString();do{const l=await t.getCoins({owner:i,coinType:n,cursor:s});r=[...r,...l.data],s=l.hasNextPage?l.nextCursor:null}while(s);return r}static async getBalance(t,e,n,r){if(w(r)){const{totalBalance:i}=await e.getBalance({owner:n});return BigInt(i)}const{totalBalance:s}=await e.getBalance({owner:n,coinType:r.toString()});return BigInt(s)}static async getBalances(t,e,n,r){return(await Promise.all(r.map(async i=>{const l=await this.getBalance(t,e,n,i);return{[w(i)?"native":new h(i).toString()]:l}}))).reduce((i,l)=>Object.assign(i,l),{})}static async sendWait(t,e,n){const r=[];for(const s of n){const i=await e.executeTransactionBlock(s);await e.waitForTransaction({digest:i.digest}),r.push(i.digest)}return r}static async getLatestBlock(t){return Number(await t.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(t){return this.getLatestBlock(t)}static chainFromChainId(t){const e=$(c._platform,t);if(e===void 0)throw new Error(`Unknown native chain id ${t}`);const[n,r]=e;return[n,r]}static async chainFromRpc(t){const e=await t.call("sui_getChainIdentifier",[]);return this.chainFromChainId(e)}};o(c,"_platform",v);let m=c;class p{constructor(t,e,n,r){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"chainId");o(this,"coreBridgePackageId");this.network=t,this.chain=e,this.provider=n,this.contracts=r,this.chainId=F(e);const s=r.coreBridge;if(!s)throw new Error(`CoreBridge contract Address for chain ${e} not found`);this.coreBridgePackageId=s}getGuardianSet(t){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(t,e){const[n,r]=await m.chainFromRpc(t),s=e[r];if(s.network!==n)throw new Error(`Network mismatch: ${s.network} !== ${n}`);return new p(n,r,t,s.contracts)}async*verifyMessage(t,e){throw new Error("Method not implemented.")}async*publishMessage(t,e){throw new Error("Method not implemented.")}async parseTransaction(t){return(await this.parseMessages(t)).map(n=>({emitter:n.emitterAddress,sequence:n.sequence,chain:this.chain}))}async getGuardianSetIndex(){throw new Error("Method not implemented.")}async parseMessages(t){var r;const n=(r=(await this.provider.getTransactionBlock({digest:t,options:{showEvents:!0,showEffects:!0,showInput:!0}})).events)==null?void 0:r.filter(s=>s.type.endsWith("WormholeMessage"));if(!n||n.length==0)throw new Error("WormholeMessage not found");return n.map(s=>{const i=s.parsedJson;return P("Uint8Array",{emitterChain:this.chain,emitterAddress:new h(i.sender).toUniversalAddress(),sequence:BigInt(i.sequence),guardianSet:0,timestamp:Number(i.timestamp),consistencyLevel:i.consistency_level,nonce:i.nonce,signatures:[],payload:new Uint8Array(i.payload)})})}}O("Sui","WormholeCore",p);export{p as SuiWormholeCore};
@@ -1 +0,0 @@
1
- var j=Object.defineProperty;var B=(i,e,t)=>e in i?j(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>B(i,typeof e!="symbol"?e+"":e,t);import{S as U,T}from"./sui-C1wbtvIC.js";import{cz as S,aM as g,dh as N,dr as A,aN as F,bp as R,aO as D,aQ as O,aR as z,aT as P,aU as C,aV as q,aX as L,dq as V,cu as W,cs as J,ct as y,cv as x,cn as Q}from"../main.js";import"./blake2b-CzqSqyTv.js";import"./index-DmaqQuhH.js";const I="::",E="0x2::sui::SUI",X=i=>/^(0x)?[0-9a-fA-F]+::\w+::\w+$/.test(i);function M(i){return i=i.startsWith("0x")?i.slice(2):i,i=i.length%2===0?i:"0"+i,`0x${i.length===64?i:g.encode(N.zpad(g.decode(i),32))}`}const h=class h{constructor(e){o(this,"address");o(this,"module");if(h.instanceof(e))this.address=e.address,this.module=e.module;else if(S.instanceof(e))this.address=e.toUint8Array();else if(typeof e=="string"){if(X(e)){const t=e.split(I);this.module=t.slice(1).join(I),e=t[0]}if(e=M(e),!g.valid(e))throw new Error("Invalid Sui address: "+e);this.address=g.decode(e)}else this.address=e}unwrap(){const e=this.getPackageId(),t=this.module?I+this.module:"";return`${e}${t}`}toString(){return this.unwrap()}toNative(){return this}toUint8Array(){return this.address}toUniversalAddress(){return new S(this.toUint8Array())}getPackageId(){return M(g.encode(this.address))}getCoinType(){if(this.module==="sui::SUI")return E;if(!this.module)throw new Error("No module present in Sui token address");return this.unwrap()}static instanceof(e){return e.constructor.platform===h.platform}equals(e){return h.instanceof(e)?e.unwrap()===this.unwrap():this.toUniversalAddress().equals(e)}};o(h,"byteSize",32),o(h,"platform","Sui");let f=h;A("Sui",f);class G{constructor(e,t,n,s,r=!1){o(this,"transaction");o(this,"network");o(this,"chain");o(this,"description");o(this,"parallelizable");this.transaction=e,this.network=t,this.chain=n,this.description=s,this.parallelizable=r}}class H extends F{}const _="Sui",K=i=>{var t;const e=(t=i.data)==null?void 0:t.content;return e&&e.dataType==="moveObject"?e.fields:null},Y=async(i,e)=>{if(!R(e))throw new Error(`Invalid object ID: ${e}`);const t=await i.getObject({id:e,options:{showContent:!0}});return K(t)},u=class u extends D{constructor(e,t){super(e,t??O(e,u._platform))}getRpc(e){if(e in this.config)return new U({url:this.config[e].rpc});throw new Error("No configuration available for chain: "+e)}getChain(e){if(e in this.config)return new H(e,this);throw new Error("No configuration available for chain: "+e)}static nativeTokenId(e,t){if(!u.isSupportedChain(t))throw new Error(`invalid chain for ${_}: ${t}`);return z.tokenId(t,E)}static isNativeTokenId(e,t,n){return!u.isSupportedChain(t)||n.chain!==t?!1:this.nativeTokenId(e,t)===n}static isSupportedChain(e){return P(e)===u._platform}static async getDecimals(e,t,n){if(C(n))return q(u._platform);const s=new f(n);try{const a=await Y(t,s.toString());if(a&&"decimals"in a)return a.decimals}catch{}const r=await t.getCoinMetadata({coinType:s.toString()});if(r===null)throw new Error(`Can't fetch decimals for token ${s.toString()}`);return r.decimals}static async getCoins(e,t,n){let s=[],r=null;const a=new f(t).toString();do{const c=await e.getCoins({owner:a,coinType:n,cursor:r});s=[...s,...c.data],r=c.hasNextPage?c.nextCursor:null}while(r);return s}static async getBalance(e,t,n,s){if(C(s)){const{totalBalance:a}=await t.getBalance({owner:n});return BigInt(a)}const{totalBalance:r}=await t.getBalance({owner:n,coinType:s.toString()});return BigInt(r)}static async getBalances(e,t,n,s){return(await Promise.all(s.map(async a=>{const c=await this.getBalance(e,t,n,a);return{[C(a)?"native":new f(a).toString()]:c}}))).reduce((a,c)=>Object.assign(a,c),{})}static async sendWait(e,t,n){const s=[];for(const r of n){const a=await t.executeTransactionBlock(r);await t.waitForTransaction({digest:a.digest}),s.push(a.digest)}return s}static async getLatestBlock(e){return Number(await e.getLatestCheckpointSequenceNumber())}static async getLatestFinalizedBlock(e){return this.getLatestBlock(e)}static chainFromChainId(e){const t=L(u._platform,e);if(t===void 0)throw new Error(`Unknown native chain id ${e}`);const[n,s]=t;return[n,s]}static async chainFromRpc(e){const t=await e.call("sui_getChainIdentifier",[]);return this.chainFromChainId(t)}};o(u,"_platform",_);let b=u;const Z=[["Testnet",{tokenMessengerState:"0x5252abd1137094ed1db3e0d75bc36abcd287aee4bc310f8e047727ef5682e7c2",messageTransmitterState:"0x98234bd0fa9ac12cc0a20a144a22e36d6a32f7e0a97baaeaf9c76cdc6d122d2e",usdcTreasury:"0x7170137d4a6431bf83351ac025baf462909bffe2877d87716374fb42b9629ebe"}],["Mainnet",{tokenMessengerState:"0x45993eecc0382f37419864992c12faee2238f5cfe22b98ad3bf455baf65c8a2f",messageTransmitterState:"0xf68268c3d9b1df3215f2439400c1c4ea08ac4ef4bb7d6f3ca6a2a239e17510af",usdcTreasury:"0x57d6725e7a8b49a7b2a612f6bd66ab5f39fc95332ca48be421c3229d514a6de7"}]],ee=V(Z,[0,1]);class k{constructor(e,t,n,s){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"usdcId");o(this,"usdcTreasuryId");o(this,"tokenMessengerId");o(this,"tokenMessengerStateId");o(this,"messageTransmitterId");o(this,"messageTransmitterStateId");var m,l,p,w;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=W.get(this.network,this.chain);if(!r)throw new Error(`No USDC contract configured for network=${this.network} chain=${this.chain}`);const{tokenMessengerState:a,messageTransmitterState:c,usdcTreasury:d}=ee(e);if(!((m=s.cctp)!=null&&m.tokenMessenger))throw new Error(`Circle Token Messenger contract for domain ${t} not found`);if(!((l=s.cctp)!=null&&l.messageTransmitter))throw new Error(`Circle Message Transmitter contract for domain ${t} not found`);this.usdcId=r,this.usdcTreasuryId=d,this.tokenMessengerId=(p=s.cctp)==null?void 0:p.tokenMessenger,this.messageTransmitterId=(w=s.cctp)==null?void 0:w.messageTransmitter,this.tokenMessengerStateId=a,this.messageTransmitterStateId=c}async*transfer(e,t,n){const s=new T,r=J.get(this.network,t.chain),[a,...c]=await b.getCoins(this.provider,e,this.usdcId);if(a===void 0)throw new Error("No USDC in wallet");const d=s.object(a.coinObjectId);c.length>0&&s.mergeCoins(d,c.map(l=>s.object(l.coinObjectId)));const[m]=s.splitCoins(d,[n]);s.moveCall({target:`${this.tokenMessengerId}::deposit_for_burn::deposit_for_burn`,arguments:[m,s.pure.u32(r),s.pure.address(t.address.toUniversalAddress().toString()),s.object(this.tokenMessengerStateId),s.object(this.messageTransmitterStateId),s.object("0x403"),s.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]}),yield this.createUnsignedTx(s,"Sui.CircleBridge.Transfer")}async isTransferCompleted(e){const t=new T;t.moveCall({target:`${this.messageTransmitterId}::state::is_nonce_used`,arguments:[t.object(this.messageTransmitterStateId),t.pure.u32(e.sourceDomain),t.pure.u64(e.nonce)]});const n=await this.provider.devInspectTransactionBlock({sender:"0x0000000000000000000000000000000000000000000000000000000000000000",transactionBlock:t});try{return!!n.results[0].returnValues[0][0][0]}catch(s){return console.error(`Error reading if nonce was used: ${s}`),!1}}async*redeem(e,t,n){const s=new T,[r]=s.moveCall({target:`${this.messageTransmitterId}::receive_message::receive_message`,arguments:[s.pure.vector("u8",y.serialize(t)),s.pure.vector("u8",g.decode(n)),s.object(this.messageTransmitterStateId)]});if(!r)throw new Error("Failed to produce receipt");const[a]=s.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::handle_receive_message`,arguments:[r,s.object(this.tokenMessengerStateId),s.object("0x403"),s.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]});if(!a)throw new Error("Failed to produce stamp receipt ticket with burn message");const[c]=s.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::deconstruct_stamp_receipt_ticket_with_burn_message`,arguments:[a]});if(!c)throw new Error("Failed to produce stamp receipt ticket");const[d]=s.moveCall({target:`${this.messageTransmitterId}::receive_message::stamp_receipt`,arguments:[c,s.object(this.messageTransmitterStateId)],typeArguments:[`${this.tokenMessengerId}::message_transmitter_authenticator::MessageTransmitterAuthenticator`]});if(!d)throw new Error("Failed to produce stamped receipt");s.moveCall({target:`${this.messageTransmitterId}::receive_message::complete_receive_message`,arguments:[d,s.object(this.messageTransmitterStateId)]}),yield this.createUnsignedTx(s,"Sui.CircleBridge.Redeem")}async parseTransactionDetails(e){var v;const t=await this.provider.waitForTransaction({digest:e,options:{showEvents:!0,showEffects:!0,showInput:!0}});if(!t)throw new Error("Transaction not found");if(!t.events)throw new Error("Transaction events not found");const n=(v=t.events)==null?void 0:v.find($=>$.type.includes("send_message::MessageSent"));if(!n)throw new Error("No MessageSent event found");const s=new Uint8Array((n==null?void 0:n.parsedJson).message),[r,a]=y.deserialize(s),{payload:c}=r,d=c.messageSender,m=c.mintRecipient,l=x(this.network,r.sourceDomain),p=x(this.network,r.destinationDomain),w={chain:l,address:c.burnToken};return{from:{chain:l,address:d},to:{chain:p,address:m},token:w,amount:c.amount,message:r,id:{hash:a}}}static async fromRpc(e,t){const[n,s]=await b.chainFromRpc(e),r=t[s];if(r.network!==n)throw new Error(`Network mismatch: ${r.network} != ${n}`);return new k(n,s,e,r.contracts)}createUnsignedTx(e,t,n=!1){return new G(e,this.network,this.chain,t,n)}}Q("Sui","CircleBridge",k);export{k as SuiCircleBridge};