@lukso/web-components 1.81.2 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/components/index.cjs +3 -3
  2. package/dist/components/index.js +3 -3
  3. package/dist/components/lukso-button/index.cjs +1 -1
  4. package/dist/components/lukso-button/index.js +1 -1
  5. package/dist/components/lukso-card/index.cjs +3 -3
  6. package/dist/components/lukso-card/index.js +3 -3
  7. package/dist/components/lukso-checkbox/index.cjs +1 -1
  8. package/dist/components/lukso-checkbox/index.js +1 -1
  9. package/dist/components/lukso-footer/index.cjs +1 -1
  10. package/dist/components/lukso-footer/index.js +1 -1
  11. package/dist/components/lukso-icon/index.cjs +2 -2
  12. package/dist/components/lukso-icon/index.js +2 -2
  13. package/dist/components/lukso-image/index.cjs +2 -2
  14. package/dist/components/lukso-image/index.js +2 -2
  15. package/dist/components/lukso-input/index.cjs +2 -2
  16. package/dist/components/lukso-input/index.js +2 -2
  17. package/dist/components/lukso-modal/index.cjs +1 -1
  18. package/dist/components/lukso-modal/index.js +1 -1
  19. package/dist/components/lukso-navbar/index.cjs +3 -3
  20. package/dist/components/lukso-navbar/index.js +3 -3
  21. package/dist/components/lukso-pagination/index.cjs +2 -2
  22. package/dist/components/lukso-pagination/index.js +2 -2
  23. package/dist/components/lukso-profile/index.cjs +2 -2
  24. package/dist/components/lukso-profile/index.js +2 -2
  25. package/dist/components/lukso-progress/index.cjs +2 -2
  26. package/dist/components/lukso-progress/index.js +2 -2
  27. package/dist/components/lukso-sanitize/index.cjs +1 -1
  28. package/dist/components/lukso-sanitize/index.js +1 -1
  29. package/dist/components/lukso-search/index.cjs +6 -13
  30. package/dist/components/lukso-search/index.d.ts.map +1 -1
  31. package/dist/components/lukso-search/index.js +6 -13
  32. package/dist/components/lukso-select/index.cjs +3 -3
  33. package/dist/components/lukso-select/index.js +3 -3
  34. package/dist/components/lukso-share/index.cjs +1 -1
  35. package/dist/components/lukso-share/index.js +1 -1
  36. package/dist/components/lukso-switch/index.cjs +2 -2
  37. package/dist/components/lukso-switch/index.js +2 -2
  38. package/dist/components/lukso-tag/index.cjs +2 -2
  39. package/dist/components/lukso-tag/index.js +2 -2
  40. package/dist/components/lukso-terms/index.cjs +2 -2
  41. package/dist/components/lukso-terms/index.js +2 -2
  42. package/dist/components/lukso-test/index.cjs +1 -1
  43. package/dist/components/lukso-test/index.js +1 -1
  44. package/dist/components/lukso-tooltip/index.cjs +2 -2
  45. package/dist/components/lukso-tooltip/index.js +2 -2
  46. package/dist/components/lukso-username/index.cjs +1159 -6
  47. package/dist/components/lukso-username/index.d.ts +2 -1
  48. package/dist/components/lukso-username/index.d.ts.map +1 -1
  49. package/dist/components/lukso-username/index.js +1159 -6
  50. package/dist/components/lukso-wizard/index.cjs +1 -1
  51. package/dist/components/lukso-wizard/index.js +1 -1
  52. package/dist/{index-b9a3ecb2.cjs → index-3b498928.cjs} +1 -1
  53. package/dist/{index-b2b55120.js → index-8043be8a.js} +1 -1
  54. package/dist/{index-d2227f06.cjs → index-e653a9ff.cjs} +1 -1
  55. package/dist/{index-b500cc08.js → index-f72579d6.js} +1 -1
  56. package/dist/index.cjs +3 -3
  57. package/dist/index.js +3 -3
  58. package/dist/shared/tailwind-element/index.cjs +1 -1
  59. package/dist/shared/tailwind-element/index.js +1 -1
  60. package/dist/{style-map-333da36f.cjs → style-map-a6d61d04.cjs} +1 -1
  61. package/dist/{style-map-babc0be8.js → style-map-ad97bcc3.js} +1 -1
  62. package/package.json +3 -2
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const shared_tailwindElement_index = require('../../index-d2227f06.cjs');
5
+ const shared_tailwindElement_index = require('../../index-e653a9ff.cjs');
6
6
  const queryAssignedElements = require('../../query-assigned-elements-d5e45650.cjs');
7
7
  const index = require('../../index-1d3f4a5a.cjs');
8
- const index$1 = require('../../index-b9a3ecb2.cjs');
8
+ const index$1 = require('../../index-3b498928.cjs');
9
9
  require('../../tailwind-config.cjs');
10
10
  const cn = require('../../cn-5ceac001.cjs');
11
11
  require('../../bundle-mjs-d58a83c6.cjs');
@@ -24,6 +24,1145 @@ const sliceAddress = (address, startSliceBy = 6, endSliceBy) => {
24
24
  return sliceAddress2;
25
25
  };
26
26
 
27
+ function number(n) {
28
+ if (!Number.isSafeInteger(n) || n < 0)
29
+ throw new Error(`positive integer expected, not ${n}`);
30
+ }
31
+ function bool(b) {
32
+ if (typeof b !== 'boolean')
33
+ throw new Error(`boolean expected, not ${b}`);
34
+ }
35
+ // copied from utils
36
+ function isBytes(a) {
37
+ return (a instanceof Uint8Array ||
38
+ (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
39
+ }
40
+ function bytes(b, ...lengths) {
41
+ if (!isBytes(b))
42
+ throw new Error('Uint8Array expected');
43
+ if (lengths.length > 0 && !lengths.includes(b.length))
44
+ throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
45
+ }
46
+ function hash(h) {
47
+ if (typeof h !== 'function' || typeof h.create !== 'function')
48
+ throw new Error('Hash should be wrapped by utils.wrapConstructor');
49
+ number(h.outputLen);
50
+ number(h.blockLen);
51
+ }
52
+ function exists(instance, checkFinished = true) {
53
+ if (instance.destroyed)
54
+ throw new Error('Hash instance has been destroyed');
55
+ if (checkFinished && instance.finished)
56
+ throw new Error('Hash#digest() has already been called');
57
+ }
58
+ function output(out, instance) {
59
+ bytes(out);
60
+ const min = instance.outputLen;
61
+ if (out.length < min) {
62
+ throw new Error(`digestInto() expects output buffer of length at least ${min}`);
63
+ }
64
+ }
65
+ const assert = { number, bool, bytes, hash, exists, output };
66
+ const assert$1 = assert;
67
+
68
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
69
+ const _32n = /* @__PURE__ */ BigInt(32);
70
+ // We are not using BigUint64Array, because they are extremely slow as per 2022
71
+ function fromBig(n, le = false) {
72
+ if (le)
73
+ return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
74
+ return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
75
+ }
76
+ function split(lst, le = false) {
77
+ let Ah = new Uint32Array(lst.length);
78
+ let Al = new Uint32Array(lst.length);
79
+ for (let i = 0; i < lst.length; i++) {
80
+ const { h, l } = fromBig(lst[i], le);
81
+ [Ah[i], Al[i]] = [h, l];
82
+ }
83
+ return [Ah, Al];
84
+ }
85
+ // Left rotate for Shift in [1, 32)
86
+ const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
87
+ const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
88
+ // Left rotate for Shift in (32, 64), NOTE: 32 is special case.
89
+ const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
90
+ const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
91
+
92
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
93
+ // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
94
+ // node.js versions earlier than v19 don't declare it in global scope.
95
+ // For node.js, package.json#exports field mapping rewrites import
96
+ // from `crypto` to `cryptoNode`, which imports native module.
97
+ // Makes the utils un-importable in browsers without a bundler.
98
+ // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
99
+ const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
100
+ const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
101
+ // The byte swap operation for uint32
102
+ const byteSwap = (word) => ((word << 24) & 0xff000000) |
103
+ ((word << 8) & 0xff0000) |
104
+ ((word >>> 8) & 0xff00) |
105
+ ((word >>> 24) & 0xff);
106
+ // In place byte swap for Uint32Array
107
+ function byteSwap32(arr) {
108
+ for (let i = 0; i < arr.length; i++) {
109
+ arr[i] = byteSwap(arr[i]);
110
+ }
111
+ }
112
+ /**
113
+ * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
114
+ */
115
+ function utf8ToBytes$1(str) {
116
+ if (typeof str !== 'string')
117
+ throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
118
+ return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
119
+ }
120
+ /**
121
+ * Normalizes (non-hex) string or Uint8Array to Uint8Array.
122
+ * Warning: when Uint8Array is passed, it would NOT get copied.
123
+ * Keep in mind for future mutable operations.
124
+ */
125
+ function toBytes(data) {
126
+ if (typeof data === 'string')
127
+ data = utf8ToBytes$1(data);
128
+ bytes(data);
129
+ return data;
130
+ }
131
+ // For runtime check if class implements interface
132
+ class Hash {
133
+ // Safe version that clones internal state
134
+ clone() {
135
+ return this._cloneInto();
136
+ }
137
+ }
138
+ function wrapConstructor(hashCons) {
139
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
140
+ const tmp = hashCons();
141
+ hashC.outputLen = tmp.outputLen;
142
+ hashC.blockLen = tmp.blockLen;
143
+ hashC.create = () => hashCons();
144
+ return hashC;
145
+ }
146
+
147
+ // SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
148
+ // It's called a sponge function.
149
+ // Various per round constants calculations
150
+ const SHA3_PI = [];
151
+ const SHA3_ROTL = [];
152
+ const _SHA3_IOTA = [];
153
+ const _0n = /* @__PURE__ */ BigInt(0);
154
+ const _1n = /* @__PURE__ */ BigInt(1);
155
+ const _2n = /* @__PURE__ */ BigInt(2);
156
+ const _7n = /* @__PURE__ */ BigInt(7);
157
+ const _256n = /* @__PURE__ */ BigInt(256);
158
+ const _0x71n = /* @__PURE__ */ BigInt(0x71);
159
+ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
160
+ // Pi
161
+ [x, y] = [y, (2 * x + 3 * y) % 5];
162
+ SHA3_PI.push(2 * (5 * y + x));
163
+ // Rotational
164
+ SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);
165
+ // Iota
166
+ let t = _0n;
167
+ for (let j = 0; j < 7; j++) {
168
+ R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;
169
+ if (R & _2n)
170
+ t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);
171
+ }
172
+ _SHA3_IOTA.push(t);
173
+ }
174
+ const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);
175
+ // Left rotation (without 0, 32, 64)
176
+ const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));
177
+ const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));
178
+ // Same as keccakf1600, but allows to skip some rounds
179
+ function keccakP(s, rounds = 24) {
180
+ const B = new Uint32Array(5 * 2);
181
+ // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)
182
+ for (let round = 24 - rounds; round < 24; round++) {
183
+ // Theta θ
184
+ for (let x = 0; x < 10; x++)
185
+ B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
186
+ for (let x = 0; x < 10; x += 2) {
187
+ const idx1 = (x + 8) % 10;
188
+ const idx0 = (x + 2) % 10;
189
+ const B0 = B[idx0];
190
+ const B1 = B[idx0 + 1];
191
+ const Th = rotlH(B0, B1, 1) ^ B[idx1];
192
+ const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
193
+ for (let y = 0; y < 50; y += 10) {
194
+ s[x + y] ^= Th;
195
+ s[x + y + 1] ^= Tl;
196
+ }
197
+ }
198
+ // Rho (ρ) and Pi (π)
199
+ let curH = s[2];
200
+ let curL = s[3];
201
+ for (let t = 0; t < 24; t++) {
202
+ const shift = SHA3_ROTL[t];
203
+ const Th = rotlH(curH, curL, shift);
204
+ const Tl = rotlL(curH, curL, shift);
205
+ const PI = SHA3_PI[t];
206
+ curH = s[PI];
207
+ curL = s[PI + 1];
208
+ s[PI] = Th;
209
+ s[PI + 1] = Tl;
210
+ }
211
+ // Chi (χ)
212
+ for (let y = 0; y < 50; y += 10) {
213
+ for (let x = 0; x < 10; x++)
214
+ B[x] = s[y + x];
215
+ for (let x = 0; x < 10; x++)
216
+ s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
217
+ }
218
+ // Iota (ι)
219
+ s[0] ^= SHA3_IOTA_H[round];
220
+ s[1] ^= SHA3_IOTA_L[round];
221
+ }
222
+ B.fill(0);
223
+ }
224
+ class Keccak extends Hash {
225
+ // NOTE: we accept arguments in bytes instead of bits here.
226
+ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
227
+ super();
228
+ this.blockLen = blockLen;
229
+ this.suffix = suffix;
230
+ this.outputLen = outputLen;
231
+ this.enableXOF = enableXOF;
232
+ this.rounds = rounds;
233
+ this.pos = 0;
234
+ this.posOut = 0;
235
+ this.finished = false;
236
+ this.destroyed = false;
237
+ // Can be passed from user as dkLen
238
+ number(outputLen);
239
+ // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
240
+ if (0 >= this.blockLen || this.blockLen >= 200)
241
+ throw new Error('Sha3 supports only keccak-f1600 function');
242
+ this.state = new Uint8Array(200);
243
+ this.state32 = u32(this.state);
244
+ }
245
+ keccak() {
246
+ if (!isLE)
247
+ byteSwap32(this.state32);
248
+ keccakP(this.state32, this.rounds);
249
+ if (!isLE)
250
+ byteSwap32(this.state32);
251
+ this.posOut = 0;
252
+ this.pos = 0;
253
+ }
254
+ update(data) {
255
+ exists(this);
256
+ const { blockLen, state } = this;
257
+ data = toBytes(data);
258
+ const len = data.length;
259
+ for (let pos = 0; pos < len;) {
260
+ const take = Math.min(blockLen - this.pos, len - pos);
261
+ for (let i = 0; i < take; i++)
262
+ state[this.pos++] ^= data[pos++];
263
+ if (this.pos === blockLen)
264
+ this.keccak();
265
+ }
266
+ return this;
267
+ }
268
+ finish() {
269
+ if (this.finished)
270
+ return;
271
+ this.finished = true;
272
+ const { state, suffix, pos, blockLen } = this;
273
+ // Do the padding
274
+ state[pos] ^= suffix;
275
+ if ((suffix & 0x80) !== 0 && pos === blockLen - 1)
276
+ this.keccak();
277
+ state[blockLen - 1] ^= 0x80;
278
+ this.keccak();
279
+ }
280
+ writeInto(out) {
281
+ exists(this, false);
282
+ bytes(out);
283
+ this.finish();
284
+ const bufferOut = this.state;
285
+ const { blockLen } = this;
286
+ for (let pos = 0, len = out.length; pos < len;) {
287
+ if (this.posOut >= blockLen)
288
+ this.keccak();
289
+ const take = Math.min(blockLen - this.posOut, len - pos);
290
+ out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
291
+ this.posOut += take;
292
+ pos += take;
293
+ }
294
+ return out;
295
+ }
296
+ xofInto(out) {
297
+ // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF
298
+ if (!this.enableXOF)
299
+ throw new Error('XOF is not possible for this instance');
300
+ return this.writeInto(out);
301
+ }
302
+ xof(bytes) {
303
+ number(bytes);
304
+ return this.xofInto(new Uint8Array(bytes));
305
+ }
306
+ digestInto(out) {
307
+ output(out, this);
308
+ if (this.finished)
309
+ throw new Error('digest() was already called');
310
+ this.writeInto(out);
311
+ this.destroy();
312
+ return out;
313
+ }
314
+ digest() {
315
+ return this.digestInto(new Uint8Array(this.outputLen));
316
+ }
317
+ destroy() {
318
+ this.destroyed = true;
319
+ this.state.fill(0);
320
+ }
321
+ _cloneInto(to) {
322
+ const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
323
+ to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
324
+ to.state32.set(this.state32);
325
+ to.pos = this.pos;
326
+ to.posOut = this.posOut;
327
+ to.finished = this.finished;
328
+ to.rounds = rounds;
329
+ // Suffix can change in cSHAKE
330
+ to.suffix = suffix;
331
+ to.outputLen = outputLen;
332
+ to.enableXOF = enableXOF;
333
+ to.destroyed = this.destroyed;
334
+ return to;
335
+ }
336
+ }
337
+ const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));
338
+ /**
339
+ * keccak-256 hash function. Different from SHA3-256.
340
+ * @param message - that would be hashed
341
+ */
342
+ const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);
343
+
344
+ assert$1.bool;
345
+ assert$1.bytes;
346
+ // Internal utils
347
+ function wrapHash(hash) {
348
+ return (msg) => {
349
+ assert$1.bytes(msg);
350
+ return hash(msg);
351
+ };
352
+ }
353
+ // TODO(v3): switch away from node crypto, remove this unnecessary variable.
354
+ (() => {
355
+ const webCrypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : undefined;
356
+ const nodeRequire = typeof module !== "undefined" &&
357
+ typeof module.require === "function" &&
358
+ module.require.bind(module);
359
+ return {
360
+ node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined,
361
+ web: webCrypto
362
+ };
363
+ })();
364
+
365
+ const keccak256 = (() => {
366
+ const k = wrapHash(keccak_256);
367
+ k.create = keccak_256.create;
368
+ return k;
369
+ })();
370
+
371
+ /*
372
+ This file is part of web3.js.
373
+
374
+ web3.js is free software: you can redistribute it and/or modify
375
+ it under the terms of the GNU Lesser General Public License as published by
376
+ the Free Software Foundation, either version 3 of the License, or
377
+ (at your option) any later version.
378
+
379
+ web3.js is distributed in the hope that it will be useful,
380
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
381
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
382
+ GNU Lesser General Public License for more details.
383
+
384
+ You should have received a copy of the GNU Lesser General Public License
385
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
386
+ */
387
+ // Response error
388
+ const ERR_MULTIPLE_ERRORS = 208;
389
+ // RPC error codes (EIP-1193)
390
+ // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors
391
+ const JSONRPC_ERR_REJECTED_REQUEST = 4001;
392
+ const JSONRPC_ERR_UNAUTHORIZED = 4100;
393
+ const JSONRPC_ERR_UNSUPPORTED_METHOD = 4200;
394
+ const JSONRPC_ERR_DISCONNECTED = 4900;
395
+ const JSONRPC_ERR_CHAIN_DISCONNECTED = 4901;
396
+ const ERR_INVALID_ADDRESS = 1005;
397
+ // RPC error codes (EIP-1474)
398
+ // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
399
+ const ERR_RPC_INVALID_JSON = -32700;
400
+ const ERR_RPC_INVALID_REQUEST = -32600;
401
+ const ERR_RPC_INVALID_METHOD = -32601;
402
+ const ERR_RPC_INVALID_PARAMS = -32602;
403
+ const ERR_RPC_INTERNAL_ERROR = -32603;
404
+ const ERR_RPC_INVALID_INPUT = -32000;
405
+ const ERR_RPC_MISSING_RESOURCE = -32001;
406
+ const ERR_RPC_UNAVAILABLE_RESOURCE = -32002;
407
+ const ERR_RPC_TRANSACTION_REJECTED = -32003;
408
+ const ERR_RPC_UNSUPPORTED_METHOD = -32004;
409
+ const ERR_RPC_LIMIT_EXCEEDED = -32005;
410
+ const ERR_RPC_NOT_SUPPORTED = -32006;
411
+
412
+ /*
413
+ This file is part of web3.js.
414
+
415
+ web3.js is free software: you can redistribute it and/or modify
416
+ it under the terms of the GNU Lesser General Public License as published by
417
+ the Free Software Foundation, either version 3 of the License, or
418
+ (at your option) any later version.
419
+
420
+ web3.js is distributed in the hope that it will be useful,
421
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
422
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
423
+ GNU Lesser General Public License for more details.
424
+
425
+ You should have received a copy of the GNU Lesser General Public License
426
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
427
+ */
428
+ /**
429
+ * Base class for Web3 errors.
430
+ */
431
+ class BaseWeb3Error extends Error {
432
+ constructor(msg, cause) {
433
+ super(msg);
434
+ if (Array.isArray(cause)) {
435
+ // eslint-disable-next-line no-use-before-define
436
+ this.cause = new MultipleErrors(cause);
437
+ }
438
+ else {
439
+ this.cause = cause;
440
+ }
441
+ this.name = this.constructor.name;
442
+ if (typeof Error.captureStackTrace === 'function') {
443
+ Error.captureStackTrace(new.target.constructor);
444
+ }
445
+ else {
446
+ this.stack = new Error().stack;
447
+ }
448
+ }
449
+ /**
450
+ * @deprecated Use the `cause` property instead.
451
+ */
452
+ get innerError() {
453
+ // eslint-disable-next-line no-use-before-define
454
+ if (this.cause instanceof MultipleErrors) {
455
+ return this.cause.errors;
456
+ }
457
+ return this.cause;
458
+ }
459
+ /**
460
+ * @deprecated Use the `cause` property instead.
461
+ */
462
+ set innerError(cause) {
463
+ if (Array.isArray(cause)) {
464
+ // eslint-disable-next-line no-use-before-define
465
+ this.cause = new MultipleErrors(cause);
466
+ }
467
+ else {
468
+ this.cause = cause;
469
+ }
470
+ }
471
+ static convertToString(value, unquotValue = false) {
472
+ // Using "null" value intentionally for validation
473
+ // eslint-disable-next-line no-null/no-null
474
+ if (value === null || value === undefined)
475
+ return 'undefined';
476
+ const result = JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v));
477
+ return unquotValue && ['bigint', 'string'].includes(typeof value)
478
+ ? result.replace(/['\\"]+/g, '')
479
+ : result;
480
+ }
481
+ toJSON() {
482
+ return {
483
+ name: this.name,
484
+ code: this.code,
485
+ message: this.message,
486
+ cause: this.cause,
487
+ // deprecated
488
+ innerError: this.cause,
489
+ };
490
+ }
491
+ }
492
+ class MultipleErrors extends BaseWeb3Error {
493
+ constructor(errors) {
494
+ super(`Multiple errors occurred: [${errors.map(e => e.message).join('], [')}]`);
495
+ this.code = ERR_MULTIPLE_ERRORS;
496
+ this.errors = errors;
497
+ }
498
+ }
499
+ class InvalidValueError extends BaseWeb3Error {
500
+ constructor(value, msg) {
501
+ super(`Invalid value given "${BaseWeb3Error.convertToString(value, true)}". Error: ${msg}.`);
502
+ this.name = this.constructor.name;
503
+ }
504
+ }
505
+
506
+ /*
507
+ This file is part of web3.js.
508
+
509
+ web3.js is free software: you can redistribute it and/or modify
510
+ it under the terms of the GNU Lesser General Public License as published by
511
+ the Free Software Foundation, either version 3 of the License, or
512
+ (at your option) any later version.
513
+
514
+ web3.js is distributed in the hope that it will be useful,
515
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
516
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
517
+ GNU Lesser General Public License for more details.
518
+
519
+ You should have received a copy of the GNU Lesser General Public License
520
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
521
+ */
522
+ /* eslint-disable max-classes-per-file */
523
+ class InvalidAddressError extends InvalidValueError {
524
+ constructor(value) {
525
+ super(value, 'invalid ethereum address');
526
+ this.code = ERR_INVALID_ADDRESS;
527
+ }
528
+ }
529
+
530
+ /*
531
+ This file is part of web3.js.
532
+
533
+ web3.js is free software: you can redistribute it and/or modify
534
+ it under the terms of the GNU Lesser General Public License as published by
535
+ the Free Software Foundation, either version 3 of the License, or
536
+ (at your option) any later version.
537
+
538
+ web3.js is distributed in the hope that it will be useful,
539
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
540
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
541
+ GNU Lesser General Public License for more details.
542
+
543
+ You should have received a copy of the GNU Lesser General Public License
544
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
545
+ */
546
+ /**
547
+ * A template string for a generic Rpc Error. The `*code*` will be replaced with the code number.
548
+ * Note: consider in next version that a spelling mistake could be corrected for `occured` and the value could be:
549
+ * `An Rpc error has occurred with a code of *code*`
550
+ */
551
+ const genericRpcErrorMessageTemplate = 'An Rpc error has occured with a code of *code*';
552
+ /* eslint-disable @typescript-eslint/naming-convention */
553
+ const RpcErrorMessages = {
554
+ // EIP-1474 & JSON RPC 2.0
555
+ // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md
556
+ [ERR_RPC_INVALID_JSON]: {
557
+ message: 'Parse error',
558
+ description: 'Invalid JSON',
559
+ },
560
+ [ERR_RPC_INVALID_REQUEST]: {
561
+ message: 'Invalid request',
562
+ description: 'JSON is not a valid request object ',
563
+ },
564
+ [ERR_RPC_INVALID_METHOD]: {
565
+ message: 'Method not found',
566
+ description: 'Method does not exist ',
567
+ },
568
+ [ERR_RPC_INVALID_PARAMS]: {
569
+ message: 'Invalid params',
570
+ description: 'Invalid method parameters',
571
+ },
572
+ [ERR_RPC_INTERNAL_ERROR]: {
573
+ message: 'Internal error',
574
+ description: 'Internal JSON-RPC error',
575
+ },
576
+ [ERR_RPC_INVALID_INPUT]: {
577
+ message: 'Invalid input',
578
+ description: 'Missing or invalid parameters',
579
+ },
580
+ [ERR_RPC_MISSING_RESOURCE]: {
581
+ message: 'Resource not found',
582
+ description: 'Requested resource not found',
583
+ },
584
+ [ERR_RPC_UNAVAILABLE_RESOURCE]: {
585
+ message: 'Resource unavailable',
586
+ description: 'Requested resource not available',
587
+ },
588
+ [ERR_RPC_TRANSACTION_REJECTED]: {
589
+ message: 'Transaction rejected',
590
+ description: 'Transaction creation failed',
591
+ },
592
+ [ERR_RPC_UNSUPPORTED_METHOD]: {
593
+ message: 'Method not supported',
594
+ description: 'Method is not implemented',
595
+ },
596
+ [ERR_RPC_LIMIT_EXCEEDED]: {
597
+ message: 'Limit exceeded',
598
+ description: 'Request exceeds defined limit',
599
+ },
600
+ [ERR_RPC_NOT_SUPPORTED]: {
601
+ message: 'JSON-RPC version not supported',
602
+ description: 'Version of JSON-RPC protocol is not supported',
603
+ },
604
+ // EIP-1193
605
+ // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors
606
+ [JSONRPC_ERR_REJECTED_REQUEST]: {
607
+ name: 'User Rejected Request',
608
+ message: 'The user rejected the request.',
609
+ },
610
+ [JSONRPC_ERR_UNAUTHORIZED]: {
611
+ name: 'Unauthorized',
612
+ message: 'The requested method and/or account has not been authorized by the user.',
613
+ },
614
+ [JSONRPC_ERR_UNSUPPORTED_METHOD]: {
615
+ name: 'Unsupported Method',
616
+ message: 'The Provider does not support the requested method.',
617
+ },
618
+ [JSONRPC_ERR_DISCONNECTED]: {
619
+ name: 'Disconnected',
620
+ message: 'The Provider is disconnected from all chains.',
621
+ },
622
+ [JSONRPC_ERR_CHAIN_DISCONNECTED]: {
623
+ name: 'Chain Disconnected',
624
+ message: 'The Provider is not connected to the requested chain.',
625
+ },
626
+ // EIP-1193 - CloseEvent
627
+ // https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
628
+ '0-999': {
629
+ name: '',
630
+ message: 'Not used.',
631
+ },
632
+ 1000: {
633
+ name: 'Normal Closure',
634
+ message: 'The connection successfully completed the purpose for which it was created.',
635
+ },
636
+ 1001: {
637
+ name: 'Going Away',
638
+ message: 'The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.',
639
+ },
640
+ 1002: {
641
+ name: 'Protocol error',
642
+ message: 'The endpoint is terminating the connection due to a protocol error.',
643
+ },
644
+ 1003: {
645
+ name: 'Unsupported Data',
646
+ message: 'The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)',
647
+ },
648
+ 1004: {
649
+ name: 'Reserved',
650
+ message: 'Reserved. A meaning might be defined in the future.',
651
+ },
652
+ 1005: {
653
+ name: 'No Status Rcvd',
654
+ message: 'Reserved. Indicates that no status code was provided even though one was expected.',
655
+ },
656
+ 1006: {
657
+ name: 'Abnormal Closure',
658
+ message: 'Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected.',
659
+ },
660
+ 1007: {
661
+ name: 'Invalid frame payload data',
662
+ message: 'The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message).',
663
+ },
664
+ 1008: {
665
+ name: 'Policy Violation',
666
+ message: 'The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable.',
667
+ },
668
+ 1009: {
669
+ name: 'Message Too Big',
670
+ message: 'The endpoint is terminating the connection because a data frame was received that is too large.',
671
+ },
672
+ 1010: {
673
+ name: 'Mandatory Ext.',
674
+ message: "The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't.",
675
+ },
676
+ 1011: {
677
+ name: 'Internal Error',
678
+ message: 'The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.',
679
+ },
680
+ 1012: {
681
+ name: 'Service Restart',
682
+ message: 'The server is terminating the connection because it is restarting.',
683
+ },
684
+ 1013: {
685
+ name: 'Try Again Later',
686
+ message: 'The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients.',
687
+ },
688
+ 1014: {
689
+ name: 'Bad Gateway',
690
+ message: 'The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code.',
691
+ },
692
+ 1015: {
693
+ name: 'TLS handshake',
694
+ message: "Reserved. Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).",
695
+ },
696
+ '1016-2999': {
697
+ name: '',
698
+ message: 'For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications.',
699
+ },
700
+ '3000-3999': {
701
+ name: '',
702
+ message: 'For use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol.',
703
+ },
704
+ '4000-4999': {
705
+ name: '',
706
+ message: "For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol.",
707
+ },
708
+ };
709
+
710
+ /*
711
+ This file is part of web3.js.
712
+
713
+ web3.js is free software: you can redistribute it and/or modify
714
+ it under the terms of the GNU Lesser General Public License as published by
715
+ the Free Software Foundation, either version 3 of the License, or
716
+ (at your option) any later version.
717
+
718
+ web3.js is distributed in the hope that it will be useful,
719
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
720
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
721
+ GNU Lesser General Public License for more details.
722
+
723
+ You should have received a copy of the GNU Lesser General Public License
724
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
725
+ */
726
+ class RpcError extends BaseWeb3Error {
727
+ constructor(rpcError, message) {
728
+ super(message !== null && message !== void 0 ? message : genericRpcErrorMessageTemplate.replace('*code*', rpcError.error.code.toString()));
729
+ this.code = rpcError.error.code;
730
+ this.id = rpcError.id;
731
+ this.jsonrpc = rpcError.jsonrpc;
732
+ this.jsonRpcError = rpcError.error;
733
+ }
734
+ toJSON() {
735
+ return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });
736
+ }
737
+ }
738
+ class ParseError extends RpcError {
739
+ constructor(rpcError) {
740
+ super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_JSON].message);
741
+ this.code = ERR_RPC_INVALID_JSON;
742
+ }
743
+ }
744
+ class InvalidRequestError extends RpcError {
745
+ constructor(rpcError) {
746
+ super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_REQUEST].message);
747
+ this.code = ERR_RPC_INVALID_REQUEST;
748
+ }
749
+ }
750
+ class MethodNotFoundError extends RpcError {
751
+ constructor(rpcError) {
752
+ super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_METHOD].message);
753
+ this.code = ERR_RPC_INVALID_METHOD;
754
+ }
755
+ }
756
+ class InvalidParamsError extends RpcError {
757
+ constructor(rpcError) {
758
+ super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_PARAMS].message);
759
+ this.code = ERR_RPC_INVALID_PARAMS;
760
+ }
761
+ }
762
+ class InternalError extends RpcError {
763
+ constructor(rpcError) {
764
+ super(rpcError, RpcErrorMessages[ERR_RPC_INTERNAL_ERROR].message);
765
+ this.code = ERR_RPC_INTERNAL_ERROR;
766
+ }
767
+ }
768
+ class InvalidInputError extends RpcError {
769
+ constructor(rpcError) {
770
+ super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_INPUT].message);
771
+ this.code = ERR_RPC_INVALID_INPUT;
772
+ }
773
+ }
774
+ class MethodNotSupported extends RpcError {
775
+ constructor(rpcError) {
776
+ super(rpcError, RpcErrorMessages[ERR_RPC_UNSUPPORTED_METHOD].message);
777
+ this.code = ERR_RPC_UNSUPPORTED_METHOD;
778
+ }
779
+ }
780
+ class ResourceUnavailableError extends RpcError {
781
+ constructor(rpcError) {
782
+ super(rpcError, RpcErrorMessages[ERR_RPC_UNAVAILABLE_RESOURCE].message);
783
+ this.code = ERR_RPC_UNAVAILABLE_RESOURCE;
784
+ }
785
+ }
786
+ class ResourcesNotFoundError extends RpcError {
787
+ constructor(rpcError) {
788
+ super(rpcError, RpcErrorMessages[ERR_RPC_MISSING_RESOURCE].message);
789
+ this.code = ERR_RPC_MISSING_RESOURCE;
790
+ }
791
+ }
792
+ class VersionNotSupportedError extends RpcError {
793
+ constructor(rpcError) {
794
+ super(rpcError, RpcErrorMessages[ERR_RPC_NOT_SUPPORTED].message);
795
+ this.code = ERR_RPC_NOT_SUPPORTED;
796
+ }
797
+ }
798
+ class TransactionRejectedError extends RpcError {
799
+ constructor(rpcError) {
800
+ super(rpcError, RpcErrorMessages[ERR_RPC_TRANSACTION_REJECTED].message);
801
+ this.code = ERR_RPC_TRANSACTION_REJECTED;
802
+ }
803
+ }
804
+ class LimitExceededError extends RpcError {
805
+ constructor(rpcError) {
806
+ super(rpcError, RpcErrorMessages[ERR_RPC_LIMIT_EXCEEDED].message);
807
+ this.code = ERR_RPC_LIMIT_EXCEEDED;
808
+ }
809
+ }
810
+ const rpcErrorsMap = new Map();
811
+ rpcErrorsMap.set(ERR_RPC_INVALID_JSON, { error: ParseError });
812
+ rpcErrorsMap.set(ERR_RPC_INVALID_REQUEST, {
813
+ error: InvalidRequestError,
814
+ });
815
+ rpcErrorsMap.set(ERR_RPC_INVALID_METHOD, {
816
+ error: MethodNotFoundError,
817
+ });
818
+ rpcErrorsMap.set(ERR_RPC_INVALID_PARAMS, { error: InvalidParamsError });
819
+ rpcErrorsMap.set(ERR_RPC_INTERNAL_ERROR, { error: InternalError });
820
+ rpcErrorsMap.set(ERR_RPC_INVALID_INPUT, { error: InvalidInputError });
821
+ rpcErrorsMap.set(ERR_RPC_UNSUPPORTED_METHOD, {
822
+ error: MethodNotSupported,
823
+ });
824
+ rpcErrorsMap.set(ERR_RPC_UNAVAILABLE_RESOURCE, {
825
+ error: ResourceUnavailableError,
826
+ });
827
+ rpcErrorsMap.set(ERR_RPC_TRANSACTION_REJECTED, {
828
+ error: TransactionRejectedError,
829
+ });
830
+ rpcErrorsMap.set(ERR_RPC_MISSING_RESOURCE, {
831
+ error: ResourcesNotFoundError,
832
+ });
833
+ rpcErrorsMap.set(ERR_RPC_NOT_SUPPORTED, {
834
+ error: VersionNotSupportedError,
835
+ });
836
+ rpcErrorsMap.set(ERR_RPC_LIMIT_EXCEEDED, { error: LimitExceededError });
837
+
838
+ /*
839
+ This file is part of web3.js.
840
+
841
+ web3.js is free software: you can redistribute it and/or modify
842
+ it under the terms of the GNU Lesser General Public License as published by
843
+ the Free Software Foundation, either version 3 of the License, or
844
+ (at your option) any later version.
845
+
846
+ web3.js is distributed in the hope that it will be useful,
847
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
848
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
849
+ GNU Lesser General Public License for more details.
850
+
851
+ You should have received a copy of the GNU Lesser General Public License
852
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
853
+ */
854
+ /**
855
+ * checks input if typeof data is valid string input
856
+ */
857
+ const isHexStrict = (hex) => typeof hex === 'string' && /^((-)?0x[0-9a-f]+|(0x))$/i.test(hex);
858
+
859
+ /*
860
+ This file is part of web3.js.
861
+
862
+ web3.js is free software: you can redistribute it and/or modify
863
+ it under the terms of the GNU Lesser General Public License as published by
864
+ the Free Software Foundation, either version 3 of the License, or
865
+ (at your option) any later version.
866
+
867
+ web3.js is distributed in the hope that it will be useful,
868
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
869
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
870
+ GNU Lesser General Public License for more details.
871
+
872
+ You should have received a copy of the GNU Lesser General Public License
873
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
874
+ */
875
+ function uint8ArrayToHexString(uint8Array) {
876
+ let hexString = '0x';
877
+ for (const e of uint8Array) {
878
+ const hex = e.toString(16);
879
+ hexString += hex.length === 1 ? `0${hex}` : hex;
880
+ }
881
+ return hexString;
882
+ }
883
+ // @TODO: Remove this function and its usages once all sub dependencies uses version 1.3.3 or above of @noble/hashes
884
+ function ensureIfUint8Array(data) {
885
+ var _a;
886
+ if (!(data instanceof Uint8Array) &&
887
+ ((_a = data === null || data === void 0 ? void 0 : data.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Uint8Array') {
888
+ return Uint8Array.from(data);
889
+ }
890
+ return data;
891
+ }
892
+
893
+ /*
894
+ This file is part of web3.js.
895
+
896
+ web3.js is free software: you can redistribute it and/or modify
897
+ it under the terms of the GNU Lesser General Public License as published by
898
+ the Free Software Foundation, either version 3 of the License, or
899
+ (at your option) any later version.
900
+
901
+ web3.js is distributed in the hope that it will be useful,
902
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
903
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
904
+ GNU Lesser General Public License for more details.
905
+
906
+ You should have received a copy of the GNU Lesser General Public License
907
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
908
+ */
909
+ /**
910
+ * checks input if typeof data is valid Uint8Array input
911
+ */
912
+ const isUint8Array = (data) => { var _a, _b; return data instanceof Uint8Array || ((_a = data === null || data === void 0 ? void 0 : data.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Uint8Array' || ((_b = data === null || data === void 0 ? void 0 : data.constructor) === null || _b === void 0 ? void 0 : _b.name) === 'Buffer'; };
913
+
914
+ /*
915
+ This file is part of web3.js.
916
+
917
+ web3.js is free software: you can redistribute it and/or modify
918
+ it under the terms of the GNU Lesser General Public License as published by
919
+ the Free Software Foundation, either version 3 of the License, or
920
+ (at your option) any later version.
921
+
922
+ web3.js is distributed in the hope that it will be useful,
923
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
924
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
925
+ GNU Lesser General Public License for more details.
926
+
927
+ You should have received a copy of the GNU Lesser General Public License
928
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
929
+ */
930
+ /**
931
+ * Checks the checksum of a given address. Will also return false on non-checksum addresses.
932
+ */
933
+ const checkAddressCheckSum = (data) => {
934
+ if (!/^(0x)?[0-9a-f]{40}$/i.test(data))
935
+ return false;
936
+ const address = data.slice(2);
937
+ const updatedData = utf8ToBytes$1(address.toLowerCase());
938
+ const addressHash = uint8ArrayToHexString(keccak256(ensureIfUint8Array(updatedData))).slice(2);
939
+ for (let i = 0; i < 40; i += 1) {
940
+ // the nth letter should be uppercase if the nth digit of casemap is 1
941
+ if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) ||
942
+ (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
943
+ return false;
944
+ }
945
+ }
946
+ return true;
947
+ };
948
+ /**
949
+ * Checks if a given string is a valid Ethereum address. It will also check the checksum, if the address has upper and lowercase letters.
950
+ */
951
+ const isAddress = (value, checkChecksum = true) => {
952
+ if (typeof value !== 'string' && !isUint8Array(value)) {
953
+ return false;
954
+ }
955
+ let valueToCheck;
956
+ if (isUint8Array(value)) {
957
+ valueToCheck = uint8ArrayToHexString(value);
958
+ }
959
+ else if (typeof value === 'string' && !isHexStrict(value)) {
960
+ valueToCheck = value.toLowerCase().startsWith('0x') ? value : `0x${value}`;
961
+ }
962
+ else {
963
+ valueToCheck = value;
964
+ }
965
+ // check if it has the basic requirements of an address
966
+ if (!/^(0x)?[0-9a-f]{40}$/i.test(valueToCheck)) {
967
+ return false;
968
+ }
969
+ // If it's ALL lowercase or ALL upppercase
970
+ if (/^(0x|0X)?[0-9a-f]{40}$/.test(valueToCheck) ||
971
+ /^(0x|0X)?[0-9A-F]{40}$/.test(valueToCheck)) {
972
+ return true;
973
+ // Otherwise check each case
974
+ }
975
+ return checkChecksum ? checkAddressCheckSum(valueToCheck) : true;
976
+ };
977
+
978
+ /*
979
+ This file is part of web3.js.
980
+
981
+ web3.js is free software: you can redistribute it and/or modify
982
+ it under the terms of the GNU Lesser General Public License as published by
983
+ the Free Software Foundation, either version 3 of the License, or
984
+ (at your option) any later version.
985
+
986
+ web3.js is distributed in the hope that it will be useful,
987
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
988
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
989
+ GNU Lesser General Public License for more details.
990
+
991
+ You should have received a copy of the GNU Lesser General Public License
992
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
993
+ */
994
+ var FMT_NUMBER;
995
+ (function (FMT_NUMBER) {
996
+ FMT_NUMBER["NUMBER"] = "NUMBER_NUMBER";
997
+ FMT_NUMBER["HEX"] = "NUMBER_HEX";
998
+ FMT_NUMBER["STR"] = "NUMBER_STR";
999
+ FMT_NUMBER["BIGINT"] = "NUMBER_BIGINT";
1000
+ })(FMT_NUMBER || (FMT_NUMBER = {}));
1001
+ var FMT_BYTES;
1002
+ (function (FMT_BYTES) {
1003
+ FMT_BYTES["HEX"] = "BYTES_HEX";
1004
+ FMT_BYTES["UINT8ARRAY"] = "BYTES_UINT8ARRAY";
1005
+ })(FMT_BYTES || (FMT_BYTES = {}));
1006
+ ({
1007
+ number: FMT_NUMBER.BIGINT,
1008
+ bytes: FMT_BYTES.HEX,
1009
+ });
1010
+ ({ number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX });
1011
+
1012
+ var BlockTags;
1013
+ (function (BlockTags) {
1014
+ BlockTags["EARLIEST"] = "earliest";
1015
+ BlockTags["LATEST"] = "latest";
1016
+ BlockTags["PENDING"] = "pending";
1017
+ BlockTags["SAFE"] = "safe";
1018
+ BlockTags["FINALIZED"] = "finalized";
1019
+ })(BlockTags || (BlockTags = {}));
1020
+ // This list of hardforks is expected to be in order
1021
+ // keep this in mind when making changes to it
1022
+ var HardforksOrdered;
1023
+ (function (HardforksOrdered) {
1024
+ HardforksOrdered["chainstart"] = "chainstart";
1025
+ HardforksOrdered["frontier"] = "frontier";
1026
+ HardforksOrdered["homestead"] = "homestead";
1027
+ HardforksOrdered["dao"] = "dao";
1028
+ HardforksOrdered["tangerineWhistle"] = "tangerineWhistle";
1029
+ HardforksOrdered["spuriousDragon"] = "spuriousDragon";
1030
+ HardforksOrdered["byzantium"] = "byzantium";
1031
+ HardforksOrdered["constantinople"] = "constantinople";
1032
+ HardforksOrdered["petersburg"] = "petersburg";
1033
+ HardforksOrdered["istanbul"] = "istanbul";
1034
+ HardforksOrdered["muirGlacier"] = "muirGlacier";
1035
+ HardforksOrdered["berlin"] = "berlin";
1036
+ HardforksOrdered["london"] = "london";
1037
+ HardforksOrdered["altair"] = "altair";
1038
+ HardforksOrdered["arrowGlacier"] = "arrowGlacier";
1039
+ HardforksOrdered["grayGlacier"] = "grayGlacier";
1040
+ HardforksOrdered["bellatrix"] = "bellatrix";
1041
+ HardforksOrdered["merge"] = "merge";
1042
+ HardforksOrdered["capella"] = "capella";
1043
+ HardforksOrdered["shanghai"] = "shanghai";
1044
+ })(HardforksOrdered || (HardforksOrdered = {}));
1045
+
1046
+ (globalThis && globalThis.__awaiter) || function (thisArg, _arguments, P, generator) {
1047
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1048
+ return new (P || (P = Promise))(function (resolve, reject) {
1049
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1050
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1051
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1052
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1053
+ });
1054
+ };
1055
+
1056
+ /*
1057
+ This file is part of web3.js.
1058
+
1059
+ web3.js is free software: you can redistribute it and/or modify
1060
+ it under the terms of the GNU Lesser General Public License as published by
1061
+ the Free Software Foundation, either version 3 of the License, or
1062
+ (at your option) any later version.
1063
+
1064
+ web3.js is distributed in the hope that it will be useful,
1065
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1066
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1067
+ GNU Lesser General Public License for more details.
1068
+
1069
+ You should have received a copy of the GNU Lesser General Public License
1070
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1071
+ */
1072
+ // Explicitly check for the
1073
+ // eslint-disable-next-line @typescript-eslint/ban-types
1074
+ const isNullish = (item) =>
1075
+ // Using "null" value intentionally for validation
1076
+ // eslint-disable-next-line no-null/no-null
1077
+ item === undefined || item === null;
1078
+
1079
+ /*
1080
+ This file is part of web3.js.
1081
+
1082
+ web3.js is free software: you can redistribute it and/or modify
1083
+ it under the terms of the GNU Lesser General Public License as published by
1084
+ the Free Software Foundation, either version 3 of the License, or
1085
+ (at your option) any later version.
1086
+
1087
+ web3.js is distributed in the hope that it will be useful,
1088
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1089
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1090
+ GNU Lesser General Public License for more details.
1091
+
1092
+ You should have received a copy of the GNU Lesser General Public License
1093
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1094
+ */
1095
+ /**
1096
+ * @module Utils
1097
+ */
1098
+ // Ref: https://ethdocs.org/en/latest/ether.html
1099
+ // Note: this could be simplified using ** operator, but babel does not handle it well (https://github.com/babel/babel/issues/13109)
1100
+ /** @internal */
1101
+ ({
1102
+ noether: BigInt(0),
1103
+ wei: BigInt(1),
1104
+ kwei: BigInt(1000),
1105
+ Kwei: BigInt(1000),
1106
+ babbage: BigInt(1000),
1107
+ femtoether: BigInt(1000),
1108
+ mwei: BigInt(1000000),
1109
+ Mwei: BigInt(1000000),
1110
+ lovelace: BigInt(1000000),
1111
+ picoether: BigInt(1000000),
1112
+ gwei: BigInt(1000000000),
1113
+ Gwei: BigInt(1000000000),
1114
+ shannon: BigInt(1000000000),
1115
+ nanoether: BigInt(1000000000),
1116
+ nano: BigInt(1000000000),
1117
+ szabo: BigInt(1000000000000),
1118
+ microether: BigInt(1000000000000),
1119
+ micro: BigInt(1000000000000),
1120
+ finney: BigInt(1000000000000000),
1121
+ milliether: BigInt(1000000000000000),
1122
+ milli: BigInt(1000000000000000),
1123
+ ether: BigInt('1000000000000000000'),
1124
+ kether: BigInt('1000000000000000000000'),
1125
+ grand: BigInt('1000000000000000000000'),
1126
+ mether: BigInt('1000000000000000000000000'),
1127
+ gether: BigInt('1000000000000000000000000000'),
1128
+ tether: BigInt('1000000000000000000000000000000'),
1129
+ });
1130
+ const utf8ToBytes = utf8ToBytes$1;
1131
+ /**
1132
+ * Will convert an upper or lowercase Ethereum address to a checksum address.
1133
+ * @param address - An address string
1134
+ * @returns The checksum address
1135
+ * @example
1136
+ * ```ts
1137
+ * web3.utils.toChecksumAddress('0xc1912fee45d61c87cc5ea59dae31190fffff232d');
1138
+ * > "0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d"
1139
+ * ```
1140
+ */
1141
+ const toChecksumAddress = (address) => {
1142
+ if (!isAddress(address, false)) {
1143
+ throw new InvalidAddressError(address);
1144
+ }
1145
+ const lowerCaseAddress = address.toLowerCase().replace(/^0x/i, '');
1146
+ // calling `Uint8Array.from` because `noble-hashes` checks with `instanceof Uint8Array` that fails in some edge cases:
1147
+ // https://github.com/paulmillr/noble-hashes/issues/25#issuecomment-1750106284
1148
+ const hash = uint8ArrayToHexString(keccak256(ensureIfUint8Array(utf8ToBytes(lowerCaseAddress))));
1149
+ if (isNullish(hash) ||
1150
+ hash === '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470')
1151
+ return ''; // // EIP-1052 if hash is equal to c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470, keccak was given empty data
1152
+ let checksumAddress = '0x';
1153
+ const addressHash = hash.replace(/^0x/i, '');
1154
+ for (let i = 0; i < lowerCaseAddress.length; i += 1) {
1155
+ // If ith character is 8 to f then make it uppercase
1156
+ if (parseInt(addressHash[i], 16) > 7) {
1157
+ checksumAddress += lowerCaseAddress[i].toUpperCase();
1158
+ }
1159
+ else {
1160
+ checksumAddress += lowerCaseAddress[i];
1161
+ }
1162
+ }
1163
+ return checksumAddress;
1164
+ };
1165
+
27
1166
  const style = ":host {\n display: inline-flex\n}";
28
1167
 
29
1168
  var __defProp = Object.defineProperty;
@@ -92,23 +1231,36 @@ exports.LuksoUsername = class LuksoUsername extends shared_tailwindElement_index
92
1231
  }
93
1232
  });
94
1233
  }
95
- validateName(name) {
1234
+ transformName(name) {
96
1235
  if (this.noTransform) {
97
1236
  return name;
98
1237
  }
99
1238
  return name?.toLowerCase();
100
1239
  }
1240
+ transformAddress(address) {
1241
+ if (this.noTransform) {
1242
+ return address;
1243
+ }
1244
+ try {
1245
+ return toChecksumAddress(address);
1246
+ } catch (error) {
1247
+ console.warn(error);
1248
+ return address;
1249
+ }
1250
+ }
101
1251
  addressBytesTemplate(styles) {
1252
+ const address = this.transformAddress(this.address);
102
1253
  return shared_tailwindElement_index.x`<div
103
1254
  class=${styles}
104
1255
  style=${index$1.customStyleMap({
105
1256
  [`color: var(--${this.addressColor})`]: this.addressColor !== ""
106
1257
  })}
107
1258
  >
108
- #${this.address.slice(2, 6)}
1259
+ #${address.slice(2, 6)}
109
1260
  </div>`;
110
1261
  }
111
1262
  nameTemplate(styles) {
1263
+ const name = this.transformName(this.name);
112
1264
  return shared_tailwindElement_index.x`<div
113
1265
  class=${styles}
114
1266
  style=${index$1.customStyleMap({
@@ -116,17 +1268,18 @@ exports.LuksoUsername = class LuksoUsername extends shared_tailwindElement_index
116
1268
  [`color: var(--${this.nameColor})`]: this.nameColor !== ""
117
1269
  })}
118
1270
  >
119
- ${this.hidePrefix ? shared_tailwindElement_index.A : this.prefix}${this.validateName(this.name)}
1271
+ ${this.hidePrefix ? shared_tailwindElement_index.A : this.prefix}${name}
120
1272
  </div>`;
121
1273
  }
122
1274
  addressTemplate(styles) {
1275
+ const address = this.transformAddress(this.address);
123
1276
  return shared_tailwindElement_index.x`<div
124
1277
  class=${styles}
125
1278
  style=${index$1.customStyleMap({
126
1279
  [`color: var(--${this.addressColor})`]: this.addressColor !== ""
127
1280
  })}
128
1281
  >
129
- ${sliceAddress(this.address, this.sliceBy, this.sliceBy)}
1282
+ ${sliceAddress(address, this.sliceBy, this.sliceBy)}
130
1283
  </div>`;
131
1284
  }
132
1285
  render() {