Skip to content

Commit 7728a72

Browse files
authored
Merge pull request #35 from 0xsequence/feat/verify
fix check
2 parents 6f928a7 + d1937b1 commit 7728a72

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/utils/contractVerification.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,19 @@ export const verifyContract = async (params: VerifyContractParams) => {
4242
return response;
4343
}
4444

45-
export const getContractSourceCode = async (contractAddress: string, chainId: string) => {
45+
export const getContractSourceCode = async (contractAddress: string, chainId: string): Promise<string | null> => {
4646
const url = `${ETHERSCAN_V2_API}?chainid=${chainId}&module=contract&action=getsourcecode&address=${contractAddress}&apikey=${process.env.ETHERSCAN_API_KEY}`;
47-
console.log('URL', url);
4847
const response = await fetch(url, {
4948
method: 'GET',
5049
})
5150
.then(res => res.json())
5251
.catch(console.error);
53-
return response.result[0].SourceCode;
52+
return response.result[0].SourceCode ?? null;
5453
}
5554

56-
export const isContractVerified = async (contractAddress: string, chainId: string) => {
55+
export const isContractVerified = async (contractAddress: string, chainId: string): Promise<boolean> => {
5756
const sourceCode = await getContractSourceCode(contractAddress, chainId);
58-
return sourceCode !== null && sourceCode !== undefined;
57+
return sourceCode !== '' && sourceCode !== null && sourceCode !== undefined;
5958
}
6059

6160
/**

0 commit comments

Comments
 (0)