Skip to content

Commit

Permalink
remove redundant function in ERC20 ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
RaaCT0R committed Jul 2, 2024
1 parent 7fdd406 commit a5f7f5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
15 changes: 1 addition & 14 deletions packages/chains/evm/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const transferABI: InterfaceAbi = [
},
];

export const ERC20ABI: InterfaceAbi = [
export const PartialERC20ABI: InterfaceAbi = [
{
constant: true,
inputs: [],
Expand Down Expand Up @@ -66,17 +66,4 @@ export const ERC20ABI: InterfaceAbi = [
payable: false,
type: 'function',
},
{
constant: true,
inputs: [],
name: 'symbol',
outputs: [
{
name: '',
type: 'string',
},
],
payable: false,
type: 'function',
},
];
15 changes: 11 additions & 4 deletions packages/networks/evm-rpc/lib/EvmRpcNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import {
AssetBalance,
BlockInfo,
FailedError,
NetworkError,
TokenDetail,
UnexpectedApiError,
} from '@rosen-chains/abstract-chain';
import JsonBigInt from '@rosen-bridge/json-bigint';
import { AbstractEvmNetwork, ERC20ABI } from '@rosen-chains/evm';
import { AbstractEvmNetwork, PartialERC20ABI } from '@rosen-chains/evm';
import {
Block,
JsonRpcProvider,
Expand Down Expand Up @@ -189,7 +188,11 @@ class EvmRpcNetwork extends AbstractEvmNetwork {
*/
getTokenDetail = async (tokenId: string): Promise<TokenDetail> => {
try {
const contract = new ethers.Contract(tokenId, ERC20ABI, this.provider);
const contract = new ethers.Contract(
tokenId,
PartialERC20ABI,
this.provider
);
const name = await contract.name();
const decimals = await contract.decimals();
return {
Expand All @@ -214,7 +217,11 @@ class EvmRpcNetwork extends AbstractEvmNetwork {
tokenId: string
): Promise<bigint> => {
try {
const contract = new ethers.Contract(tokenId, ERC20ABI, this.provider);
const contract = new ethers.Contract(
tokenId,
PartialERC20ABI,
this.provider
);
const balance = await contract.balanceOf(address);
this.logger.debug(
`requested 'balanceOf' method of [${tokenId}] contract from ${
Expand Down

0 comments on commit a5f7f5f

Please sign in to comment.