|
|
@ -59,16 +59,7 @@ export async function compile(url: string, contract: Contract): Promise<any> { |
|
|
|
if (extension !== 'vy') { |
|
|
|
if (extension !== 'vy') { |
|
|
|
throw new Error('Use extension .vy for Vyper.') |
|
|
|
throw new Error('Use extension .vy for Vyper.') |
|
|
|
} |
|
|
|
} |
|
|
|
const nameResult = normalizeContractPath(contract.name) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const files = new FormData();
|
|
|
|
|
|
|
|
// const content = new Blob([contract.content], {
|
|
|
|
|
|
|
|
// type: 'text/plain'
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// files.append('files', content, `${nameResult[2]}.vy`)
|
|
|
|
|
|
|
|
// files.append('data', JSON.stringify({vyper_version: '0.3.10'}))
|
|
|
|
|
|
|
|
type ByteCodeType = { bytecode: string, linkReferences: { offset: any; length: number; name?: string; }; linkDependencies?: { offsets: number[]; }; } |
|
|
|
|
|
|
|
const contractName = contract['name'] |
|
|
|
const contractName = contract['name'] |
|
|
|
const compilePackage = { |
|
|
|
const compilePackage = { |
|
|
|
manifest: 'ethpm/3', |
|
|
|
manifest: 'ethpm/3', |
|
|
@ -76,8 +67,9 @@ export async function compile(url: string, contract: Contract): Promise<any> { |
|
|
|
[contractName] : {content : contract.content} |
|
|
|
[contractName] : {content : contract.content} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log('about to compile contract!!!') |
|
|
|
const response = await axios.post(`${url}compile`, compilePackage ) |
|
|
|
const response = await axios.post(`${url}compile`, compilePackage ) |
|
|
|
console.log({response}) |
|
|
|
|
|
|
|
if (response.status === 404) { |
|
|
|
if (response.status === 404) { |
|
|
|
throw new Error(`Vyper compiler not found at "${url}".`) |
|
|
|
throw new Error(`Vyper compiler not found at "${url}".`) |
|
|
|
} |
|
|
|
} |
|
|
@ -91,21 +83,18 @@ export async function compile(url: string, contract: Contract): Promise<any> { |
|
|
|
const status = await (await axios.get(url + 'status/' + compileCode , { |
|
|
|
const status = await (await axios.get(url + 'status/' + compileCode , { |
|
|
|
method: 'Get' |
|
|
|
method: 'Get' |
|
|
|
})).data |
|
|
|
})).data |
|
|
|
|
|
|
|
|
|
|
|
if (status === 'SUCCESS') { |
|
|
|
if (status === 'SUCCESS') { |
|
|
|
result = await(await axios.get(url + 'artifacts/' + compileCode , { |
|
|
|
result = await(await axios.get(url + 'artifacts/' + compileCode , { |
|
|
|
method: 'Get' |
|
|
|
method: 'Get' |
|
|
|
})).data |
|
|
|
})).data |
|
|
|
console.log({result}) |
|
|
|
|
|
|
|
return result |
|
|
|
return result |
|
|
|
} else if (status === 'PENDING' || status === 'FAILED') { |
|
|
|
} else if (status === 'PENDING' || status === 'FAILED') { |
|
|
|
result = await(await axios.get(url + 'exceptions/' + compileCode , { |
|
|
|
result = await(await axios.get(url + 'exceptions/' + compileCode , { |
|
|
|
method: 'Get' |
|
|
|
method: 'Get' |
|
|
|
})).data |
|
|
|
})).data |
|
|
|
console.log({result}) |
|
|
|
return result |
|
|
|
return result.data |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
await new Promise((resolve) => setTimeout(() => resolve({}), 2000)) |
|
|
|
await new Promise((resolve) => setTimeout(() => resolve({}), 3000)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -119,8 +108,10 @@ export function toStandardOutput(fileName: string, compilationResult: any): any |
|
|
|
const deployedBytecode = compilationResult['contractTypes'][contractName].deploymentBytecode.bytecode.replace('0x', '') |
|
|
|
const deployedBytecode = compilationResult['contractTypes'][contractName].deploymentBytecode.bytecode.replace('0x', '') |
|
|
|
const bytecode = compilationResult['contractTypes'][contractName].runtimeBytecode.bytecode.replace('0x', '') |
|
|
|
const bytecode = compilationResult['contractTypes'][contractName].runtimeBytecode.bytecode.replace('0x', '') |
|
|
|
const compiledAst = compilationResult['contractTypes'][contractName].ast |
|
|
|
const compiledAst = compilationResult['contractTypes'][contractName].ast |
|
|
|
const methodIdentifiers = compilationResult['contractTypes'][contractName].methodIdentifiers |
|
|
|
const methodIds = compilationResult['contractTypes'][contractName].methodIdentifiers |
|
|
|
//const methodIdentifiers = JSON.parse(JSON.stringify(compilationResult['method_identifiers']).replace(/0x/g, ''))
|
|
|
|
const methodIdentifiers = Object.entries(methodIds as Record<any,string>).map(([key, value]) => { |
|
|
|
|
|
|
|
return { [key]: value.replace('0x', '') } |
|
|
|
|
|
|
|
}) |
|
|
|
return { |
|
|
|
return { |
|
|
|
sources: { |
|
|
|
sources: { |
|
|
|
[fileName]: { |
|
|
|
[fileName]: { |
|
|
|