mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 13:47:06 +01:00
13 lines
340 B
JavaScript
13 lines
340 B
JavaScript
|
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 };
|
||
|
};
|