From 8c37fc31718c9d6d40a03f8f3dbb2c2b0a65b601 Mon Sep 17 00:00:00 2001 From: Sebastian Pape Date: Sat, 25 Mar 2023 09:49:35 +0100 Subject: [PATCH] v6.7.0: upgrade web3-blockchains and remove web3-constants internally --- README.md | 13 +- dist/esm/index.evm.js | 21 ++- dist/esm/index.js | 17 ++- dist/esm/index.solana.js | 196 +++++++++++++++++++++++++++ dist/umd/index.evm.js | 30 +++-- dist/umd/index.js | 26 ++-- dist/umd/index.solana.js | 207 +++++++++++++++++++++++++++++ package.evm.json | 10 +- package.json | 32 ++--- package.solana.json | 35 +++++ rollup.globals.js | 3 +- rollup.module.config.js | 2 + rollup.module.evm.config.js | 4 +- rollup.module.solana.config.js | 47 +++++++ src/dripAssets.evm.js | 115 ---------------- src/dripAssets.js | 19 ++- src/getAssets.evm.js | 82 ------------ src/getAssets.js | 27 +++- src/index.evm.js | 7 - tests/setup.js | 2 + tests/units/dripAssets.evm.spec.js | 82 ++++++------ tests/units/dripAssets.spec.js | 78 +++++------ tests/units/getAssets.evm.spec.js | 2 +- yarn.lock | 169 +++++++++++++++-------- 24 files changed, 806 insertions(+), 420 deletions(-) create mode 100644 dist/esm/index.solana.js create mode 100644 dist/umd/index.solana.js create mode 100644 package.solana.json create mode 100644 rollup.module.solana.config.js delete mode 100644 src/dripAssets.evm.js delete mode 100644 src/getAssets.evm.js delete mode 100644 src/index.evm.js diff --git a/README.md b/README.md index 833fd15..07b8d07 100644 --- a/README.md +++ b/README.md @@ -76,13 +76,24 @@ This library supports the following blockchains: - [Ethereum](https://ethereum.org) - [BNB Smart Chain](https://www.binance.org/smartChain) - [Polygon](https://polygon.technology) +- [Solana](https://solana.com) +- [Fantom](https://fantom.foundation) +- [Velas](https://velas.com) ## Platform specific packaging In case you want to use and package only specific platforms, use the platform-specific package: +### EVM platform specific packaging + ```javascript -import { getAssets } from '@depay/web3-assets' +import { getAssets } from '@depay/web3-assets-evm' +``` + +### Solana platform specific packaging + +```javascript +import { getAssets } from '@depay/web3-assets-solana' ``` ## Functionalities diff --git a/dist/esm/index.evm.js b/dist/esm/index.evm.js index 0d480d0..0834a72 100644 --- a/dist/esm/index.evm.js +++ b/dist/esm/index.evm.js @@ -1,13 +1,12 @@ -import { CONSTANTS } from '@depay/web3-constants'; import { request } from '@depay/web3-client-evm'; -import { Blockchain } from '@depay/web3-blockchains'; +import Blockchains from '@depay/web3-blockchains'; import { Token } from '@depay/web3-tokens-evm'; const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { - if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } - const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase())); + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase())); if(nativeTokenMissing) { let balance = await request( { @@ -18,9 +17,9 @@ const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) { cache: 30000 } ); assets = [{ - name: CONSTANTS[blockchain].CURRENCY, - symbol: CONSTANTS[blockchain].SYMBOL, - address: CONSTANTS[blockchain].NATIVE, + name: Blockchains[blockchain].currency.name, + symbol: Blockchains[blockchain].currency.symbol, + address: Blockchains[blockchain].currency.address, type: 'NATIVE', blockchain, balance: balance.toString() @@ -108,7 +107,7 @@ const isFiltered = ({ options, address, blockchain })=> { return false }; -var dripAssets_evm = async (options) => { +var dripAssets = async (options) => { if(options === undefined) { options = { accounts: {}, priority: [] }; } let assets = []; @@ -147,7 +146,7 @@ var dripAssets_evm = async (options) => { let majorTokens = []; for (var blockchain in options.accounts){ - Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains.findByName(blockchain).tokens.forEach((token)=>{ if(isFiltered({ options, address: token.address, blockchain })){ return } majorTokens.push(Object.assign({}, token, { blockchain })); }); @@ -194,4 +193,4 @@ var dripAssets_evm = async (options) => { return assets }; -export { dripAssets_evm as dripAssets, getAssets }; +export { dripAssets, getAssets }; diff --git a/dist/esm/index.js b/dist/esm/index.js index 78aa836..12ffafd 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -1,13 +1,12 @@ -import { CONSTANTS } from '@depay/web3-constants'; import { request } from '@depay/web3-client'; -import { Blockchain } from '@depay/web3-blockchains'; +import Blockchains from '@depay/web3-blockchains'; import { Token } from '@depay/web3-tokens'; const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { - if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } - const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase())); + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase())); if(nativeTokenMissing) { let balance = await request( { @@ -18,9 +17,9 @@ const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) { cache: 30000 } ); assets = [{ - name: CONSTANTS[blockchain].CURRENCY, - symbol: CONSTANTS[blockchain].SYMBOL, - address: CONSTANTS[blockchain].NATIVE, + name: Blockchains[blockchain].currency.name, + symbol: Blockchains[blockchain].currency.symbol, + address: Blockchains[blockchain].currency.address, type: 'NATIVE', blockchain, balance: balance.toString() @@ -147,7 +146,7 @@ var dripAssets = async (options) => { let majorTokens = []; for (var blockchain in options.accounts){ - Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains.findByName(blockchain).tokens.forEach((token)=>{ if(isFiltered({ options, address: token.address, blockchain })){ return } majorTokens.push(Object.assign({}, token, { blockchain })); }); diff --git a/dist/esm/index.solana.js b/dist/esm/index.solana.js new file mode 100644 index 0000000..8578fd7 --- /dev/null +++ b/dist/esm/index.solana.js @@ -0,0 +1,196 @@ +import { request } from '@depay/web3-client-solana'; +import Blockchains from '@depay/web3-blockchains'; +import { Token } from '@depay/web3-tokens-solana'; + +const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } + + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase())); + if(nativeTokenMissing) { + let balance = await request( + { + blockchain: blockchain, + address, + method: 'balance', + }, + { cache: 30000 } + ); + assets = [{ + name: Blockchains[blockchain].currency.name, + symbol: Blockchains[blockchain].currency.symbol, + address: Blockchains[blockchain].currency.address, + type: 'NATIVE', + blockchain, + balance: balance.toString() + }, ...assets]; + } + return assets +}; + +const filterAssets = ({ assets, blockchain, options })=>{ + if(options.only) { + return assets.filter((asset)=>{ + return (options.only[blockchain] || []).find((onlyAsset)=>(onlyAsset.toLowerCase() == asset.address.toLowerCase())) + }) + } else if(options.exclude) { + return assets.filter((asset)=>{ + return (options.exclude[blockchain] || []).find((excludeAsset)=>(excludeAsset.toLowerCase() != asset.address.toLowerCase())) + }) + } else { + return assets + } +}; + +var getAssets = async (options) => { + if(options === undefined) { options = { accounts: {} }; } + + let assets = Promise.all( + (Object.keys(options.accounts)).map((blockchain) =>{ + + return new Promise((resolve, reject)=>{ + const address = options.accounts[blockchain]; + const controller = new AbortController(); + setTimeout(()=>controller.abort(), 10000); + fetch(`https://public.depay.com/accounts/${blockchain}/${address}/assets`, { signal: controller.signal }) + .catch((error) => { console.log(error); resolve([]); }) + .then((response) => { + if(response && response.ok) { + return response.json() + } else { + resolve([]); + } + }) + .then(async (assets) => { + if(assets && assets.length) { + return await ensureNativeTokenAsset({ + address, + options, + assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), + blockchain + }) + } else { + resolve([]); + } + }) + .then(resolve) + .catch((error) => { console.log(error); resolve([]); }); + }) + }), + ).then((responses) => responses.flat()); + + return assets +}; + +const reduceAssetWithBalance = (asset, balance)=>{ + return Object.assign({}, { + address: asset.address, + symbol: asset.symbol, + name: asset.name, + decimals: asset.decimals, + type: asset.type, + blockchain: asset.blockchain + }, { balance: balance.toString() }) +}; + +const exists = ({ assets, asset })=> { + return !!assets.find(element => element.blockchain == asset.blockchain && element.address.toLowerCase() == asset.address.toLowerCase()) +}; + +const isFiltered = ({ options, address, blockchain })=> { + if(options && options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>only.toLowerCase()==address.toLowerCase())){ + return true + } + if(options && options.exclude && options.exclude[blockchain] && options.exclude[blockchain].find((only)=>only.toLowerCase()==address.toLowerCase())){ + return true + } + return false +}; + +var dripAssets = async (options) => { + if(options === undefined) { options = { accounts: {}, priority: [] }; } + + let assets = []; + let promises = []; + + // Prioritized Assets + + promises = promises.concat((options.priority || []).map((asset)=>{ + return new Promise(async (resolve, reject)=>{ + try { + let token = new Token(asset); + let completedAsset = Object.assign({}, + asset, + { + name: await token.name(), + symbol: await token.symbol(), + decimals: await token.decimals(), + balance: (await token.balance(options.accounts[asset.blockchain])).toString() + } + ); + if(completedAsset.balance != '0') { + if(exists({ assets, asset })) { return resolve() } + assets.push(completedAsset); + if(typeof options.drip == 'function') { options.drip(completedAsset); } + resolve(completedAsset); + } else { + resolve(); + } + } catch (e) { + resolve(); + } + }) + })); + + // Major Tokens + + let majorTokens = []; + for (var blockchain in options.accounts){ + Blockchains.findByName(blockchain).tokens.forEach((token)=>{ + if(isFiltered({ options, address: token.address, blockchain })){ return } + majorTokens.push(Object.assign({}, token, { blockchain })); + }); + } + promises = promises.concat((majorTokens.map((asset)=>{ + return new Promise((resolve, reject)=>{ + new Token(asset).balance(options.accounts[asset.blockchain]) + .then((balance)=>{ + if(exists({ assets, asset })) { return resolve() } + const assetWithBalance = reduceAssetWithBalance(asset, balance); + if(assetWithBalance.balance != '0') { + assets.push(assetWithBalance); + if(typeof options.drip == 'function') { options.drip(assetWithBalance); } + resolve(assetWithBalance); + } else { + resolve(); + }}).catch((error)=>{ console.log(error); resolve(); }); + }) + }))); + + // All other assets + + if(options.only == undefined || Object.keys(options.only).every((list)=>list.length == 0)) { + let allAssets = await getAssets(options); + promises = promises.concat((allAssets.map((asset)=>{ + return new Promise((resolve, reject)=>{ + return new Token(asset).balance(options.accounts[asset.blockchain]) + .then((balance)=>{ + if(exists({ assets, asset })) { return resolve() } + const assetWithBalance = reduceAssetWithBalance(asset, balance); + if(assetWithBalance.balance != '0') { + assets.push(assetWithBalance); + if(typeof options.drip == 'function') { options.drip(assetWithBalance); } + resolve(assetWithBalance); + } else { + resolve(); + }}).catch((error)=>{ console.log(error); resolve(); }) + }) + }))); + } + + await Promise.all(promises); + + return assets +}; + +export { dripAssets, getAssets }; diff --git a/dist/umd/index.evm.js b/dist/umd/index.evm.js index 948ec69..a73ce3a 100644 --- a/dist/umd/index.evm.js +++ b/dist/umd/index.evm.js @@ -1,14 +1,18 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-constants'), require('@depay/web3-client-evm'), require('@depay/web3-blockchains'), require('@depay/web3-tokens-evm')) : - typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-constants', '@depay/web3-client-evm', '@depay/web3-blockchains', '@depay/web3-tokens-evm'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Assets = {}, global.Web3Constants, global.Web3Client, global.Web3Blockchains, global.Web3Tokens)); -}(this, (function (exports, web3Constants, web3ClientEvm, web3Blockchains, web3TokensEvm) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-client-evm'), require('@depay/web3-blockchains'), require('@depay/web3-tokens-evm')) : + typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-client-evm', '@depay/web3-blockchains', '@depay/web3-tokens-evm'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Assets = {}, global.Web3Client, global.Web3Blockchains, global.Web3Tokens)); +}(this, (function (exports, web3ClientEvm, Blockchains, web3TokensEvm) { 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var Blockchains__default = /*#__PURE__*/_interopDefaultLegacy(Blockchains); const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { - if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase()))){ return assets } - const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase())); + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase())); if(nativeTokenMissing) { let balance = await web3ClientEvm.request( { @@ -19,9 +23,9 @@ { cache: 30000 } ); assets = [{ - name: web3Constants.CONSTANTS[blockchain].CURRENCY, - symbol: web3Constants.CONSTANTS[blockchain].SYMBOL, - address: web3Constants.CONSTANTS[blockchain].NATIVE, + name: Blockchains__default['default'][blockchain].currency.name, + symbol: Blockchains__default['default'][blockchain].currency.symbol, + address: Blockchains__default['default'][blockchain].currency.address, type: 'NATIVE', blockchain, balance: balance.toString() @@ -109,7 +113,7 @@ return false }; - var dripAssets_evm = async (options) => { + var dripAssets = async (options) => { if(options === undefined) { options = { accounts: {}, priority: [] }; } let assets = []; @@ -148,7 +152,7 @@ let majorTokens = []; for (var blockchain in options.accounts){ - web3Blockchains.Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains__default['default'].findByName(blockchain).tokens.forEach((token)=>{ if(isFiltered({ options, address: token.address, blockchain })){ return } majorTokens.push(Object.assign({}, token, { blockchain })); }); @@ -195,7 +199,7 @@ return assets }; - exports.dripAssets = dripAssets_evm; + exports.dripAssets = dripAssets; exports.getAssets = getAssets; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/dist/umd/index.js b/dist/umd/index.js index 5b11635..aa07178 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -1,14 +1,18 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-constants'), require('@depay/web3-client'), require('@depay/web3-blockchains'), require('@depay/web3-tokens')) : - typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-constants', '@depay/web3-client', '@depay/web3-blockchains', '@depay/web3-tokens'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Assets = {}, global.Web3Constants, global.Web3Client, global.Web3Blockchains, global.Web3Tokens)); -}(this, (function (exports, web3Constants, web3Client, web3Blockchains, web3Tokens) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-client'), require('@depay/web3-blockchains'), require('@depay/web3-tokens')) : + typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-client', '@depay/web3-blockchains', '@depay/web3-tokens'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Assets = {}, global.Web3Client, global.Web3Blockchains, global.Web3Tokens)); +}(this, (function (exports, web3Client, Blockchains, web3Tokens) { 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var Blockchains__default = /*#__PURE__*/_interopDefaultLegacy(Blockchains); const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { - if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase()))){ return assets } - const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase())); + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase())); if(nativeTokenMissing) { let balance = await web3Client.request( { @@ -19,9 +23,9 @@ { cache: 30000 } ); assets = [{ - name: web3Constants.CONSTANTS[blockchain].CURRENCY, - symbol: web3Constants.CONSTANTS[blockchain].SYMBOL, - address: web3Constants.CONSTANTS[blockchain].NATIVE, + name: Blockchains__default['default'][blockchain].currency.name, + symbol: Blockchains__default['default'][blockchain].currency.symbol, + address: Blockchains__default['default'][blockchain].currency.address, type: 'NATIVE', blockchain, balance: balance.toString() @@ -148,7 +152,7 @@ let majorTokens = []; for (var blockchain in options.accounts){ - web3Blockchains.Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains__default['default'].findByName(blockchain).tokens.forEach((token)=>{ if(isFiltered({ options, address: token.address, blockchain })){ return } majorTokens.push(Object.assign({}, token, { blockchain })); }); diff --git a/dist/umd/index.solana.js b/dist/umd/index.solana.js new file mode 100644 index 0000000..2419ae0 --- /dev/null +++ b/dist/umd/index.solana.js @@ -0,0 +1,207 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@depay/web3-client-solana'), require('@depay/web3-blockchains'), require('@depay/web3-tokens-solana')) : + typeof define === 'function' && define.amd ? define(['exports', '@depay/web3-client-solana', '@depay/web3-blockchains', '@depay/web3-tokens-solana'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Web3Assets = {}, global.Web3Client, global.Web3Blockchains, global.Web3Tokens)); +}(this, (function (exports, web3ClientSolana, Blockchains, web3TokensSolana) { 'use strict'; + + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var Blockchains__default = /*#__PURE__*/_interopDefaultLegacy(Blockchains); + + const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase()))){ return assets } + + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains__default['default'][blockchain].currency.address.toLowerCase())); + if(nativeTokenMissing) { + let balance = await web3ClientSolana.request( + { + blockchain: blockchain, + address, + method: 'balance', + }, + { cache: 30000 } + ); + assets = [{ + name: Blockchains__default['default'][blockchain].currency.name, + symbol: Blockchains__default['default'][blockchain].currency.symbol, + address: Blockchains__default['default'][blockchain].currency.address, + type: 'NATIVE', + blockchain, + balance: balance.toString() + }, ...assets]; + } + return assets + }; + + const filterAssets = ({ assets, blockchain, options })=>{ + if(options.only) { + return assets.filter((asset)=>{ + return (options.only[blockchain] || []).find((onlyAsset)=>(onlyAsset.toLowerCase() == asset.address.toLowerCase())) + }) + } else if(options.exclude) { + return assets.filter((asset)=>{ + return (options.exclude[blockchain] || []).find((excludeAsset)=>(excludeAsset.toLowerCase() != asset.address.toLowerCase())) + }) + } else { + return assets + } + }; + + var getAssets = async (options) => { + if(options === undefined) { options = { accounts: {} }; } + + let assets = Promise.all( + (Object.keys(options.accounts)).map((blockchain) =>{ + + return new Promise((resolve, reject)=>{ + const address = options.accounts[blockchain]; + const controller = new AbortController(); + setTimeout(()=>controller.abort(), 10000); + fetch(`https://public.depay.com/accounts/${blockchain}/${address}/assets`, { signal: controller.signal }) + .catch((error) => { console.log(error); resolve([]); }) + .then((response) => { + if(response && response.ok) { + return response.json() + } else { + resolve([]); + } + }) + .then(async (assets) => { + if(assets && assets.length) { + return await ensureNativeTokenAsset({ + address, + options, + assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), + blockchain + }) + } else { + resolve([]); + } + }) + .then(resolve) + .catch((error) => { console.log(error); resolve([]); }); + }) + }), + ).then((responses) => responses.flat()); + + return assets + }; + + const reduceAssetWithBalance = (asset, balance)=>{ + return Object.assign({}, { + address: asset.address, + symbol: asset.symbol, + name: asset.name, + decimals: asset.decimals, + type: asset.type, + blockchain: asset.blockchain + }, { balance: balance.toString() }) + }; + + const exists = ({ assets, asset })=> { + return !!assets.find(element => element.blockchain == asset.blockchain && element.address.toLowerCase() == asset.address.toLowerCase()) + }; + + const isFiltered = ({ options, address, blockchain })=> { + if(options && options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>only.toLowerCase()==address.toLowerCase())){ + return true + } + if(options && options.exclude && options.exclude[blockchain] && options.exclude[blockchain].find((only)=>only.toLowerCase()==address.toLowerCase())){ + return true + } + return false + }; + + var dripAssets = async (options) => { + if(options === undefined) { options = { accounts: {}, priority: [] }; } + + let assets = []; + let promises = []; + + // Prioritized Assets + + promises = promises.concat((options.priority || []).map((asset)=>{ + return new Promise(async (resolve, reject)=>{ + try { + let token = new web3TokensSolana.Token(asset); + let completedAsset = Object.assign({}, + asset, + { + name: await token.name(), + symbol: await token.symbol(), + decimals: await token.decimals(), + balance: (await token.balance(options.accounts[asset.blockchain])).toString() + } + ); + if(completedAsset.balance != '0') { + if(exists({ assets, asset })) { return resolve() } + assets.push(completedAsset); + if(typeof options.drip == 'function') { options.drip(completedAsset); } + resolve(completedAsset); + } else { + resolve(); + } + } catch (e) { + resolve(); + } + }) + })); + + // Major Tokens + + let majorTokens = []; + for (var blockchain in options.accounts){ + Blockchains__default['default'].findByName(blockchain).tokens.forEach((token)=>{ + if(isFiltered({ options, address: token.address, blockchain })){ return } + majorTokens.push(Object.assign({}, token, { blockchain })); + }); + } + promises = promises.concat((majorTokens.map((asset)=>{ + return new Promise((resolve, reject)=>{ + new web3TokensSolana.Token(asset).balance(options.accounts[asset.blockchain]) + .then((balance)=>{ + if(exists({ assets, asset })) { return resolve() } + const assetWithBalance = reduceAssetWithBalance(asset, balance); + if(assetWithBalance.balance != '0') { + assets.push(assetWithBalance); + if(typeof options.drip == 'function') { options.drip(assetWithBalance); } + resolve(assetWithBalance); + } else { + resolve(); + }}).catch((error)=>{ console.log(error); resolve(); }); + }) + }))); + + // All other assets + + if(options.only == undefined || Object.keys(options.only).every((list)=>list.length == 0)) { + let allAssets = await getAssets(options); + promises = promises.concat((allAssets.map((asset)=>{ + return new Promise((resolve, reject)=>{ + return new web3TokensSolana.Token(asset).balance(options.accounts[asset.blockchain]) + .then((balance)=>{ + if(exists({ assets, asset })) { return resolve() } + const assetWithBalance = reduceAssetWithBalance(asset, balance); + if(assetWithBalance.balance != '0') { + assets.push(assetWithBalance); + if(typeof options.drip == 'function') { options.drip(assetWithBalance); } + resolve(assetWithBalance); + } else { + resolve(); + }}).catch((error)=>{ console.log(error); resolve(); }) + }) + }))); + } + + await Promise.all(promises); + + return assets + }; + + exports.dripAssets = dripAssets; + exports.getAssets = getAssets; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/package.evm.json b/package.evm.json index 0278118..f9b82f6 100644 --- a/package.evm.json +++ b/package.evm.json @@ -1,11 +1,10 @@ { "name": "@depay/web3-assets-evm", "moduleName": "Web3Assets", - "version": "6.6.2", + "version": "6.7.0", "description": "JavaScript library to retrieve Web3 assets of a given or connected wallet/account.", "main": "dist/umd/index.evm.js", "module": "dist/esm/index.evm.js", - "source": "src/index.evm.js", "files": [ "dist" ], @@ -26,10 +25,9 @@ "private": false, "dependencies": {}, "peerDependencies": { - "@depay/web3-blockchains": "^6.2.3", - "@depay/web3-client-evm": "^10.1.23", - "@depay/web3-constants": "^6.3.2", - "@depay/web3-tokens-evm": "^9.12.8" + "@depay/web3-blockchains": "^7.1.0", + "@depay/web3-client-evm": "^10.7.1", + "@depay/web3-tokens-evm": "^9.16.0" }, "engines": { "node": ">=16" diff --git a/package.json b/package.json index 0385aa6..2413302 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-assets", "moduleName": "Web3Assets", - "version": "6.6.2", + "version": "6.7.0", "description": "JavaScript library to retrieve Web3 assets of a given or connected wallet/account.", "main": "dist/umd/index.js", "module": "dist/esm/index.js", @@ -10,7 +10,7 @@ "dist" ], "scripts": { - "build": "rm -rf dist && rollup -c rollup.module.config.js && rollup -c rollup.module.evm.config.js", + "build": "rm -rf dist && rollup -c rollup.module.config.js && rollup -c rollup.module.evm.config.js && rollup -c rollup.module.solana.config.js", "lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" --fix", "dev": "rollup -c rollup.dev.config.js -w", @@ -34,11 +34,10 @@ "private": false, "dependencies": {}, "peerDependencies": { - "@depay/solana-web3.js": "^1.19.0", - "@depay/web3-blockchains": "^6.2.3", - "@depay/web3-client": "^10.1.23", - "@depay/web3-constants": "^6.3.2", - "@depay/web3-tokens": "^9.12.8" + "@depay/solana-web3.js": "^1.20.15", + "@depay/web3-blockchains": "^7.1.0", + "@depay/web3-client": "^10.7.1", + "@depay/web3-tokens": "^9.16.0" }, "engines": { "node": ">=16" @@ -46,14 +45,15 @@ "devDependencies": { "@babel/core": "^7.12.9", "@babel/preset-env": "^7.12.7", - "@depay/solana-web3.js": "^1.19.0", - "@depay/web3-blockchains": "^6.2.3", - "@depay/web3-client": "^10.1.23", - "@depay/web3-client-evm": "^10.1.23", - "@depay/web3-constants": "^6.3.2", - "@depay/web3-mock": "^13.22.4", - "@depay/web3-tokens": "^9.12.8", - "@depay/web3-tokens-evm": "^9.12.8", + "@depay/solana-web3.js": "^1.20.15", + "@depay/web3-blockchains": "^7.1.0", + "@depay/web3-client": "^10.7.1", + "@depay/web3-client-evm": "^10.7.1", + "@depay/web3-client-solana": "^10.7.1", + "@depay/web3-mock": "^13.26.0", + "@depay/web3-tokens": "^9.16.0", + "@depay/web3-tokens-evm": "^9.16.0", + "@depay/web3-tokens-solana": "^9.16.0", "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-replace": "^2.4.2", @@ -68,9 +68,11 @@ "ethers": "^5.7.1", "fetch-mock": "^9.11.0", "jest-environment-jsdom": "^28.1.0", + "node-fetch": "^2.6.9", "regenerator-runtime": "^0.13.7", "rollup": "^2.34.2", "rollup-plugin-delete": "^2.0.0", + "rollup-plugin-jscc": "^2.0.0", "rollup-plugin-livereload": "^2.0.0", "rollup-plugin-serve": "^1.1.0", "tslib": "^2.3.1", diff --git a/package.solana.json b/package.solana.json new file mode 100644 index 0000000..85ccb86 --- /dev/null +++ b/package.solana.json @@ -0,0 +1,35 @@ +{ + "name": "@depay/web3-assets-solana", + "moduleName": "Web3Assets", + "version": "6.7.0", + "description": "JavaScript library to retrieve Web3 assets of a given or connected wallet/account.", + "main": "dist/umd/index.solana.js", + "module": "dist/esm/index.solana.js", + "files": [ + "dist" + ], + "repository": "git@github.com:DePayFi/web3-assets.git", + "keywords": [ + "web3", + "assets", + "tokens", + "crypto", + "blockchain" + ], + "author": "depay.com", + "license": "MIT", + "bugs": { + "url": "https://github.com/DePayFi/web3-assets/issues" + }, + "homepage": "https://depay.com", + "private": false, + "dependencies": {}, + "peerDependencies": { + "@depay/web3-blockchains": "^7.1.0", + "@depay/web3-client-solana": "^10.7.1", + "@depay/web3-tokens-solana": "^9.16.0" + }, + "engines": { + "node": ">=16" + } +} diff --git a/rollup.globals.js b/rollup.globals.js index 53f238f..b9db9f2 100644 --- a/rollup.globals.js +++ b/rollup.globals.js @@ -3,7 +3,8 @@ export default { '@depay/web3-blockchains': 'Web3Blockchains', '@depay/web3-client': 'Web3Client', '@depay/web3-client-evm': 'Web3Client', - '@depay/web3-constants': 'Web3Constants', + '@depay/web3-client-solana': 'Web3Client', '@depay/web3-tokens': 'Web3Tokens', '@depay/web3-tokens-evm': 'Web3Tokens', + '@depay/web3-tokens-solana': 'Web3Tokens', } diff --git a/rollup.module.config.js b/rollup.module.config.js index 6dd1b27..3908f6b 100644 --- a/rollup.module.config.js +++ b/rollup.module.config.js @@ -1,5 +1,6 @@ import commonjs from '@rollup/plugin-commonjs' import globals from './rollup.globals.js' +import jscc from 'rollup-plugin-jscc' import pkg from './package.json' import replace from '@rollup/plugin-replace' import resolve from '@rollup/plugin-node-resolve' @@ -26,6 +27,7 @@ export default { ...Object.keys(pkg.peerDependencies || {}), ], plugins: [ + jscc({ include: 'src/**' }), sucrase({ exclude: ['node_modules/**'], transforms: ['jsx'] diff --git a/rollup.module.evm.config.js b/rollup.module.evm.config.js index 89b31ed..c5133b9 100644 --- a/rollup.module.evm.config.js +++ b/rollup.module.evm.config.js @@ -1,5 +1,6 @@ import commonjs from '@rollup/plugin-commonjs' import globals from './rollup.globals.js' +import jscc from 'rollup-plugin-jscc' import pkg from './package.evm.json' import replace from '@rollup/plugin-replace' import resolve from '@rollup/plugin-node-resolve' @@ -7,7 +8,7 @@ import sucrase from '@rollup/plugin-sucrase' import { nodeResolve } from '@rollup/plugin-node-resolve' export default { - input: 'src/index.evm.js', + input: 'src/index.js', output: [ { format: 'es', @@ -26,6 +27,7 @@ export default { ...Object.keys(pkg.peerDependencies || {}), ], plugins: [ + jscc({ include: 'src/**', values: { _EVM: 1 }}), sucrase({ exclude: ['node_modules/**'], transforms: ['jsx'] diff --git a/rollup.module.solana.config.js b/rollup.module.solana.config.js new file mode 100644 index 0000000..e71de38 --- /dev/null +++ b/rollup.module.solana.config.js @@ -0,0 +1,47 @@ +import commonjs from '@rollup/plugin-commonjs' +import globals from './rollup.globals.js' +import jscc from 'rollup-plugin-jscc' +import pkg from './package.solana.json' +import replace from '@rollup/plugin-replace' +import resolve from '@rollup/plugin-node-resolve' +import sucrase from '@rollup/plugin-sucrase' +import { nodeResolve } from '@rollup/plugin-node-resolve' + +export default { + input: 'src/index.js', + output: [ + { + format: 'es', + globals: globals, + file: 'dist/esm/index.solana.js' + }, + { + format: 'umd', + name: pkg.moduleName, + globals: globals, + file: 'dist/umd/index.solana.js' + }, + ], + external: [ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + ], + plugins: [ + jscc({ include: 'src/**', values: { _SOLANA: 1 }}), + sucrase({ + exclude: ['node_modules/**'], + transforms: ['jsx'] + }), + resolve({ + extensions: ['.js', '.jsx'] + }), + nodeResolve(), + commonjs({ + include: 'node_modules/**' + }), + replace({ + 'process.env.NODE_ENV': JSON.stringify( 'production' ), + preventAssignment: true + }) + ] +} diff --git a/src/dripAssets.evm.js b/src/dripAssets.evm.js deleted file mode 100644 index 8a6cfd1..0000000 --- a/src/dripAssets.evm.js +++ /dev/null @@ -1,115 +0,0 @@ -import getAssets from './getAssets.evm' -import { Blockchain } from '@depay/web3-blockchains' -import { Token } from '@depay/web3-tokens-evm' - -const reduceAssetWithBalance = (asset, balance)=>{ - return Object.assign({}, { - address: asset.address, - symbol: asset.symbol, - name: asset.name, - decimals: asset.decimals, - type: asset.type, - blockchain: asset.blockchain - }, { balance: balance.toString() }) -} - -const exists = ({ assets, asset })=> { - return !!assets.find(element => element.blockchain == asset.blockchain && element.address.toLowerCase() == asset.address.toLowerCase()) -} - -const isFiltered = ({ options, address, blockchain })=> { - if(options && options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>only.toLowerCase()==address.toLowerCase())){ - return true - } - if(options && options.exclude && options.exclude[blockchain] && options.exclude[blockchain].find((only)=>only.toLowerCase()==address.toLowerCase())){ - return true - } - return false -} - -export default async (options) => { - if(options === undefined) { options = { accounts: {}, priority: [] } } - - let assets = [] - let promises = [] - - // Prioritized Assets - - promises = promises.concat((options.priority || []).map((asset)=>{ - return new Promise(async (resolve, reject)=>{ - try { - let token = new Token(asset) - let completedAsset = Object.assign({}, - asset, - { - name: await token.name(), - symbol: await token.symbol(), - decimals: await token.decimals(), - balance: (await token.balance(options.accounts[asset.blockchain])).toString() - } - ) - if(completedAsset.balance != '0') { - if(exists({ assets, asset })) { return resolve() } - assets.push(completedAsset) - if(typeof options.drip == 'function') { options.drip(completedAsset) } - resolve(completedAsset) - } else { - resolve() - } - } catch { - resolve() - } - }) - })) - - // Major Tokens - - let majorTokens = [] - for (var blockchain in options.accounts){ - Blockchain.findByName(blockchain).tokens.forEach((token)=>{ - if(isFiltered({ options, address: token.address, blockchain })){ return } - majorTokens.push(Object.assign({}, token, { blockchain })) - }) - } - promises = promises.concat((majorTokens.map((asset)=>{ - return new Promise((resolve, reject)=>{ - let requestOptions - new Token(asset).balance(options.accounts[asset.blockchain]) - .then((balance)=>{ - if(exists({ assets, asset })) { return resolve() } - const assetWithBalance = reduceAssetWithBalance(asset, balance) - if(assetWithBalance.balance != '0') { - assets.push(assetWithBalance) - if(typeof options.drip == 'function') { options.drip(assetWithBalance) } - resolve(assetWithBalance) - } else { - resolve() - }}).catch((error)=>{ console.log(error); resolve() }) - }) - }))) - - // All other assets - - if(options.only == undefined || Object.keys(options.only).every((list)=>list.length == 0)) { - let allAssets = await getAssets(options) - promises = promises.concat((allAssets.map((asset)=>{ - return new Promise((resolve, reject)=>{ - return new Token(asset).balance(options.accounts[asset.blockchain]) - .then((balance)=>{ - if(exists({ assets, asset })) { return resolve() } - const assetWithBalance = reduceAssetWithBalance(asset, balance) - if(assetWithBalance.balance != '0') { - assets.push(assetWithBalance) - if(typeof options.drip == 'function') { options.drip(assetWithBalance) } - resolve(assetWithBalance) - } else { - resolve() - }}).catch((error)=>{ console.log(error); resolve() }) - }) - }))) - } - - await Promise.all(promises) - - return assets -} diff --git a/src/dripAssets.js b/src/dripAssets.js index 1862bb7..acc4da4 100644 --- a/src/dripAssets.js +++ b/src/dripAssets.js @@ -1,7 +1,20 @@ -import getAssets from './getAssets' -import { Blockchain } from '@depay/web3-blockchains' +/*#if _EVM + +import { Token } from '@depay/web3-tokens-evm' + +/*#elif _SOLANA + +import { Token } from '@depay/web3-tokens-solana' + +//#else */ + import { Token } from '@depay/web3-tokens' +//#endif + +import Blockchains from '@depay/web3-blockchains' +import getAssets from './getAssets' + const reduceAssetWithBalance = (asset, balance)=>{ return Object.assign({}, { address: asset.address, @@ -66,7 +79,7 @@ export default async (options) => { let majorTokens = [] for (var blockchain in options.accounts){ - Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains.findByName(blockchain).tokens.forEach((token)=>{ if(isFiltered({ options, address: token.address, blockchain })){ return } majorTokens.push(Object.assign({}, token, { blockchain })) }) diff --git a/src/getAssets.evm.js b/src/getAssets.evm.js deleted file mode 100644 index a0dae6d..0000000 --- a/src/getAssets.evm.js +++ /dev/null @@ -1,82 +0,0 @@ -import { CONSTANTS } from '@depay/web3-constants' -import { request } from '@depay/web3-client-evm' - -const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { - if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - - const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase())) - if(nativeTokenMissing) { - let balance = await request( - { - blockchain: blockchain, - address, - method: 'balance', - }, - { cache: 30000 } - ) - assets = [{ - name: CONSTANTS[blockchain].CURRENCY, - symbol: CONSTANTS[blockchain].SYMBOL, - address: CONSTANTS[blockchain].NATIVE, - type: 'NATIVE', - blockchain, - balance: balance.toString() - }, ...assets] - } - return assets -} - -const filterAssets = ({ assets, blockchain, options })=>{ - if(options.only) { - return assets.filter((asset)=>{ - return (options.only[blockchain] || []).find((onlyAsset)=>(onlyAsset.toLowerCase() == asset.address.toLowerCase())) - }) - } else if(options.exclude) { - return assets.filter((asset)=>{ - return (options.exclude[blockchain] || []).find((excludeAsset)=>(excludeAsset.toLowerCase() != asset.address.toLowerCase())) - }) - } else { - return assets - } -} - -export default async (options) => { - if(options === undefined) { options = { accounts: {} } } - - let assets = Promise.all( - (Object.keys(options.accounts)).map((blockchain) =>{ - - return new Promise((resolve, reject)=>{ - const address = options.accounts[blockchain] - const controller = new AbortController() - setTimeout(()=>controller.abort(), 10000) - fetch(`https://public.depay.com/accounts/${blockchain}/${address}/assets`, { signal: controller.signal }) - .catch((error) => { console.log(error); resolve([]) }) - .then((response) => { - if(response && response.ok) { - return response.json() - } else { - resolve([]) - } - }) - .then(async (assets) => { - if(assets && assets.length) { - return await ensureNativeTokenAsset({ - address, - options, - assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })), - blockchain - }) - } else { - resolve([]) - } - }) - .then(resolve) - .catch((error) => { console.log(error); resolve([]) }) - }) - }), - ).then((responses) => responses.flat()) - - return assets -} diff --git a/src/getAssets.js b/src/getAssets.js index c44bee2..de20734 100644 --- a/src/getAssets.js +++ b/src/getAssets.js @@ -1,11 +1,24 @@ -import { CONSTANTS } from '@depay/web3-constants' +/*#if _EVM + +import { request } from '@depay/web3-client-evm' + +/*#elif _SOLANA + +import { request } from '@depay/web3-client-solana' + +//#else */ + import { request } from '@depay/web3-client' +//#endif + +import Blockchains from '@depay/web3-blockchains' + const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) => { - if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } - if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase()))){ return assets } + if(options.only && options.only[blockchain] && !options.only[blockchain].find((only)=>(only.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } + if(options.exclude && options.exclude[blockchain] && !!options.exclude[blockchain].find((exclude)=>(exclude.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase()))){ return assets } - const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == CONSTANTS[blockchain].NATIVE.toLowerCase())) + const nativeTokenMissing = !assets.find((asset)=>(asset.address.toLowerCase() == Blockchains[blockchain].currency.address.toLowerCase())) if(nativeTokenMissing) { let balance = await request( { @@ -16,9 +29,9 @@ const ensureNativeTokenAsset = async ({ address, options, assets, blockchain }) { cache: 30000 } ) assets = [{ - name: CONSTANTS[blockchain].CURRENCY, - symbol: CONSTANTS[blockchain].SYMBOL, - address: CONSTANTS[blockchain].NATIVE, + name: Blockchains[blockchain].currency.name, + symbol: Blockchains[blockchain].currency.symbol, + address: Blockchains[blockchain].currency.address, type: 'NATIVE', blockchain, balance: balance.toString() diff --git a/src/index.evm.js b/src/index.evm.js deleted file mode 100644 index 6fb86f8..0000000 --- a/src/index.evm.js +++ /dev/null @@ -1,7 +0,0 @@ -import getAssets from './getAssets.evm' -import dripAssets from './dripAssets.evm' - -export { - getAssets, - dripAssets, -} diff --git a/tests/setup.js b/tests/setup.js index abf6292..b112994 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1 +1,3 @@ import 'regenerator-runtime/runtime' + +global.fetch = require('node-fetch') diff --git a/tests/units/dripAssets.evm.spec.js b/tests/units/dripAssets.evm.spec.js index 042c3fe..e24b6a6 100644 --- a/tests/units/dripAssets.evm.spec.js +++ b/tests/units/dripAssets.evm.spec.js @@ -1,8 +1,8 @@ +import Blockchains from '@depay/web3-blockchains' import fetchMock from 'fetch-mock' -import { Blockchain } from '@depay/web3-blockchains' -import { dripAssets } from 'src/index.evm' -import { mock, resetMocks } from '@depay/web3-mock' +import { dripAssets } from 'dist/esm/index.evm' import { getProvider, resetCache } from '@depay/web3-client-evm' +import { mock, resetMocks } from '@depay/web3-mock' import { Token } from '@depay/web3-tokens-evm' describe('dripAssets', ()=>{ @@ -22,7 +22,7 @@ describe('dripAssets', ()=>{ provider = await getProvider(blockchain) mock({ accounts: { return: accounts }, provider, blockchain }) mock({ balance: { for: accounts[0], return: '123456789' }, provider, blockchain }) - Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains.findByName(blockchain).tokens.forEach((token)=>{ if(token.type == '20') { mock({ request: { return: '123456789', to: token.address, api: Token[blockchain].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain }) } @@ -197,6 +197,15 @@ describe('dripAssets', ()=>{ blockchain: 'ethereum', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + balance: '56789', + blockchain: 'ethereum', + decimals: 18, + name: 'DePay', + symbol: 'DEPAY', + type: '20' + }, { address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', symbol: 'WBNB', @@ -260,6 +269,15 @@ describe('dripAssets', ()=>{ blockchain: 'bsc', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + balance: '56789', + blockchain: 'bsc', + decimals: 18, + name: 'DePay', + symbol: 'DEPAY', + type: '20' + }, { address: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', symbol: 'WMATIC', @@ -323,24 +341,6 @@ describe('dripAssets', ()=>{ blockchain: 'polygon', balance: '123456789' }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - balance: '56789', - blockchain: 'ethereum', - decimals: 18, - name: 'DePay', - symbol: 'DEPAY', - type: '20' - }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - balance: '56789', - blockchain: 'bsc', - decimals: 18, - name: 'DePay', - symbol: 'DEPAY', - type: '20' - }, { address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', balance: '56789', @@ -489,6 +489,15 @@ describe('dripAssets', ()=>{ blockchain: 'ethereum', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + balance: '56789', + blockchain: 'ethereum', + decimals: 18, + name: 'DePay', + symbol: 'DEPAY', + type: '20' + }, { address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', symbol: 'WBNB', @@ -543,15 +552,6 @@ describe('dripAssets', ()=>{ blockchain: 'bsc', balance: '123456789' }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - balance: '56789', - blockchain: 'ethereum', - decimals: 18, - name: 'DePay', - symbol: 'DEPAY', - type: '20' - }, { address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', balance: '56789', @@ -690,6 +690,15 @@ describe('dripAssets', ()=>{ blockchain: 'ethereum', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + symbol: 'DEPAY', + name: 'DePay', + decimals: 18, + type: '20', + blockchain: 'ethereum', + balance: '56789' + }, { address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', symbol: 'WBNB', @@ -753,15 +762,6 @@ describe('dripAssets', ()=>{ blockchain: 'bsc', balance: '123456789' }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - symbol: 'DEPAY', - name: 'DePay', - decimals: 18, - type: '20', - blockchain: 'ethereum', - balance: '56789' - }, { address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', symbol: 'DEPAY', @@ -795,7 +795,7 @@ describe('dripAssets', ()=>{ } }) - expect(dripsCount).toEqual(18) + expect(dripsCount).toEqual(19) let expectedAssets = [{ address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', diff --git a/tests/units/dripAssets.spec.js b/tests/units/dripAssets.spec.js index 561951d..2c35410 100644 --- a/tests/units/dripAssets.spec.js +++ b/tests/units/dripAssets.spec.js @@ -1,5 +1,5 @@ import fetchMock from 'fetch-mock' -import { Blockchain } from '@depay/web3-blockchains' +import Blockchains from '@depay/web3-blockchains' import { dripAssets } from 'src' import { mock, resetMocks } from '@depay/web3-mock' import { getProvider, resetCache } from '@depay/web3-client' @@ -22,7 +22,7 @@ describe('dripAssets', ()=>{ provider = await getProvider(blockchain) mock({ accounts: { return: accounts }, provider, blockchain }) mock({ balance: { for: accounts[0], return: '123456789' }, provider, blockchain }) - Blockchain.findByName(blockchain).tokens.forEach((token)=>{ + Blockchains.findByName(blockchain).tokens.forEach((token)=>{ if(token.type == '20') { mock({ request: { return: '123456789', to: token.address, api: Token[blockchain].DEFAULT, method: 'balanceOf', params: accounts[0] }, provider, blockchain }) } @@ -197,6 +197,15 @@ describe('dripAssets', ()=>{ blockchain: 'ethereum', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + balance: '56789', + blockchain: 'ethereum', + decimals: 18, + name: 'DePay', + symbol: 'DEPAY', + type: '20' + }, { address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', symbol: 'WBNB', @@ -260,6 +269,15 @@ describe('dripAssets', ()=>{ blockchain: 'bsc', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + balance: '56789', + blockchain: 'bsc', + decimals: 18, + name: 'DePay', + symbol: 'DEPAY', + type: '20' + }, { address: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', symbol: 'WMATIC', @@ -323,24 +341,6 @@ describe('dripAssets', ()=>{ blockchain: 'polygon', balance: '123456789' }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - balance: '56789', - blockchain: 'ethereum', - decimals: 18, - name: 'DePay', - symbol: 'DEPAY', - type: '20' - }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - balance: '56789', - blockchain: 'bsc', - decimals: 18, - name: 'DePay', - symbol: 'DEPAY', - type: '20' - }, { address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', balance: '56789', @@ -489,6 +489,15 @@ describe('dripAssets', ()=>{ blockchain: 'ethereum', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + balance: '56789', + blockchain: 'ethereum', + decimals: 18, + name: 'DePay', + symbol: 'DEPAY', + type: '20' + }, { address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', symbol: 'WBNB', @@ -543,15 +552,6 @@ describe('dripAssets', ()=>{ blockchain: 'bsc', balance: '123456789' }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - balance: '56789', - blockchain: 'ethereum', - decimals: 18, - name: 'DePay', - symbol: 'DEPAY', - type: '20' - }, { address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', balance: '56789', @@ -690,6 +690,15 @@ describe('dripAssets', ()=>{ blockchain: 'ethereum', balance: '123456789' }, + { + address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', + symbol: 'DEPAY', + name: 'DePay', + decimals: 18, + type: '20', + blockchain: 'ethereum', + balance: '56789' + }, { address: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c', symbol: 'WBNB', @@ -753,15 +762,6 @@ describe('dripAssets', ()=>{ blockchain: 'bsc', balance: '123456789' }, - { - address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', - symbol: 'DEPAY', - name: 'DePay', - decimals: 18, - type: '20', - blockchain: 'ethereum', - balance: '56789' - }, { address: '0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb', symbol: 'DEPAY', @@ -795,7 +795,7 @@ describe('dripAssets', ()=>{ } }) - expect(dripsCount).toEqual(18) + expect(dripsCount).toEqual(19) let expectedAssets = [{ address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', diff --git a/tests/units/getAssets.evm.spec.js b/tests/units/getAssets.evm.spec.js index 46cd9cb..f1b2d9a 100644 --- a/tests/units/getAssets.evm.spec.js +++ b/tests/units/getAssets.evm.spec.js @@ -1,5 +1,5 @@ import fetchMock from 'fetch-mock' -import { getAssets } from 'src/index.evm' +import { getAssets } from 'dist/esm/index.evm' import { mock, resetMocks } from '@depay/web3-mock' import { getProvider, resetCache } from '@depay/web3-client-evm' diff --git a/yarn.lock b/yarn.lock index 4e652fe..10790a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -896,60 +896,54 @@ "@babel/helper-validator-identifier" "^7.14.9" to-fast-properties "^2.0.0" -"@depay/solana-web3.js@^1.19.0": - version "1.19.0" - resolved "https://registry.yarnpkg.com/@depay/solana-web3.js/-/solana-web3.js-1.19.0.tgz#76ad23b34c6f7c7d375780e78fcb9f32c5bf779a" - integrity sha512-MOIBiuAT+cn4QPRO56c4aEnX/R79K3J8Z+bdXoYVyo7P2BzoXImNgPpqxhIij9MbPjR3q7VaGQvZaJeEsNiQrQ== - -"@depay/web3-blockchains@^6.2.0": - version "6.2.0" - resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-6.2.0.tgz#5ab856ad1ed6aa153e9f25a89c6acb64017367ce" - integrity sha512-giZCoTFjRBoVDZ9WA1tlTtVtw7Pc81E8krjTrErCyoc94avuFUjFRVSf8k/oUdaQ3Yvt+yLQp3cAovlWD9Gnfg== - -"@depay/web3-blockchains@^6.2.3": - version "6.2.3" - resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-6.2.3.tgz#8dbee9ec05e2d581dde0c1b7c4d1a64755e99cbf" - integrity sha512-n917CoFqvlRBzUc7JBxm2H3y8WjEgFtgzwWgfg7OaStn0LqvVRxwc/h1vzPPW8hAANhbpDsLW2b9KKaks6LUBA== - -"@depay/web3-client-evm@^10.1.23": - version "10.1.23" - resolved "https://registry.yarnpkg.com/@depay/web3-client-evm/-/web3-client-evm-10.1.23.tgz#3c9ab6bc1532a702129ccc8904cd86b301fce63a" - integrity sha512-TLEMWzagJF5rNECc+W98M7hIeNGrWs2nzGeDKx+snxRI6v6kzKcqPva1O7aiOdhFAXBBDsv24+cCy2h3h74+6w== - -"@depay/web3-client@^10.1.23": - version "10.1.23" - resolved "https://registry.yarnpkg.com/@depay/web3-client/-/web3-client-10.1.23.tgz#cae1ce44bef5828bf66bb61d48bd68ee56331fdb" - integrity sha512-/Y7DcK/lhI89+2u5Ut57cIz4B3UtnmNAY+9k+v/dzxRAvdvGgUkFsgJ7zDFLqAqQsk0ZQ3Jkck8MtUuQ1bhvxQ== - -"@depay/web3-constants@^6.3.1": - version "6.3.1" - resolved "https://registry.yarnpkg.com/@depay/web3-constants/-/web3-constants-6.3.1.tgz#2d15434774588ece0be69290087046a113340f3d" - integrity sha512-6jpYksmKFFadotlOujlF9PUAypneeIPTtiv70iPbFuV0OvZ9F/eG7FMHEBFEl4QpHOSyzbxMOSRWz4YnvYCOXg== - -"@depay/web3-constants@^6.3.2": - version "6.3.2" - resolved "https://registry.yarnpkg.com/@depay/web3-constants/-/web3-constants-6.3.2.tgz#13a6066f20baee3ea94b373eebc69bd2c4c9773b" - integrity sha512-It2ygcxIrSXMB3ilHmgtq0EMfBGf42sgnaCFbF9Lz80gPjC7O2NifNv8h3gRd/8Fy3XwzCLkjDqbVIgn7kV9tQ== - -"@depay/web3-mock@^13.22.4": - version "13.22.4" - resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-13.22.4.tgz#d0d84ea1d217420a67af70602153b443bffbbb9d" - integrity sha512-9EWA2ysH1YF9kT5HhhR6ZK4gATG0W5bDFbJTYqw7jX8bfFyTCtCnsESd4crW1v2+oj7cqIYGdQKoN06PimlQEQ== - dependencies: - "@depay/web3-blockchains" "^6.2.0" - "@depay/web3-constants" "^6.3.1" +"@depay/solana-web3.js@^1.20.15": + version "1.20.15" + resolved "https://registry.yarnpkg.com/@depay/solana-web3.js/-/solana-web3.js-1.20.15.tgz#6e18476209e04cf29dd30761102e58a0a5b98b4d" + integrity sha512-diPDtBTQDmWDeHo32xWKIO7syd8Vk/wDez8PCU9S4q8RArU8vwBM/fpAlxn+LTBR3O1ci3BTgD/YwDtwAuD7Ig== + +"@depay/web3-blockchains@^7.0.0", "@depay/web3-blockchains@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-7.1.0.tgz#101c4d36e263f5d703e1604899b3b17fdd084bbb" + integrity sha512-/ZhT+c5Z58SCpo9aU7Z2mDGQxMc2Ia2BM8RKt/V337I9fYNp7zRdiYX8U+hnN4BvB9S0yu3l8vRgKwEAU1fhuA== + +"@depay/web3-client-evm@^10.7.1": + version "10.7.1" + resolved "https://registry.yarnpkg.com/@depay/web3-client-evm/-/web3-client-evm-10.7.1.tgz#135b36a67fcd25b05486640c464d72001f766dc7" + integrity sha512-pTiv83NwONTLNcHX7IRq/fDxDy3DJXgOGIoWV8gWhrAjir5v6vTbNdcGPzrSM9n/7jMx6JBY33Tux7kZQTTCWg== + +"@depay/web3-client-solana@^10.7.1": + version "10.7.1" + resolved "https://registry.yarnpkg.com/@depay/web3-client-solana/-/web3-client-solana-10.7.1.tgz#ac909a998ddc9bd7ab1d86f2e7e939dff6ad359d" + integrity sha512-ZSvKzcIgG91G/FMf9xfvE/Z4k0QXnUbFHh5uOnD4p6+oxZ0YpwD5W5+4ONqmV4il2XrHiXkJxI653WxuMdioWQ== + +"@depay/web3-client@^10.7.1": + version "10.7.1" + resolved "https://registry.yarnpkg.com/@depay/web3-client/-/web3-client-10.7.1.tgz#1b50f747e72b8d8cfaf5c67dcfcf72fb3c0e7e49" + integrity sha512-whDS23DH2GeDODOzG5EEpoQFXTQPInyBS9YEtL91U8QiZ6tfzMcXZ/K/EQt8HKH/H0ey96SqFSJS3/eySJVqWA== + +"@depay/web3-mock@^13.26.0": + version "13.26.0" + resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-13.26.0.tgz#d7ad4faf1f8b0f650e2bacb4ffeae1022ecf71de" + integrity sha512-LMticjDtjhifYRC9wCW0VNEt1OS5Asexu7BKY8EyF/C7FWO74YV+TxzILVpPAWLNnKLV9m2KxIs0W30U0QMwFw== + dependencies: + "@depay/solana-web3.js" "^1.20.15" + "@depay/web3-blockchains" "^7.0.0" ethers "^5.7.1" - xhr2 "^0.2.1" -"@depay/web3-tokens-evm@^9.12.8": - version "9.12.8" - resolved "https://registry.yarnpkg.com/@depay/web3-tokens-evm/-/web3-tokens-evm-9.12.8.tgz#f9191a08dac3175c264c9a62b36cebe112ade291" - integrity sha512-FQ937rnlkxWTm9s+bRoEmzKFfJjn8/6rObIW+dzZLMKya8zS7z1PEjumiQy/XwVk++iv2idGF+nsd2hgcIFuKg== +"@depay/web3-tokens-evm@^9.16.0": + version "9.16.0" + resolved "https://registry.yarnpkg.com/@depay/web3-tokens-evm/-/web3-tokens-evm-9.16.0.tgz#476638c3717ae36decb836a279985d59b8091265" + integrity sha512-+Izm9g+L25FABQD+kJx8aCLsrmZT/LStYAOoq/xGCKiwgCmAx+0A5cSXF98BCRNiQ/gmAAH3J4XGRM7azAiIng== -"@depay/web3-tokens@^9.12.8": - version "9.12.8" - resolved "https://registry.yarnpkg.com/@depay/web3-tokens/-/web3-tokens-9.12.8.tgz#eec89c3e15cc508cb6b415141e9d8df09f1021e9" - integrity sha512-tNvnxFh3oEmzO0Hxr2SjFjwLVdZwVBVCeEKdXa7h45+WX+UJJ+qugAdU+e8UN55/i6ej2Wqiu+PjUdT4qbSMZg== +"@depay/web3-tokens-solana@^9.16.0": + version "9.16.0" + resolved "https://registry.yarnpkg.com/@depay/web3-tokens-solana/-/web3-tokens-solana-9.16.0.tgz#d48e727cd7feac313b0561dbaacdacc6a6324416" + integrity sha512-01Qetb5dHYBL/z2bTPDJ/xcTQimwGpSRMJHHFuDNmH7Q8183BA5RBUnR9XNnabhqG3Ccsfi1qg1AGB2O5VPEKw== + +"@depay/web3-tokens@^9.16.0": + version "9.16.0" + resolved "https://registry.yarnpkg.com/@depay/web3-tokens/-/web3-tokens-9.16.0.tgz#dc35e45e5b2629a3c07cc2a5f210357ba0167736" + integrity sha512-QAOfgRj5bfpNmHedO52BGwH8tSW8PMtVZ29S14iaCqKOm2WA03C33ro70Lzvsb5jhfSJy5HGuw++VWXMloVKwA== "@eslint/eslintrc@^0.4.3": version "0.4.3" @@ -1403,6 +1397,16 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" +"@jsbits/escape-regex-str@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@jsbits/escape-regex-str/-/escape-regex-str-1.0.3.tgz#d35a2d21dfdc81a0e5ebeb68b6a16e17ca36ad20" + integrity sha512-0800vYI2fg1nuUq/T9Tqv8DMOLLNiRAltxFbKIbR7szrvW6qTuI2+zGK51hV7NAAmUr4G83Kvpj2R6Yyg07iIw== + +"@jsbits/get-package-version@^1.0.2", "@jsbits/get-package-version@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@jsbits/get-package-version/-/get-package-version-1.0.3.tgz#a47dfd077420beee435580c3bc197931fe3c694c" + integrity sha512-IJy1jRL01x7p6UEpgKa1lVLstMUx8EiIR8pPoS5sBfsHEoeLkzYiNpAfxPx8zLDUJyS1yBbChJjcWdPqyH285w== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -3127,6 +3131,11 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.2.0.tgz#307df42547e6cc7324d3cf03c155d5cdb8c53880" integrity sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ== +estree-walker@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" + integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== + estree-walker@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" @@ -3783,6 +3792,17 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +jscc@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/jscc/-/jscc-1.1.1.tgz#fb329325773a80bcf3e3db3acec6a3f21e61ed0e" + integrity sha512-anpZkTXwZbxfxLEBMciKxXMHx2xOLK2qhynIhTnoSyC+wGOEPrAoofxnADgblbarn0kijVMt1U71cQGmRF/1Og== + dependencies: + "@jsbits/escape-regex-str" "^1.0.2" + "@jsbits/get-package-version" "^1.0.2" + magic-string "^0.25.1" + perf-regexes "^1.0.1" + skip-regex "^1.0.2" + jsdom@^19.0.0: version "19.0.0" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-19.0.0.tgz#93e67c149fe26816d38a849ea30ac93677e16b6a" @@ -4005,6 +4025,13 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +magic-string@^0.25.1: + version "0.25.9" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" + integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== + dependencies: + sourcemap-codec "^1.4.8" + magic-string@^0.25.7: version "0.25.7" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" @@ -4117,6 +4144,13 @@ node-fetch@2.6.7: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.9.tgz#7c7f744b5cc6eb5fd404e0c7a9fec630a55657e6" + integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg== + dependencies: + whatwg-url "^5.0.0" + node-modules-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40" @@ -4339,6 +4373,11 @@ path-type@^4.0.0: resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== +perf-regexes@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/perf-regexes/-/perf-regexes-1.0.1.tgz#6da1d62f5a94bf9353a0451bccacf69068b75d0b" + integrity sha512-L7MXxUDtqr4PUaLFCDCXBfGV/6KLIuSEccizDI7JxT+c9x1G1v04BQ4+4oag84SHaCdrBgQAIs/Cqn+flwFPng== + picocolors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" @@ -4593,6 +4632,15 @@ rollup-plugin-delete@^2.0.0: dependencies: del "^5.1.0" +rollup-plugin-jscc@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-jscc/-/rollup-plugin-jscc-2.0.0.tgz#1ad2f74ab3248dcaaa5ebff0b838418e22243ce6" + integrity sha512-5jG9q79K2u5uRBTKA+GA4gqt1zA7qHQRpcabZMoVs913gr75s428O7K3r58n2vADDzwIhiOKMo7rCMhOyks6dw== + dependencies: + "@jsbits/get-package-version" "^1.0.3" + jscc "^1.1.1" + rollup-pluginutils "^2.8.2" + rollup-plugin-livereload@^2.0.0: version "2.0.5" resolved "https://registry.yarnpkg.com/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.5.tgz#4747fa292a2cceb0c972c573d71b3d66b4252b37" @@ -4608,6 +4656,13 @@ rollup-plugin-serve@^1.1.0: mime ">=2.4.6" opener "1" +rollup-pluginutils@^2.8.2: + version "2.8.2" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" + integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== + dependencies: + estree-walker "^0.6.1" + rollup@^2.34.2: version "2.56.3" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.56.3.tgz#b63edadd9851b0d618a6d0e6af8201955a77aeff" @@ -4717,6 +4772,11 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" +skip-regex@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/skip-regex/-/skip-regex-1.0.2.tgz#ac655d77e7c771ac2b9f37585fea37bff56ad65b" + integrity sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA== + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -4749,7 +4809,7 @@ source-map@^0.6.0, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -sourcemap-codec@^1.4.4: +sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== @@ -5256,11 +5316,6 @@ ws@^8.2.3: resolved "https://registry.yarnpkg.com/ws/-/ws-8.6.0.tgz#e5e9f1d9e7ff88083d0c0dd8281ea662a42c9c23" integrity sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw== -xhr2@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.2.1.tgz#4e73adc4f9cfec9cbd2157f73efdce3a5f108a93" - integrity sha512-sID0rrVCqkVNUn8t6xuv9+6FViXjUVXq8H5rWOH2rz9fDNQEd4g0EA2XlcEdJXRz5BMEn4O1pJFdT+z4YHhoWw== - xml-name-validator@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-4.0.0.tgz#79a006e2e63149a8600f15430f0a4725d1524835"