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AAK,EAAC;IAChD,wBAAgB,EAAE,UAAU;IAC5B,6BAAqB,EAAE,oBAAoB;CAC5C,CAAC,CAAC;AAIH;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,mBAAK,EAAC,CAAC,8BAAsB,CAAC,CAAC,CAAC;AAItE;;GAEG;AACU,QAAA,+BAA+B,GAAG,IAAA,mBAAK,EAAC;IACnD,IAAA,oBAAM,GAAE,EAAE,aAAa;CACxB,CAAC,CAAC;AAMH;;;;;;;GAOG;AACU,QAAA,uCAAuC,GAAG,IAAA,mBAAK,EAAC;IAC3D,qCAA6B;CAC9B,CAAC,CAAC;AAMH;;GAEG;AACU,QAAA,qCAAqC,GAAG,IAAA,mBAAK,EAAC;IACzD,wBAAgB,EAAE,UAAU;IAC5B,IAAA,sBAAQ,EAAC,8CAAsC,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"]}