Skip to content

Commit

Permalink
slight refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Dec 6, 2022
1 parent ee563d3 commit 85607ed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@metamask/base-controller": "workspace:^",
"@metamask/abi-utils": "^1.1.0",
"@metamask/base-controller": "workspace:^",
"@metamask/contract-metadata": "^1.35.0",
"@metamask/controller-utils": "workspace:^",
"@metamask/metamask-eth-abis": "3.0.0",
Expand Down
7 changes: 2 additions & 5 deletions packages/assets-controllers/src/Standards/ERC20Standard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Contract } from '@ethersproject/contracts';
import { abiERC20 } from '@metamask/metamask-eth-abis';
import { BN, toUtf8 } from 'ethereumjs-util';
import { decode } from '@metamask/abi-utils';
import { decodeSingle } from '@metamask/abi-utils';

import { Web3Provider } from '@ethersproject/providers';
import { ERC20 } from '@metamask/controller-utils';
Expand Down Expand Up @@ -59,10 +59,7 @@ export class ERC20Standard {
const result = (await this.provider.call(payload)) as `0x${string}`;
// Parse as string - treat empty string as failure
try {
const decoded = decode(['string'], result)[0] as string;
if (decoded?.length > 0) {
return decoded;
}
return decodeSingle('string', result) as string;
} catch {
// Ignore error
}
Expand Down
2 changes: 1 addition & 1 deletion tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import 'isomorphic-fetch';
import { TextDecoder } from 'util';

// not sure why this is a type mismatch and has to be type cast to any...?
global.TextDecoder = TextDecoder as any;
global.TextDecoder = TextDecoder as any;

0 comments on commit 85607ed

Please sign in to comment.