diff --git a/.changeset/fifty-ways-sleep.md b/.changeset/fifty-ways-sleep.md new file mode 100644 index 00000000000..dd5a0d4603c --- /dev/null +++ b/.changeset/fifty-ways-sleep.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/abi-coder": patch +--- + +improved logging and normalized data diff --git a/packages/abi-coder/src/abi-coder.ts b/packages/abi-coder/src/abi-coder.ts index 8b886e3be96..92d4049e01b 100644 --- a/packages/abi-coder/src/abi-coder.ts +++ b/packages/abi-coder/src/abi-coder.ts @@ -121,10 +121,22 @@ export default class AbiCoder { if (Array.isArray(values) && nonEmptyTypes.length !== values.length) { if (!hasOptionTypes(types)) { - logger.throwError('Types/values length mismatch', Logger.errors.INVALID_ARGUMENT, { - count: { types: nonEmptyTypes.length, values: values.length }, - value: { types, values }, - }); + logger.throwError( + 'Types/values length mismatch during encode', + Logger.errors.INVALID_ARGUMENT, + { + count: { + types: types.length, + nonEmptyTypes: nonEmptyTypes.length, + values: values.length, + }, + value: { + types, + nonEmptyTypes, + values, + }, + } + ); } else { shallowCopyValues.length = types.length; shallowCopyValues.fill(undefined as unknown as InputValue, values.length); @@ -145,10 +157,22 @@ export default class AbiCoder { const nonEmptyTypes = filterEmptyParams(types); const assertParamsMatch = (newOffset: number) => { if (newOffset !== bytes.length) { - logger.throwError('Types/values length mismatch', Logger.errors.INVALID_ARGUMENT, { - count: { types: nonEmptyTypes.length, values: bytes.length }, - value: { types: nonEmptyTypes, bytes }, - }); + logger.throwError( + 'Types/values length mismatch during decode', + Logger.errors.INVALID_ARGUMENT, + { + count: { + types: types.length, + nonEmptyTypes: nonEmptyTypes.length, + values: bytes.length, + }, + value: { + types, + nonEmptyTypes, + values: bytes, + }, + } + ); } };