@fileverse-dev/formulajs 4.4.11-mod-68-patch-9 → 4.4.11-mod-73
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 +105 -119
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +14 -28
- package/lib/esm/index.mjs +14 -28
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -13144,42 +13144,44 @@ const SERVICES_API_KEY = {
|
|
|
13144
13144
|
Defillama: 'Defillama'
|
|
13145
13145
|
};
|
|
13146
13146
|
|
|
13147
|
+
const stagingFileverseProxyUrl = "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy";
|
|
13148
|
+
|
|
13147
13149
|
// Proxy map configuration
|
|
13148
13150
|
const PROXY_MAP = {
|
|
13149
13151
|
Etherscan: {
|
|
13150
|
-
url:
|
|
13152
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13151
13153
|
removeParams: ['apikey']
|
|
13152
13154
|
},
|
|
13153
13155
|
Basescan: {
|
|
13154
|
-
url:
|
|
13156
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13155
13157
|
removeParams: ['apikey']
|
|
13156
13158
|
},
|
|
13157
13159
|
Gnosisscan: {
|
|
13158
|
-
url:
|
|
13160
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13159
13161
|
removeParams: ['apikey']
|
|
13160
13162
|
},
|
|
13161
13163
|
Coingecko: {
|
|
13162
|
-
url:
|
|
13164
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13163
13165
|
removeParams: ['apikey']
|
|
13164
13166
|
},
|
|
13165
13167
|
Firefly: {
|
|
13166
|
-
url:
|
|
13168
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13167
13169
|
removeParams: ['apikey']
|
|
13168
13170
|
},
|
|
13169
13171
|
Neynar: {
|
|
13170
|
-
url:
|
|
13172
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13171
13173
|
removeParams: ['api_key']
|
|
13172
13174
|
},
|
|
13173
13175
|
Safe: {
|
|
13174
|
-
url:
|
|
13176
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13175
13177
|
removeParams: ['api_key']
|
|
13176
13178
|
},
|
|
13177
13179
|
Defillama: {
|
|
13178
|
-
url:
|
|
13180
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13179
13181
|
removeParams: ['api_key']
|
|
13180
13182
|
},
|
|
13181
13183
|
GnosisPay: {
|
|
13182
|
-
url:
|
|
13184
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13183
13185
|
removeParams: ['api_key']
|
|
13184
13186
|
},
|
|
13185
13187
|
// Add more services as needed. It can be direct url instead of ENV variable
|
|
@@ -13211,12 +13213,11 @@ function removeUrlParams(url, paramsToRemove) {
|
|
|
13211
13213
|
/**
|
|
13212
13214
|
* Handles URL routing through proxy or direct API calls
|
|
13213
13215
|
* @param {string} url - The original API URL
|
|
13214
|
-
* @param {string} serviceName - The name of the service (e.g., 'EOA')
|
|
13215
|
-
* @param {
|
|
13216
|
+
* @param {string} serviceName - [OPTIONAL] The name of the service (e.g., 'EOA')
|
|
13217
|
+
* @param {object} headers - [OPTIONAL] The name of the service (e.g., 'EOA')
|
|
13216
13218
|
* @returns {Object} Object containing URL and HEADERS for the fetch request
|
|
13217
13219
|
*/
|
|
13218
13220
|
function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
13219
|
-
console.log('getUrlAndHeaders new modified function from formulajs', url, serviceName);
|
|
13220
13221
|
// Check if proxy is enabled in localStorage
|
|
13221
13222
|
const apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
|
|
13222
13223
|
const isProxyModeEnabledValue = apiKeyLS === 'DEFAULT_PROXY_MODE';
|
|
@@ -13240,30 +13241,23 @@ function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
|
13240
13241
|
};
|
|
13241
13242
|
}
|
|
13242
13243
|
|
|
13243
|
-
|
|
13244
13244
|
return {
|
|
13245
13245
|
URL: url,
|
|
13246
13246
|
HEADERS: {
|
|
13247
13247
|
...headers,
|
|
13248
|
-
method: 'GET',
|
|
13249
13248
|
}
|
|
13250
13249
|
};
|
|
13251
13250
|
}
|
|
13252
13251
|
|
|
13253
13252
|
const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
|
|
13254
|
-
console.log('fromTimeStampToBlock', timestamp, chain, apiKey);
|
|
13255
13253
|
if (!timestamp || !chain || !apiKey) return
|
|
13256
13254
|
const chainId = CHAIN_ID_MAP[chain];
|
|
13257
|
-
console.log('chainId', chainId);
|
|
13258
13255
|
const url = `https://api.etherscan.io/v2/api?module=block&action=getblocknobytime×tamp=${timestamp}&closest=before&apikey=${apiKey}&chainId=${chainId}`;
|
|
13259
|
-
console.log('url', url, getUrlAndHeaders);
|
|
13260
13256
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
|
|
13261
|
-
console.log('finalUrl', finalUrl, HEADERS);
|
|
13262
13257
|
const res = await fetch(finalUrl, {
|
|
13263
13258
|
method: 'GET',
|
|
13264
13259
|
headers: HEADERS,
|
|
13265
13260
|
});
|
|
13266
|
-
console.log('res', res, finalUrl, HEADERS);
|
|
13267
13261
|
const json = await res.json();
|
|
13268
13262
|
return parseInt(json.result);
|
|
13269
13263
|
|
|
@@ -13425,7 +13419,7 @@ async function handleScanRequest({
|
|
|
13425
13419
|
}
|
|
13426
13420
|
url += `&page=${page}&offset=${offset}`;
|
|
13427
13421
|
}
|
|
13428
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({url, serviceName:
|
|
13422
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({url, serviceName: apiInfo.apiKeyName, headers: {}});
|
|
13429
13423
|
const res = await fetch(finalUrl, {
|
|
13430
13424
|
method: 'GET',
|
|
13431
13425
|
headers: HEADERS,
|
|
@@ -18257,7 +18251,6 @@ async function EOA() {
|
|
|
18257
18251
|
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
|
|
18258
18252
|
|
|
18259
18253
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18260
|
-
console.log('apiKey', apiKey);
|
|
18261
18254
|
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
|
|
18262
18255
|
|
|
18263
18256
|
const INPUTS = addresses.split(',').map(s => s.trim()).filter(Boolean);
|
|
@@ -18280,7 +18273,6 @@ async function EOA() {
|
|
|
18280
18273
|
|
|
18281
18274
|
async function fetchJSON(url) {
|
|
18282
18275
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
|
|
18283
|
-
console.log('finalUrl', finalUrl, HEADERS);
|
|
18284
18276
|
const res = await fetch(finalUrl, {
|
|
18285
18277
|
method: 'GET',
|
|
18286
18278
|
headers: HEADERS,
|
|
@@ -18297,14 +18289,10 @@ async function EOA() {
|
|
|
18297
18289
|
|
|
18298
18290
|
|
|
18299
18291
|
for (const chain of CHAINS) {
|
|
18300
|
-
console.log('chain', chain);
|
|
18301
18292
|
const chainId = CHAIN_ID_MAP[chain];
|
|
18302
18293
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
18303
|
-
console.log('chain', chain);
|
|
18304
|
-
|
|
18305
18294
|
|
|
18306
18295
|
if (category === 'balance') {
|
|
18307
|
-
console.log('balance');
|
|
18308
18296
|
// chunk 20
|
|
18309
18297
|
for (let i = 0; i < ADDRS.length; i += 20) {
|
|
18310
18298
|
const slice = ADDRS.slice(i, i + 20).join(',');
|
|
@@ -18318,10 +18306,8 @@ async function EOA() {
|
|
|
18318
18306
|
}
|
|
18319
18307
|
} else {
|
|
18320
18308
|
// txns
|
|
18321
|
-
console.log('startTime', startTime, 'endTime', endTime, chain, apiKey);
|
|
18322
18309
|
const sb = await fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startTime), chain, apiKey);
|
|
18323
18310
|
const eb = await fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endTime), chain, apiKey);
|
|
18324
|
-
console.log('sb', sb, 'eb', eb);
|
|
18325
18311
|
if (!sb) throw new ValidationError(`Invalid startTime: ${startTime}`)
|
|
18326
18312
|
if (!eb) throw new ValidationError(`Invalid endTime: ${endTime}`)
|
|
18327
18313
|
for (const addr of ADDRS) {
|
package/lib/esm/index.mjs
CHANGED
|
@@ -13142,42 +13142,44 @@ const SERVICES_API_KEY = {
|
|
|
13142
13142
|
Defillama: 'Defillama'
|
|
13143
13143
|
};
|
|
13144
13144
|
|
|
13145
|
+
const stagingFileverseProxyUrl = "https://staging-api-proxy-ca4268d7d581.herokuapp.com/proxy";
|
|
13146
|
+
|
|
13145
13147
|
// Proxy map configuration
|
|
13146
13148
|
const PROXY_MAP = {
|
|
13147
13149
|
Etherscan: {
|
|
13148
|
-
url:
|
|
13150
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13149
13151
|
removeParams: ['apikey']
|
|
13150
13152
|
},
|
|
13151
13153
|
Basescan: {
|
|
13152
|
-
url:
|
|
13154
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13153
13155
|
removeParams: ['apikey']
|
|
13154
13156
|
},
|
|
13155
13157
|
Gnosisscan: {
|
|
13156
|
-
url:
|
|
13158
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13157
13159
|
removeParams: ['apikey']
|
|
13158
13160
|
},
|
|
13159
13161
|
Coingecko: {
|
|
13160
|
-
url:
|
|
13162
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13161
13163
|
removeParams: ['apikey']
|
|
13162
13164
|
},
|
|
13163
13165
|
Firefly: {
|
|
13164
|
-
url:
|
|
13166
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13165
13167
|
removeParams: ['apikey']
|
|
13166
13168
|
},
|
|
13167
13169
|
Neynar: {
|
|
13168
|
-
url:
|
|
13170
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13169
13171
|
removeParams: ['api_key']
|
|
13170
13172
|
},
|
|
13171
13173
|
Safe: {
|
|
13172
|
-
url:
|
|
13174
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13173
13175
|
removeParams: ['api_key']
|
|
13174
13176
|
},
|
|
13175
13177
|
Defillama: {
|
|
13176
|
-
url:
|
|
13178
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13177
13179
|
removeParams: ['api_key']
|
|
13178
13180
|
},
|
|
13179
13181
|
GnosisPay: {
|
|
13180
|
-
url:
|
|
13182
|
+
url: process.env.NEXT_PUBLIC_PROXY_BASE_URL || stagingFileverseProxyUrl,
|
|
13181
13183
|
removeParams: ['api_key']
|
|
13182
13184
|
},
|
|
13183
13185
|
// Add more services as needed. It can be direct url instead of ENV variable
|
|
@@ -13209,12 +13211,11 @@ function removeUrlParams(url, paramsToRemove) {
|
|
|
13209
13211
|
/**
|
|
13210
13212
|
* Handles URL routing through proxy or direct API calls
|
|
13211
13213
|
* @param {string} url - The original API URL
|
|
13212
|
-
* @param {string} serviceName - The name of the service (e.g., 'EOA')
|
|
13213
|
-
* @param {
|
|
13214
|
+
* @param {string} serviceName - [OPTIONAL] The name of the service (e.g., 'EOA')
|
|
13215
|
+
* @param {object} headers - [OPTIONAL] The name of the service (e.g., 'EOA')
|
|
13214
13216
|
* @returns {Object} Object containing URL and HEADERS for the fetch request
|
|
13215
13217
|
*/
|
|
13216
13218
|
function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
13217
|
-
console.log('getUrlAndHeaders new modified function from formulajs', url, serviceName);
|
|
13218
13219
|
// Check if proxy is enabled in localStorage
|
|
13219
13220
|
const apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
|
|
13220
13221
|
const isProxyModeEnabledValue = apiKeyLS === 'DEFAULT_PROXY_MODE';
|
|
@@ -13238,30 +13239,23 @@ function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
|
13238
13239
|
};
|
|
13239
13240
|
}
|
|
13240
13241
|
|
|
13241
|
-
|
|
13242
13242
|
return {
|
|
13243
13243
|
URL: url,
|
|
13244
13244
|
HEADERS: {
|
|
13245
13245
|
...headers,
|
|
13246
|
-
method: 'GET',
|
|
13247
13246
|
}
|
|
13248
13247
|
};
|
|
13249
13248
|
}
|
|
13250
13249
|
|
|
13251
13250
|
const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
|
|
13252
|
-
console.log('fromTimeStampToBlock', timestamp, chain, apiKey);
|
|
13253
13251
|
if (!timestamp || !chain || !apiKey) return
|
|
13254
13252
|
const chainId = CHAIN_ID_MAP[chain];
|
|
13255
|
-
console.log('chainId', chainId);
|
|
13256
13253
|
const url = `https://api.etherscan.io/v2/api?module=block&action=getblocknobytime×tamp=${timestamp}&closest=before&apikey=${apiKey}&chainId=${chainId}`;
|
|
13257
|
-
console.log('url', url, getUrlAndHeaders);
|
|
13258
13254
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
|
|
13259
|
-
console.log('finalUrl', finalUrl, HEADERS);
|
|
13260
13255
|
const res = await fetch(finalUrl, {
|
|
13261
13256
|
method: 'GET',
|
|
13262
13257
|
headers: HEADERS,
|
|
13263
13258
|
});
|
|
13264
|
-
console.log('res', res, finalUrl, HEADERS);
|
|
13265
13259
|
const json = await res.json();
|
|
13266
13260
|
return parseInt(json.result);
|
|
13267
13261
|
|
|
@@ -13423,7 +13417,7 @@ async function handleScanRequest({
|
|
|
13423
13417
|
}
|
|
13424
13418
|
url += `&page=${page}&offset=${offset}`;
|
|
13425
13419
|
}
|
|
13426
|
-
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({url, serviceName:
|
|
13420
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({url, serviceName: apiInfo.apiKeyName, headers: {}});
|
|
13427
13421
|
const res = await fetch(finalUrl, {
|
|
13428
13422
|
method: 'GET',
|
|
13429
13423
|
headers: HEADERS,
|
|
@@ -18255,7 +18249,6 @@ async function EOA() {
|
|
|
18255
18249
|
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
|
|
18256
18250
|
|
|
18257
18251
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18258
|
-
console.log('apiKey', apiKey);
|
|
18259
18252
|
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
|
|
18260
18253
|
|
|
18261
18254
|
const INPUTS = addresses.split(',').map(s => s.trim()).filter(Boolean);
|
|
@@ -18278,7 +18271,6 @@ async function EOA() {
|
|
|
18278
18271
|
|
|
18279
18272
|
async function fetchJSON(url) {
|
|
18280
18273
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
|
|
18281
|
-
console.log('finalUrl', finalUrl, HEADERS);
|
|
18282
18274
|
const res = await fetch(finalUrl, {
|
|
18283
18275
|
method: 'GET',
|
|
18284
18276
|
headers: HEADERS,
|
|
@@ -18295,14 +18287,10 @@ async function EOA() {
|
|
|
18295
18287
|
|
|
18296
18288
|
|
|
18297
18289
|
for (const chain of CHAINS) {
|
|
18298
|
-
console.log('chain', chain);
|
|
18299
18290
|
const chainId = CHAIN_ID_MAP[chain];
|
|
18300
18291
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
18301
|
-
console.log('chain', chain);
|
|
18302
|
-
|
|
18303
18292
|
|
|
18304
18293
|
if (category === 'balance') {
|
|
18305
|
-
console.log('balance');
|
|
18306
18294
|
// chunk 20
|
|
18307
18295
|
for (let i = 0; i < ADDRS.length; i += 20) {
|
|
18308
18296
|
const slice = ADDRS.slice(i, i + 20).join(',');
|
|
@@ -18316,10 +18304,8 @@ async function EOA() {
|
|
|
18316
18304
|
}
|
|
18317
18305
|
} else {
|
|
18318
18306
|
// txns
|
|
18319
|
-
console.log('startTime', startTime, 'endTime', endTime, chain, apiKey);
|
|
18320
18307
|
const sb = await fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(startTime), chain, apiKey);
|
|
18321
18308
|
const eb = await fromTimestampToBlock.fromTimeStampToBlock(toTimestamp(endTime), chain, apiKey);
|
|
18322
|
-
console.log('sb', sb, 'eb', eb);
|
|
18323
18309
|
if (!sb) throw new ValidationError(`Invalid startTime: ${startTime}`)
|
|
18324
18310
|
if (!eb) throw new ValidationError(`Invalid endTime: ${endTime}`)
|
|
18325
18311
|
for (const addr of ADDRS) {
|
package/package.json
CHANGED