From df963d2795a2e796d2fe7a3e69850f6364a7ee73 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 8 May 2025 12:19:28 +0200 Subject: [PATCH] add optimizer options: --- js/resolc/src/index.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/js/resolc/src/index.ts b/js/resolc/src/index.ts index e1ee372..8c82276 100644 --- a/js/resolc/src/index.ts +++ b/js/resolc/src/index.ts @@ -93,13 +93,26 @@ export function version(): string { export async function compile( sources: SolcInput, - option: { bin?: string } = {} + option: { + optimizer?: Record + bin?: string + } = {} ): Promise { + const { + optimizer = { + mode: 'z', + fallback_to_optimizing_for_size: true, + enabled: true, + runs: 200, + }, + bin, + } = option + const input = JSON.stringify({ language: 'Solidity', sources: resolveInputs(sources), settings: { - optimizer: { enabled: true, runs: 200 }, + optimizer, outputSelection: { '*': { '*': ['abi'], @@ -108,8 +121,8 @@ export async function compile( }, }) - if (option.bin) { - return compileWithBin(input, option.bin) + if (bin) { + return compileWithBin(input, bin) } return resolc(input)