diff --git a/packages/transaction-request-intent/src/lib/domain.ts b/packages/transaction-request-intent/src/lib/domain.ts index fa40a066f..c3aba4683 100644 --- a/packages/transaction-request-intent/src/lib/domain.ts +++ b/packages/transaction-request-intent/src/lib/domain.ts @@ -1,4 +1,4 @@ -import { Address, Alg, AssetType as AssetTypeEnum, Caip10Id, Hex, TransactionRequest } from '@narval/authz-shared' +import { Address, Alg, AssetType, Caip10Id, Hex, TransactionRequest } from '@narval/authz-shared' import { TypedDataDomain, TypedData as TypedDataParams } from 'viem' import { Intent } from './intent.types' @@ -39,11 +39,11 @@ export type TypedDataInput = { export type ContractInformation = { contractAddress: string - assetType: AssetTypeEnum + assetType: AssetType } export type ContractRegistryInput = { contract: Caip10Id | { address: Address; chainId: number } - assetType?: AssetTypeEnum + assetType?: AssetType walletType?: WalletType }[] export type ContractRegistry = Map @@ -154,7 +154,7 @@ export enum Misc { UNKNOWN = 'unknown' } -export type AssetType = AssetTypeEnum | Misc +export type AssetTypeAndUnknown = AssetType | Misc export enum SupportedChains { ETHEREUM = 1, diff --git a/packages/transaction-request-intent/src/lib/supported-methods.ts b/packages/transaction-request-intent/src/lib/supported-methods.ts index 803b5f34e..a12264574 100644 --- a/packages/transaction-request-intent/src/lib/supported-methods.ts +++ b/packages/transaction-request-intent/src/lib/supported-methods.ts @@ -1,6 +1,6 @@ import { AssetType as AssetTypeEnum } from '@narval/authz-shared' import { AbiParameter } from 'viem' -import { AssetType, Intents, Misc } from './domain' +import { AssetTypeAndUnknown, Intents, Misc } from './domain' import { ApproveAllowanceParamsTransform, Erc1155SafeTransferFromParamsTransform, @@ -166,7 +166,7 @@ export type MethodsMapping = { name: string abi: AbiParameter[] transformer: (params: unknown[]) => StandardMethodsParams[K] - assetType: AssetType + assetType: AssetTypeAndUnknown intent: Intents } } diff --git a/packages/transaction-request-intent/src/lib/typeguards.ts b/packages/transaction-request-intent/src/lib/typeguards.ts index 771b3d6c4..17412b54a 100644 --- a/packages/transaction-request-intent/src/lib/typeguards.ts +++ b/packages/transaction-request-intent/src/lib/typeguards.ts @@ -1,6 +1,6 @@ -import { AssetType as AssetTypeEnum, Hex } from '@narval/authz-shared' -import { AssetType, Misc } from './domain' +import { AssetType, Hex } from '@narval/authz-shared' import { SupportedMethodId } from './supported-methods' +import { AssetTypeAndUnknown, Misc } from './domain' export const isString = (value: unknown): value is string => { return typeof value === 'string' @@ -75,7 +75,7 @@ export const isSupportedMethodId = (value: Hex): value is SupportedMethodId => { type AssertType = 'string' | 'bigint' | 'number' | 'boolean' | 'hex' export const isAssetType = (value: unknown): value is AssetType => { - const types: AssetType[] = Object.values(AssetTypeEnum) + const types: AssetTypeAndUnknown[] = Object.values(AssetType) types.push(Misc.UNKNOWN) return types.includes(value as AssetType) diff --git a/packages/transaction-request-intent/src/lib/utils.ts b/packages/transaction-request-intent/src/lib/utils.ts index 2898b97b0..83965f6af 100644 --- a/packages/transaction-request-intent/src/lib/utils.ts +++ b/packages/transaction-request-intent/src/lib/utils.ts @@ -1,5 +1,5 @@ import { - AssetType as AssetTypeEnum, + AssetType, Caip10Id, Hex, Namespace, @@ -9,7 +9,7 @@ import { } from '@narval/authz-shared' import { isAddress } from 'viem' import { - AssetType, + AssetTypeAndUnknown, ContractCallInput, ContractInformation, ContractRegistry, @@ -48,8 +48,8 @@ export const buildContractRegistryEntry = ({ chainId: number contractAddress: string assetType: string -}): { [key: Caip10Id]: AssetType } => { - const registry: { [key: Caip10Id]: AssetType } = {} +}): { [key: Caip10Id]: AssetTypeAndUnknown } => { + const registry: { [key: Caip10Id]: AssetTypeAndUnknown } = {} if (!isAddress(contractAddress) || !isAssetType(assetType)) { throw new Error('Invalid contract registry entry') } @@ -162,9 +162,9 @@ export const getTransactionIntentType = ({ { condition: () => methodId === SupportedMethodId.TRANSFER_FROM && - ((contractType && contractType.assetType === AssetTypeEnum.ERC20) || - (contractType && contractType.assetType === AssetTypeEnum.ERC721)), - intent: contractType?.assetType === AssetTypeEnum.ERC721 ? Intents.TRANSFER_ERC721 : Intents.TRANSFER_ERC20 + ((contractType && contractType.assetType === AssetType.ERC20) || + (contractType && contractType.assetType === AssetType.ERC721)), + intent: contractType?.assetType === AssetType.ERC721 ? Intents.TRANSFER_ERC721 : Intents.TRANSFER_ERC20 }, // Cancel condition {