@aurum-sdk/core 0.2.3-canary.3 → 0.2.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.
@@ -0,0 +1,4825 @@
1
+ import {
2
+ bytesToHex,
3
+ import_index,
4
+ sha2562 as sha256
5
+ } from "./chunk-YEVOYJGQ.mjs";
6
+ import {
7
+ __commonJS,
8
+ __toESM,
9
+ init_polyfills
10
+ } from "./chunk-YFDA5EMH.mjs";
11
+
12
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js
13
+ var require_u64 = __commonJS({
14
+ "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/_u64.js"(exports) {
15
+ "use strict";
16
+ init_polyfills();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.toBig = exports.shrSL = exports.shrSH = exports.rotrSL = exports.rotrSH = exports.rotrBL = exports.rotrBH = exports.rotr32L = exports.rotr32H = exports.rotlSL = exports.rotlSH = exports.rotlBL = exports.rotlBH = exports.add5L = exports.add5H = exports.add4L = exports.add4H = exports.add3L = exports.add3H = void 0;
19
+ exports.add = add;
20
+ exports.fromBig = fromBig;
21
+ exports.split = split;
22
+ var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
23
+ var _32n = /* @__PURE__ */ BigInt(32);
24
+ function fromBig(n2, le = false) {
25
+ if (le)
26
+ return { h: Number(n2 & U32_MASK64), l: Number(n2 >> _32n & U32_MASK64) };
27
+ return { h: Number(n2 >> _32n & U32_MASK64) | 0, l: Number(n2 & U32_MASK64) | 0 };
28
+ }
29
+ function split(lst, le = false) {
30
+ const len = lst.length;
31
+ let Ah = new Uint32Array(len);
32
+ let Al = new Uint32Array(len);
33
+ for (let i3 = 0; i3 < len; i3++) {
34
+ const { h: h3, l: l3 } = fromBig(lst[i3], le);
35
+ [Ah[i3], Al[i3]] = [h3, l3];
36
+ }
37
+ return [Ah, Al];
38
+ }
39
+ var toBig = (h3, l3) => BigInt(h3 >>> 0) << _32n | BigInt(l3 >>> 0);
40
+ exports.toBig = toBig;
41
+ var shrSH = (h3, _l, s3) => h3 >>> s3;
42
+ exports.shrSH = shrSH;
43
+ var shrSL = (h3, l3, s3) => h3 << 32 - s3 | l3 >>> s3;
44
+ exports.shrSL = shrSL;
45
+ var rotrSH = (h3, l3, s3) => h3 >>> s3 | l3 << 32 - s3;
46
+ exports.rotrSH = rotrSH;
47
+ var rotrSL = (h3, l3, s3) => h3 << 32 - s3 | l3 >>> s3;
48
+ exports.rotrSL = rotrSL;
49
+ var rotrBH = (h3, l3, s3) => h3 << 64 - s3 | l3 >>> s3 - 32;
50
+ exports.rotrBH = rotrBH;
51
+ var rotrBL = (h3, l3, s3) => h3 >>> s3 - 32 | l3 << 64 - s3;
52
+ exports.rotrBL = rotrBL;
53
+ var rotr32H = (_h, l3) => l3;
54
+ exports.rotr32H = rotr32H;
55
+ var rotr32L = (h3, _l) => h3;
56
+ exports.rotr32L = rotr32L;
57
+ var rotlSH = (h3, l3, s3) => h3 << s3 | l3 >>> 32 - s3;
58
+ exports.rotlSH = rotlSH;
59
+ var rotlSL = (h3, l3, s3) => l3 << s3 | h3 >>> 32 - s3;
60
+ exports.rotlSL = rotlSL;
61
+ var rotlBH = (h3, l3, s3) => l3 << s3 - 32 | h3 >>> 64 - s3;
62
+ exports.rotlBH = rotlBH;
63
+ var rotlBL = (h3, l3, s3) => h3 << s3 - 32 | l3 >>> 64 - s3;
64
+ exports.rotlBL = rotlBL;
65
+ function add(Ah, Al, Bh, Bl) {
66
+ const l3 = (Al >>> 0) + (Bl >>> 0);
67
+ return { h: Ah + Bh + (l3 / 2 ** 32 | 0) | 0, l: l3 | 0 };
68
+ }
69
+ var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
70
+ exports.add3L = add3L;
71
+ var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
72
+ exports.add3H = add3H;
73
+ var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
74
+ exports.add4L = add4L;
75
+ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
76
+ exports.add4H = add4H;
77
+ var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
78
+ exports.add5L = add5L;
79
+ var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
80
+ exports.add5H = add5H;
81
+ var u64 = {
82
+ fromBig,
83
+ split,
84
+ toBig,
85
+ shrSH,
86
+ shrSL,
87
+ rotrSH,
88
+ rotrSL,
89
+ rotrBH,
90
+ rotrBL,
91
+ rotr32H,
92
+ rotr32L,
93
+ rotlSH,
94
+ rotlSL,
95
+ rotlBH,
96
+ rotlBL,
97
+ add,
98
+ add3L,
99
+ add3H,
100
+ add4L,
101
+ add4H,
102
+ add5H,
103
+ add5L
104
+ };
105
+ exports.default = u64;
106
+ }
107
+ });
108
+
109
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/crypto.js
110
+ var require_crypto = __commonJS({
111
+ "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/crypto.js"(exports) {
112
+ "use strict";
113
+ init_polyfills();
114
+ Object.defineProperty(exports, "__esModule", { value: true });
115
+ exports.crypto = void 0;
116
+ exports.crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
117
+ }
118
+ });
119
+
120
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/utils.js
121
+ var require_utils = __commonJS({
122
+ "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/utils.js"(exports) {
123
+ "use strict";
124
+ init_polyfills();
125
+ Object.defineProperty(exports, "__esModule", { value: true });
126
+ exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.Hash = exports.nextTick = exports.swap32IfBE = exports.byteSwapIfBE = exports.swap8IfBE = exports.isLE = void 0;
127
+ exports.isBytes = isBytes;
128
+ exports.anumber = anumber;
129
+ exports.abytes = abytes;
130
+ exports.ahash = ahash;
131
+ exports.aexists = aexists;
132
+ exports.aoutput = aoutput;
133
+ exports.u8 = u8;
134
+ exports.u32 = u32;
135
+ exports.clean = clean;
136
+ exports.createView = createView;
137
+ exports.rotr = rotr;
138
+ exports.rotl = rotl;
139
+ exports.byteSwap = byteSwap;
140
+ exports.byteSwap32 = byteSwap32;
141
+ exports.bytesToHex = bytesToHex2;
142
+ exports.hexToBytes = hexToBytes;
143
+ exports.asyncLoop = asyncLoop;
144
+ exports.utf8ToBytes = utf8ToBytes;
145
+ exports.bytesToUtf8 = bytesToUtf8;
146
+ exports.toBytes = toBytes;
147
+ exports.kdfInputToBytes = kdfInputToBytes;
148
+ exports.concatBytes = concatBytes;
149
+ exports.checkOpts = checkOpts;
150
+ exports.createHasher = createHasher;
151
+ exports.createOptHasher = createOptHasher;
152
+ exports.createXOFer = createXOFer;
153
+ exports.randomBytes = randomBytes;
154
+ var crypto_1 = require_crypto();
155
+ function isBytes(a3) {
156
+ return a3 instanceof Uint8Array || ArrayBuffer.isView(a3) && a3.constructor.name === "Uint8Array";
157
+ }
158
+ function anumber(n2) {
159
+ if (!Number.isSafeInteger(n2) || n2 < 0)
160
+ throw new Error("positive integer expected, got " + n2);
161
+ }
162
+ function abytes(b, ...lengths) {
163
+ if (!isBytes(b))
164
+ throw new Error("Uint8Array expected");
165
+ if (lengths.length > 0 && !lengths.includes(b.length))
166
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
167
+ }
168
+ function ahash(h3) {
169
+ if (typeof h3 !== "function" || typeof h3.create !== "function")
170
+ throw new Error("Hash should be wrapped by utils.createHasher");
171
+ anumber(h3.outputLen);
172
+ anumber(h3.blockLen);
173
+ }
174
+ function aexists(instance, checkFinished = true) {
175
+ if (instance.destroyed)
176
+ throw new Error("Hash instance has been destroyed");
177
+ if (checkFinished && instance.finished)
178
+ throw new Error("Hash#digest() has already been called");
179
+ }
180
+ function aoutput(out, instance) {
181
+ abytes(out);
182
+ const min = instance.outputLen;
183
+ if (out.length < min) {
184
+ throw new Error("digestInto() expects output buffer of length at least " + min);
185
+ }
186
+ }
187
+ function u8(arr) {
188
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
189
+ }
190
+ function u32(arr) {
191
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
192
+ }
193
+ function clean(...arrays) {
194
+ for (let i3 = 0; i3 < arrays.length; i3++) {
195
+ arrays[i3].fill(0);
196
+ }
197
+ }
198
+ function createView(arr) {
199
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
200
+ }
201
+ function rotr(word, shift) {
202
+ return word << 32 - shift | word >>> shift;
203
+ }
204
+ function rotl(word, shift) {
205
+ return word << shift | word >>> 32 - shift >>> 0;
206
+ }
207
+ exports.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
208
+ function byteSwap(word) {
209
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
210
+ }
211
+ exports.swap8IfBE = exports.isLE ? (n2) => n2 : (n2) => byteSwap(n2);
212
+ exports.byteSwapIfBE = exports.swap8IfBE;
213
+ function byteSwap32(arr) {
214
+ for (let i3 = 0; i3 < arr.length; i3++) {
215
+ arr[i3] = byteSwap(arr[i3]);
216
+ }
217
+ return arr;
218
+ }
219
+ exports.swap32IfBE = exports.isLE ? (u3) => u3 : byteSwap32;
220
+ var hasHexBuiltin = /* @__PURE__ */ (() => (
221
+ // @ts-ignore
222
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
223
+ ))();
224
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_2, i3) => i3.toString(16).padStart(2, "0"));
225
+ function bytesToHex2(bytes) {
226
+ abytes(bytes);
227
+ if (hasHexBuiltin)
228
+ return bytes.toHex();
229
+ let hex = "";
230
+ for (let i3 = 0; i3 < bytes.length; i3++) {
231
+ hex += hexes[bytes[i3]];
232
+ }
233
+ return hex;
234
+ }
235
+ var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
236
+ function asciiToBase16(ch) {
237
+ if (ch >= asciis._0 && ch <= asciis._9)
238
+ return ch - asciis._0;
239
+ if (ch >= asciis.A && ch <= asciis.F)
240
+ return ch - (asciis.A - 10);
241
+ if (ch >= asciis.a && ch <= asciis.f)
242
+ return ch - (asciis.a - 10);
243
+ return;
244
+ }
245
+ function hexToBytes(hex) {
246
+ if (typeof hex !== "string")
247
+ throw new Error("hex string expected, got " + typeof hex);
248
+ if (hasHexBuiltin)
249
+ return Uint8Array.fromHex(hex);
250
+ const hl = hex.length;
251
+ const al = hl / 2;
252
+ if (hl % 2)
253
+ throw new Error("hex string expected, got unpadded hex of length " + hl);
254
+ const array = new Uint8Array(al);
255
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
256
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
257
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
258
+ if (n1 === void 0 || n2 === void 0) {
259
+ const char = hex[hi] + hex[hi + 1];
260
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
261
+ }
262
+ array[ai] = n1 * 16 + n2;
263
+ }
264
+ return array;
265
+ }
266
+ var nextTick = async () => {
267
+ };
268
+ exports.nextTick = nextTick;
269
+ async function asyncLoop(iters, tick, cb) {
270
+ let ts = Date.now();
271
+ for (let i3 = 0; i3 < iters; i3++) {
272
+ cb(i3);
273
+ const diff = Date.now() - ts;
274
+ if (diff >= 0 && diff < tick)
275
+ continue;
276
+ await (0, exports.nextTick)();
277
+ ts += diff;
278
+ }
279
+ }
280
+ function utf8ToBytes(str) {
281
+ if (typeof str !== "string")
282
+ throw new Error("string expected");
283
+ return new Uint8Array(new TextEncoder().encode(str));
284
+ }
285
+ function bytesToUtf8(bytes) {
286
+ return new TextDecoder().decode(bytes);
287
+ }
288
+ function toBytes(data) {
289
+ if (typeof data === "string")
290
+ data = utf8ToBytes(data);
291
+ abytes(data);
292
+ return data;
293
+ }
294
+ function kdfInputToBytes(data) {
295
+ if (typeof data === "string")
296
+ data = utf8ToBytes(data);
297
+ abytes(data);
298
+ return data;
299
+ }
300
+ function concatBytes(...arrays) {
301
+ let sum = 0;
302
+ for (let i3 = 0; i3 < arrays.length; i3++) {
303
+ const a3 = arrays[i3];
304
+ abytes(a3);
305
+ sum += a3.length;
306
+ }
307
+ const res = new Uint8Array(sum);
308
+ for (let i3 = 0, pad = 0; i3 < arrays.length; i3++) {
309
+ const a3 = arrays[i3];
310
+ res.set(a3, pad);
311
+ pad += a3.length;
312
+ }
313
+ return res;
314
+ }
315
+ function checkOpts(defaults, opts) {
316
+ if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
317
+ throw new Error("options should be object or undefined");
318
+ const merged = Object.assign(defaults, opts);
319
+ return merged;
320
+ }
321
+ var Hash = class {
322
+ };
323
+ exports.Hash = Hash;
324
+ function createHasher(hashCons) {
325
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
326
+ const tmp = hashCons();
327
+ hashC.outputLen = tmp.outputLen;
328
+ hashC.blockLen = tmp.blockLen;
329
+ hashC.create = () => hashCons();
330
+ return hashC;
331
+ }
332
+ function createOptHasher(hashCons) {
333
+ const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
334
+ const tmp = hashCons({});
335
+ hashC.outputLen = tmp.outputLen;
336
+ hashC.blockLen = tmp.blockLen;
337
+ hashC.create = (opts) => hashCons(opts);
338
+ return hashC;
339
+ }
340
+ function createXOFer(hashCons) {
341
+ const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
342
+ const tmp = hashCons({});
343
+ hashC.outputLen = tmp.outputLen;
344
+ hashC.blockLen = tmp.blockLen;
345
+ hashC.create = (opts) => hashCons(opts);
346
+ return hashC;
347
+ }
348
+ exports.wrapConstructor = createHasher;
349
+ exports.wrapConstructorWithOpts = createOptHasher;
350
+ exports.wrapXOFConstructorWithOpts = createXOFer;
351
+ function randomBytes(bytesLength = 32) {
352
+ if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
353
+ return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
354
+ }
355
+ if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
356
+ return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
357
+ }
358
+ throw new Error("crypto.getRandomValues must be defined");
359
+ }
360
+ }
361
+ });
362
+
363
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/sha3.js
364
+ var require_sha3 = __commonJS({
365
+ "../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/sha3.js"(exports) {
366
+ "use strict";
367
+ init_polyfills();
368
+ Object.defineProperty(exports, "__esModule", { value: true });
369
+ exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0;
370
+ exports.keccakP = keccakP;
371
+ var _u64_ts_1 = require_u64();
372
+ var utils_ts_1 = require_utils();
373
+ var _0n = BigInt(0);
374
+ var _1n = BigInt(1);
375
+ var _2n = BigInt(2);
376
+ var _7n = BigInt(7);
377
+ var _256n = BigInt(256);
378
+ var _0x71n = BigInt(113);
379
+ var SHA3_PI = [];
380
+ var SHA3_ROTL = [];
381
+ var _SHA3_IOTA = [];
382
+ for (let round = 0, R = _1n, x2 = 1, y3 = 0; round < 24; round++) {
383
+ [x2, y3] = [y3, (2 * x2 + 3 * y3) % 5];
384
+ SHA3_PI.push(2 * (5 * y3 + x2));
385
+ SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
386
+ let t3 = _0n;
387
+ for (let j3 = 0; j3 < 7; j3++) {
388
+ R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
389
+ if (R & _2n)
390
+ t3 ^= _1n << (_1n << /* @__PURE__ */ BigInt(j3)) - _1n;
391
+ }
392
+ _SHA3_IOTA.push(t3);
393
+ }
394
+ var IOTAS = (0, _u64_ts_1.split)(_SHA3_IOTA, true);
395
+ var SHA3_IOTA_H = IOTAS[0];
396
+ var SHA3_IOTA_L = IOTAS[1];
397
+ var rotlH = (h3, l3, s3) => s3 > 32 ? (0, _u64_ts_1.rotlBH)(h3, l3, s3) : (0, _u64_ts_1.rotlSH)(h3, l3, s3);
398
+ var rotlL = (h3, l3, s3) => s3 > 32 ? (0, _u64_ts_1.rotlBL)(h3, l3, s3) : (0, _u64_ts_1.rotlSL)(h3, l3, s3);
399
+ function keccakP(s3, rounds = 24) {
400
+ const B3 = new Uint32Array(5 * 2);
401
+ for (let round = 24 - rounds; round < 24; round++) {
402
+ for (let x2 = 0; x2 < 10; x2++)
403
+ B3[x2] = s3[x2] ^ s3[x2 + 10] ^ s3[x2 + 20] ^ s3[x2 + 30] ^ s3[x2 + 40];
404
+ for (let x2 = 0; x2 < 10; x2 += 2) {
405
+ const idx1 = (x2 + 8) % 10;
406
+ const idx0 = (x2 + 2) % 10;
407
+ const B0 = B3[idx0];
408
+ const B1 = B3[idx0 + 1];
409
+ const Th = rotlH(B0, B1, 1) ^ B3[idx1];
410
+ const Tl = rotlL(B0, B1, 1) ^ B3[idx1 + 1];
411
+ for (let y3 = 0; y3 < 50; y3 += 10) {
412
+ s3[x2 + y3] ^= Th;
413
+ s3[x2 + y3 + 1] ^= Tl;
414
+ }
415
+ }
416
+ let curH = s3[2];
417
+ let curL = s3[3];
418
+ for (let t3 = 0; t3 < 24; t3++) {
419
+ const shift = SHA3_ROTL[t3];
420
+ const Th = rotlH(curH, curL, shift);
421
+ const Tl = rotlL(curH, curL, shift);
422
+ const PI = SHA3_PI[t3];
423
+ curH = s3[PI];
424
+ curL = s3[PI + 1];
425
+ s3[PI] = Th;
426
+ s3[PI + 1] = Tl;
427
+ }
428
+ for (let y3 = 0; y3 < 50; y3 += 10) {
429
+ for (let x2 = 0; x2 < 10; x2++)
430
+ B3[x2] = s3[y3 + x2];
431
+ for (let x2 = 0; x2 < 10; x2++)
432
+ s3[y3 + x2] ^= ~B3[(x2 + 2) % 10] & B3[(x2 + 4) % 10];
433
+ }
434
+ s3[0] ^= SHA3_IOTA_H[round];
435
+ s3[1] ^= SHA3_IOTA_L[round];
436
+ }
437
+ (0, utils_ts_1.clean)(B3);
438
+ }
439
+ var Keccak = class _Keccak extends utils_ts_1.Hash {
440
+ // NOTE: we accept arguments in bytes instead of bits here.
441
+ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
442
+ super();
443
+ this.pos = 0;
444
+ this.posOut = 0;
445
+ this.finished = false;
446
+ this.destroyed = false;
447
+ this.enableXOF = false;
448
+ this.blockLen = blockLen;
449
+ this.suffix = suffix;
450
+ this.outputLen = outputLen;
451
+ this.enableXOF = enableXOF;
452
+ this.rounds = rounds;
453
+ (0, utils_ts_1.anumber)(outputLen);
454
+ if (!(0 < blockLen && blockLen < 200))
455
+ throw new Error("only keccak-f1600 function is supported");
456
+ this.state = new Uint8Array(200);
457
+ this.state32 = (0, utils_ts_1.u32)(this.state);
458
+ }
459
+ clone() {
460
+ return this._cloneInto();
461
+ }
462
+ keccak() {
463
+ (0, utils_ts_1.swap32IfBE)(this.state32);
464
+ keccakP(this.state32, this.rounds);
465
+ (0, utils_ts_1.swap32IfBE)(this.state32);
466
+ this.posOut = 0;
467
+ this.pos = 0;
468
+ }
469
+ update(data) {
470
+ (0, utils_ts_1.aexists)(this);
471
+ data = (0, utils_ts_1.toBytes)(data);
472
+ (0, utils_ts_1.abytes)(data);
473
+ const { blockLen, state } = this;
474
+ const len = data.length;
475
+ for (let pos = 0; pos < len; ) {
476
+ const take = Math.min(blockLen - this.pos, len - pos);
477
+ for (let i3 = 0; i3 < take; i3++)
478
+ state[this.pos++] ^= data[pos++];
479
+ if (this.pos === blockLen)
480
+ this.keccak();
481
+ }
482
+ return this;
483
+ }
484
+ finish() {
485
+ if (this.finished)
486
+ return;
487
+ this.finished = true;
488
+ const { state, suffix, pos, blockLen } = this;
489
+ state[pos] ^= suffix;
490
+ if ((suffix & 128) !== 0 && pos === blockLen - 1)
491
+ this.keccak();
492
+ state[blockLen - 1] ^= 128;
493
+ this.keccak();
494
+ }
495
+ writeInto(out) {
496
+ (0, utils_ts_1.aexists)(this, false);
497
+ (0, utils_ts_1.abytes)(out);
498
+ this.finish();
499
+ const bufferOut = this.state;
500
+ const { blockLen } = this;
501
+ for (let pos = 0, len = out.length; pos < len; ) {
502
+ if (this.posOut >= blockLen)
503
+ this.keccak();
504
+ const take = Math.min(blockLen - this.posOut, len - pos);
505
+ out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
506
+ this.posOut += take;
507
+ pos += take;
508
+ }
509
+ return out;
510
+ }
511
+ xofInto(out) {
512
+ if (!this.enableXOF)
513
+ throw new Error("XOF is not possible for this instance");
514
+ return this.writeInto(out);
515
+ }
516
+ xof(bytes) {
517
+ (0, utils_ts_1.anumber)(bytes);
518
+ return this.xofInto(new Uint8Array(bytes));
519
+ }
520
+ digestInto(out) {
521
+ (0, utils_ts_1.aoutput)(out, this);
522
+ if (this.finished)
523
+ throw new Error("digest() was already called");
524
+ this.writeInto(out);
525
+ this.destroy();
526
+ return out;
527
+ }
528
+ digest() {
529
+ return this.digestInto(new Uint8Array(this.outputLen));
530
+ }
531
+ destroy() {
532
+ this.destroyed = true;
533
+ (0, utils_ts_1.clean)(this.state);
534
+ }
535
+ _cloneInto(to) {
536
+ const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
537
+ to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
538
+ to.state32.set(this.state32);
539
+ to.pos = this.pos;
540
+ to.posOut = this.posOut;
541
+ to.finished = this.finished;
542
+ to.rounds = rounds;
543
+ to.suffix = suffix;
544
+ to.outputLen = outputLen;
545
+ to.enableXOF = enableXOF;
546
+ to.destroyed = this.destroyed;
547
+ return to;
548
+ }
549
+ };
550
+ exports.Keccak = Keccak;
551
+ var gen = (suffix, blockLen, outputLen) => (0, utils_ts_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen));
552
+ exports.sha3_224 = (() => gen(6, 144, 224 / 8))();
553
+ exports.sha3_256 = (() => gen(6, 136, 256 / 8))();
554
+ exports.sha3_384 = (() => gen(6, 104, 384 / 8))();
555
+ exports.sha3_512 = (() => gen(6, 72, 512 / 8))();
556
+ exports.keccak_224 = (() => gen(1, 144, 224 / 8))();
557
+ exports.keccak_256 = (() => gen(1, 136, 256 / 8))();
558
+ exports.keccak_384 = (() => gen(1, 104, 384 / 8))();
559
+ exports.keccak_512 = (() => gen(1, 72, 512 / 8))();
560
+ var genShake = (suffix, blockLen, outputLen) => (0, utils_ts_1.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
561
+ exports.shake128 = (() => genShake(31, 168, 128 / 8))();
562
+ exports.shake256 = (() => genShake(31, 136, 256 / 8))();
563
+ }
564
+ });
565
+
566
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/util.cjs
567
+ var require_util = __commonJS({
568
+ "../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/util.cjs"(exports, module) {
569
+ "use strict";
570
+ init_polyfills();
571
+ var { keccak_256 } = require_sha3();
572
+ function zeros(bytes) {
573
+ return Buffer.allocUnsafe(bytes).fill(0);
574
+ }
575
+ function bitLengthFromBigInt(num) {
576
+ return num.toString(2).length;
577
+ }
578
+ function bufferBEFromBigInt(num, length) {
579
+ let hex = num.toString(16);
580
+ if (hex.length % 2 !== 0) hex = "0" + hex;
581
+ const byteArray = hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16));
582
+ while (byteArray.length < length) {
583
+ byteArray.unshift(0);
584
+ }
585
+ return Buffer.from(byteArray);
586
+ }
587
+ function twosFromBigInt(value, width) {
588
+ const isNegative = value < 0n;
589
+ let result;
590
+ if (isNegative) {
591
+ const mask = (1n << BigInt(width)) - 1n;
592
+ result = (~value & mask) + 1n;
593
+ } else {
594
+ result = value;
595
+ }
596
+ result &= (1n << BigInt(width)) - 1n;
597
+ return result;
598
+ }
599
+ function setLength(msg, length, right) {
600
+ const buf = zeros(length);
601
+ msg = toBuffer(msg);
602
+ if (right) {
603
+ if (msg.length < length) {
604
+ msg.copy(buf);
605
+ return buf;
606
+ }
607
+ return msg.slice(0, length);
608
+ } else {
609
+ if (msg.length < length) {
610
+ msg.copy(buf, length - msg.length);
611
+ return buf;
612
+ }
613
+ return msg.slice(-length);
614
+ }
615
+ }
616
+ function setLengthRight(msg, length) {
617
+ return setLength(msg, length, true);
618
+ }
619
+ function toBuffer(v3) {
620
+ if (!Buffer.isBuffer(v3)) {
621
+ if (Array.isArray(v3)) {
622
+ v3 = Buffer.from(v3);
623
+ } else if (typeof v3 === "string") {
624
+ if (isHexString2(v3)) {
625
+ v3 = Buffer.from(padToEven(stripHexPrefix(v3)), "hex");
626
+ } else {
627
+ v3 = Buffer.from(v3);
628
+ }
629
+ } else if (typeof v3 === "number") {
630
+ v3 = intToBuffer(v3);
631
+ } else if (v3 === null || v3 === void 0) {
632
+ v3 = Buffer.allocUnsafe(0);
633
+ } else if (typeof v3 === "bigint") {
634
+ v3 = bufferBEFromBigInt(v3);
635
+ } else if (v3.toArray) {
636
+ v3 = Buffer.from(v3.toArray());
637
+ } else {
638
+ throw new Error("invalid type");
639
+ }
640
+ }
641
+ return v3;
642
+ }
643
+ function bufferToHex(buf) {
644
+ buf = toBuffer(buf);
645
+ return "0x" + buf.toString("hex");
646
+ }
647
+ function keccak(a3, bits) {
648
+ a3 = toBuffer(a3);
649
+ if (!bits) bits = 256;
650
+ if (bits !== 256) {
651
+ throw new Error("unsupported");
652
+ }
653
+ return Buffer.from(keccak_256(new Uint8Array(a3)));
654
+ }
655
+ function padToEven(str) {
656
+ return str.length % 2 ? "0" + str : str;
657
+ }
658
+ function isHexString2(str) {
659
+ return typeof str === "string" && str.match(/^0x[0-9A-Fa-f]*$/);
660
+ }
661
+ function stripHexPrefix(str) {
662
+ if (typeof str === "string" && str.startsWith("0x")) {
663
+ return str.slice(2);
664
+ }
665
+ return str;
666
+ }
667
+ module.exports = {
668
+ zeros,
669
+ setLength,
670
+ setLengthRight,
671
+ isHexString: isHexString2,
672
+ stripHexPrefix,
673
+ toBuffer,
674
+ bufferToHex,
675
+ keccak,
676
+ bitLengthFromBigInt,
677
+ bufferBEFromBigInt,
678
+ twosFromBigInt
679
+ };
680
+ }
681
+ });
682
+
683
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/abi.cjs
684
+ var require_abi = __commonJS({
685
+ "../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/abi.cjs"(exports, module) {
686
+ "use strict";
687
+ init_polyfills();
688
+ var util = require_util();
689
+ function elementaryName(name) {
690
+ if (name.startsWith("int[")) {
691
+ return "int256" + name.slice(3);
692
+ } else if (name === "int") {
693
+ return "int256";
694
+ } else if (name.startsWith("uint[")) {
695
+ return "uint256" + name.slice(4);
696
+ } else if (name === "uint") {
697
+ return "uint256";
698
+ } else if (name.startsWith("fixed[")) {
699
+ return "fixed128x128" + name.slice(5);
700
+ } else if (name === "fixed") {
701
+ return "fixed128x128";
702
+ } else if (name.startsWith("ufixed[")) {
703
+ return "ufixed128x128" + name.slice(6);
704
+ } else if (name === "ufixed") {
705
+ return "ufixed128x128";
706
+ }
707
+ return name;
708
+ }
709
+ function parseTypeN(type) {
710
+ return Number.parseInt(/^\D+(\d+)$/.exec(type)[1], 10);
711
+ }
712
+ function parseTypeNxM(type) {
713
+ var tmp = /^\D+(\d+)x(\d+)$/.exec(type);
714
+ return [Number.parseInt(tmp[1], 10), Number.parseInt(tmp[2], 10)];
715
+ }
716
+ function parseTypeArray(type) {
717
+ var tmp = type.match(/(.*)\[(.*?)\]$/);
718
+ if (tmp) {
719
+ return tmp[2] === "" ? "dynamic" : Number.parseInt(tmp[2], 10);
720
+ }
721
+ return null;
722
+ }
723
+ function parseNumber(arg) {
724
+ var type = typeof arg;
725
+ if (type === "string" || type === "number") {
726
+ return BigInt(arg);
727
+ } else if (type === "bigint") {
728
+ return arg;
729
+ } else {
730
+ throw new Error("Argument is not a number");
731
+ }
732
+ }
733
+ function encodeSingle(type, arg) {
734
+ var size, num, ret, i3;
735
+ if (type === "address") {
736
+ return encodeSingle("uint160", parseNumber(arg));
737
+ } else if (type === "bool") {
738
+ return encodeSingle("uint8", arg ? 1 : 0);
739
+ } else if (type === "string") {
740
+ return encodeSingle("bytes", new Buffer(arg, "utf8"));
741
+ } else if (isArray(type)) {
742
+ if (typeof arg.length === "undefined") {
743
+ throw new Error("Not an array?");
744
+ }
745
+ size = parseTypeArray(type);
746
+ if (size !== "dynamic" && size !== 0 && arg.length > size) {
747
+ throw new Error("Elements exceed array size: " + size);
748
+ }
749
+ ret = [];
750
+ type = type.slice(0, type.lastIndexOf("["));
751
+ if (typeof arg === "string") {
752
+ arg = JSON.parse(arg);
753
+ }
754
+ for (i3 in arg) {
755
+ ret.push(encodeSingle(type, arg[i3]));
756
+ }
757
+ if (size === "dynamic") {
758
+ var length = encodeSingle("uint256", arg.length);
759
+ ret.unshift(length);
760
+ }
761
+ return Buffer.concat(ret);
762
+ } else if (type === "bytes") {
763
+ arg = new Buffer(arg);
764
+ ret = Buffer.concat([encodeSingle("uint256", arg.length), arg]);
765
+ if (arg.length % 32 !== 0) {
766
+ ret = Buffer.concat([ret, util.zeros(32 - arg.length % 32)]);
767
+ }
768
+ return ret;
769
+ } else if (type.startsWith("bytes")) {
770
+ size = parseTypeN(type);
771
+ if (size < 1 || size > 32) {
772
+ throw new Error("Invalid bytes<N> width: " + size);
773
+ }
774
+ return util.setLengthRight(arg, 32);
775
+ } else if (type.startsWith("uint")) {
776
+ size = parseTypeN(type);
777
+ if (size % 8 || size < 8 || size > 256) {
778
+ throw new Error("Invalid uint<N> width: " + size);
779
+ }
780
+ num = parseNumber(arg);
781
+ const bitLength = util.bitLengthFromBigInt(num);
782
+ if (bitLength > size) {
783
+ throw new Error("Supplied uint exceeds width: " + size + " vs " + bitLength);
784
+ }
785
+ if (num < 0) {
786
+ throw new Error("Supplied uint is negative");
787
+ }
788
+ return util.bufferBEFromBigInt(num, 32);
789
+ } else if (type.startsWith("int")) {
790
+ size = parseTypeN(type);
791
+ if (size % 8 || size < 8 || size > 256) {
792
+ throw new Error("Invalid int<N> width: " + size);
793
+ }
794
+ num = parseNumber(arg);
795
+ const bitLength = util.bitLengthFromBigInt(num);
796
+ if (bitLength > size) {
797
+ throw new Error("Supplied int exceeds width: " + size + " vs " + bitLength);
798
+ }
799
+ const twos = util.twosFromBigInt(num, 256);
800
+ return util.bufferBEFromBigInt(twos, 32);
801
+ } else if (type.startsWith("ufixed")) {
802
+ size = parseTypeNxM(type);
803
+ num = parseNumber(arg);
804
+ if (num < 0) {
805
+ throw new Error("Supplied ufixed is negative");
806
+ }
807
+ return encodeSingle("uint256", num * BigInt(2) ** BigInt(size[1]));
808
+ } else if (type.startsWith("fixed")) {
809
+ size = parseTypeNxM(type);
810
+ return encodeSingle("int256", parseNumber(arg) * BigInt(2) ** BigInt(size[1]));
811
+ }
812
+ throw new Error("Unsupported or invalid type: " + type);
813
+ }
814
+ function isDynamic(type) {
815
+ return type === "string" || type === "bytes" || parseTypeArray(type) === "dynamic";
816
+ }
817
+ function isArray(type) {
818
+ return type.lastIndexOf("]") === type.length - 1;
819
+ }
820
+ function rawEncode(types, values) {
821
+ var output = [];
822
+ var data = [];
823
+ var headLength = 32 * types.length;
824
+ for (var i3 in types) {
825
+ var type = elementaryName(types[i3]);
826
+ var value = values[i3];
827
+ var cur = encodeSingle(type, value);
828
+ if (isDynamic(type)) {
829
+ output.push(encodeSingle("uint256", headLength));
830
+ data.push(cur);
831
+ headLength += cur.length;
832
+ } else {
833
+ output.push(cur);
834
+ }
835
+ }
836
+ return Buffer.concat(output.concat(data));
837
+ }
838
+ function solidityPack(types, values) {
839
+ if (types.length !== values.length) {
840
+ throw new Error("Number of types are not matching the values");
841
+ }
842
+ var size, num;
843
+ var ret = [];
844
+ for (var i3 = 0; i3 < types.length; i3++) {
845
+ var type = elementaryName(types[i3]);
846
+ var value = values[i3];
847
+ if (type === "bytes") {
848
+ ret.push(value);
849
+ } else if (type === "string") {
850
+ ret.push(new Buffer(value, "utf8"));
851
+ } else if (type === "bool") {
852
+ ret.push(new Buffer(value ? "01" : "00", "hex"));
853
+ } else if (type === "address") {
854
+ ret.push(util.setLength(value, 20));
855
+ } else if (type.startsWith("bytes")) {
856
+ size = parseTypeN(type);
857
+ if (size < 1 || size > 32) {
858
+ throw new Error("Invalid bytes<N> width: " + size);
859
+ }
860
+ ret.push(util.setLengthRight(value, size));
861
+ } else if (type.startsWith("uint")) {
862
+ size = parseTypeN(type);
863
+ if (size % 8 || size < 8 || size > 256) {
864
+ throw new Error("Invalid uint<N> width: " + size);
865
+ }
866
+ num = parseNumber(value);
867
+ const bitLength = util.bitLengthFromBigInt(num);
868
+ if (bitLength > size) {
869
+ throw new Error("Supplied uint exceeds width: " + size + " vs " + bitLength);
870
+ }
871
+ ret.push(util.bufferBEFromBigInt(num, size / 8));
872
+ } else if (type.startsWith("int")) {
873
+ size = parseTypeN(type);
874
+ if (size % 8 || size < 8 || size > 256) {
875
+ throw new Error("Invalid int<N> width: " + size);
876
+ }
877
+ num = parseNumber(value);
878
+ const bitLength = util.bitLengthFromBigInt(num);
879
+ if (bitLength > size) {
880
+ throw new Error("Supplied int exceeds width: " + size + " vs " + bitLength);
881
+ }
882
+ const twos = util.twosFromBigInt(num, size);
883
+ ret.push(util.bufferBEFromBigInt(twos, size / 8));
884
+ } else {
885
+ throw new Error("Unsupported or invalid type: " + type);
886
+ }
887
+ }
888
+ return Buffer.concat(ret);
889
+ }
890
+ function soliditySHA3(types, values) {
891
+ return util.keccak(solidityPack(types, values));
892
+ }
893
+ module.exports = {
894
+ rawEncode,
895
+ solidityPack,
896
+ soliditySHA3
897
+ };
898
+ }
899
+ });
900
+
901
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/index.cjs
902
+ var require_eth_eip712_util = __commonJS({
903
+ "../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/index.cjs"(exports, module) {
904
+ "use strict";
905
+ init_polyfills();
906
+ var util = require_util();
907
+ var abi = require_abi();
908
+ var TYPED_MESSAGE_SCHEMA = {
909
+ type: "object",
910
+ properties: {
911
+ types: {
912
+ type: "object",
913
+ additionalProperties: {
914
+ type: "array",
915
+ items: {
916
+ type: "object",
917
+ properties: {
918
+ name: { type: "string" },
919
+ type: { type: "string" }
920
+ },
921
+ required: ["name", "type"]
922
+ }
923
+ }
924
+ },
925
+ primaryType: { type: "string" },
926
+ domain: { type: "object" },
927
+ message: { type: "object" }
928
+ },
929
+ required: ["types", "primaryType", "domain", "message"]
930
+ };
931
+ var TypedDataUtils = {
932
+ /**
933
+ * Encodes an object by encoding and concatenating each of its members
934
+ *
935
+ * @param {string} primaryType - Root type
936
+ * @param {Object} data - Object to encode
937
+ * @param {Object} types - Type definitions
938
+ * @returns {string} - Encoded representation of an object
939
+ */
940
+ encodeData(primaryType, data, types, useV4 = true) {
941
+ const encodedTypes = ["bytes32"];
942
+ const encodedValues = [this.hashType(primaryType, types)];
943
+ if (useV4) {
944
+ const encodeField = (name, type, value) => {
945
+ if (types[type] !== void 0) {
946
+ return ["bytes32", value == null ? "0x0000000000000000000000000000000000000000000000000000000000000000" : util.keccak(this.encodeData(type, value, types, useV4))];
947
+ }
948
+ if (value === void 0)
949
+ throw new Error(`missing value for field ${name} of type ${type}`);
950
+ if (type === "bytes") {
951
+ return ["bytes32", util.keccak(value)];
952
+ }
953
+ if (type === "string") {
954
+ if (typeof value === "string") {
955
+ value = Buffer.from(value, "utf8");
956
+ }
957
+ return ["bytes32", util.keccak(value)];
958
+ }
959
+ if (type.lastIndexOf("]") === type.length - 1) {
960
+ const parsedType = type.slice(0, type.lastIndexOf("["));
961
+ const typeValuePairs = value.map((item) => encodeField(name, parsedType, item));
962
+ return ["bytes32", util.keccak(abi.rawEncode(
963
+ typeValuePairs.map(([type2]) => type2),
964
+ typeValuePairs.map(([, value2]) => value2)
965
+ ))];
966
+ }
967
+ return [type, value];
968
+ };
969
+ for (const field of types[primaryType]) {
970
+ const [type, value] = encodeField(field.name, field.type, data[field.name]);
971
+ encodedTypes.push(type);
972
+ encodedValues.push(value);
973
+ }
974
+ } else {
975
+ for (const field of types[primaryType]) {
976
+ let value = data[field.name];
977
+ if (value !== void 0) {
978
+ if (field.type === "bytes") {
979
+ encodedTypes.push("bytes32");
980
+ value = util.keccak(value);
981
+ encodedValues.push(value);
982
+ } else if (field.type === "string") {
983
+ encodedTypes.push("bytes32");
984
+ if (typeof value === "string") {
985
+ value = Buffer.from(value, "utf8");
986
+ }
987
+ value = util.keccak(value);
988
+ encodedValues.push(value);
989
+ } else if (types[field.type] !== void 0) {
990
+ encodedTypes.push("bytes32");
991
+ value = util.keccak(this.encodeData(field.type, value, types, useV4));
992
+ encodedValues.push(value);
993
+ } else if (field.type.lastIndexOf("]") === field.type.length - 1) {
994
+ throw new Error("Arrays currently unimplemented in encodeData");
995
+ } else {
996
+ encodedTypes.push(field.type);
997
+ encodedValues.push(value);
998
+ }
999
+ }
1000
+ }
1001
+ }
1002
+ return abi.rawEncode(encodedTypes, encodedValues);
1003
+ },
1004
+ /**
1005
+ * Encodes the type of an object by encoding a comma delimited list of its members
1006
+ *
1007
+ * @param {string} primaryType - Root type to encode
1008
+ * @param {Object} types - Type definitions
1009
+ * @returns {string} - Encoded representation of the type of an object
1010
+ */
1011
+ encodeType(primaryType, types) {
1012
+ let result = "";
1013
+ let deps = this.findTypeDependencies(primaryType, types).filter((dep) => dep !== primaryType);
1014
+ deps = [primaryType].concat(deps.sort());
1015
+ for (const type of deps) {
1016
+ const children = types[type];
1017
+ if (!children) {
1018
+ throw new Error("No type definition specified: " + type);
1019
+ }
1020
+ result += type + "(" + types[type].map(({ name, type: type2 }) => type2 + " " + name).join(",") + ")";
1021
+ }
1022
+ return result;
1023
+ },
1024
+ /**
1025
+ * Finds all types within a type definition object
1026
+ *
1027
+ * @param {string} primaryType - Root type
1028
+ * @param {Object} types - Type definitions
1029
+ * @param {Array} results - current set of accumulated types
1030
+ * @returns {Array} - Set of all types found in the type definition
1031
+ */
1032
+ findTypeDependencies(primaryType, types, results = []) {
1033
+ primaryType = primaryType.match(/^\w*/)[0];
1034
+ if (results.includes(primaryType) || types[primaryType] === void 0) {
1035
+ return results;
1036
+ }
1037
+ results.push(primaryType);
1038
+ for (const field of types[primaryType]) {
1039
+ for (const dep of this.findTypeDependencies(field.type, types, results)) {
1040
+ !results.includes(dep) && results.push(dep);
1041
+ }
1042
+ }
1043
+ return results;
1044
+ },
1045
+ /**
1046
+ * Hashes an object
1047
+ *
1048
+ * @param {string} primaryType - Root type
1049
+ * @param {Object} data - Object to hash
1050
+ * @param {Object} types - Type definitions
1051
+ * @returns {Buffer} - Hash of an object
1052
+ */
1053
+ hashStruct(primaryType, data, types, useV4 = true) {
1054
+ return util.keccak(this.encodeData(primaryType, data, types, useV4));
1055
+ },
1056
+ /**
1057
+ * Hashes the type of an object
1058
+ *
1059
+ * @param {string} primaryType - Root type to hash
1060
+ * @param {Object} types - Type definitions
1061
+ * @returns {string} - Hash of an object
1062
+ */
1063
+ hashType(primaryType, types) {
1064
+ return util.keccak(this.encodeType(primaryType, types));
1065
+ },
1066
+ /**
1067
+ * Removes properties from a message object that are not defined per EIP-712
1068
+ *
1069
+ * @param {Object} data - typed message object
1070
+ * @returns {Object} - typed message object with only allowed fields
1071
+ */
1072
+ sanitizeData(data) {
1073
+ const sanitizedData = {};
1074
+ for (const key in TYPED_MESSAGE_SCHEMA.properties) {
1075
+ data[key] && (sanitizedData[key] = data[key]);
1076
+ }
1077
+ if (sanitizedData.types) {
1078
+ sanitizedData.types = Object.assign({ EIP712Domain: [] }, sanitizedData.types);
1079
+ }
1080
+ return sanitizedData;
1081
+ },
1082
+ /**
1083
+ * Returns the hash of a typed message as per EIP-712 for signing
1084
+ *
1085
+ * @param {Object} typedData - Types message data to sign
1086
+ * @returns {string} - sha3 hash for signing
1087
+ */
1088
+ hash(typedData, useV4 = true) {
1089
+ const sanitizedData = this.sanitizeData(typedData);
1090
+ const parts = [Buffer.from("1901", "hex")];
1091
+ parts.push(this.hashStruct("EIP712Domain", sanitizedData.domain, sanitizedData.types, useV4));
1092
+ if (sanitizedData.primaryType !== "EIP712Domain") {
1093
+ parts.push(this.hashStruct(sanitizedData.primaryType, sanitizedData.message, sanitizedData.types, useV4));
1094
+ }
1095
+ return util.keccak(Buffer.concat(parts));
1096
+ }
1097
+ };
1098
+ module.exports = {
1099
+ TYPED_MESSAGE_SCHEMA,
1100
+ TypedDataUtils,
1101
+ hashForSignTypedDataLegacy: function(msgParams) {
1102
+ return typedSignatureHashLegacy(msgParams.data);
1103
+ },
1104
+ hashForSignTypedData_v3: function(msgParams) {
1105
+ return TypedDataUtils.hash(msgParams.data, false);
1106
+ },
1107
+ hashForSignTypedData_v4: function(msgParams) {
1108
+ return TypedDataUtils.hash(msgParams.data);
1109
+ }
1110
+ };
1111
+ function typedSignatureHashLegacy(typedData) {
1112
+ const error = new Error("Expect argument to be non-empty array");
1113
+ if (typeof typedData !== "object" || !typedData.length) throw error;
1114
+ const data = typedData.map(function(e3) {
1115
+ return e3.type === "bytes" ? util.toBuffer(e3.value) : e3.value;
1116
+ });
1117
+ const types = typedData.map(function(e3) {
1118
+ return e3.type;
1119
+ });
1120
+ const schema = typedData.map(function(e3) {
1121
+ if (!e3.name) throw error;
1122
+ return e3.type + " " + e3.name;
1123
+ });
1124
+ return abi.soliditySHA3(
1125
+ ["bytes32", "bytes32"],
1126
+ [
1127
+ abi.soliditySHA3(new Array(typedData.length).fill("string"), schema),
1128
+ abi.soliditySHA3(types, data)
1129
+ ]
1130
+ );
1131
+ }
1132
+ }
1133
+ });
1134
+
1135
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/index.js
1136
+ init_polyfills();
1137
+
1138
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/CoinbaseWalletSDK.js
1139
+ init_polyfills();
1140
+
1141
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/assets/wallet-logo.js
1142
+ init_polyfills();
1143
+ var walletLogo = (type, width) => {
1144
+ let height;
1145
+ switch (type) {
1146
+ case "standard":
1147
+ height = width;
1148
+ return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
1149
+ case "circle":
1150
+ height = width;
1151
+ return `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 999.81 999.81'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052fe;%7D.cls-2%7Bfill:%23fefefe;%7D.cls-3%7Bfill:%230152fe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M655-115.9h56c.83,1.59,2.36.88,3.56,1a478,478,0,0,1,75.06,10.42C891.4-81.76,978.33-32.58,1049.19,44q116.7,126,131.94,297.61c.38,4.14-.34,8.53,1.78,12.45v59c-1.58.84-.91,2.35-1,3.56a482.05,482.05,0,0,1-10.38,74.05c-24,106.72-76.64,196.76-158.83,268.93s-178.18,112.82-287.2,122.6c-4.83.43-9.86-.25-14.51,1.77H654c-1-1.68-2.69-.91-4.06-1a496.89,496.89,0,0,1-105.9-18.59c-93.54-27.42-172.78-77.59-236.91-150.94Q199.34,590.1,184.87,426.58c-.47-5.19.25-10.56-1.77-15.59V355c1.68-1,.91-2.7,1-4.06a498.12,498.12,0,0,1,18.58-105.9c26-88.75,72.64-164.9,140.6-227.57q126-116.27,297.21-131.61C645.32-114.57,650.35-113.88,655-115.9Zm377.92,500c0-192.44-156.31-349.49-347.56-350.15-194.13-.68-350.94,155.13-352.29,347.42-1.37,194.55,155.51,352.1,348.56,352.47C876.15,734.23,1032.93,577.84,1032.93,384.11Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-2' d='M1032.93,384.11c0,193.73-156.78,350.12-351.29,349.74-193-.37-349.93-157.92-348.56-352.47C334.43,189.09,491.24,33.28,685.37,34,876.62,34.62,1032.94,191.67,1032.93,384.11ZM683,496.81q43.74,0,87.48,0c15.55,0,25.32-9.72,25.33-25.21q0-87.48,0-175c0-15.83-9.68-25.46-25.59-25.46H595.77c-15.88,0-25.57,9.64-25.58,25.46q0,87.23,0,174.45c0,16.18,9.59,25.7,25.84,25.71Z' transform='translate(-183.1 115.9)'/%3E%3Cpath class='cls-3' d='M683,496.81H596c-16.25,0-25.84-9.53-25.84-25.71q0-87.23,0-174.45c0-15.82,9.7-25.46,25.58-25.46H770.22c15.91,0,25.59,9.63,25.59,25.46q0,87.47,0,175c0,15.49-9.78,25.2-25.33,25.21Q726.74,496.84,683,496.81Z' transform='translate(-183.1 115.9)'/%3E%3C/svg%3E`;
1152
+ case "text":
1153
+ height = (0.1 * width).toFixed(2);
1154
+ return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
1155
+ case "textWithLogo":
1156
+ height = (0.25 * width).toFixed(2);
1157
+ return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%230052ff;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
1158
+ case "textLight":
1159
+ height = (0.1 * width).toFixed(2);
1160
+ return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 528.15 53.64'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3ECoinbase_Wordmark_SubBrands_ALL%3C/title%3E%3Cpath class='cls-1' d='M164.45,15a15,15,0,0,0-11.74,5.4V0h-8.64V52.92h8.5V48a15,15,0,0,0,11.88,5.62c10.37,0,18.21-8.21,18.21-19.3S174.67,15,164.45,15Zm-1.3,30.67c-6.19,0-10.73-4.83-10.73-11.31S157,23,163.22,23s10.66,4.82,10.66,11.37S169.34,45.65,163.15,45.65Zm83.31-14.91-6.34-.93c-3-.43-5.18-1.44-5.18-3.82,0-2.59,2.8-3.89,6.62-3.89,4.18,0,6.84,1.8,7.42,4.76h8.35c-.94-7.49-6.7-11.88-15.55-11.88-9.15,0-15.2,4.68-15.2,11.3,0,6.34,4,10,12,11.16l6.33.94c3.1.43,4.83,1.65,4.83,4,0,2.95-3,4.17-7.2,4.17-5.12,0-8-2.09-8.43-5.25h-8.49c.79,7.27,6.48,12.38,16.84,12.38,9.44,0,15.7-4.32,15.7-11.74C258.12,35.28,253.58,31.82,246.46,30.74Zm-27.65-2.3c0-8.06-4.9-13.46-15.27-13.46-9.79,0-15.26,5-16.34,12.6h8.57c.43-3,2.73-5.4,7.63-5.4,4.39,0,6.55,1.94,6.55,4.32,0,3.09-4,3.88-8.85,4.39-6.63.72-14.84,3-14.84,11.66,0,6.7,5,11,12.89,11,6.19,0,10.08-2.59,12-6.7.28,3.67,3,6.05,6.84,6.05h5v-7.7h-4.25Zm-8.5,9.36c0,5-4.32,8.64-9.57,8.64-3.24,0-6-1.37-6-4.25,0-3.67,4.39-4.68,8.42-5.11s6-1.22,7.13-2.88ZM281.09,15c-11.09,0-19.23,8.35-19.23,19.36,0,11.6,8.72,19.3,19.37,19.3,9,0,16.06-5.33,17.86-12.89h-9c-1.3,3.31-4.47,5.19-8.71,5.19-5.55,0-9.72-3.46-10.66-9.51H299.3V33.12C299.3,22.46,291.53,15,281.09,15Zm-9.87,15.26c1.37-5.18,5.26-7.7,9.72-7.7,4.9,0,8.64,2.8,9.51,7.7ZM19.3,23a9.84,9.84,0,0,1,9.5,7h9.14c-1.65-8.93-9-15-18.57-15A19,19,0,0,0,0,34.34c0,11.09,8.28,19.3,19.37,19.3,9.36,0,16.85-6,18.5-15H28.8a9.75,9.75,0,0,1-9.43,7.06c-6.27,0-10.66-4.83-10.66-11.31S13,23,19.3,23Zm41.11-8A19,19,0,0,0,41,34.34c0,11.09,8.28,19.3,19.37,19.3A19,19,0,0,0,79.92,34.27C79.92,23.33,71.64,15,60.41,15Zm.07,30.67c-6.19,0-10.73-4.83-10.73-11.31S54.22,23,60.41,23s10.8,4.89,10.8,11.37S66.67,45.65,60.48,45.65ZM123.41,15c-5.62,0-9.29,2.3-11.45,5.54V15.7h-8.57V52.92H112V32.69C112,27,115.63,23,121,23c5,0,8.06,3.53,8.06,8.64V52.92h8.64V31C137.66,21.6,132.84,15,123.41,15ZM92,.36a5.36,5.36,0,0,0-5.55,5.47,5.55,5.55,0,0,0,11.09,0A5.35,5.35,0,0,0,92,.36Zm-9.72,23h5.4V52.92h8.64V15.7h-14Zm298.17-7.7L366.2,52.92H372L375.29,44H392l3.33,8.88h6L386.87,15.7ZM377,39.23l6.45-17.56h.1l6.56,17.56ZM362.66,15.7l-7.88,29h-.11l-8.14-29H341l-8,28.93h-.1l-8-28.87H319L329.82,53h5.45l8.19-29.24h.11L352,53h5.66L368.1,15.7Zm135.25,0v4.86h12.32V52.92h5.6V20.56h12.32V15.7ZM467.82,52.92h25.54V48.06H473.43v-12h18.35V31.35H473.43V20.56h19.93V15.7H467.82ZM443,15.7h-5.6V52.92h24.32V48.06H443Zm-30.45,0h-5.61V52.92h24.32V48.06H412.52Z'/%3E%3C/svg%3E`;
1161
+ case "textWithLogoLight":
1162
+ height = (0.25 * width).toFixed(2);
1163
+ return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 308.44 77.61'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fefefe;%7D%3C/style%3E%3C/defs%3E%3Cpath class='cls-1' d='M142.94,20.2l-7.88,29H135l-8.15-29h-5.55l-8,28.93h-.11l-8-28.87H99.27l10.84,37.27h5.44l8.2-29.24h.1l8.41,29.24h5.66L148.39,20.2Zm17.82,0L146.48,57.42h5.82l3.28-8.88h16.65l3.34,8.88h6L167.16,20.2Zm-3.44,23.52,6.45-17.55h.11l6.56,17.55ZM278.2,20.2v4.86h12.32V57.42h5.6V25.06h12.32V20.2ZM248.11,57.42h25.54V52.55H253.71V40.61h18.35V35.85H253.71V25.06h19.94V20.2H248.11ZM223.26,20.2h-5.61V57.42H242V52.55H223.26Zm-30.46,0h-5.6V57.42h24.32V52.55H192.8Zm-154,38A19.41,19.41,0,1,1,57.92,35.57H77.47a38.81,38.81,0,1,0,0,6.47H57.92A19.39,19.39,0,0,1,38.81,58.21Z'/%3E%3C/svg%3E`;
1164
+ default:
1165
+ height = width;
1166
+ return `data:image/svg+xml,%3Csvg width='${width}' height='${height}' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E %3Crect width='1024' height='1024' fill='%230052FF'/%3E %3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z' fill='white'/%3E %3C/svg%3E `;
1167
+ }
1168
+ };
1169
+
1170
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/CoinbaseWalletProvider.js
1171
+ init_polyfills();
1172
+
1173
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/util.js
1174
+ init_polyfills();
1175
+
1176
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/scw/SCWSigner.js
1177
+ init_polyfills();
1178
+ import { hexToNumber, isAddressEqual } from "viem";
1179
+
1180
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/scw/SCWKeyManager.js
1181
+ init_polyfills();
1182
+
1183
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/storage/ScopedLocalStorage.js
1184
+ init_polyfills();
1185
+ var ScopedLocalStorage = class _ScopedLocalStorage {
1186
+ constructor(scope, module) {
1187
+ this.scope = scope;
1188
+ this.module = module;
1189
+ }
1190
+ storeObject(key, item) {
1191
+ this.setItem(key, JSON.stringify(item));
1192
+ }
1193
+ loadObject(key) {
1194
+ const item = this.getItem(key);
1195
+ return item ? JSON.parse(item) : void 0;
1196
+ }
1197
+ setItem(key, value) {
1198
+ localStorage.setItem(this.scopedKey(key), value);
1199
+ }
1200
+ getItem(key) {
1201
+ return localStorage.getItem(this.scopedKey(key));
1202
+ }
1203
+ removeItem(key) {
1204
+ localStorage.removeItem(this.scopedKey(key));
1205
+ }
1206
+ clear() {
1207
+ const prefix = this.scopedKey("");
1208
+ const keysToRemove = [];
1209
+ for (let i3 = 0; i3 < localStorage.length; i3++) {
1210
+ const key = localStorage.key(i3);
1211
+ if (typeof key === "string" && key.startsWith(prefix)) {
1212
+ keysToRemove.push(key);
1213
+ }
1214
+ }
1215
+ keysToRemove.forEach((key) => localStorage.removeItem(key));
1216
+ }
1217
+ scopedKey(key) {
1218
+ return `-${this.scope}${this.module ? `:${this.module}` : ""}:${key}`;
1219
+ }
1220
+ static clearAll() {
1221
+ new _ScopedLocalStorage("CBWSDK").clear();
1222
+ new _ScopedLocalStorage("walletlink").clear();
1223
+ }
1224
+ };
1225
+
1226
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/cipher.js
1227
+ init_polyfills();
1228
+
1229
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/type/util.js
1230
+ init_polyfills();
1231
+
1232
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/error/errors.js
1233
+ init_polyfills();
1234
+
1235
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/error/constants.js
1236
+ init_polyfills();
1237
+ var standardErrorCodes = {
1238
+ rpc: {
1239
+ invalidInput: -32e3,
1240
+ resourceNotFound: -32001,
1241
+ resourceUnavailable: -32002,
1242
+ transactionRejected: -32003,
1243
+ methodNotSupported: -32004,
1244
+ limitExceeded: -32005,
1245
+ parse: -32700,
1246
+ invalidRequest: -32600,
1247
+ methodNotFound: -32601,
1248
+ invalidParams: -32602,
1249
+ internal: -32603
1250
+ },
1251
+ provider: {
1252
+ userRejectedRequest: 4001,
1253
+ unauthorized: 4100,
1254
+ unsupportedMethod: 4200,
1255
+ disconnected: 4900,
1256
+ chainDisconnected: 4901,
1257
+ unsupportedChain: 4902
1258
+ }
1259
+ };
1260
+ var errorValues = {
1261
+ "-32700": {
1262
+ standard: "JSON RPC 2.0",
1263
+ message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
1264
+ },
1265
+ "-32600": {
1266
+ standard: "JSON RPC 2.0",
1267
+ message: "The JSON sent is not a valid Request object."
1268
+ },
1269
+ "-32601": {
1270
+ standard: "JSON RPC 2.0",
1271
+ message: "The method does not exist / is not available."
1272
+ },
1273
+ "-32602": {
1274
+ standard: "JSON RPC 2.0",
1275
+ message: "Invalid method parameter(s)."
1276
+ },
1277
+ "-32603": {
1278
+ standard: "JSON RPC 2.0",
1279
+ message: "Internal JSON-RPC error."
1280
+ },
1281
+ "-32000": {
1282
+ standard: "EIP-1474",
1283
+ message: "Invalid input."
1284
+ },
1285
+ "-32001": {
1286
+ standard: "EIP-1474",
1287
+ message: "Resource not found."
1288
+ },
1289
+ "-32002": {
1290
+ standard: "EIP-1474",
1291
+ message: "Resource unavailable."
1292
+ },
1293
+ "-32003": {
1294
+ standard: "EIP-1474",
1295
+ message: "Transaction rejected."
1296
+ },
1297
+ "-32004": {
1298
+ standard: "EIP-1474",
1299
+ message: "Method not supported."
1300
+ },
1301
+ "-32005": {
1302
+ standard: "EIP-1474",
1303
+ message: "Request limit exceeded."
1304
+ },
1305
+ "4001": {
1306
+ standard: "EIP-1193",
1307
+ message: "User rejected the request."
1308
+ },
1309
+ "4100": {
1310
+ standard: "EIP-1193",
1311
+ message: "The requested account and/or method has not been authorized by the user."
1312
+ },
1313
+ "4200": {
1314
+ standard: "EIP-1193",
1315
+ message: "The requested method is not supported by this Ethereum provider."
1316
+ },
1317
+ "4900": {
1318
+ standard: "EIP-1193",
1319
+ message: "The provider is disconnected from all chains."
1320
+ },
1321
+ "4901": {
1322
+ standard: "EIP-1193",
1323
+ message: "The provider is disconnected from the specified chain."
1324
+ },
1325
+ "4902": {
1326
+ standard: "EIP-3085",
1327
+ message: "Unrecognized chain ID."
1328
+ }
1329
+ };
1330
+
1331
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/error/utils.js
1332
+ init_polyfills();
1333
+ var FALLBACK_MESSAGE = "Unspecified error message.";
1334
+ var JSON_RPC_SERVER_ERROR_MESSAGE = "Unspecified server error.";
1335
+ function getMessageFromCode(code, fallbackMessage = FALLBACK_MESSAGE) {
1336
+ if (code && Number.isInteger(code)) {
1337
+ const codeString = code.toString();
1338
+ if (hasKey(errorValues, codeString)) {
1339
+ return errorValues[codeString].message;
1340
+ }
1341
+ if (isJsonRpcServerError(code)) {
1342
+ return JSON_RPC_SERVER_ERROR_MESSAGE;
1343
+ }
1344
+ }
1345
+ return fallbackMessage;
1346
+ }
1347
+ function isValidCode(code) {
1348
+ if (!Number.isInteger(code)) {
1349
+ return false;
1350
+ }
1351
+ const codeString = code.toString();
1352
+ if (errorValues[codeString]) {
1353
+ return true;
1354
+ }
1355
+ if (isJsonRpcServerError(code)) {
1356
+ return true;
1357
+ }
1358
+ return false;
1359
+ }
1360
+ function serialize(error, { shouldIncludeStack = false } = {}) {
1361
+ const serialized = {};
1362
+ if (error && typeof error === "object" && !Array.isArray(error) && hasKey(error, "code") && isValidCode(error.code)) {
1363
+ const _error = error;
1364
+ serialized.code = _error.code;
1365
+ if (_error.message && typeof _error.message === "string") {
1366
+ serialized.message = _error.message;
1367
+ if (hasKey(_error, "data")) {
1368
+ serialized.data = _error.data;
1369
+ }
1370
+ } else {
1371
+ serialized.message = getMessageFromCode(serialized.code);
1372
+ serialized.data = { originalError: assignOriginalError(error) };
1373
+ }
1374
+ } else {
1375
+ serialized.code = standardErrorCodes.rpc.internal;
1376
+ serialized.message = hasStringProperty(error, "message") ? error.message : FALLBACK_MESSAGE;
1377
+ serialized.data = { originalError: assignOriginalError(error) };
1378
+ }
1379
+ if (shouldIncludeStack) {
1380
+ serialized.stack = hasStringProperty(error, "stack") ? error.stack : void 0;
1381
+ }
1382
+ return serialized;
1383
+ }
1384
+ function isJsonRpcServerError(code) {
1385
+ return code >= -32099 && code <= -32e3;
1386
+ }
1387
+ function assignOriginalError(error) {
1388
+ if (error && typeof error === "object" && !Array.isArray(error)) {
1389
+ return Object.assign({}, error);
1390
+ }
1391
+ return error;
1392
+ }
1393
+ function hasKey(obj, key) {
1394
+ return Object.prototype.hasOwnProperty.call(obj, key);
1395
+ }
1396
+ function hasStringProperty(obj, prop) {
1397
+ return typeof obj === "object" && obj !== null && prop in obj && typeof obj[prop] === "string";
1398
+ }
1399
+
1400
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/error/errors.js
1401
+ var standardErrors = {
1402
+ rpc: {
1403
+ parse: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.parse, arg),
1404
+ invalidRequest: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.invalidRequest, arg),
1405
+ invalidParams: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.invalidParams, arg),
1406
+ methodNotFound: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.methodNotFound, arg),
1407
+ internal: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.internal, arg),
1408
+ server: (opts) => {
1409
+ if (!opts || typeof opts !== "object" || Array.isArray(opts)) {
1410
+ throw new Error("Ethereum RPC Server errors must provide single object argument.");
1411
+ }
1412
+ const { code } = opts;
1413
+ if (!Number.isInteger(code) || code > -32005 || code < -32099) {
1414
+ throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');
1415
+ }
1416
+ return getEthJsonRpcError(code, opts);
1417
+ },
1418
+ invalidInput: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.invalidInput, arg),
1419
+ resourceNotFound: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.resourceNotFound, arg),
1420
+ resourceUnavailable: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.resourceUnavailable, arg),
1421
+ transactionRejected: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.transactionRejected, arg),
1422
+ methodNotSupported: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.methodNotSupported, arg),
1423
+ limitExceeded: (arg) => getEthJsonRpcError(standardErrorCodes.rpc.limitExceeded, arg)
1424
+ },
1425
+ provider: {
1426
+ userRejectedRequest: (arg) => {
1427
+ return getEthProviderError(standardErrorCodes.provider.userRejectedRequest, arg);
1428
+ },
1429
+ unauthorized: (arg) => {
1430
+ return getEthProviderError(standardErrorCodes.provider.unauthorized, arg);
1431
+ },
1432
+ unsupportedMethod: (arg) => {
1433
+ return getEthProviderError(standardErrorCodes.provider.unsupportedMethod, arg);
1434
+ },
1435
+ disconnected: (arg) => {
1436
+ return getEthProviderError(standardErrorCodes.provider.disconnected, arg);
1437
+ },
1438
+ chainDisconnected: (arg) => {
1439
+ return getEthProviderError(standardErrorCodes.provider.chainDisconnected, arg);
1440
+ },
1441
+ unsupportedChain: (arg) => {
1442
+ return getEthProviderError(standardErrorCodes.provider.unsupportedChain, arg);
1443
+ },
1444
+ custom: (opts) => {
1445
+ if (!opts || typeof opts !== "object" || Array.isArray(opts)) {
1446
+ throw new Error("Ethereum Provider custom errors must provide single object argument.");
1447
+ }
1448
+ const { code, message, data } = opts;
1449
+ if (!message || typeof message !== "string") {
1450
+ throw new Error('"message" must be a nonempty string');
1451
+ }
1452
+ return new EthereumProviderError(code, message, data);
1453
+ }
1454
+ }
1455
+ };
1456
+ function getEthJsonRpcError(code, arg) {
1457
+ const [message, data] = parseOpts(arg);
1458
+ return new EthereumRpcError(code, message || getMessageFromCode(code), data);
1459
+ }
1460
+ function getEthProviderError(code, arg) {
1461
+ const [message, data] = parseOpts(arg);
1462
+ return new EthereumProviderError(code, message || getMessageFromCode(code), data);
1463
+ }
1464
+ function parseOpts(arg) {
1465
+ if (arg) {
1466
+ if (typeof arg === "string") {
1467
+ return [arg];
1468
+ } else if (typeof arg === "object" && !Array.isArray(arg)) {
1469
+ const { message, data } = arg;
1470
+ if (message && typeof message !== "string") {
1471
+ throw new Error("Must specify string message.");
1472
+ }
1473
+ return [message || void 0, data];
1474
+ }
1475
+ }
1476
+ return [];
1477
+ }
1478
+ var EthereumRpcError = class extends Error {
1479
+ constructor(code, message, data) {
1480
+ if (!Number.isInteger(code)) {
1481
+ throw new Error('"code" must be an integer.');
1482
+ }
1483
+ if (!message || typeof message !== "string") {
1484
+ throw new Error('"message" must be a nonempty string.');
1485
+ }
1486
+ super(message);
1487
+ this.code = code;
1488
+ if (data !== void 0) {
1489
+ this.data = data;
1490
+ }
1491
+ }
1492
+ };
1493
+ var EthereumProviderError = class extends EthereumRpcError {
1494
+ /**
1495
+ * Create an Ethereum Provider JSON-RPC error.
1496
+ * `code` must be an integer in the 1000 <= 4999 range.
1497
+ */
1498
+ constructor(code, message, data) {
1499
+ if (!isValidEthProviderCode(code)) {
1500
+ throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
1501
+ }
1502
+ super(code, message, data);
1503
+ }
1504
+ };
1505
+ function isValidEthProviderCode(code) {
1506
+ return Number.isInteger(code) && code >= 1e3 && code <= 4999;
1507
+ }
1508
+
1509
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/type/index.js
1510
+ init_polyfills();
1511
+ function OpaqueType() {
1512
+ return (value) => value;
1513
+ }
1514
+ var HexString = OpaqueType();
1515
+ var AddressString = OpaqueType();
1516
+ var BigIntString = OpaqueType();
1517
+ function IntNumber(num) {
1518
+ return Math.floor(num);
1519
+ }
1520
+ var RegExpString = OpaqueType();
1521
+
1522
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/type/util.js
1523
+ var INT_STRING_REGEX = /^[0-9]*$/;
1524
+ var HEXADECIMAL_STRING_REGEX = /^[a-f0-9]*$/;
1525
+ function randomBytesHex(length) {
1526
+ return uint8ArrayToHex(crypto.getRandomValues(new Uint8Array(length)));
1527
+ }
1528
+ function uint8ArrayToHex(value) {
1529
+ return [...value].map((b) => b.toString(16).padStart(2, "0")).join("");
1530
+ }
1531
+ function hexStringToUint8Array(hexString) {
1532
+ return new Uint8Array(hexString.match(/.{1,2}/g).map((byte) => Number.parseInt(byte, 16)));
1533
+ }
1534
+ function hexStringFromBuffer(buf, includePrefix = false) {
1535
+ const hex = buf.toString("hex");
1536
+ return HexString(includePrefix ? `0x${hex}` : hex);
1537
+ }
1538
+ function encodeToHexString(str) {
1539
+ return hexStringFromBuffer(ensureBuffer(str), true);
1540
+ }
1541
+ function bigIntStringFromBigInt(bi) {
1542
+ return BigIntString(bi.toString(10));
1543
+ }
1544
+ function hexStringFromNumber(num) {
1545
+ return HexString(`0x${BigInt(num).toString(16)}`);
1546
+ }
1547
+ function has0xPrefix(str) {
1548
+ return str.startsWith("0x") || str.startsWith("0X");
1549
+ }
1550
+ function strip0x(hex) {
1551
+ if (has0xPrefix(hex)) {
1552
+ return hex.slice(2);
1553
+ }
1554
+ return hex;
1555
+ }
1556
+ function prepend0x(hex) {
1557
+ if (has0xPrefix(hex)) {
1558
+ return `0x${hex.slice(2)}`;
1559
+ }
1560
+ return `0x${hex}`;
1561
+ }
1562
+ function isHexString(hex) {
1563
+ if (typeof hex !== "string") {
1564
+ return false;
1565
+ }
1566
+ const s3 = strip0x(hex).toLowerCase();
1567
+ return HEXADECIMAL_STRING_REGEX.test(s3);
1568
+ }
1569
+ function ensureHexString(hex, includePrefix = false) {
1570
+ if (typeof hex === "string") {
1571
+ const s3 = strip0x(hex).toLowerCase();
1572
+ if (HEXADECIMAL_STRING_REGEX.test(s3)) {
1573
+ return HexString(includePrefix ? `0x${s3}` : s3);
1574
+ }
1575
+ }
1576
+ throw standardErrors.rpc.invalidParams(`"${String(hex)}" is not a hexadecimal string`);
1577
+ }
1578
+ function ensureEvenLengthHexString(hex, includePrefix = false) {
1579
+ let h3 = ensureHexString(hex, false);
1580
+ if (h3.length % 2 === 1) {
1581
+ h3 = HexString(`0${h3}`);
1582
+ }
1583
+ return includePrefix ? HexString(`0x${h3}`) : h3;
1584
+ }
1585
+ function ensureAddressString(str) {
1586
+ if (typeof str === "string") {
1587
+ const s3 = strip0x(str).toLowerCase();
1588
+ if (isHexString(s3) && s3.length === 40) {
1589
+ return AddressString(prepend0x(s3));
1590
+ }
1591
+ }
1592
+ throw standardErrors.rpc.invalidParams(`Invalid Ethereum address: ${String(str)}`);
1593
+ }
1594
+ function ensureBuffer(str) {
1595
+ if (Buffer.isBuffer(str)) {
1596
+ return str;
1597
+ }
1598
+ if (typeof str === "string") {
1599
+ if (isHexString(str)) {
1600
+ const s3 = ensureEvenLengthHexString(str, false);
1601
+ return Buffer.from(s3, "hex");
1602
+ }
1603
+ return Buffer.from(str, "utf8");
1604
+ }
1605
+ throw standardErrors.rpc.invalidParams(`Not binary data: ${String(str)}`);
1606
+ }
1607
+ function ensureIntNumber(num) {
1608
+ if (typeof num === "number" && Number.isInteger(num)) {
1609
+ return IntNumber(num);
1610
+ }
1611
+ if (typeof num === "string") {
1612
+ if (INT_STRING_REGEX.test(num)) {
1613
+ return IntNumber(Number(num));
1614
+ }
1615
+ if (isHexString(num)) {
1616
+ return IntNumber(Number(BigInt(ensureEvenLengthHexString(num, true))));
1617
+ }
1618
+ }
1619
+ throw standardErrors.rpc.invalidParams(`Not an integer: ${String(num)}`);
1620
+ }
1621
+ function ensureBigInt(val) {
1622
+ if (val !== null && (typeof val === "bigint" || isBigNumber(val))) {
1623
+ return BigInt(val.toString(10));
1624
+ }
1625
+ if (typeof val === "number") {
1626
+ return BigInt(ensureIntNumber(val));
1627
+ }
1628
+ if (typeof val === "string") {
1629
+ if (INT_STRING_REGEX.test(val)) {
1630
+ return BigInt(val);
1631
+ }
1632
+ if (isHexString(val)) {
1633
+ return BigInt(ensureEvenLengthHexString(val, true));
1634
+ }
1635
+ }
1636
+ throw standardErrors.rpc.invalidParams(`Not an integer: ${String(val)}`);
1637
+ }
1638
+ function ensureParsedJSONObject(val) {
1639
+ if (typeof val === "string") {
1640
+ return JSON.parse(val);
1641
+ }
1642
+ if (typeof val === "object") {
1643
+ return val;
1644
+ }
1645
+ throw standardErrors.rpc.invalidParams(`Not a JSON string or an object: ${String(val)}`);
1646
+ }
1647
+ function isBigNumber(val) {
1648
+ if (val == null || typeof val.constructor !== "function") {
1649
+ return false;
1650
+ }
1651
+ const { constructor } = val;
1652
+ return typeof constructor.config === "function" && typeof constructor.EUCLID === "number";
1653
+ }
1654
+ function getFavicon() {
1655
+ const el = document.querySelector('link[sizes="192x192"]') || document.querySelector('link[sizes="180x180"]') || document.querySelector('link[rel="icon"]') || document.querySelector('link[rel="shortcut icon"]');
1656
+ const { protocol, host } = document.location;
1657
+ const href = el ? el.getAttribute("href") : null;
1658
+ if (!href || href.startsWith("javascript:") || href.startsWith("vbscript:")) {
1659
+ return `${protocol}//${host}/favicon.ico`;
1660
+ }
1661
+ if (href.startsWith("http://") || href.startsWith("https://") || href.startsWith("data:")) {
1662
+ return href;
1663
+ }
1664
+ if (href.startsWith("//")) {
1665
+ return protocol + href;
1666
+ }
1667
+ return `${protocol}//${host}${href}`;
1668
+ }
1669
+
1670
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/cipher.js
1671
+ async function generateKeyPair() {
1672
+ return crypto.subtle.generateKey({
1673
+ name: "ECDH",
1674
+ namedCurve: "P-256"
1675
+ }, true, ["deriveKey"]);
1676
+ }
1677
+ async function deriveSharedSecret(ownPrivateKey, peerPublicKey) {
1678
+ return crypto.subtle.deriveKey({
1679
+ name: "ECDH",
1680
+ public: peerPublicKey
1681
+ }, ownPrivateKey, {
1682
+ name: "AES-GCM",
1683
+ length: 256
1684
+ }, false, ["encrypt", "decrypt"]);
1685
+ }
1686
+ async function encrypt(sharedSecret, plainText) {
1687
+ const iv = crypto.getRandomValues(new Uint8Array(12));
1688
+ const cipherText = await crypto.subtle.encrypt({
1689
+ name: "AES-GCM",
1690
+ iv
1691
+ }, sharedSecret, new TextEncoder().encode(plainText));
1692
+ return { iv, cipherText };
1693
+ }
1694
+ async function decrypt(sharedSecret, { iv, cipherText }) {
1695
+ const plainText = await crypto.subtle.decrypt({
1696
+ name: "AES-GCM",
1697
+ iv
1698
+ }, sharedSecret, cipherText);
1699
+ return new TextDecoder().decode(plainText);
1700
+ }
1701
+ function getFormat(keyType) {
1702
+ switch (keyType) {
1703
+ case "public":
1704
+ return "spki";
1705
+ case "private":
1706
+ return "pkcs8";
1707
+ }
1708
+ }
1709
+ async function exportKeyToHexString(type, key) {
1710
+ const format = getFormat(type);
1711
+ const exported = await crypto.subtle.exportKey(format, key);
1712
+ return uint8ArrayToHex(new Uint8Array(exported));
1713
+ }
1714
+ async function importKeyFromHexString(type, hexString) {
1715
+ const format = getFormat(type);
1716
+ const arrayBuffer = hexStringToUint8Array(hexString).buffer;
1717
+ return await crypto.subtle.importKey(format, new Uint8Array(arrayBuffer), {
1718
+ name: "ECDH",
1719
+ namedCurve: "P-256"
1720
+ }, true, type === "private" ? ["deriveKey"] : []);
1721
+ }
1722
+ async function encryptContent(content, sharedSecret) {
1723
+ const serialized = JSON.stringify(content, (_2, value) => {
1724
+ if (!(value instanceof Error))
1725
+ return value;
1726
+ const error = value;
1727
+ return Object.assign(Object.assign({}, error.code ? { code: error.code } : {}), { message: error.message });
1728
+ });
1729
+ return encrypt(sharedSecret, serialized);
1730
+ }
1731
+ async function decryptContent(encryptedData, sharedSecret) {
1732
+ return JSON.parse(await decrypt(sharedSecret, encryptedData));
1733
+ }
1734
+
1735
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/scw/SCWKeyManager.js
1736
+ var OWN_PRIVATE_KEY = {
1737
+ storageKey: "ownPrivateKey",
1738
+ keyType: "private"
1739
+ };
1740
+ var OWN_PUBLIC_KEY = {
1741
+ storageKey: "ownPublicKey",
1742
+ keyType: "public"
1743
+ };
1744
+ var PEER_PUBLIC_KEY = {
1745
+ storageKey: "peerPublicKey",
1746
+ keyType: "public"
1747
+ };
1748
+ var SCWKeyManager = class {
1749
+ constructor() {
1750
+ this.storage = new ScopedLocalStorage("CBWSDK", "SCWKeyManager");
1751
+ this.ownPrivateKey = null;
1752
+ this.ownPublicKey = null;
1753
+ this.peerPublicKey = null;
1754
+ this.sharedSecret = null;
1755
+ }
1756
+ async getOwnPublicKey() {
1757
+ await this.loadKeysIfNeeded();
1758
+ return this.ownPublicKey;
1759
+ }
1760
+ // returns null if the shared secret is not yet derived
1761
+ async getSharedSecret() {
1762
+ await this.loadKeysIfNeeded();
1763
+ return this.sharedSecret;
1764
+ }
1765
+ async setPeerPublicKey(key) {
1766
+ this.sharedSecret = null;
1767
+ this.peerPublicKey = key;
1768
+ await this.storeKey(PEER_PUBLIC_KEY, key);
1769
+ await this.loadKeysIfNeeded();
1770
+ }
1771
+ async clear() {
1772
+ this.ownPrivateKey = null;
1773
+ this.ownPublicKey = null;
1774
+ this.peerPublicKey = null;
1775
+ this.sharedSecret = null;
1776
+ this.storage.removeItem(OWN_PUBLIC_KEY.storageKey);
1777
+ this.storage.removeItem(OWN_PRIVATE_KEY.storageKey);
1778
+ this.storage.removeItem(PEER_PUBLIC_KEY.storageKey);
1779
+ }
1780
+ async generateKeyPair() {
1781
+ const newKeyPair = await generateKeyPair();
1782
+ this.ownPrivateKey = newKeyPair.privateKey;
1783
+ this.ownPublicKey = newKeyPair.publicKey;
1784
+ await this.storeKey(OWN_PRIVATE_KEY, newKeyPair.privateKey);
1785
+ await this.storeKey(OWN_PUBLIC_KEY, newKeyPair.publicKey);
1786
+ }
1787
+ async loadKeysIfNeeded() {
1788
+ if (this.ownPrivateKey === null) {
1789
+ this.ownPrivateKey = await this.loadKey(OWN_PRIVATE_KEY);
1790
+ }
1791
+ if (this.ownPublicKey === null) {
1792
+ this.ownPublicKey = await this.loadKey(OWN_PUBLIC_KEY);
1793
+ }
1794
+ if (this.ownPrivateKey === null || this.ownPublicKey === null) {
1795
+ await this.generateKeyPair();
1796
+ }
1797
+ if (this.peerPublicKey === null) {
1798
+ this.peerPublicKey = await this.loadKey(PEER_PUBLIC_KEY);
1799
+ }
1800
+ if (this.sharedSecret === null) {
1801
+ if (this.ownPrivateKey === null || this.peerPublicKey === null)
1802
+ return;
1803
+ this.sharedSecret = await deriveSharedSecret(this.ownPrivateKey, this.peerPublicKey);
1804
+ }
1805
+ }
1806
+ // storage methods
1807
+ async loadKey(item) {
1808
+ const key = this.storage.getItem(item.storageKey);
1809
+ if (!key)
1810
+ return null;
1811
+ return importKeyFromHexString(item.keyType, key);
1812
+ }
1813
+ async storeKey(item, key) {
1814
+ const hexString = await exportKeyToHexString(item.keyType, key);
1815
+ this.storage.setItem(item.storageKey, hexString);
1816
+ }
1817
+ };
1818
+
1819
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils.js
1820
+ init_polyfills();
1821
+ import { isAddress } from "viem";
1822
+ function assertGetCapabilitiesParams(params) {
1823
+ if (!params || !Array.isArray(params) || params.length !== 1 && params.length !== 2) {
1824
+ throw standardErrors.rpc.invalidParams();
1825
+ }
1826
+ if (typeof params[0] !== "string" || !isAddress(params[0])) {
1827
+ throw standardErrors.rpc.invalidParams();
1828
+ }
1829
+ if (params.length === 2) {
1830
+ if (!Array.isArray(params[1])) {
1831
+ throw standardErrors.rpc.invalidParams();
1832
+ }
1833
+ for (const param of params[1]) {
1834
+ if (typeof param !== "string" || !param.startsWith("0x")) {
1835
+ throw standardErrors.rpc.invalidParams();
1836
+ }
1837
+ }
1838
+ }
1839
+ }
1840
+
1841
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/provider.js
1842
+ init_polyfills();
1843
+
1844
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sdk-info.js
1845
+ init_polyfills();
1846
+ var VERSION = "4.3.7";
1847
+ var NAME = "@coinbase/wallet-sdk";
1848
+
1849
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/provider.js
1850
+ async function fetchRPCRequest(request, rpcUrl) {
1851
+ const requestBody = Object.assign(Object.assign({}, request), { jsonrpc: "2.0", id: crypto.randomUUID() });
1852
+ const res = await window.fetch(rpcUrl, {
1853
+ method: "POST",
1854
+ body: JSON.stringify(requestBody),
1855
+ mode: "cors",
1856
+ headers: {
1857
+ "Content-Type": "application/json",
1858
+ "X-Cbw-Sdk-Version": VERSION,
1859
+ "X-Cbw-Sdk-Platform": NAME
1860
+ }
1861
+ });
1862
+ const { result, error } = await res.json();
1863
+ if (error)
1864
+ throw error;
1865
+ return result;
1866
+ }
1867
+ function getCoinbaseInjectedLegacyProvider() {
1868
+ const window2 = globalThis;
1869
+ return window2.coinbaseWalletExtension;
1870
+ }
1871
+ function getInjectedEthereum() {
1872
+ var _a, _b;
1873
+ try {
1874
+ const window2 = globalThis;
1875
+ return (_b = (_a = window2.top) === null || _a === void 0 ? void 0 : _a.ethereum) !== null && _b !== void 0 ? _b : window2.ethereum;
1876
+ } catch (_c) {
1877
+ return void 0;
1878
+ }
1879
+ }
1880
+ function getCoinbaseInjectedProvider({ metadata, preference }) {
1881
+ var _a, _b;
1882
+ const { appName, appLogoUrl, appChainIds } = metadata;
1883
+ if (preference.options !== "smartWalletOnly") {
1884
+ const extension = getCoinbaseInjectedLegacyProvider();
1885
+ if (extension) {
1886
+ (_a = extension.setAppInfo) === null || _a === void 0 ? void 0 : _a.call(extension, appName, appLogoUrl, appChainIds, preference);
1887
+ return extension;
1888
+ }
1889
+ }
1890
+ const ethereum = getInjectedEthereum();
1891
+ if (ethereum === null || ethereum === void 0 ? void 0 : ethereum.isCoinbaseBrowser) {
1892
+ (_b = ethereum.setAppInfo) === null || _b === void 0 ? void 0 : _b.call(ethereum, appName, appLogoUrl, appChainIds, preference);
1893
+ return ethereum;
1894
+ }
1895
+ return void 0;
1896
+ }
1897
+ function checkErrorForInvalidRequestArgs(args) {
1898
+ if (!args || typeof args !== "object" || Array.isArray(args)) {
1899
+ throw standardErrors.rpc.invalidParams({
1900
+ message: "Expected a single, non-array, object argument.",
1901
+ data: args
1902
+ });
1903
+ }
1904
+ const { method, params } = args;
1905
+ if (typeof method !== "string" || method.length === 0) {
1906
+ throw standardErrors.rpc.invalidParams({
1907
+ message: "'args.method' must be a non-empty string.",
1908
+ data: args
1909
+ });
1910
+ }
1911
+ if (params !== void 0 && !Array.isArray(params) && (typeof params !== "object" || params === null)) {
1912
+ throw standardErrors.rpc.invalidParams({
1913
+ message: "'args.params' must be an object or array if provided.",
1914
+ data: args
1915
+ });
1916
+ }
1917
+ switch (method) {
1918
+ case "eth_sign":
1919
+ case "eth_signTypedData_v2":
1920
+ case "eth_subscribe":
1921
+ case "eth_unsubscribe":
1922
+ throw standardErrors.provider.unsupportedMethod();
1923
+ }
1924
+ }
1925
+
1926
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/scw/SCWSigner.js
1927
+ var ACCOUNTS_KEY = "accounts";
1928
+ var ACTIVE_CHAIN_STORAGE_KEY = "activeChain";
1929
+ var AVAILABLE_CHAINS_STORAGE_KEY = "availableChains";
1930
+ var WALLET_CAPABILITIES_STORAGE_KEY = "walletCapabilities";
1931
+ var SCWSigner = class {
1932
+ constructor(params) {
1933
+ var _a, _b, _c;
1934
+ this.metadata = params.metadata;
1935
+ this.communicator = params.communicator;
1936
+ this.callback = params.callback;
1937
+ this.keyManager = new SCWKeyManager();
1938
+ this.storage = new ScopedLocalStorage("CBWSDK", "SCWStateManager");
1939
+ this.accounts = (_a = this.storage.loadObject(ACCOUNTS_KEY)) !== null && _a !== void 0 ? _a : [];
1940
+ this.chain = this.storage.loadObject(ACTIVE_CHAIN_STORAGE_KEY) || {
1941
+ id: (_c = (_b = params.metadata.appChainIds) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : 1
1942
+ };
1943
+ this.handshake = this.handshake.bind(this);
1944
+ this.request = this.request.bind(this);
1945
+ this.createRequestMessage = this.createRequestMessage.bind(this);
1946
+ this.decryptResponseMessage = this.decryptResponseMessage.bind(this);
1947
+ }
1948
+ async handshake(args) {
1949
+ var _a, _b, _c, _d;
1950
+ await ((_b = (_a = this.communicator).waitForPopupLoaded) === null || _b === void 0 ? void 0 : _b.call(_a));
1951
+ const handshakeMessage = await this.createRequestMessage({
1952
+ handshake: {
1953
+ method: args.method,
1954
+ params: Object.assign({}, this.metadata, (_c = args.params) !== null && _c !== void 0 ? _c : {})
1955
+ }
1956
+ });
1957
+ const response = await this.communicator.postRequestAndWaitForResponse(handshakeMessage);
1958
+ if ("failure" in response.content)
1959
+ throw response.content.failure;
1960
+ const peerPublicKey = await importKeyFromHexString("public", response.sender);
1961
+ await this.keyManager.setPeerPublicKey(peerPublicKey);
1962
+ const decrypted = await this.decryptResponseMessage(response);
1963
+ const result = decrypted.result;
1964
+ if ("error" in result)
1965
+ throw result.error;
1966
+ switch (args.method) {
1967
+ case "eth_requestAccounts": {
1968
+ const accounts = result.value;
1969
+ this.accounts = accounts;
1970
+ this.storage.storeObject(ACCOUNTS_KEY, accounts);
1971
+ (_d = this.callback) === null || _d === void 0 ? void 0 : _d.call(this, "accountsChanged", accounts);
1972
+ break;
1973
+ }
1974
+ }
1975
+ }
1976
+ async request(request) {
1977
+ var _a;
1978
+ if (this.accounts.length === 0) {
1979
+ switch (request.method) {
1980
+ case "wallet_sendCalls":
1981
+ return this.sendRequestToPopup(request);
1982
+ default:
1983
+ throw standardErrors.provider.unauthorized();
1984
+ }
1985
+ }
1986
+ switch (request.method) {
1987
+ case "eth_requestAccounts":
1988
+ (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, "connect", { chainId: hexStringFromNumber(this.chain.id) });
1989
+ return this.accounts;
1990
+ case "eth_accounts":
1991
+ return this.accounts;
1992
+ case "eth_coinbase":
1993
+ return this.accounts[0];
1994
+ case "net_version":
1995
+ return this.chain.id;
1996
+ case "eth_chainId":
1997
+ return hexStringFromNumber(this.chain.id);
1998
+ case "wallet_getCapabilities":
1999
+ return this.handleGetCapabilitiesRequest(request);
2000
+ case "wallet_switchEthereumChain":
2001
+ return this.handleSwitchChainRequest(request);
2002
+ case "eth_ecRecover":
2003
+ case "personal_sign":
2004
+ case "wallet_sign":
2005
+ case "personal_ecRecover":
2006
+ case "eth_signTransaction":
2007
+ case "eth_sendTransaction":
2008
+ case "eth_signTypedData_v1":
2009
+ case "eth_signTypedData_v3":
2010
+ case "eth_signTypedData_v4":
2011
+ case "eth_signTypedData":
2012
+ case "wallet_addEthereumChain":
2013
+ case "wallet_watchAsset":
2014
+ case "wallet_sendCalls":
2015
+ case "wallet_showCallsStatus":
2016
+ case "wallet_grantPermissions":
2017
+ return this.sendRequestToPopup(request);
2018
+ default:
2019
+ if (!this.chain.rpcUrl)
2020
+ throw standardErrors.rpc.internal("No RPC URL set for chain");
2021
+ return fetchRPCRequest(request, this.chain.rpcUrl);
2022
+ }
2023
+ }
2024
+ async sendRequestToPopup(request) {
2025
+ var _a, _b;
2026
+ await ((_b = (_a = this.communicator).waitForPopupLoaded) === null || _b === void 0 ? void 0 : _b.call(_a));
2027
+ const response = await this.sendEncryptedRequest(request);
2028
+ const decrypted = await this.decryptResponseMessage(response);
2029
+ const result = decrypted.result;
2030
+ if ("error" in result)
2031
+ throw result.error;
2032
+ return result.value;
2033
+ }
2034
+ async cleanup() {
2035
+ var _a, _b;
2036
+ this.storage.clear();
2037
+ await this.keyManager.clear();
2038
+ this.accounts = [];
2039
+ this.chain = {
2040
+ id: (_b = (_a = this.metadata.appChainIds) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 1
2041
+ };
2042
+ }
2043
+ /**
2044
+ * @returns `null` if the request was successful.
2045
+ * https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain
2046
+ */
2047
+ async handleSwitchChainRequest(request) {
2048
+ var _a;
2049
+ const params = request.params;
2050
+ if (!params || !((_a = params[0]) === null || _a === void 0 ? void 0 : _a.chainId)) {
2051
+ throw standardErrors.rpc.invalidParams();
2052
+ }
2053
+ const chainId = ensureIntNumber(params[0].chainId);
2054
+ const localResult = this.updateChain(chainId);
2055
+ if (localResult)
2056
+ return null;
2057
+ const popupResult = await this.sendRequestToPopup(request);
2058
+ if (popupResult === null) {
2059
+ this.updateChain(chainId);
2060
+ }
2061
+ return popupResult;
2062
+ }
2063
+ async handleGetCapabilitiesRequest(request) {
2064
+ assertGetCapabilitiesParams(request.params);
2065
+ const requestedAccount = request.params[0];
2066
+ const filterChainIds = request.params[1];
2067
+ if (!this.accounts.some((account) => isAddressEqual(account, requestedAccount))) {
2068
+ throw standardErrors.provider.unauthorized("no active account found");
2069
+ }
2070
+ const capabilities = this.storage.loadObject(WALLET_CAPABILITIES_STORAGE_KEY);
2071
+ if (!capabilities) {
2072
+ return {};
2073
+ }
2074
+ if (!filterChainIds || filterChainIds.length === 0) {
2075
+ return capabilities;
2076
+ }
2077
+ const filterChainNumbers = new Set(filterChainIds.map((chainId) => hexToNumber(chainId)));
2078
+ const filteredCapabilities = Object.fromEntries(Object.entries(capabilities).filter(([capabilityKey]) => {
2079
+ try {
2080
+ const capabilityChainNumber = hexToNumber(capabilityKey);
2081
+ return filterChainNumbers.has(capabilityChainNumber);
2082
+ } catch (_a) {
2083
+ return false;
2084
+ }
2085
+ }));
2086
+ return filteredCapabilities;
2087
+ }
2088
+ async sendEncryptedRequest(request) {
2089
+ const sharedSecret = await this.keyManager.getSharedSecret();
2090
+ if (!sharedSecret) {
2091
+ throw standardErrors.provider.unauthorized("No valid session found, try requestAccounts before other methods");
2092
+ }
2093
+ const encrypted = await encryptContent({
2094
+ action: request,
2095
+ chainId: this.chain.id
2096
+ }, sharedSecret);
2097
+ const message = await this.createRequestMessage({ encrypted });
2098
+ return this.communicator.postRequestAndWaitForResponse(message);
2099
+ }
2100
+ async createRequestMessage(content) {
2101
+ const publicKey = await exportKeyToHexString("public", await this.keyManager.getOwnPublicKey());
2102
+ return {
2103
+ id: crypto.randomUUID(),
2104
+ sender: publicKey,
2105
+ content,
2106
+ timestamp: /* @__PURE__ */ new Date()
2107
+ };
2108
+ }
2109
+ async decryptResponseMessage(message) {
2110
+ var _a, _b;
2111
+ const content = message.content;
2112
+ if ("failure" in content) {
2113
+ throw content.failure;
2114
+ }
2115
+ const sharedSecret = await this.keyManager.getSharedSecret();
2116
+ if (!sharedSecret) {
2117
+ throw standardErrors.provider.unauthorized("Invalid session");
2118
+ }
2119
+ const response = await decryptContent(content.encrypted, sharedSecret);
2120
+ const availableChains = (_a = response.data) === null || _a === void 0 ? void 0 : _a.chains;
2121
+ if (availableChains) {
2122
+ const chains = Object.entries(availableChains).map(([id, rpcUrl]) => ({
2123
+ id: Number(id),
2124
+ rpcUrl
2125
+ }));
2126
+ this.storage.storeObject(AVAILABLE_CHAINS_STORAGE_KEY, chains);
2127
+ this.updateChain(this.chain.id, chains);
2128
+ }
2129
+ const walletCapabilities = (_b = response.data) === null || _b === void 0 ? void 0 : _b.capabilities;
2130
+ if (walletCapabilities) {
2131
+ this.storage.storeObject(WALLET_CAPABILITIES_STORAGE_KEY, walletCapabilities);
2132
+ }
2133
+ return response;
2134
+ }
2135
+ updateChain(chainId, newAvailableChains) {
2136
+ var _a;
2137
+ const chains = newAvailableChains !== null && newAvailableChains !== void 0 ? newAvailableChains : this.storage.loadObject(AVAILABLE_CHAINS_STORAGE_KEY);
2138
+ const chain = chains === null || chains === void 0 ? void 0 : chains.find((chain2) => chain2.id === chainId);
2139
+ if (!chain)
2140
+ return false;
2141
+ if (chain !== this.chain) {
2142
+ this.chain = chain;
2143
+ this.storage.storeObject(ACTIVE_CHAIN_STORAGE_KEY, chain);
2144
+ (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, "chainChanged", hexStringFromNumber(chain.id));
2145
+ }
2146
+ return true;
2147
+ }
2148
+ };
2149
+
2150
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/WalletLinkSigner.js
2151
+ init_polyfills();
2152
+ var import_eth_eip712_util = __toESM(require_eth_eip712_util(), 1);
2153
+
2154
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/constants.js
2155
+ init_polyfills();
2156
+ var WALLET_USER_NAME_KEY = "walletUsername";
2157
+ var LOCAL_STORAGE_ADDRESSES_KEY = "Addresses";
2158
+ var APP_VERSION_KEY = "AppVersion";
2159
+
2160
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/type/Web3Response.js
2161
+ init_polyfills();
2162
+ function isErrorResponse(response) {
2163
+ return response.errorMessage !== void 0;
2164
+ }
2165
+
2166
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/WalletLinkRelay.js
2167
+ init_polyfills();
2168
+
2169
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkConnection.js
2170
+ init_polyfills();
2171
+
2172
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkCipher.js
2173
+ init_polyfills();
2174
+ var WalletLinkCipher = class {
2175
+ // @param secret hex representation of 32-byte secret
2176
+ constructor(secret) {
2177
+ this.secret = secret;
2178
+ }
2179
+ /**
2180
+ *
2181
+ * @param plainText string to be encrypted
2182
+ * returns hex string representation of bytes in the order: initialization vector (iv),
2183
+ * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. Remaining bytes are the
2184
+ * encrypted plainText.
2185
+ */
2186
+ async encrypt(plainText) {
2187
+ const secret = this.secret;
2188
+ if (secret.length !== 64)
2189
+ throw Error(`secret must be 256 bits`);
2190
+ const ivBytes = crypto.getRandomValues(new Uint8Array(12));
2191
+ const secretKey = await crypto.subtle.importKey("raw", hexStringToUint8Array(secret), { name: "aes-gcm" }, false, ["encrypt", "decrypt"]);
2192
+ const enc = new TextEncoder();
2193
+ const encryptedResult = await window.crypto.subtle.encrypt({
2194
+ name: "AES-GCM",
2195
+ iv: ivBytes
2196
+ }, secretKey, enc.encode(plainText));
2197
+ const tagLength = 16;
2198
+ const authTag = encryptedResult.slice(encryptedResult.byteLength - tagLength);
2199
+ const encryptedPlaintext = encryptedResult.slice(0, encryptedResult.byteLength - tagLength);
2200
+ const authTagBytes = new Uint8Array(authTag);
2201
+ const encryptedPlaintextBytes = new Uint8Array(encryptedPlaintext);
2202
+ const concatted = new Uint8Array([...ivBytes, ...authTagBytes, ...encryptedPlaintextBytes]);
2203
+ return uint8ArrayToHex(concatted);
2204
+ }
2205
+ /**
2206
+ *
2207
+ * @param cipherText hex string representation of bytes in the order: initialization vector (iv),
2208
+ * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes.
2209
+ */
2210
+ async decrypt(cipherText) {
2211
+ const secret = this.secret;
2212
+ if (secret.length !== 64)
2213
+ throw Error(`secret must be 256 bits`);
2214
+ return new Promise((resolve, reject) => {
2215
+ void (async function() {
2216
+ const secretKey = await crypto.subtle.importKey("raw", hexStringToUint8Array(secret), { name: "aes-gcm" }, false, ["encrypt", "decrypt"]);
2217
+ const encrypted = hexStringToUint8Array(cipherText);
2218
+ const ivBytes = encrypted.slice(0, 12);
2219
+ const authTagBytes = encrypted.slice(12, 28);
2220
+ const encryptedPlaintextBytes = encrypted.slice(28);
2221
+ const concattedBytes = new Uint8Array([...encryptedPlaintextBytes, ...authTagBytes]);
2222
+ const algo = {
2223
+ name: "AES-GCM",
2224
+ iv: new Uint8Array(ivBytes)
2225
+ };
2226
+ try {
2227
+ const decrypted = await window.crypto.subtle.decrypt(algo, secretKey, concattedBytes);
2228
+ const decoder = new TextDecoder();
2229
+ resolve(decoder.decode(decrypted));
2230
+ } catch (err) {
2231
+ reject(err);
2232
+ }
2233
+ })();
2234
+ });
2235
+ }
2236
+ };
2237
+
2238
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkHTTP.js
2239
+ init_polyfills();
2240
+ var WalletLinkHTTP = class {
2241
+ constructor(linkAPIUrl, sessionId, sessionKey) {
2242
+ this.linkAPIUrl = linkAPIUrl;
2243
+ this.sessionId = sessionId;
2244
+ const credentials = `${sessionId}:${sessionKey}`;
2245
+ this.auth = `Basic ${btoa(credentials)}`;
2246
+ }
2247
+ // mark unseen events as seen
2248
+ async markUnseenEventsAsSeen(events) {
2249
+ return Promise.all(events.map((e3) => fetch(`${this.linkAPIUrl}/events/${e3.eventId}/seen`, {
2250
+ method: "POST",
2251
+ headers: {
2252
+ Authorization: this.auth
2253
+ }
2254
+ }))).catch((error) => console.error("Unabled to mark event as failed:", error));
2255
+ }
2256
+ async fetchUnseenEvents() {
2257
+ var _a;
2258
+ const response = await fetch(`${this.linkAPIUrl}/events?unseen=true`, {
2259
+ headers: {
2260
+ Authorization: this.auth
2261
+ }
2262
+ });
2263
+ if (response.ok) {
2264
+ const { events, error } = await response.json();
2265
+ if (error) {
2266
+ throw new Error(`Check unseen events failed: ${error}`);
2267
+ }
2268
+ const responseEvents = (_a = events === null || events === void 0 ? void 0 : events.filter((e3) => e3.event === "Web3Response").map((e3) => ({
2269
+ type: "Event",
2270
+ sessionId: this.sessionId,
2271
+ eventId: e3.id,
2272
+ event: e3.event,
2273
+ data: e3.data
2274
+ }))) !== null && _a !== void 0 ? _a : [];
2275
+ this.markUnseenEventsAsSeen(responseEvents);
2276
+ return responseEvents;
2277
+ }
2278
+ throw new Error(`Check unseen events failed: ${response.status}`);
2279
+ }
2280
+ };
2281
+
2282
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkWebSocket.js
2283
+ init_polyfills();
2284
+ var ConnectionState;
2285
+ (function(ConnectionState2) {
2286
+ ConnectionState2[ConnectionState2["DISCONNECTED"] = 0] = "DISCONNECTED";
2287
+ ConnectionState2[ConnectionState2["CONNECTING"] = 1] = "CONNECTING";
2288
+ ConnectionState2[ConnectionState2["CONNECTED"] = 2] = "CONNECTED";
2289
+ })(ConnectionState || (ConnectionState = {}));
2290
+ var WalletLinkWebSocket = class _WalletLinkWebSocket {
2291
+ setConnectionStateListener(listener) {
2292
+ this.connectionStateListener = listener;
2293
+ }
2294
+ setIncomingDataListener(listener) {
2295
+ this.incomingDataListener = listener;
2296
+ }
2297
+ /**
2298
+ * Constructor
2299
+ * @param url WebSocket server URL
2300
+ * @param [WebSocketClass] Custom WebSocket implementation
2301
+ */
2302
+ constructor(url, WebSocketClass = WebSocket) {
2303
+ this.WebSocketClass = WebSocketClass;
2304
+ this.webSocket = null;
2305
+ this.isDisconnecting = false;
2306
+ this.url = url.replace(/^http/, "ws");
2307
+ this.instanceId = _WalletLinkWebSocket.instanceCounter++;
2308
+ _WalletLinkWebSocket.activeInstances.add(this.instanceId);
2309
+ }
2310
+ /**
2311
+ * Make a websocket connection
2312
+ * @returns a Promise that resolves when connected
2313
+ */
2314
+ async connect() {
2315
+ if (this.webSocket) {
2316
+ throw new Error("webSocket object is not null");
2317
+ }
2318
+ if (this.isDisconnecting) {
2319
+ throw new Error("WebSocket is disconnecting, cannot reconnect on same instance");
2320
+ }
2321
+ return new Promise((resolve, reject) => {
2322
+ var _a;
2323
+ let webSocket;
2324
+ try {
2325
+ this.webSocket = webSocket = new this.WebSocketClass(this.url);
2326
+ } catch (err) {
2327
+ reject(err);
2328
+ return;
2329
+ }
2330
+ (_a = this.connectionStateListener) === null || _a === void 0 ? void 0 : _a.call(this, ConnectionState.CONNECTING);
2331
+ webSocket.onclose = (evt) => {
2332
+ var _a2;
2333
+ this.clearWebSocket();
2334
+ if (webSocket.readyState !== WebSocket.OPEN) {
2335
+ reject(new Error(`websocket error ${evt.code}: ${evt.reason}`));
2336
+ }
2337
+ (_a2 = this.connectionStateListener) === null || _a2 === void 0 ? void 0 : _a2.call(this, ConnectionState.DISCONNECTED);
2338
+ };
2339
+ webSocket.onopen = (_2) => {
2340
+ var _a2;
2341
+ resolve();
2342
+ (_a2 = this.connectionStateListener) === null || _a2 === void 0 ? void 0 : _a2.call(this, ConnectionState.CONNECTED);
2343
+ if (_WalletLinkWebSocket.pendingData.length > 0) {
2344
+ const pending = [..._WalletLinkWebSocket.pendingData];
2345
+ pending.forEach((data) => this.sendData(data));
2346
+ _WalletLinkWebSocket.pendingData = [];
2347
+ }
2348
+ };
2349
+ webSocket.onmessage = (evt) => {
2350
+ var _a2, _b;
2351
+ if (evt.data === "h") {
2352
+ (_a2 = this.incomingDataListener) === null || _a2 === void 0 ? void 0 : _a2.call(this, {
2353
+ type: "Heartbeat"
2354
+ });
2355
+ } else {
2356
+ try {
2357
+ const message = JSON.parse(evt.data);
2358
+ (_b = this.incomingDataListener) === null || _b === void 0 ? void 0 : _b.call(this, message);
2359
+ } catch (_c) {
2360
+ }
2361
+ }
2362
+ };
2363
+ });
2364
+ }
2365
+ /**
2366
+ * Disconnect from server
2367
+ */
2368
+ disconnect() {
2369
+ var _a;
2370
+ const { webSocket } = this;
2371
+ if (!webSocket) {
2372
+ return;
2373
+ }
2374
+ this.isDisconnecting = true;
2375
+ this.clearWebSocket();
2376
+ (_a = this.connectionStateListener) === null || _a === void 0 ? void 0 : _a.call(this, ConnectionState.DISCONNECTED);
2377
+ this.connectionStateListener = void 0;
2378
+ this.incomingDataListener = void 0;
2379
+ try {
2380
+ webSocket.close();
2381
+ } catch (_b) {
2382
+ }
2383
+ }
2384
+ /**
2385
+ * Send data to server
2386
+ * @param data text to send
2387
+ */
2388
+ sendData(data) {
2389
+ const { webSocket } = this;
2390
+ if (!webSocket) {
2391
+ _WalletLinkWebSocket.pendingData.push(data);
2392
+ if (!this.isDisconnecting) {
2393
+ this.connect();
2394
+ }
2395
+ return;
2396
+ }
2397
+ if (webSocket.readyState !== WebSocket.OPEN) {
2398
+ _WalletLinkWebSocket.pendingData.push(data);
2399
+ return;
2400
+ }
2401
+ webSocket.send(data);
2402
+ }
2403
+ clearWebSocket() {
2404
+ const { webSocket } = this;
2405
+ if (!webSocket) {
2406
+ return;
2407
+ }
2408
+ this.webSocket = null;
2409
+ webSocket.onclose = null;
2410
+ webSocket.onerror = null;
2411
+ webSocket.onmessage = null;
2412
+ webSocket.onopen = null;
2413
+ }
2414
+ /**
2415
+ * remove ws from active instances
2416
+ */
2417
+ cleanup() {
2418
+ _WalletLinkWebSocket.activeInstances.delete(this.instanceId);
2419
+ }
2420
+ };
2421
+ WalletLinkWebSocket.instanceCounter = 0;
2422
+ WalletLinkWebSocket.activeInstances = /* @__PURE__ */ new Set();
2423
+ WalletLinkWebSocket.pendingData = [];
2424
+
2425
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkConnection.js
2426
+ var HEARTBEAT_INTERVAL = 1e4;
2427
+ var REQUEST_TIMEOUT = 6e4;
2428
+ var WalletLinkConnection = class {
2429
+ /**
2430
+ * Constructor
2431
+ * @param session Session
2432
+ * @param linkAPIUrl Coinbase Wallet link server URL
2433
+ * @param listener WalletLinkConnectionUpdateListener
2434
+ * @param [WebSocketClass] Custom WebSocket implementation
2435
+ */
2436
+ constructor({ session, linkAPIUrl, listener }) {
2437
+ this.destroyed = false;
2438
+ this.lastHeartbeatResponse = 0;
2439
+ this.nextReqId = IntNumber(1);
2440
+ this.reconnectAttempts = 0;
2441
+ this.isReconnecting = false;
2442
+ this._connected = false;
2443
+ this._linked = false;
2444
+ this.requestResolutions = /* @__PURE__ */ new Map();
2445
+ this.handleSessionMetadataUpdated = (metadata) => {
2446
+ if (!metadata)
2447
+ return;
2448
+ const handlers = /* @__PURE__ */ new Map([
2449
+ ["__destroyed", this.handleDestroyed],
2450
+ ["EthereumAddress", this.handleAccountUpdated],
2451
+ ["WalletUsername", this.handleWalletUsernameUpdated],
2452
+ ["AppVersion", this.handleAppVersionUpdated],
2453
+ [
2454
+ "ChainId",
2455
+ // ChainId and JsonRpcUrl are always updated together
2456
+ (v3) => metadata.JsonRpcUrl && this.handleChainUpdated(v3, metadata.JsonRpcUrl)
2457
+ ]
2458
+ ]);
2459
+ handlers.forEach((handler, key) => {
2460
+ const value = metadata[key];
2461
+ if (value === void 0)
2462
+ return;
2463
+ handler(value);
2464
+ });
2465
+ };
2466
+ this.handleDestroyed = (__destroyed) => {
2467
+ var _a;
2468
+ if (__destroyed !== "1")
2469
+ return;
2470
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.resetAndReload();
2471
+ };
2472
+ this.handleAccountUpdated = async (encryptedEthereumAddress) => {
2473
+ var _a;
2474
+ try {
2475
+ const address = await this.cipher.decrypt(encryptedEthereumAddress);
2476
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.accountUpdated(address);
2477
+ } catch (_b) {
2478
+ }
2479
+ };
2480
+ this.handleMetadataUpdated = async (key, encryptedMetadataValue) => {
2481
+ var _a;
2482
+ try {
2483
+ const decryptedValue = await this.cipher.decrypt(encryptedMetadataValue);
2484
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.metadataUpdated(key, decryptedValue);
2485
+ } catch (_b) {
2486
+ }
2487
+ };
2488
+ this.handleWalletUsernameUpdated = async (walletUsername) => {
2489
+ this.handleMetadataUpdated(WALLET_USER_NAME_KEY, walletUsername);
2490
+ };
2491
+ this.handleAppVersionUpdated = async (appVersion) => {
2492
+ this.handleMetadataUpdated(APP_VERSION_KEY, appVersion);
2493
+ };
2494
+ this.handleChainUpdated = async (encryptedChainId, encryptedJsonRpcUrl) => {
2495
+ var _a;
2496
+ try {
2497
+ const chainId = await this.cipher.decrypt(encryptedChainId);
2498
+ const jsonRpcUrl = await this.cipher.decrypt(encryptedJsonRpcUrl);
2499
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.chainUpdated(chainId, jsonRpcUrl);
2500
+ } catch (_b) {
2501
+ }
2502
+ };
2503
+ this.session = session;
2504
+ this.cipher = new WalletLinkCipher(session.secret);
2505
+ this.listener = listener;
2506
+ this.linkAPIUrl = linkAPIUrl;
2507
+ this.WebSocketClass = WebSocket;
2508
+ const ws = this.createWebSocket();
2509
+ this.ws = ws;
2510
+ this.http = new WalletLinkHTTP(linkAPIUrl, session.id, session.key);
2511
+ this.setupVisibilityChangeHandler();
2512
+ }
2513
+ createWebSocket() {
2514
+ const ws = new WalletLinkWebSocket(`${this.linkAPIUrl}/rpc`, this.WebSocketClass);
2515
+ this.activeWsInstance = ws;
2516
+ ws.setConnectionStateListener(async (state) => {
2517
+ if (ws !== this.activeWsInstance) {
2518
+ return;
2519
+ }
2520
+ let connected = false;
2521
+ switch (state) {
2522
+ case ConnectionState.DISCONNECTED:
2523
+ if (this.heartbeatIntervalId) {
2524
+ clearInterval(this.heartbeatIntervalId);
2525
+ this.heartbeatIntervalId = void 0;
2526
+ }
2527
+ this.lastHeartbeatResponse = 0;
2528
+ connected = false;
2529
+ if (!this.destroyed) {
2530
+ const reconnect = async () => {
2531
+ if (this.isReconnecting) {
2532
+ return;
2533
+ }
2534
+ this.isReconnecting = true;
2535
+ const delay = this.reconnectAttempts === 0 ? 0 : 3e3;
2536
+ await new Promise((resolve) => setTimeout(resolve, delay));
2537
+ if (!this.destroyed && ws === this.activeWsInstance) {
2538
+ this.reconnectAttempts++;
2539
+ if ("cleanup" in this.ws && typeof this.ws.cleanup === "function") {
2540
+ this.ws.cleanup();
2541
+ }
2542
+ this.ws = this.createWebSocket();
2543
+ this.ws.connect().catch(() => {
2544
+ }).finally(() => {
2545
+ this.isReconnecting = false;
2546
+ });
2547
+ } else {
2548
+ this.isReconnecting = false;
2549
+ }
2550
+ };
2551
+ reconnect();
2552
+ }
2553
+ break;
2554
+ case ConnectionState.CONNECTED:
2555
+ this.reconnectAttempts = 0;
2556
+ try {
2557
+ connected = await this.handleConnected();
2558
+ this.fetchUnseenEventsAPI().catch(() => {
2559
+ });
2560
+ } catch (_error) {
2561
+ break;
2562
+ }
2563
+ this.connected = connected;
2564
+ this.updateLastHeartbeat();
2565
+ if (this.heartbeatIntervalId) {
2566
+ clearInterval(this.heartbeatIntervalId);
2567
+ }
2568
+ this.heartbeatIntervalId = window.setInterval(() => {
2569
+ this.heartbeat();
2570
+ }, HEARTBEAT_INTERVAL);
2571
+ setTimeout(() => {
2572
+ this.heartbeat();
2573
+ }, 100);
2574
+ break;
2575
+ case ConnectionState.CONNECTING:
2576
+ break;
2577
+ }
2578
+ if (state !== ConnectionState.CONNECTED) {
2579
+ this.connected = connected;
2580
+ }
2581
+ });
2582
+ ws.setIncomingDataListener((m3) => {
2583
+ var _a;
2584
+ switch (m3.type) {
2585
+ // handle server's heartbeat responses
2586
+ case "Heartbeat":
2587
+ this.updateLastHeartbeat();
2588
+ return;
2589
+ // handle link status updates
2590
+ case "IsLinkedOK":
2591
+ case "Linked": {
2592
+ const linked = m3.type === "IsLinkedOK" ? m3.linked : void 0;
2593
+ this.linked = linked || m3.onlineGuests > 0;
2594
+ break;
2595
+ }
2596
+ // handle session config updates
2597
+ case "GetSessionConfigOK":
2598
+ case "SessionConfigUpdated": {
2599
+ this.handleSessionMetadataUpdated(m3.metadata);
2600
+ break;
2601
+ }
2602
+ case "Event": {
2603
+ this.handleIncomingEvent(m3);
2604
+ break;
2605
+ }
2606
+ }
2607
+ if (m3.id !== void 0) {
2608
+ (_a = this.requestResolutions.get(m3.id)) === null || _a === void 0 ? void 0 : _a(m3);
2609
+ }
2610
+ });
2611
+ return ws;
2612
+ }
2613
+ setupVisibilityChangeHandler() {
2614
+ this.visibilityChangeHandler = () => {
2615
+ if (!document.hidden && !this.destroyed) {
2616
+ if (!this.connected) {
2617
+ this.reconnectWithFreshWebSocket();
2618
+ } else {
2619
+ this.heartbeat();
2620
+ }
2621
+ }
2622
+ };
2623
+ this.focusHandler = () => {
2624
+ if (!this.destroyed && !this.connected) {
2625
+ this.reconnectWithFreshWebSocket();
2626
+ }
2627
+ };
2628
+ document.addEventListener("visibilitychange", this.visibilityChangeHandler);
2629
+ window.addEventListener("focus", this.focusHandler);
2630
+ window.addEventListener("pageshow", (event) => {
2631
+ if (event.persisted) {
2632
+ if (this.focusHandler) {
2633
+ this.focusHandler();
2634
+ }
2635
+ }
2636
+ });
2637
+ }
2638
+ reconnectWithFreshWebSocket() {
2639
+ if (this.destroyed)
2640
+ return;
2641
+ const oldWs = this.ws;
2642
+ this.activeWsInstance = void 0;
2643
+ oldWs.disconnect();
2644
+ if ("cleanup" in oldWs && typeof oldWs.cleanup === "function") {
2645
+ oldWs.cleanup();
2646
+ }
2647
+ this.ws = this.createWebSocket();
2648
+ this.ws.connect().catch(() => {
2649
+ });
2650
+ }
2651
+ /**
2652
+ * Make a connection to the server
2653
+ */
2654
+ connect() {
2655
+ if (this.destroyed) {
2656
+ throw new Error("instance is destroyed");
2657
+ }
2658
+ this.ws.connect();
2659
+ }
2660
+ /**
2661
+ * Terminate connection, and mark as destroyed. To reconnect, create a new
2662
+ * instance of WalletSDKConnection
2663
+ */
2664
+ async destroy() {
2665
+ if (this.destroyed)
2666
+ return;
2667
+ await this.makeRequest({
2668
+ type: "SetSessionConfig",
2669
+ id: IntNumber(this.nextReqId++),
2670
+ sessionId: this.session.id,
2671
+ metadata: { __destroyed: "1" }
2672
+ }, { timeout: 1e3 });
2673
+ this.destroyed = true;
2674
+ this.activeWsInstance = void 0;
2675
+ if (this.heartbeatIntervalId) {
2676
+ clearInterval(this.heartbeatIntervalId);
2677
+ this.heartbeatIntervalId = void 0;
2678
+ }
2679
+ if (this.visibilityChangeHandler) {
2680
+ document.removeEventListener("visibilitychange", this.visibilityChangeHandler);
2681
+ }
2682
+ if (this.focusHandler) {
2683
+ window.removeEventListener("focus", this.focusHandler);
2684
+ }
2685
+ this.ws.disconnect();
2686
+ if ("cleanup" in this.ws && typeof this.ws.cleanup === "function") {
2687
+ this.ws.cleanup();
2688
+ }
2689
+ this.listener = void 0;
2690
+ }
2691
+ get connected() {
2692
+ return this._connected;
2693
+ }
2694
+ set connected(connected) {
2695
+ this._connected = connected;
2696
+ }
2697
+ get linked() {
2698
+ return this._linked;
2699
+ }
2700
+ set linked(linked) {
2701
+ var _a, _b;
2702
+ this._linked = linked;
2703
+ if (linked)
2704
+ (_a = this.onceLinked) === null || _a === void 0 ? void 0 : _a.call(this);
2705
+ (_b = this.listener) === null || _b === void 0 ? void 0 : _b.linkedUpdated(linked);
2706
+ }
2707
+ setOnceLinked(callback) {
2708
+ return new Promise((resolve) => {
2709
+ if (this.linked) {
2710
+ callback().then(resolve);
2711
+ } else {
2712
+ this.onceLinked = () => {
2713
+ callback().then(resolve);
2714
+ this.onceLinked = void 0;
2715
+ };
2716
+ }
2717
+ });
2718
+ }
2719
+ async handleIncomingEvent(m3) {
2720
+ var _a;
2721
+ if (m3.type !== "Event" || m3.event !== "Web3Response") {
2722
+ return;
2723
+ }
2724
+ try {
2725
+ const decryptedData = await this.cipher.decrypt(m3.data);
2726
+ const message = JSON.parse(decryptedData);
2727
+ if (message.type !== "WEB3_RESPONSE")
2728
+ return;
2729
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.handleWeb3ResponseMessage(message.id, message.response);
2730
+ } catch (_error) {
2731
+ }
2732
+ }
2733
+ async checkUnseenEvents() {
2734
+ await new Promise((resolve) => setTimeout(resolve, 250));
2735
+ try {
2736
+ await this.fetchUnseenEventsAPI();
2737
+ } catch (e3) {
2738
+ console.error("Unable to check for unseen events", e3);
2739
+ }
2740
+ }
2741
+ async fetchUnseenEventsAPI() {
2742
+ try {
2743
+ const responseEvents = await this.http.fetchUnseenEvents();
2744
+ responseEvents.forEach((e3) => {
2745
+ this.handleIncomingEvent(e3);
2746
+ });
2747
+ } catch (_error) {
2748
+ }
2749
+ }
2750
+ /**
2751
+ * Publish an event and emit event ID when successful
2752
+ * @param event event name
2753
+ * @param unencryptedData unencrypted event data
2754
+ * @param callWebhook whether the webhook should be invoked
2755
+ * @returns a Promise that emits event ID when successful
2756
+ */
2757
+ async publishEvent(event, unencryptedData, callWebhook = false) {
2758
+ const data = await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({}, unencryptedData), { origin: location.origin, location: location.href, relaySource: "coinbaseWalletExtension" in window && window.coinbaseWalletExtension ? "injected_sdk" : "sdk" })));
2759
+ const message = {
2760
+ type: "PublishEvent",
2761
+ id: IntNumber(this.nextReqId++),
2762
+ sessionId: this.session.id,
2763
+ event,
2764
+ data,
2765
+ callWebhook
2766
+ };
2767
+ return this.setOnceLinked(async () => {
2768
+ const res = await this.makeRequest(message);
2769
+ if (res.type === "Fail") {
2770
+ throw new Error(res.error || "failed to publish event");
2771
+ }
2772
+ return res.eventId;
2773
+ });
2774
+ }
2775
+ sendData(message) {
2776
+ this.ws.sendData(JSON.stringify(message));
2777
+ }
2778
+ updateLastHeartbeat() {
2779
+ this.lastHeartbeatResponse = Date.now();
2780
+ }
2781
+ heartbeat() {
2782
+ if (Date.now() - this.lastHeartbeatResponse > HEARTBEAT_INTERVAL * 2) {
2783
+ this.ws.disconnect();
2784
+ return;
2785
+ }
2786
+ if (!this.connected) {
2787
+ return;
2788
+ }
2789
+ try {
2790
+ this.ws.sendData("h");
2791
+ } catch (_error) {
2792
+ }
2793
+ }
2794
+ async makeRequest(message, options = { timeout: REQUEST_TIMEOUT }) {
2795
+ const reqId = message.id;
2796
+ this.sendData(message);
2797
+ let timeoutId;
2798
+ return Promise.race([
2799
+ new Promise((_2, reject) => {
2800
+ timeoutId = window.setTimeout(() => {
2801
+ reject(new Error(`request ${reqId} timed out`));
2802
+ }, options.timeout);
2803
+ }),
2804
+ new Promise((resolve) => {
2805
+ this.requestResolutions.set(reqId, (m3) => {
2806
+ clearTimeout(timeoutId);
2807
+ resolve(m3);
2808
+ this.requestResolutions.delete(reqId);
2809
+ });
2810
+ })
2811
+ ]);
2812
+ }
2813
+ async handleConnected() {
2814
+ const res = await this.makeRequest({
2815
+ type: "HostSession",
2816
+ id: IntNumber(this.nextReqId++),
2817
+ sessionId: this.session.id,
2818
+ sessionKey: this.session.key
2819
+ });
2820
+ if (res.type === "Fail") {
2821
+ return false;
2822
+ }
2823
+ this.sendData({
2824
+ type: "IsLinked",
2825
+ id: IntNumber(this.nextReqId++),
2826
+ sessionId: this.session.id
2827
+ });
2828
+ this.sendData({
2829
+ type: "GetSessionConfig",
2830
+ id: IntNumber(this.nextReqId++),
2831
+ sessionId: this.session.id
2832
+ });
2833
+ return true;
2834
+ }
2835
+ };
2836
+
2837
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/RelayEventManager.js
2838
+ init_polyfills();
2839
+ var RelayEventManager = class {
2840
+ constructor() {
2841
+ this._nextRequestId = 0;
2842
+ this.callbacks = /* @__PURE__ */ new Map();
2843
+ }
2844
+ makeRequestId() {
2845
+ this._nextRequestId = (this._nextRequestId + 1) % 2147483647;
2846
+ const id = this._nextRequestId;
2847
+ const idStr = prepend0x(id.toString(16));
2848
+ const callback = this.callbacks.get(idStr);
2849
+ if (callback) {
2850
+ this.callbacks.delete(idStr);
2851
+ }
2852
+ return id;
2853
+ }
2854
+ };
2855
+
2856
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/type/WalletLinkSession.js
2857
+ init_polyfills();
2858
+ var STORAGE_KEY_SESSION_ID = "session:id";
2859
+ var STORAGE_KEY_SESSION_SECRET = "session:secret";
2860
+ var STORAGE_KEY_SESSION_LINKED = "session:linked";
2861
+ var WalletLinkSession = class _WalletLinkSession {
2862
+ constructor(storage2, id, secret, linked = false) {
2863
+ this.storage = storage2;
2864
+ this.id = id;
2865
+ this.secret = secret;
2866
+ this.key = bytesToHex(sha256(`${id}, ${secret} WalletLink`));
2867
+ this._linked = !!linked;
2868
+ }
2869
+ static create(storage2) {
2870
+ const id = randomBytesHex(16);
2871
+ const secret = randomBytesHex(32);
2872
+ return new _WalletLinkSession(storage2, id, secret).save();
2873
+ }
2874
+ static load(storage2) {
2875
+ const id = storage2.getItem(STORAGE_KEY_SESSION_ID);
2876
+ const linked = storage2.getItem(STORAGE_KEY_SESSION_LINKED);
2877
+ const secret = storage2.getItem(STORAGE_KEY_SESSION_SECRET);
2878
+ if (id && secret) {
2879
+ return new _WalletLinkSession(storage2, id, secret, linked === "1");
2880
+ }
2881
+ return null;
2882
+ }
2883
+ get linked() {
2884
+ return this._linked;
2885
+ }
2886
+ set linked(val) {
2887
+ this._linked = val;
2888
+ this.persistLinked();
2889
+ }
2890
+ save() {
2891
+ this.storage.setItem(STORAGE_KEY_SESSION_ID, this.id);
2892
+ this.storage.setItem(STORAGE_KEY_SESSION_SECRET, this.secret);
2893
+ this.persistLinked();
2894
+ return this;
2895
+ }
2896
+ persistLinked() {
2897
+ this.storage.setItem(STORAGE_KEY_SESSION_LINKED, this._linked ? "1" : "0");
2898
+ }
2899
+ };
2900
+
2901
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/util.js
2902
+ init_polyfills();
2903
+ function isInIFrame() {
2904
+ try {
2905
+ return window.frameElement !== null;
2906
+ } catch (e3) {
2907
+ return false;
2908
+ }
2909
+ }
2910
+ function getLocation() {
2911
+ try {
2912
+ if (isInIFrame() && window.top) {
2913
+ return window.top.location;
2914
+ }
2915
+ return window.location;
2916
+ } catch (e3) {
2917
+ return window.location;
2918
+ }
2919
+ }
2920
+ function isMobileWeb() {
2921
+ var _a;
2922
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent);
2923
+ }
2924
+ function isDarkMode() {
2925
+ var _a, _b;
2926
+ return (_b = (_a = window === null || window === void 0 ? void 0 : window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, "(prefers-color-scheme: dark)").matches) !== null && _b !== void 0 ? _b : false;
2927
+ }
2928
+
2929
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/WalletLinkRelayUI.js
2930
+ init_polyfills();
2931
+
2932
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/cssReset/cssReset.js
2933
+ init_polyfills();
2934
+
2935
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/cssReset/cssReset-css.js
2936
+ init_polyfills();
2937
+ var cssReset_css_default = /* @__PURE__ */ (() => `@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}`)();
2938
+
2939
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/cssReset/cssReset.js
2940
+ function injectCssReset() {
2941
+ const styleEl = document.createElement("style");
2942
+ styleEl.type = "text/css";
2943
+ styleEl.appendChild(document.createTextNode(cssReset_css_default));
2944
+ document.documentElement.appendChild(styleEl);
2945
+ }
2946
+
2947
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/Snackbar/Snackbar.js
2948
+ init_polyfills();
2949
+
2950
+ // ../../node_modules/.pnpm/clsx@1.2.1/node_modules/clsx/dist/clsx.m.js
2951
+ init_polyfills();
2952
+ function r(e3) {
2953
+ var t3, f3, n2 = "";
2954
+ if ("string" == typeof e3 || "number" == typeof e3) n2 += e3;
2955
+ else if ("object" == typeof e3) if (Array.isArray(e3)) for (t3 = 0; t3 < e3.length; t3++) e3[t3] && (f3 = r(e3[t3])) && (n2 && (n2 += " "), n2 += f3);
2956
+ else for (t3 in e3) e3[t3] && (n2 && (n2 += " "), n2 += t3);
2957
+ return n2;
2958
+ }
2959
+ function clsx() {
2960
+ for (var e3, t3, f3 = 0, n2 = ""; f3 < arguments.length; ) (e3 = arguments[f3++]) && (t3 = r(e3)) && (n2 && (n2 += " "), n2 += t3);
2961
+ return n2;
2962
+ }
2963
+
2964
+ // ../../node_modules/.pnpm/preact@10.27.2/node_modules/preact/dist/preact.module.js
2965
+ init_polyfills();
2966
+ var n;
2967
+ var l;
2968
+ var u;
2969
+ var t;
2970
+ var i;
2971
+ var r2;
2972
+ var o;
2973
+ var e;
2974
+ var f;
2975
+ var c;
2976
+ var s;
2977
+ var a;
2978
+ var h;
2979
+ var p = {};
2980
+ var v = [];
2981
+ var y = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
2982
+ var w = Array.isArray;
2983
+ function d(n2, l3) {
2984
+ for (var u3 in l3) n2[u3] = l3[u3];
2985
+ return n2;
2986
+ }
2987
+ function g(n2) {
2988
+ n2 && n2.parentNode && n2.parentNode.removeChild(n2);
2989
+ }
2990
+ function _(l3, u3, t3) {
2991
+ var i3, r4, o3, e3 = {};
2992
+ for (o3 in u3) "key" == o3 ? i3 = u3[o3] : "ref" == o3 ? r4 = u3[o3] : e3[o3] = u3[o3];
2993
+ if (arguments.length > 2 && (e3.children = arguments.length > 3 ? n.call(arguments, 2) : t3), "function" == typeof l3 && null != l3.defaultProps) for (o3 in l3.defaultProps) void 0 === e3[o3] && (e3[o3] = l3.defaultProps[o3]);
2994
+ return m(l3, e3, i3, r4, null);
2995
+ }
2996
+ function m(n2, t3, i3, r4, o3) {
2997
+ var e3 = { type: n2, props: t3, key: i3, ref: r4, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: null == o3 ? ++u : o3, __i: -1, __u: 0 };
2998
+ return null == o3 && null != l.vnode && l.vnode(e3), e3;
2999
+ }
3000
+ function k(n2) {
3001
+ return n2.children;
3002
+ }
3003
+ function x(n2, l3) {
3004
+ this.props = n2, this.context = l3;
3005
+ }
3006
+ function S(n2, l3) {
3007
+ if (null == l3) return n2.__ ? S(n2.__, n2.__i + 1) : null;
3008
+ for (var u3; l3 < n2.__k.length; l3++) if (null != (u3 = n2.__k[l3]) && null != u3.__e) return u3.__e;
3009
+ return "function" == typeof n2.type ? S(n2) : null;
3010
+ }
3011
+ function C(n2) {
3012
+ var l3, u3;
3013
+ if (null != (n2 = n2.__) && null != n2.__c) {
3014
+ for (n2.__e = n2.__c.base = null, l3 = 0; l3 < n2.__k.length; l3++) if (null != (u3 = n2.__k[l3]) && null != u3.__e) {
3015
+ n2.__e = n2.__c.base = u3.__e;
3016
+ break;
3017
+ }
3018
+ return C(n2);
3019
+ }
3020
+ }
3021
+ function M(n2) {
3022
+ (!n2.__d && (n2.__d = true) && i.push(n2) && !$.__r++ || r2 != l.debounceRendering) && ((r2 = l.debounceRendering) || o)($);
3023
+ }
3024
+ function $() {
3025
+ for (var n2, u3, t3, r4, o3, f3, c3, s3 = 1; i.length; ) i.length > s3 && i.sort(e), n2 = i.shift(), s3 = i.length, n2.__d && (t3 = void 0, r4 = void 0, o3 = (r4 = (u3 = n2).__v).__e, f3 = [], c3 = [], u3.__P && ((t3 = d({}, r4)).__v = r4.__v + 1, l.vnode && l.vnode(t3), O(u3.__P, t3, r4, u3.__n, u3.__P.namespaceURI, 32 & r4.__u ? [o3] : null, f3, null == o3 ? S(r4) : o3, !!(32 & r4.__u), c3), t3.__v = r4.__v, t3.__.__k[t3.__i] = t3, N(f3, t3, c3), r4.__e = r4.__ = null, t3.__e != o3 && C(t3)));
3026
+ $.__r = 0;
3027
+ }
3028
+ function I(n2, l3, u3, t3, i3, r4, o3, e3, f3, c3, s3) {
3029
+ var a3, h3, y3, w3, d3, g2, _2, m3 = t3 && t3.__k || v, b = l3.length;
3030
+ for (f3 = P(u3, l3, m3, f3, b), a3 = 0; a3 < b; a3++) null != (y3 = u3.__k[a3]) && (h3 = -1 == y3.__i ? p : m3[y3.__i] || p, y3.__i = a3, g2 = O(n2, y3, h3, i3, r4, o3, e3, f3, c3, s3), w3 = y3.__e, y3.ref && h3.ref != y3.ref && (h3.ref && B(h3.ref, null, y3), s3.push(y3.ref, y3.__c || w3, y3)), null == d3 && null != w3 && (d3 = w3), (_2 = !!(4 & y3.__u)) || h3.__k === y3.__k ? f3 = A(y3, f3, n2, _2) : "function" == typeof y3.type && void 0 !== g2 ? f3 = g2 : w3 && (f3 = w3.nextSibling), y3.__u &= -7);
3031
+ return u3.__e = d3, f3;
3032
+ }
3033
+ function P(n2, l3, u3, t3, i3) {
3034
+ var r4, o3, e3, f3, c3, s3 = u3.length, a3 = s3, h3 = 0;
3035
+ for (n2.__k = new Array(i3), r4 = 0; r4 < i3; r4++) null != (o3 = l3[r4]) && "boolean" != typeof o3 && "function" != typeof o3 ? (f3 = r4 + h3, (o3 = n2.__k[r4] = "string" == typeof o3 || "number" == typeof o3 || "bigint" == typeof o3 || o3.constructor == String ? m(null, o3, null, null, null) : w(o3) ? m(k, { children: o3 }, null, null, null) : null == o3.constructor && o3.__b > 0 ? m(o3.type, o3.props, o3.key, o3.ref ? o3.ref : null, o3.__v) : o3).__ = n2, o3.__b = n2.__b + 1, e3 = null, -1 != (c3 = o3.__i = L(o3, u3, f3, a3)) && (a3--, (e3 = u3[c3]) && (e3.__u |= 2)), null == e3 || null == e3.__v ? (-1 == c3 && (i3 > s3 ? h3-- : i3 < s3 && h3++), "function" != typeof o3.type && (o3.__u |= 4)) : c3 != f3 && (c3 == f3 - 1 ? h3-- : c3 == f3 + 1 ? h3++ : (c3 > f3 ? h3-- : h3++, o3.__u |= 4))) : n2.__k[r4] = null;
3036
+ if (a3) for (r4 = 0; r4 < s3; r4++) null != (e3 = u3[r4]) && 0 == (2 & e3.__u) && (e3.__e == t3 && (t3 = S(e3)), D(e3, e3));
3037
+ return t3;
3038
+ }
3039
+ function A(n2, l3, u3, t3) {
3040
+ var i3, r4;
3041
+ if ("function" == typeof n2.type) {
3042
+ for (i3 = n2.__k, r4 = 0; i3 && r4 < i3.length; r4++) i3[r4] && (i3[r4].__ = n2, l3 = A(i3[r4], l3, u3, t3));
3043
+ return l3;
3044
+ }
3045
+ n2.__e != l3 && (t3 && (l3 && n2.type && !l3.parentNode && (l3 = S(n2)), u3.insertBefore(n2.__e, l3 || null)), l3 = n2.__e);
3046
+ do {
3047
+ l3 = l3 && l3.nextSibling;
3048
+ } while (null != l3 && 8 == l3.nodeType);
3049
+ return l3;
3050
+ }
3051
+ function L(n2, l3, u3, t3) {
3052
+ var i3, r4, o3, e3 = n2.key, f3 = n2.type, c3 = l3[u3], s3 = null != c3 && 0 == (2 & c3.__u);
3053
+ if (null === c3 && null == n2.key || s3 && e3 == c3.key && f3 == c3.type) return u3;
3054
+ if (t3 > (s3 ? 1 : 0)) {
3055
+ for (i3 = u3 - 1, r4 = u3 + 1; i3 >= 0 || r4 < l3.length; ) if (null != (c3 = l3[o3 = i3 >= 0 ? i3-- : r4++]) && 0 == (2 & c3.__u) && e3 == c3.key && f3 == c3.type) return o3;
3056
+ }
3057
+ return -1;
3058
+ }
3059
+ function T(n2, l3, u3) {
3060
+ "-" == l3[0] ? n2.setProperty(l3, null == u3 ? "" : u3) : n2[l3] = null == u3 ? "" : "number" != typeof u3 || y.test(l3) ? u3 : u3 + "px";
3061
+ }
3062
+ function j(n2, l3, u3, t3, i3) {
3063
+ var r4, o3;
3064
+ n: if ("style" == l3) if ("string" == typeof u3) n2.style.cssText = u3;
3065
+ else {
3066
+ if ("string" == typeof t3 && (n2.style.cssText = t3 = ""), t3) for (l3 in t3) u3 && l3 in u3 || T(n2.style, l3, "");
3067
+ if (u3) for (l3 in u3) t3 && u3[l3] == t3[l3] || T(n2.style, l3, u3[l3]);
3068
+ }
3069
+ else if ("o" == l3[0] && "n" == l3[1]) r4 = l3 != (l3 = l3.replace(f, "$1")), o3 = l3.toLowerCase(), l3 = o3 in n2 || "onFocusOut" == l3 || "onFocusIn" == l3 ? o3.slice(2) : l3.slice(2), n2.l || (n2.l = {}), n2.l[l3 + r4] = u3, u3 ? t3 ? u3.u = t3.u : (u3.u = c, n2.addEventListener(l3, r4 ? a : s, r4)) : n2.removeEventListener(l3, r4 ? a : s, r4);
3070
+ else {
3071
+ if ("http://www.w3.org/2000/svg" == i3) l3 = l3.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
3072
+ else if ("width" != l3 && "height" != l3 && "href" != l3 && "list" != l3 && "form" != l3 && "tabIndex" != l3 && "download" != l3 && "rowSpan" != l3 && "colSpan" != l3 && "role" != l3 && "popover" != l3 && l3 in n2) try {
3073
+ n2[l3] = null == u3 ? "" : u3;
3074
+ break n;
3075
+ } catch (n3) {
3076
+ }
3077
+ "function" == typeof u3 || (null == u3 || false === u3 && "-" != l3[4] ? n2.removeAttribute(l3) : n2.setAttribute(l3, "popover" == l3 && 1 == u3 ? "" : u3));
3078
+ }
3079
+ }
3080
+ function F(n2) {
3081
+ return function(u3) {
3082
+ if (this.l) {
3083
+ var t3 = this.l[u3.type + n2];
3084
+ if (null == u3.t) u3.t = c++;
3085
+ else if (u3.t < t3.u) return;
3086
+ return t3(l.event ? l.event(u3) : u3);
3087
+ }
3088
+ };
3089
+ }
3090
+ function O(n2, u3, t3, i3, r4, o3, e3, f3, c3, s3) {
3091
+ var a3, h3, p3, v3, y3, _2, m3, b, S2, C3, M2, $2, P2, A2, H, L2, T2, j3 = u3.type;
3092
+ if (null != u3.constructor) return null;
3093
+ 128 & t3.__u && (c3 = !!(32 & t3.__u), o3 = [f3 = u3.__e = t3.__e]), (a3 = l.__b) && a3(u3);
3094
+ n: if ("function" == typeof j3) try {
3095
+ if (b = u3.props, S2 = "prototype" in j3 && j3.prototype.render, C3 = (a3 = j3.contextType) && i3[a3.__c], M2 = a3 ? C3 ? C3.props.value : a3.__ : i3, t3.__c ? m3 = (h3 = u3.__c = t3.__c).__ = h3.__E : (S2 ? u3.__c = h3 = new j3(b, M2) : (u3.__c = h3 = new x(b, M2), h3.constructor = j3, h3.render = E), C3 && C3.sub(h3), h3.props = b, h3.state || (h3.state = {}), h3.context = M2, h3.__n = i3, p3 = h3.__d = true, h3.__h = [], h3._sb = []), S2 && null == h3.__s && (h3.__s = h3.state), S2 && null != j3.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = d({}, h3.__s)), d(h3.__s, j3.getDerivedStateFromProps(b, h3.__s))), v3 = h3.props, y3 = h3.state, h3.__v = u3, p3) S2 && null == j3.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), S2 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
3096
+ else {
3097
+ if (S2 && null == j3.getDerivedStateFromProps && b !== v3 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(b, M2), !h3.__e && null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(b, h3.__s, M2) || u3.__v == t3.__v) {
3098
+ for (u3.__v != t3.__v && (h3.props = b, h3.state = h3.__s, h3.__d = false), u3.__e = t3.__e, u3.__k = t3.__k, u3.__k.some(function(n3) {
3099
+ n3 && (n3.__ = u3);
3100
+ }), $2 = 0; $2 < h3._sb.length; $2++) h3.__h.push(h3._sb[$2]);
3101
+ h3._sb = [], h3.__h.length && e3.push(h3);
3102
+ break n;
3103
+ }
3104
+ null != h3.componentWillUpdate && h3.componentWillUpdate(b, h3.__s, M2), S2 && null != h3.componentDidUpdate && h3.__h.push(function() {
3105
+ h3.componentDidUpdate(v3, y3, _2);
3106
+ });
3107
+ }
3108
+ if (h3.context = M2, h3.props = b, h3.__P = n2, h3.__e = false, P2 = l.__r, A2 = 0, S2) {
3109
+ for (h3.state = h3.__s, h3.__d = false, P2 && P2(u3), a3 = h3.render(h3.props, h3.state, h3.context), H = 0; H < h3._sb.length; H++) h3.__h.push(h3._sb[H]);
3110
+ h3._sb = [];
3111
+ } else do {
3112
+ h3.__d = false, P2 && P2(u3), a3 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
3113
+ } while (h3.__d && ++A2 < 25);
3114
+ h3.state = h3.__s, null != h3.getChildContext && (i3 = d(d({}, i3), h3.getChildContext())), S2 && !p3 && null != h3.getSnapshotBeforeUpdate && (_2 = h3.getSnapshotBeforeUpdate(v3, y3)), L2 = a3, null != a3 && a3.type === k && null == a3.key && (L2 = V(a3.props.children)), f3 = I(n2, w(L2) ? L2 : [L2], u3, t3, i3, r4, o3, e3, f3, c3, s3), h3.base = u3.__e, u3.__u &= -161, h3.__h.length && e3.push(h3), m3 && (h3.__E = h3.__ = null);
3115
+ } catch (n3) {
3116
+ if (u3.__v = null, c3 || null != o3) if (n3.then) {
3117
+ for (u3.__u |= c3 ? 160 : 128; f3 && 8 == f3.nodeType && f3.nextSibling; ) f3 = f3.nextSibling;
3118
+ o3[o3.indexOf(f3)] = null, u3.__e = f3;
3119
+ } else {
3120
+ for (T2 = o3.length; T2--; ) g(o3[T2]);
3121
+ z(u3);
3122
+ }
3123
+ else u3.__e = t3.__e, u3.__k = t3.__k, n3.then || z(u3);
3124
+ l.__e(n3, u3, t3);
3125
+ }
3126
+ else null == o3 && u3.__v == t3.__v ? (u3.__k = t3.__k, u3.__e = t3.__e) : f3 = u3.__e = q(t3.__e, u3, t3, i3, r4, o3, e3, c3, s3);
3127
+ return (a3 = l.diffed) && a3(u3), 128 & u3.__u ? void 0 : f3;
3128
+ }
3129
+ function z(n2) {
3130
+ n2 && n2.__c && (n2.__c.__e = true), n2 && n2.__k && n2.__k.forEach(z);
3131
+ }
3132
+ function N(n2, u3, t3) {
3133
+ for (var i3 = 0; i3 < t3.length; i3++) B(t3[i3], t3[++i3], t3[++i3]);
3134
+ l.__c && l.__c(u3, n2), n2.some(function(u4) {
3135
+ try {
3136
+ n2 = u4.__h, u4.__h = [], n2.some(function(n3) {
3137
+ n3.call(u4);
3138
+ });
3139
+ } catch (n3) {
3140
+ l.__e(n3, u4.__v);
3141
+ }
3142
+ });
3143
+ }
3144
+ function V(n2) {
3145
+ return "object" != typeof n2 || null == n2 || n2.__b && n2.__b > 0 ? n2 : w(n2) ? n2.map(V) : d({}, n2);
3146
+ }
3147
+ function q(u3, t3, i3, r4, o3, e3, f3, c3, s3) {
3148
+ var a3, h3, v3, y3, d3, _2, m3, b = i3.props, k3 = t3.props, x2 = t3.type;
3149
+ if ("svg" == x2 ? o3 = "http://www.w3.org/2000/svg" : "math" == x2 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != e3) {
3150
+ for (a3 = 0; a3 < e3.length; a3++) if ((d3 = e3[a3]) && "setAttribute" in d3 == !!x2 && (x2 ? d3.localName == x2 : 3 == d3.nodeType)) {
3151
+ u3 = d3, e3[a3] = null;
3152
+ break;
3153
+ }
3154
+ }
3155
+ if (null == u3) {
3156
+ if (null == x2) return document.createTextNode(k3);
3157
+ u3 = document.createElementNS(o3, x2, k3.is && k3), c3 && (l.__m && l.__m(t3, e3), c3 = false), e3 = null;
3158
+ }
3159
+ if (null == x2) b === k3 || c3 && u3.data == k3 || (u3.data = k3);
3160
+ else {
3161
+ if (e3 = e3 && n.call(u3.childNodes), b = i3.props || p, !c3 && null != e3) for (b = {}, a3 = 0; a3 < u3.attributes.length; a3++) b[(d3 = u3.attributes[a3]).name] = d3.value;
3162
+ for (a3 in b) if (d3 = b[a3], "children" == a3) ;
3163
+ else if ("dangerouslySetInnerHTML" == a3) v3 = d3;
3164
+ else if (!(a3 in k3)) {
3165
+ if ("value" == a3 && "defaultValue" in k3 || "checked" == a3 && "defaultChecked" in k3) continue;
3166
+ j(u3, a3, null, d3, o3);
3167
+ }
3168
+ for (a3 in k3) d3 = k3[a3], "children" == a3 ? y3 = d3 : "dangerouslySetInnerHTML" == a3 ? h3 = d3 : "value" == a3 ? _2 = d3 : "checked" == a3 ? m3 = d3 : c3 && "function" != typeof d3 || b[a3] === d3 || j(u3, a3, d3, b[a3], o3);
3169
+ if (h3) c3 || v3 && (h3.__html == v3.__html || h3.__html == u3.innerHTML) || (u3.innerHTML = h3.__html), t3.__k = [];
3170
+ else if (v3 && (u3.innerHTML = ""), I("template" == t3.type ? u3.content : u3, w(y3) ? y3 : [y3], t3, i3, r4, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o3, e3, f3, e3 ? e3[0] : i3.__k && S(i3, 0), c3, s3), null != e3) for (a3 = e3.length; a3--; ) g(e3[a3]);
3171
+ c3 || (a3 = "value", "progress" == x2 && null == _2 ? u3.removeAttribute("value") : null != _2 && (_2 !== u3[a3] || "progress" == x2 && !_2 || "option" == x2 && _2 != b[a3]) && j(u3, a3, _2, b[a3], o3), a3 = "checked", null != m3 && m3 != u3[a3] && j(u3, a3, m3, b[a3], o3));
3172
+ }
3173
+ return u3;
3174
+ }
3175
+ function B(n2, u3, t3) {
3176
+ try {
3177
+ if ("function" == typeof n2) {
3178
+ var i3 = "function" == typeof n2.__u;
3179
+ i3 && n2.__u(), i3 && null == u3 || (n2.__u = n2(u3));
3180
+ } else n2.current = u3;
3181
+ } catch (n3) {
3182
+ l.__e(n3, t3);
3183
+ }
3184
+ }
3185
+ function D(n2, u3, t3) {
3186
+ var i3, r4;
3187
+ if (l.unmount && l.unmount(n2), (i3 = n2.ref) && (i3.current && i3.current != n2.__e || B(i3, null, u3)), null != (i3 = n2.__c)) {
3188
+ if (i3.componentWillUnmount) try {
3189
+ i3.componentWillUnmount();
3190
+ } catch (n3) {
3191
+ l.__e(n3, u3);
3192
+ }
3193
+ i3.base = i3.__P = null;
3194
+ }
3195
+ if (i3 = n2.__k) for (r4 = 0; r4 < i3.length; r4++) i3[r4] && D(i3[r4], u3, t3 || "function" != typeof n2.type);
3196
+ t3 || g(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
3197
+ }
3198
+ function E(n2, l3, u3) {
3199
+ return this.constructor(n2, u3);
3200
+ }
3201
+ function G(u3, t3, i3) {
3202
+ var r4, o3, e3, f3;
3203
+ t3 == document && (t3 = document.documentElement), l.__ && l.__(u3, t3), o3 = (r4 = "function" == typeof i3) ? null : i3 && i3.__k || t3.__k, e3 = [], f3 = [], O(t3, u3 = (!r4 && i3 || t3).__k = _(k, null, [u3]), o3 || p, p, t3.namespaceURI, !r4 && i3 ? [i3] : o3 ? null : t3.firstChild ? n.call(t3.childNodes) : null, e3, !r4 && i3 ? i3 : o3 ? o3.__e : t3.firstChild, r4, f3), N(e3, u3, f3);
3204
+ }
3205
+ n = v.slice, l = { __e: function(n2, l3, u3, t3) {
3206
+ for (var i3, r4, o3; l3 = l3.__; ) if ((i3 = l3.__c) && !i3.__) try {
3207
+ if ((r4 = i3.constructor) && null != r4.getDerivedStateFromError && (i3.setState(r4.getDerivedStateFromError(n2)), o3 = i3.__d), null != i3.componentDidCatch && (i3.componentDidCatch(n2, t3 || {}), o3 = i3.__d), o3) return i3.__E = i3;
3208
+ } catch (l4) {
3209
+ n2 = l4;
3210
+ }
3211
+ throw n2;
3212
+ } }, u = 0, t = function(n2) {
3213
+ return null != n2 && null == n2.constructor;
3214
+ }, x.prototype.setState = function(n2, l3) {
3215
+ var u3;
3216
+ u3 = null != this.__s && this.__s != this.state ? this.__s : this.__s = d({}, this.state), "function" == typeof n2 && (n2 = n2(d({}, u3), this.props)), n2 && d(u3, n2), null != n2 && this.__v && (l3 && this._sb.push(l3), M(this));
3217
+ }, x.prototype.forceUpdate = function(n2) {
3218
+ this.__v && (this.__e = true, n2 && this.__h.push(n2), M(this));
3219
+ }, x.prototype.render = k, i = [], o = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e = function(n2, l3) {
3220
+ return n2.__v.__b - l3.__v.__b;
3221
+ }, $.__r = 0, f = /(PointerCapture)$|Capture$/i, c = 0, s = F(false), a = F(true), h = 0;
3222
+
3223
+ // ../../node_modules/.pnpm/preact@10.27.2/node_modules/preact/hooks/dist/hooks.module.js
3224
+ init_polyfills();
3225
+ var t2;
3226
+ var r3;
3227
+ var u2;
3228
+ var i2;
3229
+ var o2 = 0;
3230
+ var f2 = [];
3231
+ var c2 = l;
3232
+ var e2 = c2.__b;
3233
+ var a2 = c2.__r;
3234
+ var v2 = c2.diffed;
3235
+ var l2 = c2.__c;
3236
+ var m2 = c2.unmount;
3237
+ var s2 = c2.__;
3238
+ function p2(n2, t3) {
3239
+ c2.__h && c2.__h(r3, n2, o2 || t3), o2 = 0;
3240
+ var u3 = r3.__H || (r3.__H = { __: [], __h: [] });
3241
+ return n2 >= u3.__.length && u3.__.push({}), u3.__[n2];
3242
+ }
3243
+ function d2(n2) {
3244
+ return o2 = 1, h2(D2, n2);
3245
+ }
3246
+ function h2(n2, u3, i3) {
3247
+ var o3 = p2(t2++, 2);
3248
+ if (o3.t = n2, !o3.__c && (o3.__ = [i3 ? i3(u3) : D2(void 0, u3), function(n3) {
3249
+ var t3 = o3.__N ? o3.__N[0] : o3.__[0], r4 = o3.t(t3, n3);
3250
+ t3 !== r4 && (o3.__N = [r4, o3.__[1]], o3.__c.setState({}));
3251
+ }], o3.__c = r3, !r3.__f)) {
3252
+ var f3 = function(n3, t3, r4) {
3253
+ if (!o3.__c.__H) return true;
3254
+ var u4 = o3.__c.__H.__.filter(function(n4) {
3255
+ return !!n4.__c;
3256
+ });
3257
+ if (u4.every(function(n4) {
3258
+ return !n4.__N;
3259
+ })) return !c3 || c3.call(this, n3, t3, r4);
3260
+ var i4 = o3.__c.props !== n3;
3261
+ return u4.forEach(function(n4) {
3262
+ if (n4.__N) {
3263
+ var t4 = n4.__[0];
3264
+ n4.__ = n4.__N, n4.__N = void 0, t4 !== n4.__[0] && (i4 = true);
3265
+ }
3266
+ }), c3 && c3.call(this, n3, t3, r4) || i4;
3267
+ };
3268
+ r3.__f = true;
3269
+ var c3 = r3.shouldComponentUpdate, e3 = r3.componentWillUpdate;
3270
+ r3.componentWillUpdate = function(n3, t3, r4) {
3271
+ if (this.__e) {
3272
+ var u4 = c3;
3273
+ c3 = void 0, f3(n3, t3, r4), c3 = u4;
3274
+ }
3275
+ e3 && e3.call(this, n3, t3, r4);
3276
+ }, r3.shouldComponentUpdate = f3;
3277
+ }
3278
+ return o3.__N || o3.__;
3279
+ }
3280
+ function y2(n2, u3) {
3281
+ var i3 = p2(t2++, 3);
3282
+ !c2.__s && C2(i3.__H, u3) && (i3.__ = n2, i3.u = u3, r3.__H.__h.push(i3));
3283
+ }
3284
+ function j2() {
3285
+ for (var n2; n2 = f2.shift(); ) if (n2.__P && n2.__H) try {
3286
+ n2.__H.__h.forEach(z2), n2.__H.__h.forEach(B2), n2.__H.__h = [];
3287
+ } catch (t3) {
3288
+ n2.__H.__h = [], c2.__e(t3, n2.__v);
3289
+ }
3290
+ }
3291
+ c2.__b = function(n2) {
3292
+ r3 = null, e2 && e2(n2);
3293
+ }, c2.__ = function(n2, t3) {
3294
+ n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
3295
+ }, c2.__r = function(n2) {
3296
+ a2 && a2(n2), t2 = 0;
3297
+ var i3 = (r3 = n2.__c).__H;
3298
+ i3 && (u2 === r3 ? (i3.__h = [], r3.__h = [], i3.__.forEach(function(n3) {
3299
+ n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
3300
+ })) : (i3.__h.forEach(z2), i3.__h.forEach(B2), i3.__h = [], t2 = 0)), u2 = r3;
3301
+ }, c2.diffed = function(n2) {
3302
+ v2 && v2(n2);
3303
+ var t3 = n2.__c;
3304
+ t3 && t3.__H && (t3.__H.__h.length && (1 !== f2.push(t3) && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.forEach(function(n3) {
3305
+ n3.u && (n3.__H = n3.u), n3.u = void 0;
3306
+ })), u2 = r3 = null;
3307
+ }, c2.__c = function(n2, t3) {
3308
+ t3.some(function(n3) {
3309
+ try {
3310
+ n3.__h.forEach(z2), n3.__h = n3.__h.filter(function(n4) {
3311
+ return !n4.__ || B2(n4);
3312
+ });
3313
+ } catch (r4) {
3314
+ t3.some(function(n4) {
3315
+ n4.__h && (n4.__h = []);
3316
+ }), t3 = [], c2.__e(r4, n3.__v);
3317
+ }
3318
+ }), l2 && l2(n2, t3);
3319
+ }, c2.unmount = function(n2) {
3320
+ m2 && m2(n2);
3321
+ var t3, r4 = n2.__c;
3322
+ r4 && r4.__H && (r4.__H.__.forEach(function(n3) {
3323
+ try {
3324
+ z2(n3);
3325
+ } catch (n4) {
3326
+ t3 = n4;
3327
+ }
3328
+ }), r4.__H = void 0, t3 && c2.__e(t3, r4.__v));
3329
+ };
3330
+ var k2 = "function" == typeof requestAnimationFrame;
3331
+ function w2(n2) {
3332
+ var t3, r4 = function() {
3333
+ clearTimeout(u3), k2 && cancelAnimationFrame(t3), setTimeout(n2);
3334
+ }, u3 = setTimeout(r4, 35);
3335
+ k2 && (t3 = requestAnimationFrame(r4));
3336
+ }
3337
+ function z2(n2) {
3338
+ var t3 = r3, u3 = n2.__c;
3339
+ "function" == typeof u3 && (n2.__c = void 0, u3()), r3 = t3;
3340
+ }
3341
+ function B2(n2) {
3342
+ var t3 = r3;
3343
+ n2.__c = n2.__(), r3 = t3;
3344
+ }
3345
+ function C2(n2, t3) {
3346
+ return !n2 || n2.length !== t3.length || t3.some(function(t4, r4) {
3347
+ return t4 !== n2[r4];
3348
+ });
3349
+ }
3350
+ function D2(n2, t3) {
3351
+ return "function" == typeof t3 ? t3(n2) : t3;
3352
+ }
3353
+
3354
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/Snackbar/Snackbar-css.js
3355
+ init_polyfills();
3356
+ var Snackbar_css_default = /* @__PURE__ */ (() => `.-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}`)();
3357
+
3358
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/Snackbar/Snackbar.js
3359
+ var cblogo = `data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+`;
3360
+ var gearIcon = `data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=`;
3361
+ var Snackbar = class {
3362
+ constructor() {
3363
+ this.items = /* @__PURE__ */ new Map();
3364
+ this.nextItemKey = 0;
3365
+ this.root = null;
3366
+ this.darkMode = isDarkMode();
3367
+ }
3368
+ attach(el) {
3369
+ this.root = document.createElement("div");
3370
+ this.root.className = "-cbwsdk-snackbar-root";
3371
+ el.appendChild(this.root);
3372
+ this.render();
3373
+ }
3374
+ presentItem(itemProps) {
3375
+ const key = this.nextItemKey++;
3376
+ this.items.set(key, itemProps);
3377
+ this.render();
3378
+ return () => {
3379
+ this.items.delete(key);
3380
+ this.render();
3381
+ };
3382
+ }
3383
+ clear() {
3384
+ this.items.clear();
3385
+ this.render();
3386
+ }
3387
+ render() {
3388
+ if (!this.root) {
3389
+ return;
3390
+ }
3391
+ G(_(
3392
+ "div",
3393
+ null,
3394
+ _(SnackbarContainer, { darkMode: this.darkMode }, Array.from(this.items.entries()).map(([key, itemProps]) => _(SnackbarInstance, Object.assign({}, itemProps, { key }))))
3395
+ ), this.root);
3396
+ }
3397
+ };
3398
+ var SnackbarContainer = (props) => _(
3399
+ "div",
3400
+ { class: clsx("-cbwsdk-snackbar-container") },
3401
+ _("style", null, Snackbar_css_default),
3402
+ _("div", { class: "-cbwsdk-snackbar" }, props.children)
3403
+ );
3404
+ var SnackbarInstance = ({ autoExpand, message, menuItems }) => {
3405
+ const [hidden, setHidden] = d2(true);
3406
+ const [expanded, setExpanded] = d2(autoExpand !== null && autoExpand !== void 0 ? autoExpand : false);
3407
+ y2(() => {
3408
+ const timers = [
3409
+ window.setTimeout(() => {
3410
+ setHidden(false);
3411
+ }, 1),
3412
+ window.setTimeout(() => {
3413
+ setExpanded(true);
3414
+ }, 1e4)
3415
+ ];
3416
+ return () => {
3417
+ timers.forEach(window.clearTimeout);
3418
+ };
3419
+ });
3420
+ const toggleExpanded = () => {
3421
+ setExpanded(!expanded);
3422
+ };
3423
+ return _(
3424
+ "div",
3425
+ { class: clsx("-cbwsdk-snackbar-instance", hidden && "-cbwsdk-snackbar-instance-hidden", expanded && "-cbwsdk-snackbar-instance-expanded") },
3426
+ _(
3427
+ "div",
3428
+ { class: "-cbwsdk-snackbar-instance-header", onClick: toggleExpanded },
3429
+ _("img", { src: cblogo, class: "-cbwsdk-snackbar-instance-header-cblogo" }),
3430
+ " ",
3431
+ _("div", { class: "-cbwsdk-snackbar-instance-header-message" }, message),
3432
+ _(
3433
+ "div",
3434
+ { class: "-gear-container" },
3435
+ !expanded && _(
3436
+ "svg",
3437
+ { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
3438
+ _("circle", { cx: "12", cy: "12", r: "12", fill: "#F5F7F8" })
3439
+ ),
3440
+ _("img", { src: gearIcon, class: "-gear-icon", title: "Expand" })
3441
+ )
3442
+ ),
3443
+ menuItems && menuItems.length > 0 && _("div", { class: "-cbwsdk-snackbar-instance-menu" }, menuItems.map((action, i3) => _(
3444
+ "div",
3445
+ { class: clsx("-cbwsdk-snackbar-instance-menu-item", action.isRed && "-cbwsdk-snackbar-instance-menu-item-is-red"), onClick: action.onClick, key: i3 },
3446
+ _(
3447
+ "svg",
3448
+ { width: action.svgWidth, height: action.svgHeight, viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
3449
+ _("path", { "fill-rule": action.defaultFillRule, "clip-rule": action.defaultClipRule, d: action.path, fill: "#AAAAAA" })
3450
+ ),
3451
+ _("span", { class: clsx("-cbwsdk-snackbar-instance-menu-item-info", action.isRed && "-cbwsdk-snackbar-instance-menu-item-info-is-red") }, action.info)
3452
+ )))
3453
+ );
3454
+ };
3455
+
3456
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/WalletLinkRelayUI.js
3457
+ var RETRY_SVG_PATH = "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z";
3458
+ var WalletLinkRelayUI = class {
3459
+ constructor() {
3460
+ this.attached = false;
3461
+ this.snackbar = new Snackbar();
3462
+ }
3463
+ attach() {
3464
+ if (this.attached) {
3465
+ throw new Error("Coinbase Wallet SDK UI is already attached");
3466
+ }
3467
+ const el = document.documentElement;
3468
+ const container = document.createElement("div");
3469
+ container.className = "-cbwsdk-css-reset";
3470
+ el.appendChild(container);
3471
+ this.snackbar.attach(container);
3472
+ this.attached = true;
3473
+ injectCssReset();
3474
+ }
3475
+ showConnecting(options) {
3476
+ let snackbarProps;
3477
+ if (options.isUnlinkedErrorState) {
3478
+ snackbarProps = {
3479
+ autoExpand: true,
3480
+ message: "Connection lost",
3481
+ menuItems: [
3482
+ {
3483
+ isRed: false,
3484
+ info: "Reset connection",
3485
+ svgWidth: "10",
3486
+ svgHeight: "11",
3487
+ path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",
3488
+ defaultFillRule: "evenodd",
3489
+ defaultClipRule: "evenodd",
3490
+ onClick: options.onResetConnection
3491
+ }
3492
+ ]
3493
+ };
3494
+ } else {
3495
+ snackbarProps = {
3496
+ message: "Confirm on phone",
3497
+ menuItems: [
3498
+ {
3499
+ isRed: true,
3500
+ info: "Cancel transaction",
3501
+ svgWidth: "11",
3502
+ svgHeight: "11",
3503
+ path: "M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",
3504
+ defaultFillRule: "inherit",
3505
+ defaultClipRule: "inherit",
3506
+ onClick: options.onCancel
3507
+ },
3508
+ {
3509
+ isRed: false,
3510
+ info: "Reset connection",
3511
+ svgWidth: "10",
3512
+ svgHeight: "11",
3513
+ path: RETRY_SVG_PATH,
3514
+ defaultFillRule: "evenodd",
3515
+ defaultClipRule: "evenodd",
3516
+ onClick: options.onResetConnection
3517
+ }
3518
+ ]
3519
+ };
3520
+ }
3521
+ return this.snackbar.presentItem(snackbarProps);
3522
+ }
3523
+ };
3524
+
3525
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/WLMobileRelayUI.js
3526
+ init_polyfills();
3527
+
3528
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/RedirectDialog/RedirectDialog.js
3529
+ init_polyfills();
3530
+
3531
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/RedirectDialog/RedirectDialog-css.js
3532
+ init_polyfills();
3533
+ var RedirectDialog_css_default = /* @__PURE__ */ (() => `.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}`)();
3534
+
3535
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/RedirectDialog/RedirectDialog.js
3536
+ var RedirectDialog = class {
3537
+ constructor() {
3538
+ this.root = null;
3539
+ this.darkMode = isDarkMode();
3540
+ }
3541
+ attach() {
3542
+ const el = document.documentElement;
3543
+ this.root = document.createElement("div");
3544
+ this.root.className = "-cbwsdk-css-reset";
3545
+ el.appendChild(this.root);
3546
+ injectCssReset();
3547
+ }
3548
+ present(props) {
3549
+ this.render(props);
3550
+ }
3551
+ clear() {
3552
+ this.render(null);
3553
+ }
3554
+ render(props) {
3555
+ if (!this.root)
3556
+ return;
3557
+ G(null, this.root);
3558
+ if (!props)
3559
+ return;
3560
+ G(_(RedirectDialogContent, Object.assign({}, props, { onDismiss: () => {
3561
+ this.clear();
3562
+ }, darkMode: this.darkMode })), this.root);
3563
+ }
3564
+ };
3565
+ var RedirectDialogContent = ({ title, buttonText, darkMode, onButtonClick, onDismiss }) => {
3566
+ const theme = darkMode ? "dark" : "light";
3567
+ return _(
3568
+ SnackbarContainer,
3569
+ { darkMode },
3570
+ _(
3571
+ "div",
3572
+ { class: "-cbwsdk-redirect-dialog" },
3573
+ _("style", null, RedirectDialog_css_default),
3574
+ _("div", { class: "-cbwsdk-redirect-dialog-backdrop", onClick: onDismiss }),
3575
+ _(
3576
+ "div",
3577
+ { class: clsx("-cbwsdk-redirect-dialog-box", theme) },
3578
+ _("p", null, title),
3579
+ _("button", { onClick: onButtonClick }, buttonText)
3580
+ )
3581
+ )
3582
+ );
3583
+ };
3584
+
3585
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/constants.js
3586
+ init_polyfills();
3587
+ var CB_KEYS_URL = "https://keys.coinbase.com/connect";
3588
+ var CB_WALLET_RPC_URL = "https://rpc.wallet.coinbase.com";
3589
+ var WALLETLINK_URL = "https://www.walletlink.org";
3590
+ var CBW_MOBILE_DEEPLINK_URL = "https://go.cb-w.com/walletlink";
3591
+
3592
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/WLMobileRelayUI.js
3593
+ var WLMobileRelayUI = class {
3594
+ constructor() {
3595
+ this.attached = false;
3596
+ this.redirectDialog = new RedirectDialog();
3597
+ }
3598
+ attach() {
3599
+ if (this.attached) {
3600
+ throw new Error("Coinbase Wallet SDK UI is already attached");
3601
+ }
3602
+ this.redirectDialog.attach();
3603
+ this.attached = true;
3604
+ }
3605
+ redirectToCoinbaseWallet(walletLinkUrl) {
3606
+ const url = new URL(CBW_MOBILE_DEEPLINK_URL);
3607
+ url.searchParams.append("redirect_url", getLocation().href);
3608
+ if (walletLinkUrl) {
3609
+ url.searchParams.append("wl_url", walletLinkUrl);
3610
+ }
3611
+ const anchorTag = document.createElement("a");
3612
+ anchorTag.target = "cbw-opener";
3613
+ anchorTag.href = url.href;
3614
+ anchorTag.rel = "noreferrer noopener";
3615
+ anchorTag.click();
3616
+ }
3617
+ openCoinbaseWalletDeeplink(walletLinkUrl) {
3618
+ this.redirectToCoinbaseWallet(walletLinkUrl);
3619
+ setTimeout(() => {
3620
+ this.redirectDialog.present({
3621
+ title: "Redirecting to Coinbase Wallet...",
3622
+ buttonText: "Open",
3623
+ onButtonClick: () => {
3624
+ this.redirectToCoinbaseWallet(walletLinkUrl);
3625
+ }
3626
+ });
3627
+ }, 99);
3628
+ }
3629
+ showConnecting(_options) {
3630
+ return () => {
3631
+ this.redirectDialog.clear();
3632
+ };
3633
+ }
3634
+ };
3635
+
3636
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/WalletLinkRelay.js
3637
+ var WalletLinkRelay = class _WalletLinkRelay {
3638
+ constructor(options) {
3639
+ this.chainCallbackParams = { chainId: "", jsonRpcUrl: "" };
3640
+ this.isMobileWeb = isMobileWeb();
3641
+ this.linkedUpdated = (linked) => {
3642
+ this.isLinked = linked;
3643
+ const cachedAddresses = this.storage.getItem(LOCAL_STORAGE_ADDRESSES_KEY);
3644
+ if (linked) {
3645
+ this._session.linked = linked;
3646
+ }
3647
+ this.isUnlinkedErrorState = false;
3648
+ if (cachedAddresses) {
3649
+ const addresses = cachedAddresses.split(" ");
3650
+ const wasConnectedViaStandalone = this.storage.getItem("IsStandaloneSigning") === "true";
3651
+ if (addresses[0] !== "" && !linked && this._session.linked && !wasConnectedViaStandalone) {
3652
+ this.isUnlinkedErrorState = true;
3653
+ }
3654
+ }
3655
+ };
3656
+ this.metadataUpdated = (key, value) => {
3657
+ this.storage.setItem(key, value);
3658
+ };
3659
+ this.chainUpdated = (chainId, jsonRpcUrl) => {
3660
+ if (this.chainCallbackParams.chainId === chainId && this.chainCallbackParams.jsonRpcUrl === jsonRpcUrl) {
3661
+ return;
3662
+ }
3663
+ this.chainCallbackParams = {
3664
+ chainId,
3665
+ jsonRpcUrl
3666
+ };
3667
+ if (this.chainCallback) {
3668
+ this.chainCallback(jsonRpcUrl, Number.parseInt(chainId, 10));
3669
+ }
3670
+ };
3671
+ this.accountUpdated = (selectedAddress) => {
3672
+ if (this.accountsCallback) {
3673
+ this.accountsCallback([selectedAddress]);
3674
+ }
3675
+ if (_WalletLinkRelay.accountRequestCallbackIds.size > 0) {
3676
+ Array.from(_WalletLinkRelay.accountRequestCallbackIds.values()).forEach((id) => {
3677
+ this.invokeCallback(id, {
3678
+ method: "requestEthereumAccounts",
3679
+ result: [selectedAddress]
3680
+ });
3681
+ });
3682
+ _WalletLinkRelay.accountRequestCallbackIds.clear();
3683
+ }
3684
+ };
3685
+ this.resetAndReload = this.resetAndReload.bind(this);
3686
+ this.linkAPIUrl = options.linkAPIUrl;
3687
+ this.storage = options.storage;
3688
+ this.metadata = options.metadata;
3689
+ this.accountsCallback = options.accountsCallback;
3690
+ this.chainCallback = options.chainCallback;
3691
+ const { session, ui, connection } = this.subscribe();
3692
+ this._session = session;
3693
+ this.connection = connection;
3694
+ this.relayEventManager = new RelayEventManager();
3695
+ this.ui = ui;
3696
+ this.ui.attach();
3697
+ }
3698
+ subscribe() {
3699
+ const session = WalletLinkSession.load(this.storage) || WalletLinkSession.create(this.storage);
3700
+ const { linkAPIUrl } = this;
3701
+ const connection = new WalletLinkConnection({
3702
+ session,
3703
+ linkAPIUrl,
3704
+ listener: this
3705
+ });
3706
+ const ui = this.isMobileWeb ? new WLMobileRelayUI() : new WalletLinkRelayUI();
3707
+ connection.connect();
3708
+ return { session, ui, connection };
3709
+ }
3710
+ resetAndReload() {
3711
+ this.connection.destroy().then(() => {
3712
+ const storedSession = WalletLinkSession.load(this.storage);
3713
+ if ((storedSession === null || storedSession === void 0 ? void 0 : storedSession.id) === this._session.id) {
3714
+ ScopedLocalStorage.clearAll();
3715
+ }
3716
+ document.location.reload();
3717
+ }).catch((_2) => {
3718
+ });
3719
+ }
3720
+ signEthereumTransaction(params) {
3721
+ return this.sendRequest({
3722
+ method: "signEthereumTransaction",
3723
+ params: {
3724
+ fromAddress: params.fromAddress,
3725
+ toAddress: params.toAddress,
3726
+ weiValue: bigIntStringFromBigInt(params.weiValue),
3727
+ data: hexStringFromBuffer(params.data, true),
3728
+ nonce: params.nonce,
3729
+ gasPriceInWei: params.gasPriceInWei ? bigIntStringFromBigInt(params.gasPriceInWei) : null,
3730
+ maxFeePerGas: params.gasPriceInWei ? bigIntStringFromBigInt(params.gasPriceInWei) : null,
3731
+ maxPriorityFeePerGas: params.gasPriceInWei ? bigIntStringFromBigInt(params.gasPriceInWei) : null,
3732
+ gasLimit: params.gasLimit ? bigIntStringFromBigInt(params.gasLimit) : null,
3733
+ chainId: params.chainId,
3734
+ shouldSubmit: false
3735
+ }
3736
+ });
3737
+ }
3738
+ signAndSubmitEthereumTransaction(params) {
3739
+ return this.sendRequest({
3740
+ method: "signEthereumTransaction",
3741
+ params: {
3742
+ fromAddress: params.fromAddress,
3743
+ toAddress: params.toAddress,
3744
+ weiValue: bigIntStringFromBigInt(params.weiValue),
3745
+ data: hexStringFromBuffer(params.data, true),
3746
+ nonce: params.nonce,
3747
+ gasPriceInWei: params.gasPriceInWei ? bigIntStringFromBigInt(params.gasPriceInWei) : null,
3748
+ maxFeePerGas: params.maxFeePerGas ? bigIntStringFromBigInt(params.maxFeePerGas) : null,
3749
+ maxPriorityFeePerGas: params.maxPriorityFeePerGas ? bigIntStringFromBigInt(params.maxPriorityFeePerGas) : null,
3750
+ gasLimit: params.gasLimit ? bigIntStringFromBigInt(params.gasLimit) : null,
3751
+ chainId: params.chainId,
3752
+ shouldSubmit: true
3753
+ }
3754
+ });
3755
+ }
3756
+ submitEthereumTransaction(signedTransaction, chainId) {
3757
+ return this.sendRequest({
3758
+ method: "submitEthereumTransaction",
3759
+ params: {
3760
+ signedTransaction: hexStringFromBuffer(signedTransaction, true),
3761
+ chainId
3762
+ }
3763
+ });
3764
+ }
3765
+ getWalletLinkSession() {
3766
+ return this._session;
3767
+ }
3768
+ sendRequest(request) {
3769
+ let hideSnackbarItem = null;
3770
+ const id = randomBytesHex(8);
3771
+ const cancel = (error) => {
3772
+ this.publishWeb3RequestCanceledEvent(id);
3773
+ this.handleErrorResponse(id, request.method, error);
3774
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3775
+ };
3776
+ return new Promise((resolve, reject) => {
3777
+ {
3778
+ hideSnackbarItem = this.ui.showConnecting({
3779
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
3780
+ onCancel: cancel,
3781
+ onResetConnection: this.resetAndReload
3782
+ // eslint-disable-line @typescript-eslint/unbound-method
3783
+ });
3784
+ }
3785
+ this.relayEventManager.callbacks.set(id, (response) => {
3786
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3787
+ if (isErrorResponse(response)) {
3788
+ return reject(new Error(response.errorMessage));
3789
+ }
3790
+ resolve(response);
3791
+ });
3792
+ this.publishWeb3RequestEvent(id, request);
3793
+ });
3794
+ }
3795
+ publishWeb3RequestEvent(id, request) {
3796
+ const message = { type: "WEB3_REQUEST", id, request };
3797
+ this.publishEvent("Web3Request", message, true).then((_2) => {
3798
+ }).catch((err) => {
3799
+ this.handleWeb3ResponseMessage(message.id, {
3800
+ method: request.method,
3801
+ errorMessage: err.message
3802
+ });
3803
+ });
3804
+ if (this.isMobileWeb) {
3805
+ this.openCoinbaseWalletDeeplink(request.method);
3806
+ }
3807
+ }
3808
+ // copied from MobileRelay
3809
+ openCoinbaseWalletDeeplink(method) {
3810
+ if (!(this.ui instanceof WLMobileRelayUI))
3811
+ return;
3812
+ switch (method) {
3813
+ case "requestEthereumAccounts":
3814
+ // requestEthereumAccounts is handled via popup
3815
+ case "switchEthereumChain":
3816
+ return;
3817
+ default:
3818
+ window.addEventListener("blur", () => {
3819
+ window.addEventListener("focus", () => {
3820
+ this.connection.checkUnseenEvents();
3821
+ }, { once: true });
3822
+ }, { once: true });
3823
+ this.ui.openCoinbaseWalletDeeplink();
3824
+ break;
3825
+ }
3826
+ }
3827
+ publishWeb3RequestCanceledEvent(id) {
3828
+ const message = {
3829
+ type: "WEB3_REQUEST_CANCELED",
3830
+ id
3831
+ };
3832
+ this.publishEvent("Web3RequestCanceled", message, false).then();
3833
+ }
3834
+ publishEvent(event, message, callWebhook) {
3835
+ return this.connection.publishEvent(event, message, callWebhook);
3836
+ }
3837
+ handleWeb3ResponseMessage(id, response) {
3838
+ if (response.method === "requestEthereumAccounts") {
3839
+ _WalletLinkRelay.accountRequestCallbackIds.forEach((id2) => this.invokeCallback(id2, response));
3840
+ _WalletLinkRelay.accountRequestCallbackIds.clear();
3841
+ return;
3842
+ }
3843
+ this.invokeCallback(id, response);
3844
+ }
3845
+ handleErrorResponse(id, method, error) {
3846
+ var _a;
3847
+ const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "Unspecified error message.";
3848
+ this.handleWeb3ResponseMessage(id, {
3849
+ method,
3850
+ errorMessage
3851
+ });
3852
+ }
3853
+ invokeCallback(id, response) {
3854
+ const callback = this.relayEventManager.callbacks.get(id);
3855
+ if (callback) {
3856
+ callback(response);
3857
+ this.relayEventManager.callbacks.delete(id);
3858
+ }
3859
+ }
3860
+ requestEthereumAccounts() {
3861
+ const { appName, appLogoUrl } = this.metadata;
3862
+ const request = {
3863
+ method: "requestEthereumAccounts",
3864
+ params: {
3865
+ appName,
3866
+ appLogoUrl
3867
+ }
3868
+ };
3869
+ const hideSnackbarItem = null;
3870
+ const id = randomBytesHex(8);
3871
+ return new Promise((resolve, reject) => {
3872
+ this.relayEventManager.callbacks.set(id, (response) => {
3873
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3874
+ if (isErrorResponse(response)) {
3875
+ return reject(new Error(response.errorMessage));
3876
+ }
3877
+ resolve(response);
3878
+ });
3879
+ _WalletLinkRelay.accountRequestCallbackIds.add(id);
3880
+ this.publishWeb3RequestEvent(id, request);
3881
+ });
3882
+ }
3883
+ watchAsset(type, address, symbol, decimals, image, chainId) {
3884
+ const request = {
3885
+ method: "watchAsset",
3886
+ params: {
3887
+ type,
3888
+ options: {
3889
+ address,
3890
+ symbol,
3891
+ decimals,
3892
+ image
3893
+ },
3894
+ chainId
3895
+ }
3896
+ };
3897
+ let hideSnackbarItem = null;
3898
+ const id = randomBytesHex(8);
3899
+ const cancel = (error) => {
3900
+ this.publishWeb3RequestCanceledEvent(id);
3901
+ this.handleErrorResponse(id, request.method, error);
3902
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3903
+ };
3904
+ {
3905
+ hideSnackbarItem = this.ui.showConnecting({
3906
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
3907
+ onCancel: cancel,
3908
+ onResetConnection: this.resetAndReload
3909
+ // eslint-disable-line @typescript-eslint/unbound-method
3910
+ });
3911
+ }
3912
+ return new Promise((resolve, reject) => {
3913
+ this.relayEventManager.callbacks.set(id, (response) => {
3914
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3915
+ if (isErrorResponse(response)) {
3916
+ return reject(new Error(response.errorMessage));
3917
+ }
3918
+ resolve(response);
3919
+ });
3920
+ this.publishWeb3RequestEvent(id, request);
3921
+ });
3922
+ }
3923
+ addEthereumChain(chainId, rpcUrls, iconUrls, blockExplorerUrls, chainName, nativeCurrency) {
3924
+ const request = {
3925
+ method: "addEthereumChain",
3926
+ params: {
3927
+ chainId,
3928
+ rpcUrls,
3929
+ blockExplorerUrls,
3930
+ chainName,
3931
+ iconUrls,
3932
+ nativeCurrency
3933
+ }
3934
+ };
3935
+ let hideSnackbarItem = null;
3936
+ const id = randomBytesHex(8);
3937
+ const cancel = (error) => {
3938
+ this.publishWeb3RequestCanceledEvent(id);
3939
+ this.handleErrorResponse(id, request.method, error);
3940
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3941
+ };
3942
+ {
3943
+ hideSnackbarItem = this.ui.showConnecting({
3944
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
3945
+ onCancel: cancel,
3946
+ onResetConnection: this.resetAndReload
3947
+ // eslint-disable-line @typescript-eslint/unbound-method
3948
+ });
3949
+ }
3950
+ return new Promise((resolve, reject) => {
3951
+ this.relayEventManager.callbacks.set(id, (response) => {
3952
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3953
+ if (isErrorResponse(response)) {
3954
+ return reject(new Error(response.errorMessage));
3955
+ }
3956
+ resolve(response);
3957
+ });
3958
+ this.publishWeb3RequestEvent(id, request);
3959
+ });
3960
+ }
3961
+ switchEthereumChain(chainId, address) {
3962
+ const request = {
3963
+ method: "switchEthereumChain",
3964
+ params: Object.assign({ chainId }, { address })
3965
+ };
3966
+ let hideSnackbarItem = null;
3967
+ const id = randomBytesHex(8);
3968
+ const cancel = (error) => {
3969
+ this.publishWeb3RequestCanceledEvent(id);
3970
+ this.handleErrorResponse(id, request.method, error);
3971
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3972
+ };
3973
+ {
3974
+ hideSnackbarItem = this.ui.showConnecting({
3975
+ isUnlinkedErrorState: this.isUnlinkedErrorState,
3976
+ onCancel: cancel,
3977
+ onResetConnection: this.resetAndReload
3978
+ // eslint-disable-line @typescript-eslint/unbound-method
3979
+ });
3980
+ }
3981
+ return new Promise((resolve, reject) => {
3982
+ this.relayEventManager.callbacks.set(id, (response) => {
3983
+ hideSnackbarItem === null || hideSnackbarItem === void 0 ? void 0 : hideSnackbarItem();
3984
+ if (isErrorResponse(response) && response.errorCode) {
3985
+ return reject(standardErrors.provider.custom({
3986
+ code: response.errorCode,
3987
+ message: `Unrecognized chain ID. Try adding the chain using addEthereumChain first.`
3988
+ }));
3989
+ } else if (isErrorResponse(response)) {
3990
+ return reject(new Error(response.errorMessage));
3991
+ }
3992
+ resolve(response);
3993
+ });
3994
+ this.publishWeb3RequestEvent(id, request);
3995
+ });
3996
+ }
3997
+ };
3998
+ WalletLinkRelay.accountRequestCallbackIds = /* @__PURE__ */ new Set();
3999
+
4000
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/WalletLinkSigner.js
4001
+ var DEFAULT_CHAIN_ID_KEY = "DefaultChainId";
4002
+ var DEFAULT_JSON_RPC_URL = "DefaultJsonRpcUrl";
4003
+ var WalletLinkSigner = class {
4004
+ constructor(options) {
4005
+ this._relay = null;
4006
+ this._addresses = [];
4007
+ this.metadata = options.metadata;
4008
+ this._storage = new ScopedLocalStorage("walletlink", WALLETLINK_URL);
4009
+ this.callback = options.callback || null;
4010
+ const cachedAddresses = this._storage.getItem(LOCAL_STORAGE_ADDRESSES_KEY);
4011
+ if (cachedAddresses) {
4012
+ const addresses = cachedAddresses.split(" ");
4013
+ if (addresses[0] !== "") {
4014
+ this._addresses = addresses.map((address) => ensureAddressString(address));
4015
+ }
4016
+ }
4017
+ this.initializeRelay();
4018
+ }
4019
+ getSession() {
4020
+ const relay = this.initializeRelay();
4021
+ const { id, secret } = relay.getWalletLinkSession();
4022
+ return { id, secret };
4023
+ }
4024
+ async handshake() {
4025
+ await this._eth_requestAccounts();
4026
+ }
4027
+ get selectedAddress() {
4028
+ return this._addresses[0] || void 0;
4029
+ }
4030
+ get jsonRpcUrl() {
4031
+ var _a;
4032
+ return (_a = this._storage.getItem(DEFAULT_JSON_RPC_URL)) !== null && _a !== void 0 ? _a : void 0;
4033
+ }
4034
+ set jsonRpcUrl(value) {
4035
+ this._storage.setItem(DEFAULT_JSON_RPC_URL, value);
4036
+ }
4037
+ updateProviderInfo(jsonRpcUrl, chainId) {
4038
+ var _a;
4039
+ this.jsonRpcUrl = jsonRpcUrl;
4040
+ const originalChainId = this.getChainId();
4041
+ this._storage.setItem(DEFAULT_CHAIN_ID_KEY, chainId.toString(10));
4042
+ const chainChanged = ensureIntNumber(chainId) !== originalChainId;
4043
+ if (chainChanged) {
4044
+ (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, "chainChanged", hexStringFromNumber(chainId));
4045
+ }
4046
+ }
4047
+ async watchAsset(params) {
4048
+ const request = Array.isArray(params) ? params[0] : params;
4049
+ if (!request.type) {
4050
+ throw standardErrors.rpc.invalidParams("Type is required");
4051
+ }
4052
+ if ((request === null || request === void 0 ? void 0 : request.type) !== "ERC20") {
4053
+ throw standardErrors.rpc.invalidParams(`Asset of type '${request.type}' is not supported`);
4054
+ }
4055
+ if (!(request === null || request === void 0 ? void 0 : request.options)) {
4056
+ throw standardErrors.rpc.invalidParams("Options are required");
4057
+ }
4058
+ if (!(request === null || request === void 0 ? void 0 : request.options.address)) {
4059
+ throw standardErrors.rpc.invalidParams("Address is required");
4060
+ }
4061
+ const chainId = this.getChainId();
4062
+ const { address, symbol, image, decimals } = request.options;
4063
+ const relay = this.initializeRelay();
4064
+ const result = await relay.watchAsset(request.type, address, symbol, decimals, image, chainId === null || chainId === void 0 ? void 0 : chainId.toString());
4065
+ if (isErrorResponse(result))
4066
+ return false;
4067
+ return !!result.result;
4068
+ }
4069
+ async addEthereumChain(params) {
4070
+ var _a, _b;
4071
+ const request = params[0];
4072
+ if (((_a = request.rpcUrls) === null || _a === void 0 ? void 0 : _a.length) === 0) {
4073
+ throw standardErrors.rpc.invalidParams("please pass in at least 1 rpcUrl");
4074
+ }
4075
+ if (!request.chainName || request.chainName.trim() === "") {
4076
+ throw standardErrors.rpc.invalidParams("chainName is a required field");
4077
+ }
4078
+ if (!request.nativeCurrency) {
4079
+ throw standardErrors.rpc.invalidParams("nativeCurrency is a required field");
4080
+ }
4081
+ const chainIdNumber = Number.parseInt(request.chainId, 16);
4082
+ if (chainIdNumber === this.getChainId()) {
4083
+ return false;
4084
+ }
4085
+ const relay = this.initializeRelay();
4086
+ const { rpcUrls = [], blockExplorerUrls = [], chainName, iconUrls = [], nativeCurrency } = request;
4087
+ const res = await relay.addEthereumChain(chainIdNumber.toString(), rpcUrls, iconUrls, blockExplorerUrls, chainName, nativeCurrency);
4088
+ if (isErrorResponse(res))
4089
+ return false;
4090
+ if (((_b = res.result) === null || _b === void 0 ? void 0 : _b.isApproved) === true) {
4091
+ this.updateProviderInfo(rpcUrls[0], chainIdNumber);
4092
+ return null;
4093
+ }
4094
+ throw standardErrors.rpc.internal("unable to add ethereum chain");
4095
+ }
4096
+ async switchEthereumChain(params) {
4097
+ const request = params[0];
4098
+ const chainId = Number.parseInt(request.chainId, 16);
4099
+ const relay = this.initializeRelay();
4100
+ const res = await relay.switchEthereumChain(chainId.toString(10), this.selectedAddress || void 0);
4101
+ if (isErrorResponse(res))
4102
+ throw res;
4103
+ const switchResponse = res.result;
4104
+ if (switchResponse.isApproved && switchResponse.rpcUrl.length > 0) {
4105
+ this.updateProviderInfo(switchResponse.rpcUrl, chainId);
4106
+ }
4107
+ return null;
4108
+ }
4109
+ async cleanup() {
4110
+ this.callback = null;
4111
+ if (this._relay) {
4112
+ this._relay.resetAndReload();
4113
+ }
4114
+ this._storage.clear();
4115
+ }
4116
+ _setAddresses(addresses, _2) {
4117
+ var _a;
4118
+ if (!Array.isArray(addresses)) {
4119
+ throw new Error("addresses is not an array");
4120
+ }
4121
+ const newAddresses = addresses.map((address) => ensureAddressString(address));
4122
+ if (JSON.stringify(newAddresses) === JSON.stringify(this._addresses)) {
4123
+ return;
4124
+ }
4125
+ this._addresses = newAddresses;
4126
+ (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, "accountsChanged", newAddresses);
4127
+ this._storage.setItem(LOCAL_STORAGE_ADDRESSES_KEY, newAddresses.join(" "));
4128
+ }
4129
+ async request(request) {
4130
+ const params = request.params || [];
4131
+ switch (request.method) {
4132
+ case "eth_accounts":
4133
+ return [...this._addresses];
4134
+ case "eth_coinbase":
4135
+ return this.selectedAddress || null;
4136
+ case "net_version":
4137
+ return this.getChainId().toString(10);
4138
+ case "eth_chainId":
4139
+ return hexStringFromNumber(this.getChainId());
4140
+ case "eth_requestAccounts":
4141
+ return this._eth_requestAccounts();
4142
+ case "eth_ecRecover":
4143
+ case "personal_ecRecover":
4144
+ return this.ecRecover(request);
4145
+ case "personal_sign":
4146
+ return this.personalSign(request);
4147
+ case "eth_signTransaction":
4148
+ return this._eth_signTransaction(params);
4149
+ case "eth_sendRawTransaction":
4150
+ return this._eth_sendRawTransaction(params);
4151
+ case "eth_sendTransaction":
4152
+ return this._eth_sendTransaction(params);
4153
+ case "eth_signTypedData_v1":
4154
+ case "eth_signTypedData_v3":
4155
+ case "eth_signTypedData_v4":
4156
+ case "eth_signTypedData":
4157
+ return this.signTypedData(request);
4158
+ case "wallet_addEthereumChain":
4159
+ return this.addEthereumChain(params);
4160
+ case "wallet_switchEthereumChain":
4161
+ return this.switchEthereumChain(params);
4162
+ case "wallet_watchAsset":
4163
+ return this.watchAsset(params);
4164
+ default:
4165
+ if (!this.jsonRpcUrl)
4166
+ throw standardErrors.rpc.internal("No RPC URL set for chain");
4167
+ return fetchRPCRequest(request, this.jsonRpcUrl);
4168
+ }
4169
+ }
4170
+ _ensureKnownAddress(addressString) {
4171
+ const addressStr = ensureAddressString(addressString);
4172
+ const lowercaseAddresses = this._addresses.map((address) => ensureAddressString(address));
4173
+ if (!lowercaseAddresses.includes(addressStr)) {
4174
+ throw new Error("Unknown Ethereum address");
4175
+ }
4176
+ }
4177
+ _prepareTransactionParams(tx) {
4178
+ const fromAddress = tx.from ? ensureAddressString(tx.from) : this.selectedAddress;
4179
+ if (!fromAddress) {
4180
+ throw new Error("Ethereum address is unavailable");
4181
+ }
4182
+ this._ensureKnownAddress(fromAddress);
4183
+ const toAddress = tx.to ? ensureAddressString(tx.to) : null;
4184
+ const weiValue = tx.value != null ? ensureBigInt(tx.value) : BigInt(0);
4185
+ const data = tx.data ? ensureBuffer(tx.data) : Buffer.alloc(0);
4186
+ const nonce = tx.nonce != null ? ensureIntNumber(tx.nonce) : null;
4187
+ const gasPriceInWei = tx.gasPrice != null ? ensureBigInt(tx.gasPrice) : null;
4188
+ const maxFeePerGas = tx.maxFeePerGas != null ? ensureBigInt(tx.maxFeePerGas) : null;
4189
+ const maxPriorityFeePerGas = tx.maxPriorityFeePerGas != null ? ensureBigInt(tx.maxPriorityFeePerGas) : null;
4190
+ const gasLimit = tx.gas != null ? ensureBigInt(tx.gas) : null;
4191
+ const chainId = tx.chainId ? ensureIntNumber(tx.chainId) : this.getChainId();
4192
+ return {
4193
+ fromAddress,
4194
+ toAddress,
4195
+ weiValue,
4196
+ data,
4197
+ nonce,
4198
+ gasPriceInWei,
4199
+ maxFeePerGas,
4200
+ maxPriorityFeePerGas,
4201
+ gasLimit,
4202
+ chainId
4203
+ };
4204
+ }
4205
+ async ecRecover(request) {
4206
+ const { method, params } = request;
4207
+ if (!Array.isArray(params))
4208
+ throw standardErrors.rpc.invalidParams();
4209
+ const relay = this.initializeRelay();
4210
+ const res = await relay.sendRequest({
4211
+ method: "ethereumAddressFromSignedMessage",
4212
+ params: {
4213
+ message: encodeToHexString(params[0]),
4214
+ signature: encodeToHexString(params[1]),
4215
+ addPrefix: method === "personal_ecRecover"
4216
+ }
4217
+ });
4218
+ if (isErrorResponse(res))
4219
+ throw res;
4220
+ return res.result;
4221
+ }
4222
+ getChainId() {
4223
+ var _a;
4224
+ return Number.parseInt((_a = this._storage.getItem(DEFAULT_CHAIN_ID_KEY)) !== null && _a !== void 0 ? _a : "1", 10);
4225
+ }
4226
+ async _eth_requestAccounts() {
4227
+ var _a, _b;
4228
+ if (this._addresses.length > 0) {
4229
+ (_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, "connect", { chainId: hexStringFromNumber(this.getChainId()) });
4230
+ return this._addresses;
4231
+ }
4232
+ const relay = this.initializeRelay();
4233
+ const res = await relay.requestEthereumAccounts();
4234
+ if (isErrorResponse(res))
4235
+ throw res;
4236
+ if (!res.result) {
4237
+ throw new Error("accounts received is empty");
4238
+ }
4239
+ this._setAddresses(res.result);
4240
+ (_b = this.callback) === null || _b === void 0 ? void 0 : _b.call(this, "connect", { chainId: hexStringFromNumber(this.getChainId()) });
4241
+ return this._addresses;
4242
+ }
4243
+ async personalSign({ params }) {
4244
+ if (!Array.isArray(params))
4245
+ throw standardErrors.rpc.invalidParams();
4246
+ const address = params[1];
4247
+ const rawData = params[0];
4248
+ this._ensureKnownAddress(address);
4249
+ const relay = this.initializeRelay();
4250
+ const res = await relay.sendRequest({
4251
+ method: "signEthereumMessage",
4252
+ params: {
4253
+ address: ensureAddressString(address),
4254
+ message: encodeToHexString(rawData),
4255
+ addPrefix: true,
4256
+ typedDataJson: null
4257
+ }
4258
+ });
4259
+ if (isErrorResponse(res))
4260
+ throw res;
4261
+ return res.result;
4262
+ }
4263
+ async _eth_signTransaction(params) {
4264
+ const tx = this._prepareTransactionParams(params[0] || {});
4265
+ const relay = this.initializeRelay();
4266
+ const res = await relay.signEthereumTransaction(tx);
4267
+ if (isErrorResponse(res))
4268
+ throw res;
4269
+ return res.result;
4270
+ }
4271
+ async _eth_sendRawTransaction(params) {
4272
+ const signedTransaction = ensureBuffer(params[0]);
4273
+ const relay = this.initializeRelay();
4274
+ const res = await relay.submitEthereumTransaction(signedTransaction, this.getChainId());
4275
+ if (isErrorResponse(res))
4276
+ throw res;
4277
+ return res.result;
4278
+ }
4279
+ async _eth_sendTransaction(params) {
4280
+ const tx = this._prepareTransactionParams(params[0] || {});
4281
+ const relay = this.initializeRelay();
4282
+ const res = await relay.signAndSubmitEthereumTransaction(tx);
4283
+ if (isErrorResponse(res))
4284
+ throw res;
4285
+ return res.result;
4286
+ }
4287
+ async signTypedData(request) {
4288
+ const { method, params } = request;
4289
+ if (!Array.isArray(params))
4290
+ throw standardErrors.rpc.invalidParams();
4291
+ const encode = (input) => {
4292
+ const hashFuncMap = {
4293
+ eth_signTypedData_v1: import_eth_eip712_util.default.hashForSignTypedDataLegacy,
4294
+ eth_signTypedData_v3: import_eth_eip712_util.default.hashForSignTypedData_v3,
4295
+ eth_signTypedData_v4: import_eth_eip712_util.default.hashForSignTypedData_v4,
4296
+ eth_signTypedData: import_eth_eip712_util.default.hashForSignTypedData_v4
4297
+ };
4298
+ return hexStringFromBuffer(hashFuncMap[method]({
4299
+ data: ensureParsedJSONObject(input)
4300
+ }), true);
4301
+ };
4302
+ const address = params[method === "eth_signTypedData_v1" ? 1 : 0];
4303
+ const rawData = params[method === "eth_signTypedData_v1" ? 0 : 1];
4304
+ this._ensureKnownAddress(address);
4305
+ const relay = this.initializeRelay();
4306
+ const res = await relay.sendRequest({
4307
+ method: "signEthereumMessage",
4308
+ params: {
4309
+ address: ensureAddressString(address),
4310
+ message: encode(rawData),
4311
+ typedDataJson: JSON.stringify(rawData, null, 2),
4312
+ addPrefix: false
4313
+ }
4314
+ });
4315
+ if (isErrorResponse(res))
4316
+ throw res;
4317
+ return res.result;
4318
+ }
4319
+ initializeRelay() {
4320
+ if (!this._relay) {
4321
+ this._relay = new WalletLinkRelay({
4322
+ linkAPIUrl: WALLETLINK_URL,
4323
+ storage: this._storage,
4324
+ metadata: this.metadata,
4325
+ accountsCallback: this._setAddresses.bind(this),
4326
+ chainCallback: this.updateProviderInfo.bind(this)
4327
+ });
4328
+ }
4329
+ return this._relay;
4330
+ }
4331
+ };
4332
+
4333
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/sign/util.js
4334
+ var SIGNER_TYPE_KEY = "SignerType";
4335
+ var storage = new ScopedLocalStorage("CBWSDK", "SignerConfigurator");
4336
+ function loadSignerType() {
4337
+ return storage.getItem(SIGNER_TYPE_KEY);
4338
+ }
4339
+ function storeSignerType(signerType) {
4340
+ storage.setItem(SIGNER_TYPE_KEY, signerType);
4341
+ }
4342
+ async function fetchSignerType(params) {
4343
+ const { communicator, metadata, handshakeRequest, callback } = params;
4344
+ listenForWalletLinkSessionRequest(communicator, metadata, callback).catch(() => {
4345
+ });
4346
+ const request = {
4347
+ id: crypto.randomUUID(),
4348
+ event: "selectSignerType",
4349
+ data: Object.assign(Object.assign({}, params.preference), { handshakeRequest })
4350
+ };
4351
+ const { data } = await communicator.postRequestAndWaitForResponse(request);
4352
+ return data;
4353
+ }
4354
+ function createSigner(params) {
4355
+ const { signerType, metadata, communicator, callback } = params;
4356
+ switch (signerType) {
4357
+ case "scw": {
4358
+ return new SCWSigner({
4359
+ metadata,
4360
+ callback,
4361
+ communicator
4362
+ });
4363
+ }
4364
+ case "walletlink": {
4365
+ return new WalletLinkSigner({
4366
+ metadata,
4367
+ callback
4368
+ });
4369
+ }
4370
+ }
4371
+ }
4372
+ async function listenForWalletLinkSessionRequest(communicator, metadata, callback) {
4373
+ await communicator.onMessage(({ event }) => event === "WalletLinkSessionRequest");
4374
+ const walletlink = new WalletLinkSigner({
4375
+ metadata,
4376
+ callback
4377
+ });
4378
+ communicator.postMessage({
4379
+ event: "WalletLinkUpdate",
4380
+ data: { session: walletlink.getSession() }
4381
+ });
4382
+ await walletlink.handshake();
4383
+ communicator.postMessage({
4384
+ event: "WalletLinkUpdate",
4385
+ data: { connected: true }
4386
+ });
4387
+ }
4388
+
4389
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/communicator/Communicator.js
4390
+ init_polyfills();
4391
+
4392
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/web.js
4393
+ init_polyfills();
4394
+
4395
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/checkCrossOriginOpenerPolicy.js
4396
+ init_polyfills();
4397
+ var COOP_ERROR_MESSAGE = `Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.
4398
+
4399
+ Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`;
4400
+ var createCoopChecker = () => {
4401
+ let crossOriginOpenerPolicy;
4402
+ return {
4403
+ getCrossOriginOpenerPolicy: () => {
4404
+ if (crossOriginOpenerPolicy === void 0) {
4405
+ return "undefined";
4406
+ }
4407
+ return crossOriginOpenerPolicy;
4408
+ },
4409
+ checkCrossOriginOpenerPolicy: async () => {
4410
+ if (typeof window === "undefined") {
4411
+ crossOriginOpenerPolicy = "non-browser-env";
4412
+ return;
4413
+ }
4414
+ try {
4415
+ const url = `${window.location.origin}${window.location.pathname}`;
4416
+ const response = await fetch(url, {
4417
+ method: "HEAD"
4418
+ });
4419
+ if (!response.ok) {
4420
+ throw new Error(`HTTP error! status: ${response.status}`);
4421
+ }
4422
+ const result = response.headers.get("Cross-Origin-Opener-Policy");
4423
+ crossOriginOpenerPolicy = result !== null && result !== void 0 ? result : "null";
4424
+ if (crossOriginOpenerPolicy === "same-origin") {
4425
+ console.error(COOP_ERROR_MESSAGE);
4426
+ }
4427
+ } catch (error) {
4428
+ console.error("Error checking Cross-Origin-Opener-Policy:", error.message);
4429
+ crossOriginOpenerPolicy = "error";
4430
+ }
4431
+ }
4432
+ };
4433
+ };
4434
+ var { checkCrossOriginOpenerPolicy, getCrossOriginOpenerPolicy } = createCoopChecker();
4435
+
4436
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/web.js
4437
+ var POPUP_WIDTH = 420;
4438
+ var POPUP_HEIGHT = 540;
4439
+ var RETRY_BUTTON = {
4440
+ isRed: false,
4441
+ info: "Retry",
4442
+ svgWidth: "10",
4443
+ svgHeight: "11",
4444
+ path: RETRY_SVG_PATH,
4445
+ defaultFillRule: "evenodd",
4446
+ defaultClipRule: "evenodd"
4447
+ };
4448
+ var POPUP_BLOCKED_MESSAGE = "Popup was blocked. Try again.";
4449
+ var snackbar = null;
4450
+ function openPopup(url) {
4451
+ const left = (window.innerWidth - POPUP_WIDTH) / 2 + window.screenX;
4452
+ const top = (window.innerHeight - POPUP_HEIGHT) / 2 + window.screenY;
4453
+ appendAppInfoQueryParams(url);
4454
+ function tryOpenPopup() {
4455
+ const popupId = `wallet_${crypto.randomUUID()}`;
4456
+ const popup2 = window.open(url, popupId, `width=${POPUP_WIDTH}, height=${POPUP_HEIGHT}, left=${left}, top=${top}`);
4457
+ popup2 === null || popup2 === void 0 ? void 0 : popup2.focus();
4458
+ if (!popup2) {
4459
+ return null;
4460
+ }
4461
+ return popup2;
4462
+ }
4463
+ let popup = tryOpenPopup();
4464
+ if (!popup) {
4465
+ const sb = initSnackbar();
4466
+ return new Promise((resolve, reject) => {
4467
+ sb.presentItem({
4468
+ autoExpand: true,
4469
+ message: POPUP_BLOCKED_MESSAGE,
4470
+ menuItems: [
4471
+ Object.assign(Object.assign({}, RETRY_BUTTON), { onClick: () => {
4472
+ popup = tryOpenPopup();
4473
+ if (popup) {
4474
+ resolve(popup);
4475
+ } else {
4476
+ reject(standardErrors.rpc.internal("Popup window was blocked"));
4477
+ }
4478
+ sb.clear();
4479
+ } })
4480
+ ]
4481
+ });
4482
+ });
4483
+ }
4484
+ return Promise.resolve(popup);
4485
+ }
4486
+ function closePopup(popup) {
4487
+ if (popup && !popup.closed) {
4488
+ popup.close();
4489
+ }
4490
+ }
4491
+ function appendAppInfoQueryParams(url) {
4492
+ const params = {
4493
+ sdkName: NAME,
4494
+ sdkVersion: VERSION,
4495
+ origin: window.location.origin,
4496
+ coop: getCrossOriginOpenerPolicy()
4497
+ };
4498
+ for (const [key, value] of Object.entries(params)) {
4499
+ url.searchParams.append(key, value.toString());
4500
+ }
4501
+ }
4502
+ function initSnackbar() {
4503
+ if (!snackbar) {
4504
+ const root = document.createElement("div");
4505
+ root.className = "-cbwsdk-css-reset";
4506
+ document.body.appendChild(root);
4507
+ snackbar = new Snackbar();
4508
+ snackbar.attach(root);
4509
+ }
4510
+ return snackbar;
4511
+ }
4512
+
4513
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/communicator/Communicator.js
4514
+ var Communicator = class {
4515
+ constructor({ url = CB_KEYS_URL, metadata, preference }) {
4516
+ this.popup = null;
4517
+ this.listeners = /* @__PURE__ */ new Map();
4518
+ this.postMessage = async (message) => {
4519
+ const popup = await this.waitForPopupLoaded();
4520
+ popup.postMessage(message, this.url.origin);
4521
+ };
4522
+ this.postRequestAndWaitForResponse = async (request) => {
4523
+ const responsePromise = this.onMessage(({ requestId }) => requestId === request.id);
4524
+ this.postMessage(request);
4525
+ return await responsePromise;
4526
+ };
4527
+ this.onMessage = async (predicate) => {
4528
+ return new Promise((resolve, reject) => {
4529
+ const listener = (event) => {
4530
+ if (event.origin !== this.url.origin)
4531
+ return;
4532
+ const message = event.data;
4533
+ if (predicate(message)) {
4534
+ resolve(message);
4535
+ window.removeEventListener("message", listener);
4536
+ this.listeners.delete(listener);
4537
+ }
4538
+ };
4539
+ window.addEventListener("message", listener);
4540
+ this.listeners.set(listener, { reject });
4541
+ });
4542
+ };
4543
+ this.disconnect = () => {
4544
+ closePopup(this.popup);
4545
+ this.popup = null;
4546
+ this.listeners.forEach(({ reject }, listener) => {
4547
+ reject(standardErrors.provider.userRejectedRequest("Request rejected"));
4548
+ window.removeEventListener("message", listener);
4549
+ });
4550
+ this.listeners.clear();
4551
+ };
4552
+ this.waitForPopupLoaded = async () => {
4553
+ if (this.popup && !this.popup.closed) {
4554
+ this.popup.focus();
4555
+ return this.popup;
4556
+ }
4557
+ this.popup = await openPopup(this.url);
4558
+ this.onMessage(({ event }) => event === "PopupUnload").then(this.disconnect).catch(() => {
4559
+ });
4560
+ return this.onMessage(({ event }) => event === "PopupLoaded").then((message) => {
4561
+ this.postMessage({
4562
+ requestId: message.id,
4563
+ data: {
4564
+ version: VERSION,
4565
+ metadata: this.metadata,
4566
+ preference: this.preference,
4567
+ location: window.location.toString()
4568
+ }
4569
+ });
4570
+ }).then(() => {
4571
+ if (!this.popup)
4572
+ throw standardErrors.rpc.internal();
4573
+ return this.popup;
4574
+ });
4575
+ };
4576
+ this.url = new URL(url);
4577
+ this.metadata = metadata;
4578
+ this.preference = preference;
4579
+ }
4580
+ };
4581
+
4582
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/error/serialize.js
4583
+ init_polyfills();
4584
+ function serializeError(error) {
4585
+ const serialized = serialize(getErrorObject(error), {
4586
+ shouldIncludeStack: true
4587
+ });
4588
+ const docUrl = new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");
4589
+ docUrl.searchParams.set("version", VERSION);
4590
+ docUrl.searchParams.set("code", serialized.code.toString());
4591
+ docUrl.searchParams.set("message", serialized.message);
4592
+ return Object.assign(Object.assign({}, serialized), { docUrl: docUrl.href });
4593
+ }
4594
+ function getErrorObject(error) {
4595
+ var _a;
4596
+ if (typeof error === "string") {
4597
+ return {
4598
+ message: error,
4599
+ code: standardErrorCodes.rpc.internal
4600
+ };
4601
+ } else if (isErrorResponse(error)) {
4602
+ const message = error.errorMessage;
4603
+ const code = (_a = error.errorCode) !== null && _a !== void 0 ? _a : message.match(/(denied|rejected)/i) ? standardErrorCodes.provider.userRejectedRequest : void 0;
4604
+ return Object.assign(Object.assign({}, error), {
4605
+ message,
4606
+ code,
4607
+ data: { method: error.method }
4608
+ });
4609
+ }
4610
+ return error;
4611
+ }
4612
+
4613
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/core/provider/interface.js
4614
+ init_polyfills();
4615
+ var ProviderEventEmitter = class extends import_index.default {
4616
+ };
4617
+
4618
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/CoinbaseWalletProvider.js
4619
+ var __rest = function(s3, e3) {
4620
+ var t3 = {};
4621
+ for (var p3 in s3) if (Object.prototype.hasOwnProperty.call(s3, p3) && e3.indexOf(p3) < 0)
4622
+ t3[p3] = s3[p3];
4623
+ if (s3 != null && typeof Object.getOwnPropertySymbols === "function")
4624
+ for (var i3 = 0, p3 = Object.getOwnPropertySymbols(s3); i3 < p3.length; i3++) {
4625
+ if (e3.indexOf(p3[i3]) < 0 && Object.prototype.propertyIsEnumerable.call(s3, p3[i3]))
4626
+ t3[p3[i3]] = s3[p3[i3]];
4627
+ }
4628
+ return t3;
4629
+ };
4630
+ var CoinbaseWalletProvider = class extends ProviderEventEmitter {
4631
+ constructor(_a) {
4632
+ var { metadata } = _a, _b = _a.preference, { keysUrl } = _b, preference = __rest(_b, ["keysUrl"]);
4633
+ super();
4634
+ this.signer = null;
4635
+ this.isCoinbaseWallet = true;
4636
+ this.metadata = metadata;
4637
+ this.preference = preference;
4638
+ this.communicator = new Communicator({
4639
+ url: keysUrl,
4640
+ metadata,
4641
+ preference
4642
+ });
4643
+ const signerType = loadSignerType();
4644
+ if (signerType) {
4645
+ this.signer = this.initSigner(signerType);
4646
+ }
4647
+ }
4648
+ async request(args) {
4649
+ try {
4650
+ checkErrorForInvalidRequestArgs(args);
4651
+ if (!this.signer) {
4652
+ switch (args.method) {
4653
+ case "eth_requestAccounts": {
4654
+ const signerType = await this.requestSignerSelection(args);
4655
+ const signer = this.initSigner(signerType);
4656
+ await signer.handshake(args);
4657
+ this.signer = signer;
4658
+ storeSignerType(signerType);
4659
+ break;
4660
+ }
4661
+ case "wallet_sendCalls": {
4662
+ const ephemeralSigner = this.initSigner("scw");
4663
+ await ephemeralSigner.handshake({ method: "handshake" });
4664
+ const result = await ephemeralSigner.request(args);
4665
+ await ephemeralSigner.cleanup();
4666
+ return result;
4667
+ }
4668
+ case "wallet_getCallsStatus":
4669
+ return fetchRPCRequest(args, CB_WALLET_RPC_URL);
4670
+ case "net_version":
4671
+ return 1;
4672
+ // default value
4673
+ case "eth_chainId":
4674
+ return hexStringFromNumber(1);
4675
+ // default value
4676
+ default: {
4677
+ throw standardErrors.provider.unauthorized("Must call 'eth_requestAccounts' before other methods");
4678
+ }
4679
+ }
4680
+ }
4681
+ return await this.signer.request(args);
4682
+ } catch (error) {
4683
+ const { code } = error;
4684
+ if (code === standardErrorCodes.provider.unauthorized)
4685
+ this.disconnect();
4686
+ return Promise.reject(serializeError(error));
4687
+ }
4688
+ }
4689
+ /** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */
4690
+ async enable() {
4691
+ console.warn(`.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.`);
4692
+ return await this.request({
4693
+ method: "eth_requestAccounts"
4694
+ });
4695
+ }
4696
+ async disconnect() {
4697
+ var _a;
4698
+ await ((_a = this.signer) === null || _a === void 0 ? void 0 : _a.cleanup());
4699
+ this.signer = null;
4700
+ ScopedLocalStorage.clearAll();
4701
+ this.emit("disconnect", standardErrors.provider.disconnected("User initiated disconnection"));
4702
+ }
4703
+ requestSignerSelection(handshakeRequest) {
4704
+ return fetchSignerType({
4705
+ communicator: this.communicator,
4706
+ preference: this.preference,
4707
+ metadata: this.metadata,
4708
+ handshakeRequest,
4709
+ callback: this.emit.bind(this)
4710
+ });
4711
+ }
4712
+ initSigner(signerType) {
4713
+ return createSigner({
4714
+ signerType,
4715
+ metadata: this.metadata,
4716
+ communicator: this.communicator,
4717
+ callback: this.emit.bind(this)
4718
+ });
4719
+ }
4720
+ };
4721
+
4722
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/util/validatePreferences.js
4723
+ init_polyfills();
4724
+ function validatePreferences(preference) {
4725
+ if (!preference) {
4726
+ return;
4727
+ }
4728
+ if (!["all", "smartWalletOnly", "eoaOnly"].includes(preference.options)) {
4729
+ throw new Error(`Invalid options: ${preference.options}`);
4730
+ }
4731
+ if (preference.attribution) {
4732
+ if (preference.attribution.auto !== void 0 && preference.attribution.dataSuffix !== void 0) {
4733
+ throw new Error(`Attribution cannot contain both auto and dataSuffix properties`);
4734
+ }
4735
+ }
4736
+ }
4737
+
4738
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/CoinbaseWalletSDK.js
4739
+ var CoinbaseWalletSDK = class {
4740
+ constructor(metadata) {
4741
+ this.metadata = {
4742
+ appName: metadata.appName || "Dapp",
4743
+ appLogoUrl: metadata.appLogoUrl || getFavicon(),
4744
+ appChainIds: metadata.appChainIds || []
4745
+ };
4746
+ this.storeLatestVersion();
4747
+ void checkCrossOriginOpenerPolicy();
4748
+ }
4749
+ makeWeb3Provider(preference = { options: "all" }) {
4750
+ var _a;
4751
+ validatePreferences(preference);
4752
+ const params = { metadata: this.metadata, preference };
4753
+ return (_a = getCoinbaseInjectedProvider(params)) !== null && _a !== void 0 ? _a : new CoinbaseWalletProvider(params);
4754
+ }
4755
+ /**
4756
+ * Official Coinbase Wallet logo for developers to use on their frontend
4757
+ * @param type Type of wallet logo: "standard" | "circle" | "text" | "textWithLogo" | "textLight" | "textWithLogoLight"
4758
+ * @param width Width of the logo (Optional)
4759
+ * @returns SVG Data URI
4760
+ */
4761
+ getCoinbaseWalletLogo(type, width = 240) {
4762
+ return walletLogo(type, width);
4763
+ }
4764
+ storeLatestVersion() {
4765
+ const versionStorage = new ScopedLocalStorage("CBWSDK");
4766
+ versionStorage.setItem("VERSION", VERSION);
4767
+ }
4768
+ };
4769
+
4770
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/createCoinbaseWalletSDK.js
4771
+ init_polyfills();
4772
+
4773
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/createCoinbaseWalletProvider.js
4774
+ init_polyfills();
4775
+ function createCoinbaseWalletProvider(options) {
4776
+ var _a;
4777
+ const params = {
4778
+ metadata: options.metadata,
4779
+ preference: options.preference
4780
+ };
4781
+ return (_a = getCoinbaseInjectedProvider(params)) !== null && _a !== void 0 ? _a : new CoinbaseWalletProvider(params);
4782
+ }
4783
+
4784
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/createCoinbaseWalletSDK.js
4785
+ var DEFAULT_PREFERENCE = {
4786
+ options: "all"
4787
+ };
4788
+ function createCoinbaseWalletSDK(params) {
4789
+ var _a;
4790
+ const versionStorage = new ScopedLocalStorage("CBWSDK");
4791
+ versionStorage.setItem("VERSION", VERSION);
4792
+ void checkCrossOriginOpenerPolicy();
4793
+ const options = {
4794
+ metadata: {
4795
+ appName: params.appName || "Dapp",
4796
+ appLogoUrl: params.appLogoUrl || "",
4797
+ appChainIds: params.appChainIds || []
4798
+ },
4799
+ preference: Object.assign(DEFAULT_PREFERENCE, (_a = params.preference) !== null && _a !== void 0 ? _a : {})
4800
+ };
4801
+ validatePreferences(options.preference);
4802
+ let provider = null;
4803
+ return {
4804
+ getProvider: () => {
4805
+ if (!provider) {
4806
+ provider = createCoinbaseWalletProvider(options);
4807
+ }
4808
+ return provider;
4809
+ }
4810
+ };
4811
+ }
4812
+
4813
+ // ../../node_modules/.pnpm/@coinbase+wallet-sdk@4.3.7_typescript@5.9.3/node_modules/@coinbase/wallet-sdk/dist/index.js
4814
+ var dist_default = CoinbaseWalletSDK;
4815
+ export {
4816
+ CoinbaseWalletSDK,
4817
+ createCoinbaseWalletSDK,
4818
+ dist_default as default
4819
+ };
4820
+ /*! Bundled license information:
4821
+
4822
+ @noble/hashes/utils.js:
4823
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
4824
+ */
4825
+ //# sourceMappingURL=dist-SYSRLCAE.mjs.map