Skip to content

Commit

Permalink
slight refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Nov 22, 2022
1 parent 9c67cb6 commit c133fed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
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 c133fed

Please sign in to comment.