From 02856cfe2b711f3798ee1fc2c4dfa506cea669bb Mon Sep 17 00:00:00 2001 From: IOVGomezdn Date: Sat, 2 Mar 2024 14:29:56 -0300 Subject: [PATCH 1/3] minor fixes --- src/lib/verifier.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/verifier.js b/src/lib/verifier.js index 443a8d0..f0902d3 100644 --- a/src/lib/verifier.js +++ b/src/lib/verifier.js @@ -45,8 +45,8 @@ export function Verifier (options = {}) { if (!compiled) { for (const path of Object.keys(contracts)) { - const file = path.split('/').pop() - if (file.split('.')[0] === KEY) { + const contractName = path.split('/').pop().split('.')[0] + if (contractName === KEY) { compiled = contracts[path][KEY] } } @@ -59,18 +59,20 @@ export function Verifier (options = {}) { const { sources } = JSON.parse(compiled.metadata) for (const [path, { content }] of Object.entries(sources)) { - const name = path.split('/').pop().split() + const name = path.split('/').pop().split('.')[0] const sourceObj = { path, file: path.split('/').pop() } if (name === KEY) { sourceObj.contents = content - usedSources.unshift(sourceObj) } else { sourceObj.hash = getHash(content) - usedSources.push(sourceObj) } + + usedSources.push(sourceObj) } - } catch (e) {} + } catch (err) { + return Promise.reject(err) + } } const { evm, abi } = compiled From 31e6e57e4b2ab7a64c97bc09b07d747105ec29ad Mon Sep 17 00:00:00 2001 From: IOVGomezdn Date: Sat, 2 Mar 2024 14:30:24 -0300 Subject: [PATCH 2/3] feat: add useLiteralContent set to true in settings.metadata as default --- src/lib/compiler.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/compiler.js b/src/lib/compiler.js index 33b258d..fadafe1 100644 --- a/src/lib/compiler.js +++ b/src/lib/compiler.js @@ -16,12 +16,20 @@ export function Compiler ({ solcCache } = {}) { ] } } - const { optimizer } = settings + const { optimizer, metadata } = settings + if (optimizer) { let { runs } = optimizer runs = (runs) ? parseInt(runs) : 200 settings.optimizer.runs = runs } + + if (metadata) { + settings.metadata.useLiteralContent = true + } else { + settings.metadata = { useLiteralContent: true } + } + return { language: 'Solidity', sources, From bb317a28544478f1f4c4d1d27a809ffb7fc42cc5 Mon Sep 17 00:00:00 2001 From: IOVGomezdn Date: Tue, 5 Mar 2024 12:42:26 -0300 Subject: [PATCH 3/3] add dist changes --- dist/lib/compiler.js | 10 +++++++++- dist/lib/defaultConfig.js | 2 +- dist/lib/verifier.js | 14 ++++++++------ src/lib/defaultConfig.js | 1 - 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/dist/lib/compiler.js b/dist/lib/compiler.js index 6ff8f3b..c148e53 100644 --- a/dist/lib/compiler.js +++ b/dist/lib/compiler.js @@ -16,12 +16,20 @@ function Compiler({ solcCache } = {}) { - const { optimizer } = settings; + const { optimizer, metadata } = settings; + if (optimizer) { let { runs } = optimizer; runs = runs ? parseInt(runs) : 200; settings.optimizer.runs = runs; } + + if (metadata) { + settings.metadata.useLiteralContent = true; + } else { + settings.metadata = { useLiteralContent: true }; + } + return { language: 'Solidity', sources, diff --git a/dist/lib/defaultConfig.js b/dist/lib/defaultConfig.js index 371f439..e957780 100644 --- a/dist/lib/defaultConfig.js +++ b/dist/lib/defaultConfig.js @@ -3,4 +3,4 @@ port: 3008, solcCache: '/tmp/solc', log: {}, - timeout: 60000 };exports.default = _default; \ No newline at end of file + timeout: 600000 };exports.default = _default; \ No newline at end of file diff --git a/dist/lib/verifier.js b/dist/lib/verifier.js index 4e28f4f..ba957a2 100644 --- a/dist/lib/verifier.js +++ b/dist/lib/verifier.js @@ -45,8 +45,8 @@ function Verifier(options = {}) { if (!compiled) { for (const path of Object.keys(contracts)) { - const file = path.split('/').pop(); - if (file.split('.')[0] === KEY) { + const contractName = path.split('/').pop().split('.')[0]; + if (contractName === KEY) { compiled = contracts[path][KEY]; } } @@ -59,18 +59,20 @@ function Verifier(options = {}) { const { sources } = JSON.parse(compiled.metadata); for (const [path, { content }] of Object.entries(sources)) { - const name = path.split('/').pop().split(); + const name = path.split('/').pop().split('.')[0]; const sourceObj = { path, file: path.split('/').pop() }; if (name === KEY) { sourceObj.contents = content; - usedSources.unshift(sourceObj); } else { sourceObj.hash = (0, _utils.getHash)(content); - usedSources.push(sourceObj); } + + usedSources.push(sourceObj); } - } catch (e) {} + } catch (err) { + return Promise.reject(err); + } } const { evm, abi } = compiled; diff --git a/src/lib/defaultConfig.js b/src/lib/defaultConfig.js index 12355ab..c5832b0 100644 --- a/src/lib/defaultConfig.js +++ b/src/lib/defaultConfig.js @@ -5,4 +5,3 @@ export default { log: {}, timeout: 600000 } -