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