@fileverse-dev/formulajs 4.4.11-mod-74 → 4.4.11-mod-76
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 +184 -264
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +8 -26
- package/lib/esm/index.mjs +8 -26
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -13132,6 +13132,7 @@ const UTILITY = {
|
|
|
13132
13132
|
};
|
|
13133
13133
|
const MAX_PAGE_LIMIT = 250;
|
|
13134
13134
|
|
|
13135
|
+
// if data block need API key
|
|
13135
13136
|
const SERVICES_API_KEY = {
|
|
13136
13137
|
Etherscan: 'Etherscan',
|
|
13137
13138
|
Coingecko: 'Coingecko',
|
|
@@ -13264,17 +13265,17 @@ function removeUrlParams(url, paramsToRemove) {
|
|
|
13264
13265
|
function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
13265
13266
|
// Check if proxy is enabled in localStorage
|
|
13266
13267
|
const apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
|
|
13267
|
-
if(SERVICES_API_KEY[serviceName] && (!apiKeyLS || apiKeyLS === '')) {
|
|
13268
|
-
throw new MissingApiKeyError(SERVICES_API_KEY[serviceName])
|
|
13269
|
-
}
|
|
13270
13268
|
const isProxyModeEnabledValue = apiKeyLS === 'DEFAULT_PROXY_MODE';
|
|
13271
13269
|
|
|
13272
13270
|
// Check if proxy URL exists for this service
|
|
13273
13271
|
const proxyConfig = PROXY_MAP[serviceName];
|
|
13274
13272
|
|
|
13273
|
+
if (!proxyConfig && SERVICES_API_KEY[serviceName] && (!apiKeyLS || apiKeyLS === '')) {
|
|
13274
|
+
throw new MissingApiKeyError(SERVICES_API_KEY[serviceName])
|
|
13275
|
+
}
|
|
13276
|
+
|
|
13275
13277
|
// If proxy mode is enabled AND proxy URL exists for this service
|
|
13276
|
-
if (isProxyModeEnabledValue
|
|
13277
|
-
console.log('isProxyModeEnabledValue', isProxyModeEnabledValue);
|
|
13278
|
+
if ((isProxyModeEnabledValue || !apiKeyLS || apiKeyLS === '') && proxyConfig) {
|
|
13278
13279
|
// Remove specified parameters from the target URL
|
|
13279
13280
|
const cleanedUrl = removeUrlParams(url, proxyConfig.removeParams);
|
|
13280
13281
|
|
|
@@ -13297,7 +13298,7 @@ function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
|
13297
13298
|
}
|
|
13298
13299
|
|
|
13299
13300
|
const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
|
|
13300
|
-
if (!timestamp || !chain
|
|
13301
|
+
if (!timestamp || !chain) return
|
|
13301
13302
|
const chainId = CHAIN_ID_MAP[chain];
|
|
13302
13303
|
const url = `https://api.etherscan.io/v2/api?module=block&action=getblocknobytime×tamp=${timestamp}&closest=before&apikey=${apiKey}&chainId=${chainId}`;
|
|
13303
13304
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
|
|
@@ -17708,9 +17709,6 @@ async function FIREFLY() {
|
|
|
17708
17709
|
});
|
|
17709
17710
|
|
|
17710
17711
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
|
|
17711
|
-
if (!apiKey) {
|
|
17712
|
-
throw new MissingApiKeyError(SERVICES_API_KEY.Firefly)
|
|
17713
|
-
}
|
|
17714
17712
|
|
|
17715
17713
|
const url = new URL('https://openapi.firefly.land/v1/fileverse/fetch');
|
|
17716
17714
|
url.searchParams
|
|
@@ -17770,9 +17768,6 @@ async function LENS() {
|
|
|
17770
17768
|
const apiKey = window.localStorage.getItem(
|
|
17771
17769
|
SERVICES_API_KEY.Firefly
|
|
17772
17770
|
);
|
|
17773
|
-
if (!apiKey) {
|
|
17774
|
-
throw new MissingApiKeyError(SERVICES_API_KEY.Firefly)
|
|
17775
|
-
}
|
|
17776
17771
|
|
|
17777
17772
|
const url = new URL(
|
|
17778
17773
|
'https://openapi.firefly.land/v1/fileverse/fetch'
|
|
@@ -17834,9 +17829,6 @@ async function FARCASTER() {
|
|
|
17834
17829
|
const apiKey = window.localStorage.getItem(
|
|
17835
17830
|
SERVICES_API_KEY.Firefly
|
|
17836
17831
|
);
|
|
17837
|
-
if (!apiKey) {
|
|
17838
|
-
throw new MissingApiKeyError(SERVICES_API_KEY.Firefly)
|
|
17839
|
-
}
|
|
17840
17832
|
|
|
17841
17833
|
const url = new URL(
|
|
17842
17834
|
'https://openapi.firefly.land/v1/fileverse/fetch'
|
|
@@ -17975,7 +17967,6 @@ async function BASE() {
|
|
|
17975
17967
|
const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
|
|
17976
17968
|
validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
|
|
17977
17969
|
const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
|
|
17978
|
-
if (!API_KEY) throw new MissingApiKeyError(SERVICES_API_KEY.Basescan)
|
|
17979
17970
|
|
|
17980
17971
|
return await handleScanRequest({
|
|
17981
17972
|
type,
|
|
@@ -18011,7 +18002,6 @@ async function GNOSIS() {
|
|
|
18011
18002
|
const apiKey = window.localStorage.getItem(
|
|
18012
18003
|
SERVICES_API_KEY.Gnosisscan
|
|
18013
18004
|
);
|
|
18014
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Gnosisscan)
|
|
18015
18005
|
|
|
18016
18006
|
return await handleScanRequest({
|
|
18017
18007
|
type,
|
|
@@ -18041,7 +18031,6 @@ async function NEYNAR() {
|
|
|
18041
18031
|
validateParams(neynarParamsSchema, { username });
|
|
18042
18032
|
|
|
18043
18033
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Neynar);
|
|
18044
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Neynar)
|
|
18045
18034
|
|
|
18046
18035
|
const fid = await fromUsernameToFid$1.fromUsernameToFid(username, apiKey);
|
|
18047
18036
|
if (!fid) throw new ValidationError(`Invalid username: ${username}`)
|
|
@@ -18049,7 +18038,7 @@ async function NEYNAR() {
|
|
|
18049
18038
|
const url = `https://api.neynar.com/v2/farcaster/followers?fid=${fid}`;
|
|
18050
18039
|
|
|
18051
18040
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
|
|
18052
|
-
url: url.toString(), serviceName: '
|
|
18041
|
+
url: url.toString(), serviceName: 'Neynar',
|
|
18053
18042
|
headers: {
|
|
18054
18043
|
'x-api-key': apiKey,
|
|
18055
18044
|
'x-neynar-experimental': 'false'
|
|
@@ -18154,7 +18143,6 @@ async function ETHERSCAN() {
|
|
|
18154
18143
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
18155
18144
|
|
|
18156
18145
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18157
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
|
|
18158
18146
|
|
|
18159
18147
|
return await handleScanRequest({
|
|
18160
18148
|
type,
|
|
@@ -18180,7 +18168,6 @@ async function COINGECKO() {
|
|
|
18180
18168
|
validateParams(coingeckoParamsSchema, { category, param1, param2 });
|
|
18181
18169
|
|
|
18182
18170
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
|
|
18183
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Coingecko)
|
|
18184
18171
|
|
|
18185
18172
|
const headers = {
|
|
18186
18173
|
accept: 'application/json',
|
|
@@ -18247,14 +18234,12 @@ async function COINGECKO() {
|
|
|
18247
18234
|
}
|
|
18248
18235
|
|
|
18249
18236
|
async function EOA() {
|
|
18250
|
-
console.log('EOA');
|
|
18251
18237
|
try {
|
|
18252
18238
|
const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
|
|
18253
18239
|
argsToArray(arguments);
|
|
18254
18240
|
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
|
|
18255
18241
|
|
|
18256
18242
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18257
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
|
|
18258
18243
|
|
|
18259
18244
|
const INPUTS = addresses.split(',').map(s => s.trim()).filter(Boolean);
|
|
18260
18245
|
const CHAINS = chains.split(',').map(s => s.trim()).filter(Boolean);
|
|
@@ -18271,7 +18256,6 @@ async function EOA() {
|
|
|
18271
18256
|
}
|
|
18272
18257
|
}
|
|
18273
18258
|
const ADDRS = Object.keys(ADDRESS_MAP);
|
|
18274
|
-
console.log('ADDRS', ADDRS);
|
|
18275
18259
|
const out = [];
|
|
18276
18260
|
|
|
18277
18261
|
async function fetchJSON(url) {
|
|
@@ -18346,7 +18330,6 @@ async function SAFE() {
|
|
|
18346
18330
|
validateParams(safeParamsSchema, { address, utility, chain, limit, offset });
|
|
18347
18331
|
|
|
18348
18332
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Safe);
|
|
18349
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Safe)
|
|
18350
18333
|
|
|
18351
18334
|
const chainId = SAFE_CHAIN_MAP[chain];
|
|
18352
18335
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
@@ -18383,7 +18366,6 @@ async function DEFILLAMA() {
|
|
|
18383
18366
|
const [category] = argsToArray(arguments);
|
|
18384
18367
|
validateParams(defillamaParamsSchema, { category });
|
|
18385
18368
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Defillama);
|
|
18386
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Defillama)
|
|
18387
18369
|
const url = CATEGORY_URLS[category];
|
|
18388
18370
|
if (!url) throw new ValidationError(`Invalid category: ${category}`)
|
|
18389
18371
|
const res = await fetch(url);
|
package/lib/esm/index.mjs
CHANGED
|
@@ -13130,6 +13130,7 @@ const UTILITY = {
|
|
|
13130
13130
|
};
|
|
13131
13131
|
const MAX_PAGE_LIMIT = 250;
|
|
13132
13132
|
|
|
13133
|
+
// if data block need API key
|
|
13133
13134
|
const SERVICES_API_KEY = {
|
|
13134
13135
|
Etherscan: 'Etherscan',
|
|
13135
13136
|
Coingecko: 'Coingecko',
|
|
@@ -13262,17 +13263,17 @@ function removeUrlParams(url, paramsToRemove) {
|
|
|
13262
13263
|
function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
13263
13264
|
// Check if proxy is enabled in localStorage
|
|
13264
13265
|
const apiKeyLS = window.localStorage.getItem(SERVICES_API_KEY[serviceName]);
|
|
13265
|
-
if(SERVICES_API_KEY[serviceName] && (!apiKeyLS || apiKeyLS === '')) {
|
|
13266
|
-
throw new MissingApiKeyError(SERVICES_API_KEY[serviceName])
|
|
13267
|
-
}
|
|
13268
13266
|
const isProxyModeEnabledValue = apiKeyLS === 'DEFAULT_PROXY_MODE';
|
|
13269
13267
|
|
|
13270
13268
|
// Check if proxy URL exists for this service
|
|
13271
13269
|
const proxyConfig = PROXY_MAP[serviceName];
|
|
13272
13270
|
|
|
13271
|
+
if (!proxyConfig && SERVICES_API_KEY[serviceName] && (!apiKeyLS || apiKeyLS === '')) {
|
|
13272
|
+
throw new MissingApiKeyError(SERVICES_API_KEY[serviceName])
|
|
13273
|
+
}
|
|
13274
|
+
|
|
13273
13275
|
// If proxy mode is enabled AND proxy URL exists for this service
|
|
13274
|
-
if (isProxyModeEnabledValue
|
|
13275
|
-
console.log('isProxyModeEnabledValue', isProxyModeEnabledValue);
|
|
13276
|
+
if ((isProxyModeEnabledValue || !apiKeyLS || apiKeyLS === '') && proxyConfig) {
|
|
13276
13277
|
// Remove specified parameters from the target URL
|
|
13277
13278
|
const cleanedUrl = removeUrlParams(url, proxyConfig.removeParams);
|
|
13278
13279
|
|
|
@@ -13295,7 +13296,7 @@ function getUrlAndHeaders({ url, serviceName, headers = {} }) {
|
|
|
13295
13296
|
}
|
|
13296
13297
|
|
|
13297
13298
|
const fromTimeStampToBlock = async (timestamp, chain, apiKey) => {
|
|
13298
|
-
if (!timestamp || !chain
|
|
13299
|
+
if (!timestamp || !chain) return
|
|
13299
13300
|
const chainId = CHAIN_ID_MAP[chain];
|
|
13300
13301
|
const url = `https://api.etherscan.io/v2/api?module=block&action=getblocknobytime×tamp=${timestamp}&closest=before&apikey=${apiKey}&chainId=${chainId}`;
|
|
13301
13302
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Etherscan', headers: {} });
|
|
@@ -17706,9 +17707,6 @@ async function FIREFLY() {
|
|
|
17706
17707
|
});
|
|
17707
17708
|
|
|
17708
17709
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Firefly);
|
|
17709
|
-
if (!apiKey) {
|
|
17710
|
-
throw new MissingApiKeyError(SERVICES_API_KEY.Firefly)
|
|
17711
|
-
}
|
|
17712
17710
|
|
|
17713
17711
|
const url = new URL('https://openapi.firefly.land/v1/fileverse/fetch');
|
|
17714
17712
|
url.searchParams
|
|
@@ -17768,9 +17766,6 @@ async function LENS() {
|
|
|
17768
17766
|
const apiKey = window.localStorage.getItem(
|
|
17769
17767
|
SERVICES_API_KEY.Firefly
|
|
17770
17768
|
);
|
|
17771
|
-
if (!apiKey) {
|
|
17772
|
-
throw new MissingApiKeyError(SERVICES_API_KEY.Firefly)
|
|
17773
|
-
}
|
|
17774
17769
|
|
|
17775
17770
|
const url = new URL(
|
|
17776
17771
|
'https://openapi.firefly.land/v1/fileverse/fetch'
|
|
@@ -17832,9 +17827,6 @@ async function FARCASTER() {
|
|
|
17832
17827
|
const apiKey = window.localStorage.getItem(
|
|
17833
17828
|
SERVICES_API_KEY.Firefly
|
|
17834
17829
|
);
|
|
17835
|
-
if (!apiKey) {
|
|
17836
|
-
throw new MissingApiKeyError(SERVICES_API_KEY.Firefly)
|
|
17837
|
-
}
|
|
17838
17830
|
|
|
17839
17831
|
const url = new URL(
|
|
17840
17832
|
'https://openapi.firefly.land/v1/fileverse/fetch'
|
|
@@ -17973,7 +17965,6 @@ async function BASE() {
|
|
|
17973
17965
|
const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
|
|
17974
17966
|
validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
|
|
17975
17967
|
const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
|
|
17976
|
-
if (!API_KEY) throw new MissingApiKeyError(SERVICES_API_KEY.Basescan)
|
|
17977
17968
|
|
|
17978
17969
|
return await handleScanRequest({
|
|
17979
17970
|
type,
|
|
@@ -18009,7 +18000,6 @@ async function GNOSIS() {
|
|
|
18009
18000
|
const apiKey = window.localStorage.getItem(
|
|
18010
18001
|
SERVICES_API_KEY.Gnosisscan
|
|
18011
18002
|
);
|
|
18012
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Gnosisscan)
|
|
18013
18003
|
|
|
18014
18004
|
return await handleScanRequest({
|
|
18015
18005
|
type,
|
|
@@ -18039,7 +18029,6 @@ async function NEYNAR() {
|
|
|
18039
18029
|
validateParams(neynarParamsSchema, { username });
|
|
18040
18030
|
|
|
18041
18031
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Neynar);
|
|
18042
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Neynar)
|
|
18043
18032
|
|
|
18044
18033
|
const fid = await fromUsernameToFid$1.fromUsernameToFid(username, apiKey);
|
|
18045
18034
|
if (!fid) throw new ValidationError(`Invalid username: ${username}`)
|
|
@@ -18047,7 +18036,7 @@ async function NEYNAR() {
|
|
|
18047
18036
|
const url = `https://api.neynar.com/v2/farcaster/followers?fid=${fid}`;
|
|
18048
18037
|
|
|
18049
18038
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
|
|
18050
|
-
url: url.toString(), serviceName: '
|
|
18039
|
+
url: url.toString(), serviceName: 'Neynar',
|
|
18051
18040
|
headers: {
|
|
18052
18041
|
'x-api-key': apiKey,
|
|
18053
18042
|
'x-neynar-experimental': 'false'
|
|
@@ -18152,7 +18141,6 @@ async function ETHERSCAN() {
|
|
|
18152
18141
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
18153
18142
|
|
|
18154
18143
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18155
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
|
|
18156
18144
|
|
|
18157
18145
|
return await handleScanRequest({
|
|
18158
18146
|
type,
|
|
@@ -18178,7 +18166,6 @@ async function COINGECKO() {
|
|
|
18178
18166
|
validateParams(coingeckoParamsSchema, { category, param1, param2 });
|
|
18179
18167
|
|
|
18180
18168
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
|
|
18181
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Coingecko)
|
|
18182
18169
|
|
|
18183
18170
|
const headers = {
|
|
18184
18171
|
accept: 'application/json',
|
|
@@ -18245,14 +18232,12 @@ async function COINGECKO() {
|
|
|
18245
18232
|
}
|
|
18246
18233
|
|
|
18247
18234
|
async function EOA() {
|
|
18248
|
-
console.log('EOA');
|
|
18249
18235
|
try {
|
|
18250
18236
|
const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
|
|
18251
18237
|
argsToArray(arguments);
|
|
18252
18238
|
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
|
|
18253
18239
|
|
|
18254
18240
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18255
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Etherscan)
|
|
18256
18241
|
|
|
18257
18242
|
const INPUTS = addresses.split(',').map(s => s.trim()).filter(Boolean);
|
|
18258
18243
|
const CHAINS = chains.split(',').map(s => s.trim()).filter(Boolean);
|
|
@@ -18269,7 +18254,6 @@ async function EOA() {
|
|
|
18269
18254
|
}
|
|
18270
18255
|
}
|
|
18271
18256
|
const ADDRS = Object.keys(ADDRESS_MAP);
|
|
18272
|
-
console.log('ADDRS', ADDRS);
|
|
18273
18257
|
const out = [];
|
|
18274
18258
|
|
|
18275
18259
|
async function fetchJSON(url) {
|
|
@@ -18344,7 +18328,6 @@ async function SAFE() {
|
|
|
18344
18328
|
validateParams(safeParamsSchema, { address, utility, chain, limit, offset });
|
|
18345
18329
|
|
|
18346
18330
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Safe);
|
|
18347
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Safe)
|
|
18348
18331
|
|
|
18349
18332
|
const chainId = SAFE_CHAIN_MAP[chain];
|
|
18350
18333
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
@@ -18381,7 +18364,6 @@ async function DEFILLAMA() {
|
|
|
18381
18364
|
const [category] = argsToArray(arguments);
|
|
18382
18365
|
validateParams(defillamaParamsSchema, { category });
|
|
18383
18366
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Defillama);
|
|
18384
|
-
if (!apiKey) throw new MissingApiKeyError(SERVICES_API_KEY.Defillama)
|
|
18385
18367
|
const url = CATEGORY_URLS[category];
|
|
18386
18368
|
if (!url) throw new ValidationError(`Invalid category: ${category}`)
|
|
18387
18369
|
const res = await fetch(url);
|