Skip to content

Commit

Permalink
v6.1.4: fix resolve during fetch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Apr 13, 2022
1 parent 805e2a5 commit 810afdf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 37 deletions.
27 changes: 15 additions & 12 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,22 @@ var getAssets = async (options) => {
let assets = Promise.all(
(Object.keys(options.accounts)).map((blockchain) =>{

const address = options.accounts[blockchain];

return fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`)
.catch((error) => { console.log(error); resolve(); })
.then((response) => response.json())
.then(async (assets) => {
return await ensureNativeTokenAsset({
address,
options,
assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })),
blockchain
return new Promise((resolve, reject)=>{
const address = options.accounts[blockchain];
fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`)
.catch((error) => { console.log(error); resolve(); })
.then((response) => response.json())
.then(async (assets) => {
return await ensureNativeTokenAsset({
address,
options,
assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })),
blockchain
})
})
}).catch((error) => { console.log(error); })
.then(resolve)
.catch((error) => { console.log(error); resolve(); });
})
}),
).then((responses) => responses.flat());

Expand Down
27 changes: 15 additions & 12 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@
let assets = Promise.all(
(Object.keys(options.accounts)).map((blockchain) =>{

const address = options.accounts[blockchain];

return fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`)
.catch((error) => { console.log(error); resolve(); })
.then((response) => response.json())
.then(async (assets) => {
return await ensureNativeTokenAsset({
address,
options,
assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })),
blockchain
return new Promise((resolve, reject)=>{
const address = options.accounts[blockchain];
fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`)
.catch((error) => { console.log(error); resolve(); })
.then((response) => response.json())
.then(async (assets) => {
return await ensureNativeTokenAsset({
address,
options,
assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })),
blockchain
})
})
}).catch((error) => { console.log(error); })
.then(resolve)
.catch((error) => { console.log(error); resolve(); });
})
}),
).then((responses) => responses.flat());

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": "6.1.3",
"version": "6.1.4",
"description": "",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down
27 changes: 15 additions & 12 deletions src/getAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,22 @@ export default async (options) => {
let assets = Promise.all(
(Object.keys(options.accounts)).map((blockchain) =>{

const address = options.accounts[blockchain]

return fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`)
.catch((error) => { console.log(error); resolve() })
.then((response) => response.json())
.then(async (assets) => {
return await ensureNativeTokenAsset({
address,
options,
assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })),
blockchain
return new Promise((resolve, reject)=>{
const address = options.accounts[blockchain]
fetch(`https://public.depay.fi/accounts/${blockchain}/${address}/assets`)
.catch((error) => { console.log(error); resolve() })
.then((response) => response.json())
.then(async (assets) => {
return await ensureNativeTokenAsset({
address,
options,
assets: filterAssets({ assets, blockchain, options }).map((asset) => Object.assign(asset, { blockchain })),
blockchain
})
})
}).catch((error) => { console.log(error) })
.then(resolve)
.catch((error) => { console.log(error); resolve() })
})
}),
).then((responses) => responses.flat())

Expand Down

0 comments on commit 810afdf

Please sign in to comment.