/** * AEGIS: Sovereign Agency Protocol * * Cryptographic delegation of signing authority across all chains. * Enables scoped, hierarchical, revocable delegation enforced by * threshold cryptography — not law, not smart contracts, not trust. * * @example * ```typescript * // Delegate trading authority to an AI agent * const grant = await wallet.delegate({ * to: '0xAiAgent...', * chains: ['ethereum', 'arbitrum'], * constraints: { * maxPerTransaction: '1000000000000000000', // 1 ETH * maxPerDay: '10000000000000000000', // 10 ETH * allowedOperations: ['swap', 'transfer'], * }, * validUntil: '2026-12-31T23:59:59Z', * }); * * // Sub-delegate from the AI agent to a sub-bot * const subGrant = await wallet.delegateFrom({ * parentGrantId: grant.delegationId, * signerKey: '0xAiAgentPrivateKey...', * to: '0xSubBot...', * chains: ['ethereum'], * constraints: { * maxPerTransaction: '100000000000000000', // 0.1 ETH * maxPerDay: '500000000000000000', // 0.5 ETH * }, * }); * ``` */ import { Chain } from './types'; /** * Options for creating a delegation grant. * The wallet owner specifies who can sign, on which chains, * with what constraints, and for how long. */ export interface DelegateOptions { /** Public key or address of the delegate */ to: string; /** Which chains this delegation covers */ chains: Chain[]; /** Optional SIGNET WASM policy ID for custom constraint logic */ wasmPolicyId?: string; /** Spending and operation constraints */ constraints: DelegationConstraints; /** ISO 8601 start time (default: now) */ validFrom?: string; /** ISO 8601 expiration (omit for no expiration) */ validUntil?: string; /** Can this delegate create sub-delegates? (default: false) */ subDelegation?: boolean; /** Max levels of sub-delegation below this grant (default: 0) */ maxSubDepth?: number; /** Revocation mode: 'immediate' or 'owner-only' (default: 'immediate') */ revocation?: 'immediate' | 'owner-only'; /** Dead-man's switch activation config */ activation?: DeadMansSwitchConfig; } /** * Spending and operation constraints for a delegation grant. * All limits are enforced by the agent network at signing time. */ export interface DelegationConstraints { /** Max value per transaction in wei (omit for unlimited) */ maxPerTransaction?: string; /** Max value per day in wei (omit for unlimited) */ maxPerDay?: string; /** Max lifetime spending in wei (omit for unlimited) */ maxTotal?: string; /** Allowed operation types (e.g., 'transfer', 'swap', 'stake') */ allowedOperations?: string[]; /** Whitelisted target addresses/contracts */ allowedTargets?: string[]; /** Blacklisted target addresses */ deniedTargets?: string[]; /** Block external transfers (only protocol interactions) */ denyExternalTransfers?: boolean; } /** * Dead-man's switch configuration. * If the owner misses a heartbeat beyond the grace period, * the delegate's authority automatically activates. */ export interface DeadMansSwitchConfig { /** Heartbeat interval (e.g., '180 days', '30 days') */ heartbeatInterval: string; /** Grace period after missed heartbeat */ gracePeriod: string; } /** * Options for creating a sub-delegation from an existing grant. * The parent delegate can further scope down authority to a child delegate. * Constraints can only be narrowed, never expanded. */ export interface SubDelegateOptions extends DelegateOptions { /** Parent grant ID to sub-delegate from */ parentGrantId: string; /** Private key of the parent delegate (signs the sub-grant) */ signerKey: string; } /** * A delegation grant — the cryptographic record of delegated authority. * Stored and enforced by the agent network. */ export interface DelegationGrant { /** Unique delegation ID */ delegationId: string; /** Address of the delegator (owner or parent delegate) */ delegator: string; /** Address of the delegate receiving authority */ delegate: string; /** Wallet ID this delegation applies to */ walletId: string; /** Chains this delegation covers */ chains: Chain[]; /** Optional WASM policy ID */ wasmPolicyId?: string; /** Spending and operation constraints */ constraints: DelegationConstraints; /** ISO 8601 start time */ validFrom: string; /** ISO 8601 expiration (undefined = no expiration) */ validUntil?: string; /** Parent grant ID (undefined = root delegation from owner) */ parentGrantId?: string; /** Max sub-delegation depth allowed */ maxSubDepth: number; /** Current depth in the delegation tree (0 = root) */ currentDepth: number; /** Whether this delegate can create sub-delegates */ allowSubDelegation: boolean; /** Whether this grant is currently active */ isActive: boolean; /** Dead-man's switch config (if applicable) */ activation?: DeadMansSwitchConfig; /** Unix timestamp of creation */ createdAt: number; /** Amount spent today in wei */ spentToday: string; /** Total amount spent lifetime in wei */ spentTotal: string; } /** * Hierarchical tree of delegation grants. * The root is the owner's direct delegation, with children * representing sub-delegations at each level. */ export interface DelegationTree { /** The delegation grant at this node */ grant: DelegationGrant; /** Sub-delegations created from this grant */ children: DelegationTree[]; } /** * Current authority status of a delegate. * Shows remaining budgets, allowed actions, and delegation metadata. */ export interface AuthorityStatus { /** Delegation ID */ delegationId: string; /** Whether the delegation is currently active */ isActive: boolean; /** Remaining per-transaction budget in wei */ remainingPerTx: string; /** Remaining daily budget in wei */ remainingToday: string; /** Remaining lifetime budget in wei */ remainingTotal: string; /** Chains this delegate can sign on */ allowedChains: Chain[]; /** Allowed operation types */ allowedOperations: string[]; /** ISO 8601 expiration (undefined = no expiration) */ validUntil?: string; /** Number of active sub-delegations from this grant */ subDelegateCount: number; /** Depth of this delegation in the hierarchy */ delegationDepth: number; } //# sourceMappingURL=delegation.d.ts.map