Skip to content

Commit

Permalink
fix: normalize number from dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv committed Sep 30, 2021
1 parent c82a2d6 commit 6b327a2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ui/views/Approval/components/SignTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { Chain } from 'background/service/chain';

const normalizeHex = (value: string | number) => {
if (typeof value === 'number') {
return intToHex(value);
return intToHex(Math.floor(value));
}
if (typeof value === 'string') {
if (!isHexPrefixed(value)) {
Expand All @@ -58,7 +58,7 @@ const normalizeTxParams = (tx) => {
copy.gas = normalizeHex(copy.gas);
}
if ('gasPrice' in copy) {
copy.gas = normalizeHex(copy.gas);
copy.gasPrice = normalizeHex(copy.gasPrice);
}
if ('value' in copy) {
copy.value = addHexPrefix(unpadHexString(copy.value || '0x0'));
Expand Down Expand Up @@ -319,7 +319,7 @@ const SignTx = ({ params, origin }) => {
const gas = await wallet.openapi.gasMarket(chain!.serverId);
setTx({
...tx,
gasPrice: intToHex(Math.max(...gas.map((item) => item.price))),
gasPrice: intToHex(Math.max(...gas.map((item) => parseInt(item.price)))),
});
};

Expand Down

0 comments on commit 6b327a2

Please sign in to comment.