{"version":3,"file":"wallet-get-granted-execution-permissions.mjs","sourceRoot":"","sources":["../../src/methods/wallet-get-granted-execution-permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,OAAO,EACR,8BAA8B;AAC/B,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,wBAAwB;AAG5E,OAAO,EAAE,cAAc,EAAE,6BAAyB;AAClD,OAAO,EAAE,cAAc,EAAE,gCAA4B;AAGrD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,cAAc,CAAC;AAEzE,MAAM,gBAAgB,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,eAAe;IACxB,WAAW,EAAE,eAAe;CAC7B,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,MAAM,CAAC;IAC9B,IAAI,EAAE,MAAM,EAAE;IACd,mBAAmB,EAAE,OAAO,EAAE;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC;CAClC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,wBAAwB;IAC9B,EAAE,EAAE,wBAAwB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,eAAe;IACxB,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC;IACrC,iBAAiB,EAAE,wBAAwB;CAC5C,CAAC,CAAC;AASH;;GAEG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAAG,KAAK,CAC7D,gCAAgC,CACjC,CAAC;AAiBF;;;;;;;;GAQG;AACH,MAAM,UAAU,iDAAiD,CAAC,EAChE,qCAAqC,GAGtC;IACC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;QACpC,IAAI,CAAC,qCAAqC,EAAE,CAAC;YAC3C,MAAM,SAAS,CAAC,kBAAkB,CAChC,kEAAkE,CACnE,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,cAAc,CAAC,MAAM,EAAE,0CAA0C,CAAC,CAAC;QAEnE,OAAO,MAAM,qCAAqC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine/v2';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n  array,\n  boolean,\n  object,\n  record,\n  string,\n  unknown,\n} from '@metamask/superstruct';\nimport { HexChecksumAddressStruct, 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_getGrantedExecutionPermissions` 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 GetGrantedExecutionPermissionsParamsStruct = NoParamsStruct;\n\nconst DependencyStruct = object({\n  factory: StrictHexStruct,\n  factoryData: StrictHexStruct,\n});\n\nconst PermissionStruct = object({\n  type: string(),\n  isAdjustmentAllowed: boolean(),\n  data: record(string(), unknown()),\n});\n\n/**\n * Superstruct schema for a single granted execution permission.\n */\nexport const GrantedExecutionPermissionStruct = object({\n  chainId: StrictHexStruct,\n  from: HexChecksumAddressStruct,\n  to: HexChecksumAddressStruct,\n  permission: PermissionStruct,\n  context: StrictHexStruct,\n  dependencies: array(DependencyStruct),\n  delegationManager: HexChecksumAddressStruct,\n});\n\n/**\n * Represents a single granted execution permission.\n */\nexport type GrantedExecutionPermission = Infer<\n  typeof GrantedExecutionPermissionStruct\n>;\n\n/**\n * Superstruct schema for the `wallet_getGrantedExecutionPermissions` result.\n */\nexport const GetGrantedExecutionPermissionsResultStruct = array(\n  GrantedExecutionPermissionStruct,\n);\n\n/**\n * Result type for the `wallet_getGrantedExecutionPermissions` JSON-RPC method.\n * Returns an array of all granted permissions that are not yet revoked.\n */\nexport type GetGrantedExecutionPermissionsResult = Json &\n  Infer<typeof GetGrantedExecutionPermissionsResultStruct>;\n\n/**\n * Hook type for processing the `wallet_getGrantedExecutionPermissions` request.\n */\nexport type ProcessGetGrantedExecutionPermissionsHook = (\n  req: JsonRpcRequest,\n  context: WalletMiddlewareContext,\n) => Promise<GetGrantedExecutionPermissionsResult>;\n\n/**\n * Creates a handler for the `wallet_getGrantedExecutionPermissions` JSON-RPC method.\n *\n * @param options - The options for the handler.\n * @param options.processGetGrantedExecutionPermissions - The function to process the\n * get granted execution permissions request.\n * @returns A JSON-RPC middleware function that handles the\n * `wallet_getGrantedExecutionPermissions` JSON-RPC method.\n */\nexport function createWalletGetGrantedExecutionPermissionsHandler({\n  processGetGrantedExecutionPermissions,\n}: {\n  processGetGrantedExecutionPermissions?: ProcessGetGrantedExecutionPermissionsHook;\n}): JsonRpcMiddleware<JsonRpcRequest, Json, WalletMiddlewareContext> {\n  return async ({ request, context }) => {\n    if (!processGetGrantedExecutionPermissions) {\n      throw rpcErrors.methodNotSupported(\n        'wallet_getGrantedExecutionPermissions - no middleware configured',\n      );\n    }\n\n    const { params } = request;\n\n    validateParams(params, GetGrantedExecutionPermissionsParamsStruct);\n\n    return await processGetGrantedExecutionPermissions(request, context);\n  };\n}\n"]}