Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for vyper version 0.4.0 with the new output identifiers #5469

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-cars-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomiclabs/hardhat-vyper": patch
---

Support Vyper 0.4.0's new output identifiers (Thanks, @kiriyaga-txfusion!)
1 change: 1 addition & 0 deletions packages/hardhat-vyper/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export const ARTIFACT_FORMAT_VERSION = "hh-vyper-artifact-1";
export const DEBUG_NAMESPACE = "hardhat:plugin:vyper";
export const CACHE_FORMAT_VERSION = "hh-vy-cache-1";
export const VYPER_FILES_CACHE_FILENAME = "vyper-files-cache.json";
export const OUTPUT_BREAKABLE_VYPER_VERSION = "0.4.0";
23 changes: 20 additions & 3 deletions packages/hardhat-vyper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
TASK_COMPILE_VYPER_LOG_DOWNLOAD_COMPILER_END,
TASK_COMPILE_VYPER_LOG_COMPILATION_RESULT,
} from "./task-names";
import { DEFAULT_VYPER_VERSION } from "./constants";
import {
DEFAULT_VYPER_VERSION,
OUTPUT_BREAKABLE_VYPER_VERSION,
} from "./constants";
import { Compiler } from "./compiler";
import { CompilerDownloader } from "./downloader";
import {
Expand Down Expand Up @@ -344,10 +347,24 @@ ${list}`
}
);

for (const [sourceName, output] of Object.entries(contracts)) {
const { localPathToSourceName } = await import(
"hardhat/utils/source-names"
);

for (const [contractSourceIdentifier, output] of Object.entries(
contracts
)) {
const sourceName = semver.gte(
vyperVersion,
OUTPUT_BREAKABLE_VYPER_VERSION
)
? await localPathToSourceName(
config.paths.root,
contractSourceIdentifier
)
: contractSourceIdentifier;
const artifact = getArtifactFromVyperOutput(sourceName, output);
await artifacts.saveArtifactAndDebugFile(artifact);

const file = files.find((f) => f.sourceName === sourceName);
assertPluginInvariant(
file !== undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pragma version ~=0.4.0

IMMUTABLE_1: public(immutable(String[4]))

@deploy
@payable
def __init__():
IMMUTABLE_1 = "A"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# pragma version ~=0.4.0

IMMUTABLE_1: public(immutable(String[4]))

@deploy
@payable
def __init__():
IMMUTABLE_1 = "B"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require("../../../src/index");

module.exports = {
vyper: {
compilers: [
{
version: "0.4.0",
settings: {
evmVersion: "paris",
optimize: "gas",
},
},
],
},
};
12 changes: 12 additions & 0 deletions packages/hardhat-vyper/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,16 @@ describe("Vyper plugin", function () {
);
});
});

describe("compile project with different ouput identifiers returned from the vyper compiler", function () {
useFixtureProject("compilation-with-vyper-output-breakable-version");
useEnvironment();

it("Should successfully compile the contracts for versions >= 0.4.0", async function () {
await this.env.run(TASK_COMPILE);

assert.equal(this.env.artifacts.readArtifactSync("A").contractName, "A");
assert.equal(this.env.artifacts.readArtifactSync("B").contractName, "B");
});
});
});
Loading