import { DeriveGetter, AsyncStorageInterface, SyncEngine } from '@storesjs/stores'; import { Address, WalletClient, PublicClient, Hex, Hash, TransactionRequestEIP1559, TransactionRequestEIP7702 } from 'viem'; import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype'; /** * HTTP client interface for API requests. * Parent app provides an implementation of this interface. */ interface PlatformClient { get(url?: string, opts?: { abortController?: AbortController | null; params?: Record; headers?: Record; timeout?: number; }): Promise<{ data: T; headers: Headers; status: number; }>; } /** * Logger interface for structured logging. * Parent app provides an implementation of this interface. */ interface Logger { debug(message: string, metadata?: Record): void; info(message: string, metadata?: Record): void; warn(message: string, metadata?: Record): void; error: { (error: T, metadata?: Record): void; (error: T, metadata?: Record): void; }; } /** * Store options meant primarily for browser extension environments. * * Allows the client to specify a shared storage/sync configuration * and limit query store enablement as needed. */ type StoreOptions = { /** Async storage adapter (e.g., ChromeStorageAdapter) */ storage: Storage; /** Sync engine for cross-tab/device synchronization */ sync: { engine: Sync; }; /** Function to determine if query stores should be enabled */ shouldEnable: () => boolean; }; /** * Required services - must be provided at configure() time. */ interface RequiredServices { /** HTTP client for API requests */ platformClient: PlatformClient; /** Logger for debug/info/warn/error messages */ logger: Logger; /** * Reactive `$` getter for current wallet address. * Enables automatic pre-fetching when address changes. */ getCurrentAddress: ($: DeriveGetter) => Address | null; } /** * Optional services. */ interface OptionalServices { /** Store options with platform-specific storage/sync */ storeOptions?: StoreOptions; } /** * All services - required and optional. */ type Services = RequiredServices & OptionalServices; /** Forces TypeScript to expand a type for more legible IDE display. */ type Prettify = T extends infer U ? { [K in keyof U]: U[K]; } : never; /** * Configure the delegation library with required services. * * Must be called before using any delegation functions. */ declare function configure(configuration: Readonly>): void; /** * Structural type for ethers `Provider`. * * Connection properties are optional since only `JsonRpcProvider` has them. */ type ProviderLike = { readonly _isProvider: boolean; connection?: { url: string; }; _getConnection?: () => { url: string; }; }; /** * Structural type for ethers `Wallet`. * * Requires `privateKey` which doesn't exist on the abstract `Signer`. */ type SignerLike = { readonly _isSigner: boolean; privateKey: string; provider?: ProviderLike | null; }; type ViemClientInput = { walletClient: WalletClient; publicClient: PublicClient; }; type EthersClientInput = { signer: SignerLike; provider: ProviderLike; chainId: number; }; type ClientInput = ViemClientInput | EthersClientInput; /** Reason why delegation is not supported. */ declare const UnsupportedReason: { /** User has disabled delegation for this address */ readonly USER_DISABLED: "USER_DISABLED"; /** Delegation requirements are not satisfied on this chain */ readonly NOT_AVAILABLE: "NOT_AVAILABLE"; }; type UnsupportedReason = (typeof UnsupportedReason)[keyof typeof UnsupportedReason]; type SupportsDelegationResult = { supported: boolean; reason: UnsupportedReason | null; }; type SupportsDelegationParams = { address: Address; chainId: number; /** * Set true to bypass cache and fetch the latest chain status. * Keep false for UI paths that can use recent cached status. */ requireFreshStatus?: boolean; }; /** * Check whether delegation requirements for `executeBatchedTransaction` * are currently satisfied for this address/chain. * * `supported: true` means delegation is enabled for this address and either: * - the account is already Rainbow delegated on the chain, or * - the account can authorize delegation on the chain now. * * Use this for UI branching (batched vs sequential). Execution actions still * revalidate with fresh reads before signing. */ declare function supportsDelegation({ address, chainId, requireFreshStatus, }: SupportsDelegationParams): Promise; type Revoke = { address: Address; chainId: number; }; type ShouldRevokeDelegationResult = { shouldRevoke: boolean; revokes: Revoke[]; }; /** * Check if the wallet should revoke delegation across all chains. * * Returns shouldRevoke: true when delegated to Rainbow with a revoke reason. */ declare function shouldRevokeDelegation({ address, }: { address: Address; }): Promise<{ shouldRevoke: boolean; revokes: Revoke[]; }>; /** * Enum for wallet delegation status * These represent the state of delegation: e.g. delegated, undelegated */ declare const DelegationStatus: { /** UNSPECIFIED - Unspecified */ readonly UNSPECIFIED: "DELEGATION_STATUS_UNSPECIFIED"; /** NOT_DELEGATED - Wallet is not Delegated to any contract */ readonly NOT_DELEGATED: "DELEGATION_STATUS_NOT_DELEGATED"; /** RAINBOW_DELEGATED - Already Delegated to any rainbow contract */ readonly RAINBOW_DELEGATED: "DELEGATION_STATUS_RAINBOW_DELEGATED"; /** THIRD_PARTY_DELEGATED - Already Delegated to a contract that does not belong to rainbow */ readonly THIRD_PARTY_DELEGATED: "DELEGATION_STATUS_THIRD_PARTY_DELEGATED"; readonly UNRECOGNIZED: "UNRECOGNIZED"; }; type DelegationStatus = typeof DelegationStatus[keyof typeof DelegationStatus]; declare namespace DelegationStatus { type UNSPECIFIED = typeof DelegationStatus.UNSPECIFIED; type NOT_DELEGATED = typeof DelegationStatus.NOT_DELEGATED; type RAINBOW_DELEGATED = typeof DelegationStatus.RAINBOW_DELEGATED; type THIRD_PARTY_DELEGATED = typeof DelegationStatus.THIRD_PARTY_DELEGATED; type UNRECOGNIZED = typeof DelegationStatus.UNRECOGNIZED; } /** * Enum for reasons a wallet should revoke current delegation * These represent the reason: e.g. exploit, buggy */ declare const RevokeReason: { /** UNSPECIFIED - Unspecified */ readonly UNSPECIFIED: "REVOKE_REASON_UNSPECIFIED"; /** VULNERABILITY - The current contract is potentially exploitable */ readonly VULNERABILITY: "REVOKE_REASON_VULNERABILITY"; /** BUG - The current contract has errors */ readonly BUG: "REVOKE_REASON_BUG"; readonly UNRECOGNIZED: "UNRECOGNIZED"; }; type RevokeReason = typeof RevokeReason[keyof typeof RevokeReason]; declare namespace RevokeReason { type UNSPECIFIED = typeof RevokeReason.UNSPECIFIED; type VULNERABILITY = typeof RevokeReason.VULNERABILITY; type BUG = typeof RevokeReason.BUG; type UNRECOGNIZED = typeof RevokeReason.UNRECOGNIZED; } /** * Enum for reasons a wallet should update current delegation * These represent the reason: e.g. new version, use rainbow contract */ declare const UpdateReason: { /** UNSPECIFIED - Unspecified */ readonly UNSPECIFIED: "UPDATE_REASON_UNSPECIFIED"; /** UPGRADE_AVAILABLE - User is using an older version of rainbow contract */ readonly UPGRADE_AVAILABLE: "UPDATE_REASON_UPGRADE_AVAILABLE"; /** RAINBOW_ONBOARDING - User can start using the rainbow contract for delegation */ readonly RAINBOW_ONBOARDING: "UPDATE_REASON_RAINBOW_ONBOARDING"; readonly UNRECOGNIZED: "UNRECOGNIZED"; }; type UpdateReason = typeof UpdateReason[keyof typeof UpdateReason]; declare namespace UpdateReason { type UNSPECIFIED = typeof UpdateReason.UNSPECIFIED; type UPGRADE_AVAILABLE = typeof UpdateReason.UPGRADE_AVAILABLE; type RAINBOW_ONBOARDING = typeof UpdateReason.RAINBOW_ONBOARDING; type UNRECOGNIZED = typeof UpdateReason.UNRECOGNIZED; } /** * Represents the delegation state for an address on a specific chain. * Flattened view of the protobuf Status for client consumption. */ type ChainDelegationState = { /** Current delegation status of the wallet */ delegationStatus: DelegationStatus; /** Present when the current delegation should be revoked (vulnerability or bug) */ revokeReason: RevokeReason | null; /** Contract address to revoke, present when revokeReason is set */ revokeAddress: Address | null; /** Present when an update is available (upgrade or onboarding) */ updateReason: UpdateReason | null; /** Current delegation contract address, present when delegated to Rainbow */ currentContract: Address | null; /** Current delegation contract name, present when delegated to Rainbow */ currentContractName: string | null; /** Latest Rainbow contract address, present when an update is available */ latestContract: Address | null; /** Timestamp of the last update (chain specific) */ lastUpdated?: number; }; /** * Delegation state for all chains - map of chainId to ChainDelegationState */ type DelegationState = { [chainId: number]: ChainDelegationState; }; type DelegationContract = { chainId: number; contractAddress: Address; }; declare enum DelegationDecisionType { AlreadyDelegated = "ALREADY_DELEGATED", Authorize = "AUTHORIZE", None = "NONE" } type DelegationDecision = { type: DelegationDecisionType.AlreadyDelegated; } | { type: DelegationDecisionType.Authorize; delegation: DelegationContract; } | { type: DelegationDecisionType.None; }; type AddressChainParams = { address: Address; chainId: number; }; type RainbowDelegationStatus = Extract; type NonRainbowDelegationStatus = Exclude | null; type DelegationStatusPatch = ({ delegation?: DelegationContract; delegationStatus: RainbowDelegationStatus; } | { delegation?: never; delegationStatus: NonRainbowDelegationStatus; }) & Partial>; type DelegationWithChainId = Omit & { chainId: number; }; type FreshnessOptions = { /** * Set true to bypass cache and fetch the latest chain status. * @default false */ fresh?: boolean; staleTime?: never; } | { fresh?: never; /** * Return cached status only if fetched within this window. * * Defaults: * - Chain-specific: `time.seconds(30)` * - Full delegation status: `time.minutes(5)` */ staleTime?: number; }; type DelegationStatusStoreState = { disabledAddresses: Set
; isDelegationEnabled: (address: Address) => boolean; disableDelegation: (address: Address) => void; enableDelegation: (address: Address) => void; getActiveDelegations: (address: Address) => DelegationWithChainId[]; getDelegationStatus: (params: { address: Address; } & FreshnessOptions) => Promise; getChainDelegationStatus: (params: AddressChainParams & FreshnessOptions) => Promise; getCachedChainStatus: (params: AddressChainParams & { /** * Return cached status only if fetched within this window. * @default time.minutes(5) */ staleTime?: number; }) => ChainDelegationState | null; getDelegationDecision: (params: AddressChainParams) => DelegationDecision; updateStatus: (params: AddressChainParams & DelegationStatusPatch) => void; resetCache: () => void; }; /** Returns whether delegation is enabled for an address. */ declare const isDelegationEnabled: DelegationStatusStoreState['isDelegationEnabled']; /** Disable delegation for an address (user preference). */ declare const disableDelegation: DelegationStatusStoreState['disableDelegation']; /** Enable delegation for an address (remove user preference). */ declare const enableDelegation: DelegationStatusStoreState['enableDelegation']; /** Reset the delegation status cache (clears all cached delegation data). */ declare const resetCache: DelegationStatusStoreState['resetCache']; type GetDelegationsParams = { address: Address; }; type GetDelegationsResult = DelegationWithChainId[]; /** * Get all delegations for a wallet across all chains. * Reads delegation state and returns only chains where the wallet is delegated. */ declare function getDelegations({ address, }: { address: Address; }): Promise; declare const caliburEntryAbi: readonly [{ readonly type: "fallback"; readonly stateMutability: "payable"; }, { readonly type: "receive"; readonly stateMutability: "payable"; }, { readonly type: "function"; readonly name: "CUSTOM_STORAGE_ROOT"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "ENTRY_POINT"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "address"; readonly internalType: "address"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "approveNative"; readonly inputs: readonly [{ readonly name: "spender"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "amount"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bool"; readonly internalType: "bool"; }]; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "approveNativeTransient"; readonly inputs: readonly [{ readonly name: "spender"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "amount"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bool"; readonly internalType: "bool"; }]; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "domainBytes"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "bytes"; readonly internalType: "bytes"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "domainSeparator"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "eip712Domain"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: "fields"; readonly type: "bytes1"; readonly internalType: "bytes1"; }, { readonly name: "name"; readonly type: "string"; readonly internalType: "string"; }, { readonly name: "version"; readonly type: "string"; readonly internalType: "string"; }, { readonly name: "chainId"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "verifyingContract"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "salt"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "extensions"; readonly type: "uint256[]"; readonly internalType: "uint256[]"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "execute"; readonly inputs: readonly [{ readonly name: "batchedCall"; readonly type: "tuple"; readonly internalType: "struct BatchedCall"; readonly components: readonly [{ readonly name: "calls"; readonly type: "tuple[]"; readonly internalType: "struct Call[]"; readonly components: readonly [{ readonly name: "to"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "data"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }, { readonly name: "revertOnFailure"; readonly type: "bool"; readonly internalType: "bool"; }]; }]; readonly outputs: readonly []; readonly stateMutability: "payable"; }, { readonly type: "function"; readonly name: "execute"; readonly inputs: readonly [{ readonly name: "signedBatchedCall"; readonly type: "tuple"; readonly internalType: "struct SignedBatchedCall"; readonly components: readonly [{ readonly name: "batchedCall"; readonly type: "tuple"; readonly internalType: "struct BatchedCall"; readonly components: readonly [{ readonly name: "calls"; readonly type: "tuple[]"; readonly internalType: "struct Call[]"; readonly components: readonly [{ readonly name: "to"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "data"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }, { readonly name: "revertOnFailure"; readonly type: "bool"; readonly internalType: "bool"; }]; }, { readonly name: "nonce"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "keyHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "executor"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "deadline"; readonly type: "uint256"; readonly internalType: "uint256"; }]; }, { readonly name: "wrappedSignature"; readonly type: "bytes"; readonly internalType: "bytes"; }]; readonly outputs: readonly []; readonly stateMutability: "payable"; }, { readonly type: "function"; readonly name: "execute"; readonly inputs: readonly [{ readonly name: "mode"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "executionData"; readonly type: "bytes"; readonly internalType: "bytes"; }]; readonly outputs: readonly []; readonly stateMutability: "payable"; }, { readonly type: "function"; readonly name: "executeUserOp"; readonly inputs: readonly [{ readonly name: "userOp"; readonly type: "tuple"; readonly internalType: "struct PackedUserOperation"; readonly components: readonly [{ readonly name: "sender"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "nonce"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "initCode"; readonly type: "bytes"; readonly internalType: "bytes"; }, { readonly name: "callData"; readonly type: "bytes"; readonly internalType: "bytes"; }, { readonly name: "accountGasLimits"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "preVerificationGas"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "gasFees"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "paymasterAndData"; readonly type: "bytes"; readonly internalType: "bytes"; }, { readonly name: "signature"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }, { readonly name: ""; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "getKey"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "tuple"; readonly internalType: "struct Key"; readonly components: readonly [{ readonly name: "keyType"; readonly type: "uint8"; readonly internalType: "enum KeyType"; }, { readonly name: "publicKey"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "getKeySettings"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "uint256"; readonly internalType: "Settings"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "getSeq"; readonly inputs: readonly [{ readonly name: "key"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: "seq"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "hashTypedData"; readonly inputs: readonly [{ readonly name: "hash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "invalidateNonce"; readonly inputs: readonly [{ readonly name: "newNonce"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "isRegistered"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bool"; readonly internalType: "bool"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "isValidSignature"; readonly inputs: readonly [{ readonly name: "digest"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "wrappedSignature"; readonly type: "bytes"; readonly internalType: "bytes"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bytes4"; readonly internalType: "bytes4"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "keyAt"; readonly inputs: readonly [{ readonly name: "i"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "tuple"; readonly internalType: "struct Key"; readonly components: readonly [{ readonly name: "keyType"; readonly type: "uint8"; readonly internalType: "enum KeyType"; }, { readonly name: "publicKey"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "keyCount"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "keyHashes"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: "_spacer"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "multicall"; readonly inputs: readonly [{ readonly name: "data"; readonly type: "bytes[]"; readonly internalType: "bytes[]"; }]; readonly outputs: readonly [{ readonly name: "results"; readonly type: "bytes[]"; readonly internalType: "bytes[]"; }]; readonly stateMutability: "payable"; }, { readonly type: "function"; readonly name: "namespaceAndVersion"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "string"; readonly internalType: "string"; }]; readonly stateMutability: "pure"; }, { readonly type: "function"; readonly name: "nativeAllowance"; readonly inputs: readonly [{ readonly name: "spender"; readonly type: "address"; readonly internalType: "address"; }]; readonly outputs: readonly [{ readonly name: "allowance"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "nonceSequenceNumber"; readonly inputs: readonly [{ readonly name: "key"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: "seq"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "register"; readonly inputs: readonly [{ readonly name: "key"; readonly type: "tuple"; readonly internalType: "struct Key"; readonly components: readonly [{ readonly name: "keyType"; readonly type: "uint8"; readonly internalType: "enum KeyType"; }, { readonly name: "publicKey"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "revoke"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "supportsExecutionMode"; readonly inputs: readonly [{ readonly name: "mode"; readonly type: "bytes32"; readonly internalType: "bytes32"; }]; readonly outputs: readonly [{ readonly name: "result"; readonly type: "bool"; readonly internalType: "bool"; }]; readonly stateMutability: "pure"; }, { readonly type: "function"; readonly name: "transferFromNative"; readonly inputs: readonly [{ readonly name: "from"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "recipient"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "amount"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bool"; readonly internalType: "bool"; }]; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "transferFromNativeTransient"; readonly inputs: readonly [{ readonly name: "from"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "recipient"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "amount"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bool"; readonly internalType: "bool"; }]; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "transientNativeAllowance"; readonly inputs: readonly [{ readonly name: "spender"; readonly type: "address"; readonly internalType: "address"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "update"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "settings"; readonly type: "uint256"; readonly internalType: "Settings"; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "updateEntryPoint"; readonly inputs: readonly [{ readonly name: "entryPoint"; readonly type: "address"; readonly internalType: "address"; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "updateSalt"; readonly inputs: readonly [{ readonly name: "prefix"; readonly type: "uint96"; readonly internalType: "uint96"; }]; readonly outputs: readonly []; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "validateUserOp"; readonly inputs: readonly [{ readonly name: "userOp"; readonly type: "tuple"; readonly internalType: "struct PackedUserOperation"; readonly components: readonly [{ readonly name: "sender"; readonly type: "address"; readonly internalType: "address"; }, { readonly name: "nonce"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "initCode"; readonly type: "bytes"; readonly internalType: "bytes"; }, { readonly name: "callData"; readonly type: "bytes"; readonly internalType: "bytes"; }, { readonly name: "accountGasLimits"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "preVerificationGas"; readonly type: "uint256"; readonly internalType: "uint256"; }, { readonly name: "gasFees"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "paymasterAndData"; readonly type: "bytes"; readonly internalType: "bytes"; }, { readonly name: "signature"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }, { readonly name: "userOpHash"; readonly type: "bytes32"; readonly internalType: "bytes32"; }, { readonly name: "missingAccountFunds"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly outputs: readonly [{ readonly name: "validationData"; readonly type: "uint256"; readonly internalType: "uint256"; }]; readonly stateMutability: "nonpayable"; }, { readonly type: "event"; readonly name: "ApproveNative"; readonly inputs: readonly [{ readonly name: "owner"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "spender"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "uint256"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "ApproveNativeTransient"; readonly inputs: readonly [{ readonly name: "owner"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "spender"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "uint256"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "EIP712DomainChanged"; readonly inputs: readonly []; readonly anonymous: false; }, { readonly type: "event"; readonly name: "EntryPointUpdated"; readonly inputs: readonly [{ readonly name: "newEntryPoint"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "KeySettingsUpdated"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly indexed: true; readonly internalType: "bytes32"; }, { readonly name: "settings"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "Settings"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "NativeAllowanceUpdated"; readonly inputs: readonly [{ readonly name: "spender"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "uint256"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "NonceInvalidated"; readonly inputs: readonly [{ readonly name: "nonce"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "uint256"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "Registered"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly indexed: true; readonly internalType: "bytes32"; }, { readonly name: "key"; readonly type: "tuple"; readonly indexed: false; readonly internalType: "struct Key"; readonly components: readonly [{ readonly name: "keyType"; readonly type: "uint8"; readonly internalType: "enum KeyType"; }, { readonly name: "publicKey"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "Revoked"; readonly inputs: readonly [{ readonly name: "keyHash"; readonly type: "bytes32"; readonly indexed: true; readonly internalType: "bytes32"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "TransferFromNative"; readonly inputs: readonly [{ readonly name: "from"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "to"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "uint256"; }]; readonly anonymous: false; }, { readonly type: "event"; readonly name: "TransferFromNativeTransient"; readonly inputs: readonly [{ readonly name: "from"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "to"; readonly type: "address"; readonly indexed: true; readonly internalType: "address"; }, { readonly name: "value"; readonly type: "uint256"; readonly indexed: false; readonly internalType: "uint256"; }]; readonly anonymous: false; }, { readonly type: "error"; readonly name: "AllowanceExceeded"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "CallFailed"; readonly inputs: readonly [{ readonly name: "reason"; readonly type: "bytes"; readonly internalType: "bytes"; }]; }, { readonly type: "error"; readonly name: "CannotRegisterRootKey"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "CannotUpdateRootKey"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "ExcessiveInvalidation"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "FnSelectorNotRecognized"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "IncorrectSender"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "IndexOutOfBounds"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "InvalidHookResponse"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "InvalidNonce"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "InvalidSignature"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "KeyDoesNotExist"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "KeyExpired"; readonly inputs: readonly [{ readonly name: "expiration"; readonly type: "uint40"; readonly internalType: "uint40"; }]; }, { readonly type: "error"; readonly name: "NotEntryPoint"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "OnlyAdminCanSelfCall"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "SignatureExpired"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "TransferNativeFailed"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "Unauthorized"; readonly inputs: readonly []; }, { readonly type: "error"; readonly name: "UnsupportedExecutionMode"; readonly inputs: readonly []; }]; type ExecuteBatchedCallFn = Extract, { inputs: readonly [{ readonly name: 'batchedCall'; }]; }>; type BatchedCall = AbiParametersToPrimitiveTypes[0]; type Merge = { [K in keyof T | keyof U]: K extends keyof U ? U[K] : K extends keyof T ? T[K] : never; }; type BatchCall = Merge; type ExecutionResult = { hash: Hash; type: 'eip1559'; transaction: TransactionRequestEIP1559; } | { hash: Hash; type: 'eip7702'; transaction: TransactionRequestEIP7702; }; type TransactionGasOptions = { maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; gasLimit: bigint | null; }; /** * Execute batched transactions with EIP-7702 delegation. * * Resolves delegation state internally and executes either: * - direct call path (already delegated), or * - delegation + call path (delegation needed and allowed) * * Throws when delegation requirements are not satisfied on the chain. */ declare const executeBatchedTransaction: (params: { chainId: number; calls: readonly BatchCall[]; value?: bigint | undefined; transactionOptions: TransactionGasOptions; nonce: number; } & ClientInput) => Promise; type WillDelegateParams = { address: Address; chainId: number; /** * Set true to bypass cache and fetch the latest chain status. * Keep false where recent cached status is acceptable. */ requireFreshStatus?: boolean; }; type WillDelegateResult = { /** True when executeBatchedTransaction would perform delegation. */ willDelegate: boolean; /** Delegation target when willDelegate is true. */ delegation: DelegationContract | null; }; /** * Check whether the next batched execution would perform delegation. * * Useful for advance-warning UI copy and gas messaging. Execution actions * still revalidate with fresh reads before signing. * * Returns `willDelegate: false` when already Rainbow delegated, including * upgrade-available states. Upgrade flows are explicit (`executeDelegation`). */ declare function willDelegate({ address, chainId, requireFreshStatus, }: WillDelegateParams): Promise; type ExecuteDelegationParams = { chainId: number; calldata: Hex; value?: bigint; transactionOptions: TransactionGasOptions; nonce: number; }; /** * Execute a delegation transaction with EIP-7702 authorization. * * Signs an authorization for the delegation contract and sends * the transaction with the provided calldata. * * Callers may run supportsDelegation() as a UI check; this action * still performs fresh delegation checks before signing. */ declare const executeDelegation: (params: { chainId: number; calldata: Hex; value?: bigint | undefined; transactionOptions: TransactionGasOptions; nonce: number; } & ClientInput) => Promise; type ExecuteRevokeDelegationParams = { chainId: number; transactionOptions: TransactionGasOptions; nonce: number; }; /** * Revoke EIP-7702 delegation by setting contract address to zero address. * * Revocation is allowed regardless of user preference since it's a cleanup operation. * Use shouldRevokeDelegation() to check if revocation is recommended. */ declare const executeRevokeDelegation: (params: { chainId: number; transactionOptions: TransactionGasOptions; nonce: number; } & ClientInput) => Promise; type Authorization = { address: Address; chainId: Hex; nonce: Hex; }; type Transaction = { from: Address; to: Address; data: Hex; value: Hex; authorization_list?: Authorization[]; }; /** * Prepare batched transaction for gas simulation. * * Returns a Transaction object suitable for simulation, * including `authorization_list` when delegation would be performed. */ declare function prepareBatchedTransaction({ from, calls, chainId, nonce, }: { from: Address; calls: readonly BatchCall[]; chainId: number; nonce: number; }): Promise; /** * Returns `true` if delegation is disabled for the given address, `false` otherwise. * * @example * ```tsx * import { * enableDelegation, * disableDelegation, * useDelegationDisabled * } from '@rainbow-me/delegation'; * * const disabled = useDelegationDisabled(address); * * function handleToggle() { * if (disabled) enableDelegation(address); * else disableDelegation(address); * } * ``` */ declare function useDelegationDisabled(address: Address): boolean; /** * Returns true when current delegation store state indicates the next batched * execution would perform delegation. */ declare function useWillDelegate(address: Address, chainId: number): boolean; /** * Active delegations for an address across all chains. */ type ActiveDelegations = DelegationWithChainId[]; /** * Subscribes to active delegation state for an address. * * Returns active delegations only (`RAINBOW_DELEGATED` and * `THIRD_PARTY_DELEGATED`), or an empty array when none are active. */ declare function useDelegations(address: Address): ActiveDelegations; export { type ActiveDelegations, type Authorization, type BatchCall, type ChainDelegationState, type DelegationState, DelegationStatus, type DelegationWithChainId, type ExecuteDelegationParams, type ExecuteRevokeDelegationParams, type ExecutionResult, type GetDelegationsParams, type GetDelegationsResult, type Revoke, RevokeReason, type Services, type ShouldRevokeDelegationResult, type SupportsDelegationResult, type Transaction, type TransactionGasOptions, UnsupportedReason, UpdateReason, type WillDelegateParams, type WillDelegateResult, configure, disableDelegation, enableDelegation, executeBatchedTransaction, executeDelegation, executeRevokeDelegation, getDelegations, isDelegationEnabled, prepareBatchedTransaction, resetCache, shouldRevokeDelegation, supportsDelegation, useDelegationDisabled, useDelegations, useWillDelegate, willDelegate };