diff --git a/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/Erc1155TransferDecoder.ts b/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/Erc1155TransferDecoder.ts index 847ec34a7..8c9082d3a 100644 --- a/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/Erc1155TransferDecoder.ts +++ b/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/Erc1155TransferDecoder.ts @@ -1,4 +1,4 @@ -import { AssetType, Hex, toAccountId, toAssetId } from '@narval/authz-shared' +import { AssetType, Hex, toAssetId } from '@narval/authz-shared' import { Address } from 'viem' import { ContractCallInput, Intents } from '../../../domain' import { DecoderError } from '../../../error' @@ -6,6 +6,7 @@ import { Erc1155SafeTransferFromParams, SafeBatchTransferFromParams } from '../. import { ERC1155Transfer, TransferErc1155 } from '../../../intent.types' import { MethodsMapping, SupportedMethodId } from '../../../supported-methods' import { isSupportedMethodId } from '../../../typeguards' +import { toAccountIdLowerCase } from '../../../utils' import { extract } from '../../utils' export const decodeERC1155Transfer = (input: ContractCallInput, supportedMethods: MethodsMapping): TransferErc1155 => { @@ -71,10 +72,10 @@ function constructTransferErc1155Intent({ chainId: number }): TransferErc1155 { return { - to: toAccountId({ chainId, address: to }), - from: toAccountId({ chainId, address: from }), + to: toAccountIdLowerCase({ chainId, address: to }), + from: toAccountIdLowerCase({ chainId, address: from }), type: Intents.TRANSFER_ERC1155, transfers, - contract: toAccountId({ chainId, address: contract }) + contract: toAccountIdLowerCase({ chainId, address: contract }) } } diff --git a/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/UserOperationDecoder.ts b/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/UserOperationDecoder.ts index 4da877f6c..48af478b3 100644 --- a/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/UserOperationDecoder.ts +++ b/packages/transaction-request-intent/src/lib/decoders/transaction/interaction/UserOperationDecoder.ts @@ -1,5 +1,5 @@ import { Address } from '@narval/authz-shared' -import { assertAddress, assertBigInt, assertHexString } from 'packages/authz-shared/src/lib/util/typeguards' +import { assertAddress, assertHexString } from 'packages/authz-shared/src/lib/util/typeguards' import { Hex, toHex } from 'viem' import { ContractCallInput, InputType, Intents } from '../../../domain' import { DecoderError } from '../../../error' @@ -17,12 +17,12 @@ const decodeExecute = (callData: Hex, from: Address, chainId: number, supportedM const params = extract(supportedMethods, dataWithoutMethodId, SupportedMethodId.EXECUTE) as ExecuteParams const { to, value, data } = params - const assertAddressfrom = assertAddress(from) const assertAddressTo = assertAddress(to) + const assertAddressfrom = assertAddress(from) const assertAddressValue = assertHexString(value) const assertData = assertHexString(data) - if (!assertAddressfrom || !assertAddressTo || !assertAddressValue || !assertData) { + if (!assertAddressTo || !assertAddressfrom || !assertAddressValue || !assertData) { throw new DecoderError({ message: 'Invalid parameters', status: 400 }) } @@ -56,18 +56,14 @@ const decodeExecuteAndRevert = ( dataWithoutMethodId, SupportedMethodId.EXECUTE_AND_REVERT ) as ExecuteAndRevertParams - const { to, value } = params - const bigint = assertBigInt(value) - - if (!bigint) { - throw new DecoderError({ message: 'Invalid value', status: 400 }) - } + const { to, value, data } = params - const hexValue = toHex(bigint) - const assertAddressfrom = assertAddress(from) const assertAddressTo = assertAddress(to) + const assertAddressfrom = assertAddress(from) + const assertValue = toHex(value) + const assertData = assertHexString(data) - if (!assertAddressfrom || !assertAddressTo) { + if (!assertAddressTo || !assertAddressfrom || !assertData) { throw new DecoderError({ message: 'Invalid parameters', status: 400 }) } @@ -75,10 +71,10 @@ const decodeExecuteAndRevert = ( input: { type: InputType.TRANSACTION_REQUEST, txRequest: { - to: assertAddress(to), + to: assertAddressTo, from: assertAddressfrom, - value: hexValue, - data: assertAddressTo, + value: assertValue, + data: assertData, chainId } }, diff --git a/packages/transaction-request-intent/src/lib/extraction/transformers.ts b/packages/transaction-request-intent/src/lib/extraction/transformers.ts index 9058fc244..f7fe251ed 100644 --- a/packages/transaction-request-intent/src/lib/extraction/transformers.ts +++ b/packages/transaction-request-intent/src/lib/extraction/transformers.ts @@ -108,7 +108,8 @@ export const ExecuteParamsTransform = (params: unknown[]): ExecuteParams => { const value = assertBigInt(params[1]) const data = assertHexString(params[2]) - if (!to || !value || !data) { + // value can be 0 so we must be explicit that we check for non null value + if (!to || null === value || !data) { throw new DecoderError({ message: 'Invalid parameters', status: 400 }) } @@ -181,15 +182,15 @@ export const HandleOpsParamsTransform = (params: unknown[]): HandleOpsParams => throw new DecoderError({ message: 'Invalid input format', status: 400 }) } - const assertAddressBeneficiary = assertAddress(params[1]) + const assertBeneficiary = assertAddress(params[1]) - if (!assertAddressBeneficiary) { + if (!assertBeneficiary) { throw new DecoderError({ message: 'Invalid parameters', status: 400 }) } return { userOps: params[0].map(transformUserOperation), - beneficiary: assertAddressBeneficiary + beneficiary: assertBeneficiary } }