From c34ab2dea7705ae1eb9715182a3044c952dd1e2d Mon Sep 17 00:00:00 2001 From: gichiba Date: Fri, 17 May 2019 13:27:11 -0400 Subject: [PATCH 1/4] add pragma experimental handling previously and `pragma experimental` statements would be treated the same as solidity versions. This changes the script to add `pragma experimental "string"; instead. --- index.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9ba2170..164001a 100644 --- a/index.js +++ b/index.js @@ -30,10 +30,13 @@ const flatten = (file, store = { imported: new Set(), pragmas: [] }, depth = 0) }); if (depth === 0) { const solidityPragma = findPragmaVersion(store.pragmas, 'solidity'); - const experimentalPragma = findPragmaVersion(store.pragmas, 'experimental'); - if (experimentalPragma) { - contract = `pragma experimental "v${experimentalPragma}";\n${contract}`; - } + const experimentalPragmas = findExperimentalPragmas(store.pragmas, 'experimental'); + + experimentalPragmas.forEach( + pragma => { + contract = `pragma experimental ${pragma};\n${contract}`; + } + ); if (solidityPragma) { contract = `pragma solidity ^${solidityPragma};\n${contract}`; } @@ -58,4 +61,13 @@ function findPragmaVersion(pragmas, name) { }, null); } +function findExperimentalPragmas(pragmas) { + return Array.from( + new Set(pragmas + .filter(pragma => pragma.name === 'experimental') + .map(pragma => pragma.value) + ) + ); +} + module.exports = flatten; From be804b74f41528ebc9c696b722b63149868fe626 Mon Sep 17 00:00:00 2001 From: gichiba Date: Sat, 18 May 2019 12:36:27 -0400 Subject: [PATCH 2/4] remove vestigial argument in findExperimentalPragmas function --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 164001a..8b99c18 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,7 @@ const flatten = (file, store = { imported: new Set(), pragmas: [] }, depth = 0) }); if (depth === 0) { const solidityPragma = findPragmaVersion(store.pragmas, 'solidity'); - const experimentalPragmas = findExperimentalPragmas(store.pragmas, 'experimental'); + const experimentalPragmas = findExperimentalPragmas(store.pragmas); experimentalPragmas.forEach( pragma => { From 86bd0ecf2d962cfed4980748d035bd780db4c3bc Mon Sep 17 00:00:00 2001 From: gichiba Date: Sat, 18 May 2019 13:03:29 -0400 Subject: [PATCH 3/4] add node_modules to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules From 02a3b630f6e95feb48db1873aef682b843b049f6 Mon Sep 17 00:00:00 2001 From: gichiba Date: Sat, 18 May 2019 13:03:38 -0400 Subject: [PATCH 4/4] remove quotes from otherwise identical experimental pragmas --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8b99c18..264cd16 100644 --- a/index.js +++ b/index.js @@ -65,7 +65,7 @@ function findExperimentalPragmas(pragmas) { return Array.from( new Set(pragmas .filter(pragma => pragma.name === 'experimental') - .map(pragma => pragma.value) + .map(pragma => pragma.value.replace(/("|')/g, '')) ) ); }