Skip to content

Commit

Permalink
v4.0.0: use new assets api
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Dec 23, 2021
1 parent 2ec13e0 commit ee9bf72
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 27 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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"
// }
//]
Expand All @@ -102,7 +98,7 @@ let assets = await getAssets({ blockchain: 'bsc', apiKey: 'XXX' })
// "symbol": "CAKE",
// "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
// "blockchain": "bsc",
// "type": "BEP20",
// "type": "20",
// "balance": "2221112213212321"
// }
//]
Expand All @@ -118,7 +114,7 @@ let assets = await getAssets({ account: '0xEcA533Ef096f191A35DE76aa4580FA3A72272
// "symbol": "CAKE",
// "address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
// "blockchain": "bsc",
// "type": "BEP20",
// "type": "20",
// "balance": "2221112213212321"
// }
//]
Expand Down
4 changes: 2 additions & 2 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions dist/es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 5 additions & 5 deletions tests/units/getAssets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit ee9bf72

Please sign in to comment.