From 5122b8ecbf0acd28bd0b215b24484fb5f65bedbb Mon Sep 17 00:00:00 2001 From: hzz780 Date: Tue, 17 May 2022 15:36:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Decimal=20null=20->=20def?= =?UTF-8?q?ault=200;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/utils.js | 8 ++++---- src/formatters/index.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/utils.js b/src/common/utils.js index 337af53..f2d5c09 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -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) { @@ -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 @@ -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}` }), {}); } diff --git a/src/formatters/index.js b/src/formatters/index.js index c8cf354..c16508c 100644 --- a/src/formatters/index.js +++ b/src/formatters/index.js @@ -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; @@ -132,7 +132,7 @@ function tokenCreatedFormatter(transaction, chainId) { name: params.tokenName, total_supply: params.totalSupply, supply: 0, - decimals: params.decimals + decimals: params.decimals || 0 } ]; }