File tree 7 files changed +69
-3
lines changed
fixture-projects/compilation-with-vyper-output-breakable-version
7 files changed +69
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @nomiclabs/hardhat-vyper " : patch
3
+ ---
4
+
5
+ Support Vyper 0.4.0's new output identifiers (Thanks, @kiriyaga-txfusion !)
Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ export const ARTIFACT_FORMAT_VERSION = "hh-vyper-artifact-1";
3
3
export const DEBUG_NAMESPACE = "hardhat:plugin:vyper" ;
4
4
export const CACHE_FORMAT_VERSION = "hh-vy-cache-1" ;
5
5
export const VYPER_FILES_CACHE_FILENAME = "vyper-files-cache.json" ;
6
+ export const OUTPUT_BREAKABLE_VYPER_VERSION = "0.4.0" ;
Original file line number Diff line number Diff line change @@ -23,7 +23,10 @@ import {
23
23
TASK_COMPILE_VYPER_LOG_DOWNLOAD_COMPILER_END ,
24
24
TASK_COMPILE_VYPER_LOG_COMPILATION_RESULT ,
25
25
} from "./task-names" ;
26
- import { DEFAULT_VYPER_VERSION } from "./constants" ;
26
+ import {
27
+ DEFAULT_VYPER_VERSION ,
28
+ OUTPUT_BREAKABLE_VYPER_VERSION ,
29
+ } from "./constants" ;
27
30
import { Compiler } from "./compiler" ;
28
31
import { CompilerDownloader } from "./downloader" ;
29
32
import {
@@ -344,10 +347,24 @@ ${list}`
344
347
}
345
348
) ;
346
349
347
- for ( const [ sourceName , output ] of Object . entries ( contracts ) ) {
350
+ const { localPathToSourceName } = await import (
351
+ "hardhat/utils/source-names"
352
+ ) ;
353
+
354
+ for ( const [ contractSourceIdentifier , output ] of Object . entries (
355
+ contracts
356
+ ) ) {
357
+ const sourceName = semver . gte (
358
+ vyperVersion ,
359
+ OUTPUT_BREAKABLE_VYPER_VERSION
360
+ )
361
+ ? await localPathToSourceName (
362
+ config . paths . root ,
363
+ contractSourceIdentifier
364
+ )
365
+ : contractSourceIdentifier ;
348
366
const artifact = getArtifactFromVyperOutput ( sourceName , output ) ;
349
367
await artifacts . saveArtifactAndDebugFile ( artifact ) ;
350
-
351
368
const file = files . find ( ( f ) => f . sourceName === sourceName ) ;
352
369
assertPluginInvariant (
353
370
file !== undefined ,
Original file line number Diff line number Diff line change
1
+ # pragma version ~=0.4.0
2
+
3
+ IMMUTABLE_1: public (immutable (String[4 ]))
4
+
5
+ @deploy
6
+ @payable
7
+ def __init__ ():
8
+ IMMUTABLE_1 = "A "
Original file line number Diff line number Diff line change
1
+ # pragma version ~=0.4.0
2
+
3
+ IMMUTABLE_1: public (immutable (String[4 ]))
4
+
5
+ @deploy
6
+ @payable
7
+ def __init__ ():
8
+ IMMUTABLE_1 = "B "
Original file line number Diff line number Diff line change
1
+ require ( "../../../src/index" ) ;
2
+
3
+ module . exports = {
4
+ vyper : {
5
+ compilers : [
6
+ {
7
+ version : "0.4.0" ,
8
+ settings : {
9
+ evmVersion : "paris" ,
10
+ optimize : "gas" ,
11
+ } ,
12
+ } ,
13
+ ] ,
14
+ } ,
15
+ } ;
Original file line number Diff line number Diff line change @@ -305,4 +305,16 @@ describe("Vyper plugin", function () {
305
305
) ;
306
306
} ) ;
307
307
} ) ;
308
+
309
+ describe ( "compile project with different ouput identifiers returned from the vyper compiler" , function ( ) {
310
+ useFixtureProject ( "compilation-with-vyper-output-breakable-version" ) ;
311
+ useEnvironment ( ) ;
312
+
313
+ it ( "Should successfully compile the contracts for versions >= 0.4.0" , async function ( ) {
314
+ await this . env . run ( TASK_COMPILE ) ;
315
+
316
+ assert . equal ( this . env . artifacts . readArtifactSync ( "A" ) . contractName , "A" ) ;
317
+ assert . equal ( this . env . artifacts . readArtifactSync ( "B" ) . contractName , "B" ) ;
318
+ } ) ;
319
+ } ) ;
308
320
} ) ;
You can’t perform that action at this time.
0 commit comments