Skip to content

Commit

Permalink
controller-utils,gas-controller: remove redundant toString call
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Nov 20, 2023
1 parent 3727aaa commit 515c477
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@metamask/auto-changelog": "^3.4.3",
"@metamask/eth-query": "^4.0.0",
"@types/jest": "^27.4.1",
"bn.js": "^5.2.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"nock": "^13.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function gweiDecToWEIBN(n: number | string) {
*/
export function weiHexToGweiDec(hex: string) {
const hexWei = new BN(stripHexPrefix(hex), 16);
return fromWei(hexWei, 'gwei').toString(10);
return fromWei(hexWei, 'gwei');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/src/gas-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const makeClientIdHeader = (clientId: string) => ({ 'X-Client-Id': clientId });
*/
export function normalizeGWEIDecimalNumbers(n: string | number) {
const numberAsWEIHex = gweiDecToWEIBN(n).toString(16);
const numberAsGWEI = weiHexToGweiDec(numberAsWEIHex).toString(10);
const numberAsGWEI = weiHexToGweiDec(numberAsWEIHex);
return numberAsGWEI;
}

Expand Down
39 changes: 38 additions & 1 deletion types/@metamask/ethjs-unit.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
declare module '@metamask/ethjs-unit';
declare module '@metamask/ethjs-unit' {
import type BN from 'bn.js';

Check failure on line 2 in types/@metamask/ethjs-unit.d.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test / Lint (20.x)

"bn.js" is extraneous

type EthDenomination =
| 'noether'
| 'wei'
| 'kwei'
| 'Kwei'
| 'babbage'
| 'femtoether'
| 'mwei'
| 'Mwei'
| 'lovelace'
| 'picoether'
| 'gwei'
| 'Gwei'
| 'shannon'
| 'nanoether'
| 'nano'
| 'szabo'
| 'microether'
| 'micro'
| 'finney'
| 'milliether'
| 'milli'
| 'ether'
| 'kether'
| 'grand'
| 'mether'
| 'gether'
| 'tether';
function fromWei(
weiInput: number | string | BN,
unit: EthDenomination,
optionsInput?: { pad?: boolean; commify?: boolean },
): string;
function toWei(etherInput: number | string | BN, unit: EthDenomination): BN;
}
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ __metadata:
"@metamask/utils": ^8.2.0
"@spruceid/siwe-parser": 1.1.3
"@types/jest": ^27.4.1
bn.js: ^5.2.1
deepmerge: ^4.2.2
eth-ens-namehash: ^2.0.8
ethereumjs-util: ^7.0.10
Expand Down

0 comments on commit 515c477

Please sign in to comment.