From c9d77d52b2ad0f9303f967449b342314dbc56155 Mon Sep 17 00:00:00 2001 From: Edi Date: Mon, 7 Sep 2020 22:36:25 +0200 Subject: [PATCH 1/3] Adding metadata save on each compile --- apps/remix-ide/src/app/files/compiler-metadata.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/remix-ide/src/app/files/compiler-metadata.js b/apps/remix-ide/src/app/files/compiler-metadata.js index b1dd9239e3..a19c3d088c 100644 --- a/apps/remix-ide/src/app/files/compiler-metadata.js +++ b/apps/remix-ide/src/app/files/compiler-metadata.js @@ -24,6 +24,10 @@ class CompilerMetadata extends Plugin { return path + '/' + this.innerPath + '/' + contractName + '.json' } + _MetadataFileName(path, contractName) { + return path + '/' + this.innerPath + '/' + contractName + '_metadata' + '.json' + } + onActivation () { var self = this this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { @@ -36,6 +40,7 @@ class CompilerMetadata extends Plugin { if (contract.file !== source.target) return var fileName = self._JSONFileName(path, contract.name) + var metadataFileName = self._MetadataFileName(path, contract.name) provider.get(fileName, (error, content) => { if (!error) { content = content || '{}' @@ -51,6 +56,8 @@ class CompilerMetadata extends Plugin { deploy[network] = self._syncContext(contract, deploy[network] || {}) }) + provider.set(metadataFileName, JSON.stringify(contract.object.metadata, null, '\t')); + var data = { deploy, data: { From 4ada5b6c8300f1edcc5f41d7e4905186da0bdf98 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 Sep 2020 12:15:00 +0200 Subject: [PATCH 2/3] fix formatting --- apps/remix-ide/src/app/files/compiler-metadata.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/compiler-metadata.js b/apps/remix-ide/src/app/files/compiler-metadata.js index a19c3d088c..c77bfa7614 100644 --- a/apps/remix-ide/src/app/files/compiler-metadata.js +++ b/apps/remix-ide/src/app/files/compiler-metadata.js @@ -56,7 +56,7 @@ class CompilerMetadata extends Plugin { deploy[network] = self._syncContext(contract, deploy[network] || {}) }) - provider.set(metadataFileName, JSON.stringify(contract.object.metadata, null, '\t')); + provider.set(metadataFileName, JSON.stringify(JSON.parse(contract.object.metadata), null, '\t')) var data = { deploy, From 89db995c91f8a40131f848c2a0812a1006ae4fd8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 Sep 2020 12:15:11 +0200 Subject: [PATCH 3/3] add e2e tests --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 52794aa2ac..a3ddde4d1d 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -27,6 +27,11 @@ module.exports = { .pause(3000) .click('*[data-id="verticalIconsKindfileExplorers"]') .openFile('browser/artifacts/Ballot.json') + .openFile('browser/artifacts/Ballot_metadata.json') + .getEditorValue((content) => { + const metadata = JSON.parse(content) + browser.assert.equal(metadata.language, 'Solidity') + }) }, 'Should add new github access token': function (browser: NightwatchBrowser) {