From 0c675ccb81e3777a3a362cdc3e82e98e9163a28e Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 Oct 2024 14:32:04 +0200 Subject: [PATCH] remove parsing pragma --- apps/vyper/src/app/utils/compiler.tsx | 67 +-------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/apps/vyper/src/app/utils/compiler.tsx b/apps/vyper/src/app/utils/compiler.tsx index 5a9841636a..e2cb6753ec 100644 --- a/apps/vyper/src/app/utils/compiler.tsx +++ b/apps/vyper/src/app/utils/compiler.tsx @@ -25,43 +25,6 @@ export function normalizeContractPath(contractPath: string): string[] { return [folders,resultingPath, filename] } -const buildError = (output) => { - if (isCompilationError(output)) { - const line = output.line - if (line) { - const lineColumnPos = { - start: { line: line - 1, column: 10 }, - end: { line: line - 1, column: 10 } - } - // remixClient.highlight(lineColumnPos as any, _contract.name, '#e0b4b4') - } else { - const regex = output?.message?.match(/line ((\d+):(\d+))+/g) - const errors = output?.message?.split(/line ((\d+):(\d+))+/g) // extract error message - if (regex) { - let errorIndex = 0 - regex.map((errorLocation) => { - const location = errorLocation?.replace('line ', '').split(':') - let message = errors[errorIndex] - errorIndex = errorIndex + 4 - if (message && message?.split('\n\n').length > 0) { - try { - message = message?.split('\n\n')[message.split('\n\n').length - 1] - } catch (e) {} - } - if (location?.length > 0) { - const lineColumnPos = { - start: { line: parseInt(location[0]) - 1, column: 10 }, - end: { line: parseInt(location[0]) - 1, column: 10 } - } - // remixClient.highlight(lineColumnPos as any, _contract.name, message) - } - }) - } - } - throw new Error(output.message) - } -} - const compileReturnType = (output, contract): VyperCompilationResult => { const t: any = toStandardOutput(contract, output) const temp = _.merge(t['contracts'][contract]) @@ -100,32 +63,6 @@ const compileReturnType = (output, contract): VyperCompilationResult => { return result } -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 oldPragmaFound = content.match(oldPragmaRegex) - - const pragma = '# pragma version ~=0.4.0' - - if (oldPragmaFound) { - // oldPragmaDeclaration.forEach(declaration => { - // content = content.replace(declaration, '# pragma version >0.3.10') - // }) - return content - } - if (!pragmaFound) { - 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 @@ -140,13 +77,11 @@ export async function compile(url: string, contract: Contract): Promise