@imtbl/cryptofiat 2.0.0-alpha.1 → 2.0.0-alpha.10

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.
@@ -1,2 +1,6 @@
1
- import {Environment}from'@imtbl/config';import h from'axios';var p=class{baseConfig;constructor({baseConfig:t}){this.baseConfig=t;}};var y={[Environment.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[Environment.PRODUCTION]:"https://checkout-api.immutable.com"},w="usd",l=class{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig;}urlWithPath(t){return y[this.config.environment]+t}async fetchOverrides(){if(this.overridesCache!==null)return;let t=this.urlWithPath("/v1/fiat/coins/overrides"),r=await h.get(t);if(r.status!==200)throw new Error(`Error fetching coins overrides: ${r.status} ${r.statusText}`);this.overridesCache=new Map(Object.entries(r.data));}async fetchCoins(){if(this.coinsCache!==null)return;await this.fetchOverrides();let t=this.urlWithPath("/v1/fiat/coins/all"),r=await h.get(t);if(r.status!==200)throw new Error(`Error fetching coins list: ${r.status} ${r.statusText}`);let{data:i}=r;this.coinsCache=new Map;for(let e of i){let n=this.overridesCache.get(e.symbol.toLowerCase());this.coinsCache.set(e.symbol.toLowerCase(),n||e.id.toLowerCase());}}async convert({tokenSymbols:t,fiatSymbols:r=[]}){if(!t||t.length===0)throw new Error("Error missing token symbols to convert");let i=r.filter(o=>o!=="");i.length===0&&i.push(w),await this.fetchCoins();let e=t.map(o=>this.coinsCache.get(o.toLowerCase())).filter(o=>o!==""&&o!==void 0).join(","),n=i.join(",").toLowerCase(),v=this.urlWithPath(`/v1/fiat/conversion?ids=${e}&currencies=${n}`),s=await h.get(v);if(s.status!==200)throw new Error(`Error fetching prices: ${s.status} ${s.statusText}`);let{data:d}=s,a={};for(let o of t){let c=o.toLowerCase(),f=this.coinsCache.get(c);a[c]={},f&&(a[c]=d[f]||{});}return a}};
2
- export{l as CryptoFiat,p as CryptoFiatConfiguration};
1
+ import { Environment } from '@imtbl/config';
2
+ import h from 'axios';
3
+
4
+ var p=class{baseConfig;constructor({baseConfig:t}){this.baseConfig=t;}};var y={[Environment.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[Environment.PRODUCTION]:"https://checkout-api.immutable.com"},w="usd",l=class{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig;}urlWithPath(t){return y[this.config.environment]+t}async fetchOverrides(){if(this.overridesCache!==null)return;let t=this.urlWithPath("/v1/fiat/coins/overrides"),r=await h.get(t);if(r.status!==200)throw new Error(`Error fetching coins overrides: ${r.status} ${r.statusText}`);this.overridesCache=new Map(Object.entries(r.data));}async fetchCoins(){if(this.coinsCache!==null)return;await this.fetchOverrides();let t=this.urlWithPath("/v1/fiat/coins/all"),r=await h.get(t);if(r.status!==200)throw new Error(`Error fetching coins list: ${r.status} ${r.statusText}`);let{data:i}=r;this.coinsCache=new Map;for(let e of i){let n=this.overridesCache.get(e.symbol.toLowerCase());this.coinsCache.set(e.symbol.toLowerCase(),n||e.id.toLowerCase());}}async convert({tokenSymbols:t,fiatSymbols:r=[]}){if(!t||t.length===0)throw new Error("Error missing token symbols to convert");let i=r.filter(o=>o!=="");i.length===0&&i.push(w),await this.fetchCoins();let e=t.map(o=>this.coinsCache.get(o.toLowerCase())).filter(o=>o!==""&&o!==void 0).join(","),n=i.join(",").toLowerCase(),v=this.urlWithPath(`/v1/fiat/conversion?ids=${e}&currencies=${n}`),s=await h.get(v);if(s.status!==200)throw new Error(`Error fetching prices: ${s.status} ${s.statusText}`);let{data:d}=s,a={};for(let o of t){let c=o.toLowerCase(),f=this.coinsCache.get(c);a[c]={},f&&(a[c]=d[f]||{});}return a}};
5
+
6
+ export { l as CryptoFiat, p as CryptoFiatConfiguration };
@@ -1,2 +1,13 @@
1
- 'use strict';var config=require('@imtbl/config'),u=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var f=class{baseConfig;constructor({baseConfig:t}){this.baseConfig=t;}};var v={[config.Environment.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[config.Environment.PRODUCTION]:"https://checkout-api.immutable.com"},d="usd",m=class{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig;}urlWithPath(t){return v[this.config.environment]+t}async fetchOverrides(){if(this.overridesCache!==null)return;let t=this.urlWithPath("/v1/fiat/coins/overrides"),r=await u__default.default.get(t);if(r.status!==200)throw new Error(`Error fetching coins overrides: ${r.status} ${r.statusText}`);this.overridesCache=new Map(Object.entries(r.data));}async fetchCoins(){if(this.coinsCache!==null)return;await this.fetchOverrides();let t=this.urlWithPath("/v1/fiat/coins/all"),r=await u__default.default.get(t);if(r.status!==200)throw new Error(`Error fetching coins list: ${r.status} ${r.statusText}`);let{data:i}=r;this.coinsCache=new Map;for(let s of i){let n=this.overridesCache.get(s.symbol.toLowerCase());this.coinsCache.set(s.symbol.toLowerCase(),n||s.id.toLowerCase());}}async convert({tokenSymbols:t,fiatSymbols:r=[]}){if(!t||t.length===0)throw new Error("Error missing token symbols to convert");let i=r.filter(o=>o!=="");i.length===0&&i.push(d),await this.fetchCoins();let s=t.map(o=>this.coinsCache.get(o.toLowerCase())).filter(o=>o!==""&&o!==void 0).join(","),n=i.join(",").toLowerCase(),p=this.urlWithPath(`/v1/fiat/conversion?ids=${s}&currencies=${n}`),e=await u__default.default.get(p);if(e.status!==200)throw new Error(`Error fetching prices: ${e.status} ${e.statusText}`);let{data:g}=e,a={};for(let o of t){let c=o.toLowerCase(),h=this.coinsCache.get(c);a[c]={},h&&(a[c]=g[h]||{});}return a}};
2
- exports.CryptoFiat=m;exports.CryptoFiatConfiguration=f;
1
+ 'use strict';
2
+
3
+ var config = require('@imtbl/config');
4
+ var u = require('axios');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var u__default = /*#__PURE__*/_interopDefault(u);
9
+
10
+ var f=class{baseConfig;constructor({baseConfig:t}){this.baseConfig=t;}};var v={[config.Environment.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[config.Environment.PRODUCTION]:"https://checkout-api.immutable.com"},d="usd",m=class{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig;}urlWithPath(t){return v[this.config.environment]+t}async fetchOverrides(){if(this.overridesCache!==null)return;let t=this.urlWithPath("/v1/fiat/coins/overrides"),r=await u__default.default.get(t);if(r.status!==200)throw new Error(`Error fetching coins overrides: ${r.status} ${r.statusText}`);this.overridesCache=new Map(Object.entries(r.data));}async fetchCoins(){if(this.coinsCache!==null)return;await this.fetchOverrides();let t=this.urlWithPath("/v1/fiat/coins/all"),r=await u__default.default.get(t);if(r.status!==200)throw new Error(`Error fetching coins list: ${r.status} ${r.statusText}`);let{data:i}=r;this.coinsCache=new Map;for(let s of i){let n=this.overridesCache.get(s.symbol.toLowerCase());this.coinsCache.set(s.symbol.toLowerCase(),n||s.id.toLowerCase());}}async convert({tokenSymbols:t,fiatSymbols:r=[]}){if(!t||t.length===0)throw new Error("Error missing token symbols to convert");let i=r.filter(o=>o!=="");i.length===0&&i.push(d),await this.fetchCoins();let s=t.map(o=>this.coinsCache.get(o.toLowerCase())).filter(o=>o!==""&&o!==void 0).join(","),n=i.join(",").toLowerCase(),p=this.urlWithPath(`/v1/fiat/conversion?ids=${s}&currencies=${n}`),e=await u__default.default.get(p);if(e.status!==200)throw new Error(`Error fetching prices: ${e.status} ${e.statusText}`);let{data:g}=e,a={};for(let o of t){let c=o.toLowerCase(),h=this.coinsCache.get(c);a[c]={},h&&(a[c]=g[h]||{});}return a}};
11
+
12
+ exports.CryptoFiat = m;
13
+ exports.CryptoFiatConfiguration = f;
@@ -1,2 +1,6 @@
1
- import {Environment}from'@imtbl/config';import u from'axios';var f=class{baseConfig;constructor({baseConfig:t}){this.baseConfig=t;}};var v={[Environment.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[Environment.PRODUCTION]:"https://checkout-api.immutable.com"},d="usd",m=class{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig;}urlWithPath(t){return v[this.config.environment]+t}async fetchOverrides(){if(this.overridesCache!==null)return;let t=this.urlWithPath("/v1/fiat/coins/overrides"),r=await u.get(t);if(r.status!==200)throw new Error(`Error fetching coins overrides: ${r.status} ${r.statusText}`);this.overridesCache=new Map(Object.entries(r.data));}async fetchCoins(){if(this.coinsCache!==null)return;await this.fetchOverrides();let t=this.urlWithPath("/v1/fiat/coins/all"),r=await u.get(t);if(r.status!==200)throw new Error(`Error fetching coins list: ${r.status} ${r.statusText}`);let{data:i}=r;this.coinsCache=new Map;for(let s of i){let n=this.overridesCache.get(s.symbol.toLowerCase());this.coinsCache.set(s.symbol.toLowerCase(),n||s.id.toLowerCase());}}async convert({tokenSymbols:t,fiatSymbols:r=[]}){if(!t||t.length===0)throw new Error("Error missing token symbols to convert");let i=r.filter(o=>o!=="");i.length===0&&i.push(d),await this.fetchCoins();let s=t.map(o=>this.coinsCache.get(o.toLowerCase())).filter(o=>o!==""&&o!==void 0).join(","),n=i.join(",").toLowerCase(),p=this.urlWithPath(`/v1/fiat/conversion?ids=${s}&currencies=${n}`),e=await u.get(p);if(e.status!==200)throw new Error(`Error fetching prices: ${e.status} ${e.statusText}`);let{data:g}=e,a={};for(let o of t){let c=o.toLowerCase(),h=this.coinsCache.get(c);a[c]={},h&&(a[c]=g[h]||{});}return a}};
2
- export{m as CryptoFiat,f as CryptoFiatConfiguration};
1
+ import { Environment } from '@imtbl/config';
2
+ import u from 'axios';
3
+
4
+ var f=class{baseConfig;constructor({baseConfig:t}){this.baseConfig=t;}};var v={[Environment.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[Environment.PRODUCTION]:"https://checkout-api.immutable.com"},d="usd",m=class{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig;}urlWithPath(t){return v[this.config.environment]+t}async fetchOverrides(){if(this.overridesCache!==null)return;let t=this.urlWithPath("/v1/fiat/coins/overrides"),r=await u.get(t);if(r.status!==200)throw new Error(`Error fetching coins overrides: ${r.status} ${r.statusText}`);this.overridesCache=new Map(Object.entries(r.data));}async fetchCoins(){if(this.coinsCache!==null)return;await this.fetchOverrides();let t=this.urlWithPath("/v1/fiat/coins/all"),r=await u.get(t);if(r.status!==200)throw new Error(`Error fetching coins list: ${r.status} ${r.statusText}`);let{data:i}=r;this.coinsCache=new Map;for(let s of i){let n=this.overridesCache.get(s.symbol.toLowerCase());this.coinsCache.set(s.symbol.toLowerCase(),n||s.id.toLowerCase());}}async convert({tokenSymbols:t,fiatSymbols:r=[]}){if(!t||t.length===0)throw new Error("Error missing token symbols to convert");let i=r.filter(o=>o!=="");i.length===0&&i.push(d),await this.fetchCoins();let s=t.map(o=>this.coinsCache.get(o.toLowerCase())).filter(o=>o!==""&&o!==void 0).join(","),n=i.join(",").toLowerCase(),p=this.urlWithPath(`/v1/fiat/conversion?ids=${s}&currencies=${n}`),e=await u.get(p);if(e.status!==200)throw new Error(`Error fetching prices: ${e.status} ${e.statusText}`);let{data:g}=e,a={};for(let o of t){let c=o.toLowerCase(),h=this.coinsCache.get(c);a[c]={},h&&(a[c]=g[h]||{});}return a}};
5
+
6
+ export { m as CryptoFiat, f as CryptoFiatConfiguration };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@imtbl/cryptofiat",
3
3
  "description": "Crypto to Fiat SDK powered by Coingecko",
4
- "version": "2.0.0-alpha.1",
4
+ "version": "2.0.0-alpha.10",
5
5
  "author": "Immutable",
6
6
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
7
7
  "dependencies": {
8
- "@imtbl/config": "2.0.0-alpha.1",
8
+ "@imtbl/config": "2.0.0-alpha.10",
9
9
  "axios": "^1.6.5"
10
10
  },
11
11
  "devDependencies": {
@@ -23,7 +23,7 @@
23
23
  "jest-environment-jsdom": "^29.4.3",
24
24
  "prettier": "^2.8.7",
25
25
  "ts-node": "^10.9.1",
26
- "tsup": "^8.3.5",
26
+ "tsup": "8.3.0",
27
27
  "typescript": "^5.6.2"
28
28
  },
29
29
  "engines": {