|
|
|
@ -14,6 +14,8 @@ export interface IVerifyContractData { |
|
|
|
|
isLoading: boolean; |
|
|
|
|
argsLoading: boolean; |
|
|
|
|
error: string; |
|
|
|
|
tab: string; |
|
|
|
|
fileList?: File[]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export interface IVerifyContractDataSendData { |
|
|
|
@ -26,32 +28,76 @@ export interface IVerifyContractDataSendData { |
|
|
|
|
constructorArguments: string; |
|
|
|
|
chainType: string; |
|
|
|
|
contractName: string; |
|
|
|
|
fileList?: File[], |
|
|
|
|
tab: string, |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const verifyContractCode = async (data: IVerifyContractDataSendData) => { |
|
|
|
|
const response = await fetch( |
|
|
|
|
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`, |
|
|
|
|
{ |
|
|
|
|
method: "POST", |
|
|
|
|
mode: "cors", |
|
|
|
|
cache: "no-cache", |
|
|
|
|
credentials: "same-origin", |
|
|
|
|
headers: { |
|
|
|
|
"Content-Type": "application/json", |
|
|
|
|
}, |
|
|
|
|
redirect: "follow", |
|
|
|
|
referrerPolicy: "no-referrer", |
|
|
|
|
body: JSON.stringify(data), |
|
|
|
|
|
|
|
|
|
if (data.tab === "Multiple Source Files") { |
|
|
|
|
const formData = new FormData(); |
|
|
|
|
data.fileList?.forEach(file=>{ |
|
|
|
|
formData.append(file.name, file); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) { |
|
|
|
|
if (k === "fileList") continue; |
|
|
|
|
|
|
|
|
|
if (k === "libraries") { |
|
|
|
|
formData.append(k, v.join(",")); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
formData.append(k, v); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const body = await response.json(); |
|
|
|
|
const response = await fetch( |
|
|
|
|
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`, |
|
|
|
|
{ |
|
|
|
|
method: "POST", |
|
|
|
|
mode: "cors", |
|
|
|
|
cache: "no-cache", |
|
|
|
|
credentials: "same-origin", |
|
|
|
|
redirect: "follow", |
|
|
|
|
referrerPolicy: "no-referrer", |
|
|
|
|
body: formData, |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (response.status !== 200) { |
|
|
|
|
throw new Error(body?.message); |
|
|
|
|
const body = await response.json(); |
|
|
|
|
|
|
|
|
|
if (response.status !== 200) { |
|
|
|
|
throw new Error(body?.message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return body; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
const response = await fetch( |
|
|
|
|
`${process.env.REACT_APP_EXPLORER_V1_API_URL}codeVerification`, |
|
|
|
|
{ |
|
|
|
|
method: "POST", |
|
|
|
|
mode: "cors", |
|
|
|
|
cache: "no-cache", |
|
|
|
|
credentials: "same-origin", |
|
|
|
|
headers: { |
|
|
|
|
"Content-Type": "application/json", |
|
|
|
|
}, |
|
|
|
|
redirect: "follow", |
|
|
|
|
referrerPolicy: "no-referrer", |
|
|
|
|
body: JSON.stringify(data), |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return body; |
|
|
|
|
const body = await response.json(); |
|
|
|
|
|
|
|
|
|
if (response.status !== 200) { |
|
|
|
|
throw new Error(body?.message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return body; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export const loadSourceCode = async (address: string): Promise<ISourceCode> => { |
|
|
|
@ -70,6 +116,7 @@ export const loadSourceCode = async (address: string): Promise<ISourceCode> => { |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const body = await response.json(); |
|
|
|
|
console.log(body); |
|
|
|
|
|
|
|
|
|
if (response.status !== 200) { |
|
|
|
|
throw new Error(body); |
|
|
|
@ -84,6 +131,7 @@ export interface ISourceCode { |
|
|
|
|
optimizer: string; |
|
|
|
|
optimizerTimes: string; |
|
|
|
|
sourceCode: string; |
|
|
|
|
supporting: any; |
|
|
|
|
libraries: string[]; |
|
|
|
|
constructorArguments: string; |
|
|
|
|
chainType: string; |
|
|
|
|