import { type SessionConfig } from "@abstract-foundation/agw-client/sessions"; import type { WriteContractParameters } from "@wagmi/core"; import type { Address, Hash, Hex } from "viem"; import type { UseWriteContractReturnType } from "wagmi"; export type RevokeSessionsArgs = { sessions: SessionConfig | Hash | (SessionConfig | Hash)[]; paymaster?: Address; paymasterData?: Hex; } & Omit; /** * React hook for revoking session keys from an Abstract Global Wallet. * * Use this hook to revoke session keys, preventing them from being able to execute * any further transactions on behalf of the wallet. * * Under the hood, it uses wagmi's `useWriteContract` hook to call the `revokeKeys` * function on the SessionKeyValidator contract. * * @returns An object containing functions and state for revoking sessions: * - `revokeSessions`: Function to revoke session keys * - `revokeSessionsAsync`: Promise-based function to revoke session keys * - `isPending`: Boolean indicating if a revocation is in progress * - `isError`: Boolean indicating if the revocation resulted in an error * - `error`: Error object if the revocation failed * - Other standard wagmi useWriteContract properties * * @example * ```tsx * import { useRevokeSessions } from "@abstract-foundation/agw-react"; * import { getSessionHash } from "@abstract-foundation/agw-client/sessions"; * import type { SessionConfig } from "@abstract-foundation/agw-client/sessions"; * * export default function RevokeSessionExample() { * const { * revokeSessionsAsync, * revokeSessions, * isPending, * isError, * error * } = useRevokeSessions(); * * // A session configuration stored in your application * const mySessionConfig: SessionConfig = { * // Your session configuration * }; * * async function handleRevokeSession() { * try { * // Revoke a single session using its configuration * await revokeSessionsAsync({ * sessions: mySessionConfig, * }); * * // Or revoke a session using its hash * await revokeSessionsAsync({ * sessions: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", * }); * * // Or revoke multiple sessions at once * await revokeSessionsAsync({ * sessions: [ * mySessionConfig, * "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", * anotherSessionConfig * ], * }); * * console.log("Sessions revoked successfully"); * } catch (err) { * console.error("Failed to revoke sessions:", err); * } * } * * return ( *
* * * {isError && ( *
* Error: {error?.message} *
* )} *
* ); * } * ``` * * Read more: [Abstract docs: useRevokeSessions](https://docs.abs.xyz/abstract-global-wallet/agw-react/hooks/useRevokeSessions) * * @see {@link useWriteContract} - The underlying wagmi hook * @see {@link SessionKeyValidatorAbi} - The ABI for the session validator contract * @see {@link getSessionHash} - Function to compute the hash of a session configuration */ export declare const useRevokeSessions: () => Omit & { revokeSessions: (params: RevokeSessionsArgs) => void; revokeSessionsAsync: (params: RevokeSessionsArgs) => Promise; }; //# sourceMappingURL=useRevokeSessions.d.ts.map