@fileverse-dev/formulajs 4.4.38-col-3 → 4.4.38
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 +104 -254
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +29 -125
- package/lib/esm/index.mjs +29 -125
- package/package.json +1 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -17697,16 +17697,15 @@ const aaveParamsSchema = objectType({
|
|
|
17697
17697
|
category: enumType(['tokens','markets']),
|
|
17698
17698
|
param1: stringType().nonempty(),
|
|
17699
17699
|
param2: stringType().optional(),
|
|
17700
|
-
columnName: stringType().optional(),
|
|
17701
17700
|
});
|
|
17702
17701
|
|
|
17703
17702
|
async function AAVE() {
|
|
17704
17703
|
try {
|
|
17705
17704
|
|
|
17706
|
-
const [graphType, category, param1, param2
|
|
17705
|
+
const [graphType, category, param1, param2] = argsToArray(arguments);
|
|
17707
17706
|
|
|
17708
17707
|
|
|
17709
|
-
validateParams(aaveParamsSchema, { graphType, category, param1, param2
|
|
17708
|
+
validateParams(aaveParamsSchema, { graphType, category, param1, param2 });
|
|
17710
17709
|
|
|
17711
17710
|
const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
|
|
17712
17711
|
const url =
|
|
@@ -17723,25 +17722,16 @@ async function AAVE() {
|
|
|
17723
17722
|
}
|
|
17724
17723
|
|
|
17725
17724
|
const json = await res.json();
|
|
17726
|
-
const filterColumnName = columnName?.split(',').map(s => s.trim());
|
|
17727
|
-
|
|
17728
17725
|
if (Array.isArray(json)) {
|
|
17729
17726
|
return json.map(item => {
|
|
17730
17727
|
const flat = {};
|
|
17731
17728
|
Object.entries(item).forEach(([k, v]) => {
|
|
17732
|
-
if (
|
|
17729
|
+
if (v === null || typeof v !== 'object') flat[k] = v;
|
|
17733
17730
|
});
|
|
17734
17731
|
return flat
|
|
17735
17732
|
})
|
|
17736
17733
|
}
|
|
17737
|
-
|
|
17738
|
-
const data = {};
|
|
17739
|
-
filterColumnName.forEach(k => {
|
|
17740
|
-
data[k] = json[k];
|
|
17741
|
-
});
|
|
17742
|
-
return data
|
|
17743
|
-
}
|
|
17744
|
-
return json;
|
|
17734
|
+
return json
|
|
17745
17735
|
} catch (err) {
|
|
17746
17736
|
return errorMessageHandler(err, 'AAVE')
|
|
17747
17737
|
}
|
|
@@ -17781,7 +17771,6 @@ const baseSchema = objectType({
|
|
|
17781
17771
|
endTime: dateOrTimestamp.optional(),
|
|
17782
17772
|
page: numberType().int().nonnegative().default(1),
|
|
17783
17773
|
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17784
|
-
columnName: stringType().optional(),
|
|
17785
17774
|
});
|
|
17786
17775
|
|
|
17787
17776
|
const eoaParamsSchema = preprocessType(
|
|
@@ -18011,9 +18000,9 @@ function toTimestamp(dateStr) {
|
|
|
18011
18000
|
|
|
18012
18001
|
async function EOA() {
|
|
18013
18002
|
try {
|
|
18014
|
-
const [addresses, category, chains, startTime, endTime, page = 1, offset = 10
|
|
18003
|
+
const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
|
|
18015
18004
|
argsToArray(arguments);
|
|
18016
|
-
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset
|
|
18005
|
+
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
|
|
18017
18006
|
|
|
18018
18007
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18019
18008
|
|
|
@@ -18083,16 +18072,6 @@ async function EOA() {
|
|
|
18083
18072
|
}
|
|
18084
18073
|
}
|
|
18085
18074
|
}
|
|
18086
|
-
if(columnName){
|
|
18087
|
-
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18088
|
-
return out.map(obj =>
|
|
18089
|
-
Object.fromEntries(
|
|
18090
|
-
filterColumnName
|
|
18091
|
-
.filter(key => key in obj)
|
|
18092
|
-
.map(key => [key, obj[key]])
|
|
18093
|
-
)
|
|
18094
|
-
);
|
|
18095
|
-
}
|
|
18096
18075
|
return out
|
|
18097
18076
|
} catch (err) {
|
|
18098
18077
|
return errorMessageHandler(err, 'EOA')
|
|
@@ -18105,7 +18084,6 @@ const gasSchema$1 = objectType({
|
|
|
18105
18084
|
endDate: dateOrTimestamp.optional(),
|
|
18106
18085
|
page: numberType().int().nonnegative().default(1),
|
|
18107
18086
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18108
|
-
columnName: stringType().optional(),
|
|
18109
18087
|
});
|
|
18110
18088
|
|
|
18111
18089
|
const txnSchema$1 = objectType({
|
|
@@ -18115,7 +18093,6 @@ const txnSchema$1 = objectType({
|
|
|
18115
18093
|
endDate: dateOrTimestamp.optional(),
|
|
18116
18094
|
page: numberType().int().nonnegative().default(1),
|
|
18117
18095
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18118
|
-
columnName: stringType().optional(),
|
|
18119
18096
|
});
|
|
18120
18097
|
|
|
18121
18098
|
const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
|
|
@@ -18192,11 +18169,11 @@ async function handleScanRequest({
|
|
|
18192
18169
|
|
|
18193
18170
|
async function BASE() {
|
|
18194
18171
|
try {
|
|
18195
|
-
const [type, address, startDate, endDate, page, limit
|
|
18196
|
-
validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit
|
|
18172
|
+
const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
|
|
18173
|
+
validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
|
|
18197
18174
|
const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
|
|
18198
18175
|
|
|
18199
|
-
|
|
18176
|
+
return await handleScanRequest({
|
|
18200
18177
|
type,
|
|
18201
18178
|
address,
|
|
18202
18179
|
startDate,
|
|
@@ -18207,18 +18184,7 @@ async function BASE() {
|
|
|
18207
18184
|
functionName: 'BASE',
|
|
18208
18185
|
chainId: CHAIN_ID_MAP.base,
|
|
18209
18186
|
network: 'base'
|
|
18210
|
-
})
|
|
18211
|
-
if (columnName) {
|
|
18212
|
-
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18213
|
-
return out.map(obj =>
|
|
18214
|
-
Object.fromEntries(
|
|
18215
|
-
filterColumnName
|
|
18216
|
-
.filter(key => key in obj)
|
|
18217
|
-
.map(key => [key, obj[key]])
|
|
18218
|
-
)
|
|
18219
|
-
);
|
|
18220
|
-
}
|
|
18221
|
-
return out
|
|
18187
|
+
})
|
|
18222
18188
|
} catch (error) {
|
|
18223
18189
|
return errorMessageHandler(error, 'BASE')
|
|
18224
18190
|
}
|
|
@@ -18338,7 +18304,6 @@ const derivativesSchema = objectType({
|
|
|
18338
18304
|
category: literalType('derivatives'),
|
|
18339
18305
|
param1: stringType().nonempty(),
|
|
18340
18306
|
param2: anyType().optional(),
|
|
18341
|
-
columnName: stringType().optional(),
|
|
18342
18307
|
});
|
|
18343
18308
|
const coingeckoParamsSchema = discriminatedUnionType('category', [
|
|
18344
18309
|
priceSchema$1,
|
|
@@ -18353,8 +18318,8 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
|
|
|
18353
18318
|
|
|
18354
18319
|
async function COINGECKO() {
|
|
18355
18320
|
try {
|
|
18356
|
-
const [category, param1, param2
|
|
18357
|
-
validateParams(coingeckoParamsSchema, { category, param1, param2
|
|
18321
|
+
const [category, param1, param2] = argsToArray(arguments);
|
|
18322
|
+
validateParams(coingeckoParamsSchema, { category, param1, param2 });
|
|
18358
18323
|
|
|
18359
18324
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
|
|
18360
18325
|
|
|
@@ -18389,7 +18354,7 @@ async function COINGECKO() {
|
|
|
18389
18354
|
break
|
|
18390
18355
|
}
|
|
18391
18356
|
}
|
|
18392
|
-
const {
|
|
18357
|
+
const {URL: finalUrl, HEADERS} = getUrlAndHeaders({url, serviceName: 'Coingecko', headers});
|
|
18393
18358
|
|
|
18394
18359
|
const res = await fetch(finalUrl + "?refresh=true", { headers: HEADERS });
|
|
18395
18360
|
const json = await res.json();
|
|
@@ -18415,16 +18380,6 @@ async function COINGECKO() {
|
|
|
18415
18380
|
flat[key] = value;
|
|
18416
18381
|
}
|
|
18417
18382
|
}
|
|
18418
|
-
if (columnName) {
|
|
18419
|
-
const filterData = {};
|
|
18420
|
-
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18421
|
-
filterColumnName.forEach(col => {
|
|
18422
|
-
if (flat[col] !== undefined) {
|
|
18423
|
-
filterData[col] = flat[col];
|
|
18424
|
-
}
|
|
18425
|
-
});
|
|
18426
|
-
return filterData;
|
|
18427
|
-
}
|
|
18428
18383
|
return flat
|
|
18429
18384
|
})
|
|
18430
18385
|
} catch (err) {
|
|
@@ -18434,8 +18389,7 @@ async function COINGECKO() {
|
|
|
18434
18389
|
|
|
18435
18390
|
const categories = ['protocols','yields','dex','fees'];
|
|
18436
18391
|
const defillamaParamsSchema = objectType({
|
|
18437
|
-
category: enumType(categories)
|
|
18438
|
-
columnName: stringType().optional(),
|
|
18392
|
+
category: enumType(categories)
|
|
18439
18393
|
});
|
|
18440
18394
|
|
|
18441
18395
|
const CATEGORY_URLS = {
|
|
@@ -18447,8 +18401,8 @@ const CATEGORY_URLS = {
|
|
|
18447
18401
|
|
|
18448
18402
|
async function DEFILLAMA() {
|
|
18449
18403
|
try {
|
|
18450
|
-
const [category
|
|
18451
|
-
validateParams(defillamaParamsSchema, { category
|
|
18404
|
+
const [category] = argsToArray(arguments);
|
|
18405
|
+
validateParams(defillamaParamsSchema, { category });
|
|
18452
18406
|
const url = CATEGORY_URLS[category];
|
|
18453
18407
|
if (!url) throw new ValidationError(`Invalid category: ${category}`)
|
|
18454
18408
|
const res = await fetch(url);
|
|
@@ -18468,12 +18422,10 @@ async function DEFILLAMA() {
|
|
|
18468
18422
|
break
|
|
18469
18423
|
}
|
|
18470
18424
|
|
|
18471
|
-
const filterColumnName = columnName?.split(',').map(s => s.trim());
|
|
18472
|
-
|
|
18473
18425
|
return (Array.isArray(json) ? json : [json]).map(item => {
|
|
18474
18426
|
const out = {};
|
|
18475
18427
|
for (const [k, v] of Object.entries(item)) {
|
|
18476
|
-
if (
|
|
18428
|
+
if (v === null || typeof v !== 'object') out[k] = v;
|
|
18477
18429
|
}
|
|
18478
18430
|
return out
|
|
18479
18431
|
})
|
|
@@ -18488,7 +18440,6 @@ const gasSchema = objectType({
|
|
|
18488
18440
|
endDate: dateOrTimestamp.optional(),
|
|
18489
18441
|
page: numberType().int().nonnegative().default(1),
|
|
18490
18442
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18491
|
-
columnName: stringType().optional(),
|
|
18492
18443
|
});
|
|
18493
18444
|
|
|
18494
18445
|
const txnSchema = objectType({
|
|
@@ -18499,7 +18450,6 @@ const txnSchema = objectType({
|
|
|
18499
18450
|
chain: enumType(['ethereum','base','gnosis']),
|
|
18500
18451
|
page: numberType().int().nonnegative().default(1),
|
|
18501
18452
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18502
|
-
columnName: stringType().optional(),
|
|
18503
18453
|
});
|
|
18504
18454
|
|
|
18505
18455
|
const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
|
|
@@ -18513,18 +18463,18 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
|
|
|
18513
18463
|
|
|
18514
18464
|
async function ETHERSCAN() {
|
|
18515
18465
|
try {
|
|
18516
|
-
const [type, chain, address, startDate, endDate, page = 1, limit = 10
|
|
18466
|
+
const [type, chain, address, startDate, endDate, page = 1, limit = 10] =
|
|
18517
18467
|
argsToArray(arguments);
|
|
18518
18468
|
|
|
18519
18469
|
|
|
18520
|
-
validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit
|
|
18470
|
+
validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit });
|
|
18521
18471
|
|
|
18522
18472
|
const chainId = CHAIN_ID_MAP[chain];
|
|
18523
18473
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
18524
18474
|
|
|
18525
18475
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18526
18476
|
|
|
18527
|
-
|
|
18477
|
+
return await handleScanRequest({
|
|
18528
18478
|
type,
|
|
18529
18479
|
address,
|
|
18530
18480
|
startDate,
|
|
@@ -18535,18 +18485,7 @@ async function ETHERSCAN() {
|
|
|
18535
18485
|
functionName: 'ETHERSCAN',
|
|
18536
18486
|
chainId,
|
|
18537
18487
|
network: chain,
|
|
18538
|
-
})
|
|
18539
|
-
if (columnName) {
|
|
18540
|
-
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18541
|
-
return out.map(obj =>
|
|
18542
|
-
Object.fromEntries(
|
|
18543
|
-
filterColumnName
|
|
18544
|
-
.filter(key => key in obj)
|
|
18545
|
-
.map(key => [key, obj[key]])
|
|
18546
|
-
)
|
|
18547
|
-
);
|
|
18548
|
-
}
|
|
18549
|
-
return out
|
|
18488
|
+
})
|
|
18550
18489
|
} catch (err) {
|
|
18551
18490
|
return errorMessageHandler(err, 'ETHERSCAN')
|
|
18552
18491
|
}
|
|
@@ -18985,14 +18924,13 @@ const uniswapParamsSchema = objectType({
|
|
|
18985
18924
|
category: enumType(['tokens','markets']),
|
|
18986
18925
|
param1: stringType().nonempty(),
|
|
18987
18926
|
param2: stringType().optional(),
|
|
18988
|
-
colummnName: stringType().optional(),
|
|
18989
18927
|
});
|
|
18990
18928
|
|
|
18991
18929
|
async function UNISWAP() {
|
|
18992
18930
|
try {
|
|
18993
|
-
const [graphType, category, param1, param2
|
|
18931
|
+
const [graphType, category, param1, param2] = argsToArray(arguments);
|
|
18994
18932
|
|
|
18995
|
-
validateParams(uniswapParamsSchema, { graphType, category, param1, param2
|
|
18933
|
+
validateParams(uniswapParamsSchema, { graphType, category, param1, param2 });
|
|
18996
18934
|
|
|
18997
18935
|
const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
|
|
18998
18936
|
const url =
|
|
@@ -19010,24 +18948,16 @@ async function UNISWAP() {
|
|
|
19010
18948
|
}
|
|
19011
18949
|
|
|
19012
18950
|
const json = await res.json();
|
|
19013
|
-
const filterColumnName = columnName?.split(',').map(s => s.trim());
|
|
19014
18951
|
if (Array.isArray(json)) {
|
|
19015
18952
|
// flatten nested
|
|
19016
18953
|
return json.map(item => {
|
|
19017
18954
|
const flat = {};
|
|
19018
18955
|
Object.entries(item).forEach(([k, v]) => {
|
|
19019
|
-
if (
|
|
18956
|
+
if (v === null || typeof v !== 'object') flat[k] = v;
|
|
19020
18957
|
});
|
|
19021
18958
|
return flat
|
|
19022
18959
|
})
|
|
19023
18960
|
}
|
|
19024
|
-
if(columnName && typeof json === 'object') {
|
|
19025
|
-
const data = {};
|
|
19026
|
-
filterColumnName.forEach(k => {
|
|
19027
|
-
data[k] = json[k];
|
|
19028
|
-
});
|
|
19029
|
-
return data
|
|
19030
|
-
}
|
|
19031
18961
|
return json
|
|
19032
18962
|
} catch (err) {
|
|
19033
18963
|
return errorMessageHandler(err, 'UNISWAP')
|
|
@@ -19037,7 +18967,6 @@ async function UNISWAP() {
|
|
|
19037
18967
|
async function SMARTCONTRACT() {
|
|
19038
18968
|
try {
|
|
19039
18969
|
const args = argsToArray(arguments);
|
|
19040
|
-
console.log(args, arguments);
|
|
19041
18970
|
|
|
19042
18971
|
return new Promise((resolve) => {
|
|
19043
18972
|
resolve( {
|
|
@@ -29941,15 +29870,14 @@ class CirclesData {
|
|
|
29941
29870
|
const circlesParamsSchema = objectType({
|
|
29942
29871
|
functionName: enumType(['trust', 'profile', 'transactions', 'balances']),
|
|
29943
29872
|
address: stringType().nonempty(),
|
|
29944
|
-
entries: numberType().int().nonnegative().default(10)
|
|
29945
|
-
columnName: stringType().optional(),
|
|
29873
|
+
entries: numberType().int().nonnegative().default(10)
|
|
29946
29874
|
});
|
|
29947
29875
|
|
|
29948
29876
|
async function CIRCLES() {
|
|
29949
29877
|
try {
|
|
29950
|
-
const [functionName, address, entries
|
|
29878
|
+
const [functionName, address, entries] = argsToArray(arguments);
|
|
29951
29879
|
|
|
29952
|
-
validateParams(circlesParamsSchema, { functionName, address, entries
|
|
29880
|
+
validateParams(circlesParamsSchema, { functionName, address, entries });
|
|
29953
29881
|
|
|
29954
29882
|
const resolved = await fromEnsNameToAddress$1.validateAndGetAddress(address);
|
|
29955
29883
|
const dataClient = new CirclesData('https://rpc.aboutcircles.com');
|
|
@@ -29967,34 +29895,10 @@ async function CIRCLES() {
|
|
|
29967
29895
|
|
|
29968
29896
|
switch (functionName) {
|
|
29969
29897
|
case 'trust':
|
|
29970
|
-
|
|
29971
|
-
if (columnName) {
|
|
29972
|
-
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
29973
|
-
return dataTrust.map(obj =>
|
|
29974
|
-
Object.fromEntries(
|
|
29975
|
-
filterColumnName
|
|
29976
|
-
.filter(key => key in obj)
|
|
29977
|
-
.map(key => [key, obj[key]])
|
|
29978
|
-
)
|
|
29979
|
-
);
|
|
29980
|
-
} else {
|
|
29981
|
-
return dataTrust;
|
|
29982
|
-
}
|
|
29898
|
+
return await runOnePage(dataClient.getTrustRelations(resolved, limit))
|
|
29983
29899
|
|
|
29984
29900
|
case 'transactions':
|
|
29985
|
-
|
|
29986
|
-
if (columnName) {
|
|
29987
|
-
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
29988
|
-
return data.map(obj =>
|
|
29989
|
-
Object.fromEntries(
|
|
29990
|
-
filterColumnName
|
|
29991
|
-
.filter(key => key in obj)
|
|
29992
|
-
.map(key => [key, obj[key]])
|
|
29993
|
-
)
|
|
29994
|
-
);
|
|
29995
|
-
} else {
|
|
29996
|
-
return data;
|
|
29997
|
-
}
|
|
29901
|
+
return await runOnePage(dataClient.getTransactionHistory(resolved, limit))
|
|
29998
29902
|
|
|
29999
29903
|
case 'profile': {
|
|
30000
29904
|
const res = await dataClient.getAvatarInfo(resolved);
|