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