diff --git a/src/caip-types.ts b/src/caip-types.ts index 2d1446e62..361aa60d6 100644 --- a/src/caip-types.ts +++ b/src/caip-types.ts @@ -1,5 +1,5 @@ -import type { Infer } from '@metamask/superstruct'; import { is, pattern, string } from '@metamask/superstruct'; +import type { Infer, Struct } from '@metamask/superstruct'; export const CAIP_CHAIN_ID_REGEX = /^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u; @@ -16,7 +16,10 @@ export const CAIP_ACCOUNT_ADDRESS_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u; /** * A CAIP-2 chain ID, i.e., a human-readable namespace and reference. */ -export const CaipChainIdStruct = pattern(string(), CAIP_CHAIN_ID_REGEX); +export const CaipChainIdStruct = pattern( + string(), + CAIP_CHAIN_ID_REGEX, +) as Struct; export type CaipChainId = `${string}:${string}`; /** @@ -34,7 +37,10 @@ export type CaipReference = Infer; /** * A CAIP-10 account ID, i.e., a human-readable namespace, reference, and account address. */ -export const CaipAccountIdStruct = pattern(string(), CAIP_ACCOUNT_ID_REGEX); +export const CaipAccountIdStruct = pattern( + string(), + CAIP_ACCOUNT_ID_REGEX, +) as Struct; export type CaipAccountId = `${string}:${string}:${string}`; /**