@abstract-foundation/agw-react
Version:
Abstract Global Wallet React Components
542 lines • 20.7 kB
TypeScript
import { type SessionConfig } from '@abstract-foundation/agw-client/sessions';
import type { WriteContractParameters } from '@wagmi/core';
import type { Address, Hash, Hex } from 'viem';
export type RevokeSessionsArgs = {
sessions: SessionConfig | Hash | (SessionConfig | Hash)[];
paymaster?: Address;
paymasterData?: Hex;
} & Omit<WriteContractParameters, 'address' | 'abi' | 'functionName' | 'args'>;
/**
* 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 (
* <div>
* <button
* onClick={handleRevokeSession}
* disabled={isPending}
* >
* {isPending ? "Revoking..." : "Revoke Sessions"}
* </button>
*
* {isError && (
* <div className="error">
* Error: {error?.message}
* </div>
* )}
* </div>
* );
* }
* ```
*
* 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: () => {
data: undefined;
error: null;
isError: false;
isPending: false;
isSuccess: false;
status: "idle";
failureCount: number;
failureReason: import("@wagmi/core").WriteContractErrorType | null;
isPaused: boolean;
variables: undefined;
isIdle: true;
reset: () => void;
context: unknown;
submittedAt: number;
revokeSessions: (params: RevokeSessionsArgs) => void;
revokeSessionsAsync: (params: RevokeSessionsArgs) => Promise<void>;
} | {
data: undefined;
error: null;
isError: false;
isPending: true;
isSuccess: false;
status: "pending";
failureCount: number;
failureReason: import("@wagmi/core").WriteContractErrorType | null;
isPaused: boolean;
variables: {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "legacy" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: bigint | undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
authorizationList?: undefined;
accessList?: undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip2930" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: bigint | undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip1559" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip4844" | undefined;
maxFeePerBlobGas: bigint;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs: readonly Hex[] | readonly import("viem").ByteArray[];
blobVersionedHashes?: readonly Hex[] | undefined;
kzg?: import("viem").Kzg | undefined;
sidecars?: readonly import("viem").BlobSidecar<Hex>[] | undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip7702" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: import("viem/experimental").AuthorizationList<number, boolean> | undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
};
isIdle: false;
reset: () => void;
context: unknown;
submittedAt: number;
revokeSessions: (params: RevokeSessionsArgs) => void;
revokeSessionsAsync: (params: RevokeSessionsArgs) => Promise<void>;
} | {
data: undefined;
error: import("@wagmi/core").WriteContractErrorType;
isError: true;
isPending: false;
isSuccess: false;
status: "error";
failureCount: number;
failureReason: import("@wagmi/core").WriteContractErrorType | null;
isPaused: boolean;
variables: {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "legacy" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: bigint | undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
authorizationList?: undefined;
accessList?: undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip2930" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: bigint | undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip1559" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip4844" | undefined;
maxFeePerBlobGas: bigint;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs: readonly Hex[] | readonly import("viem").ByteArray[];
blobVersionedHashes?: readonly Hex[] | undefined;
kzg?: import("viem").Kzg | undefined;
sidecars?: readonly import("viem").BlobSidecar<Hex>[] | undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip7702" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: import("viem/experimental").AuthorizationList<number, boolean> | undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
};
isIdle: false;
reset: () => void;
context: unknown;
submittedAt: number;
revokeSessions: (params: RevokeSessionsArgs) => void;
revokeSessionsAsync: (params: RevokeSessionsArgs) => Promise<void>;
} | {
data: `0x${string}`;
error: null;
isError: false;
isPending: false;
isSuccess: true;
status: "success";
failureCount: number;
failureReason: import("@wagmi/core").WriteContractErrorType | null;
isPaused: boolean;
variables: {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "legacy" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: bigint | undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
authorizationList?: undefined;
accessList?: undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip2930" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: bigint | undefined;
maxFeePerGas?: undefined;
maxPriorityFeePerGas?: undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip1559" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip4844" | undefined;
maxFeePerBlobGas: bigint;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: undefined;
accessList?: import("viem").AccessList | undefined;
blobs: readonly Hex[] | readonly import("viem").ByteArray[];
blobVersionedHashes?: readonly Hex[] | undefined;
kzg?: import("viem").Kzg | undefined;
sidecars?: readonly import("viem").BlobSidecar<Hex>[] | undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
} | {
abi: import("viem").Abi;
functionName: string;
args?: readonly unknown[] | undefined;
address: Address;
chain?: import("viem").Chain | null | undefined;
account?: `0x${string}` | import("viem").Account | null | undefined;
value?: bigint | undefined;
dataSuffix?: Hex | undefined;
gas?: bigint | undefined;
nonce?: number | undefined;
type?: "eip7702" | undefined;
maxFeePerBlobGas?: undefined;
gasPrice?: undefined;
maxFeePerGas?: bigint | undefined;
maxPriorityFeePerGas?: bigint | undefined;
authorizationList?: import("viem/experimental").AuthorizationList<number, boolean> | undefined;
accessList?: import("viem").AccessList | undefined;
blobs?: undefined;
blobVersionedHashes?: undefined;
kzg?: undefined;
sidecars?: undefined;
chainId?: number | undefined;
connector?: import("wagmi").Connector | undefined;
__mode?: "prepared" | undefined;
};
isIdle: false;
reset: () => void;
context: unknown;
submittedAt: number;
revokeSessions: (params: RevokeSessionsArgs) => void;
revokeSessionsAsync: (params: RevokeSessionsArgs) => Promise<void>;
};
//# sourceMappingURL=useRevokeSessions.d.ts.map