mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
03e3edb00c
* Refactor checking if address is contract into a new module. Tests for new module. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * addressIsContract is an async function, use await when calling it. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Mock ethQuery change variable names refactor in transaction.utils. fix possible boolean destructiring. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Refactor isContractAddress boolean checks. Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Lint fixes Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
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 };
|
|
};
|