Skip to content

Commit

Permalink
v7.1.2: fix asset meta data completion (decimals, name etc.)
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Aug 20, 2023
1 parent 16cc3bd commit c776034
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 17 deletions.
14 changes: 12 additions & 2 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,21 @@ var dripAssets = async (options) => {
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)=>{
const token = new Token(asset);
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance);
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name();
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol();
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals();
}
assets.push(assetWithBalance);
drip(assetWithBalance);
resolve(assetWithBalance);
Expand Down
14 changes: 12 additions & 2 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,21 @@ var dripAssets = async (options) => {
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)=>{
const token = new Token(asset);
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance);
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name();
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol();
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals();
}
assets.push(assetWithBalance);
drip(assetWithBalance);
resolve(assetWithBalance);
Expand Down
14 changes: 12 additions & 2 deletions dist/esm/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,21 @@ var dripAssets = async (options) => {
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)=>{
const token = new Token(asset);
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance);
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name();
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol();
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals();
}
assets.push(assetWithBalance);
drip(assetWithBalance);
resolve(assetWithBalance);
Expand Down
14 changes: 12 additions & 2 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,21 @@
let allAssets = await getAssets(options);
promises = promises.concat((allAssets.map((asset)=>{
return new Promise((resolve, reject)=>{
return new Token__default['default'](asset).balance(options.accounts[asset.blockchain])
.then((balance)=>{
const token = new Token__default['default'](asset);
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance);
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name();
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol();
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals();
}
assets.push(assetWithBalance);
drip(assetWithBalance);
resolve(assetWithBalance);
Expand Down
14 changes: 12 additions & 2 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,21 @@
let allAssets = await getAssets(options);
promises = promises.concat((allAssets.map((asset)=>{
return new Promise((resolve, reject)=>{
return new Token__default['default'](asset).balance(options.accounts[asset.blockchain])
.then((balance)=>{
const token = new Token__default['default'](asset);
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance);
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name();
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol();
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals();
}
assets.push(assetWithBalance);
drip(assetWithBalance);
resolve(assetWithBalance);
Expand Down
14 changes: 12 additions & 2 deletions dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,21 @@
let allAssets = await getAssets(options);
promises = promises.concat((allAssets.map((asset)=>{
return new Promise((resolve, reject)=>{
return new Token__default['default'](asset).balance(options.accounts[asset.blockchain])
.then((balance)=>{
const token = new Token__default['default'](asset);
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance);
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name();
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol();
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals();
}
assets.push(assetWithBalance);
drip(assetWithBalance);
resolve(assetWithBalance);
Expand Down
17 changes: 17 additions & 0 deletions examples/drip.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,20 @@ let allAssets = await Web3Assets.dripAssets({

console.log('allAssets', allAssets)
```


```javascript
let allAssets = await Web3Assets.dripAssets({
accounts: {
solana: '2UgCJaHU5y8NC4uWQcZYeV9a5RyYLF7iKYCybCsdFFD1',
},
priority: [
{ blockchain: 'solana', address: Web3Blockchains.solana.currency.address },
],
drip: (asset)=>{
console.log('drip asset', asset)
}
})

console.log('allAssets', allAssets)
```
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-assets-evm",
"moduleName": "Web3Assets",
"version": "7.1.1",
"version": "7.1.2",
"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",
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": "7.1.1",
"version": "7.1.2",
"description": "JavaScript library to retrieve Web3 assets of a given or connected wallet/account.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-assets-solana",
"moduleName": "Web3Assets",
"version": "7.1.1",
"version": "7.1.2",
"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",
Expand Down
14 changes: 12 additions & 2 deletions src/dripAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,21 @@ export default async (options) => {
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)=>{
const token = new Token(asset)
return token.balance(options.accounts[asset.blockchain])
.then(async(balance)=>{
if(exists({ assets, asset })) { return resolve() }
const assetWithBalance = reduceAssetWithBalance(asset, balance)
if(assetWithBalance.balance != '0') {
if(assetWithBalance.name === undefined) {
assetWithBalance.name = await token.name()
}
if(assetWithBalance.symbol === undefined) {
assetWithBalance.symbol = await token.symbol()
}
if(assetWithBalance.decimals === undefined) {
assetWithBalance.decimals = await token.decimals()
}
assets.push(assetWithBalance)
drip(assetWithBalance)
resolve(assetWithBalance)
Expand Down

0 comments on commit c776034

Please sign in to comment.