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;IACnD,MAAM,EAAE,EAAE,aAAa;CACxB,CAAC,CAAC;AAMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,CAAC;IAC3D,6BAA6B;CAC9B,CAAC,CAAC;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;IACzD,gBAAgB,EAAE,UAAU;IAC5B,QAAQ,CAAC,sCAAsC,CAAC,EAAE,UAAU;CAC7D,CAAC,CAAC","sourcesContent":["/**\n * Superstruct validation schemas for Ethereum JSON-RPC method parameters.\n *\n * These structs provide runtime validation for the parameters passed to various\n * Ethereum RPC methods. They can be used by keyring implementations to validate\n * incoming requests before processing.\n */\n\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n  any,\n  array,\n  literal,\n  nullable,\n  number,\n  optional,\n  record,\n  string,\n  tuple,\n  type,\n  union,\n  unknown,\n} from '@metamask/superstruct';\n\nimport {\n  EthAddressStrictStruct,\n  EthAddressStruct,\n  EthBytesStruct,\n} from '../types';\n\n/**\n * A struct for validating Ethereum transaction data.\n *\n * This uses `type()` instead of `object()` to allow extra properties,\n * since transaction formats can vary and include additional fields.\n * The actual transaction validation is performed by the transaction library.\n */\nexport const EthTransactionDataStruct = type({\n  to: optional(nullable(EthAddressStruct)),\n  from: optional(EthAddressStruct),\n  nonce: optional(union([string(), number()])),\n  value: optional(union([string(), number()])),\n  data: optional(EthBytesStruct),\n  gas: optional(union([string(), number()])),\n  gasLimit: optional(union([string(), number()])),\n  gasPrice: optional(union([string(), number()])),\n  maxFeePerGas: optional(union([string(), number()])),\n  maxPriorityFeePerGas: optional(union([string(), number()])),\n  accessList: optional(\n    array(\n      type({\n        address: EthAddressStruct,\n        storageKeys: array(string()),\n      }),\n    ),\n  ),\n  type: optional(union([string(), number()])),\n  chainId: optional(union([string(), number()])),\n});\n\nexport type EthTransactionData = Infer<typeof EthTransactionDataStruct>;\n\n/**\n * A struct for TypedDataV1 format (legacy typed data).\n * This is an array of { type, name, value } objects.\n */\nexport const EthTypedDataV1Struct = array(\n  object({\n    type: string(),\n    name: string(),\n    value: unknown(),\n  }),\n);\n\nexport type EthTypedDataV1 = Infer<typeof EthTypedDataV1Struct>;\n\n/**\n * A struct for TypedData types definition.\n * Maps type names to arrays of { name, type } definitions.\n */\nexport const EthTypedDataTypesStruct = record(\n  string(),\n  array(\n    object({\n      name: string(),\n      type: string(),\n    }),\n  ),\n);\n\nexport type EthTypedDataTypes = Infer<typeof EthTypedDataTypesStruct>;\n\n/**\n * A struct for TypedMessage format (EIP-712 V3/V4).\n * Contains types, domain, primaryType, and message.\n */\nexport const EthTypedMessageStruct = object({\n  types: EthTypedDataTypesStruct,\n  primaryType: string(),\n  domain: record(string(), any()),\n  message: record(string(), any()),\n});\n\nexport type EthTypedMessage = Infer<typeof EthTypedMessageStruct>;\n\n/**\n * A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).\n */\nexport const EthEncryptedDataStruct = object({\n  version: literal('x25519-xsalsa20-poly1305'),\n  nonce: string(),\n  ephemPublicKey: string(),\n  ciphertext: string(),\n});\n\nexport type EthEncryptedData = Infer<typeof EthEncryptedDataStruct>;\n\n/**\n * A struct for EIP-7702 authorization tuple.\n * Format: [chainId, address, nonce]\n */\nexport const EthEip7702AuthorizationStruct = tuple([\n  number(), // chainId\n  EthAddressStrictStruct, // address (contract to delegate to)\n  number(), // nonce\n]);\n\nexport type EthEip7702Authorization = Infer<\n  typeof EthEip7702AuthorizationStruct\n>;\n\n/**\n * A struct for getEncryptionPublicKey options.\n */\nexport const EthGetEncryptionPublicKeyOptionsStruct = record(\n  string(),\n  unknown(),\n);\n\n// ============================================================================\n// RPC Method Parameter Structs\n// ============================================================================\n\n/**\n * Parameters for `eth_signTransaction`.\n */\nexport const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);\n\nexport type EthSignTransactionParams = Infer<\n  typeof EthSignTransactionParamsStruct\n>;\n\n/**\n * Parameters for `eth_sign`.\n */\nexport const EthSignParamsStruct = tuple([\n  EthAddressStruct, // address\n  EthBytesStruct, // data (hex-encoded message hash)\n]);\n\nexport type EthSignParams = Infer<typeof EthSignParamsStruct>;\n\n/**\n * Parameters for `personal_sign`.\n */\nexport const EthPersonalSignParamsStruct = union([\n  tuple([EthBytesStruct]), // [data]\n  tuple([EthBytesStruct, EthAddressStruct]), // [data, address]\n]);\n\nexport type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>;\n\n/**\n * Parameters for `eth_signTypedData_v1`.\n */\nexport const EthSignTypedDataV1ParamsStruct = tuple([\n  EthAddressStruct, // address\n  EthTypedDataV1Struct, // typed data array\n]);\n\nexport type EthSignTypedDataV1Params = Infer<\n  typeof EthSignTypedDataV1ParamsStruct\n>;\n\n/**\n * Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.\n */\nexport const EthSignTypedDataParamsStruct = tuple([\n  EthAddressStruct, // address\n  EthTypedMessageStruct, // typed data object\n]);\n\nexport type EthSignTypedDataParams = Infer<typeof EthSignTypedDataParamsStruct>;\n\n/**\n * Parameters for `eth_decrypt`.\n */\nexport const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);\n\nexport type EthDecryptParams = Infer<typeof EthDecryptParamsStruct>;\n\n/**\n * Parameters for `eth_getAppKeyAddress`.\n */\nexport const EthGetAppKeyAddressParamsStruct = tuple([\n  string(), // origin URL\n]);\n\nexport type EthGetAppKeyAddressParams = Infer<\n  typeof EthGetAppKeyAddressParamsStruct\n>;\n\n/**\n * Parameters for `eth_signEip7702Authorization`.\n *\n * @example\n * ```ts\n * const params = [[1, '0xContractAddress', 0]];\n * ```\n */\nexport const EthSignEip7702AuthorizationParamsStruct = tuple([\n  EthEip7702AuthorizationStruct,\n]);\n\nexport type EthSignEip7702AuthorizationParams = Infer<\n  typeof EthSignEip7702AuthorizationParamsStruct\n>;\n\n/**\n * Parameters for `eth_getEncryptionPublicKey`.\n */\nexport const EthGetEncryptionPublicKeyParamsStruct = tuple([\n  EthAddressStruct, // address\n  optional(EthGetEncryptionPublicKeyOptionsStruct), // options\n]);\n"]}