{"version":3,"file":"wallet-get-granted-execution-permissions.cjs","sourceRoot":"","sources":["../../src/methods/wallet-get-granted-execution-permissions.ts"],"names":[],"mappings":";;;AACA,qDAAiD;AAEjD,uDAO+B;AAC/B,2CAA4E;AAG5E,kDAAkD;AAClD,wDAAqD;AAGrD;;;;;GAKG;AACU,QAAA,0CAA0C,GAAG,wBAAc,CAAC;AAEzE,MAAM,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IAC9B,OAAO,EAAE,uBAAe;IACxB,WAAW,EAAE,uBAAe;CAC7B,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,IAAA,oBAAM,EAAC;IAC9B,IAAI,EAAE,IAAA,oBAAM,GAAE;IACd,mBAAmB,EAAE,IAAA,qBAAO,GAAE;IAC9B,IAAI,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,qBAAO,GAAE,CAAC;CAClC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,OAAO,EAAE,uBAAe;IACxB,IAAI,EAAE,gCAAwB;IAC9B,EAAE,EAAE,gCAAwB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,uBAAe;IACxB,YAAY,EAAE,IAAA,mBAAK,EAAC,gBAAgB,CAAC;IACrC,iBAAiB,EAAE,gCAAwB;CAC5C,CAAC,CAAC;AASH;;GAEG;AACU,QAAA,0CAA0C,GAAG,IAAA,mBAAK,EAC7D,wCAAgC,CACjC,CAAC;AAiBF;;;;;;;;GAQG;AACH,SAAgB,iDAAiD,CAAC,EAChE,qCAAqC,GAGtC;IACC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;QACpC,IAAI,CAAC,qCAAqC,EAAE,CAAC;YAC3C,MAAM,sBAAS,CAAC,kBAAkB,CAChC,kEAAkE,CACnE,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,IAAA,2BAAc,EAAC,MAAM,EAAE,kDAA0C,CAAC,CAAC;QAEnE,OAAO,MAAM,qCAAqC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC;AACJ,CAAC;AAlBD,8GAkBC","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"]}