diff --git a/packages/policy-engine-shared/src/lib/util/__test__/unit/caip.util.spec.ts b/packages/policy-engine-shared/src/lib/util/__test__/unit/caip.util.spec.ts index 28c06d0c6..0d8a3a6d6 100644 --- a/packages/policy-engine-shared/src/lib/util/__test__/unit/caip.util.spec.ts +++ b/packages/policy-engine-shared/src/lib/util/__test__/unit/caip.util.spec.ts @@ -19,10 +19,10 @@ import { describe('caip', () => { const validAddress = '0x5db3Bf14413d7e3c69FAA279EFa1D1B08637eC4c' - const validAccountId = `${Namespace.EIP155}:1/${validAddress}` + const validAccountId = `${Namespace.EIP155}:1:${validAddress}` const invalidAccountId = 'invalid_caip10_id' - const invalidAccountIdNamespace = 'invalid_namespace:1/0x1234567890abcdef' - const invalidAccountIdAddress = `${Namespace.EIP155}:1/invalid_address` + const invalidAccountIdNamespace = 'invalid_namespace:1:0x1234567890abcdef' + const invalidAccountIdAddress = `${Namespace.EIP155}:1:invalid_address` describe('safeParseAccount', () => { it('returns success for valid account id', () => { @@ -96,7 +96,7 @@ describe('caip', () => { chainId: 1, address: '0x1234567890abcdef' }) - ).toEqual(`${Namespace.EIP155}:1/0x1234567890abcdef`) + ).toEqual(`${Namespace.EIP155}:1:0x1234567890abcdef`) }) }) diff --git a/packages/policy-engine-shared/src/lib/util/caip.util.ts b/packages/policy-engine-shared/src/lib/util/caip.util.ts index 3c681d1c1..110d04862 100644 --- a/packages/policy-engine-shared/src/lib/util/caip.util.ts +++ b/packages/policy-engine-shared/src/lib/util/caip.util.ts @@ -1,5 +1,6 @@ import { SetOptional } from 'type-fest' import { Address } from 'viem' +import { z } from 'zod' import { toEnum } from './enum.util' import { getAddress, isAddress } from './evm.util' @@ -37,7 +38,7 @@ export enum AssetType { /** * @see https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md */ -export type AccountId = `${Namespace}:${number}/${string}` +export type AccountId = `${Namespace}:${number}:${string}` export type Account = { chainId: number @@ -45,15 +46,16 @@ export type Account = { namespace: Namespace } +type NonCollectableAssetId = `${Namespace}:${number}/${AssetType}:${string}` +type CollectableAssetId = `${Namespace}:${number}/${AssetType}:${string}/${string}` +type CoinAssetId = `${Namespace}:${number}/${AssetType.SLIP44}:${number}` + /** * @see https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md * @see https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-20.md * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md */ -export type AssetId = - | `${Namespace}:${number}/${AssetType}:${string}` - | `${Namespace}:${number}/${AssetType}:${string}/${string}` - | `${Namespace}:${number}/${AssetType.SLIP44}:${number}` +export type AssetId = NonCollectableAssetId | CollectableAssetId | CoinAssetId export type Token = Account & { assetType: AssetType @@ -101,7 +103,7 @@ const unsafeParse = (fn: (value: string) => Result, value: string): T => { // const matchAccountId = (value: string) => { - const match = value.match(/^([^:]+):(\d+)\/(.+)$/) + const match = value.match(/^([^:]+):(\d+):(.+)$/) if (!match) { return null @@ -207,7 +209,7 @@ export const toAccountId = (input: SetOptional): AccountId namespace: input.namespace || Namespace.EIP155 } - return `${account.namespace}:${account.chainId}/${account.address}` + return `${account.namespace}:${account.chainId}:${account.address}` } /** @@ -464,3 +466,49 @@ export const safeGetAssetId = (value: string): Result => { * @returns The parsed AssetId. */ export const getAssetId = (value: string): AssetId => unsafeParse(safeGetAssetId, value) + +// +// Zod Schema +// + +const nonCollectableAssetIdSchema = z.custom((value) => { + const parse = z.string().safeParse(value) + + if (parse.success) { + return isAssetId(parse.data) + } + + return false +}) + +const collectableAssetIdSchema = z.custom((value) => { + const parse = z.string().safeParse(value) + + if (parse.success) { + return isAssetId(parse.data) + } + + return false +}) + +const coinAssetIdSchema = z.custom((value) => { + const parse = z.string().safeParse(value) + + if (parse.success) { + return isAssetId(parse.data) + } + + return false +}) + +export const assetIdSchema = z.union([nonCollectableAssetIdSchema, collectableAssetIdSchema, coinAssetIdSchema]) + +export const accountIdSchema = z.custom((value) => { + const parse = z.string().safeParse(value) + + if (parse.success) { + return isAccountId(parse.data) + } + + return false +}) diff --git a/packages/transaction-request-intent/src/lib/__test__/unit/decoders.spec.ts b/packages/transaction-request-intent/src/lib/__test__/unit/decoders.spec.ts index 79c5e7803..afcfcdfe7 100644 --- a/packages/transaction-request-intent/src/lib/__test__/unit/decoders.spec.ts +++ b/packages/transaction-request-intent/src/lib/__test__/unit/decoders.spec.ts @@ -54,8 +54,8 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.TRANSFER_NATIVE, - to: 'eip155:137/0x031d8c0ca142921c459bcb28104c0ff37928f9ed', - from: 'eip155:137/0xed123cf8e3ba51c6c15da1eac74b2b5deea31448', + to: 'eip155:137:0x031d8c0ca142921c459bcb28104c0ff37928f9ed', + from: 'eip155:137:0xed123cf8e3ba51c6c15da1eac74b2b5deea31448', amount: '16676', token: 'eip155:137/slip44:966' }) @@ -75,10 +75,10 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.APPROVE_TOKEN_ALLOWANCE, - from: 'eip155:137/0xed123cf8e3ba51c6c15da1eac74b2b5deea31448', - token: 'eip155:137/0x031d8c0ca142921c459bcb28104c0ff37928f9ed', + from: 'eip155:137:0xed123cf8e3ba51c6c15da1eac74b2b5deea31448', + token: 'eip155:137:0x031d8c0ca142921c459bcb28104c0ff37928f9ed', amount: '11541971132511365478906515907109950360107522067033065608472376982619868367719', - spender: 'eip155:137/0x1111111254eeb25477b68fb85ed929f73a960582' + spender: 'eip155:137:0x1111111254eeb25477b68fb85ed929f73a960582' }) }) it('decodes user operation', () => { @@ -95,13 +95,13 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.USER_OPERATION, - from: 'eip155:1/0x791b1689526b5560145f99cb9d3b7f24eca2591a', - entrypoint: 'eip155:1/0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789', + from: 'eip155:1:0x791b1689526b5560145f99cb9d3b7f24eca2591a', + entrypoint: 'eip155:1:0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789', beneficiary: '0x791b1689526b5560145f99cb9d3b7f24eca2591a', operationIntents: [ { - contract: 'eip155:1/0x8ae01fcf7c655655ff2c6ef907b8b4718ab4e17c', - from: 'eip155:1/0x791b1689526b5560145f99cb9d3b7f24eca2591a', + contract: 'eip155:1:0x8ae01fcf7c655655ff2c6ef907b8b4718ab4e17c', + from: 'eip155:1:0x791b1689526b5560145f99cb9d3b7f24eca2591a', hexSignature: '0x8d80ff0a', type: Intents.CALL_CONTRACT } @@ -123,8 +123,8 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.CALL_CONTRACT, - from: 'eip155:137/0xed123cf8e3ba51c6c15da1eac74b2b5deea31448', - contract: 'eip155:137/0x031d8c0ca142921c459bcb28104c0ff37928f9ed', + from: 'eip155:137:0xed123cf8e3ba51c6c15da1eac74b2b5deea31448', + contract: 'eip155:137:0x031d8c0ca142921c459bcb28104c0ff37928f9ed', hexSignature: '0xf2d12b12' }) }) @@ -221,7 +221,7 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.DEPLOY_SAFE_WALLET, - from: 'eip155:137/0xaaad8c0ca142921c459bcb28104c0ff37928f9ed', + from: 'eip155:137:0xaaad8c0ca142921c459bcb28104c0ff37928f9ed', chainId: 137 }) }) @@ -241,7 +241,7 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.DEPLOY_ERC_4337_WALLET, - from: 'eip155:137/0xcccd8c0ca142921c459bcb28104c0ff37928f9ed', + from: 'eip155:137:0xcccd8c0ca142921c459bcb28104c0ff37928f9ed', chainId: 137, bytecode: '0x41284124120948012849081209470127490127940790127490712038017403178947109247' }) @@ -262,7 +262,7 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.DEPLOY_CONTRACT, - from: 'eip155:137/0x031d8c0ca142921c459bcb28104c0ff37928f9ed', + from: 'eip155:137:0x031d8c0ca142921c459bcb28104c0ff37928f9ed', chainId: 137 }) }) @@ -380,11 +380,11 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.PERMIT, - spender: 'eip155:137/0xffcf8fdee72ac11b5c542428b35eef5769c409f0', - token: 'eip155:137/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + spender: 'eip155:137:0xffcf8fdee72ac11b5c542428b35eef5769c409f0', + token: 'eip155:137:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', amount: '1000000000000000000', deadline: '9999999999', - owner: 'eip155:137/0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1' + owner: 'eip155:137:0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1' }) }) it('decodes permit2', () => { @@ -431,13 +431,12 @@ describe('decode', () => { }) expect(decoded).toEqual({ type: Intents.PERMIT2, - token: 'eip155:137/0x64060ab139feaae7f06ca4e63189d86adeb51691', - spender: 'eip155:137/0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4', + token: 'eip155:137:0x64060ab139feaae7f06ca4e63189d86adeb51691', + spender: 'eip155:137:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4', amount: '1461501637330902918203684832716283019655932542975', deadline: 1709143217, - owner: 'eip155:137/0xed123cf8e3ba51c6c15da1eac74b2b5deea31448' + owner: 'eip155:137:0xed123cf8e3ba51c6c15da1eac74b2b5deea31448' }) }) - it('defaults to raw payload', () => {}) }) }) diff --git a/packages/transaction-request-intent/src/lib/__test__/unit/mocks.ts b/packages/transaction-request-intent/src/lib/__test__/unit/mocks.ts index 80246cb4c..90e48fd4d 100644 --- a/packages/transaction-request-intent/src/lib/__test__/unit/mocks.ts +++ b/packages/transaction-request-intent/src/lib/__test__/unit/mocks.ts @@ -1,5 +1,4 @@ -import { AccountId, AssetId, TransactionRequest, getAssetId } from '@narval/policy-engine-shared' -import { Address } from 'viem' +import { AccountId, TransactionRequest, getAccountId, getAddress, getAssetId } from '@narval/policy-engine-shared' import { DecodeInput, InputType, Intents, TransactionInput } from '../../domain' import { TransferErc1155, TransferErc20, TransferErc721, TransferNative } from '../../intent.types' @@ -201,7 +200,7 @@ export const TREASURY_WALLET_GROUP: WalletGroup = { // Address Book export const SHY_ACCOUNT_137: AddressBookAccount = { - uid: 'eip155:137/0xddcf208f219a6e6af072f2cfdc615b2c1805f98e', + uid: 'eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e', address: '0xddcf208f219a6e6af072f2cfdc615b2c1805f98e', chainId: 137, classification: 'wallet' @@ -215,21 +214,22 @@ export const SHY_ACCOUNT_1: AddressBookAccount = { } export const ACCOUNT_Q_137: AddressBookAccount = { - uid: 'eip155:137/0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4', - address: '0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4' as Address, + uid: getAccountId('eip155:137:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4'), + address: getAddress('0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4'), chainId: 137, classification: 'wallet' } export const ACCOUNT_INTERNAL_WXZ_137: AddressBookAccount = { - uid: 'eip155:137/0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3', - address: '0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3', + uid: getAccountId('eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3'), + address: getAddress('0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3'), chainId: 137, classification: 'internal' } export const NATIVE_TRANSFER_INTENT: TransferNative = { type: Intents.TRANSFER_NATIVE, + // TODO WHAT"S THIS? to: 'eip155:137/eoa:0x08a08d0504d4f3363a5b7fda1f5fff1c7bca8ad4' as AccountId, from: 'eip155:137/eoa:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b' as AccountId, amount: '0x8000', @@ -237,8 +237,8 @@ export const NATIVE_TRANSFER_INTENT: TransferNative = { } const ERC20_TRANSFER_TX_REQUEST: TransactionRequest = { - from: TREASURY_WALLET_X.address as Address, - to: '0x031d8C0cA142921c459bCB28104c0FF37928F9eD' as Address, + from: getAddress(TREASURY_WALLET_X.address), + to: getAddress('0x031d8C0cA142921c459bCB28104c0FF37928F9eD'), chainId: ACCOUNT_Q_137.chainId, data: '0xa9059cbb000000000000000000000000031d8c0ca142921c459bcb28104c0ff37928f9ed000000000000000000000000000000000000000000005ab7f55035d1e7b4fe6d', nonce: 192, @@ -247,15 +247,15 @@ const ERC20_TRANSFER_TX_REQUEST: TransactionRequest = { const ERC20_TRANSFER_INTENT: TransferErc20 = { type: Intents.TRANSFER_ERC20, - to: `eip155:137/0x031d8c0ca142921c459bcb28104c0ff37928f9ed` as AccountId, - from: `eip155:137/${ERC20_TRANSFER_TX_REQUEST.from.toLowerCase()}` as AccountId, - token: `eip155:137/${ERC20_TRANSFER_TX_REQUEST.to?.toLowerCase()}` as AccountId, + to: getAccountId('eip155:137:0x031d8c0ca142921c459bcb28104c0ff37928f9ed'), + from: getAccountId(`eip155:137:${ERC20_TRANSFER_TX_REQUEST.from.toLowerCase()}`), + token: getAccountId(`eip155:137:${ERC20_TRANSFER_TX_REQUEST.to?.toLowerCase()}`), amount: '428406414311469998210669' } const ERC721_SAFE_TRANSFER_FROM_TX_REQUEST: TransactionRequest = { - from: TREASURY_WALLET_X.address as Address, - to: ACCOUNT_Q_137.address as Address, + from: getAddress(TREASURY_WALLET_X.address), + to: getAddress(ACCOUNT_Q_137.address), chainId: ACCOUNT_Q_137.chainId, data: '0x42842e0e000000000000000000000000ea7278a0d8306658dd6d38274dde084f24cd8a11000000000000000000000000b253f6156e64b12ba0dec3974062dbbaee139f0c000000000000000000000000000000000000000000000000000000000000a0d5', nonce: 192, @@ -264,10 +264,10 @@ const ERC721_SAFE_TRANSFER_FROM_TX_REQUEST: TransactionRequest = { const ERC721_SAFE_TRANSFER_FROM_INTENT: TransferErc721 = { type: Intents.TRANSFER_ERC721, - to: `eip155:137/0xb253f6156e64b12ba0dec3974062dbbaee139f0c` as AccountId, - from: `eip155:137/${ERC721_SAFE_TRANSFER_FROM_TX_REQUEST.from.toLowerCase()}` as AccountId, - contract: `eip155:137/${ERC721_SAFE_TRANSFER_FROM_TX_REQUEST.to?.toLowerCase()}` as AccountId, - token: `eip155:137/erc721:${ERC721_SAFE_TRANSFER_FROM_TX_REQUEST.to}/41173` as AssetId + to: getAccountId('eip155:137:0xb253f6156e64b12ba0dec3974062dbbaee139f0c'), + from: getAccountId(`eip155:137:${ERC721_SAFE_TRANSFER_FROM_TX_REQUEST.from.toLowerCase()}`), + contract: getAccountId(`eip155:137:${ERC721_SAFE_TRANSFER_FROM_TX_REQUEST.to?.toLowerCase()}`), + token: getAssetId(`eip155:137/erc721:${ERC721_SAFE_TRANSFER_FROM_TX_REQUEST.to}/41173`) } export const mockErc721SafeTransferFrom = { @@ -285,8 +285,8 @@ export const mockTransferFrom = { input: { type: InputType.TRANSACTION_REQUEST, txRequest: { - from: TREASURY_WALLET_X.address as Address, - to: ACCOUNT_Q_137.address as Address, + from: getAddress(TREASURY_WALLET_X.address), + to: getAddress(ACCOUNT_Q_137.address), chainId: ACCOUNT_Q_137.chainId, data: transferFromData, nonce: 192, @@ -294,16 +294,16 @@ export const mockTransferFrom = { } } as TransactionInput, intent: { - to: `eip155:137/0x59895c2cdaa07cc3ac20ef0918d2597a277b276c` as AccountId, - from: `eip155:137/${TREASURY_WALLET_X.address}` as AccountId, - contract: `eip155:137/${ACCOUNT_Q_137.address}` as AccountId, + to: getAccountId('eip155:137:0x59895c2cdaa07cc3ac20ef0918d2597a277b276c'), + from: getAccountId(`eip155:137:${TREASURY_WALLET_X.address}`), + contract: getAccountId(`eip155:137:${ACCOUNT_Q_137.address}`), amount: '5532' } } const ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST: TransactionRequest = { - from: TREASURY_WALLET_X.address as Address, - to: ACCOUNT_Q_137.address as Address, + from: getAddress(TREASURY_WALLET_X.address), + to: getAddress(ACCOUNT_Q_137.address), chainId: ACCOUNT_Q_137.chainId, data: '0xf242432a000000000000000000000000d15b4cb5495cffa8d01970018ea3bc4942e34b7a00000000000000000000000000ca04c45da318d5b7e7b14d5381ca59f09c73f000000000000000000000000000000000000000000000000000000000000000af000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000704760f2a0b00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000ca04c45da318d5b7e7b14d5381ca59f09c73f00000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006042b8a88ec00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000005c0000000000000000000000000d15b4cb5495cffa8d01970018ea3bc4942e34b7a000000000000000000000000d15b4cb5495cffa8d01970018ea3bc4942e34b7a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000005e000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000cb02f88ea1b95ba4adccfc0d0ac2a6052b70f2e400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000065a9d6a20000000000000000000000000000000000000000000000000000000065adcb5d000000000000000000000000000000000000000000000000000000000000000060665ba51d4da48b00000000000000004cb15528fa439a0e4e2a583202e926d50000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024b2b50d4fec700000000000000000000000000000000000000000000000000024b2b50d4fec7000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000939821fd096b4e4f67f369af67cf9411b1a2816000000000000000000000000000000000000000000000000000000000000000af00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cb02f88ea1b95ba4adccfc0d0ac2a6052b70f2e400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf127000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001d5bc40aa656c0000000000000000000000000000000000000000000000000001d5bc40aa656c00000000000000000000000000001f429aa3c402e9deabe8a8ecae7d37b0d35452c0000000000000000000000000000000000000000000000000000000000000041efa2557bc958943cb6a7df19ae9c8b1b516515b5184f21516458a44d559141d94229134f3da4243b36151bba8cc65bf4d441a277326a87e59b1b5dcb18c681021b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001d4da48b60665ba5', nonce: 192, @@ -312,10 +312,15 @@ const ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST: TransactionRequest = { const ERC1155_SAFE_TRANSFER_FROM_INTENT: TransferErc1155 = { type: Intents.TRANSFER_ERC1155, - to: `eip155:137/0x00ca04c45da318d5b7e7b14d5381ca59f09c73f0` as AccountId, - from: `eip155:137/${ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST.from.toLowerCase()}` as AccountId, - contract: `eip155:137/${ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST.to?.toLowerCase()}` as AccountId, - transfers: [{ token: `eip155:137/erc1155:${ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST.to}/175` as AssetId, amount: '1' }] + to: getAccountId('eip155:137:0x00ca04c45da318d5b7e7b14d5381ca59f09c73f0'), + from: getAccountId(`eip155:137:${ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST.from.toLowerCase()}`), + contract: getAccountId(`eip155:137:${ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST.to?.toLowerCase()}`), + transfers: [ + { + token: getAssetId(`eip155:137/erc1155:${ERC1155_SAFE_TRANSFER_FROM_TX_REQUEST.to}/175`), + amount: '1' + } + ] } export const mockErc1155SafeTransferFrom = { input: { @@ -326,8 +331,8 @@ export const mockErc1155SafeTransferFrom = { } const ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST = { - from: TREASURY_WALLET_X.address as Address, - to: ACCOUNT_Q_137.address as Address, + from: getAddress(TREASURY_WALLET_X.address), + to: getAddress(ACCOUNT_Q_137.address), chainId: ACCOUNT_Q_137.chainId, data: '0x2eb2c2d60000000000000000000000008b149b00ce4ad98878ec342d69eb42dcbcbd6306000000000000000000000000383370726a5bd619e0d2af8ef37a58013b823a8c00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000b9c00000000000000000000000000000000000000000000000000000000000000a200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000610000000000000000000000000000000000000000000000000000000065a9d9340feb2529261db182817eef5823d8f659495e6bdc097b95cac8011dd73a13be723d4c281943fbfff8b8ba89cfa2a44286411e94e8eb9601502914ffd41764bc781c00000000000000000000000000000000000000000000000000000000000000', nonce: 2 @@ -335,16 +340,16 @@ const ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST = { const ERC1155_BATCH_SAFE_TRANSFER_FROM_INTENT = { type: Intents.TRANSFER_ERC1155, - from: `eip155:137/${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.from.toLowerCase()}` as AccountId, - to: `eip155:137/0x383370726a5bd619e0d2af8ef37a58013b823a8c` as AccountId, - contract: `eip155:137/${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.to?.toLowerCase()}` as AccountId, + from: getAccountId(`eip155:137:${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.from.toLowerCase()}`), + to: getAccountId('eip155:137:0x383370726a5bd619e0d2af8ef37a58013b823a8c'), + contract: getAccountId(`eip155:137:${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.to?.toLowerCase()}`), transfers: [ { - token: `eip155:137/erc1155:${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.to}/2972` as AssetId, + token: getAssetId(`eip155:137/erc1155:${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.to}/2972`), amount: '1' }, { - token: `eip155:137/erc1155:${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.to}/162` as AssetId, + token: getAssetId(`eip155:137/erc1155:${ERC1155_BATCH_SAFE_TRANSFER_FROM_REQUEST.to}/162`), amount: '1' } ] @@ -371,7 +376,7 @@ export const mockCancelTransaction: DecodeInput = { txRequest: { chainId: 1, value: '0x', - to: ACCOUNT_Q_137.address as Address, - from: ACCOUNT_Q_137.address as Address + to: getAddress(ACCOUNT_Q_137.address), + from: getAddress(ACCOUNT_Q_137.address) } }