@fileverse-dev/formulajs 4.4.12-mod-5 → 4.4.12-mod-7
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 +510 -484
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +57 -29
- package/lib/esm/crypto-constants.mjs +28 -7
- package/lib/esm/index.mjs +57 -29
- package/package.json +1 -1
- package/types/cjs/index.d.cts +19 -1
- package/types/esm/index.d.mts +19 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -18524,7 +18524,7 @@ const activity = objectType({
|
|
|
18524
18524
|
});
|
|
18525
18525
|
|
|
18526
18526
|
const tokenHolders = objectType({
|
|
18527
|
-
type: literalType("
|
|
18527
|
+
type: literalType("token-holders"),
|
|
18528
18528
|
input1: stringType().nonempty(), // expects token address
|
|
18529
18529
|
input2: stringType().nonempty(), // chain id / name
|
|
18530
18530
|
input3: numberType().int().min(1).max(500).optional() // limit
|
|
@@ -18551,16 +18551,12 @@ function flattenObject(obj, parentKey = '', res = {}) {
|
|
|
18551
18551
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
18552
18552
|
const newKey = parentKey ? `${parentKey}_${key}` : key;
|
|
18553
18553
|
|
|
18554
|
-
if (typeof obj[key] === 'object' && obj[key] !== null
|
|
18555
|
-
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
} else {
|
|
18561
|
-
res[`${newKey}_${i}`] = val;
|
|
18562
|
-
}
|
|
18563
|
-
});
|
|
18554
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
18555
|
+
if (Array.isArray(obj[key])) {
|
|
18556
|
+
continue;
|
|
18557
|
+
} else {
|
|
18558
|
+
flattenObject(obj[key], newKey, res);
|
|
18559
|
+
}
|
|
18564
18560
|
} else {
|
|
18565
18561
|
res[newKey] = obj[key];
|
|
18566
18562
|
}
|
|
@@ -18584,6 +18580,22 @@ const SUPPORTED_TOKEN_NAMES = {
|
|
|
18584
18580
|
|
|
18585
18581
|
|
|
18586
18582
|
|
|
18583
|
+
function formatNumber(raw, decimals) {
|
|
18584
|
+
if(!decimals){
|
|
18585
|
+
return raw
|
|
18586
|
+
}
|
|
18587
|
+
const quorum = BigInt(raw);
|
|
18588
|
+
const divisor = 10 ** decimals;
|
|
18589
|
+
const normalized = Number(quorum) / divisor;
|
|
18590
|
+
|
|
18591
|
+
return new Intl.NumberFormat("en-US", {
|
|
18592
|
+
notation: "compact",
|
|
18593
|
+
maximumFractionDigits: 2,
|
|
18594
|
+
}).format(normalized);
|
|
18595
|
+
}
|
|
18596
|
+
|
|
18597
|
+
|
|
18598
|
+
|
|
18587
18599
|
async function DUNESIM() {
|
|
18588
18600
|
try {
|
|
18589
18601
|
const [type, input1, input2, input3, input4] = argsToArray(arguments);
|
|
@@ -18608,16 +18620,17 @@ async function DUNESIM() {
|
|
|
18608
18620
|
}
|
|
18609
18621
|
|
|
18610
18622
|
if (type === 'price') {
|
|
18611
|
-
const chain = SUPPORTED_TOKEN_NAMES[input1] ||
|
|
18623
|
+
const chain = SUPPORTED_TOKEN_NAMES[input1] || input1;
|
|
18612
18624
|
const qs = buildQuery([
|
|
18613
18625
|
['chain_ids', chain],
|
|
18614
|
-
['historical_prices',
|
|
18626
|
+
['historical_prices', input2],
|
|
18615
18627
|
['limit', input4],
|
|
18616
18628
|
]);
|
|
18617
|
-
|
|
18629
|
+
const tokenAddress = input3 || "native";
|
|
18630
|
+
route = `token-info/${tokenAddress}${qs}`;
|
|
18618
18631
|
}
|
|
18619
18632
|
|
|
18620
|
-
if (type === '
|
|
18633
|
+
if (type === 'token-holders') {
|
|
18621
18634
|
const qs = buildQuery([['limit', input3]]);
|
|
18622
18635
|
const chain = SUPPORTED_TOKEN_NAMES[input2] || input2;
|
|
18623
18636
|
route = `token-holders/${chain}/${input1}${qs}`;
|
|
@@ -18637,11 +18650,26 @@ async function DUNESIM() {
|
|
|
18637
18650
|
const json = await res.json();
|
|
18638
18651
|
const data =
|
|
18639
18652
|
type === "activity" ? json?.activity ?? json ?? [] :
|
|
18640
|
-
type === "
|
|
18653
|
+
type === "token-holders" ? json?.holders ?? json ?? [] :
|
|
18641
18654
|
type === "price" ? json?.tokens ?? json ?? [] :
|
|
18642
18655
|
json ?? [];
|
|
18643
|
-
const result = data.map((item) =>
|
|
18644
|
-
|
|
18656
|
+
const result = (Array.isArray(data) ? data : [data]).map((item) => {
|
|
18657
|
+
if(item?.decimals){
|
|
18658
|
+
if(item?.total_supply){
|
|
18659
|
+
item.total_supply = formatNumber(item?.total_supply, item.decimals);
|
|
18660
|
+
}
|
|
18661
|
+
}
|
|
18662
|
+
if(item?.first_acquired){
|
|
18663
|
+
item.first_acquired = new Intl.DateTimeFormat("en-US", {
|
|
18664
|
+
year: "numeric",
|
|
18665
|
+
month: "long",
|
|
18666
|
+
day: "numeric",
|
|
18667
|
+
hour: "numeric",
|
|
18668
|
+
minute: "2-digit"
|
|
18669
|
+
}).format(new Date(item.first_acquired));
|
|
18670
|
+
}
|
|
18671
|
+
return flattenObject(item)
|
|
18672
|
+
});
|
|
18645
18673
|
return result
|
|
18646
18674
|
} catch (err) {
|
|
18647
18675
|
return errorMessageHandler(err, "DUNESIM");
|
|
@@ -18649,19 +18677,19 @@ async function DUNESIM() {
|
|
|
18649
18677
|
}
|
|
18650
18678
|
|
|
18651
18679
|
|
|
18652
|
-
|
|
18653
|
-
//
|
|
18654
|
-
//
|
|
18655
|
-
//
|
|
18680
|
+
(async () => {
|
|
18681
|
+
// Example: activity
|
|
18682
|
+
// const res1 = await DUNESIM('activity', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', "eth", 5);
|
|
18683
|
+
// console.log('Activity result:', res1, res1.length);
|
|
18656
18684
|
|
|
18657
|
-
//
|
|
18658
|
-
//
|
|
18659
|
-
//
|
|
18685
|
+
// Example: price (token-info)
|
|
18686
|
+
// const res2 = await DUNESIM('price', 'base', '1,6,24', "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", 5);
|
|
18687
|
+
// console.log('Price result:', res2);
|
|
18660
18688
|
|
|
18661
|
-
//
|
|
18662
|
-
//
|
|
18663
|
-
//
|
|
18664
|
-
|
|
18689
|
+
// // Example: token holders
|
|
18690
|
+
// const res3 = await DUNESIM('token-holders', '0x63706e401c06ac8513145b7687A14804d17f814b', "base", 5);
|
|
18691
|
+
// console.log('Holders result:', res3, res3.length);
|
|
18692
|
+
})();
|
|
18665
18693
|
|
|
18666
18694
|
// export {GNOSISPAY} from './gnosispay/gnosispay.js'
|
|
18667
18695
|
|
|
@@ -883,22 +883,43 @@ var DUNESIM_metadata = {
|
|
|
883
883
|
BRAND_SECONDARY_COLOR: "#f9ab99",
|
|
884
884
|
n: "DUNESIM",
|
|
885
885
|
t: 20,
|
|
886
|
-
d: "Query Sim APIs for blockchain activity and
|
|
887
|
-
a: "Query Sim APIs for blockchain activity and
|
|
886
|
+
d: "Query Sim APIs for blockchain activity, token prices, and token-holder data.",
|
|
887
|
+
a: "Query Sim APIs for blockchain activity, token prices, and token-holder data.",
|
|
888
888
|
p: [
|
|
889
889
|
{
|
|
890
890
|
name: "type",
|
|
891
|
-
detail: "
|
|
892
|
-
example: `"
|
|
891
|
+
detail: "Specify \u201Cprice\u201D to query token price info, \u201Cactivity\u201D for wallet activity, or \u201Ctoken_holders\u201D for token-holder distribution.",
|
|
892
|
+
example: `"price"`,
|
|
893
893
|
require: "m",
|
|
894
894
|
type: "string"
|
|
895
895
|
},
|
|
896
896
|
{
|
|
897
|
-
name: "
|
|
898
|
-
detail: "
|
|
899
|
-
example: `"
|
|
897
|
+
name: "input1",
|
|
898
|
+
detail: 'When type is "price": the chain ID or name to query token prices. When "activity": wallet address or ENS. When "token-holders": token address.',
|
|
899
|
+
example: `"base"`,
|
|
900
900
|
require: "m",
|
|
901
901
|
type: "string"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
name: "input2",
|
|
905
|
+
detail: 'When "price": optional historical price offsets. When "activity": optional chain ID or name ( e.g eth ). When "token-holders": chain ID or name ( e.g eth ).',
|
|
906
|
+
example: `"1,6,24"`,
|
|
907
|
+
require: "o",
|
|
908
|
+
type: "string"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
name: "input3",
|
|
912
|
+
detail: 'When "price": optional token contract address, when "activity": limit (1\u2013100), when "token-holders": limit (1\u2013500).',
|
|
913
|
+
example: `"0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca"`,
|
|
914
|
+
require: "o",
|
|
915
|
+
type: "number"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
name: "input4",
|
|
919
|
+
detail: 'When "price": optional limit for results.',
|
|
920
|
+
example: `5`,
|
|
921
|
+
require: "o",
|
|
922
|
+
type: "number"
|
|
902
923
|
}
|
|
903
924
|
]
|
|
904
925
|
};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -18522,7 +18522,7 @@ const activity = objectType({
|
|
|
18522
18522
|
});
|
|
18523
18523
|
|
|
18524
18524
|
const tokenHolders = objectType({
|
|
18525
|
-
type: literalType("
|
|
18525
|
+
type: literalType("token-holders"),
|
|
18526
18526
|
input1: stringType().nonempty(), // expects token address
|
|
18527
18527
|
input2: stringType().nonempty(), // chain id / name
|
|
18528
18528
|
input3: numberType().int().min(1).max(500).optional() // limit
|
|
@@ -18549,16 +18549,12 @@ function flattenObject(obj, parentKey = '', res = {}) {
|
|
|
18549
18549
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
18550
18550
|
const newKey = parentKey ? `${parentKey}_${key}` : key;
|
|
18551
18551
|
|
|
18552
|
-
if (typeof obj[key] === 'object' && obj[key] !== null
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
} else {
|
|
18559
|
-
res[`${newKey}_${i}`] = val;
|
|
18560
|
-
}
|
|
18561
|
-
});
|
|
18552
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
18553
|
+
if (Array.isArray(obj[key])) {
|
|
18554
|
+
continue;
|
|
18555
|
+
} else {
|
|
18556
|
+
flattenObject(obj[key], newKey, res);
|
|
18557
|
+
}
|
|
18562
18558
|
} else {
|
|
18563
18559
|
res[newKey] = obj[key];
|
|
18564
18560
|
}
|
|
@@ -18582,6 +18578,22 @@ const SUPPORTED_TOKEN_NAMES = {
|
|
|
18582
18578
|
|
|
18583
18579
|
|
|
18584
18580
|
|
|
18581
|
+
function formatNumber(raw, decimals) {
|
|
18582
|
+
if(!decimals){
|
|
18583
|
+
return raw
|
|
18584
|
+
}
|
|
18585
|
+
const quorum = BigInt(raw);
|
|
18586
|
+
const divisor = 10 ** decimals;
|
|
18587
|
+
const normalized = Number(quorum) / divisor;
|
|
18588
|
+
|
|
18589
|
+
return new Intl.NumberFormat("en-US", {
|
|
18590
|
+
notation: "compact",
|
|
18591
|
+
maximumFractionDigits: 2,
|
|
18592
|
+
}).format(normalized);
|
|
18593
|
+
}
|
|
18594
|
+
|
|
18595
|
+
|
|
18596
|
+
|
|
18585
18597
|
async function DUNESIM() {
|
|
18586
18598
|
try {
|
|
18587
18599
|
const [type, input1, input2, input3, input4] = argsToArray(arguments);
|
|
@@ -18606,16 +18618,17 @@ async function DUNESIM() {
|
|
|
18606
18618
|
}
|
|
18607
18619
|
|
|
18608
18620
|
if (type === 'price') {
|
|
18609
|
-
const chain = SUPPORTED_TOKEN_NAMES[input1] ||
|
|
18621
|
+
const chain = SUPPORTED_TOKEN_NAMES[input1] || input1;
|
|
18610
18622
|
const qs = buildQuery([
|
|
18611
18623
|
['chain_ids', chain],
|
|
18612
|
-
['historical_prices',
|
|
18624
|
+
['historical_prices', input2],
|
|
18613
18625
|
['limit', input4],
|
|
18614
18626
|
]);
|
|
18615
|
-
|
|
18627
|
+
const tokenAddress = input3 || "native";
|
|
18628
|
+
route = `token-info/${tokenAddress}${qs}`;
|
|
18616
18629
|
}
|
|
18617
18630
|
|
|
18618
|
-
if (type === '
|
|
18631
|
+
if (type === 'token-holders') {
|
|
18619
18632
|
const qs = buildQuery([['limit', input3]]);
|
|
18620
18633
|
const chain = SUPPORTED_TOKEN_NAMES[input2] || input2;
|
|
18621
18634
|
route = `token-holders/${chain}/${input1}${qs}`;
|
|
@@ -18635,11 +18648,26 @@ async function DUNESIM() {
|
|
|
18635
18648
|
const json = await res.json();
|
|
18636
18649
|
const data =
|
|
18637
18650
|
type === "activity" ? json?.activity ?? json ?? [] :
|
|
18638
|
-
type === "
|
|
18651
|
+
type === "token-holders" ? json?.holders ?? json ?? [] :
|
|
18639
18652
|
type === "price" ? json?.tokens ?? json ?? [] :
|
|
18640
18653
|
json ?? [];
|
|
18641
|
-
const result = data.map((item) =>
|
|
18642
|
-
|
|
18654
|
+
const result = (Array.isArray(data) ? data : [data]).map((item) => {
|
|
18655
|
+
if(item?.decimals){
|
|
18656
|
+
if(item?.total_supply){
|
|
18657
|
+
item.total_supply = formatNumber(item?.total_supply, item.decimals);
|
|
18658
|
+
}
|
|
18659
|
+
}
|
|
18660
|
+
if(item?.first_acquired){
|
|
18661
|
+
item.first_acquired = new Intl.DateTimeFormat("en-US", {
|
|
18662
|
+
year: "numeric",
|
|
18663
|
+
month: "long",
|
|
18664
|
+
day: "numeric",
|
|
18665
|
+
hour: "numeric",
|
|
18666
|
+
minute: "2-digit"
|
|
18667
|
+
}).format(new Date(item.first_acquired));
|
|
18668
|
+
}
|
|
18669
|
+
return flattenObject(item)
|
|
18670
|
+
});
|
|
18643
18671
|
return result
|
|
18644
18672
|
} catch (err) {
|
|
18645
18673
|
return errorMessageHandler(err, "DUNESIM");
|
|
@@ -18647,19 +18675,19 @@ async function DUNESIM() {
|
|
|
18647
18675
|
}
|
|
18648
18676
|
|
|
18649
18677
|
|
|
18650
|
-
|
|
18651
|
-
//
|
|
18652
|
-
//
|
|
18653
|
-
//
|
|
18678
|
+
(async () => {
|
|
18679
|
+
// Example: activity
|
|
18680
|
+
// const res1 = await DUNESIM('activity', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', "eth", 5);
|
|
18681
|
+
// console.log('Activity result:', res1, res1.length);
|
|
18654
18682
|
|
|
18655
|
-
//
|
|
18656
|
-
//
|
|
18657
|
-
//
|
|
18683
|
+
// Example: price (token-info)
|
|
18684
|
+
// const res2 = await DUNESIM('price', 'base', '1,6,24', "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", 5);
|
|
18685
|
+
// console.log('Price result:', res2);
|
|
18658
18686
|
|
|
18659
|
-
//
|
|
18660
|
-
//
|
|
18661
|
-
//
|
|
18662
|
-
|
|
18687
|
+
// // Example: token holders
|
|
18688
|
+
// const res3 = await DUNESIM('token-holders', '0x63706e401c06ac8513145b7687A14804d17f814b', "base", 5);
|
|
18689
|
+
// console.log('Holders result:', res3, res3.length);
|
|
18690
|
+
})();
|
|
18663
18691
|
|
|
18664
18692
|
// export {GNOSISPAY} from './gnosispay/gnosispay.js'
|
|
18665
18693
|
|
package/package.json
CHANGED
package/types/cjs/index.d.cts
CHANGED
|
@@ -1292,7 +1292,25 @@ export function DSTDEVP(database: any, field: any, criteria: any): number | Erro
|
|
|
1292
1292
|
* @returns
|
|
1293
1293
|
*/
|
|
1294
1294
|
export function DSUM(database: any, field: any, criteria: any): number | Error;
|
|
1295
|
-
export function DUNESIM(...args: any[]): Promise<
|
|
1295
|
+
export function DUNESIM(...args: any[]): Promise<{
|
|
1296
|
+
message: string;
|
|
1297
|
+
functionName: any;
|
|
1298
|
+
type: string;
|
|
1299
|
+
apiKeyName?: undefined;
|
|
1300
|
+
reason?: undefined;
|
|
1301
|
+
} | {
|
|
1302
|
+
message: string;
|
|
1303
|
+
functionName: any;
|
|
1304
|
+
type: string;
|
|
1305
|
+
apiKeyName: any;
|
|
1306
|
+
reason?: undefined;
|
|
1307
|
+
} | {
|
|
1308
|
+
message: string;
|
|
1309
|
+
functionName: any;
|
|
1310
|
+
type: string;
|
|
1311
|
+
reason: any;
|
|
1312
|
+
apiKeyName?: undefined;
|
|
1313
|
+
} | {}[]>;
|
|
1296
1314
|
/**
|
|
1297
1315
|
* Estimates variance based on a sample from selected database entries.
|
|
1298
1316
|
*
|
package/types/esm/index.d.mts
CHANGED
|
@@ -1292,7 +1292,25 @@ export function DSTDEVP(database: any, field: any, criteria: any): number | Erro
|
|
|
1292
1292
|
* @returns
|
|
1293
1293
|
*/
|
|
1294
1294
|
export function DSUM(database: any, field: any, criteria: any): number | Error;
|
|
1295
|
-
export function DUNESIM(...args: any[]): Promise<
|
|
1295
|
+
export function DUNESIM(...args: any[]): Promise<{
|
|
1296
|
+
message: string;
|
|
1297
|
+
functionName: any;
|
|
1298
|
+
type: string;
|
|
1299
|
+
apiKeyName?: undefined;
|
|
1300
|
+
reason?: undefined;
|
|
1301
|
+
} | {
|
|
1302
|
+
message: string;
|
|
1303
|
+
functionName: any;
|
|
1304
|
+
type: string;
|
|
1305
|
+
apiKeyName: any;
|
|
1306
|
+
reason?: undefined;
|
|
1307
|
+
} | {
|
|
1308
|
+
message: string;
|
|
1309
|
+
functionName: any;
|
|
1310
|
+
type: string;
|
|
1311
|
+
reason: any;
|
|
1312
|
+
apiKeyName?: undefined;
|
|
1313
|
+
} | {}[]>;
|
|
1296
1314
|
/**
|
|
1297
1315
|
* Estimates variance based on a sample from selected database entries.
|
|
1298
1316
|
*
|