From aabce099ed517a7966522e2803e142a06445b8cc Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 7 Nov 2023 14:03:18 +0100 Subject: [PATCH] fix encoding boolean --- libs/remix-lib/src/execution/txHelper.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-lib/src/execution/txHelper.ts b/libs/remix-lib/src/execution/txHelper.ts index f3c78930b1..18074bfa27 100644 --- a/libs/remix-lib/src/execution/txHelper.ts +++ b/libs/remix-lib/src/execution/txHelper.ts @@ -14,10 +14,10 @@ export function encodeParams (funABI, args) { if (funABI.inputs && funABI.inputs.length) { for (let i = 0; i < funABI.inputs.length; i++) { const type = funABI.inputs[i].type - // "false" will be converting to `false` and "true" will be working - // fine as abiCoder assume anything in quotes as `true` - if (type === 'bool' && args[i] === 'false') { - args[i] = false + if (type === 'bool') { + if (args[i] === false || args[i] === 'false' || args[i] === '0' || args[i] === 0) args[i] = false + else if (args[i] === true || args[i] === 'true' || args[i] === '1' || args[i] === 1) args[i] = true + else throw new Error(`provided value for boolean is invalid: ${args[i]}`) } types.push(type.indexOf('tuple') === 0 ? makeFullTypeDefinition(funABI.inputs[i]) : type) if (args.length < types.length) {