@fileverse-dev/formulajs 4.4.12-mod-6 → 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 +518 -488
- package/lib/browser/formula.min.js +2 -2
- package/lib/browser/formula.min.js.map +1 -1
- package/lib/cjs/index.cjs +47 -22
- package/lib/esm/crypto-constants.mjs +4 -4
- package/lib/esm/index.mjs +47 -22
- 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);
|
|
@@ -18602,7 +18614,7 @@ async function DUNESIM() {
|
|
|
18602
18614
|
};
|
|
18603
18615
|
|
|
18604
18616
|
if (type === 'activity') {
|
|
18605
|
-
const address = fromEnsNameToAddress$1.validateAndGetAddress(input1);
|
|
18617
|
+
const address = await fromEnsNameToAddress$1.validateAndGetAddress(input1);
|
|
18606
18618
|
const qs = buildQuery([['chain_ids', SUPPORTED_TOKEN_NAMES[input2] || input2], ['limit', input3]]);
|
|
18607
18619
|
route = `activity/${address}${qs}`;
|
|
18608
18620
|
}
|
|
@@ -18618,7 +18630,7 @@ async function DUNESIM() {
|
|
|
18618
18630
|
route = `token-info/${tokenAddress}${qs}`;
|
|
18619
18631
|
}
|
|
18620
18632
|
|
|
18621
|
-
if (type === '
|
|
18633
|
+
if (type === 'token-holders') {
|
|
18622
18634
|
const qs = buildQuery([['limit', input3]]);
|
|
18623
18635
|
const chain = SUPPORTED_TOKEN_NAMES[input2] || input2;
|
|
18624
18636
|
route = `token-holders/${chain}/${input1}${qs}`;
|
|
@@ -18627,8 +18639,6 @@ async function DUNESIM() {
|
|
|
18627
18639
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.DuneSim);
|
|
18628
18640
|
const url = `https://api.sim.dune.com/v1/evm/${route}`;
|
|
18629
18641
|
|
|
18630
|
-
console.log({route});
|
|
18631
|
-
|
|
18632
18642
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
|
|
18633
18643
|
url, serviceName: "DuneSim",
|
|
18634
18644
|
headers: { "X-Sim-Api-Key": apiKey },
|
|
@@ -18640,11 +18650,26 @@ async function DUNESIM() {
|
|
|
18640
18650
|
const json = await res.json();
|
|
18641
18651
|
const data =
|
|
18642
18652
|
type === "activity" ? json?.activity ?? json ?? [] :
|
|
18643
|
-
type === "
|
|
18653
|
+
type === "token-holders" ? json?.holders ?? json ?? [] :
|
|
18644
18654
|
type === "price" ? json?.tokens ?? json ?? [] :
|
|
18645
18655
|
json ?? [];
|
|
18646
|
-
const result = data.map((item) =>
|
|
18647
|
-
|
|
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
|
+
});
|
|
18648
18673
|
return result
|
|
18649
18674
|
} catch (err) {
|
|
18650
18675
|
return errorMessageHandler(err, "DUNESIM");
|
|
@@ -18652,19 +18677,19 @@ async function DUNESIM() {
|
|
|
18652
18677
|
}
|
|
18653
18678
|
|
|
18654
18679
|
|
|
18655
|
-
|
|
18680
|
+
(async () => {
|
|
18656
18681
|
// Example: activity
|
|
18657
18682
|
// const res1 = await DUNESIM('activity', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', "eth", 5);
|
|
18658
18683
|
// console.log('Activity result:', res1, res1.length);
|
|
18659
18684
|
|
|
18660
|
-
//
|
|
18685
|
+
// Example: price (token-info)
|
|
18661
18686
|
// const res2 = await DUNESIM('price', 'base', '1,6,24', "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", 5);
|
|
18662
18687
|
// console.log('Price result:', res2);
|
|
18663
18688
|
|
|
18664
18689
|
// // Example: token holders
|
|
18665
|
-
// const res3 = await DUNESIM('
|
|
18690
|
+
// const res3 = await DUNESIM('token-holders', '0x63706e401c06ac8513145b7687A14804d17f814b', "base", 5);
|
|
18666
18691
|
// console.log('Holders result:', res3, res3.length);
|
|
18667
|
-
|
|
18692
|
+
})();
|
|
18668
18693
|
|
|
18669
18694
|
// export {GNOSISPAY} from './gnosispay/gnosispay.js'
|
|
18670
18695
|
|
|
@@ -895,21 +895,21 @@ var DUNESIM_metadata = {
|
|
|
895
895
|
},
|
|
896
896
|
{
|
|
897
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 "
|
|
899
|
-
example: "base"
|
|
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
902
|
},
|
|
903
903
|
{
|
|
904
904
|
name: "input2",
|
|
905
|
-
detail: 'When "price": optional historical price offsets. When "activity": optional chain ID or name ( e.g eth ). When "
|
|
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
906
|
example: `"1,6,24"`,
|
|
907
907
|
require: "o",
|
|
908
908
|
type: "string"
|
|
909
909
|
},
|
|
910
910
|
{
|
|
911
911
|
name: "input3",
|
|
912
|
-
detail: 'When "price": optional token contract address, when "activity": limit (1\u2013100), when "
|
|
912
|
+
detail: 'When "price": optional token contract address, when "activity": limit (1\u2013100), when "token-holders": limit (1\u2013500).',
|
|
913
913
|
example: `"0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca"`,
|
|
914
914
|
require: "o",
|
|
915
915
|
type: "number"
|
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);
|
|
@@ -18600,7 +18612,7 @@ async function DUNESIM() {
|
|
|
18600
18612
|
};
|
|
18601
18613
|
|
|
18602
18614
|
if (type === 'activity') {
|
|
18603
|
-
const address = fromEnsNameToAddress$1.validateAndGetAddress(input1);
|
|
18615
|
+
const address = await fromEnsNameToAddress$1.validateAndGetAddress(input1);
|
|
18604
18616
|
const qs = buildQuery([['chain_ids', SUPPORTED_TOKEN_NAMES[input2] || input2], ['limit', input3]]);
|
|
18605
18617
|
route = `activity/${address}${qs}`;
|
|
18606
18618
|
}
|
|
@@ -18616,7 +18628,7 @@ async function DUNESIM() {
|
|
|
18616
18628
|
route = `token-info/${tokenAddress}${qs}`;
|
|
18617
18629
|
}
|
|
18618
18630
|
|
|
18619
|
-
if (type === '
|
|
18631
|
+
if (type === 'token-holders') {
|
|
18620
18632
|
const qs = buildQuery([['limit', input3]]);
|
|
18621
18633
|
const chain = SUPPORTED_TOKEN_NAMES[input2] || input2;
|
|
18622
18634
|
route = `token-holders/${chain}/${input1}${qs}`;
|
|
@@ -18625,8 +18637,6 @@ async function DUNESIM() {
|
|
|
18625
18637
|
const apiKey = window.localStorage.getItem(SERVICES_API_KEY.DuneSim);
|
|
18626
18638
|
const url = `https://api.sim.dune.com/v1/evm/${route}`;
|
|
18627
18639
|
|
|
18628
|
-
console.log({route});
|
|
18629
|
-
|
|
18630
18640
|
const { URL: finalUrl, HEADERS } = getUrlAndHeaders({
|
|
18631
18641
|
url, serviceName: "DuneSim",
|
|
18632
18642
|
headers: { "X-Sim-Api-Key": apiKey },
|
|
@@ -18638,11 +18648,26 @@ async function DUNESIM() {
|
|
|
18638
18648
|
const json = await res.json();
|
|
18639
18649
|
const data =
|
|
18640
18650
|
type === "activity" ? json?.activity ?? json ?? [] :
|
|
18641
|
-
type === "
|
|
18651
|
+
type === "token-holders" ? json?.holders ?? json ?? [] :
|
|
18642
18652
|
type === "price" ? json?.tokens ?? json ?? [] :
|
|
18643
18653
|
json ?? [];
|
|
18644
|
-
const result = data.map((item) =>
|
|
18645
|
-
|
|
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
|
+
});
|
|
18646
18671
|
return result
|
|
18647
18672
|
} catch (err) {
|
|
18648
18673
|
return errorMessageHandler(err, "DUNESIM");
|
|
@@ -18650,19 +18675,19 @@ async function DUNESIM() {
|
|
|
18650
18675
|
}
|
|
18651
18676
|
|
|
18652
18677
|
|
|
18653
|
-
|
|
18678
|
+
(async () => {
|
|
18654
18679
|
// Example: activity
|
|
18655
18680
|
// const res1 = await DUNESIM('activity', '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', "eth", 5);
|
|
18656
18681
|
// console.log('Activity result:', res1, res1.length);
|
|
18657
18682
|
|
|
18658
|
-
//
|
|
18683
|
+
// Example: price (token-info)
|
|
18659
18684
|
// const res2 = await DUNESIM('price', 'base', '1,6,24', "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", 5);
|
|
18660
18685
|
// console.log('Price result:', res2);
|
|
18661
18686
|
|
|
18662
18687
|
// // Example: token holders
|
|
18663
|
-
// const res3 = await DUNESIM('
|
|
18688
|
+
// const res3 = await DUNESIM('token-holders', '0x63706e401c06ac8513145b7687A14804d17f814b', "base", 5);
|
|
18664
18689
|
// console.log('Holders result:', res3, res3.length);
|
|
18665
|
-
|
|
18690
|
+
})();
|
|
18666
18691
|
|
|
18667
18692
|
// export {GNOSISPAY} from './gnosispay/gnosispay.js'
|
|
18668
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
|
*
|