@awarizon/web3 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,12 +1,3276 @@
1
1
  'use strict';
2
2
 
3
3
  var viem = require('viem');
4
- var walletEngine = require('@awarizon/wallet-engine');
5
- var txEngine = require('@awarizon/tx-engine');
4
+ var accounts = require('viem/accounts');
5
+ var nc = require('crypto');
6
6
  var chains = require('viem/chains');
7
- var abiEngine = require('@awarizon/abi-engine');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var nc__namespace = /*#__PURE__*/_interopNamespace(nc);
8
27
 
9
28
  // src/sdk.ts
29
+ var crypto = nc__namespace && typeof nc__namespace === "object" && "webcrypto" in nc__namespace ? nc__namespace.webcrypto : nc__namespace && typeof nc__namespace === "object" && "randomBytes" in nc__namespace ? nc__namespace : void 0;
30
+
31
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
32
+ function isBytes(a) {
33
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
34
+ }
35
+ function anumber(n) {
36
+ if (!Number.isSafeInteger(n) || n < 0)
37
+ throw new Error("positive integer expected, got " + n);
38
+ }
39
+ function abytes(b, ...lengths) {
40
+ if (!isBytes(b))
41
+ throw new Error("Uint8Array expected");
42
+ if (lengths.length > 0 && !lengths.includes(b.length))
43
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
44
+ }
45
+ function aexists(instance, checkFinished = true) {
46
+ if (instance.destroyed)
47
+ throw new Error("Hash instance has been destroyed");
48
+ if (checkFinished && instance.finished)
49
+ throw new Error("Hash#digest() has already been called");
50
+ }
51
+ function aoutput(out, instance) {
52
+ abytes(out);
53
+ const min = instance.outputLen;
54
+ if (out.length < min) {
55
+ throw new Error("digestInto() expects output buffer of length at least " + min);
56
+ }
57
+ }
58
+ function clean(...arrays) {
59
+ for (let i = 0; i < arrays.length; i++) {
60
+ arrays[i].fill(0);
61
+ }
62
+ }
63
+ function createView(arr) {
64
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
65
+ }
66
+ function rotr(word, shift) {
67
+ return word << 32 - shift | word >>> shift;
68
+ }
69
+ function utf8ToBytes(str) {
70
+ if (typeof str !== "string")
71
+ throw new Error("string expected");
72
+ return new Uint8Array(new TextEncoder().encode(str));
73
+ }
74
+ function toBytes(data) {
75
+ if (typeof data === "string")
76
+ data = utf8ToBytes(data);
77
+ abytes(data);
78
+ return data;
79
+ }
80
+ var Hash = class {
81
+ };
82
+ function createHasher(hashCons) {
83
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
84
+ const tmp = hashCons();
85
+ hashC.outputLen = tmp.outputLen;
86
+ hashC.blockLen = tmp.blockLen;
87
+ hashC.create = () => hashCons();
88
+ return hashC;
89
+ }
90
+ function randomBytes(bytesLength = 32) {
91
+ if (crypto && typeof crypto.getRandomValues === "function") {
92
+ return crypto.getRandomValues(new Uint8Array(bytesLength));
93
+ }
94
+ if (crypto && typeof crypto.randomBytes === "function") {
95
+ return Uint8Array.from(crypto.randomBytes(bytesLength));
96
+ }
97
+ throw new Error("crypto.getRandomValues must be defined");
98
+ }
99
+
100
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
101
+ function setBigUint64(view, byteOffset, value, isLE) {
102
+ if (typeof view.setBigUint64 === "function")
103
+ return view.setBigUint64(byteOffset, value, isLE);
104
+ const _32n = BigInt(32);
105
+ const _u32_max = BigInt(4294967295);
106
+ const wh = Number(value >> _32n & _u32_max);
107
+ const wl = Number(value & _u32_max);
108
+ const h = isLE ? 4 : 0;
109
+ const l = isLE ? 0 : 4;
110
+ view.setUint32(byteOffset + h, wh, isLE);
111
+ view.setUint32(byteOffset + l, wl, isLE);
112
+ }
113
+ function Chi(a, b, c) {
114
+ return a & b ^ ~a & c;
115
+ }
116
+ function Maj(a, b, c) {
117
+ return a & b ^ a & c ^ b & c;
118
+ }
119
+ var HashMD = class extends Hash {
120
+ constructor(blockLen, outputLen, padOffset, isLE) {
121
+ super();
122
+ this.finished = false;
123
+ this.length = 0;
124
+ this.pos = 0;
125
+ this.destroyed = false;
126
+ this.blockLen = blockLen;
127
+ this.outputLen = outputLen;
128
+ this.padOffset = padOffset;
129
+ this.isLE = isLE;
130
+ this.buffer = new Uint8Array(blockLen);
131
+ this.view = createView(this.buffer);
132
+ }
133
+ update(data) {
134
+ aexists(this);
135
+ data = toBytes(data);
136
+ abytes(data);
137
+ const { view, buffer, blockLen } = this;
138
+ const len = data.length;
139
+ for (let pos = 0; pos < len; ) {
140
+ const take = Math.min(blockLen - this.pos, len - pos);
141
+ if (take === blockLen) {
142
+ const dataView = createView(data);
143
+ for (; blockLen <= len - pos; pos += blockLen)
144
+ this.process(dataView, pos);
145
+ continue;
146
+ }
147
+ buffer.set(data.subarray(pos, pos + take), this.pos);
148
+ this.pos += take;
149
+ pos += take;
150
+ if (this.pos === blockLen) {
151
+ this.process(view, 0);
152
+ this.pos = 0;
153
+ }
154
+ }
155
+ this.length += data.length;
156
+ this.roundClean();
157
+ return this;
158
+ }
159
+ digestInto(out) {
160
+ aexists(this);
161
+ aoutput(out, this);
162
+ this.finished = true;
163
+ const { buffer, view, blockLen, isLE } = this;
164
+ let { pos } = this;
165
+ buffer[pos++] = 128;
166
+ clean(this.buffer.subarray(pos));
167
+ if (this.padOffset > blockLen - pos) {
168
+ this.process(view, 0);
169
+ pos = 0;
170
+ }
171
+ for (let i = pos; i < blockLen; i++)
172
+ buffer[i] = 0;
173
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
174
+ this.process(view, 0);
175
+ const oview = createView(out);
176
+ const len = this.outputLen;
177
+ if (len % 4)
178
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
179
+ const outLen = len / 4;
180
+ const state = this.get();
181
+ if (outLen > state.length)
182
+ throw new Error("_sha2: outputLen bigger than state");
183
+ for (let i = 0; i < outLen; i++)
184
+ oview.setUint32(4 * i, state[i], isLE);
185
+ }
186
+ digest() {
187
+ const { buffer, outputLen } = this;
188
+ this.digestInto(buffer);
189
+ const res = buffer.slice(0, outputLen);
190
+ this.destroy();
191
+ return res;
192
+ }
193
+ _cloneInto(to) {
194
+ to || (to = new this.constructor());
195
+ to.set(...this.get());
196
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
197
+ to.destroyed = destroyed;
198
+ to.finished = finished;
199
+ to.length = length;
200
+ to.pos = pos;
201
+ if (length % blockLen)
202
+ to.buffer.set(buffer);
203
+ return to;
204
+ }
205
+ clone() {
206
+ return this._cloneInto();
207
+ }
208
+ };
209
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
210
+ 1779033703,
211
+ 3144134277,
212
+ 1013904242,
213
+ 2773480762,
214
+ 1359893119,
215
+ 2600822924,
216
+ 528734635,
217
+ 1541459225
218
+ ]);
219
+
220
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
221
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
222
+ 1116352408,
223
+ 1899447441,
224
+ 3049323471,
225
+ 3921009573,
226
+ 961987163,
227
+ 1508970993,
228
+ 2453635748,
229
+ 2870763221,
230
+ 3624381080,
231
+ 310598401,
232
+ 607225278,
233
+ 1426881987,
234
+ 1925078388,
235
+ 2162078206,
236
+ 2614888103,
237
+ 3248222580,
238
+ 3835390401,
239
+ 4022224774,
240
+ 264347078,
241
+ 604807628,
242
+ 770255983,
243
+ 1249150122,
244
+ 1555081692,
245
+ 1996064986,
246
+ 2554220882,
247
+ 2821834349,
248
+ 2952996808,
249
+ 3210313671,
250
+ 3336571891,
251
+ 3584528711,
252
+ 113926993,
253
+ 338241895,
254
+ 666307205,
255
+ 773529912,
256
+ 1294757372,
257
+ 1396182291,
258
+ 1695183700,
259
+ 1986661051,
260
+ 2177026350,
261
+ 2456956037,
262
+ 2730485921,
263
+ 2820302411,
264
+ 3259730800,
265
+ 3345764771,
266
+ 3516065817,
267
+ 3600352804,
268
+ 4094571909,
269
+ 275423344,
270
+ 430227734,
271
+ 506948616,
272
+ 659060556,
273
+ 883997877,
274
+ 958139571,
275
+ 1322822218,
276
+ 1537002063,
277
+ 1747873779,
278
+ 1955562222,
279
+ 2024104815,
280
+ 2227730452,
281
+ 2361852424,
282
+ 2428436474,
283
+ 2756734187,
284
+ 3204031479,
285
+ 3329325298
286
+ ]);
287
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
288
+ var SHA256 = class extends HashMD {
289
+ constructor(outputLen = 32) {
290
+ super(64, outputLen, 8, false);
291
+ this.A = SHA256_IV[0] | 0;
292
+ this.B = SHA256_IV[1] | 0;
293
+ this.C = SHA256_IV[2] | 0;
294
+ this.D = SHA256_IV[3] | 0;
295
+ this.E = SHA256_IV[4] | 0;
296
+ this.F = SHA256_IV[5] | 0;
297
+ this.G = SHA256_IV[6] | 0;
298
+ this.H = SHA256_IV[7] | 0;
299
+ }
300
+ get() {
301
+ const { A, B, C, D, E, F, G, H } = this;
302
+ return [A, B, C, D, E, F, G, H];
303
+ }
304
+ // prettier-ignore
305
+ set(A, B, C, D, E, F, G, H) {
306
+ this.A = A | 0;
307
+ this.B = B | 0;
308
+ this.C = C | 0;
309
+ this.D = D | 0;
310
+ this.E = E | 0;
311
+ this.F = F | 0;
312
+ this.G = G | 0;
313
+ this.H = H | 0;
314
+ }
315
+ process(view, offset) {
316
+ for (let i = 0; i < 16; i++, offset += 4)
317
+ SHA256_W[i] = view.getUint32(offset, false);
318
+ for (let i = 16; i < 64; i++) {
319
+ const W15 = SHA256_W[i - 15];
320
+ const W2 = SHA256_W[i - 2];
321
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
322
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
323
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
324
+ }
325
+ let { A, B, C, D, E, F, G, H } = this;
326
+ for (let i = 0; i < 64; i++) {
327
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
328
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
329
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
330
+ const T2 = sigma0 + Maj(A, B, C) | 0;
331
+ H = G;
332
+ G = F;
333
+ F = E;
334
+ E = D + T1 | 0;
335
+ D = C;
336
+ C = B;
337
+ B = A;
338
+ A = T1 + T2 | 0;
339
+ }
340
+ A = A + this.A | 0;
341
+ B = B + this.B | 0;
342
+ C = C + this.C | 0;
343
+ D = D + this.D | 0;
344
+ E = E + this.E | 0;
345
+ F = F + this.F | 0;
346
+ G = G + this.G | 0;
347
+ H = H + this.H | 0;
348
+ this.set(A, B, C, D, E, F, G, H);
349
+ }
350
+ roundClean() {
351
+ clean(SHA256_W);
352
+ }
353
+ destroy() {
354
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
355
+ clean(this.buffer);
356
+ }
357
+ };
358
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
359
+
360
+ // ../../node_modules/.pnpm/@scure+base@1.2.6/node_modules/@scure/base/lib/esm/index.js
361
+ function isBytes2(a) {
362
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
363
+ }
364
+ function isArrayOf(isString, arr) {
365
+ if (!Array.isArray(arr))
366
+ return false;
367
+ if (arr.length === 0)
368
+ return true;
369
+ if (isString) {
370
+ return arr.every((item) => typeof item === "string");
371
+ } else {
372
+ return arr.every((item) => Number.isSafeInteger(item));
373
+ }
374
+ }
375
+ function afn(input) {
376
+ if (typeof input !== "function")
377
+ throw new Error("function expected");
378
+ return true;
379
+ }
380
+ function astr(label, input) {
381
+ if (typeof input !== "string")
382
+ throw new Error(`${label}: string expected`);
383
+ return true;
384
+ }
385
+ function anumber2(n) {
386
+ if (!Number.isSafeInteger(n))
387
+ throw new Error(`invalid integer: ${n}`);
388
+ }
389
+ function aArr(input) {
390
+ if (!Array.isArray(input))
391
+ throw new Error("array expected");
392
+ }
393
+ function astrArr(label, input) {
394
+ if (!isArrayOf(true, input))
395
+ throw new Error(`${label}: array of strings expected`);
396
+ }
397
+ function anumArr(label, input) {
398
+ if (!isArrayOf(false, input))
399
+ throw new Error(`${label}: array of numbers expected`);
400
+ }
401
+ // @__NO_SIDE_EFFECTS__
402
+ function chain(...args) {
403
+ const id = (a) => a;
404
+ const wrap = (a, b) => (c) => a(b(c));
405
+ const encode = args.map((x) => x.encode).reduceRight(wrap, id);
406
+ const decode = args.map((x) => x.decode).reduce(wrap, id);
407
+ return { encode, decode };
408
+ }
409
+ // @__NO_SIDE_EFFECTS__
410
+ function alphabet(letters) {
411
+ const lettersA = typeof letters === "string" ? letters.split("") : letters;
412
+ const len = lettersA.length;
413
+ astrArr("alphabet", lettersA);
414
+ const indexes = new Map(lettersA.map((l, i) => [l, i]));
415
+ return {
416
+ encode: (digits) => {
417
+ aArr(digits);
418
+ return digits.map((i) => {
419
+ if (!Number.isSafeInteger(i) || i < 0 || i >= len)
420
+ throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
421
+ return lettersA[i];
422
+ });
423
+ },
424
+ decode: (input) => {
425
+ aArr(input);
426
+ return input.map((letter) => {
427
+ astr("alphabet.decode", letter);
428
+ const i = indexes.get(letter);
429
+ if (i === void 0)
430
+ throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
431
+ return i;
432
+ });
433
+ }
434
+ };
435
+ }
436
+ // @__NO_SIDE_EFFECTS__
437
+ function join(separator = "") {
438
+ astr("join", separator);
439
+ return {
440
+ encode: (from) => {
441
+ astrArr("join.decode", from);
442
+ return from.join(separator);
443
+ },
444
+ decode: (to) => {
445
+ astr("join.decode", to);
446
+ return to.split(separator);
447
+ }
448
+ };
449
+ }
450
+ // @__NO_SIDE_EFFECTS__
451
+ function padding(bits, chr = "=") {
452
+ anumber2(bits);
453
+ astr("padding", chr);
454
+ return {
455
+ encode(data) {
456
+ astrArr("padding.encode", data);
457
+ while (data.length * bits % 8)
458
+ data.push(chr);
459
+ return data;
460
+ },
461
+ decode(input) {
462
+ astrArr("padding.decode", input);
463
+ let end = input.length;
464
+ if (end * bits % 8)
465
+ throw new Error("padding: invalid, string should have whole number of bytes");
466
+ for (; end > 0 && input[end - 1] === chr; end--) {
467
+ const last = end - 1;
468
+ const byte = last * bits;
469
+ if (byte % 8 === 0)
470
+ throw new Error("padding: invalid, string has too much padding");
471
+ }
472
+ return input.slice(0, end);
473
+ }
474
+ };
475
+ }
476
+ function convertRadix(data, from, to) {
477
+ if (from < 2)
478
+ throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
479
+ if (to < 2)
480
+ throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
481
+ aArr(data);
482
+ if (!data.length)
483
+ return [];
484
+ let pos = 0;
485
+ const res = [];
486
+ const digits = Array.from(data, (d) => {
487
+ anumber2(d);
488
+ if (d < 0 || d >= from)
489
+ throw new Error(`invalid integer: ${d}`);
490
+ return d;
491
+ });
492
+ const dlen = digits.length;
493
+ while (true) {
494
+ let carry = 0;
495
+ let done = true;
496
+ for (let i = pos; i < dlen; i++) {
497
+ const digit = digits[i];
498
+ const fromCarry = from * carry;
499
+ const digitBase = fromCarry + digit;
500
+ if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
501
+ throw new Error("convertRadix: carry overflow");
502
+ }
503
+ const div = digitBase / to;
504
+ carry = digitBase % to;
505
+ const rounded = Math.floor(div);
506
+ digits[i] = rounded;
507
+ if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
508
+ throw new Error("convertRadix: carry overflow");
509
+ if (!done)
510
+ continue;
511
+ else if (!rounded)
512
+ pos = i;
513
+ else
514
+ done = false;
515
+ }
516
+ res.push(carry);
517
+ if (done)
518
+ break;
519
+ }
520
+ for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
521
+ res.push(0);
522
+ return res.reverse();
523
+ }
524
+ var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
525
+ var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
526
+ var powers = /* @__PURE__ */ (() => {
527
+ let res = [];
528
+ for (let i = 0; i < 40; i++)
529
+ res.push(2 ** i);
530
+ return res;
531
+ })();
532
+ function convertRadix2(data, from, to, padding2) {
533
+ aArr(data);
534
+ if (from <= 0 || from > 32)
535
+ throw new Error(`convertRadix2: wrong from=${from}`);
536
+ if (to <= 0 || to > 32)
537
+ throw new Error(`convertRadix2: wrong to=${to}`);
538
+ if (/* @__PURE__ */ radix2carry(from, to) > 32) {
539
+ throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
540
+ }
541
+ let carry = 0;
542
+ let pos = 0;
543
+ const max = powers[from];
544
+ const mask = powers[to] - 1;
545
+ const res = [];
546
+ for (const n of data) {
547
+ anumber2(n);
548
+ if (n >= max)
549
+ throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
550
+ carry = carry << from | n;
551
+ if (pos + from > 32)
552
+ throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
553
+ pos += from;
554
+ for (; pos >= to; pos -= to)
555
+ res.push((carry >> pos - to & mask) >>> 0);
556
+ const pow = powers[pos];
557
+ if (pow === void 0)
558
+ throw new Error("invalid carry");
559
+ carry &= pow - 1;
560
+ }
561
+ carry = carry << to - pos & mask;
562
+ if (!padding2 && pos >= from)
563
+ throw new Error("Excess padding");
564
+ if (!padding2 && carry > 0)
565
+ throw new Error(`Non-zero padding: ${carry}`);
566
+ if (padding2 && pos > 0)
567
+ res.push(carry >>> 0);
568
+ return res;
569
+ }
570
+ // @__NO_SIDE_EFFECTS__
571
+ function radix(num) {
572
+ anumber2(num);
573
+ const _256 = 2 ** 8;
574
+ return {
575
+ encode: (bytes) => {
576
+ if (!isBytes2(bytes))
577
+ throw new Error("radix.encode input should be Uint8Array");
578
+ return convertRadix(Array.from(bytes), _256, num);
579
+ },
580
+ decode: (digits) => {
581
+ anumArr("radix.decode", digits);
582
+ return Uint8Array.from(convertRadix(digits, num, _256));
583
+ }
584
+ };
585
+ }
586
+ // @__NO_SIDE_EFFECTS__
587
+ function radix2(bits, revPadding = false) {
588
+ anumber2(bits);
589
+ if (bits <= 0 || bits > 32)
590
+ throw new Error("radix2: bits should be in (0..32]");
591
+ if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32)
592
+ throw new Error("radix2: carry overflow");
593
+ return {
594
+ encode: (bytes) => {
595
+ if (!isBytes2(bytes))
596
+ throw new Error("radix2.encode input should be Uint8Array");
597
+ return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
598
+ },
599
+ decode: (digits) => {
600
+ anumArr("radix2.decode", digits);
601
+ return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
602
+ }
603
+ };
604
+ }
605
+ function checksum(len, fn) {
606
+ anumber2(len);
607
+ afn(fn);
608
+ return {
609
+ encode(data) {
610
+ if (!isBytes2(data))
611
+ throw new Error("checksum.encode: input should be Uint8Array");
612
+ const sum = fn(data).slice(0, len);
613
+ const res = new Uint8Array(data.length + len);
614
+ res.set(data);
615
+ res.set(sum, data.length);
616
+ return res;
617
+ },
618
+ decode(data) {
619
+ if (!isBytes2(data))
620
+ throw new Error("checksum.decode: input should be Uint8Array");
621
+ const payload = data.slice(0, -len);
622
+ const oldChecksum = data.slice(-len);
623
+ const newChecksum = fn(payload).slice(0, len);
624
+ for (let i = 0; i < len; i++)
625
+ if (newChecksum[i] !== oldChecksum[i])
626
+ throw new Error("Invalid checksum");
627
+ return payload;
628
+ }
629
+ };
630
+ }
631
+ var utils = {
632
+ alphabet,
633
+ chain,
634
+ checksum,
635
+ convertRadix,
636
+ convertRadix2,
637
+ radix,
638
+ radix2,
639
+ join,
640
+ padding
641
+ };
642
+
643
+ // ../../node_modules/.pnpm/@scure+bip39@1.6.0/node_modules/@scure/bip39/esm/index.js
644
+ var isJapanese = (wordlist2) => wordlist2[0] === "\u3042\u3044\u3053\u304F\u3057\u3093";
645
+ function nfkd(str) {
646
+ if (typeof str !== "string")
647
+ throw new TypeError("invalid mnemonic type: " + typeof str);
648
+ return str.normalize("NFKD");
649
+ }
650
+ function normalize(str) {
651
+ const norm = nfkd(str);
652
+ const words = norm.split(" ");
653
+ if (![12, 15, 18, 21, 24].includes(words.length))
654
+ throw new Error("Invalid mnemonic");
655
+ return { nfkd: norm, words };
656
+ }
657
+ function aentropy(ent) {
658
+ abytes(ent, 16, 20, 24, 28, 32);
659
+ }
660
+ function generateMnemonic(wordlist2, strength = 128) {
661
+ anumber(strength);
662
+ if (strength % 32 !== 0 || strength > 256)
663
+ throw new TypeError("Invalid entropy");
664
+ return entropyToMnemonic(randomBytes(strength / 8), wordlist2);
665
+ }
666
+ var calcChecksum = (entropy) => {
667
+ const bitsLeft = 8 - entropy.length / 4;
668
+ return new Uint8Array([sha256(entropy)[0] >> bitsLeft << bitsLeft]);
669
+ };
670
+ function getCoder(wordlist2) {
671
+ if (!Array.isArray(wordlist2) || wordlist2.length !== 2048 || typeof wordlist2[0] !== "string")
672
+ throw new Error("Wordlist: expected array of 2048 strings");
673
+ wordlist2.forEach((i) => {
674
+ if (typeof i !== "string")
675
+ throw new Error("wordlist: non-string element: " + i);
676
+ });
677
+ return utils.chain(utils.checksum(1, calcChecksum), utils.radix2(11, true), utils.alphabet(wordlist2));
678
+ }
679
+ function mnemonicToEntropy(mnemonic, wordlist2) {
680
+ const { words } = normalize(mnemonic);
681
+ const entropy = getCoder(wordlist2).decode(words);
682
+ aentropy(entropy);
683
+ return entropy;
684
+ }
685
+ function entropyToMnemonic(entropy, wordlist2) {
686
+ aentropy(entropy);
687
+ const words = getCoder(wordlist2).encode(entropy);
688
+ return words.join(isJapanese(wordlist2) ? "\u3000" : " ");
689
+ }
690
+ function validateMnemonic(mnemonic, wordlist2) {
691
+ try {
692
+ mnemonicToEntropy(mnemonic, wordlist2);
693
+ } catch (e) {
694
+ return false;
695
+ }
696
+ return true;
697
+ }
698
+
699
+ // ../../node_modules/.pnpm/@scure+bip39@1.6.0/node_modules/@scure/bip39/esm/wordlists/english.js
700
+ var wordlist = `abandon
701
+ ability
702
+ able
703
+ about
704
+ above
705
+ absent
706
+ absorb
707
+ abstract
708
+ absurd
709
+ abuse
710
+ access
711
+ accident
712
+ account
713
+ accuse
714
+ achieve
715
+ acid
716
+ acoustic
717
+ acquire
718
+ across
719
+ act
720
+ action
721
+ actor
722
+ actress
723
+ actual
724
+ adapt
725
+ add
726
+ addict
727
+ address
728
+ adjust
729
+ admit
730
+ adult
731
+ advance
732
+ advice
733
+ aerobic
734
+ affair
735
+ afford
736
+ afraid
737
+ again
738
+ age
739
+ agent
740
+ agree
741
+ ahead
742
+ aim
743
+ air
744
+ airport
745
+ aisle
746
+ alarm
747
+ album
748
+ alcohol
749
+ alert
750
+ alien
751
+ all
752
+ alley
753
+ allow
754
+ almost
755
+ alone
756
+ alpha
757
+ already
758
+ also
759
+ alter
760
+ always
761
+ amateur
762
+ amazing
763
+ among
764
+ amount
765
+ amused
766
+ analyst
767
+ anchor
768
+ ancient
769
+ anger
770
+ angle
771
+ angry
772
+ animal
773
+ ankle
774
+ announce
775
+ annual
776
+ another
777
+ answer
778
+ antenna
779
+ antique
780
+ anxiety
781
+ any
782
+ apart
783
+ apology
784
+ appear
785
+ apple
786
+ approve
787
+ april
788
+ arch
789
+ arctic
790
+ area
791
+ arena
792
+ argue
793
+ arm
794
+ armed
795
+ armor
796
+ army
797
+ around
798
+ arrange
799
+ arrest
800
+ arrive
801
+ arrow
802
+ art
803
+ artefact
804
+ artist
805
+ artwork
806
+ ask
807
+ aspect
808
+ assault
809
+ asset
810
+ assist
811
+ assume
812
+ asthma
813
+ athlete
814
+ atom
815
+ attack
816
+ attend
817
+ attitude
818
+ attract
819
+ auction
820
+ audit
821
+ august
822
+ aunt
823
+ author
824
+ auto
825
+ autumn
826
+ average
827
+ avocado
828
+ avoid
829
+ awake
830
+ aware
831
+ away
832
+ awesome
833
+ awful
834
+ awkward
835
+ axis
836
+ baby
837
+ bachelor
838
+ bacon
839
+ badge
840
+ bag
841
+ balance
842
+ balcony
843
+ ball
844
+ bamboo
845
+ banana
846
+ banner
847
+ bar
848
+ barely
849
+ bargain
850
+ barrel
851
+ base
852
+ basic
853
+ basket
854
+ battle
855
+ beach
856
+ bean
857
+ beauty
858
+ because
859
+ become
860
+ beef
861
+ before
862
+ begin
863
+ behave
864
+ behind
865
+ believe
866
+ below
867
+ belt
868
+ bench
869
+ benefit
870
+ best
871
+ betray
872
+ better
873
+ between
874
+ beyond
875
+ bicycle
876
+ bid
877
+ bike
878
+ bind
879
+ biology
880
+ bird
881
+ birth
882
+ bitter
883
+ black
884
+ blade
885
+ blame
886
+ blanket
887
+ blast
888
+ bleak
889
+ bless
890
+ blind
891
+ blood
892
+ blossom
893
+ blouse
894
+ blue
895
+ blur
896
+ blush
897
+ board
898
+ boat
899
+ body
900
+ boil
901
+ bomb
902
+ bone
903
+ bonus
904
+ book
905
+ boost
906
+ border
907
+ boring
908
+ borrow
909
+ boss
910
+ bottom
911
+ bounce
912
+ box
913
+ boy
914
+ bracket
915
+ brain
916
+ brand
917
+ brass
918
+ brave
919
+ bread
920
+ breeze
921
+ brick
922
+ bridge
923
+ brief
924
+ bright
925
+ bring
926
+ brisk
927
+ broccoli
928
+ broken
929
+ bronze
930
+ broom
931
+ brother
932
+ brown
933
+ brush
934
+ bubble
935
+ buddy
936
+ budget
937
+ buffalo
938
+ build
939
+ bulb
940
+ bulk
941
+ bullet
942
+ bundle
943
+ bunker
944
+ burden
945
+ burger
946
+ burst
947
+ bus
948
+ business
949
+ busy
950
+ butter
951
+ buyer
952
+ buzz
953
+ cabbage
954
+ cabin
955
+ cable
956
+ cactus
957
+ cage
958
+ cake
959
+ call
960
+ calm
961
+ camera
962
+ camp
963
+ can
964
+ canal
965
+ cancel
966
+ candy
967
+ cannon
968
+ canoe
969
+ canvas
970
+ canyon
971
+ capable
972
+ capital
973
+ captain
974
+ car
975
+ carbon
976
+ card
977
+ cargo
978
+ carpet
979
+ carry
980
+ cart
981
+ case
982
+ cash
983
+ casino
984
+ castle
985
+ casual
986
+ cat
987
+ catalog
988
+ catch
989
+ category
990
+ cattle
991
+ caught
992
+ cause
993
+ caution
994
+ cave
995
+ ceiling
996
+ celery
997
+ cement
998
+ census
999
+ century
1000
+ cereal
1001
+ certain
1002
+ chair
1003
+ chalk
1004
+ champion
1005
+ change
1006
+ chaos
1007
+ chapter
1008
+ charge
1009
+ chase
1010
+ chat
1011
+ cheap
1012
+ check
1013
+ cheese
1014
+ chef
1015
+ cherry
1016
+ chest
1017
+ chicken
1018
+ chief
1019
+ child
1020
+ chimney
1021
+ choice
1022
+ choose
1023
+ chronic
1024
+ chuckle
1025
+ chunk
1026
+ churn
1027
+ cigar
1028
+ cinnamon
1029
+ circle
1030
+ citizen
1031
+ city
1032
+ civil
1033
+ claim
1034
+ clap
1035
+ clarify
1036
+ claw
1037
+ clay
1038
+ clean
1039
+ clerk
1040
+ clever
1041
+ click
1042
+ client
1043
+ cliff
1044
+ climb
1045
+ clinic
1046
+ clip
1047
+ clock
1048
+ clog
1049
+ close
1050
+ cloth
1051
+ cloud
1052
+ clown
1053
+ club
1054
+ clump
1055
+ cluster
1056
+ clutch
1057
+ coach
1058
+ coast
1059
+ coconut
1060
+ code
1061
+ coffee
1062
+ coil
1063
+ coin
1064
+ collect
1065
+ color
1066
+ column
1067
+ combine
1068
+ come
1069
+ comfort
1070
+ comic
1071
+ common
1072
+ company
1073
+ concert
1074
+ conduct
1075
+ confirm
1076
+ congress
1077
+ connect
1078
+ consider
1079
+ control
1080
+ convince
1081
+ cook
1082
+ cool
1083
+ copper
1084
+ copy
1085
+ coral
1086
+ core
1087
+ corn
1088
+ correct
1089
+ cost
1090
+ cotton
1091
+ couch
1092
+ country
1093
+ couple
1094
+ course
1095
+ cousin
1096
+ cover
1097
+ coyote
1098
+ crack
1099
+ cradle
1100
+ craft
1101
+ cram
1102
+ crane
1103
+ crash
1104
+ crater
1105
+ crawl
1106
+ crazy
1107
+ cream
1108
+ credit
1109
+ creek
1110
+ crew
1111
+ cricket
1112
+ crime
1113
+ crisp
1114
+ critic
1115
+ crop
1116
+ cross
1117
+ crouch
1118
+ crowd
1119
+ crucial
1120
+ cruel
1121
+ cruise
1122
+ crumble
1123
+ crunch
1124
+ crush
1125
+ cry
1126
+ crystal
1127
+ cube
1128
+ culture
1129
+ cup
1130
+ cupboard
1131
+ curious
1132
+ current
1133
+ curtain
1134
+ curve
1135
+ cushion
1136
+ custom
1137
+ cute
1138
+ cycle
1139
+ dad
1140
+ damage
1141
+ damp
1142
+ dance
1143
+ danger
1144
+ daring
1145
+ dash
1146
+ daughter
1147
+ dawn
1148
+ day
1149
+ deal
1150
+ debate
1151
+ debris
1152
+ decade
1153
+ december
1154
+ decide
1155
+ decline
1156
+ decorate
1157
+ decrease
1158
+ deer
1159
+ defense
1160
+ define
1161
+ defy
1162
+ degree
1163
+ delay
1164
+ deliver
1165
+ demand
1166
+ demise
1167
+ denial
1168
+ dentist
1169
+ deny
1170
+ depart
1171
+ depend
1172
+ deposit
1173
+ depth
1174
+ deputy
1175
+ derive
1176
+ describe
1177
+ desert
1178
+ design
1179
+ desk
1180
+ despair
1181
+ destroy
1182
+ detail
1183
+ detect
1184
+ develop
1185
+ device
1186
+ devote
1187
+ diagram
1188
+ dial
1189
+ diamond
1190
+ diary
1191
+ dice
1192
+ diesel
1193
+ diet
1194
+ differ
1195
+ digital
1196
+ dignity
1197
+ dilemma
1198
+ dinner
1199
+ dinosaur
1200
+ direct
1201
+ dirt
1202
+ disagree
1203
+ discover
1204
+ disease
1205
+ dish
1206
+ dismiss
1207
+ disorder
1208
+ display
1209
+ distance
1210
+ divert
1211
+ divide
1212
+ divorce
1213
+ dizzy
1214
+ doctor
1215
+ document
1216
+ dog
1217
+ doll
1218
+ dolphin
1219
+ domain
1220
+ donate
1221
+ donkey
1222
+ donor
1223
+ door
1224
+ dose
1225
+ double
1226
+ dove
1227
+ draft
1228
+ dragon
1229
+ drama
1230
+ drastic
1231
+ draw
1232
+ dream
1233
+ dress
1234
+ drift
1235
+ drill
1236
+ drink
1237
+ drip
1238
+ drive
1239
+ drop
1240
+ drum
1241
+ dry
1242
+ duck
1243
+ dumb
1244
+ dune
1245
+ during
1246
+ dust
1247
+ dutch
1248
+ duty
1249
+ dwarf
1250
+ dynamic
1251
+ eager
1252
+ eagle
1253
+ early
1254
+ earn
1255
+ earth
1256
+ easily
1257
+ east
1258
+ easy
1259
+ echo
1260
+ ecology
1261
+ economy
1262
+ edge
1263
+ edit
1264
+ educate
1265
+ effort
1266
+ egg
1267
+ eight
1268
+ either
1269
+ elbow
1270
+ elder
1271
+ electric
1272
+ elegant
1273
+ element
1274
+ elephant
1275
+ elevator
1276
+ elite
1277
+ else
1278
+ embark
1279
+ embody
1280
+ embrace
1281
+ emerge
1282
+ emotion
1283
+ employ
1284
+ empower
1285
+ empty
1286
+ enable
1287
+ enact
1288
+ end
1289
+ endless
1290
+ endorse
1291
+ enemy
1292
+ energy
1293
+ enforce
1294
+ engage
1295
+ engine
1296
+ enhance
1297
+ enjoy
1298
+ enlist
1299
+ enough
1300
+ enrich
1301
+ enroll
1302
+ ensure
1303
+ enter
1304
+ entire
1305
+ entry
1306
+ envelope
1307
+ episode
1308
+ equal
1309
+ equip
1310
+ era
1311
+ erase
1312
+ erode
1313
+ erosion
1314
+ error
1315
+ erupt
1316
+ escape
1317
+ essay
1318
+ essence
1319
+ estate
1320
+ eternal
1321
+ ethics
1322
+ evidence
1323
+ evil
1324
+ evoke
1325
+ evolve
1326
+ exact
1327
+ example
1328
+ excess
1329
+ exchange
1330
+ excite
1331
+ exclude
1332
+ excuse
1333
+ execute
1334
+ exercise
1335
+ exhaust
1336
+ exhibit
1337
+ exile
1338
+ exist
1339
+ exit
1340
+ exotic
1341
+ expand
1342
+ expect
1343
+ expire
1344
+ explain
1345
+ expose
1346
+ express
1347
+ extend
1348
+ extra
1349
+ eye
1350
+ eyebrow
1351
+ fabric
1352
+ face
1353
+ faculty
1354
+ fade
1355
+ faint
1356
+ faith
1357
+ fall
1358
+ false
1359
+ fame
1360
+ family
1361
+ famous
1362
+ fan
1363
+ fancy
1364
+ fantasy
1365
+ farm
1366
+ fashion
1367
+ fat
1368
+ fatal
1369
+ father
1370
+ fatigue
1371
+ fault
1372
+ favorite
1373
+ feature
1374
+ february
1375
+ federal
1376
+ fee
1377
+ feed
1378
+ feel
1379
+ female
1380
+ fence
1381
+ festival
1382
+ fetch
1383
+ fever
1384
+ few
1385
+ fiber
1386
+ fiction
1387
+ field
1388
+ figure
1389
+ file
1390
+ film
1391
+ filter
1392
+ final
1393
+ find
1394
+ fine
1395
+ finger
1396
+ finish
1397
+ fire
1398
+ firm
1399
+ first
1400
+ fiscal
1401
+ fish
1402
+ fit
1403
+ fitness
1404
+ fix
1405
+ flag
1406
+ flame
1407
+ flash
1408
+ flat
1409
+ flavor
1410
+ flee
1411
+ flight
1412
+ flip
1413
+ float
1414
+ flock
1415
+ floor
1416
+ flower
1417
+ fluid
1418
+ flush
1419
+ fly
1420
+ foam
1421
+ focus
1422
+ fog
1423
+ foil
1424
+ fold
1425
+ follow
1426
+ food
1427
+ foot
1428
+ force
1429
+ forest
1430
+ forget
1431
+ fork
1432
+ fortune
1433
+ forum
1434
+ forward
1435
+ fossil
1436
+ foster
1437
+ found
1438
+ fox
1439
+ fragile
1440
+ frame
1441
+ frequent
1442
+ fresh
1443
+ friend
1444
+ fringe
1445
+ frog
1446
+ front
1447
+ frost
1448
+ frown
1449
+ frozen
1450
+ fruit
1451
+ fuel
1452
+ fun
1453
+ funny
1454
+ furnace
1455
+ fury
1456
+ future
1457
+ gadget
1458
+ gain
1459
+ galaxy
1460
+ gallery
1461
+ game
1462
+ gap
1463
+ garage
1464
+ garbage
1465
+ garden
1466
+ garlic
1467
+ garment
1468
+ gas
1469
+ gasp
1470
+ gate
1471
+ gather
1472
+ gauge
1473
+ gaze
1474
+ general
1475
+ genius
1476
+ genre
1477
+ gentle
1478
+ genuine
1479
+ gesture
1480
+ ghost
1481
+ giant
1482
+ gift
1483
+ giggle
1484
+ ginger
1485
+ giraffe
1486
+ girl
1487
+ give
1488
+ glad
1489
+ glance
1490
+ glare
1491
+ glass
1492
+ glide
1493
+ glimpse
1494
+ globe
1495
+ gloom
1496
+ glory
1497
+ glove
1498
+ glow
1499
+ glue
1500
+ goat
1501
+ goddess
1502
+ gold
1503
+ good
1504
+ goose
1505
+ gorilla
1506
+ gospel
1507
+ gossip
1508
+ govern
1509
+ gown
1510
+ grab
1511
+ grace
1512
+ grain
1513
+ grant
1514
+ grape
1515
+ grass
1516
+ gravity
1517
+ great
1518
+ green
1519
+ grid
1520
+ grief
1521
+ grit
1522
+ grocery
1523
+ group
1524
+ grow
1525
+ grunt
1526
+ guard
1527
+ guess
1528
+ guide
1529
+ guilt
1530
+ guitar
1531
+ gun
1532
+ gym
1533
+ habit
1534
+ hair
1535
+ half
1536
+ hammer
1537
+ hamster
1538
+ hand
1539
+ happy
1540
+ harbor
1541
+ hard
1542
+ harsh
1543
+ harvest
1544
+ hat
1545
+ have
1546
+ hawk
1547
+ hazard
1548
+ head
1549
+ health
1550
+ heart
1551
+ heavy
1552
+ hedgehog
1553
+ height
1554
+ hello
1555
+ helmet
1556
+ help
1557
+ hen
1558
+ hero
1559
+ hidden
1560
+ high
1561
+ hill
1562
+ hint
1563
+ hip
1564
+ hire
1565
+ history
1566
+ hobby
1567
+ hockey
1568
+ hold
1569
+ hole
1570
+ holiday
1571
+ hollow
1572
+ home
1573
+ honey
1574
+ hood
1575
+ hope
1576
+ horn
1577
+ horror
1578
+ horse
1579
+ hospital
1580
+ host
1581
+ hotel
1582
+ hour
1583
+ hover
1584
+ hub
1585
+ huge
1586
+ human
1587
+ humble
1588
+ humor
1589
+ hundred
1590
+ hungry
1591
+ hunt
1592
+ hurdle
1593
+ hurry
1594
+ hurt
1595
+ husband
1596
+ hybrid
1597
+ ice
1598
+ icon
1599
+ idea
1600
+ identify
1601
+ idle
1602
+ ignore
1603
+ ill
1604
+ illegal
1605
+ illness
1606
+ image
1607
+ imitate
1608
+ immense
1609
+ immune
1610
+ impact
1611
+ impose
1612
+ improve
1613
+ impulse
1614
+ inch
1615
+ include
1616
+ income
1617
+ increase
1618
+ index
1619
+ indicate
1620
+ indoor
1621
+ industry
1622
+ infant
1623
+ inflict
1624
+ inform
1625
+ inhale
1626
+ inherit
1627
+ initial
1628
+ inject
1629
+ injury
1630
+ inmate
1631
+ inner
1632
+ innocent
1633
+ input
1634
+ inquiry
1635
+ insane
1636
+ insect
1637
+ inside
1638
+ inspire
1639
+ install
1640
+ intact
1641
+ interest
1642
+ into
1643
+ invest
1644
+ invite
1645
+ involve
1646
+ iron
1647
+ island
1648
+ isolate
1649
+ issue
1650
+ item
1651
+ ivory
1652
+ jacket
1653
+ jaguar
1654
+ jar
1655
+ jazz
1656
+ jealous
1657
+ jeans
1658
+ jelly
1659
+ jewel
1660
+ job
1661
+ join
1662
+ joke
1663
+ journey
1664
+ joy
1665
+ judge
1666
+ juice
1667
+ jump
1668
+ jungle
1669
+ junior
1670
+ junk
1671
+ just
1672
+ kangaroo
1673
+ keen
1674
+ keep
1675
+ ketchup
1676
+ key
1677
+ kick
1678
+ kid
1679
+ kidney
1680
+ kind
1681
+ kingdom
1682
+ kiss
1683
+ kit
1684
+ kitchen
1685
+ kite
1686
+ kitten
1687
+ kiwi
1688
+ knee
1689
+ knife
1690
+ knock
1691
+ know
1692
+ lab
1693
+ label
1694
+ labor
1695
+ ladder
1696
+ lady
1697
+ lake
1698
+ lamp
1699
+ language
1700
+ laptop
1701
+ large
1702
+ later
1703
+ latin
1704
+ laugh
1705
+ laundry
1706
+ lava
1707
+ law
1708
+ lawn
1709
+ lawsuit
1710
+ layer
1711
+ lazy
1712
+ leader
1713
+ leaf
1714
+ learn
1715
+ leave
1716
+ lecture
1717
+ left
1718
+ leg
1719
+ legal
1720
+ legend
1721
+ leisure
1722
+ lemon
1723
+ lend
1724
+ length
1725
+ lens
1726
+ leopard
1727
+ lesson
1728
+ letter
1729
+ level
1730
+ liar
1731
+ liberty
1732
+ library
1733
+ license
1734
+ life
1735
+ lift
1736
+ light
1737
+ like
1738
+ limb
1739
+ limit
1740
+ link
1741
+ lion
1742
+ liquid
1743
+ list
1744
+ little
1745
+ live
1746
+ lizard
1747
+ load
1748
+ loan
1749
+ lobster
1750
+ local
1751
+ lock
1752
+ logic
1753
+ lonely
1754
+ long
1755
+ loop
1756
+ lottery
1757
+ loud
1758
+ lounge
1759
+ love
1760
+ loyal
1761
+ lucky
1762
+ luggage
1763
+ lumber
1764
+ lunar
1765
+ lunch
1766
+ luxury
1767
+ lyrics
1768
+ machine
1769
+ mad
1770
+ magic
1771
+ magnet
1772
+ maid
1773
+ mail
1774
+ main
1775
+ major
1776
+ make
1777
+ mammal
1778
+ man
1779
+ manage
1780
+ mandate
1781
+ mango
1782
+ mansion
1783
+ manual
1784
+ maple
1785
+ marble
1786
+ march
1787
+ margin
1788
+ marine
1789
+ market
1790
+ marriage
1791
+ mask
1792
+ mass
1793
+ master
1794
+ match
1795
+ material
1796
+ math
1797
+ matrix
1798
+ matter
1799
+ maximum
1800
+ maze
1801
+ meadow
1802
+ mean
1803
+ measure
1804
+ meat
1805
+ mechanic
1806
+ medal
1807
+ media
1808
+ melody
1809
+ melt
1810
+ member
1811
+ memory
1812
+ mention
1813
+ menu
1814
+ mercy
1815
+ merge
1816
+ merit
1817
+ merry
1818
+ mesh
1819
+ message
1820
+ metal
1821
+ method
1822
+ middle
1823
+ midnight
1824
+ milk
1825
+ million
1826
+ mimic
1827
+ mind
1828
+ minimum
1829
+ minor
1830
+ minute
1831
+ miracle
1832
+ mirror
1833
+ misery
1834
+ miss
1835
+ mistake
1836
+ mix
1837
+ mixed
1838
+ mixture
1839
+ mobile
1840
+ model
1841
+ modify
1842
+ mom
1843
+ moment
1844
+ monitor
1845
+ monkey
1846
+ monster
1847
+ month
1848
+ moon
1849
+ moral
1850
+ more
1851
+ morning
1852
+ mosquito
1853
+ mother
1854
+ motion
1855
+ motor
1856
+ mountain
1857
+ mouse
1858
+ move
1859
+ movie
1860
+ much
1861
+ muffin
1862
+ mule
1863
+ multiply
1864
+ muscle
1865
+ museum
1866
+ mushroom
1867
+ music
1868
+ must
1869
+ mutual
1870
+ myself
1871
+ mystery
1872
+ myth
1873
+ naive
1874
+ name
1875
+ napkin
1876
+ narrow
1877
+ nasty
1878
+ nation
1879
+ nature
1880
+ near
1881
+ neck
1882
+ need
1883
+ negative
1884
+ neglect
1885
+ neither
1886
+ nephew
1887
+ nerve
1888
+ nest
1889
+ net
1890
+ network
1891
+ neutral
1892
+ never
1893
+ news
1894
+ next
1895
+ nice
1896
+ night
1897
+ noble
1898
+ noise
1899
+ nominee
1900
+ noodle
1901
+ normal
1902
+ north
1903
+ nose
1904
+ notable
1905
+ note
1906
+ nothing
1907
+ notice
1908
+ novel
1909
+ now
1910
+ nuclear
1911
+ number
1912
+ nurse
1913
+ nut
1914
+ oak
1915
+ obey
1916
+ object
1917
+ oblige
1918
+ obscure
1919
+ observe
1920
+ obtain
1921
+ obvious
1922
+ occur
1923
+ ocean
1924
+ october
1925
+ odor
1926
+ off
1927
+ offer
1928
+ office
1929
+ often
1930
+ oil
1931
+ okay
1932
+ old
1933
+ olive
1934
+ olympic
1935
+ omit
1936
+ once
1937
+ one
1938
+ onion
1939
+ online
1940
+ only
1941
+ open
1942
+ opera
1943
+ opinion
1944
+ oppose
1945
+ option
1946
+ orange
1947
+ orbit
1948
+ orchard
1949
+ order
1950
+ ordinary
1951
+ organ
1952
+ orient
1953
+ original
1954
+ orphan
1955
+ ostrich
1956
+ other
1957
+ outdoor
1958
+ outer
1959
+ output
1960
+ outside
1961
+ oval
1962
+ oven
1963
+ over
1964
+ own
1965
+ owner
1966
+ oxygen
1967
+ oyster
1968
+ ozone
1969
+ pact
1970
+ paddle
1971
+ page
1972
+ pair
1973
+ palace
1974
+ palm
1975
+ panda
1976
+ panel
1977
+ panic
1978
+ panther
1979
+ paper
1980
+ parade
1981
+ parent
1982
+ park
1983
+ parrot
1984
+ party
1985
+ pass
1986
+ patch
1987
+ path
1988
+ patient
1989
+ patrol
1990
+ pattern
1991
+ pause
1992
+ pave
1993
+ payment
1994
+ peace
1995
+ peanut
1996
+ pear
1997
+ peasant
1998
+ pelican
1999
+ pen
2000
+ penalty
2001
+ pencil
2002
+ people
2003
+ pepper
2004
+ perfect
2005
+ permit
2006
+ person
2007
+ pet
2008
+ phone
2009
+ photo
2010
+ phrase
2011
+ physical
2012
+ piano
2013
+ picnic
2014
+ picture
2015
+ piece
2016
+ pig
2017
+ pigeon
2018
+ pill
2019
+ pilot
2020
+ pink
2021
+ pioneer
2022
+ pipe
2023
+ pistol
2024
+ pitch
2025
+ pizza
2026
+ place
2027
+ planet
2028
+ plastic
2029
+ plate
2030
+ play
2031
+ please
2032
+ pledge
2033
+ pluck
2034
+ plug
2035
+ plunge
2036
+ poem
2037
+ poet
2038
+ point
2039
+ polar
2040
+ pole
2041
+ police
2042
+ pond
2043
+ pony
2044
+ pool
2045
+ popular
2046
+ portion
2047
+ position
2048
+ possible
2049
+ post
2050
+ potato
2051
+ pottery
2052
+ poverty
2053
+ powder
2054
+ power
2055
+ practice
2056
+ praise
2057
+ predict
2058
+ prefer
2059
+ prepare
2060
+ present
2061
+ pretty
2062
+ prevent
2063
+ price
2064
+ pride
2065
+ primary
2066
+ print
2067
+ priority
2068
+ prison
2069
+ private
2070
+ prize
2071
+ problem
2072
+ process
2073
+ produce
2074
+ profit
2075
+ program
2076
+ project
2077
+ promote
2078
+ proof
2079
+ property
2080
+ prosper
2081
+ protect
2082
+ proud
2083
+ provide
2084
+ public
2085
+ pudding
2086
+ pull
2087
+ pulp
2088
+ pulse
2089
+ pumpkin
2090
+ punch
2091
+ pupil
2092
+ puppy
2093
+ purchase
2094
+ purity
2095
+ purpose
2096
+ purse
2097
+ push
2098
+ put
2099
+ puzzle
2100
+ pyramid
2101
+ quality
2102
+ quantum
2103
+ quarter
2104
+ question
2105
+ quick
2106
+ quit
2107
+ quiz
2108
+ quote
2109
+ rabbit
2110
+ raccoon
2111
+ race
2112
+ rack
2113
+ radar
2114
+ radio
2115
+ rail
2116
+ rain
2117
+ raise
2118
+ rally
2119
+ ramp
2120
+ ranch
2121
+ random
2122
+ range
2123
+ rapid
2124
+ rare
2125
+ rate
2126
+ rather
2127
+ raven
2128
+ raw
2129
+ razor
2130
+ ready
2131
+ real
2132
+ reason
2133
+ rebel
2134
+ rebuild
2135
+ recall
2136
+ receive
2137
+ recipe
2138
+ record
2139
+ recycle
2140
+ reduce
2141
+ reflect
2142
+ reform
2143
+ refuse
2144
+ region
2145
+ regret
2146
+ regular
2147
+ reject
2148
+ relax
2149
+ release
2150
+ relief
2151
+ rely
2152
+ remain
2153
+ remember
2154
+ remind
2155
+ remove
2156
+ render
2157
+ renew
2158
+ rent
2159
+ reopen
2160
+ repair
2161
+ repeat
2162
+ replace
2163
+ report
2164
+ require
2165
+ rescue
2166
+ resemble
2167
+ resist
2168
+ resource
2169
+ response
2170
+ result
2171
+ retire
2172
+ retreat
2173
+ return
2174
+ reunion
2175
+ reveal
2176
+ review
2177
+ reward
2178
+ rhythm
2179
+ rib
2180
+ ribbon
2181
+ rice
2182
+ rich
2183
+ ride
2184
+ ridge
2185
+ rifle
2186
+ right
2187
+ rigid
2188
+ ring
2189
+ riot
2190
+ ripple
2191
+ risk
2192
+ ritual
2193
+ rival
2194
+ river
2195
+ road
2196
+ roast
2197
+ robot
2198
+ robust
2199
+ rocket
2200
+ romance
2201
+ roof
2202
+ rookie
2203
+ room
2204
+ rose
2205
+ rotate
2206
+ rough
2207
+ round
2208
+ route
2209
+ royal
2210
+ rubber
2211
+ rude
2212
+ rug
2213
+ rule
2214
+ run
2215
+ runway
2216
+ rural
2217
+ sad
2218
+ saddle
2219
+ sadness
2220
+ safe
2221
+ sail
2222
+ salad
2223
+ salmon
2224
+ salon
2225
+ salt
2226
+ salute
2227
+ same
2228
+ sample
2229
+ sand
2230
+ satisfy
2231
+ satoshi
2232
+ sauce
2233
+ sausage
2234
+ save
2235
+ say
2236
+ scale
2237
+ scan
2238
+ scare
2239
+ scatter
2240
+ scene
2241
+ scheme
2242
+ school
2243
+ science
2244
+ scissors
2245
+ scorpion
2246
+ scout
2247
+ scrap
2248
+ screen
2249
+ script
2250
+ scrub
2251
+ sea
2252
+ search
2253
+ season
2254
+ seat
2255
+ second
2256
+ secret
2257
+ section
2258
+ security
2259
+ seed
2260
+ seek
2261
+ segment
2262
+ select
2263
+ sell
2264
+ seminar
2265
+ senior
2266
+ sense
2267
+ sentence
2268
+ series
2269
+ service
2270
+ session
2271
+ settle
2272
+ setup
2273
+ seven
2274
+ shadow
2275
+ shaft
2276
+ shallow
2277
+ share
2278
+ shed
2279
+ shell
2280
+ sheriff
2281
+ shield
2282
+ shift
2283
+ shine
2284
+ ship
2285
+ shiver
2286
+ shock
2287
+ shoe
2288
+ shoot
2289
+ shop
2290
+ short
2291
+ shoulder
2292
+ shove
2293
+ shrimp
2294
+ shrug
2295
+ shuffle
2296
+ shy
2297
+ sibling
2298
+ sick
2299
+ side
2300
+ siege
2301
+ sight
2302
+ sign
2303
+ silent
2304
+ silk
2305
+ silly
2306
+ silver
2307
+ similar
2308
+ simple
2309
+ since
2310
+ sing
2311
+ siren
2312
+ sister
2313
+ situate
2314
+ six
2315
+ size
2316
+ skate
2317
+ sketch
2318
+ ski
2319
+ skill
2320
+ skin
2321
+ skirt
2322
+ skull
2323
+ slab
2324
+ slam
2325
+ sleep
2326
+ slender
2327
+ slice
2328
+ slide
2329
+ slight
2330
+ slim
2331
+ slogan
2332
+ slot
2333
+ slow
2334
+ slush
2335
+ small
2336
+ smart
2337
+ smile
2338
+ smoke
2339
+ smooth
2340
+ snack
2341
+ snake
2342
+ snap
2343
+ sniff
2344
+ snow
2345
+ soap
2346
+ soccer
2347
+ social
2348
+ sock
2349
+ soda
2350
+ soft
2351
+ solar
2352
+ soldier
2353
+ solid
2354
+ solution
2355
+ solve
2356
+ someone
2357
+ song
2358
+ soon
2359
+ sorry
2360
+ sort
2361
+ soul
2362
+ sound
2363
+ soup
2364
+ source
2365
+ south
2366
+ space
2367
+ spare
2368
+ spatial
2369
+ spawn
2370
+ speak
2371
+ special
2372
+ speed
2373
+ spell
2374
+ spend
2375
+ sphere
2376
+ spice
2377
+ spider
2378
+ spike
2379
+ spin
2380
+ spirit
2381
+ split
2382
+ spoil
2383
+ sponsor
2384
+ spoon
2385
+ sport
2386
+ spot
2387
+ spray
2388
+ spread
2389
+ spring
2390
+ spy
2391
+ square
2392
+ squeeze
2393
+ squirrel
2394
+ stable
2395
+ stadium
2396
+ staff
2397
+ stage
2398
+ stairs
2399
+ stamp
2400
+ stand
2401
+ start
2402
+ state
2403
+ stay
2404
+ steak
2405
+ steel
2406
+ stem
2407
+ step
2408
+ stereo
2409
+ stick
2410
+ still
2411
+ sting
2412
+ stock
2413
+ stomach
2414
+ stone
2415
+ stool
2416
+ story
2417
+ stove
2418
+ strategy
2419
+ street
2420
+ strike
2421
+ strong
2422
+ struggle
2423
+ student
2424
+ stuff
2425
+ stumble
2426
+ style
2427
+ subject
2428
+ submit
2429
+ subway
2430
+ success
2431
+ such
2432
+ sudden
2433
+ suffer
2434
+ sugar
2435
+ suggest
2436
+ suit
2437
+ summer
2438
+ sun
2439
+ sunny
2440
+ sunset
2441
+ super
2442
+ supply
2443
+ supreme
2444
+ sure
2445
+ surface
2446
+ surge
2447
+ surprise
2448
+ surround
2449
+ survey
2450
+ suspect
2451
+ sustain
2452
+ swallow
2453
+ swamp
2454
+ swap
2455
+ swarm
2456
+ swear
2457
+ sweet
2458
+ swift
2459
+ swim
2460
+ swing
2461
+ switch
2462
+ sword
2463
+ symbol
2464
+ symptom
2465
+ syrup
2466
+ system
2467
+ table
2468
+ tackle
2469
+ tag
2470
+ tail
2471
+ talent
2472
+ talk
2473
+ tank
2474
+ tape
2475
+ target
2476
+ task
2477
+ taste
2478
+ tattoo
2479
+ taxi
2480
+ teach
2481
+ team
2482
+ tell
2483
+ ten
2484
+ tenant
2485
+ tennis
2486
+ tent
2487
+ term
2488
+ test
2489
+ text
2490
+ thank
2491
+ that
2492
+ theme
2493
+ then
2494
+ theory
2495
+ there
2496
+ they
2497
+ thing
2498
+ this
2499
+ thought
2500
+ three
2501
+ thrive
2502
+ throw
2503
+ thumb
2504
+ thunder
2505
+ ticket
2506
+ tide
2507
+ tiger
2508
+ tilt
2509
+ timber
2510
+ time
2511
+ tiny
2512
+ tip
2513
+ tired
2514
+ tissue
2515
+ title
2516
+ toast
2517
+ tobacco
2518
+ today
2519
+ toddler
2520
+ toe
2521
+ together
2522
+ toilet
2523
+ token
2524
+ tomato
2525
+ tomorrow
2526
+ tone
2527
+ tongue
2528
+ tonight
2529
+ tool
2530
+ tooth
2531
+ top
2532
+ topic
2533
+ topple
2534
+ torch
2535
+ tornado
2536
+ tortoise
2537
+ toss
2538
+ total
2539
+ tourist
2540
+ toward
2541
+ tower
2542
+ town
2543
+ toy
2544
+ track
2545
+ trade
2546
+ traffic
2547
+ tragic
2548
+ train
2549
+ transfer
2550
+ trap
2551
+ trash
2552
+ travel
2553
+ tray
2554
+ treat
2555
+ tree
2556
+ trend
2557
+ trial
2558
+ tribe
2559
+ trick
2560
+ trigger
2561
+ trim
2562
+ trip
2563
+ trophy
2564
+ trouble
2565
+ truck
2566
+ true
2567
+ truly
2568
+ trumpet
2569
+ trust
2570
+ truth
2571
+ try
2572
+ tube
2573
+ tuition
2574
+ tumble
2575
+ tuna
2576
+ tunnel
2577
+ turkey
2578
+ turn
2579
+ turtle
2580
+ twelve
2581
+ twenty
2582
+ twice
2583
+ twin
2584
+ twist
2585
+ two
2586
+ type
2587
+ typical
2588
+ ugly
2589
+ umbrella
2590
+ unable
2591
+ unaware
2592
+ uncle
2593
+ uncover
2594
+ under
2595
+ undo
2596
+ unfair
2597
+ unfold
2598
+ unhappy
2599
+ uniform
2600
+ unique
2601
+ unit
2602
+ universe
2603
+ unknown
2604
+ unlock
2605
+ until
2606
+ unusual
2607
+ unveil
2608
+ update
2609
+ upgrade
2610
+ uphold
2611
+ upon
2612
+ upper
2613
+ upset
2614
+ urban
2615
+ urge
2616
+ usage
2617
+ use
2618
+ used
2619
+ useful
2620
+ useless
2621
+ usual
2622
+ utility
2623
+ vacant
2624
+ vacuum
2625
+ vague
2626
+ valid
2627
+ valley
2628
+ valve
2629
+ van
2630
+ vanish
2631
+ vapor
2632
+ various
2633
+ vast
2634
+ vault
2635
+ vehicle
2636
+ velvet
2637
+ vendor
2638
+ venture
2639
+ venue
2640
+ verb
2641
+ verify
2642
+ version
2643
+ very
2644
+ vessel
2645
+ veteran
2646
+ viable
2647
+ vibrant
2648
+ vicious
2649
+ victory
2650
+ video
2651
+ view
2652
+ village
2653
+ vintage
2654
+ violin
2655
+ virtual
2656
+ virus
2657
+ visa
2658
+ visit
2659
+ visual
2660
+ vital
2661
+ vivid
2662
+ vocal
2663
+ voice
2664
+ void
2665
+ volcano
2666
+ volume
2667
+ vote
2668
+ voyage
2669
+ wage
2670
+ wagon
2671
+ wait
2672
+ walk
2673
+ wall
2674
+ walnut
2675
+ want
2676
+ warfare
2677
+ warm
2678
+ warrior
2679
+ wash
2680
+ wasp
2681
+ waste
2682
+ water
2683
+ wave
2684
+ way
2685
+ wealth
2686
+ weapon
2687
+ wear
2688
+ weasel
2689
+ weather
2690
+ web
2691
+ wedding
2692
+ weekend
2693
+ weird
2694
+ welcome
2695
+ west
2696
+ wet
2697
+ whale
2698
+ what
2699
+ wheat
2700
+ wheel
2701
+ when
2702
+ where
2703
+ whip
2704
+ whisper
2705
+ wide
2706
+ width
2707
+ wife
2708
+ wild
2709
+ will
2710
+ win
2711
+ window
2712
+ wine
2713
+ wing
2714
+ wink
2715
+ winner
2716
+ winter
2717
+ wire
2718
+ wisdom
2719
+ wise
2720
+ wish
2721
+ witness
2722
+ wolf
2723
+ woman
2724
+ wonder
2725
+ wood
2726
+ wool
2727
+ word
2728
+ work
2729
+ world
2730
+ worry
2731
+ worth
2732
+ wrap
2733
+ wreck
2734
+ wrestle
2735
+ wrist
2736
+ write
2737
+ wrong
2738
+ yard
2739
+ year
2740
+ yellow
2741
+ you
2742
+ young
2743
+ youth
2744
+ zebra
2745
+ zero
2746
+ zone
2747
+ zoo`.split("\n");
2748
+
2749
+ // ../wallet-engine/src/errors.ts
2750
+ var WalletNotConnectedError = class extends Error {
2751
+ constructor(message = "No wallet connected. Call awarizon.wallet.create(), awarizon.wallet.importPrivateKey(), awarizon.wallet.importMnemonic(), or awarizon.connectWallet(walletClient).") {
2752
+ super(`[wallet-engine] ${message}`);
2753
+ this.code = "WALLET_NOT_CONNECTED";
2754
+ this.name = "WalletNotConnectedError";
2755
+ }
2756
+ };
2757
+ var InvalidMnemonicError = class extends Error {
2758
+ constructor(message = "The provided mnemonic phrase is invalid.") {
2759
+ super(`[wallet-engine] ${message}`);
2760
+ this.code = "INVALID_MNEMONIC";
2761
+ this.name = "InvalidMnemonicError";
2762
+ }
2763
+ };
2764
+ var InvalidPrivateKeyError = class extends Error {
2765
+ constructor(message = "The provided private key is invalid.") {
2766
+ super(`[wallet-engine] ${message}`);
2767
+ this.code = "INVALID_PRIVATE_KEY";
2768
+ this.name = "InvalidPrivateKeyError";
2769
+ }
2770
+ };
2771
+ var ChainSwitchError = class extends Error {
2772
+ constructor(message) {
2773
+ super(`[wallet-engine] ${message}`);
2774
+ this.code = "CHAIN_SWITCH_ERROR";
2775
+ this.name = "ChainSwitchError";
2776
+ }
2777
+ };
2778
+ var ChainMismatchError = class extends Error {
2779
+ constructor(walletChainId, expectedChainId) {
2780
+ super(
2781
+ `[wallet-engine] Chain mismatch: wallet is on chain ${walletChainId}, SDK is configured for chain ${expectedChainId}. Switch networks in your wallet or call awarizon.switchChain().`
2782
+ );
2783
+ this.code = "CHAIN_MISMATCH";
2784
+ this.name = "ChainMismatchError";
2785
+ this.walletChainId = walletChainId;
2786
+ this.expectedChainId = expectedChainId;
2787
+ }
2788
+ };
2789
+
2790
+ // ../wallet-engine/src/wallet.ts
2791
+ var ETH_PATH = (addressIndex) => `m/44'/60'/0'/0/${addressIndex}`;
2792
+ var WalletEngine = class {
2793
+ constructor(config) {
2794
+ this.internalClient = null;
2795
+ this.externalClient = null;
2796
+ this._connectorInfo = null;
2797
+ this._walletListeners = /* @__PURE__ */ new Set();
2798
+ this._chainListeners = /* @__PURE__ */ new Set();
2799
+ this.config = config;
2800
+ }
2801
+ // ─── Internal wallet creation ──────────────────────────────────────────────
2802
+ async create() {
2803
+ const mnemonic = generateMnemonic(wordlist, 128);
2804
+ const path = ETH_PATH(0);
2805
+ const account = accounts.mnemonicToAccount(mnemonic, { accountIndex: 0, addressIndex: 0 });
2806
+ this.internalClient = this._buildInternalClient(account);
2807
+ this._connectorInfo = { type: "internal" };
2808
+ this._emitWalletChange();
2809
+ return { address: account.address, mnemonic, derivationPath: path };
2810
+ }
2811
+ /**
2812
+ * Import a wallet from a BIP-39 mnemonic phrase.
2813
+ *
2814
+ * `addressIndex` maps to MetaMask's account switcher:
2815
+ * 0 → Account 1 (m/44'/60'/0'/0/0)
2816
+ * 1 → Account 2 (m/44'/60'/0'/0/1)
2817
+ * N → Account N+1
2818
+ */
2819
+ async importMnemonic(mnemonic, addressIndex = 0) {
2820
+ if (!mnemonic || typeof mnemonic !== "string") throw new InvalidMnemonicError();
2821
+ if (!validateMnemonic(mnemonic, wordlist)) {
2822
+ throw new InvalidMnemonicError(
2823
+ `Invalid BIP-39 mnemonic: ${mnemonic.split(" ").slice(0, 2).join(" ")}\u2026`
2824
+ );
2825
+ }
2826
+ let account;
2827
+ try {
2828
+ account = accounts.mnemonicToAccount(mnemonic, { accountIndex: 0, addressIndex });
2829
+ } catch {
2830
+ throw new InvalidMnemonicError(
2831
+ `Could not derive account from mnemonic: ${mnemonic.slice(0, 8)}\u2026`
2832
+ );
2833
+ }
2834
+ this.internalClient = this._buildInternalClient(account);
2835
+ this._connectorInfo = { type: "internal" };
2836
+ this._emitWalletChange();
2837
+ const path = ETH_PATH(addressIndex);
2838
+ return { address: account.address, mnemonic, derivationPath: path };
2839
+ }
2840
+ async importPrivateKey(privateKey) {
2841
+ if (!privateKey || !privateKey.startsWith("0x")) {
2842
+ throw new InvalidPrivateKeyError("Private key must be a 0x-prefixed hex string.");
2843
+ }
2844
+ let account;
2845
+ try {
2846
+ account = accounts.privateKeyToAccount(privateKey);
2847
+ } catch {
2848
+ throw new InvalidPrivateKeyError();
2849
+ }
2850
+ this.internalClient = this._buildInternalClient(account);
2851
+ this._connectorInfo = { type: "internal" };
2852
+ this._emitWalletChange();
2853
+ return { address: account.address };
2854
+ }
2855
+ // ─── External wallet integration ───────────────────────────────────────────
2856
+ /**
2857
+ * Connect any viem WalletClient (wagmi, RainbowKit, custom).
2858
+ * Optionally pass connector metadata to display in the UI.
2859
+ *
2860
+ * External wallets always take priority over internal wallets.
2861
+ */
2862
+ connectExternal(walletClient, info) {
2863
+ if (!walletClient || typeof walletClient !== "object") {
2864
+ throw new TypeError("[wallet-engine] connectExternal: expected a viem WalletClient");
2865
+ }
2866
+ this.externalClient = walletClient;
2867
+ this._connectorInfo = { type: "external", ...info };
2868
+ this._emitWalletChange();
2869
+ }
2870
+ /**
2871
+ * Connect directly from a raw EIP-1193 provider (window.ethereum, WalletConnect, etc.)
2872
+ * without needing wagmi or any wrapper. Calls eth_requestAccounts internally.
2873
+ *
2874
+ * @param provider - Any object implementing the EIP-1193 interface
2875
+ * @param info - Optional connector metadata (name, icon)
2876
+ */
2877
+ async connectEIP1193(provider, info) {
2878
+ const accounts = await provider.request({
2879
+ method: "eth_requestAccounts"
2880
+ });
2881
+ const account = accounts[0];
2882
+ if (!account) {
2883
+ throw new WalletNotConnectedError(
2884
+ "No accounts returned by EIP-1193 provider. The user may have rejected the connection request."
2885
+ );
2886
+ }
2887
+ const walletClient = viem.createWalletClient({
2888
+ account,
2889
+ chain: this.config.chain,
2890
+ transport: viem.custom(provider)
2891
+ });
2892
+ this.connectExternal(walletClient, info);
2893
+ provider.on?.("accountsChanged", (...args) => {
2894
+ const newAccounts = args[0];
2895
+ if (!newAccounts || newAccounts.length === 0) {
2896
+ this.disconnectExternal();
2897
+ return;
2898
+ }
2899
+ const updated = viem.createWalletClient({
2900
+ account: newAccounts[0],
2901
+ chain: this.config.chain,
2902
+ transport: viem.custom(provider)
2903
+ });
2904
+ this.connectExternal(updated, info);
2905
+ });
2906
+ provider.on?.("chainChanged", (..._args) => {
2907
+ this._emitChainChange();
2908
+ });
2909
+ provider.on?.("disconnect", (..._args) => {
2910
+ this.disconnectExternal();
2911
+ });
2912
+ }
2913
+ /** Remove the external wallet. Falls back to internal wallet if one is loaded. */
2914
+ disconnectExternal() {
2915
+ this.externalClient = null;
2916
+ this._connectorInfo = this.internalClient ? { type: "internal" } : null;
2917
+ this._emitWalletChange();
2918
+ }
2919
+ /** Remove all wallet state — both internal and external. */
2920
+ disconnect() {
2921
+ this.internalClient = null;
2922
+ this.externalClient = null;
2923
+ this._connectorInfo = null;
2924
+ this._emitWalletChange();
2925
+ }
2926
+ // ─── Chain management ──────────────────────────────────────────────────────
2927
+ async switchChain(chain2) {
2928
+ this.config.chain = chain2;
2929
+ this.config.publicClient = viem.createPublicClient({
2930
+ chain: chain2,
2931
+ transport: this._resolveTransport(chain2)
2932
+ });
2933
+ if (this.internalClient?.account) {
2934
+ this.internalClient = this._buildInternalClient(this.internalClient.account);
2935
+ }
2936
+ this._emitChainChange();
2937
+ }
2938
+ // ─── Signing ───────────────────────────────────────────────────────────────
2939
+ /**
2940
+ * Sign a plain text or raw-bytes message with the active wallet.
2941
+ * Supports Sign-In with Ethereum (SIWE) and off-chain auth flows.
2942
+ *
2943
+ * @param message - A UTF-8 string or `{ raw: Hex | Uint8Array }` for raw bytes
2944
+ */
2945
+ async signMessage(message) {
2946
+ const client = this.externalClient ?? this.internalClient;
2947
+ if (!client) throw new WalletNotConnectedError();
2948
+ const account = client.account;
2949
+ if (!account) {
2950
+ throw new WalletNotConnectedError(
2951
+ "No account set on wallet client. The wallet may need to be unlocked or reconnected."
2952
+ );
2953
+ }
2954
+ return client.signMessage({
2955
+ account,
2956
+ message
2957
+ });
2958
+ }
2959
+ /**
2960
+ * Sign EIP-712 typed structured data (permit2, SIWE, Seaport, etc.).
2961
+ *
2962
+ * @param params - domain, types, primaryType, and message fields per EIP-712
2963
+ */
2964
+ async signTypedData(params) {
2965
+ const client = this.externalClient ?? this.internalClient;
2966
+ if (!client) throw new WalletNotConnectedError();
2967
+ const account = client.account;
2968
+ if (!account) {
2969
+ throw new WalletNotConnectedError(
2970
+ "No account set on wallet client. The wallet may need to be unlocked or reconnected."
2971
+ );
2972
+ }
2973
+ return client.signTypedData({
2974
+ account,
2975
+ ...params
2976
+ });
2977
+ }
2978
+ // ─── Chain awareness ───────────────────────────────────────────────────────
2979
+ /**
2980
+ * Returns the chain ID the active wallet is currently on.
2981
+ * For external wallets this queries the wallet directly (may differ from SDK config).
2982
+ * For internal wallets this always returns the SDK-configured chain ID.
2983
+ */
2984
+ async getChainId() {
2985
+ if (this.externalClient) {
2986
+ try {
2987
+ return await this.externalClient.getChainId();
2988
+ } catch {
2989
+ return this.config.chain.id;
2990
+ }
2991
+ }
2992
+ return this.config.chain.id;
2993
+ }
2994
+ /**
2995
+ * Returns true if the external wallet is on a different chain than the SDK.
2996
+ * Always false for internal wallets (they follow the SDK chain automatically).
2997
+ */
2998
+ async isChainMismatch() {
2999
+ if (!this.externalClient) return false;
3000
+ const activeChainId = await this.getChainId();
3001
+ return activeChainId !== this.config.chain.id;
3002
+ }
3003
+ // ─── Event listeners ───────────────────────────────────────────────────────
3004
+ /**
3005
+ * Subscribe to wallet changes (connect, disconnect, account switch).
3006
+ * Returns an unsubscribe function — call it to stop listening.
3007
+ *
3008
+ * @example
3009
+ * const unsub = engine.onWalletChange(({ address, type }) => {
3010
+ * console.log('wallet changed:', address, type)
3011
+ * })
3012
+ * unsub() // stop listening
3013
+ */
3014
+ onWalletChange(cb) {
3015
+ this._walletListeners.add(cb);
3016
+ return () => this._walletListeners.delete(cb);
3017
+ }
3018
+ /**
3019
+ * Subscribe to chain changes (switchChain calls).
3020
+ * Returns an unsubscribe function — call it to stop listening.
3021
+ */
3022
+ onChainChange(cb) {
3023
+ this._chainListeners.add(cb);
3024
+ return () => this._chainListeners.delete(cb);
3025
+ }
3026
+ // ─── Accessors ─────────────────────────────────────────────────────────────
3027
+ getWalletClient() {
3028
+ const client = this.externalClient ?? this.internalClient;
3029
+ if (!client) throw new WalletNotConnectedError();
3030
+ return client;
3031
+ }
3032
+ getSigner() {
3033
+ return this.getWalletClient();
3034
+ }
3035
+ address() {
3036
+ const client = this.externalClient ?? this.internalClient;
3037
+ const addr = client?.account?.address;
3038
+ if (!addr) throw new WalletNotConnectedError();
3039
+ return addr;
3040
+ }
3041
+ getChain() {
3042
+ return this.config.chain;
3043
+ }
3044
+ getPublicClient() {
3045
+ return this.config.publicClient;
3046
+ }
3047
+ isConnected() {
3048
+ return !!(this.externalClient ?? this.internalClient);
3049
+ }
3050
+ hasExternalWallet() {
3051
+ return this.externalClient !== null;
3052
+ }
3053
+ hasInternalWallet() {
3054
+ return this.internalClient !== null;
3055
+ }
3056
+ /**
3057
+ * Returns metadata about the currently active connector.
3058
+ * Useful for displaying "Connected via MetaMask" in the UI.
3059
+ */
3060
+ getConnectorInfo() {
3061
+ if (this._connectorInfo) return this._connectorInfo;
3062
+ if (this.externalClient) return { type: "external" };
3063
+ if (this.internalClient) return { type: "internal" };
3064
+ return { type: "none" };
3065
+ }
3066
+ // ─── Private helpers ───────────────────────────────────────────────────────
3067
+ _resolveTransport(chain2) {
3068
+ return this.config.getTransport ? this.config.getTransport(chain2) : viem.http(this.config.rpcUrl);
3069
+ }
3070
+ _buildInternalClient(account) {
3071
+ return viem.createWalletClient({
3072
+ account,
3073
+ chain: this.config.chain,
3074
+ transport: this._resolveTransport(this.config.chain)
3075
+ });
3076
+ }
3077
+ _emitWalletChange() {
3078
+ let addr = null;
3079
+ try {
3080
+ addr = this.address();
3081
+ } catch {
3082
+ }
3083
+ const event = {
3084
+ address: addr,
3085
+ type: this.externalClient ? "external" : this.internalClient ? "internal" : "none",
3086
+ name: this._connectorInfo?.name
3087
+ };
3088
+ this._walletListeners.forEach((cb) => {
3089
+ try {
3090
+ cb(event);
3091
+ } catch {
3092
+ }
3093
+ });
3094
+ }
3095
+ _emitChainChange() {
3096
+ const event = {
3097
+ chainId: this.config.chain.id,
3098
+ chain: this.config.chain
3099
+ };
3100
+ this._chainListeners.forEach((cb) => {
3101
+ try {
3102
+ cb(event);
3103
+ } catch {
3104
+ }
3105
+ });
3106
+ }
3107
+ };
3108
+
3109
+ // ../tx-engine/src/errors.ts
3110
+ var ContractExecutionError = class extends Error {
3111
+ constructor(message, options) {
3112
+ super(`[tx-engine] ${message}`);
3113
+ this.code = "CONTRACT_EXECUTION_ERROR";
3114
+ this.name = "ContractExecutionError";
3115
+ this.functionName = options?.functionName;
3116
+ this.cause = options?.cause;
3117
+ }
3118
+ };
3119
+ var SimulationError = class extends Error {
3120
+ constructor(message, options) {
3121
+ super(`[tx-engine] Simulation failed: ${message}`);
3122
+ this.code = "SIMULATION_ERROR";
3123
+ this.name = "SimulationError";
3124
+ this.functionName = options?.functionName;
3125
+ this.cause = options?.cause;
3126
+ }
3127
+ };
3128
+ var GasEstimationError = class extends Error {
3129
+ constructor(message, cause) {
3130
+ super(`[tx-engine] Gas estimation failed: ${message}`);
3131
+ this.code = "GAS_ESTIMATION_ERROR";
3132
+ this.name = "GasEstimationError";
3133
+ this.cause = cause;
3134
+ }
3135
+ };
3136
+ var TransactionTimeoutError = class extends Error {
3137
+ constructor(hash) {
3138
+ super(`[tx-engine] Transaction confirmation timed out${hash ? ` (hash: ${hash})` : ""}`);
3139
+ this.code = "TRANSACTION_TIMEOUT";
3140
+ this.name = "TransactionTimeoutError";
3141
+ this.hash = hash;
3142
+ }
3143
+ };
3144
+
3145
+ // ../tx-engine/src/transaction.ts
3146
+ function extractRevertReason(error) {
3147
+ if (!error || typeof error !== "object") return String(error);
3148
+ const e = error;
3149
+ if (typeof e["reason"] === "string" && e["reason"]) return e["reason"];
3150
+ if (e["data"] && typeof e["data"] === "object") {
3151
+ const data = e["data"];
3152
+ if (typeof data["errorName"] === "string" && data["errorName"]) {
3153
+ const args = Array.isArray(data["args"]) && data["args"].length ? `(${data["args"].join(", ")})` : "";
3154
+ return `${data["errorName"]}${args}`;
3155
+ }
3156
+ }
3157
+ if (typeof e["shortMessage"] === "string" && e["shortMessage"]) return e["shortMessage"];
3158
+ if (e["cause"]) return extractRevertReason(e["cause"]);
3159
+ return error.message ?? String(error);
3160
+ }
3161
+ var TransactionEngine = class {
3162
+ constructor(publicClient, getWalletClient) {
3163
+ this.publicClient = publicClient;
3164
+ this.getWalletClient = getWalletClient;
3165
+ }
3166
+ // ─── Read ─────────────────────────────────────────────────────────────────
3167
+ /**
3168
+ * Execute a read-only contract call (view / pure functions).
3169
+ * Returns the decoded output — single values or tuples.
3170
+ */
3171
+ async read(params) {
3172
+ try {
3173
+ return await this.publicClient.readContract({
3174
+ address: params.address,
3175
+ abi: params.abi,
3176
+ functionName: params.functionName,
3177
+ args: params.args
3178
+ });
3179
+ } catch (error) {
3180
+ throw new ContractExecutionError(
3181
+ `read(${params.functionName}) failed: ${extractRevertReason(error)}`,
3182
+ { functionName: params.functionName, cause: error }
3183
+ );
3184
+ }
3185
+ }
3186
+ // ─── Write ────────────────────────────────────────────────────────────────
3187
+ /**
3188
+ * Execute a state-mutating contract call:
3189
+ * 1. Simulate the transaction (surfaces revert reasons before spending gas)
3190
+ * 2. Broadcast the signed transaction
3191
+ * 3. Wait for on-chain confirmation
3192
+ *
3193
+ * @returns { hash, receipt } — the tx hash and on-chain receipt
3194
+ */
3195
+ async write(params) {
3196
+ const walletClient = this.getWalletClient();
3197
+ const account = walletClient.account;
3198
+ if (!account) {
3199
+ throw new ContractExecutionError(
3200
+ `write(${params.functionName}): wallet client has no account attached`,
3201
+ { functionName: params.functionName }
3202
+ );
3203
+ }
3204
+ let request;
3205
+ try {
3206
+ const simulation = await this.publicClient.simulateContract({
3207
+ address: params.address,
3208
+ abi: params.abi,
3209
+ functionName: params.functionName,
3210
+ args: params.args,
3211
+ account,
3212
+ value: params.value,
3213
+ gas: params.gas
3214
+ });
3215
+ request = simulation.request;
3216
+ } catch (error) {
3217
+ throw new SimulationError(
3218
+ `${params.functionName}: ${extractRevertReason(error)}`,
3219
+ { functionName: params.functionName, cause: error }
3220
+ );
3221
+ }
3222
+ let hash;
3223
+ try {
3224
+ hash = await walletClient.writeContract(request);
3225
+ } catch (error) {
3226
+ throw new ContractExecutionError(
3227
+ `write(${params.functionName}) broadcast failed: ${error.message}`,
3228
+ { functionName: params.functionName, cause: error }
3229
+ );
3230
+ }
3231
+ let receipt;
3232
+ try {
3233
+ receipt = await this.publicClient.waitForTransactionReceipt({ hash });
3234
+ } catch (error) {
3235
+ throw new ContractExecutionError(
3236
+ `write(${params.functionName}) receipt wait failed: ${error.message}`,
3237
+ { functionName: params.functionName, cause: error }
3238
+ );
3239
+ }
3240
+ return { hash, receipt };
3241
+ }
3242
+ // ─── Gas estimation ───────────────────────────────────────────────────────
3243
+ /**
3244
+ * Estimate gas for a write transaction.
3245
+ * Useful for displaying fee previews before the user confirms.
3246
+ */
3247
+ async estimateGas(params) {
3248
+ const walletClient = this.getWalletClient();
3249
+ const account = walletClient.account;
3250
+ if (!account) {
3251
+ throw new GasEstimationError("Wallet client has no account attached");
3252
+ }
3253
+ try {
3254
+ const gas = await this.publicClient.estimateContractGas({
3255
+ address: params.address,
3256
+ abi: params.abi,
3257
+ functionName: params.functionName,
3258
+ args: params.args,
3259
+ account,
3260
+ value: params.value
3261
+ });
3262
+ let gasCost;
3263
+ try {
3264
+ const gasPrice = await this.publicClient.getGasPrice();
3265
+ gasCost = gas * gasPrice;
3266
+ } catch {
3267
+ }
3268
+ return { gas, gasCost };
3269
+ } catch (error) {
3270
+ throw new GasEstimationError(extractRevertReason(error), error);
3271
+ }
3272
+ }
3273
+ };
10
3274
  var CHAINS = {
11
3275
  // Mainnet
12
3276
  mainnet: chains.mainnet,
@@ -58,21 +3322,21 @@ var CHAINS = {
58
3322
  moonbeam: chains.moonbeam
59
3323
  };
60
3324
  var _chainAliases = Object.keys(CHAINS).sort().join(", ");
61
- function resolveChain(chain) {
62
- if (typeof chain === "object" && "id" in chain) {
63
- return chain;
3325
+ function resolveChain(chain2) {
3326
+ if (typeof chain2 === "object" && "id" in chain2) {
3327
+ return chain2;
64
3328
  }
65
- if (typeof chain === "string") {
66
- const resolved = CHAINS[chain.toLowerCase()] ?? CHAINS[chain];
3329
+ if (typeof chain2 === "string") {
3330
+ const resolved = CHAINS[chain2.toLowerCase()] ?? CHAINS[chain2];
67
3331
  if (!resolved) {
68
3332
  throw new Error(
69
- `[awarizon/web3] Unsupported chain: "${chain}".
3333
+ `[awarizon/web3] Unsupported chain: "${chain2}".
70
3334
  Available chains: ${_chainAliases}`
71
3335
  );
72
3336
  }
73
3337
  return resolved;
74
3338
  }
75
- throw new TypeError(`[awarizon/web3] chain must be a string or Chain object, got: ${typeof chain}`);
3339
+ throw new TypeError(`[awarizon/web3] chain must be a string or Chain object, got: ${typeof chain2}`);
76
3340
  }
77
3341
  function getSupportedChainIds() {
78
3342
  const seen = /* @__PURE__ */ new Set();
@@ -94,67 +3358,179 @@ var FALLBACK_RPCS = {
94
3358
  1284: "https://moonbeam.drpc.org"
95
3359
  // moonbeam
96
3360
  };
97
- function getChainTransport(chain, rpcUrlOverride) {
3361
+ function getChainTransport(chain2, rpcUrlOverride) {
98
3362
  if (rpcUrlOverride) return viem.http(rpcUrlOverride);
99
- const fallbackUrl = FALLBACK_RPCS[chain.id];
3363
+ const fallbackUrl = FALLBACK_RPCS[chain2.id];
100
3364
  if (fallbackUrl) {
101
- const primaryUrl = chain.rpcUrls.default.http[0];
3365
+ const primaryUrl = chain2.rpcUrls.default.http[0];
102
3366
  return viem.fallback([viem.http(primaryUrl), viem.http(fallbackUrl)]);
103
3367
  }
104
3368
  return viem.http();
105
3369
  }
106
- function trackEvent(telemetry, type, chain, functionName, success, start) {
3370
+
3371
+ // ../abi-engine/src/errors.ts
3372
+ var InvalidABIError = class extends Error {
3373
+ constructor(message) {
3374
+ super(`[abi-engine] ${message}`);
3375
+ this.code = "INVALID_ABI";
3376
+ this.name = "InvalidABIError";
3377
+ }
3378
+ };
3379
+ var UnsupportedABIItemError = class extends Error {
3380
+ constructor(itemType) {
3381
+ super(`[abi-engine] Unsupported ABI item type: "${itemType}"`);
3382
+ this.code = "UNSUPPORTED_ABI_ITEM";
3383
+ this.name = "UnsupportedABIItemError";
3384
+ this.itemType = itemType;
3385
+ }
3386
+ };
3387
+ var DuplicateFunctionError = class extends Error {
3388
+ constructor(name) {
3389
+ super(`[abi-engine] Duplicate function name detected: "${name}". Function overloads are not yet supported.`);
3390
+ this.code = "DUPLICATE_FUNCTION";
3391
+ this.name = "DuplicateFunctionError";
3392
+ this.functionName = name;
3393
+ }
3394
+ };
3395
+
3396
+ // ../abi-engine/src/parser.ts
3397
+ var _parseCache = /* @__PURE__ */ new WeakMap();
3398
+ function parseABI(abi) {
3399
+ const hit = _parseCache.get(abi);
3400
+ if (hit) return hit;
3401
+ if (!Array.isArray(abi) || abi.length === 0) {
3402
+ throw new InvalidABIError("ABI must be a non-empty array");
3403
+ }
3404
+ const readFunctions = [];
3405
+ const writeFunctions = [];
3406
+ const payableFunctions = [];
3407
+ const events = [];
3408
+ let constructor;
3409
+ for (const item of abi) {
3410
+ if (!item || typeof item !== "object" || !("type" in item)) {
3411
+ throw new InvalidABIError(`Invalid ABI item: ${JSON.stringify(item)}`);
3412
+ }
3413
+ switch (item.type) {
3414
+ case "function": {
3415
+ const fn = item;
3416
+ const sm = fn.stateMutability;
3417
+ if (sm === "view" || sm === "pure") {
3418
+ readFunctions.push(fn);
3419
+ } else if (sm === "payable") {
3420
+ payableFunctions.push(fn);
3421
+ writeFunctions.push(fn);
3422
+ } else {
3423
+ writeFunctions.push(fn);
3424
+ }
3425
+ break;
3426
+ }
3427
+ case "event":
3428
+ events.push(item);
3429
+ break;
3430
+ case "constructor":
3431
+ constructor = item;
3432
+ break;
3433
+ }
3434
+ }
3435
+ const result = { readFunctions, writeFunctions, payableFunctions, events, constructor };
3436
+ _parseCache.set(abi, result);
3437
+ return result;
3438
+ }
3439
+ function isWriteFunction(fn) {
3440
+ return fn.stateMutability !== "view" && fn.stateMutability !== "pure";
3441
+ }
3442
+ function isPayableFunction(fn) {
3443
+ return fn.stateMutability === "payable";
3444
+ }
3445
+ function solidityTypeToTS(abiType) {
3446
+ if (abiType.endsWith("[]")) return `${solidityTypeToTS(abiType.slice(0, -2))}[]`;
3447
+ if (abiType.startsWith("uint") || abiType.startsWith("int")) return "bigint";
3448
+ if (abiType === "address") return "`0x${string}`";
3449
+ if (abiType === "bool") return "boolean";
3450
+ if (abiType.startsWith("bytes")) return "`0x${string}`";
3451
+ if (abiType === "string") return "string";
3452
+ if (abiType === "tuple") return "Record<string, unknown>";
3453
+ return "unknown";
3454
+ }
3455
+ function generateMethodSignature(fn) {
3456
+ const sm = fn.stateMutability;
3457
+ const kind = sm === "view" || sm === "pure" ? "read" : sm === "payable" ? "payable" : "write";
3458
+ const params = (fn.inputs ?? []).map((p, i) => ({
3459
+ name: p.name || `arg${i}`,
3460
+ type: solidityTypeToTS(p.type)
3461
+ }));
3462
+ const paramStr = params.map((p) => `${p.name}: ${p.type}`).join(", ");
3463
+ let returnType;
3464
+ const outputs = fn.outputs ?? [];
3465
+ if (outputs.length === 0) {
3466
+ returnType = kind === "read" ? "void" : "TransactionResult";
3467
+ } else if (outputs.length === 1) {
3468
+ returnType = solidityTypeToTS(outputs[0].type);
3469
+ } else {
3470
+ returnType = `[${outputs.map((o) => solidityTypeToTS(o.type)).join(", ")}]`;
3471
+ }
3472
+ const asyncReturn = kind === "read" ? `Promise<${returnType}>` : "Promise<TransactionResult>";
3473
+ const signature = `${fn.name}(${paramStr}): ${asyncReturn}`;
3474
+ return { name: fn.name, kind, signature, params };
3475
+ }
3476
+ function generateAllMethodSignatures(parsed) {
3477
+ const all = [...parsed.readFunctions, ...parsed.writeFunctions];
3478
+ return all.map(generateMethodSignature);
3479
+ }
3480
+
3481
+ // src/contract.ts
3482
+ function trackEvent(telemetry, type, chain2, functionName, success, start) {
107
3483
  telemetry?.track({
108
3484
  type,
109
- chain: chain?.name ?? "unknown",
110
- chainId: chain?.id ?? 0,
3485
+ chain: chain2?.name ?? "unknown",
3486
+ chainId: chain2?.id ?? 0,
111
3487
  functionName,
112
3488
  success,
113
3489
  durationMs: Date.now() - start,
114
3490
  ts: Date.now()
115
3491
  });
116
3492
  }
117
- function buildContractInstance(address, abi, publicClient, txEngine, telemetry, chain) {
118
- const parsed = abiEngine.parseABI(abi);
3493
+ function buildContractInstance(address, abi, publicClient, txEngine, telemetry, chain2) {
3494
+ const parsed = parseABI(abi);
119
3495
  const eventsMap = new Map(parsed.events.map((e) => [e.name, e]));
120
3496
  const instance = {
121
3497
  _address: address,
122
3498
  _abi: abi
123
3499
  };
124
3500
  for (const fn of parsed.readFunctions) {
125
- instance[fn.name] = buildReadMethod(fn, address, abi, txEngine, telemetry, chain);
3501
+ instance[fn.name] = buildReadMethod(fn, address, abi, txEngine, telemetry, chain2);
126
3502
  }
127
3503
  for (const fn of parsed.writeFunctions) {
128
- instance[fn.name] = buildWriteMethod(fn, address, abi, txEngine, telemetry, chain);
3504
+ instance[fn.name] = buildWriteMethod(fn, address, abi, txEngine, telemetry, chain2);
129
3505
  }
130
3506
  instance["on"] = buildEventSubscription(address, abi, eventsMap, publicClient);
131
3507
  instance["estimateGas"] = async (method, ...args) => {
132
3508
  const start = Date.now();
133
3509
  try {
134
3510
  const estimate = await txEngine.estimateGas({ address, abi, functionName: method, args });
135
- trackEvent(telemetry, "contract.gas_estimate", chain, method, true, start);
3511
+ trackEvent(telemetry, "contract.gas_estimate", chain2, method, true, start);
136
3512
  return estimate.gas;
137
3513
  } catch (error) {
138
- trackEvent(telemetry, "contract.gas_estimate", chain, method, false, start);
3514
+ trackEvent(telemetry, "contract.gas_estimate", chain2, method, false, start);
139
3515
  throw error;
140
3516
  }
141
3517
  };
142
3518
  return instance;
143
3519
  }
144
- function buildReadMethod(fn, address, abi, txEngine, telemetry, chain) {
3520
+ function buildReadMethod(fn, address, abi, txEngine, telemetry, chain2) {
145
3521
  return async (...args) => {
146
3522
  const start = Date.now();
147
3523
  try {
148
3524
  const result = await txEngine.read({ address, abi, functionName: fn.name, args });
149
- trackEvent(telemetry, "contract.read", chain, fn.name, true, start);
3525
+ trackEvent(telemetry, "contract.read", chain2, fn.name, true, start);
150
3526
  return result;
151
3527
  } catch (error) {
152
- trackEvent(telemetry, "contract.read", chain, fn.name, false, start);
3528
+ trackEvent(telemetry, "contract.read", chain2, fn.name, false, start);
153
3529
  throw error;
154
3530
  }
155
3531
  };
156
3532
  }
157
- function buildWriteMethod(fn, address, abi, txEngine, telemetry, chain) {
3533
+ function buildWriteMethod(fn, address, abi, txEngine, telemetry, chain2) {
158
3534
  const isPayable = fn.stateMutability === "payable";
159
3535
  return async (...args) => {
160
3536
  let callArgs = args;
@@ -178,10 +3554,10 @@ function buildWriteMethod(fn, address, abi, txEngine, telemetry, chain) {
178
3554
  value,
179
3555
  gas
180
3556
  });
181
- trackEvent(telemetry, "contract.write", chain, fn.name, true, start);
3557
+ trackEvent(telemetry, "contract.write", chain2, fn.name, true, start);
182
3558
  return result;
183
3559
  } catch (error) {
184
- trackEvent(telemetry, "contract.write", chain, fn.name, false, start);
3560
+ trackEvent(telemetry, "contract.write", chain2, fn.name, false, start);
185
3561
  throw error;
186
3562
  }
187
3563
  };
@@ -240,11 +3616,11 @@ var ContractNotLoadedError = class extends Error {
240
3616
  }
241
3617
  };
242
3618
  var UnsupportedChainError = class extends Error {
243
- constructor(chain) {
244
- super(`[awarizon/web3] Unsupported chain: "${chain}". Pass a valid chain name or viem Chain object.`);
3619
+ constructor(chain2) {
3620
+ super(`[awarizon/web3] Unsupported chain: "${chain2}". Pass a valid chain name or viem Chain object.`);
245
3621
  this.code = "UNSUPPORTED_CHAIN";
246
3622
  this.name = "UnsupportedChainError";
247
- this.chain = chain;
3623
+ this.chain = chain2;
248
3624
  }
249
3625
  };
250
3626
  var ApiKeyRequiredError = class extends Error {
@@ -715,6 +4091,8 @@ var ERC1155_ABI = [
715
4091
  { type: "event", name: "TransferBatch", inputs: [{ indexed: true, name: "operator", type: "address" }, { indexed: true, name: "from", type: "address" }, { indexed: true, name: "to", type: "address" }, { name: "ids", type: "uint256[]" }, { name: "values", type: "uint256[]" }] },
716
4092
  { type: "event", name: "ApprovalForAll", inputs: [{ indexed: true, name: "account", type: "address" }, { indexed: true, name: "operator", type: "address" }, { name: "approved", type: "bool" }] }
717
4093
  ];
4094
+
4095
+ // src/sdk.ts
718
4096
  var WalletProxy = class {
719
4097
  constructor(engine, ensureReady) {
720
4098
  this.engine = engine;
@@ -764,8 +4142,8 @@ var WalletProxy = class {
764
4142
  disconnect() {
765
4143
  this.engine.disconnect();
766
4144
  }
767
- async switchChain(chain) {
768
- return this.engine.switchChain(chain);
4145
+ async switchChain(chain2) {
4146
+ return this.engine.switchChain(chain2);
769
4147
  }
770
4148
  // ── Gated async — EIP-1193, signing, chain awareness ───────────────────────
771
4149
  async connectEIP1193(provider, info) {
@@ -807,13 +4185,13 @@ var AwarizonWeb3 = class {
807
4185
  chain: this.chain,
808
4186
  transport: getChainTransport(this.chain, config.rpcUrl)
809
4187
  });
810
- this._engine = new walletEngine.WalletEngine({
4188
+ this._engine = new WalletEngine({
811
4189
  chain: this.chain,
812
4190
  publicClient: this.publicClient,
813
4191
  rpcUrl: config.rpcUrl,
814
- getTransport: (chain) => getChainTransport(chain, config.rpcUrl)
4192
+ getTransport: (chain2) => getChainTransport(chain2, config.rpcUrl)
815
4193
  });
816
- this._txEngine = new txEngine.TransactionEngine(
4194
+ this._txEngine = new TransactionEngine(
817
4195
  this.publicClient,
818
4196
  () => this._engine.getWalletClient()
819
4197
  );
@@ -924,9 +4302,9 @@ var AwarizonWeb3 = class {
924
4302
  this._engine.disconnectExternal();
925
4303
  return this;
926
4304
  }
927
- async switchChain(chain) {
4305
+ async switchChain(chain2) {
928
4306
  await this._telemetry.ensureValidated();
929
- const resolved = resolveChain(chain);
4307
+ const resolved = resolveChain(chain2);
930
4308
  await this._engine.switchChain(resolved);
931
4309
  this._contractCache.clear();
932
4310
  return this;
@@ -1301,100 +4679,54 @@ Currently registered: ${registered}`
1301
4679
  await this._telemetry.destroy();
1302
4680
  }
1303
4681
  };
4682
+ /*! Bundled license information:
4683
+
4684
+ @noble/hashes/esm/utils.js:
4685
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
4686
+
4687
+ @scure/base/lib/esm/index.js:
4688
+ (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
4689
+
4690
+ @scure/bip39/esm/index.js:
4691
+ (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
4692
+ */
1304
4693
 
1305
- Object.defineProperty(exports, "ChainMismatchError", {
1306
- enumerable: true,
1307
- get: function () { return walletEngine.ChainMismatchError; }
1308
- });
1309
- Object.defineProperty(exports, "ChainSwitchError", {
1310
- enumerable: true,
1311
- get: function () { return walletEngine.ChainSwitchError; }
1312
- });
1313
- Object.defineProperty(exports, "InvalidMnemonicError", {
1314
- enumerable: true,
1315
- get: function () { return walletEngine.InvalidMnemonicError; }
1316
- });
1317
- Object.defineProperty(exports, "InvalidPrivateKeyError", {
1318
- enumerable: true,
1319
- get: function () { return walletEngine.InvalidPrivateKeyError; }
1320
- });
1321
- Object.defineProperty(exports, "WalletEngine", {
1322
- enumerable: true,
1323
- get: function () { return walletEngine.WalletEngine; }
1324
- });
1325
- Object.defineProperty(exports, "WalletNotConnectedError", {
1326
- enumerable: true,
1327
- get: function () { return walletEngine.WalletNotConnectedError; }
1328
- });
1329
- Object.defineProperty(exports, "ContractExecutionError", {
1330
- enumerable: true,
1331
- get: function () { return txEngine.ContractExecutionError; }
1332
- });
1333
- Object.defineProperty(exports, "GasEstimationError", {
1334
- enumerable: true,
1335
- get: function () { return txEngine.GasEstimationError; }
1336
- });
1337
- Object.defineProperty(exports, "SimulationError", {
1338
- enumerable: true,
1339
- get: function () { return txEngine.SimulationError; }
1340
- });
1341
- Object.defineProperty(exports, "TransactionEngine", {
1342
- enumerable: true,
1343
- get: function () { return txEngine.TransactionEngine; }
1344
- });
1345
- Object.defineProperty(exports, "TransactionTimeoutError", {
1346
- enumerable: true,
1347
- get: function () { return txEngine.TransactionTimeoutError; }
1348
- });
1349
- Object.defineProperty(exports, "DuplicateFunctionError", {
1350
- enumerable: true,
1351
- get: function () { return abiEngine.DuplicateFunctionError; }
1352
- });
1353
- Object.defineProperty(exports, "InvalidABIError", {
1354
- enumerable: true,
1355
- get: function () { return abiEngine.InvalidABIError; }
1356
- });
1357
- Object.defineProperty(exports, "UnsupportedABIItemError", {
1358
- enumerable: true,
1359
- get: function () { return abiEngine.UnsupportedABIItemError; }
1360
- });
1361
- Object.defineProperty(exports, "generateAllMethodSignatures", {
1362
- enumerable: true,
1363
- get: function () { return abiEngine.generateAllMethodSignatures; }
1364
- });
1365
- Object.defineProperty(exports, "generateMethodSignature", {
1366
- enumerable: true,
1367
- get: function () { return abiEngine.generateMethodSignature; }
1368
- });
1369
- Object.defineProperty(exports, "isPayableFunction", {
1370
- enumerable: true,
1371
- get: function () { return abiEngine.isPayableFunction; }
1372
- });
1373
- Object.defineProperty(exports, "isWriteFunction", {
1374
- enumerable: true,
1375
- get: function () { return abiEngine.isWriteFunction; }
1376
- });
1377
- Object.defineProperty(exports, "parseABI", {
1378
- enumerable: true,
1379
- get: function () { return abiEngine.parseABI; }
1380
- });
1381
4694
  exports.ApiKeyRequiredError = ApiKeyRequiredError;
1382
4695
  exports.AwarizonWeb3 = AwarizonWeb3;
1383
4696
  exports.CHAINLINK_FEEDS = CHAINLINK_FEEDS;
1384
4697
  exports.CHAINS = CHAINS;
1385
4698
  exports.COINGECKO_IDS = COINGECKO_IDS;
4699
+ exports.ChainMismatchError = ChainMismatchError;
4700
+ exports.ChainSwitchError = ChainSwitchError;
4701
+ exports.ContractExecutionError = ContractExecutionError;
1386
4702
  exports.ContractNotLoadedError = ContractNotLoadedError;
4703
+ exports.DuplicateFunctionError = DuplicateFunctionError;
1387
4704
  exports.ERC1155_ABI = ERC1155_ABI;
1388
4705
  exports.ERC20_ABI = ERC20_ABI;
1389
4706
  exports.ERC721_ABI = ERC721_ABI;
4707
+ exports.GasEstimationError = GasEstimationError;
4708
+ exports.InvalidABIError = InvalidABIError;
1390
4709
  exports.InvalidApiKeyError = InvalidApiKeyError;
4710
+ exports.InvalidMnemonicError = InvalidMnemonicError;
4711
+ exports.InvalidPrivateKeyError = InvalidPrivateKeyError;
1391
4712
  exports.NetworkMismatchError = NetworkMismatchError;
1392
4713
  exports.PriceEngine = PriceEngine;
1393
4714
  exports.ProviderError = ProviderError;
4715
+ exports.SimulationError = SimulationError;
1394
4716
  exports.TelemetryClient = TelemetryClient;
4717
+ exports.TransactionEngine = TransactionEngine;
4718
+ exports.TransactionTimeoutError = TransactionTimeoutError;
4719
+ exports.UnsupportedABIItemError = UnsupportedABIItemError;
1395
4720
  exports.UnsupportedChainError = UnsupportedChainError;
4721
+ exports.WalletEngine = WalletEngine;
4722
+ exports.WalletNotConnectedError = WalletNotConnectedError;
4723
+ exports.generateAllMethodSignatures = generateAllMethodSignatures;
4724
+ exports.generateMethodSignature = generateMethodSignature;
1396
4725
  exports.getChainTransport = getChainTransport;
1397
4726
  exports.getSupportedChainIds = getSupportedChainIds;
4727
+ exports.isPayableFunction = isPayableFunction;
4728
+ exports.isWriteFunction = isWriteFunction;
4729
+ exports.parseABI = parseABI;
1398
4730
  exports.resolveChain = resolveChain;
1399
4731
  //# sourceMappingURL=index.js.map
1400
4732
  //# sourceMappingURL=index.js.map