{"version":3,"file":"wallet-get-supported-execution-permissions.cjs","sourceRoot":"","sources":["../../src/methods/wallet-get-supported-execution-permissions.ts"],"names":[],"mappings":";;;AACA,qDAAiD;AAEjD,uDAAsE;AACtE,2CAAkD;AAGlD,kDAAkD;AAClD,wDAAqD;AAGrD;;;;;GAKG;AACU,QAAA,4CAA4C,GAAG,wBAAc,CAAC;AAE3E;;GAEG;AACU,QAAA,wCAAwC,GAAG,IAAA,oBAAM,EAAC;IAC7D,QAAQ,EAAE,IAAA,mBAAK,EAAC,uBAAe,CAAC;IAChC,SAAS,EAAE,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC3B,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,4CAA4C,GAAG,IAAA,oBAAM,EAChE,IAAA,oBAAM,GAAE,EACR,gDAAwC,CACzC,CAAC;AAiBF;;;;;;;;GAQG;AACH,SAAgB,mDAAmD,CAAC,EAClE,uCAAuC,GAGxC;IACC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;QACpC,IAAI,CAAC,uCAAuC,EAAE,CAAC;YAC7C,MAAM,sBAAS,CAAC,kBAAkB,CAChC,oEAAoE,CACrE,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,IAAA,2BAAc,EAAC,MAAM,EAAE,oDAA4C,CAAC,CAAC;QAErE,OAAO,MAAM,uCAAuC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC,CAAC;AACJ,CAAC;AAlBD,kHAkBC","sourcesContent":["import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine/v2';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, object, record, string } from '@metamask/superstruct';\nimport { StrictHexStruct } from '@metamask/utils';\nimport type { Json, JsonRpcRequest } from '@metamask/utils';\n\nimport { NoParamsStruct } from '../utils/structs';\nimport { validateParams } from '../utils/validation';\nimport type { WalletMiddlewareContext } from '../wallet';\n\n/**\n * Superstruct schema for the `wallet_getSupportedExecutionPermissions` request params.\n *\n * This method expects no parameters. Different JSON-RPC clients may send \"no params\"\n * in different ways (omitted, empty array, or empty object), so we accept all three.\n */\nexport const GetSupportedExecutionPermissionsParamsStruct = NoParamsStruct;\n\n/**\n * Superstruct schema for a supported permission type configuration.\n */\nexport const SupportedExecutionPermissionConfigStruct = object({\n  chainIds: array(StrictHexStruct),\n  ruleTypes: array(string()),\n});\n\n/**\n * Represents the supported configuration for a permission type.\n */\nexport type SupportedExecutionPermissionConfig = Infer<\n  typeof SupportedExecutionPermissionConfigStruct\n>;\n\n/**\n * Superstruct schema for the `wallet_getSupportedExecutionPermissions` result.\n */\nexport const GetSupportedExecutionPermissionsResultStruct = record(\n  string(),\n  SupportedExecutionPermissionConfigStruct,\n);\n\n/**\n * Result type for the `wallet_getSupportedExecutionPermissions` JSON-RPC method.\n * Returns an object keyed on supported permission types with their configurations.\n */\nexport type GetSupportedExecutionPermissionsResult = Json &\n  Infer<typeof GetSupportedExecutionPermissionsResultStruct>;\n\n/**\n * Hook type for processing the `wallet_getSupportedExecutionPermissions` request.\n */\nexport type ProcessGetSupportedExecutionPermissionsHook = (\n  req: JsonRpcRequest,\n  context: WalletMiddlewareContext,\n) => Promise<GetSupportedExecutionPermissionsResult>;\n\n/**\n * Creates a handler for the `wallet_getSupportedExecutionPermissions` JSON-RPC method.\n *\n * @param options - The options for the handler.\n * @param options.processGetSupportedExecutionPermissions - The function to process the\n * get supported execution permissions request.\n * @returns A JSON-RPC middleware function that handles the\n * `wallet_getSupportedExecutionPermissions` JSON-RPC method.\n */\nexport function createWalletGetSupportedExecutionPermissionsHandler({\n  processGetSupportedExecutionPermissions,\n}: {\n  processGetSupportedExecutionPermissions?: ProcessGetSupportedExecutionPermissionsHook;\n}): JsonRpcMiddleware<JsonRpcRequest, Json, WalletMiddlewareContext> {\n  return async ({ request, context }) => {\n    if (!processGetSupportedExecutionPermissions) {\n      throw rpcErrors.methodNotSupported(\n        'wallet_getSupportedExecutionPermissions - no middleware configured',\n      );\n    }\n\n    const { params } = request;\n\n    validateParams(params, GetSupportedExecutionPermissionsParamsStruct);\n\n    return await processGetSupportedExecutionPermissions(request, context);\n  };\n}\n"]}