mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
feature: convert shared/modules/contract-utils.test.js to typescript (#17435)
This commit is contained in:
parent
ab329e5186
commit
787add7c70
@ -1,12 +0,0 @@
|
||||
export const readAddressAsContract = async (ethQuery, address) => {
|
||||
let contractCode;
|
||||
try {
|
||||
contractCode = await ethQuery.getCode(address);
|
||||
} catch (e) {
|
||||
contractCode = null;
|
||||
}
|
||||
|
||||
const isContractAddress =
|
||||
contractCode && contractCode !== '0x' && contractCode !== '0x0';
|
||||
return { contractCode, isContractAddress };
|
||||
};
|
23
shared/modules/contract-utils.ts
Normal file
23
shared/modules/contract-utils.ts
Normal file
@ -0,0 +1,23 @@
|
||||
type contract = {
|
||||
contractCode: string | null;
|
||||
isContractAddress: boolean;
|
||||
};
|
||||
|
||||
export const readAddressAsContract = async (
|
||||
ethQuery: {
|
||||
getCode: (address: string) => string;
|
||||
},
|
||||
address: string,
|
||||
): Promise<contract> => {
|
||||
let contractCode;
|
||||
try {
|
||||
contractCode = await ethQuery.getCode(address);
|
||||
} catch (e) {
|
||||
contractCode = null;
|
||||
}
|
||||
|
||||
const isContractAddress = contractCode
|
||||
? contractCode !== '0x' && contractCode !== '0x0'
|
||||
: false;
|
||||
return { contractCode, isContractAddress };
|
||||
};
|
Loading…
Reference in New Issue
Block a user