updates for v0.4.0

pull/5178/head
Joseph Izang 2 months ago
parent 6b9a7c527b
commit cbb5dfe01d
  1. 40
      apps/vyper/src/app/utils/compiler.tsx
  2. 2
      apps/vyper/src/app/utils/remix-client.tsx

@ -48,6 +48,7 @@ export function normalizeContractPath(contractPath: string): string[] {
function parseErrorString(errorString) {
// Split the string into lines
console.log(errorString)
return
let lines = errorString.trim().split('\n')
// Extract the line number and message
let message = errorString.trim()
@ -141,27 +142,32 @@ const compileReturnType = (output, contract) => {
return result
}
const fixContractContent = (content: string) => {
const pragmaRegex = /#\s*pragma\s+[@]*version\s+([\^~<>!=^]+)\s*(\d+\.\d+\.\d+)/
if (content.length === 0) return
const updatePragmaDeclaration = (content: string) => {
const pragmaRegex = /#\s*pragma\s+[@]*version\s+([~<>!=^]+)\s*(\d+\.\d+\.\d+)/
const oldPragmaRegex = /#\s*pragma\s+[@]*version\s+([\^^]+)\s*(\d+\.\d+\.\d+)/
const oldPragmaDeclaration = ['# pragma version ^0.2.16', '# pragma version ^0.3.10', '#pragma version ^0.2.16', '#pragma version ^0.3.10']
const pragmaFound = content.match(pragmaRegex)
const wrongpragmaFound = content.includes('# pragma version ^0.3.10')
const evmVerFound = content.includes('#pragma evm-version cancun')
const oldPragmaFound = content.match(oldPragmaRegex)
const pragma = '# pragma version ~=0.4.0'
const evmVer = '# pragma evm-version cancun'
// if (evmVerFound === false) {
// content = `${evmVer}\n${content}`
// }
if (wrongpragmaFound === true) {
content = content.replace('# pragma version ^0.3.10', '')
if (oldPragmaFound) {
console.log('found old pragma')
// oldPragmaDeclaration.forEach(declaration => {
// content = content.replace(declaration, '# pragma version ~=0.4.0')
// })
}
if (!pragmaFound) {
content = `${pragma}\n${content}`
content = `${pragma}\n\n${content}`
}
return content
}
const fixContractContent = (content: string) => {
if (content.length === 0) return
return updatePragmaDeclaration(content)
}
/**
* Compile the a contract
* @param url The url of the compiler
@ -177,7 +183,7 @@ export async function compile(url: string, contract: Contract): Promise<any> {
}
const cleanedUpContent = fixContractContent(contract.content)
console.log('cleanedUp', cleanedUpContent)
// console.log('cleanedUp', cleanedUpContent)
let contractName = contract['name']
const compilePackage = {
@ -187,6 +193,7 @@ export async function compile(url: string, contract: Contract): Promise<any> {
}
}
console.log(compilePackage)
let response = await axios.post(`${url}compile`, compilePackage )
if (response.status === 404) {
@ -197,9 +204,11 @@ export async function compile(url: string, contract: Contract): Promise<any> {
}
const compileCode = response.data
console.log('compileCode', compileCode)
contractName = null
response = null
let result: any
let intermediateError
const status = await (await axios.get(url + 'status/' + compileCode , {
method: 'Get'
@ -210,12 +219,13 @@ export async function compile(url: string, contract: Contract): Promise<any> {
})).data
return result
} else if (status !== 'SUCCESS') {
} else if (status === 'FAILED') {
const intermediate = await(await axios.get(url + 'exceptions/' + compileCode , {
method: 'Get'
})).data
result = parseErrorString(intermediate)
console.log('Errors found', intermediate)
result = parseErrorString(intermediate)
intermediateError = intermediate
return result
}
await new Promise((resolve) => setTimeout(() => resolve({}), 3000))

@ -87,7 +87,7 @@ export class RemixClient extends PluginClient<any, CustomRemixApi> {
await this.call(
'dgitApi',
'clone',
{url: 'https://github.com/pcaversaccio/snekmate', token: null, branch: 'main', singleBranch: false, workspaceName: 'snekmate'},
{ url: 'https://github.com/vyperlang/vyper', token: null, branch: 'master', singleBranch: false, workspaceName: 'vyper' },
)
await this.call(

Loading…
Cancel
Save