@fileverse-dev/formulajs 4.4.11-mod-8 → 4.4.11-mod-9

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/cjs/index.cjs CHANGED
@@ -12950,74 +12950,72 @@ function SWITCH() {
12950
12950
  }
12951
12951
 
12952
12952
  const SERVICE_API_KEY = {
12953
- Etherscan: "ETHERSCAN_API_KEY",
12954
- Coingecko: "COINGECKO_API_KEY"
12953
+ Etherscan: "ETHERSCAN_API_KEY",
12954
+ Coingecko: "COINGECKO_API_KEY"
12955
12955
  };
12956
12956
 
12957
12957
  async function GETTXLIST(address, page, offset) {
12958
- const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
12959
- console.log("FORMULA JS API KEY ETHERSCAN NOT FOUND", API_KEY);
12960
- const url = `https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=${page}&offset=${offset}&sort=asc&apikey=${API_KEY}`;
12961
-
12962
- try {
12963
- const response = await fetch(url);
12964
- if (!response.ok) {
12965
- throw new Error(`HTTP error! Status: ${response.status}`)
12966
- }
12967
- const json = await response.json();
12968
- console.log(json.result);
12969
- if(json.result.includes("Invalid API Key")){
12970
- return `${SERVICE_API_KEY.Etherscan}_MISSING`
12971
- }
12972
- return json.result;
12973
- } catch (error) {
12974
- console.error('API call failed:', error);
12975
- return "ERROR IN FETCHING"
12976
- }
12977
- }
12978
-
12979
- async function GETPRICE(token, vs_currencies, offset) {
12980
- const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Coingecko);
12981
- console.log("FORMULA JS API KEY ETHERSCAN NOT FOUND", API_KEY);
12982
- // const url = 'https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids=bitcoin';
12983
- const url = `https://api.coingecko.com/api/v3/simple/price?vs_currencies=${vs_currencies}&ids=${token}`;
12984
-
12985
- try {
12986
- const response = await fetch(url);
12987
- if (!response.ok) {
12988
- throw new Error(`HTTP error! Status: ${response.status}`)
12989
- }
12990
- const jsonResponse = await response.json();
12991
- //JSON RESPONSE EXAMPLE
12992
- // {
12993
- // "bitcoin": {
12994
- // "usd": 103457,
12995
- // "inr": 8854165
12996
- // },
12997
- // "solana": {
12998
- // "usd": 167.56,
12999
- // "inr": 14340.55
13000
- // }
13001
- // }
13002
- console.log(jsonResponse);
13003
- // if(jsonResponse.result.includes("Invalid API Key")){
13004
- // return `${SERVICE_API_KEY.Coingecko}_MISSING`
13005
- // }
13006
- const output = {};
13007
-
13008
- for (const [coin, prices] of Object.entries(jsonResponse)) {
13009
- for (const [currency, value] of Object.entries(prices)) {
13010
- const key = `${coin.charAt(0).toUpperCase() + coin.slice(1)}_${currency.toUpperCase()}`;
13011
- output[key] = value;
12958
+ const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
12959
+ const url = `https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=${page}&offset=${offset}&sort=asc&apikey=${API_KEY}`;
12960
+
12961
+ try {
12962
+ const response = await fetch(url);
12963
+ if (!response.ok) {
12964
+ throw new Error(`HTTP error! Status: ${response.status}`)
12965
+ }
12966
+ const json = await response.json();
12967
+ if (json.result.includes("Invalid API Key")) {
12968
+ return `${SERVICE_API_KEY.Etherscan}_MISSING`
12969
+ }
12970
+ return json.result;
12971
+ } catch (error) {
12972
+ return "ERROR IN FETCHING"
12973
+ }
12974
+ }
12975
+
12976
+ async function GETPRICE(token, vs_currencies) {
12977
+ const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Coingecko);
12978
+ const url = `https://api.coingecko.com/api/v3/simple/price?vs_currencies=${vs_currencies}&ids=${token}`;
12979
+
12980
+ const options = {
12981
+ method: 'GET',
12982
+ headers: { accept: 'application/json', 'x-cg-demo-api-key': `${API_KEY}` },
12983
+ };
12984
+
12985
+ try {
12986
+ const response = await fetch(url, options);
12987
+ if (!response.ok) {
12988
+ throw new Error(`HTTP error! Status: ${response.status}`)
12989
+ }
12990
+ const jsonResponse = await response.json();
12991
+ /*
12992
+ JSON RESPONSE EXAMPLE
12993
+ {
12994
+ "bitcoin": {
12995
+ "usd": 103457,
12996
+ "inr": 8854165
12997
+ },
12998
+ "solana": {
12999
+ "usd": 167.56,
13000
+ "inr": 14340.55
13012
13001
  }
13002
+ }
13003
+ */
13004
+
13005
+ // Free Coingecko API does not require API key, not need to handle API key error
13006
+
13007
+ const output = {};
13008
+ for (const [coin, prices] of Object.entries(jsonResponse)) {
13009
+ for (const [currency, value] of Object.entries(prices)) {
13010
+ const key = `${coin.charAt(0).toUpperCase() + coin.slice(1)}_${currency.toUpperCase()}`;
13011
+ output[key] = value;
13013
13012
  }
13014
- console.log([output]);
13015
- return [output];
13016
- } catch (error) {
13017
- console.error('API call failed:', error);
13018
- return "ERROR IN FETCHING"
13019
13013
  }
13014
+ return [output];
13015
+ } catch (error) {
13016
+ return "ERROR IN FETCHING"
13020
13017
  }
13018
+ }
13021
13019
 
13022
13020
  const utils = { errors, symbols, date };
13023
13021
 
package/lib/esm/index.mjs CHANGED
@@ -12948,74 +12948,72 @@ function SWITCH() {
12948
12948
  }
12949
12949
 
12950
12950
  const SERVICE_API_KEY = {
12951
- Etherscan: "ETHERSCAN_API_KEY",
12952
- Coingecko: "COINGECKO_API_KEY"
12951
+ Etherscan: "ETHERSCAN_API_KEY",
12952
+ Coingecko: "COINGECKO_API_KEY"
12953
12953
  };
12954
12954
 
12955
12955
  async function GETTXLIST(address, page, offset) {
12956
- const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
12957
- console.log("FORMULA JS API KEY ETHERSCAN NOT FOUND", API_KEY);
12958
- const url = `https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=${page}&offset=${offset}&sort=asc&apikey=${API_KEY}`;
12959
-
12960
- try {
12961
- const response = await fetch(url);
12962
- if (!response.ok) {
12963
- throw new Error(`HTTP error! Status: ${response.status}`)
12964
- }
12965
- const json = await response.json();
12966
- console.log(json.result);
12967
- if(json.result.includes("Invalid API Key")){
12968
- return `${SERVICE_API_KEY.Etherscan}_MISSING`
12969
- }
12970
- return json.result;
12971
- } catch (error) {
12972
- console.error('API call failed:', error);
12973
- return "ERROR IN FETCHING"
12974
- }
12975
- }
12976
-
12977
- async function GETPRICE(token, vs_currencies, offset) {
12978
- const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Coingecko);
12979
- console.log("FORMULA JS API KEY ETHERSCAN NOT FOUND", API_KEY);
12980
- // const url = 'https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids=bitcoin';
12981
- const url = `https://api.coingecko.com/api/v3/simple/price?vs_currencies=${vs_currencies}&ids=${token}`;
12982
-
12983
- try {
12984
- const response = await fetch(url);
12985
- if (!response.ok) {
12986
- throw new Error(`HTTP error! Status: ${response.status}`)
12987
- }
12988
- const jsonResponse = await response.json();
12989
- //JSON RESPONSE EXAMPLE
12990
- // {
12991
- // "bitcoin": {
12992
- // "usd": 103457,
12993
- // "inr": 8854165
12994
- // },
12995
- // "solana": {
12996
- // "usd": 167.56,
12997
- // "inr": 14340.55
12998
- // }
12999
- // }
13000
- console.log(jsonResponse);
13001
- // if(jsonResponse.result.includes("Invalid API Key")){
13002
- // return `${SERVICE_API_KEY.Coingecko}_MISSING`
13003
- // }
13004
- const output = {};
13005
-
13006
- for (const [coin, prices] of Object.entries(jsonResponse)) {
13007
- for (const [currency, value] of Object.entries(prices)) {
13008
- const key = `${coin.charAt(0).toUpperCase() + coin.slice(1)}_${currency.toUpperCase()}`;
13009
- output[key] = value;
12956
+ const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Etherscan);
12957
+ const url = `https://api.etherscan.io/api?module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&page=${page}&offset=${offset}&sort=asc&apikey=${API_KEY}`;
12958
+
12959
+ try {
12960
+ const response = await fetch(url);
12961
+ if (!response.ok) {
12962
+ throw new Error(`HTTP error! Status: ${response.status}`)
12963
+ }
12964
+ const json = await response.json();
12965
+ if (json.result.includes("Invalid API Key")) {
12966
+ return `${SERVICE_API_KEY.Etherscan}_MISSING`
12967
+ }
12968
+ return json.result;
12969
+ } catch (error) {
12970
+ return "ERROR IN FETCHING"
12971
+ }
12972
+ }
12973
+
12974
+ async function GETPRICE(token, vs_currencies) {
12975
+ const API_KEY = window.localStorage.getItem(SERVICE_API_KEY.Coingecko);
12976
+ const url = `https://api.coingecko.com/api/v3/simple/price?vs_currencies=${vs_currencies}&ids=${token}`;
12977
+
12978
+ const options = {
12979
+ method: 'GET',
12980
+ headers: { accept: 'application/json', 'x-cg-demo-api-key': `${API_KEY}` },
12981
+ };
12982
+
12983
+ try {
12984
+ const response = await fetch(url, options);
12985
+ if (!response.ok) {
12986
+ throw new Error(`HTTP error! Status: ${response.status}`)
12987
+ }
12988
+ const jsonResponse = await response.json();
12989
+ /*
12990
+ JSON RESPONSE EXAMPLE
12991
+ {
12992
+ "bitcoin": {
12993
+ "usd": 103457,
12994
+ "inr": 8854165
12995
+ },
12996
+ "solana": {
12997
+ "usd": 167.56,
12998
+ "inr": 14340.55
13010
12999
  }
13000
+ }
13001
+ */
13002
+
13003
+ // Free Coingecko API does not require API key, not need to handle API key error
13004
+
13005
+ const output = {};
13006
+ for (const [coin, prices] of Object.entries(jsonResponse)) {
13007
+ for (const [currency, value] of Object.entries(prices)) {
13008
+ const key = `${coin.charAt(0).toUpperCase() + coin.slice(1)}_${currency.toUpperCase()}`;
13009
+ output[key] = value;
13011
13010
  }
13012
- console.log([output]);
13013
- return [output];
13014
- } catch (error) {
13015
- console.error('API call failed:', error);
13016
- return "ERROR IN FETCHING"
13017
13011
  }
13012
+ return [output];
13013
+ } catch (error) {
13014
+ return "ERROR IN FETCHING"
13018
13015
  }
13016
+ }
13019
13017
 
13020
13018
  const utils = { errors, symbols, date };
13021
13019
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/formulajs",
3
- "version": "4.4.11-mod-8",
3
+ "version": "4.4.11-mod-9",
4
4
  "description": "JavaScript implementation of most Microsoft Excel formula functions",
5
5
  "author": "Formulajs",
6
6
  "publishConfig": {
@@ -1784,7 +1784,7 @@ export function GEOMEAN(...args: any[]): any;
1784
1784
  * @returns
1785
1785
  */
1786
1786
  export function GESTEP(number: any, step: any): any;
1787
- export function GETPRICE(token: any, vs_currencies: any, offset: any): Promise<"ERROR IN FETCHING" | {}[]>;
1787
+ export function GETPRICE(token: any, vs_currencies: any): Promise<"ERROR IN FETCHING" | {}[]>;
1788
1788
  export function GETTXLIST(address: any, page: any, offset: any): Promise<any>;
1789
1789
  /**
1790
1790
  * Returns values along an exponential trend.
@@ -1784,7 +1784,7 @@ export function GEOMEAN(...args: any[]): any;
1784
1784
  * @returns
1785
1785
  */
1786
1786
  export function GESTEP(number: any, step: any): any;
1787
- export function GETPRICE(token: any, vs_currencies: any, offset: any): Promise<"ERROR IN FETCHING" | {}[]>;
1787
+ export function GETPRICE(token: any, vs_currencies: any): Promise<"ERROR IN FETCHING" | {}[]>;
1788
1788
  export function GETTXLIST(address: any, page: any, offset: any): Promise<any>;
1789
1789
  /**
1790
1790
  * Returns values along an exponential trend.