@fileverse-dev/formulajs 4.4.11-mod-22-patch-4 → 4.4.11-mod-23
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/browser/formula.js +332 -91
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +118 -54
- package/lib/esm/crypto-constants.mjs +462 -19
- package/lib/esm/index.mjs +118 -54
- package/package.json +1 -1
- package/types/cjs/index.d.cts +3 -3
- package/types/esm/index.d.mts +3 -3
package/lib/cjs/index.cjs
CHANGED
|
@@ -13101,7 +13101,10 @@ const ERROR_MESSAGES_FLAG = {
|
|
|
13101
13101
|
INVALID_API_KEY: '_INVALID_KEY',
|
|
13102
13102
|
RATE_LIMIT: '_RATE_LIMIT_REACHED',
|
|
13103
13103
|
DEFAULT: 'FETCH_ERROR',
|
|
13104
|
-
MISSING_KEY: '_MISSING'
|
|
13104
|
+
MISSING_KEY: '_MISSING',
|
|
13105
|
+
INVALID_CHAIN: '_INVALID_CHAIN',
|
|
13106
|
+
INVALID_TYPE: '_INVALID_TYPE',
|
|
13107
|
+
INVALID_ADDRESS: '_INVALID_ADDRESS'
|
|
13105
13108
|
};
|
|
13106
13109
|
|
|
13107
13110
|
const SERVICE_API_KEY = {
|
|
@@ -13120,7 +13123,7 @@ if(!timestamp || !chain || !apiKey) return
|
|
|
13120
13123
|
|
|
13121
13124
|
};
|
|
13122
13125
|
|
|
13123
|
-
async function BLOCKSCOUT(address, type, chain,
|
|
13126
|
+
async function BLOCKSCOUT(address, type, chain, startTimestamp, endTimestamp, page, offset) {
|
|
13124
13127
|
if (!chain) {
|
|
13125
13128
|
chain = 'ethereum';
|
|
13126
13129
|
}
|
|
@@ -13189,38 +13192,73 @@ async function BLOCKSCOUT(address, type, chain, page, offset, startTimestamp, en
|
|
|
13189
13192
|
}
|
|
13190
13193
|
}
|
|
13191
13194
|
|
|
13192
|
-
async function ETHERSCAN(
|
|
13195
|
+
async function ETHERSCAN(...args) {
|
|
13196
|
+
const [type, chain, address, startDate, endDate] = args;
|
|
13197
|
+
|
|
13193
13198
|
const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
|
|
13194
|
-
if(!API_KEY){
|
|
13195
|
-
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.MISSING_KEY}
|
|
13199
|
+
if (!API_KEY) {
|
|
13200
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.MISSING_KEY}`;
|
|
13201
|
+
}
|
|
13202
|
+
// TO REMOVE - TEMORARY ADDED TO TEST RATE LIMIT FLOW
|
|
13203
|
+
if (API_KEY === 'xxxx') {
|
|
13204
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.RATE_LIMIT}`;
|
|
13205
|
+
}
|
|
13206
|
+
|
|
13207
|
+
const chainId = CHAIN_ID_MAP[chain?.toLowerCase()];
|
|
13208
|
+
if (!chainId) {
|
|
13209
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.INVALID_CHAIN}`;
|
|
13196
13210
|
}
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13211
|
+
|
|
13212
|
+
let action;
|
|
13213
|
+
switch (type) {
|
|
13214
|
+
case 'all-txns':
|
|
13215
|
+
action = 'txlist';
|
|
13216
|
+
break;
|
|
13217
|
+
case 'token-txns':
|
|
13218
|
+
action = 'tokentx';
|
|
13219
|
+
break;
|
|
13220
|
+
case 'nft-txns':
|
|
13221
|
+
action = 'tokennfttx';
|
|
13222
|
+
break;
|
|
13223
|
+
case 'gas':
|
|
13224
|
+
action = 'gastracker';
|
|
13225
|
+
break;
|
|
13226
|
+
default:
|
|
13227
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.INVALID_TYPE}`;
|
|
13228
|
+
}
|
|
13229
|
+
|
|
13230
|
+
let url = `https://api.etherscan.io/v2/api?chainid=${chainId}&module=account&action=${action}&apikey=${API_KEY}`;
|
|
13231
|
+
|
|
13232
|
+
if (['all-txns', 'token-txns', 'nft-txns'].includes(type)) {
|
|
13233
|
+
if (!address) return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.INVALID_ADDRESS}`;
|
|
13234
|
+
url += `&address=${address}&startblock=0&endblock=99999999&sort=asc`;
|
|
13235
|
+
if (startDate && endDate && !isNaN(startDate) && !isNaN(endDate)) {
|
|
13236
|
+
const startBlock = await fromTimeStampToBlock(startDate, chain, API_KEY);
|
|
13237
|
+
const endBlock = await fromTimeStampToBlock(endDate, chain, API_KEY);
|
|
13238
|
+
url += `&startblock=${startBlock}&endblock=${endBlock}`;
|
|
13239
|
+
}
|
|
13200
13240
|
}
|
|
13201
|
-
const url = `https://api.etherscan.io/v2/api?chainid=1&module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=${page || 1}&offset=${offset || 10}&sort=asc&apikey=${API_KEY}`;
|
|
13202
13241
|
|
|
13203
13242
|
try {
|
|
13204
13243
|
const response = await fetch(url);
|
|
13205
|
-
if (!response.ok) {
|
|
13206
|
-
throw new Error(`HTTP error! Status: ${response.status}`)
|
|
13207
|
-
}
|
|
13244
|
+
if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
|
|
13208
13245
|
const json = await response.json();
|
|
13209
|
-
|
|
13210
|
-
|
|
13246
|
+
|
|
13247
|
+
if (typeof json.result === 'string' && json.result.includes('Invalid API Key')) {
|
|
13248
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.INVALID_API_KEY}`;
|
|
13211
13249
|
}
|
|
13212
|
-
|
|
13213
|
-
|
|
13250
|
+
|
|
13251
|
+
if (typeof json.result === 'string' && json.result.includes('Max rate limit reached')) {
|
|
13252
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.RATE_LIMIT}`;
|
|
13214
13253
|
}
|
|
13215
|
-
|
|
13216
|
-
[{blockNumber: '0x1d3d1', timeStamp: '0x5f7e4f', hash: '0x3c3c3c3c', nonce: '0x1',}]
|
|
13217
|
-
*/
|
|
13254
|
+
|
|
13218
13255
|
return json.result;
|
|
13219
13256
|
} catch (error) {
|
|
13220
|
-
return ERROR_MESSAGES_FLAG.DEFAULT
|
|
13257
|
+
return ERROR_MESSAGES_FLAG.DEFAULT;
|
|
13221
13258
|
}
|
|
13222
13259
|
}
|
|
13223
13260
|
|
|
13261
|
+
|
|
13224
13262
|
async function COINGECKO(token, vs_currencies) {
|
|
13225
13263
|
const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Coingecko);
|
|
13226
13264
|
const url = `https://api.coingecko.com/api/v3/simple/price?vs_currencies=${vs_currencies}&ids=${token}`;
|
|
@@ -13257,50 +13295,76 @@ async function COINGECKO(token, vs_currencies) {
|
|
|
13257
13295
|
*/
|
|
13258
13296
|
return [output];
|
|
13259
13297
|
} catch (error) {
|
|
13298
|
+
console.log(error);
|
|
13260
13299
|
return ERROR_MESSAGES_FLAG.DEFAULT
|
|
13261
13300
|
}
|
|
13262
13301
|
}
|
|
13263
13302
|
|
|
13264
|
-
async function EOA(
|
|
13265
|
-
const API_KEYS = {
|
|
13266
|
-
ethereum: window.localStorage.getItem(SERVICE_API_KEY.Etherscan),
|
|
13267
|
-
gnosis: window.localStorage.getItem(SERVICE_API_KEY.Gnosisscan),
|
|
13268
|
-
base: window.localStorage.getItem(SERVICE_API_KEY.Basescan),
|
|
13269
|
-
};
|
|
13270
|
-
const apiKey = API_KEYS[chain];
|
|
13271
|
-
const chainId = CHAIN_ID_MAP[chain];
|
|
13272
|
-
if (!apiKey || !chainId) return `${chain.toUpperCase()}_MISSING`;
|
|
13273
|
-
|
|
13274
|
-
let action = '';
|
|
13275
|
-
if (categories === 'txns') action = 'account.txlist';
|
|
13276
|
-
else { action = 'account.balance'; } let timeQuery = '';
|
|
13277
|
-
if (!isNaN(startTime) && !isNaN(endTime)) {
|
|
13278
|
-
const startBlock = await fromTimeStampToBlock(startTime, chain, apiKey);
|
|
13279
|
-
const endBlock = await fromTimeStampToBlock(endTime, chain, apiKey);
|
|
13280
|
-
timeQuery = `&startblock=${startBlock}&endblock=${endBlock}`;
|
|
13281
|
-
} else if (categories === 'balance') {
|
|
13282
|
-
timeQuery = `&tag=latest`;
|
|
13283
|
-
} else {
|
|
13284
|
-
throw new Error('Start and End Time is required for querying transaction list ')
|
|
13285
|
-
}
|
|
13286
|
-
const url = `https://api.etherscan.io/v2/api?module=${action.split('.')[0]}&action=${action.split('.')[1]}&address=${address}&sort=asc&chainid=${chainId}&apikey=${apiKey}${timeQuery}`;
|
|
13303
|
+
async function EOA(addresses, category, chains, startTime, endTime) {
|
|
13287
13304
|
try {
|
|
13288
|
-
const
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
if(
|
|
13295
|
-
|
|
13305
|
+
const ADDRESSES = addresses.split(',').map(a => a.trim());
|
|
13306
|
+
const CHAINS = typeof chains === 'string' ? chains.split(',').map(c => c.trim()) : chains;
|
|
13307
|
+
|
|
13308
|
+
const flatResults = [];
|
|
13309
|
+
const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
|
|
13310
|
+
|
|
13311
|
+
if (!API_KEY) return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.MISSING_KEY}`;
|
|
13312
|
+
|
|
13313
|
+
for (const chain of CHAINS) {
|
|
13314
|
+
const chainId = CHAIN_ID_MAP[chain];
|
|
13315
|
+
if (!chainId) throw new Error('Unsupported chain');
|
|
13316
|
+
|
|
13317
|
+
for (const address of ADDRESSES) {
|
|
13318
|
+
let action = category === 'txns' ? 'account.txlist' : 'account.balance';
|
|
13319
|
+
let timeQuery = '';
|
|
13320
|
+
|
|
13321
|
+
if (category === 'txns') {
|
|
13322
|
+
const startBlock = await fromTimeStampToBlock(startTime, chain, API_KEY);
|
|
13323
|
+
const endBlock = await fromTimeStampToBlock(endTime, chain, API_KEY);
|
|
13324
|
+
timeQuery = `&startblock=${startBlock}&endblock=${endBlock}`;
|
|
13325
|
+
} else {
|
|
13326
|
+
timeQuery = `&tag=latest`;
|
|
13327
|
+
}
|
|
13328
|
+
|
|
13329
|
+
const url = `https://api.etherscan.io/v2/api?module=${action.split('.')[0]}&action=${action.split('.')[1]}&address=${address}&sort=asc&chainid=${chainId}&apikey=${API_KEY}${timeQuery}`;
|
|
13330
|
+
|
|
13331
|
+
try {
|
|
13332
|
+
const response = await fetch(url);
|
|
13333
|
+
if (!response.ok) {
|
|
13334
|
+
return `HTTP_${response.status}`;
|
|
13335
|
+
}
|
|
13336
|
+
|
|
13337
|
+
const json = await response.json();
|
|
13338
|
+
|
|
13339
|
+
if (json.result?.includes?.('Invalid API Key')) {
|
|
13340
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.INVALID_API_KEY}`;
|
|
13341
|
+
}
|
|
13342
|
+
|
|
13343
|
+
if (json.result?.includes?.('Max rate limit reached')) {
|
|
13344
|
+
return `${SERVICE_API_KEY.Etherscan}${ERROR_MESSAGES_FLAG.RATE_LIMIT}`;
|
|
13345
|
+
}
|
|
13346
|
+
|
|
13347
|
+
const entries = Array.isArray(json.result) ? json.result : [json.result];
|
|
13348
|
+
for (const entry of entries) {
|
|
13349
|
+
flatResults.push({ chain, address, ...entry });
|
|
13350
|
+
}
|
|
13351
|
+
|
|
13352
|
+
} catch (e) {
|
|
13353
|
+
return ERROR_MESSAGES_FLAG.DEFAULT;
|
|
13354
|
+
}
|
|
13355
|
+
}
|
|
13296
13356
|
}
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13357
|
+
|
|
13358
|
+
return flatResults;
|
|
13359
|
+
} catch (error) {
|
|
13360
|
+
console.log(error);
|
|
13300
13361
|
return ERROR_MESSAGES_FLAG.DEFAULT;
|
|
13301
13362
|
}
|
|
13302
13363
|
}
|
|
13303
13364
|
|
|
13365
|
+
|
|
13366
|
+
|
|
13367
|
+
|
|
13304
13368
|
async function FLVURL(token, vs_currencies) {
|
|
13305
13369
|
return new Promise((resolve) => {
|
|
13306
13370
|
setTimeout(() => {
|