From c0154a8e4f59c3c48c073f28e03ee2da3ad66e3b Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Wed, 13 Mar 2024 17:03:41 +0100 Subject: [PATCH] updates to vyper as per @LianaHus more to come --- apps/vyper/src/app/app.tsx | 2 +- apps/vyper/src/app/components/VyperResult.tsx | 12 +++++------ apps/vyper/src/app/utils/compiler.tsx | 20 ++++++++++++++++++- apps/vyper/src/profile.json | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index ed16a3f6d0..f6f0ef2279 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -164,7 +164,7 @@ const App = () => { setOutput({...output, [name]: update})} resetCompilerState={resetCompilerResultState} /> -
+
{output && Object.keys(output).length > 0 && output.status !== 'failed' ? ( <> diff --git a/apps/vyper/src/app/components/VyperResult.tsx b/apps/vyper/src/app/components/VyperResult.tsx index 0efc4afc28..94b9fdba16 100644 --- a/apps/vyper/src/app/components/VyperResult.tsx +++ b/apps/vyper/src/app/components/VyperResult.tsx @@ -67,17 +67,17 @@ function VyperResult({ output, plugin }: VyperResultProps) {
- (Object.values(output)[0] as OutputType).abi} direction="bottom" icon="far fa-copy"> - + - (Object.values(output)[0] as OutputType).bytecode.object} direction="bottom" icon="far fa-copy"> - +
diff --git a/apps/vyper/src/app/utils/compiler.tsx b/apps/vyper/src/app/utils/compiler.tsx index 980f0e46bb..c3b9182e1d 100644 --- a/apps/vyper/src/app/utils/compiler.tsx +++ b/apps/vyper/src/app/utils/compiler.tsx @@ -141,6 +141,22 @@ const compileReturnType = (output, contract) => { return result } +const fixContractContent = (content: string) => { + if (content.length === 0) return + const pragmaFound = content.includes('#pragma version ^0.3.10') + const evmVerFound = content.includes('#pragma evm-version shanghai') + const pragma = '#pragma version ^0.3.10' + const evmVer = '#pragma evm-version shanghai' + + if (!evmVerFound) { + content = `${evmVer}\n${content}` + } + if (!pragmaFound) { + content = `${pragma}\n${content}` + } + return content +} + /** * Compile the a contract * @param url The url of the compiler @@ -155,11 +171,13 @@ export async function compile(url: string, contract: Contract): Promise { throw new Error('Use extension .vy for Vyper.') } + + let contractName = contract['name'] const compilePackage = { manifest: 'ethpm/3', sources: { - [contractName] : {content : contract.content} + [contractName] : {content : fixContractContent(contract.content)} } } let response = await axios.post(`${url}compile`, compilePackage ) diff --git a/apps/vyper/src/profile.json b/apps/vyper/src/profile.json index da5050a0b8..669d5340c4 100644 --- a/apps/vyper/src/profile.json +++ b/apps/vyper/src/profile.json @@ -3,7 +3,7 @@ "displayName": "Vyper Compiler", "methods": ["getCompilationResult", "compile", "vyperCompileCustomAction"], "url": "https://ipfs-cluster.ethdevops.io/ipfs/QmbmPzUg7ghTKcF2eo64zm1k1LKdibYfqYmiqXkHKXks8r", - "documentation": "https://remix-ide.readthedocs.io/en/latest/plugin_list.html", + "documentation": "https://remix-ide.readthedocs.io/en/latest/vyper.html", "description": "Compile vyper contracts", "kind": "compiler", "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzM4IiBoZWlnaHQ9IjM3NiIgdmlld0JveD0iMCAwIDMzOCAzNzYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xOTUuMzA0IDMxMS44MzdMODIuNTE4IDE5OS4wODRDNzcuOTI0MSAxOTQuMzA0IDc1LjM5MjcgMTg3LjgzNyA3NS4zOTI3IDE4MC42MlYxOS42OTE0Qzc1LjM5MjcgMTAuMzE4OCA2Ni4wMTc0IDAuOTQ2MTI3IDU2LjY0MiAwLjk0NjEyN0gxOS4wNDY3QzkuNjcxMjggMC45NDYxMjcgMC4yOTU4OTggMTAuMzE4OCAwLjI5NTg5OCAxOS42OTE0VjIwNy4xNDVDMC4yOTU4OTggMjE3LjA4IDMuOTUyMyAyMjYuNjQgMTAuOTgzOCAyMzMuNjY5TDE0Mi4yMzkgMzY0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