diff --git a/README.md b/README.md index c6db9ac..da411a7 100644 --- a/README.md +++ b/README.md @@ -20,27 +20,27 @@ let assets = await getAssets({ apiKey: 'XXX' }) // "symbol": "DAI", // "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", // "blockchain": "ethereum", -// "type": "ERC20", +// "type": "20", // "balance": "8007804249707967889272" // }, { // "name": "DePay", // "symbol": "DEPAY", // "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb", // "blockchain": "ethereum", -// "type": "ERC20", +// "type": "20", // "balance": "212816860003097638129" // }, { // "name": "PancakeSwap Token", // "symbol": "CAKE", // "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", // "blockchain": "bsc", -// "type": "BEP20", +// "type": "20", // "balance": "2221112213212321" // } //] ``` -This requires you to have a [DePay PRO apiKey](https://depay.fi/documentation/api#introduction). +This requires you to have a [DePay Api Key](https://depay.fi/documentation/api#introduction). ## Support @@ -49,10 +49,6 @@ This library supports the following blockchains: - [Ethereum](https://ethereum.org) - [Binance Smart Chain](https://www.binance.org/en/smartChain) -This library supports the following wallets: - -- [MetaMask](https://metamask.io) - ## Functionalities ### getAssets @@ -72,21 +68,21 @@ let assets = await getAssets({ apiKey: 'XXX' }) // "symbol": "DAI", // "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", // "blockchain": "ethereum", -// "type": "ERC20", +// "type": "20", // "balance": "8007804249707967889272" // }, { // "name": "DePay", // "symbol": "DEPAY", // "address": "0xa0bEd124a09ac2Bd941b10349d8d224fe3c955eb", // "blockchain": "ethereum", -// "type": "ERC20", +// "type": "20", // "balance": "212816860003097638129" // }, { // "name": "PancakeSwap Token", // "symbol": "CAKE", // "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", // "blockchain": "bsc", -// "type": "BEP20", +// "type": "20", // "balance": "2221112213212321" // } //] @@ -102,7 +98,7 @@ let assets = await getAssets({ blockchain: 'bsc', apiKey: 'XXX' }) // "symbol": "CAKE", // "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", // "blockchain": "bsc", -// "type": "BEP20", +// "type": "20", // "balance": "2221112213212321" // } //] @@ -118,7 +114,7 @@ let assets = await getAssets({ account: '0xEcA533Ef096f191A35DE76aa4580FA3A72272 // "symbol": "CAKE", // "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82", // "blockchain": "bsc", -// "type": "BEP20", +// "type": "20", // "balance": "2221112213212321" // } //] diff --git a/dist/cjs/index.js b/dist/cjs/index.js index 569a6ff..242b91f 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -48,8 +48,8 @@ const getAssets = async (options) => { let assets = Promise.all( (options.blockchain ? [options.blockchain] : wallet.blockchains).map((blockchain) =>{ - return fetch('https://api.depay.pro/v1/assets?account=' + account + '&blockchain=' + blockchain, { - headers: { 'X-Api-Key': options.apiKey } + return fetch(`https://api.depay.fi/v2/accounts/${blockchain}/${account}/assets`, { + headers: { 'x-api-key': options.apiKey } }) .then((response) => response.json()) .then(async (assets) => { diff --git a/dist/es/index.js b/dist/es/index.js index a6413bc..65d1d28 100644 --- a/dist/es/index.js +++ b/dist/es/index.js @@ -44,8 +44,8 @@ const getAssets = async (options) => { let assets = Promise.all( (options.blockchain ? [options.blockchain] : wallet.blockchains).map((blockchain) =>{ - return fetch('https://api.depay.pro/v1/assets?account=' + account + '&blockchain=' + blockchain, { - headers: { 'X-Api-Key': options.apiKey } + return fetch(`https://api.depay.fi/v2/accounts/${blockchain}/${account}/assets`, { + headers: { 'x-api-key': options.apiKey } }) .then((response) => response.json()) .then(async (assets) => { diff --git a/dist/umd/index.js b/dist/umd/index.js index 858efdc..aca35f4 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -46,8 +46,8 @@ let assets = Promise.all( (options.blockchain ? [options.blockchain] : wallet.blockchains).map((blockchain) =>{ - return fetch('https://api.depay.pro/v1/assets?account=' + account + '&blockchain=' + blockchain, { - headers: { 'X-Api-Key': options.apiKey } + return fetch(`https://api.depay.fi/v2/accounts/${blockchain}/${account}/assets`, { + headers: { 'x-api-key': options.apiKey } }) .then((response) => response.json()) .then(async (assets) => { diff --git a/package.json b/package.json index 59c5ea8..f358206 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/web3-assets", "moduleName": "Web3Assets", - "version": "3.0.0", + "version": "4.0.0", "description": "", "main": "dist/cjs/index.js", "module": "dist/es/index.js", diff --git a/src/index.js b/src/index.js index a0591ea..7c1af94 100644 --- a/src/index.js +++ b/src/index.js @@ -44,8 +44,8 @@ const getAssets = async (options) => { let assets = Promise.all( (options.blockchain ? [options.blockchain] : undefined || wallet.blockchains).map((blockchain) =>{ - return fetch('https://api.depay.pro/v1/assets?account=' + account + '&blockchain=' + blockchain, { - headers: { 'X-Api-Key': options.apiKey } + return fetch(`https://api.depay.fi/v2/accounts/${blockchain}/${account}/assets`, { + headers: { 'x-api-key': options.apiKey } }) .then((response) => response.json()) .then(async (assets) => { diff --git a/tests/units/getAssets.spec.js b/tests/units/getAssets.spec.js index 6333838..e3d9e9c 100644 --- a/tests/units/getAssets.spec.js +++ b/tests/units/getAssets.spec.js @@ -28,7 +28,7 @@ describe('assets', ()=>{ beforeEach(()=>{ mock({ blockchain: 'ethereum', wallet: 'metamask' }) fetchMock.get({ - url: 'https://api.depay.pro/v1/assets?account=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&blockchain=ethereum', + url: 'https://api.depay.fi/v2/accounts/ethereum/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/assets', headers: { 'X-Api-Key': 'TEST-123' } }, [{ "name": "Ether", @@ -43,7 +43,7 @@ describe('assets', ()=>{ }] ) fetchMock.get({ - url: 'https://api.depay.pro/v1/assets?account=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&blockchain=bsc', + url: 'https://api.depay.fi/v2/accounts/bsc/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/assets', headers: { 'X-Api-Key': 'TEST-123' } }, [{ "name": "Binance Coin", @@ -134,7 +134,7 @@ describe('assets', ()=>{ it('fetches the assets for a given account without any connected wallet', async()=> { let account = '0xEcA533Ef096f191A35DE76aa4580FA3A722724bE' fetchMock.get({ - url: `https://api.depay.pro/v1/assets?account=${account}&blockchain=ethereum`, + url: `https://api.depay.fi/v2/accounts/ethereum/${account}/assets`, headers: { 'X-Api-Key': 'TEST-123' } }, [{ "name": "Ether", @@ -175,7 +175,7 @@ describe('assets', ()=>{ beforeEach(()=>{ mock({ blockchain: 'ethereum', wallet: 'metamask' }) fetchMock.get({ - url: 'https://api.depay.pro/v1/assets?account=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&blockchain=ethereum', + url: 'https://api.depay.fi/v2/accounts/ethereum/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/assets', headers: { 'X-Api-Key': 'TEST-123' } }, [{ "name": "Dai Stablecoin", @@ -185,7 +185,7 @@ describe('assets', ()=>{ }] ) fetchMock.get({ - url: 'https://api.depay.pro/v1/assets?account=0xd8da6bf26964af9d7eed9e03e53415d37aa96045&blockchain=bsc', + url: 'https://api.depay.fi/v2/accounts/bsc/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/assets', headers: { 'X-Api-Key': 'TEST-123' } }, [{ "name": "PancakeSwap",