@fileverse-dev/formulajs 4.4.11-mod-28 → 4.4.11-mod-31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/esm/index.mjs CHANGED
@@ -13106,6 +13106,10 @@ const ERROR_MESSAGES_FLAG = {
13106
13106
  INVALID_PARAM: '_INVALID_PARAM'
13107
13107
  };
13108
13108
 
13109
+ const UTILITY = {
13110
+ ALCHEMY_API_KEY: 'ALCHEMY_API_KEY'
13111
+ };
13112
+
13109
13113
  const SERVICE_API_KEY = {
13110
13114
  Etherscan: "ETHERSCAN_API_KEY",
13111
13115
  Coingecko: "COINGECKO_API_KEY",
@@ -13133,6 +13137,37 @@ function toTimestamp(dateStr) {
13133
13137
  return Math.floor(date.getTime() / 1000); // Unix timestamp in seconds
13134
13138
  }
13135
13139
 
13140
+ const isAddress = (input) => {
13141
+ return (/^0x[a-fA-F0-9]{40}$/.test(input))
13142
+ };
13143
+
13144
+ async function fromEnsNameToAddress(name) {
13145
+ if (typeof ethers === "undefined") {
13146
+ await new Promise((resolve, reject) => {
13147
+ const script = document.createElement("script");
13148
+ script.src = "https://cdn.jsdelivr.net/npm/ethers@6.10.0/dist/ethers.umd.min.js";
13149
+ script.onload = resolve;
13150
+ script.onerror = reject;
13151
+ document.head.appendChild(script);
13152
+ });
13153
+ }
13154
+
13155
+ const ALCHEMY_KEY = window.localStorage.getItem(UTILITY.ALCHEMY_API_KEY);
13156
+ if(!ALCHEMY_KEY){
13157
+ console.error("alchemy api key missing");
13158
+ return null
13159
+ }
13160
+ const provider = new ethers.AlchemyProvider("mainnet", ALCHEMY_KEY);
13161
+
13162
+ try {
13163
+ const resolved = await provider.resolveName(name); // ENS ➝ address
13164
+ return resolved || null;
13165
+ } catch (err) {
13166
+ console.error("ENS resolution failed:", err.message);
13167
+ return null;
13168
+ }
13169
+ }
13170
+
13136
13171
  async function handleScanRequest({
13137
13172
  scanKey,
13138
13173
  baseUrl,
@@ -13151,6 +13186,14 @@ async function handleScanRequest({
13151
13186
  let chainId = CHAIN_ID_MAP[chain?.toLowerCase()];
13152
13187
  if (!chainId) return `${scanKey}${ERROR_MESSAGES_FLAG.INVALID_CHAIN}`;
13153
13188
 
13189
+ if(!isAddress(address)){
13190
+ address = await fromEnsNameToAddress(address);
13191
+ }
13192
+
13193
+ if(!address){
13194
+ return `${address}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`
13195
+ }
13196
+
13154
13197
  const ACTION_MAP = {
13155
13198
  'all-txns': 'txlist',
13156
13199
  'token-txns': 'tokentx',
@@ -13198,767 +13241,6 @@ if (scanKey === SERVICE_API_KEY.Gnosisscan) chainId = 'gnosis';
13198
13241
  }
13199
13242
  }
13200
13243
 
13201
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
13202
-
13203
- var sha3 = {exports: {}};
13204
-
13205
- /**
13206
- * [js-sha3]{@link https://github.com/emn178/js-sha3}
13207
- *
13208
- * @version 0.9.3
13209
- * @author Chen, Yi-Cyuan [emn178@gmail.com]
13210
- * @copyright Chen, Yi-Cyuan 2015-2023
13211
- * @license MIT
13212
- */
13213
-
13214
- var hasRequiredSha3;
13215
-
13216
- function requireSha3 () {
13217
- if (hasRequiredSha3) return sha3.exports;
13218
- hasRequiredSha3 = 1;
13219
- (function (module) {
13220
- /*jslint bitwise: true */
13221
- (function () {
13222
-
13223
- var INPUT_ERROR = 'input is invalid type';
13224
- var FINALIZE_ERROR = 'finalize already called';
13225
- var WINDOW = typeof window === 'object';
13226
- var root = WINDOW ? window : {};
13227
- if (root.JS_SHA3_NO_WINDOW) {
13228
- WINDOW = false;
13229
- }
13230
- var WEB_WORKER = !WINDOW && typeof self === 'object';
13231
- var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
13232
- if (NODE_JS) {
13233
- root = commonjsGlobal;
13234
- } else if (WEB_WORKER) {
13235
- root = self;
13236
- }
13237
- var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && 'object' === 'object' && module.exports;
13238
- var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
13239
- var HEX_CHARS = '0123456789abcdef'.split('');
13240
- var SHAKE_PADDING = [31, 7936, 2031616, 520093696];
13241
- var CSHAKE_PADDING = [4, 1024, 262144, 67108864];
13242
- var KECCAK_PADDING = [1, 256, 65536, 16777216];
13243
- var PADDING = [6, 1536, 393216, 100663296];
13244
- var SHIFT = [0, 8, 16, 24];
13245
- var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649,
13246
- 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0,
13247
- 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771,
13248
- 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648,
13249
- 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648];
13250
- var BITS = [224, 256, 384, 512];
13251
- var SHAKE_BITS = [128, 256];
13252
- var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest'];
13253
- var CSHAKE_BYTEPAD = {
13254
- '128': 168,
13255
- '256': 136
13256
- };
13257
-
13258
-
13259
- var isArray = root.JS_SHA3_NO_NODE_JS || !Array.isArray
13260
- ? function (obj) {
13261
- return Object.prototype.toString.call(obj) === '[object Array]';
13262
- }
13263
- : Array.isArray;
13264
-
13265
- var isView = (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView))
13266
- ? function (obj) {
13267
- return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
13268
- }
13269
- : ArrayBuffer.isView;
13270
-
13271
- // [message: string, isString: bool]
13272
- var formatMessage = function (message) {
13273
- var type = typeof message;
13274
- if (type === 'string') {
13275
- return [message, true];
13276
- }
13277
- if (type !== 'object' || message === null) {
13278
- throw new Error(INPUT_ERROR);
13279
- }
13280
- if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
13281
- return [new Uint8Array(message), false];
13282
- }
13283
- if (!isArray(message) && !isView(message)) {
13284
- throw new Error(INPUT_ERROR);
13285
- }
13286
- return [message, false];
13287
- };
13288
-
13289
- var empty = function (message) {
13290
- return formatMessage(message)[0].length === 0;
13291
- };
13292
-
13293
- var cloneArray = function (array) {
13294
- var newArray = [];
13295
- for (var i = 0; i < array.length; ++i) {
13296
- newArray[i] = array[i];
13297
- }
13298
- return newArray;
13299
- };
13300
-
13301
- var createOutputMethod = function (bits, padding, outputType) {
13302
- return function (message) {
13303
- return new Keccak(bits, padding, bits).update(message)[outputType]();
13304
- };
13305
- };
13306
-
13307
- var createShakeOutputMethod = function (bits, padding, outputType) {
13308
- return function (message, outputBits) {
13309
- return new Keccak(bits, padding, outputBits).update(message)[outputType]();
13310
- };
13311
- };
13312
-
13313
- var createCshakeOutputMethod = function (bits, padding, outputType) {
13314
- return function (message, outputBits, n, s) {
13315
- return methods['cshake' + bits].update(message, outputBits, n, s)[outputType]();
13316
- };
13317
- };
13318
-
13319
- var createKmacOutputMethod = function (bits, padding, outputType) {
13320
- return function (key, message, outputBits, s) {
13321
- return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
13322
- };
13323
- };
13324
-
13325
- var createOutputMethods = function (method, createMethod, bits, padding) {
13326
- for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
13327
- var type = OUTPUT_TYPES[i];
13328
- method[type] = createMethod(bits, padding, type);
13329
- }
13330
- return method;
13331
- };
13332
-
13333
- var createMethod = function (bits, padding) {
13334
- var method = createOutputMethod(bits, padding, 'hex');
13335
- method.create = function () {
13336
- return new Keccak(bits, padding, bits);
13337
- };
13338
- method.update = function (message) {
13339
- return method.create().update(message);
13340
- };
13341
- return createOutputMethods(method, createOutputMethod, bits, padding);
13342
- };
13343
-
13344
- var createShakeMethod = function (bits, padding) {
13345
- var method = createShakeOutputMethod(bits, padding, 'hex');
13346
- method.create = function (outputBits) {
13347
- return new Keccak(bits, padding, outputBits);
13348
- };
13349
- method.update = function (message, outputBits) {
13350
- return method.create(outputBits).update(message);
13351
- };
13352
- return createOutputMethods(method, createShakeOutputMethod, bits, padding);
13353
- };
13354
-
13355
- var createCshakeMethod = function (bits, padding) {
13356
- var w = CSHAKE_BYTEPAD[bits];
13357
- var method = createCshakeOutputMethod(bits, padding, 'hex');
13358
- method.create = function (outputBits, n, s) {
13359
- if (empty(n) && empty(s)) {
13360
- return methods['shake' + bits].create(outputBits);
13361
- } else {
13362
- return new Keccak(bits, padding, outputBits).bytepad([n, s], w);
13363
- }
13364
- };
13365
- method.update = function (message, outputBits, n, s) {
13366
- return method.create(outputBits, n, s).update(message);
13367
- };
13368
- return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
13369
- };
13370
-
13371
- var createKmacMethod = function (bits, padding) {
13372
- var w = CSHAKE_BYTEPAD[bits];
13373
- var method = createKmacOutputMethod(bits, padding, 'hex');
13374
- method.create = function (key, outputBits, s) {
13375
- return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
13376
- };
13377
- method.update = function (key, message, outputBits, s) {
13378
- return method.create(key, outputBits, s).update(message);
13379
- };
13380
- return createOutputMethods(method, createKmacOutputMethod, bits, padding);
13381
- };
13382
-
13383
- var algorithms = [
13384
- { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
13385
- { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
13386
- { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
13387
- { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
13388
- { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod }
13389
- ];
13390
-
13391
- var methods = {}, methodNames = [];
13392
-
13393
- for (var i = 0; i < algorithms.length; ++i) {
13394
- var algorithm = algorithms[i];
13395
- var bits = algorithm.bits;
13396
- for (var j = 0; j < bits.length; ++j) {
13397
- var methodName = algorithm.name + '_' + bits[j];
13398
- methodNames.push(methodName);
13399
- methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding);
13400
- if (algorithm.name !== 'sha3') {
13401
- var newMethodName = algorithm.name + bits[j];
13402
- methodNames.push(newMethodName);
13403
- methods[newMethodName] = methods[methodName];
13404
- }
13405
- }
13406
- }
13407
-
13408
- function Keccak(bits, padding, outputBits) {
13409
- this.blocks = [];
13410
- this.s = [];
13411
- this.padding = padding;
13412
- this.outputBits = outputBits;
13413
- this.reset = true;
13414
- this.finalized = false;
13415
- this.block = 0;
13416
- this.start = 0;
13417
- this.blockCount = (1600 - (bits << 1)) >> 5;
13418
- this.byteCount = this.blockCount << 2;
13419
- this.outputBlocks = outputBits >> 5;
13420
- this.extraBytes = (outputBits & 31) >> 3;
13421
-
13422
- for (var i = 0; i < 50; ++i) {
13423
- this.s[i] = 0;
13424
- }
13425
- }
13426
-
13427
- Keccak.prototype.update = function (message) {
13428
- if (this.finalized) {
13429
- throw new Error(FINALIZE_ERROR);
13430
- }
13431
- var result = formatMessage(message);
13432
- message = result[0];
13433
- var isString = result[1];
13434
- var blocks = this.blocks, byteCount = this.byteCount, length = message.length,
13435
- blockCount = this.blockCount, index = 0, s = this.s, i, code;
13436
-
13437
- while (index < length) {
13438
- if (this.reset) {
13439
- this.reset = false;
13440
- blocks[0] = this.block;
13441
- for (i = 1; i < blockCount + 1; ++i) {
13442
- blocks[i] = 0;
13443
- }
13444
- }
13445
- if (isString) {
13446
- for (i = this.start; index < length && i < byteCount; ++index) {
13447
- code = message.charCodeAt(index);
13448
- if (code < 0x80) {
13449
- blocks[i >> 2] |= code << SHIFT[i++ & 3];
13450
- } else if (code < 0x800) {
13451
- blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
13452
- blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
13453
- } else if (code < 0xd800 || code >= 0xe000) {
13454
- blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
13455
- blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
13456
- blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
13457
- } else {
13458
- code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
13459
- blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
13460
- blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
13461
- blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
13462
- blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
13463
- }
13464
- }
13465
- } else {
13466
- for (i = this.start; index < length && i < byteCount; ++index) {
13467
- blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
13468
- }
13469
- }
13470
- this.lastByteIndex = i;
13471
- if (i >= byteCount) {
13472
- this.start = i - byteCount;
13473
- this.block = blocks[blockCount];
13474
- for (i = 0; i < blockCount; ++i) {
13475
- s[i] ^= blocks[i];
13476
- }
13477
- f(s);
13478
- this.reset = true;
13479
- } else {
13480
- this.start = i;
13481
- }
13482
- }
13483
- return this;
13484
- };
13485
-
13486
- Keccak.prototype.encode = function (x, right) {
13487
- var o = x & 255, n = 1;
13488
- var bytes = [o];
13489
- x = x >> 8;
13490
- o = x & 255;
13491
- while (o > 0) {
13492
- bytes.unshift(o);
13493
- x = x >> 8;
13494
- o = x & 255;
13495
- ++n;
13496
- }
13497
- if (right) {
13498
- bytes.push(n);
13499
- } else {
13500
- bytes.unshift(n);
13501
- }
13502
- this.update(bytes);
13503
- return bytes.length;
13504
- };
13505
-
13506
- Keccak.prototype.encodeString = function (str) {
13507
- var result = formatMessage(str);
13508
- str = result[0];
13509
- var isString = result[1];
13510
- var bytes = 0, length = str.length;
13511
- if (isString) {
13512
- for (var i = 0; i < str.length; ++i) {
13513
- var code = str.charCodeAt(i);
13514
- if (code < 0x80) {
13515
- bytes += 1;
13516
- } else if (code < 0x800) {
13517
- bytes += 2;
13518
- } else if (code < 0xd800 || code >= 0xe000) {
13519
- bytes += 3;
13520
- } else {
13521
- code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
13522
- bytes += 4;
13523
- }
13524
- }
13525
- } else {
13526
- bytes = length;
13527
- }
13528
- bytes += this.encode(bytes * 8);
13529
- this.update(str);
13530
- return bytes;
13531
- };
13532
-
13533
- Keccak.prototype.bytepad = function (strs, w) {
13534
- var bytes = this.encode(w);
13535
- for (var i = 0; i < strs.length; ++i) {
13536
- bytes += this.encodeString(strs[i]);
13537
- }
13538
- var paddingBytes = (w - bytes % w) % w;
13539
- var zeros = [];
13540
- zeros.length = paddingBytes;
13541
- this.update(zeros);
13542
- return this;
13543
- };
13544
-
13545
- Keccak.prototype.finalize = function () {
13546
- if (this.finalized) {
13547
- return;
13548
- }
13549
- this.finalized = true;
13550
- var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s;
13551
- blocks[i >> 2] |= this.padding[i & 3];
13552
- if (this.lastByteIndex === this.byteCount) {
13553
- blocks[0] = blocks[blockCount];
13554
- for (i = 1; i < blockCount + 1; ++i) {
13555
- blocks[i] = 0;
13556
- }
13557
- }
13558
- blocks[blockCount - 1] |= 0x80000000;
13559
- for (i = 0; i < blockCount; ++i) {
13560
- s[i] ^= blocks[i];
13561
- }
13562
- f(s);
13563
- };
13564
-
13565
- Keccak.prototype.toString = Keccak.prototype.hex = function () {
13566
- this.finalize();
13567
-
13568
- var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
13569
- extraBytes = this.extraBytes, i = 0, j = 0;
13570
- var hex = '', block;
13571
- while (j < outputBlocks) {
13572
- for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
13573
- block = s[i];
13574
- hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] +
13575
- HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] +
13576
- HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] +
13577
- HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F];
13578
- }
13579
- if (j % blockCount === 0) {
13580
- s = cloneArray(s);
13581
- f(s);
13582
- i = 0;
13583
- }
13584
- }
13585
- if (extraBytes) {
13586
- block = s[i];
13587
- hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F];
13588
- if (extraBytes > 1) {
13589
- hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F];
13590
- }
13591
- if (extraBytes > 2) {
13592
- hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F];
13593
- }
13594
- }
13595
- return hex;
13596
- };
13597
-
13598
- Keccak.prototype.arrayBuffer = function () {
13599
- this.finalize();
13600
-
13601
- var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
13602
- extraBytes = this.extraBytes, i = 0, j = 0;
13603
- var bytes = this.outputBits >> 3;
13604
- var buffer;
13605
- if (extraBytes) {
13606
- buffer = new ArrayBuffer((outputBlocks + 1) << 2);
13607
- } else {
13608
- buffer = new ArrayBuffer(bytes);
13609
- }
13610
- var array = new Uint32Array(buffer);
13611
- while (j < outputBlocks) {
13612
- for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
13613
- array[j] = s[i];
13614
- }
13615
- if (j % blockCount === 0) {
13616
- s = cloneArray(s);
13617
- f(s);
13618
- }
13619
- }
13620
- if (extraBytes) {
13621
- array[j] = s[i];
13622
- buffer = buffer.slice(0, bytes);
13623
- }
13624
- return buffer;
13625
- };
13626
-
13627
- Keccak.prototype.buffer = Keccak.prototype.arrayBuffer;
13628
-
13629
- Keccak.prototype.digest = Keccak.prototype.array = function () {
13630
- this.finalize();
13631
-
13632
- var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks,
13633
- extraBytes = this.extraBytes, i = 0, j = 0;
13634
- var array = [], offset, block;
13635
- while (j < outputBlocks) {
13636
- for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) {
13637
- offset = j << 2;
13638
- block = s[i];
13639
- array[offset] = block & 0xFF;
13640
- array[offset + 1] = (block >> 8) & 0xFF;
13641
- array[offset + 2] = (block >> 16) & 0xFF;
13642
- array[offset + 3] = (block >> 24) & 0xFF;
13643
- }
13644
- if (j % blockCount === 0) {
13645
- s = cloneArray(s);
13646
- f(s);
13647
- }
13648
- }
13649
- if (extraBytes) {
13650
- offset = j << 2;
13651
- block = s[i];
13652
- array[offset] = block & 0xFF;
13653
- if (extraBytes > 1) {
13654
- array[offset + 1] = (block >> 8) & 0xFF;
13655
- }
13656
- if (extraBytes > 2) {
13657
- array[offset + 2] = (block >> 16) & 0xFF;
13658
- }
13659
- }
13660
- return array;
13661
- };
13662
-
13663
- function Kmac(bits, padding, outputBits) {
13664
- Keccak.call(this, bits, padding, outputBits);
13665
- }
13666
-
13667
- Kmac.prototype = new Keccak();
13668
-
13669
- Kmac.prototype.finalize = function () {
13670
- this.encode(this.outputBits, true);
13671
- return Keccak.prototype.finalize.call(this);
13672
- };
13673
-
13674
- var f = function (s) {
13675
- var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9,
13676
- b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17,
13677
- b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33,
13678
- b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49;
13679
- for (n = 0; n < 48; n += 2) {
13680
- c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
13681
- c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
13682
- c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
13683
- c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
13684
- c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
13685
- c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
13686
- c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
13687
- c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
13688
- c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
13689
- c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
13690
-
13691
- h = c8 ^ ((c2 << 1) | (c3 >>> 31));
13692
- l = c9 ^ ((c3 << 1) | (c2 >>> 31));
13693
- s[0] ^= h;
13694
- s[1] ^= l;
13695
- s[10] ^= h;
13696
- s[11] ^= l;
13697
- s[20] ^= h;
13698
- s[21] ^= l;
13699
- s[30] ^= h;
13700
- s[31] ^= l;
13701
- s[40] ^= h;
13702
- s[41] ^= l;
13703
- h = c0 ^ ((c4 << 1) | (c5 >>> 31));
13704
- l = c1 ^ ((c5 << 1) | (c4 >>> 31));
13705
- s[2] ^= h;
13706
- s[3] ^= l;
13707
- s[12] ^= h;
13708
- s[13] ^= l;
13709
- s[22] ^= h;
13710
- s[23] ^= l;
13711
- s[32] ^= h;
13712
- s[33] ^= l;
13713
- s[42] ^= h;
13714
- s[43] ^= l;
13715
- h = c2 ^ ((c6 << 1) | (c7 >>> 31));
13716
- l = c3 ^ ((c7 << 1) | (c6 >>> 31));
13717
- s[4] ^= h;
13718
- s[5] ^= l;
13719
- s[14] ^= h;
13720
- s[15] ^= l;
13721
- s[24] ^= h;
13722
- s[25] ^= l;
13723
- s[34] ^= h;
13724
- s[35] ^= l;
13725
- s[44] ^= h;
13726
- s[45] ^= l;
13727
- h = c4 ^ ((c8 << 1) | (c9 >>> 31));
13728
- l = c5 ^ ((c9 << 1) | (c8 >>> 31));
13729
- s[6] ^= h;
13730
- s[7] ^= l;
13731
- s[16] ^= h;
13732
- s[17] ^= l;
13733
- s[26] ^= h;
13734
- s[27] ^= l;
13735
- s[36] ^= h;
13736
- s[37] ^= l;
13737
- s[46] ^= h;
13738
- s[47] ^= l;
13739
- h = c6 ^ ((c0 << 1) | (c1 >>> 31));
13740
- l = c7 ^ ((c1 << 1) | (c0 >>> 31));
13741
- s[8] ^= h;
13742
- s[9] ^= l;
13743
- s[18] ^= h;
13744
- s[19] ^= l;
13745
- s[28] ^= h;
13746
- s[29] ^= l;
13747
- s[38] ^= h;
13748
- s[39] ^= l;
13749
- s[48] ^= h;
13750
- s[49] ^= l;
13751
-
13752
- b0 = s[0];
13753
- b1 = s[1];
13754
- b32 = (s[11] << 4) | (s[10] >>> 28);
13755
- b33 = (s[10] << 4) | (s[11] >>> 28);
13756
- b14 = (s[20] << 3) | (s[21] >>> 29);
13757
- b15 = (s[21] << 3) | (s[20] >>> 29);
13758
- b46 = (s[31] << 9) | (s[30] >>> 23);
13759
- b47 = (s[30] << 9) | (s[31] >>> 23);
13760
- b28 = (s[40] << 18) | (s[41] >>> 14);
13761
- b29 = (s[41] << 18) | (s[40] >>> 14);
13762
- b20 = (s[2] << 1) | (s[3] >>> 31);
13763
- b21 = (s[3] << 1) | (s[2] >>> 31);
13764
- b2 = (s[13] << 12) | (s[12] >>> 20);
13765
- b3 = (s[12] << 12) | (s[13] >>> 20);
13766
- b34 = (s[22] << 10) | (s[23] >>> 22);
13767
- b35 = (s[23] << 10) | (s[22] >>> 22);
13768
- b16 = (s[33] << 13) | (s[32] >>> 19);
13769
- b17 = (s[32] << 13) | (s[33] >>> 19);
13770
- b48 = (s[42] << 2) | (s[43] >>> 30);
13771
- b49 = (s[43] << 2) | (s[42] >>> 30);
13772
- b40 = (s[5] << 30) | (s[4] >>> 2);
13773
- b41 = (s[4] << 30) | (s[5] >>> 2);
13774
- b22 = (s[14] << 6) | (s[15] >>> 26);
13775
- b23 = (s[15] << 6) | (s[14] >>> 26);
13776
- b4 = (s[25] << 11) | (s[24] >>> 21);
13777
- b5 = (s[24] << 11) | (s[25] >>> 21);
13778
- b36 = (s[34] << 15) | (s[35] >>> 17);
13779
- b37 = (s[35] << 15) | (s[34] >>> 17);
13780
- b18 = (s[45] << 29) | (s[44] >>> 3);
13781
- b19 = (s[44] << 29) | (s[45] >>> 3);
13782
- b10 = (s[6] << 28) | (s[7] >>> 4);
13783
- b11 = (s[7] << 28) | (s[6] >>> 4);
13784
- b42 = (s[17] << 23) | (s[16] >>> 9);
13785
- b43 = (s[16] << 23) | (s[17] >>> 9);
13786
- b24 = (s[26] << 25) | (s[27] >>> 7);
13787
- b25 = (s[27] << 25) | (s[26] >>> 7);
13788
- b6 = (s[36] << 21) | (s[37] >>> 11);
13789
- b7 = (s[37] << 21) | (s[36] >>> 11);
13790
- b38 = (s[47] << 24) | (s[46] >>> 8);
13791
- b39 = (s[46] << 24) | (s[47] >>> 8);
13792
- b30 = (s[8] << 27) | (s[9] >>> 5);
13793
- b31 = (s[9] << 27) | (s[8] >>> 5);
13794
- b12 = (s[18] << 20) | (s[19] >>> 12);
13795
- b13 = (s[19] << 20) | (s[18] >>> 12);
13796
- b44 = (s[29] << 7) | (s[28] >>> 25);
13797
- b45 = (s[28] << 7) | (s[29] >>> 25);
13798
- b26 = (s[38] << 8) | (s[39] >>> 24);
13799
- b27 = (s[39] << 8) | (s[38] >>> 24);
13800
- b8 = (s[48] << 14) | (s[49] >>> 18);
13801
- b9 = (s[49] << 14) | (s[48] >>> 18);
13802
-
13803
- s[0] = b0 ^ (~b2 & b4);
13804
- s[1] = b1 ^ (~b3 & b5);
13805
- s[10] = b10 ^ (~b12 & b14);
13806
- s[11] = b11 ^ (~b13 & b15);
13807
- s[20] = b20 ^ (~b22 & b24);
13808
- s[21] = b21 ^ (~b23 & b25);
13809
- s[30] = b30 ^ (~b32 & b34);
13810
- s[31] = b31 ^ (~b33 & b35);
13811
- s[40] = b40 ^ (~b42 & b44);
13812
- s[41] = b41 ^ (~b43 & b45);
13813
- s[2] = b2 ^ (~b4 & b6);
13814
- s[3] = b3 ^ (~b5 & b7);
13815
- s[12] = b12 ^ (~b14 & b16);
13816
- s[13] = b13 ^ (~b15 & b17);
13817
- s[22] = b22 ^ (~b24 & b26);
13818
- s[23] = b23 ^ (~b25 & b27);
13819
- s[32] = b32 ^ (~b34 & b36);
13820
- s[33] = b33 ^ (~b35 & b37);
13821
- s[42] = b42 ^ (~b44 & b46);
13822
- s[43] = b43 ^ (~b45 & b47);
13823
- s[4] = b4 ^ (~b6 & b8);
13824
- s[5] = b5 ^ (~b7 & b9);
13825
- s[14] = b14 ^ (~b16 & b18);
13826
- s[15] = b15 ^ (~b17 & b19);
13827
- s[24] = b24 ^ (~b26 & b28);
13828
- s[25] = b25 ^ (~b27 & b29);
13829
- s[34] = b34 ^ (~b36 & b38);
13830
- s[35] = b35 ^ (~b37 & b39);
13831
- s[44] = b44 ^ (~b46 & b48);
13832
- s[45] = b45 ^ (~b47 & b49);
13833
- s[6] = b6 ^ (~b8 & b0);
13834
- s[7] = b7 ^ (~b9 & b1);
13835
- s[16] = b16 ^ (~b18 & b10);
13836
- s[17] = b17 ^ (~b19 & b11);
13837
- s[26] = b26 ^ (~b28 & b20);
13838
- s[27] = b27 ^ (~b29 & b21);
13839
- s[36] = b36 ^ (~b38 & b30);
13840
- s[37] = b37 ^ (~b39 & b31);
13841
- s[46] = b46 ^ (~b48 & b40);
13842
- s[47] = b47 ^ (~b49 & b41);
13843
- s[8] = b8 ^ (~b0 & b2);
13844
- s[9] = b9 ^ (~b1 & b3);
13845
- s[18] = b18 ^ (~b10 & b12);
13846
- s[19] = b19 ^ (~b11 & b13);
13847
- s[28] = b28 ^ (~b20 & b22);
13848
- s[29] = b29 ^ (~b21 & b23);
13849
- s[38] = b38 ^ (~b30 & b32);
13850
- s[39] = b39 ^ (~b31 & b33);
13851
- s[48] = b48 ^ (~b40 & b42);
13852
- s[49] = b49 ^ (~b41 & b43);
13853
-
13854
- s[0] ^= RC[n];
13855
- s[1] ^= RC[n + 1];
13856
- }
13857
- };
13858
-
13859
- if (COMMON_JS) {
13860
- module.exports = methods;
13861
- } else {
13862
- for (i = 0; i < methodNames.length; ++i) {
13863
- root[methodNames[i]] = methods[methodNames[i]];
13864
- }
13865
- }
13866
- })();
13867
- } (sha3));
13868
- return sha3.exports;
13869
- }
13870
-
13871
- var sha3Exports = requireSha3();
13872
-
13873
- async function toEnsName(address) {
13874
- const reverseName = address.toLowerCase().replace(/^0x/, "") + ".addr.reverse";
13875
- const node = namehash(reverseName);
13876
- const endpoint = "https://cloudflare-eth.com";
13877
-
13878
- // Step 1: Get resolver address from ENS registry
13879
- const resolverRes = await fetch(endpoint, {
13880
- method: "POST",
13881
- headers: { "Content-Type": "application/json" },
13882
- body: JSON.stringify({
13883
- jsonrpc: "2.0",
13884
- id: 1,
13885
- method: "eth_call",
13886
- params: [
13887
- {
13888
- to: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
13889
- data: "0x0178b8bf" + node.slice(2).padStart(64, "0")
13890
- },
13891
- "latest"
13892
- ]
13893
- })
13894
- });
13895
-
13896
- const { result: resolverHex } = await resolverRes.json();
13897
- const resolverAddress = "0x" + resolverHex.slice(-40);
13898
- if (!/^0x[0-9a-f]{40}$/i.test(resolverAddress)) return null;
13899
-
13900
- // Step 2: Call resolver.name(node)
13901
- const nameRes = await fetch(endpoint, {
13902
- method: "POST",
13903
- headers: { "Content-Type": "application/json" },
13904
- body: JSON.stringify({
13905
- jsonrpc: "2.0",
13906
- id: 2,
13907
- method: "eth_call",
13908
- params: [
13909
- {
13910
- to: resolverAddress,
13911
- data: "0x691f3431" + node.slice(2)
13912
- },
13913
- "latest"
13914
- ]
13915
- })
13916
- });
13917
-
13918
- const { result: nameHex } = await nameRes.json();
13919
- if (!nameHex || nameHex === "0x") return null;
13920
-
13921
- // Decode hex ENS name
13922
- const hex = nameHex.slice(2);
13923
- let name = "";
13924
- for (let i = 0; i < hex.length; i += 2) {
13925
- const code = parseInt(hex.slice(i, i + 2), 16);
13926
- if (code === 0) break;
13927
- name += String.fromCharCode(code);
13928
- }
13929
-
13930
- return name || null;
13931
- }
13932
-
13933
- // ENS Namehash using js-sha3
13934
- function namehash(name) {
13935
- let node = "0000000000000000000000000000000000000000000000000000000000000000";
13936
- if (name) {
13937
- const labels = name.toLowerCase().split(".");
13938
- for (let i = labels.length - 1; i >= 0; i--) {
13939
- const labelSha = sha3Exports.sha3_256.array(labels[i]);
13940
- const combined = node + bytesToHex(labelSha);
13941
- node = sha3Exports.sha3_256.array(hexToBytes(combined));
13942
- node = bytesToHex(node);
13943
- }
13944
- }
13945
- return "0x" + node;
13946
- }
13947
-
13948
- // Helpers
13949
- function hexToBytes(hex) {
13950
- hex = hex.replace(/^0x/, "");
13951
- const bytes = new Uint8Array(hex.length / 2);
13952
- for (let i = 0; i < bytes.length; i++) {
13953
- bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
13954
- }
13955
- return bytes;
13956
- }
13957
-
13958
- function bytesToHex(bytes) {
13959
- return Array.from(bytes).map(b => b.toString(16).padStart(2, "0")).join("");
13960
- }
13961
-
13962
13244
  async function FIREFLY(platform, contentType, identifier, start = 0, end = 10) {
13963
13245
  const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Firefly);
13964
13246
  if (!API_KEY) return `${SERVICE_API_KEY.Firefly}${ERROR_MESSAGES_FLAG.MISSING_KEY}`;
@@ -14045,7 +13327,13 @@ async function BLOCKSCOUT(address, type, chain, startTimestamp, endTimestamp, pa
14045
13327
  endTimestamp = toTimestamp(endTimestamp);
14046
13328
  }
14047
13329
 
13330
+ if(!isAddress(address)){
13331
+ address = await fromEnsNameToAddress(address);
13332
+ }
14048
13333
 
13334
+ if(!address){
13335
+ return `${address}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`
13336
+ }
14049
13337
 
14050
13338
  const hostname = BLOCKSCOUT_CHAINS_MAP[chain];
14051
13339
 
@@ -14257,12 +13545,15 @@ async function COINGECKO(category, param1, param2, page = 1, perPage = 2) {
14257
13545
  };
14258
13546
 
14259
13547
  let url = '';
13548
+ const lowerCategory = (category || '').toLowerCase();
14260
13549
 
14261
- switch ((category || '').toLowerCase()) {
13550
+ switch (lowerCategory) {
14262
13551
  case 'price': {
14263
13552
  const token = param1;
14264
13553
  const vsCurrencies = param2;
14265
- if (!token || !vsCurrencies) return `${SERVICE_API_KEY.Coingecko}${ERROR_MESSAGES_FLAG.INVALID_PARAMS}`;
13554
+ if (!token || !vsCurrencies) {
13555
+ return `${SERVICE_API_KEY.Coingecko}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`;
13556
+ }
14266
13557
  url = `https://api.coingecko.com/api/v3/simple/price?vs_currencies=${vsCurrencies}&ids=${token}`;
14267
13558
  break;
14268
13559
  }
@@ -14276,29 +13567,28 @@ async function COINGECKO(category, param1, param2, page = 1, perPage = 2) {
14276
13567
  hyperliquid: 'hyperliquid',
14277
13568
  bitcoin: 'bitcoin-ecosystem',
14278
13569
  pump: 'pump-ecosystem',
13570
+ aiagents: 'ai-agents',
13571
+ meme: 'meme-token',
14279
13572
  };
14280
13573
 
14281
13574
  const key = param1?.toLowerCase();
14282
- const categoryVal = key ? ecosystemMap[key] : '';
14283
-
14284
- if (param1 && !categoryVal) {
14285
- return `${SERVICE_API_KEY.Coingecko}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`;
14286
- }
14287
-
13575
+ const categoryVal = ecosystemMap[key] || '';
14288
13576
  const trend = param2 ? `&price_change_percentage=${param2}` : '';
13577
+
14289
13578
  url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&include_tokens=top&page=${page}&per_page=${perPage}`;
13579
+ if (key && !categoryVal) return `${SERVICE_API_KEY.Coingecko}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`;
14290
13580
  if (categoryVal) url += `&category=${categoryVal}`;
14291
13581
  if (trend) url += trend;
14292
13582
  break;
14293
13583
  }
14294
13584
 
14295
13585
  case 'stablecoins': {
14296
- const category = param1 === 'all' || !param1
13586
+ const category = !param1 || param1.toLowerCase() === 'all'
14297
13587
  ? 'stablecoins'
14298
- : param1?.toLowerCase();
14299
- const trend = param2 ? `&price_change_percentage=${param2}` : '';
13588
+ : param1.toLowerCase();
14300
13589
 
14301
- url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&category=${category}&page=${page}&per_page=${perPage}${trend}`;
13590
+ const trend = param2 ? `&price_change_percentage=${param2}` : '';
13591
+ url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&category=${category}&order=market_cap_desc&page=${page}&per_page=${perPage}${trend}`;
14302
13592
  break;
14303
13593
  }
14304
13594
 
@@ -14330,7 +13620,7 @@ async function COINGECKO(category, param1, param2, page = 1, perPage = 2) {
14330
13620
  }
14331
13621
  }
14332
13622
 
14333
- if (category.toLowerCase() === 'price') {
13623
+ if (lowerCategory === 'price') {
14334
13624
  const output = {};
14335
13625
  for (const [token, prices] of Object.entries(json)) {
14336
13626
  for (const [currency, value] of Object.entries(prices)) {
@@ -14380,11 +13670,11 @@ async function EOA(
14380
13670
  const ADDRESS_MAP = {};
14381
13671
 
14382
13672
  for (const input of INPUTS) {
14383
- if (/^0x[a-fA-F0-9]{40}$/.test(input)) {
13673
+ if (isAddress(input)) {
14384
13674
  ADDRESS_MAP[input.toLowerCase()] = null; // it's a direct address
14385
13675
  } else {
14386
13676
  try {
14387
- const resolved = await toEnsName(input); // ENS -> address
13677
+ const resolved = await fromEnsNameToAddress(input); // ENS -> address
14388
13678
  if (resolved) ADDRESS_MAP[resolved.toLowerCase()] = input;
14389
13679
  } catch {
14390
13680
  return `${input}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`;
@@ -14476,12 +13766,6 @@ async function EOA(
14476
13766
  }
14477
13767
  }
14478
13768
 
14479
-
14480
-
14481
-
14482
-
14483
-
14484
-
14485
13769
  async function FLVURL(token, vs_currencies) {
14486
13770
  return new Promise((resolve) => {
14487
13771
  setTimeout(() => {
@@ -14502,6 +13786,14 @@ async function SAFE(address, utility, chain, limit, offset) {
14502
13786
  if (!apiKey) return `${SERVICE_API_KEY.Safe}_MISSING`;
14503
13787
  if (!chainIdentifier) return 'CHAIN IS NOT SUPPORTED';
14504
13788
 
13789
+ if(!isAddress(address)){
13790
+ address = await fromEnsNameToAddress(address);
13791
+ }
13792
+
13793
+ if(!address){
13794
+ return `${address}${ERROR_MESSAGES_FLAG.INVALID_PARAM}`
13795
+ }
13796
+
14505
13797
  const url = `https://api.safe.global/tx-service/${chainIdentifier}/api/v2/safes/${address}/multisig-transactions?limit=${limit}&offset=${offset}`;
14506
13798
  try {
14507
13799
  const response = await fetch(url,