Skip to content

Commit

Permalink
fix: 🐛 Decimal null -> default 0;
Browse files Browse the repository at this point in the history
  • Loading branch information
hzz780 committed May 17, 2022
1 parent 1a55124 commit 5122b8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function getDecimal(symbol) {
});
TOKEN_DECIMALS[symbol] = decimals;
}
return TOKEN_DECIMALS[symbol] || 8;
return TOKEN_DECIMALS[symbol] || 0;
}

async function getFee(transaction) {
Expand All @@ -99,14 +99,14 @@ async function getFee(transaction) {
return {
fee: fee.map((v, i) => ({
...v,
amount: new Decimal(v.amount).dividedBy(`1e${feeDecimals[i] || 8}`).toNumber()
amount: new Decimal(v.amount).dividedBy(`1e${feeDecimals[i] || 0}`).toNumber()
})).reduce((acc, v) => ({
...acc,
[v.symbol]: v.amount
}), {}),
resources: resourceFees.map((v, i) => ({
...v,
amount: new Decimal(v.amount).dividedBy(`1e${resourceDecimals[i] || 8}`).toNumber()
amount: new Decimal(v.amount).dividedBy(`1e${resourceDecimals[i] || 0}`).toNumber()
})).reduce((acc, v) => ({
...acc,
[v.symbol]: v.amount
Expand All @@ -122,7 +122,7 @@ async function getDividend(height) {
const decimals = await Promise.all(Object.keys(dividends).map(getDecimal));
return Object.keys(dividends).reduce((acc, v, i) => ({
...acc,
[v]: +dividends[v] / `1e${decimals[i]}`
[v]: +dividends[v] / `1e${decimals[i] || 0}`
}), {});
}

Expand Down
4 changes: 2 additions & 2 deletions src/formatters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function tokenCreatedFormatter(transaction, chainId) {
name: l.tokenName,
total_supply: l.totalSupply,
supply: 0,
decimals: l.decimals
decimals: l.decimals || 0
}));
if (list.length > 0) {
return list;
Expand All @@ -132,7 +132,7 @@ function tokenCreatedFormatter(transaction, chainId) {
name: params.tokenName,
total_supply: params.totalSupply,
supply: 0,
decimals: params.decimals
decimals: params.decimals || 0
}
];
}
Expand Down

0 comments on commit 5122b8e

Please sign in to comment.