change types to fit compile results

pull/4182/head
Joseph Izang 1 year ago
parent 734153a100
commit 626bd9711a
  1. 3
      apps/vyper/src/app/components/CompilerButton.tsx
  2. 1
      apps/vyper/src/app/components/VyperResult.tsx
  3. 52
      apps/vyper/src/app/utils/compiler.tsx

@ -44,6 +44,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}:
setOutput(_contract.name, {status: 'failed', message: e.message})
return
}
console.log({ output })
const compileReturnType = () => {
const t: any = toStandardOutput(contract, output)
const temp = _.merge(t['contracts'][contract])
@ -110,7 +111,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}:
remixClient.compilationFinish(_contract.name, _contract.content, data)
//map data to compilation details shape
remixClient.call('compilationDetails' as any, 'showDetails', data)
} catch (err: any) {
remixClient.changeStatus({

@ -26,6 +26,7 @@ type TabContentMembers = {
}
function VyperResult({ output, themeColor }: VyperResultProps) {
// const [active, setActive] = useState<keyof VyperCompilationResult>('abi')
const [active, setActive] = useState<keyof VyperCompilationResult>('abi')
if (!output)

@ -51,7 +51,7 @@ export function normalizeContractPath(contractPath: string): string[] {
* @param url The url of the compiler
* @param contract The name and content of the contract
*/
export async function compile(url: string, contract: Contract): Promise<VyperCompilationOutput> {
export async function compile(url: string, contract: Contract): Promise<any> {
if (!contract.name) {
throw new Error('Set your Vyper contract file.')
}
@ -69,41 +69,12 @@ export async function compile(url: string, contract: Contract): Promise<VyperCom
// 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 compilePackage: ETHPM3Format = {
const contractName = contract['name']
const compilePackage = {
manifest: 'ethpm/3',
name: nameResult[2],
version: '0.3.10',
meta: {
authors: [],
license: '',
description: '',
keywords: []
},
sources: {
[contract.name] : {
content: contract.content,
checksum: {
'keccak256': '',
hash: ''
},
type: '',
license: ''
}
},
buildDependencies: {},
compilers: {} as CompilerInformationObject[],
contractTypes: {
[nameResult[2]]: {
content: contract.content
},
contractName: nameResult[2],
abi: {} as ABI[],
ast: {} as AST,
depolymentBytecode: {} as ByteCodeType,
runtimeBytecode: {} as any,
},
deployments: {}
[contractName] : {content : contract.content}
}
}
const response = await axios.post(`${url}compile`, compilePackage )
console.log({response})
@ -122,7 +93,7 @@ export async function compile(url: string, contract: Contract): Promise<VyperCom
})).data
if (status === 'SUCCESS') {
result = await(await axios.get(url + 'compiled_artifact/' + compileCode , {
result = await(await axios.get(url + 'artifacts/' + compileCode , {
method: 'Get'
})).data
console.log({result})
@ -131,6 +102,7 @@ export async function compile(url: string, contract: Contract): Promise<VyperCom
result = await(await axios.get(url + 'exceptions/' + compileCode , {
method: 'Get'
})).data
console.log({result})
return result.data
}
await new Promise((resolve) => setTimeout(() => resolve({}), 2000))
@ -141,19 +113,19 @@ export async function compile(url: string, contract: Contract): Promise<VyperCom
* @param name Name of the contract file
* @param compilationResult Result returned by the compiler
*/
export function toStandardOutput(fileName: string, compilationResult: VyperCompilationResultType): CompilationResult {
export function toStandardOutput(fileName: string, compilationResult: any): any {
const contractName = normalizeContractPath(fileName)[2]
const compiledAbi = compilationResult['contractTypes'][contractName].abi
const deployedBytecode = compilationResult['contractTypes'][contractName].deploymentBytecode.bytecode.replace('0x', '')
const bytecode = compilationResult['contractTypes'][contractName].runtimeBytecode.bytecode.replace('0x', '')
const compiledAst = compilationResult['contractTypes'][contractName].abi
const compiledAst = compilationResult['contractTypes'][contractName].ast
const methodIdentifiers = compilationResult['contractTypes'][contractName].methodIdentifiers
//const methodIdentifiers = JSON.parse(JSON.stringify(compilationResult['method_identifiers']).replace(/0x/g, ''))
return {
sources: {
[fileName]: {
id: 1,
ast: compiledAst,
legacyAST: {} as any
ast: compiledAst
}
},
contracts: {
@ -175,7 +147,7 @@ export function toStandardOutput(fileName: string, compilationResult: VyperCompi
object: bytecode,
opcodes: ''
},
// methodIdentifiers: methodIdentifiers
methodIdentifiers: methodIdentifiers
}
}
} as any

Loading…
Cancel
Save