@fileverse-dev/formulajs 4.4.38 → 4.4.41-example
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 +254 -104
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +125 -30
- package/lib/esm/crypto-constants.mjs +288 -10
- package/lib/esm/index.mjs +125 -30
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -17695,15 +17695,16 @@ const aaveParamsSchema = objectType({
|
|
|
17695
17695
|
category: enumType(['tokens','markets']),
|
|
17696
17696
|
param1: stringType().nonempty(),
|
|
17697
17697
|
param2: stringType().optional(),
|
|
17698
|
+
columnName: stringType().optional(),
|
|
17698
17699
|
});
|
|
17699
17700
|
|
|
17700
17701
|
async function AAVE() {
|
|
17701
17702
|
try {
|
|
17702
17703
|
|
|
17703
|
-
const [graphType, category, param1, param2] = argsToArray(arguments);
|
|
17704
|
+
const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
|
|
17704
17705
|
|
|
17705
17706
|
|
|
17706
|
-
validateParams(aaveParamsSchema, { graphType, category, param1, param2 });
|
|
17707
|
+
validateParams(aaveParamsSchema, { graphType, category, param1, param2, columnName });
|
|
17707
17708
|
|
|
17708
17709
|
const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
|
|
17709
17710
|
const url =
|
|
@@ -17720,16 +17721,25 @@ async function AAVE() {
|
|
|
17720
17721
|
}
|
|
17721
17722
|
|
|
17722
17723
|
const json = await res.json();
|
|
17724
|
+
const filterColumnName = columnName?.split(',').map(s => s.trim());
|
|
17725
|
+
|
|
17723
17726
|
if (Array.isArray(json)) {
|
|
17724
17727
|
return json.map(item => {
|
|
17725
17728
|
const flat = {};
|
|
17726
17729
|
Object.entries(item).forEach(([k, v]) => {
|
|
17727
|
-
if (v === null || typeof v !== 'object') flat[k] = v;
|
|
17730
|
+
if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
|
|
17728
17731
|
});
|
|
17729
17732
|
return flat
|
|
17730
17733
|
})
|
|
17731
17734
|
}
|
|
17732
|
-
|
|
17735
|
+
if(columnName && typeof json === 'object') {
|
|
17736
|
+
const data = {};
|
|
17737
|
+
filterColumnName.forEach(k => {
|
|
17738
|
+
data[k] = json[k];
|
|
17739
|
+
});
|
|
17740
|
+
return data
|
|
17741
|
+
}
|
|
17742
|
+
return json;
|
|
17733
17743
|
} catch (err) {
|
|
17734
17744
|
return errorMessageHandler(err, 'AAVE')
|
|
17735
17745
|
}
|
|
@@ -17769,6 +17779,7 @@ const baseSchema = objectType({
|
|
|
17769
17779
|
endTime: dateOrTimestamp.optional(),
|
|
17770
17780
|
page: numberType().int().nonnegative().default(1),
|
|
17771
17781
|
offset: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"offset" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
17782
|
+
columnName: stringType().optional(),
|
|
17772
17783
|
});
|
|
17773
17784
|
|
|
17774
17785
|
const eoaParamsSchema = preprocessType(
|
|
@@ -17998,9 +18009,9 @@ function toTimestamp(dateStr) {
|
|
|
17998
18009
|
|
|
17999
18010
|
async function EOA() {
|
|
18000
18011
|
try {
|
|
18001
|
-
const [addresses, category, chains, startTime, endTime, page = 1, offset = 10] =
|
|
18012
|
+
const [addresses, category, chains, startTime, endTime, page = 1, offset = 10, columnName = null] =
|
|
18002
18013
|
argsToArray(arguments);
|
|
18003
|
-
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset });
|
|
18014
|
+
validateParams(eoaParamsSchema, { addresses, category, chains, startTime, endTime, page, offset, columnName });
|
|
18004
18015
|
|
|
18005
18016
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18006
18017
|
|
|
@@ -18070,6 +18081,16 @@ async function EOA() {
|
|
|
18070
18081
|
}
|
|
18071
18082
|
}
|
|
18072
18083
|
}
|
|
18084
|
+
if(columnName){
|
|
18085
|
+
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18086
|
+
return out.map(obj =>
|
|
18087
|
+
Object.fromEntries(
|
|
18088
|
+
filterColumnName
|
|
18089
|
+
.filter(key => key in obj)
|
|
18090
|
+
.map(key => [key, obj[key]])
|
|
18091
|
+
)
|
|
18092
|
+
);
|
|
18093
|
+
}
|
|
18073
18094
|
return out
|
|
18074
18095
|
} catch (err) {
|
|
18075
18096
|
return errorMessageHandler(err, 'EOA')
|
|
@@ -18082,6 +18103,7 @@ const gasSchema$1 = objectType({
|
|
|
18082
18103
|
endDate: dateOrTimestamp.optional(),
|
|
18083
18104
|
page: numberType().int().nonnegative().default(1),
|
|
18084
18105
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18106
|
+
columnName: stringType().optional(),
|
|
18085
18107
|
});
|
|
18086
18108
|
|
|
18087
18109
|
const txnSchema$1 = objectType({
|
|
@@ -18091,6 +18113,7 @@ const txnSchema$1 = objectType({
|
|
|
18091
18113
|
endDate: dateOrTimestamp.optional(),
|
|
18092
18114
|
page: numberType().int().nonnegative().default(1),
|
|
18093
18115
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18116
|
+
columnName: stringType().optional(),
|
|
18094
18117
|
});
|
|
18095
18118
|
|
|
18096
18119
|
const baseParamsSchema = discriminatedUnionType('type', [gasSchema$1, txnSchema$1]);
|
|
@@ -18167,11 +18190,11 @@ async function handleScanRequest({
|
|
|
18167
18190
|
|
|
18168
18191
|
async function BASE() {
|
|
18169
18192
|
try {
|
|
18170
|
-
const [type, address, startDate, endDate, page, limit] = argsToArray(arguments);
|
|
18171
|
-
validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit });
|
|
18193
|
+
const [type, address, startDate, endDate, page, limit, columnName] = argsToArray(arguments);
|
|
18194
|
+
validateParams(baseParamsSchema, { type, address, startDate, endDate, page, limit, columnName });
|
|
18172
18195
|
const API_KEY = window.localStorage.getItem(SERVICES_API_KEY.Basescan);
|
|
18173
18196
|
|
|
18174
|
-
|
|
18197
|
+
const out = await handleScanRequest({
|
|
18175
18198
|
type,
|
|
18176
18199
|
address,
|
|
18177
18200
|
startDate,
|
|
@@ -18182,7 +18205,18 @@ async function BASE() {
|
|
|
18182
18205
|
functionName: 'BASE',
|
|
18183
18206
|
chainId: CHAIN_ID_MAP.base,
|
|
18184
18207
|
network: 'base'
|
|
18185
|
-
})
|
|
18208
|
+
});
|
|
18209
|
+
if (columnName) {
|
|
18210
|
+
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18211
|
+
return out.map(obj =>
|
|
18212
|
+
Object.fromEntries(
|
|
18213
|
+
filterColumnName
|
|
18214
|
+
.filter(key => key in obj)
|
|
18215
|
+
.map(key => [key, obj[key]])
|
|
18216
|
+
)
|
|
18217
|
+
);
|
|
18218
|
+
}
|
|
18219
|
+
return out
|
|
18186
18220
|
} catch (error) {
|
|
18187
18221
|
return errorMessageHandler(error, 'BASE')
|
|
18188
18222
|
}
|
|
@@ -18302,6 +18336,7 @@ const derivativesSchema = objectType({
|
|
|
18302
18336
|
category: literalType('derivatives'),
|
|
18303
18337
|
param1: stringType().nonempty(),
|
|
18304
18338
|
param2: anyType().optional(),
|
|
18339
|
+
columnName: stringType().optional(),
|
|
18305
18340
|
});
|
|
18306
18341
|
const coingeckoParamsSchema = discriminatedUnionType('category', [
|
|
18307
18342
|
priceSchema$1,
|
|
@@ -18313,11 +18348,10 @@ const coingeckoParamsSchema = discriminatedUnionType('category', [
|
|
|
18313
18348
|
/* global window */
|
|
18314
18349
|
|
|
18315
18350
|
|
|
18316
|
-
|
|
18317
18351
|
async function COINGECKO() {
|
|
18318
18352
|
try {
|
|
18319
|
-
const [category, param1, param2] = argsToArray(arguments);
|
|
18320
|
-
validateParams(coingeckoParamsSchema, { category, param1, param2 });
|
|
18353
|
+
const [category, param1, param2, columnName = null] = argsToArray(arguments);
|
|
18354
|
+
validateParams(coingeckoParamsSchema, { category, param1, param2, columnName });
|
|
18321
18355
|
|
|
18322
18356
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Coingecko);
|
|
18323
18357
|
|
|
@@ -18352,7 +18386,7 @@ async function COINGECKO() {
|
|
|
18352
18386
|
break
|
|
18353
18387
|
}
|
|
18354
18388
|
}
|
|
18355
|
-
const {URL: finalUrl, HEADERS} = getUrlAndHeaders({url, serviceName: 'Coingecko', headers});
|
|
18389
|
+
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({ url, serviceName: 'Coingecko', headers });
|
|
18356
18390
|
|
|
18357
18391
|
const res = await fetch(finalUrl + "?refresh=true", { headers: HEADERS });
|
|
18358
18392
|
const json = await res.json();
|
|
@@ -18378,6 +18412,16 @@ async function COINGECKO() {
|
|
|
18378
18412
|
flat[key] = value;
|
|
18379
18413
|
}
|
|
18380
18414
|
}
|
|
18415
|
+
if (columnName) {
|
|
18416
|
+
const filterData = {};
|
|
18417
|
+
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18418
|
+
filterColumnName.forEach(col => {
|
|
18419
|
+
if (flat[col] !== undefined) {
|
|
18420
|
+
filterData[col] = flat[col];
|
|
18421
|
+
}
|
|
18422
|
+
});
|
|
18423
|
+
return filterData;
|
|
18424
|
+
}
|
|
18381
18425
|
return flat
|
|
18382
18426
|
})
|
|
18383
18427
|
} catch (err) {
|
|
@@ -18387,7 +18431,8 @@ async function COINGECKO() {
|
|
|
18387
18431
|
|
|
18388
18432
|
const categories = ['protocols','yields','dex','fees'];
|
|
18389
18433
|
const defillamaParamsSchema = objectType({
|
|
18390
|
-
category: enumType(categories)
|
|
18434
|
+
category: enumType(categories),
|
|
18435
|
+
columnName: stringType().optional(),
|
|
18391
18436
|
});
|
|
18392
18437
|
|
|
18393
18438
|
const CATEGORY_URLS = {
|
|
@@ -18399,8 +18444,8 @@ const CATEGORY_URLS = {
|
|
|
18399
18444
|
|
|
18400
18445
|
async function DEFILLAMA() {
|
|
18401
18446
|
try {
|
|
18402
|
-
const [category] = argsToArray(arguments);
|
|
18403
|
-
validateParams(defillamaParamsSchema, { category });
|
|
18447
|
+
const [category, columnName = null] = argsToArray(arguments);
|
|
18448
|
+
validateParams(defillamaParamsSchema, { category, columnName });
|
|
18404
18449
|
const url = CATEGORY_URLS[category];
|
|
18405
18450
|
if (!url) throw new ValidationError(`Invalid category: ${category}`)
|
|
18406
18451
|
const res = await fetch(url);
|
|
@@ -18420,10 +18465,12 @@ async function DEFILLAMA() {
|
|
|
18420
18465
|
break
|
|
18421
18466
|
}
|
|
18422
18467
|
|
|
18468
|
+
const filterColumnName = columnName?.split(',').map(s => s.trim());
|
|
18469
|
+
|
|
18423
18470
|
return (Array.isArray(json) ? json : [json]).map(item => {
|
|
18424
18471
|
const out = {};
|
|
18425
18472
|
for (const [k, v] of Object.entries(item)) {
|
|
18426
|
-
if (v === null || typeof v !== 'object') out[k] = v;
|
|
18473
|
+
if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) out[k] = v;
|
|
18427
18474
|
}
|
|
18428
18475
|
return out
|
|
18429
18476
|
})
|
|
@@ -18438,6 +18485,7 @@ const gasSchema = objectType({
|
|
|
18438
18485
|
endDate: dateOrTimestamp.optional(),
|
|
18439
18486
|
page: numberType().int().nonnegative().default(1),
|
|
18440
18487
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18488
|
+
columnName: stringType().optional(),
|
|
18441
18489
|
});
|
|
18442
18490
|
|
|
18443
18491
|
const txnSchema = objectType({
|
|
@@ -18448,6 +18496,7 @@ const txnSchema = objectType({
|
|
|
18448
18496
|
chain: enumType(['ethereum','base','gnosis']),
|
|
18449
18497
|
page: numberType().int().nonnegative().default(1),
|
|
18450
18498
|
limit: numberType().int().nonnegative().max(MAX_PAGE_LIMIT, {message: `"limit" must be less than or equal to ${MAX_PAGE_LIMIT}`}).default(10),
|
|
18499
|
+
columnName: stringType().optional(),
|
|
18451
18500
|
});
|
|
18452
18501
|
|
|
18453
18502
|
const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSchema]);
|
|
@@ -18461,18 +18510,18 @@ const etherscanParamsSchema = discriminatedUnionType('type', [gasSchema, txnSche
|
|
|
18461
18510
|
|
|
18462
18511
|
async function ETHERSCAN() {
|
|
18463
18512
|
try {
|
|
18464
|
-
const [type, chain, address, startDate, endDate, page = 1, limit = 10] =
|
|
18513
|
+
const [type, chain, address, startDate, endDate, page = 1, limit = 10, columnName = null] =
|
|
18465
18514
|
argsToArray(arguments);
|
|
18466
18515
|
|
|
18467
18516
|
|
|
18468
|
-
validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit });
|
|
18517
|
+
validateParams(etherscanParamsSchema, { type, chain, address, startDate, endDate, page, limit, columnName });
|
|
18469
18518
|
|
|
18470
18519
|
const chainId = CHAIN_ID_MAP[chain];
|
|
18471
18520
|
if (!chainId) throw new ValidationError(`Invalid chain: ${chain}`)
|
|
18472
18521
|
|
|
18473
18522
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.Etherscan);
|
|
18474
18523
|
|
|
18475
|
-
|
|
18524
|
+
const out = await handleScanRequest({
|
|
18476
18525
|
type,
|
|
18477
18526
|
address,
|
|
18478
18527
|
startDate,
|
|
@@ -18483,7 +18532,18 @@ async function ETHERSCAN() {
|
|
|
18483
18532
|
functionName: 'ETHERSCAN',
|
|
18484
18533
|
chainId,
|
|
18485
18534
|
network: chain,
|
|
18486
|
-
})
|
|
18535
|
+
});
|
|
18536
|
+
if (columnName) {
|
|
18537
|
+
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
18538
|
+
return out.map(obj =>
|
|
18539
|
+
Object.fromEntries(
|
|
18540
|
+
filterColumnName
|
|
18541
|
+
.filter(key => key in obj)
|
|
18542
|
+
.map(key => [key, obj[key]])
|
|
18543
|
+
)
|
|
18544
|
+
);
|
|
18545
|
+
}
|
|
18546
|
+
return out
|
|
18487
18547
|
} catch (err) {
|
|
18488
18548
|
return errorMessageHandler(err, 'ETHERSCAN')
|
|
18489
18549
|
}
|
|
@@ -18922,13 +18982,14 @@ const uniswapParamsSchema = objectType({
|
|
|
18922
18982
|
category: enumType(['tokens','markets']),
|
|
18923
18983
|
param1: stringType().nonempty(),
|
|
18924
18984
|
param2: stringType().optional(),
|
|
18985
|
+
colummnName: stringType().optional(),
|
|
18925
18986
|
});
|
|
18926
18987
|
|
|
18927
18988
|
async function UNISWAP() {
|
|
18928
18989
|
try {
|
|
18929
|
-
const [graphType, category, param1, param2] = argsToArray(arguments);
|
|
18990
|
+
const [graphType, category, param1, param2, columnName] = argsToArray(arguments);
|
|
18930
18991
|
|
|
18931
|
-
validateParams(uniswapParamsSchema, { graphType, category, param1, param2 });
|
|
18992
|
+
validateParams(uniswapParamsSchema, { graphType, category, param1, param2, columnName });
|
|
18932
18993
|
|
|
18933
18994
|
const baseUrl = 'https://onchain-proxy.fileverse.io/third-party';
|
|
18934
18995
|
const url =
|
|
@@ -18946,16 +19007,24 @@ async function UNISWAP() {
|
|
|
18946
19007
|
}
|
|
18947
19008
|
|
|
18948
19009
|
const json = await res.json();
|
|
19010
|
+
const filterColumnName = columnName?.split(',').map(s => s.trim());
|
|
18949
19011
|
if (Array.isArray(json)) {
|
|
18950
19012
|
// flatten nested
|
|
18951
19013
|
return json.map(item => {
|
|
18952
19014
|
const flat = {};
|
|
18953
19015
|
Object.entries(item).forEach(([k, v]) => {
|
|
18954
|
-
if (v === null || typeof v !== 'object') flat[k] = v;
|
|
19016
|
+
if ((columnName && filterColumnName.includes(k)) && (v === null || typeof v !== 'object')) flat[k] = v;
|
|
18955
19017
|
});
|
|
18956
19018
|
return flat
|
|
18957
19019
|
})
|
|
18958
19020
|
}
|
|
19021
|
+
if(columnName && typeof json === 'object') {
|
|
19022
|
+
const data = {};
|
|
19023
|
+
filterColumnName.forEach(k => {
|
|
19024
|
+
data[k] = json[k];
|
|
19025
|
+
});
|
|
19026
|
+
return data
|
|
19027
|
+
}
|
|
18959
19028
|
return json
|
|
18960
19029
|
} catch (err) {
|
|
18961
19030
|
return errorMessageHandler(err, 'UNISWAP')
|
|
@@ -18965,6 +19034,7 @@ async function UNISWAP() {
|
|
|
18965
19034
|
async function SMARTCONTRACT() {
|
|
18966
19035
|
try {
|
|
18967
19036
|
const args = argsToArray(arguments);
|
|
19037
|
+
console.log(args, arguments);
|
|
18968
19038
|
|
|
18969
19039
|
return new Promise((resolve) => {
|
|
18970
19040
|
resolve( {
|
|
@@ -29868,14 +29938,15 @@ class CirclesData {
|
|
|
29868
29938
|
const circlesParamsSchema = objectType({
|
|
29869
29939
|
functionName: enumType(['trust', 'profile', 'transactions', 'balances']),
|
|
29870
29940
|
address: stringType().nonempty(),
|
|
29871
|
-
entries: numberType().int().nonnegative().default(10)
|
|
29941
|
+
entries: numberType().int().nonnegative().default(10),
|
|
29942
|
+
columnName: stringType().optional(),
|
|
29872
29943
|
});
|
|
29873
29944
|
|
|
29874
29945
|
async function CIRCLES() {
|
|
29875
29946
|
try {
|
|
29876
|
-
const [functionName, address, entries] = argsToArray(arguments);
|
|
29947
|
+
const [functionName, address, entries, columnName] = argsToArray(arguments);
|
|
29877
29948
|
|
|
29878
|
-
validateParams(circlesParamsSchema, { functionName, address, entries });
|
|
29949
|
+
validateParams(circlesParamsSchema, { functionName, address, entries, columnName });
|
|
29879
29950
|
|
|
29880
29951
|
const resolved = await fromEnsNameToAddress$1.validateAndGetAddress(address);
|
|
29881
29952
|
const dataClient = new CirclesData('https://rpc.aboutcircles.com');
|
|
@@ -29893,10 +29964,34 @@ async function CIRCLES() {
|
|
|
29893
29964
|
|
|
29894
29965
|
switch (functionName) {
|
|
29895
29966
|
case 'trust':
|
|
29896
|
-
|
|
29967
|
+
const dataTrust = await runOnePage(dataClient.getTrustRelations(resolved, limit));
|
|
29968
|
+
if (columnName) {
|
|
29969
|
+
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
29970
|
+
return dataTrust.map(obj =>
|
|
29971
|
+
Object.fromEntries(
|
|
29972
|
+
filterColumnName
|
|
29973
|
+
.filter(key => key in obj)
|
|
29974
|
+
.map(key => [key, obj[key]])
|
|
29975
|
+
)
|
|
29976
|
+
);
|
|
29977
|
+
} else {
|
|
29978
|
+
return dataTrust;
|
|
29979
|
+
}
|
|
29897
29980
|
|
|
29898
29981
|
case 'transactions':
|
|
29899
|
-
|
|
29982
|
+
const data = await runOnePage(dataClient.getTransactionHistory(resolved, limit));
|
|
29983
|
+
if (columnName) {
|
|
29984
|
+
const filterColumnName = columnName.split(',').map(s => s.trim());
|
|
29985
|
+
return data.map(obj =>
|
|
29986
|
+
Object.fromEntries(
|
|
29987
|
+
filterColumnName
|
|
29988
|
+
.filter(key => key in obj)
|
|
29989
|
+
.map(key => [key, obj[key]])
|
|
29990
|
+
)
|
|
29991
|
+
);
|
|
29992
|
+
} else {
|
|
29993
|
+
return data;
|
|
29994
|
+
}
|
|
29900
29995
|
|
|
29901
29996
|
case 'profile': {
|
|
29902
29997
|
const res = await dataClient.getAvatarInfo(resolved);
|