@lukso/web-components 1.172.13 → 1.172.14

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