From 0916fd7afa1bd0a0a8fd13a39ec948b5a5d4c61a Mon Sep 17 00:00:00 2001 From: Sebastian Pape Date: Mon, 27 Dec 2021 15:22:23 +0100 Subject: [PATCH] v5.0.0: drop cjs support and focus on umd+esm --- dev.html | 2 +- dist/cjs/index.js | 68 --------------------------------------- dist/{es => esm}/index.js | 0 package.json | 12 +++---- rollup.module.config.js | 7 +--- yarn.lock | 16 ++++----- 6 files changed, 16 insertions(+), 89 deletions(-) delete mode 100644 dist/cjs/index.js rename dist/{es => esm}/index.js (100%) diff --git a/dev.html b/dev.html index 24eed52..960f079 100644 --- a/dev.html +++ b/dev.html @@ -11,7 +11,7 @@ - + diff --git a/dist/cjs/index.js b/dist/cjs/index.js deleted file mode 100644 index 242b91f..0000000 --- a/dist/cjs/index.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var web3Constants = require('@depay/web3-constants'); -var web3Wallets = require('@depay/web3-wallets'); -var web3Client = require('@depay/web3-client'); - -const ensureNativeTokenAsset = async ({ account, assets, blockchain }) => { - if(assets.find((asset)=> { - return asset.address.toLowerCase() == web3Constants.CONSTANTS[blockchain].NATIVE.toLowerCase() - }) == undefined) { - let balance = await web3Client.request( - { - blockchain: blockchain, - address: account, - method: 'balance', - }, - { cache: 30000 } - ); - assets = [{ - name: web3Constants.CONSTANTS[blockchain].CURRENCY, - symbol: web3Constants.CONSTANTS[blockchain].SYMBOL, - address: web3Constants.CONSTANTS[blockchain].NATIVE, - type: 'NATIVE', - blockchain, - balance: balance.toString() - }, ...assets]; - } - return assets -}; - -const getAssets = async (options) => { - if(options === undefined) { options = {}; } - - let wallet = await web3Wallets.getWallet(); - - let account; - if(options.account) { - account = options.account; - } else if(wallet) { - account = await wallet.account(); - } - if (!account) { return } - - if(options.apiKey == undefined) { throw 'Web3Wallets: Please pass an apiKey. See documentation.' } - - let assets = Promise.all( - (options.blockchain ? [options.blockchain] : wallet.blockchains).map((blockchain) =>{ - - return fetch(`https://api.depay.fi/v2/accounts/${blockchain}/${account}/assets`, { - headers: { 'x-api-key': options.apiKey } - }) - .then((response) => response.json()) - .then(async (assets) => { - return await ensureNativeTokenAsset({ - account, - assets: assets.map((asset) => Object.assign(asset, { blockchain })), - blockchain - }) - }) - }), - ).then((responses) => responses.flat()); - - return assets -}; - -exports.getAssets = getAssets; diff --git a/dist/es/index.js b/dist/esm/index.js similarity index 100% rename from dist/es/index.js rename to dist/esm/index.js diff --git a/package.json b/package.json index ac45ddb..5d7805b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "@depay/web3-assets", "moduleName": "Web3Assets", - "version": "4.0.2", + "version": "5.0.0", "description": "", - "main": "dist/cjs/index.js", - "module": "dist/es/index.js", + "main": "dist/umd/index.js", + "module": "dist/esm/index.js", "source": "src/index.js", "files": [ "dist" @@ -38,7 +38,7 @@ "@depay/web3-blockchains": "^3.0.0", "@depay/web3-client": "^7.2.0", "@depay/web3-constants": "^4.0.1", - "@depay/web3-wallets": "^6.1.6" + "@depay/web3-wallets": "^7.0.0" }, "engines": { "node": ">=10" @@ -46,12 +46,12 @@ "devDependencies": { "@babel/core": "^7.12.9", "@babel/preset-env": "^7.12.7", - "@depay/walletconnect-v1": "^1.0.17", + "@depay/walletconnect-v1": "^1.0.18", "@depay/web3-blockchains": "^3.0.0", "@depay/web3-client": "^7.2.0", "@depay/web3-constants": "^4.0.1", "@depay/web3-mock": "^9.2.0", - "@depay/web3-wallets": "^6.1.6", + "@depay/web3-wallets": "^7.0.0", "@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-replace": "^2.4.2", diff --git a/rollup.module.config.js b/rollup.module.config.js index fdacca3..6dd1b27 100644 --- a/rollup.module.config.js +++ b/rollup.module.config.js @@ -9,15 +9,10 @@ import { nodeResolve } from '@rollup/plugin-node-resolve' export default { input: 'src/index.js', output: [ - { - format: 'cjs', - globals: globals, - file: 'dist/cjs/index.js' - }, { format: 'es', globals: globals, - file: 'dist/es/index.js' + file: 'dist/esm/index.js' }, { format: 'umd', diff --git a/yarn.lock b/yarn.lock index 5e2c824..16bcdd5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -875,10 +875,10 @@ "@babel/helper-validator-identifier" "^7.14.9" to-fast-properties "^2.0.0" -"@depay/walletconnect-v1@^1.0.17": - version "1.0.17" - resolved "https://registry.yarnpkg.com/@depay/walletconnect-v1/-/walletconnect-v1-1.0.17.tgz#b050103c9b5d2f7bfe757d01c72d2bf6dfeca6f8" - integrity sha512-oNPaqQzO2a4L9iY2jAlWqHEoLzCNvnW1QNIMbbEkhub3yICjIQ5Ly5kyHPkdoTH3EP/YSyfsmLvirZxx7Ivxig== +"@depay/walletconnect-v1@^1.0.18": + version "1.0.18" + resolved "https://registry.yarnpkg.com/@depay/walletconnect-v1/-/walletconnect-v1-1.0.18.tgz#57a368580077b886c68216071f4694b3bd821abc" + integrity sha512-PD1HH7eH3QjGgEU4k4L0PHjIu4WMxX4f5r7wezkP9y1bvlzdGtxfyQCsgY/+0O3iu+spQvfOoY5h8gSO5x1B/A== dependencies: "@walletconnect/client" "^1.6.5" "@walletconnect/qrcode-modal" "^1.6.5" @@ -903,10 +903,10 @@ resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-9.2.0.tgz#f19fb2d3dd7912ba229fcdfa0e1092bb31f16e96" integrity sha512-7XVds6JVlfCPc5A6SyOlaGLkvP3Rh06xEi5h7EAS6BQGZgOyBHLWRbctNqHEbzWexUvW/xtQCdp1ujM1zi0FXA== -"@depay/web3-wallets@^6.1.6": - version "6.1.6" - resolved "https://registry.yarnpkg.com/@depay/web3-wallets/-/web3-wallets-6.1.6.tgz#7f0681abe8cf65be342e9d4b831210ded3e397bf" - integrity sha512-eyUgpafpPW/nKrbGmAyHVwUNniCUyGglLqyt8BXrsEcd0bpAqenzXCdtdJ8NsJSZgOyE3zrtL2cjiv3kVJNFbA== +"@depay/web3-wallets@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@depay/web3-wallets/-/web3-wallets-7.0.0.tgz#ff94c5d9acf4d5ad779ffb4b3d61e79d3e11c809" + integrity sha512-lZzZnAmhfd+Sd5Zthuz0JtkWKJeDl82oIPpgAvQJWe6ecLCyJJ3egxTXvEPBVfnvsE8F6bl4LxuFlf3Ci5twNg== "@eslint/eslintrc@^0.4.3": version "0.4.3"