import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem'; import { getContract } from 'viem'; /** * Safe_json ABI * * This ABI is typed using viem's type system for full type safety. */ export const Safe_jsonAbi = [ { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" } ], "name": "AddedOwner", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "approvedHash", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "owner", "type": "address" } ], "name": "ApproveHash", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "handler", "type": "address" } ], "name": "ChangedFallbackHandler", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "guard", "type": "address" } ], "name": "ChangedGuard", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "threshold", "type": "uint256" } ], "name": "ChangedThreshold", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "module", "type": "address" } ], "name": "DisabledModule", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "module", "type": "address" } ], "name": "EnabledModule", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "txHash", "type": "bytes32" }, { "indexed": false, "internalType": "uint256", "name": "payment", "type": "uint256" } ], "name": "ExecutionFailure", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "module", "type": "address" } ], "name": "ExecutionFromModuleFailure", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "module", "type": "address" } ], "name": "ExecutionFromModuleSuccess", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "txHash", "type": "bytes32" }, { "indexed": false, "internalType": "uint256", "name": "payment", "type": "uint256" } ], "name": "ExecutionSuccess", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "owner", "type": "address" } ], "name": "RemovedOwner", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } ], "name": "SafeReceived", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "initiator", "type": "address" }, { "indexed": false, "internalType": "address[]", "name": "owners", "type": "address[]" }, { "indexed": false, "internalType": "uint256", "name": "threshold", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "initializer", "type": "address" }, { "indexed": false, "internalType": "address", "name": "fallbackHandler", "type": "address" } ], "name": "SafeSetup", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "bytes32", "name": "msgHash", "type": "bytes32" } ], "name": "SignMsg", "type": "event" }, { "stateMutability": "nonpayable", "type": "fallback" }, { "inputs": [], "name": "VERSION", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "uint256", "name": "_threshold", "type": "uint256" } ], "name": "addOwnerWithThreshold", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "hashToApprove", "type": "bytes32" } ], "name": "approveHash", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "", "type": "address" }, { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "name": "approvedHashes", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "_threshold", "type": "uint256" } ], "name": "changeThreshold", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "dataHash", "type": "bytes32" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "signatures", "type": "bytes" }, { "internalType": "uint256", "name": "requiredSignatures", "type": "uint256" } ], "name": "checkNSignatures", "outputs": [], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "dataHash", "type": "bytes32" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "signatures", "type": "bytes" } ], "name": "checkSignatures", "outputs": [], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "prevModule", "type": "address" }, { "internalType": "address", "name": "module", "type": "address" } ], "name": "disableModule", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "domainSeparator", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "module", "type": "address" } ], "name": "enableModule", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "enum Enum.Operation", "name": "operation", "type": "uint8" }, { "internalType": "uint256", "name": "safeTxGas", "type": "uint256" }, { "internalType": "uint256", "name": "baseGas", "type": "uint256" }, { "internalType": "uint256", "name": "gasPrice", "type": "uint256" }, { "internalType": "address", "name": "gasToken", "type": "address" }, { "internalType": "address", "name": "refundReceiver", "type": "address" }, { "internalType": "uint256", "name": "_nonce", "type": "uint256" } ], "name": "encodeTransactionData", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "enum Enum.Operation", "name": "operation", "type": "uint8" }, { "internalType": "uint256", "name": "safeTxGas", "type": "uint256" }, { "internalType": "uint256", "name": "baseGas", "type": "uint256" }, { "internalType": "uint256", "name": "gasPrice", "type": "uint256" }, { "internalType": "address", "name": "gasToken", "type": "address" }, { "internalType": "address payable", "name": "refundReceiver", "type": "address" }, { "internalType": "bytes", "name": "signatures", "type": "bytes" } ], "name": "execTransaction", "outputs": [ { "internalType": "bool", "name": "success", "type": "bool" } ], "stateMutability": "payable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "enum Enum.Operation", "name": "operation", "type": "uint8" } ], "name": "execTransactionFromModule", "outputs": [ { "internalType": "bool", "name": "success", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "enum Enum.Operation", "name": "operation", "type": "uint8" } ], "name": "execTransactionFromModuleReturnData", "outputs": [ { "internalType": "bool", "name": "success", "type": "bool" }, { "internalType": "bytes", "name": "returnData", "type": "bytes" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "getChainId", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "start", "type": "address" }, { "internalType": "uint256", "name": "pageSize", "type": "uint256" } ], "name": "getModulesPaginated", "outputs": [ { "internalType": "address[]", "name": "array", "type": "address[]" }, { "internalType": "address", "name": "next", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getOwners", "outputs": [ { "internalType": "address[]", "name": "", "type": "address[]" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "offset", "type": "uint256" }, { "internalType": "uint256", "name": "length", "type": "uint256" } ], "name": "getStorageAt", "outputs": [ { "internalType": "bytes", "name": "", "type": "bytes" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getThreshold", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "value", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "enum Enum.Operation", "name": "operation", "type": "uint8" }, { "internalType": "uint256", "name": "safeTxGas", "type": "uint256" }, { "internalType": "uint256", "name": "baseGas", "type": "uint256" }, { "internalType": "uint256", "name": "gasPrice", "type": "uint256" }, { "internalType": "address", "name": "gasToken", "type": "address" }, { "internalType": "address", "name": "refundReceiver", "type": "address" }, { "internalType": "uint256", "name": "_nonce", "type": "uint256" } ], "name": "getTransactionHash", "outputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "module", "type": "address" } ], "name": "isModuleEnabled", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "owner", "type": "address" } ], "name": "isOwner", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "nonce", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "prevOwner", "type": "address" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "uint256", "name": "_threshold", "type": "uint256" } ], "name": "removeOwner", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "handler", "type": "address" } ], "name": "setFallbackHandler", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "guard", "type": "address" } ], "name": "setGuard", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address[]", "name": "_owners", "type": "address[]" }, { "internalType": "uint256", "name": "_threshold", "type": "uint256" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "address", "name": "fallbackHandler", "type": "address" }, { "internalType": "address", "name": "paymentToken", "type": "address" }, { "internalType": "uint256", "name": "payment", "type": "uint256" }, { "internalType": "address payable", "name": "paymentReceiver", "type": "address" } ], "name": "setup", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "bytes32", "name": "", "type": "bytes32" } ], "name": "signedMessages", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "targetContract", "type": "address" }, { "internalType": "bytes", "name": "calldataPayload", "type": "bytes" } ], "name": "simulateAndRevert", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "prevOwner", "type": "address" }, { "internalType": "address", "name": "oldOwner", "type": "address" }, { "internalType": "address", "name": "newOwner", "type": "address" } ], "name": "swapOwner", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "stateMutability": "payable", "type": "receive" } ] as const satisfies Abi; /** * Type-safe ABI for Safe_json */ export type Safe_jsonAbi = typeof Safe_jsonAbi; /** * Contract instance type for Safe_json */ // Use any for contract type to avoid complex viem type issues // The runtime behavior is type-safe through viem's ABI typing export type Safe_jsonContract = any; /** * Safe_json Contract Class * * Provides a class-based API similar to TypeChain for interacting with the contract. * * @example * ```typescript * import { createPublicClient, createWalletClient, http } from 'viem'; * import { mainnet } from 'viem/chains'; * import { Safe_json } from 'Safe_json'; * * const publicClient = createPublicClient({ chain: mainnet, transport: http() }); * const walletClient = createWalletClient({ chain: mainnet, transport: http() }); * * const contract = new Safe_json('0x...', { publicClient, walletClient }); * * // Read functions * const result = await contract.balanceOf('0x...'); * * // Write functions * const hash = await contract.transfer('0x...', 1000n); * * // Simulate transactions (dry-run) * const simulation = await contract.simulate.transfer('0x...', 1000n); * console.log('Gas estimate:', simulation.request.gas); * * // Watch events * const unwatch = contract.watch.Transfer((event) => { * console.log('Transfer event:', event); * }); * ``` */ export class Safe_json { private contract: Safe_jsonContract; private contractAddress: Address; private publicClient: PublicClient; constructor( address: Address, clients: { publicClient: PublicClient; walletClient?: WalletClient; } ) { this.contractAddress = address; this.publicClient = clients.publicClient; this.contract = getContract({ address, abi: Safe_jsonAbi, client: { public: clients.publicClient, wallet: clients.walletClient, }, }); } /** * Get the contract address */ get address(): Address { return this.contractAddress; } /** * Get the underlying viem contract instance */ getContract(): Safe_jsonContract { return this.contract; } /** * VERSION * view */ async VERSION(): Promise { return this.contract.read.VERSION() as Promise; } /** * approvedHashes * view */ async approvedHashes(arg0: `0x${string}`, arg1: `0x${string}`): Promise { return this.contract.read.approvedHashes([arg0, arg1] as const) as Promise; } /** * checkNSignatures * view */ async checkNSignatures(dataHash: `0x${string}`, data: `0x${string}`, signatures: `0x${string}`, requiredSignatures: bigint): Promise { return this.contract.read.checkNSignatures([dataHash, data, signatures, requiredSignatures] as const) as Promise; } /** * checkSignatures * view */ async checkSignatures(dataHash: `0x${string}`, data: `0x${string}`, signatures: `0x${string}`): Promise { return this.contract.read.checkSignatures([dataHash, data, signatures] as const) as Promise; } /** * domainSeparator * view */ async domainSeparator(): Promise<`0x${string}`> { return this.contract.read.domainSeparator() as Promise<`0x${string}`>; } /** * encodeTransactionData * view */ async encodeTransactionData(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, safeTxGas: bigint, baseGas: bigint, gasPrice: bigint, gasToken: `0x${string}`, refundReceiver: `0x${string}`, _nonce: bigint): Promise<`0x${string}`> { return this.contract.read.encodeTransactionData([to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce] as const) as Promise<`0x${string}`>; } /** * getChainId * view */ async getChainId(): Promise { return this.contract.read.getChainId() as Promise; } /** * getModulesPaginated * view */ async getModulesPaginated(start: `0x${string}`, pageSize: bigint): Promise<[`0x${string}`[], `0x${string}`]> { return this.contract.read.getModulesPaginated([start, pageSize] as const) as Promise<[`0x${string}`[], `0x${string}`]>; } /** * getOwners * view */ async getOwners(): Promise<`0x${string}`[]> { return this.contract.read.getOwners() as Promise<`0x${string}`[]>; } /** * getStorageAt * view */ async getStorageAt(offset: bigint, length: bigint): Promise<`0x${string}`> { return this.contract.read.getStorageAt([offset, length] as const) as Promise<`0x${string}`>; } /** * getThreshold * view */ async getThreshold(): Promise { return this.contract.read.getThreshold() as Promise; } /** * getTransactionHash * view */ async getTransactionHash(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, safeTxGas: bigint, baseGas: bigint, gasPrice: bigint, gasToken: `0x${string}`, refundReceiver: `0x${string}`, _nonce: bigint): Promise<`0x${string}`> { return this.contract.read.getTransactionHash([to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce] as const) as Promise<`0x${string}`>; } /** * isModuleEnabled * view */ async isModuleEnabled(module: `0x${string}`): Promise { return this.contract.read.isModuleEnabled([module] as const) as Promise; } /** * isOwner * view */ async isOwner(owner: `0x${string}`): Promise { return this.contract.read.isOwner([owner] as const) as Promise; } /** * nonce * view */ async nonce(): Promise { return this.contract.read.nonce() as Promise; } /** * signedMessages * view */ async signedMessages(arg0: `0x${string}`): Promise { return this.contract.read.signedMessages([arg0] as const) as Promise; } /** * addOwnerWithThreshold * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async addOwnerWithThreshold(owner: `0x${string}`, _threshold: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.addOwnerWithThreshold([owner, _threshold] as const, options) as Promise<`0x${string}`>; } /** * approveHash * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async approveHash(hashToApprove: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.approveHash([hashToApprove] as const, options) as Promise<`0x${string}`>; } /** * changeThreshold * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async changeThreshold(_threshold: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.changeThreshold([_threshold] as const, options) as Promise<`0x${string}`>; } /** * disableModule * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async disableModule(prevModule: `0x${string}`, module: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.disableModule([prevModule, module] as const, options) as Promise<`0x${string}`>; } /** * enableModule * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async enableModule(module: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.enableModule([module] as const, options) as Promise<`0x${string}`>; } /** * execTransaction * payable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async execTransaction(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, safeTxGas: bigint, baseGas: bigint, gasPrice: bigint, gasToken: `0x${string}`, refundReceiver: `0x${string}`, signatures: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.execTransaction([to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures] as const, options) as Promise<`0x${string}`>; } /** * execTransactionFromModule * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async execTransactionFromModule(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.execTransactionFromModule([to, value, data, operation] as const, options) as Promise<`0x${string}`>; } /** * execTransactionFromModuleReturnData * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async execTransactionFromModuleReturnData(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.execTransactionFromModuleReturnData([to, value, data, operation] as const, options) as Promise<`0x${string}`>; } /** * removeOwner * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async removeOwner(prevOwner: `0x${string}`, owner: `0x${string}`, _threshold: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.removeOwner([prevOwner, owner, _threshold] as const, options) as Promise<`0x${string}`>; } /** * setFallbackHandler * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async setFallbackHandler(handler: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.setFallbackHandler([handler] as const, options) as Promise<`0x${string}`>; } /** * setGuard * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async setGuard(guard: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.setGuard([guard] as const, options) as Promise<`0x${string}`>; } /** * setup * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async setup(_owners: `0x${string}`[], _threshold: bigint, to: `0x${string}`, data: `0x${string}`, fallbackHandler: `0x${string}`, paymentToken: `0x${string}`, payment: bigint, paymentReceiver: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.setup([_owners, _threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver] as const, options) as Promise<`0x${string}`>; } /** * simulateAndRevert * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async simulateAndRevert(targetContract: `0x${string}`, calldataPayload: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.simulateAndRevert([targetContract, calldataPayload] as const, options) as Promise<`0x${string}`>; } /** * swapOwner * nonpayable * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async swapOwner(prevOwner: `0x${string}`, oldOwner: `0x${string}`, newOwner: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<`0x${string}`> { if (!this.contract.write) { throw new Error('Wallet client is required for write operations'); } return this.contract.write.swapOwner([prevOwner, oldOwner, newOwner] as const, options) as Promise<`0x${string}`>; } /** * Simulate contract write operations (dry-run without sending transaction) * * @example * const result = await contract.simulate.transfer('0x...', 1000n); * console.log('Gas estimate:', result.request.gas); * console.log('Would succeed:', result.result); */ get simulate() { const contract = this.contract; if (!contract.simulate) { throw new Error('Public client is required for simulation'); } return { /** * Simulate addOwnerWithThreshold * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async addOwnerWithThreshold(owner: `0x${string}`, _threshold: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.addOwnerWithThreshold([owner, _threshold] as const, options) as Promise; }, /** * Simulate approveHash * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async approveHash(hashToApprove: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.approveHash([hashToApprove] as const, options) as Promise; }, /** * Simulate changeThreshold * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async changeThreshold(_threshold: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.changeThreshold([_threshold] as const, options) as Promise; }, /** * Simulate disableModule * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async disableModule(prevModule: `0x${string}`, module: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.disableModule([prevModule, module] as const, options) as Promise; }, /** * Simulate enableModule * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async enableModule(module: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.enableModule([module] as const, options) as Promise; }, /** * Simulate execTransaction * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async execTransaction(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, safeTxGas: bigint, baseGas: bigint, gasPrice: bigint, gasToken: `0x${string}`, refundReceiver: `0x${string}`, signatures: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.execTransaction([to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, signatures] as const, options) as Promise; }, /** * Simulate execTransactionFromModule * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async execTransactionFromModule(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.execTransactionFromModule([to, value, data, operation] as const, options) as Promise; }, /** * Simulate execTransactionFromModuleReturnData * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async execTransactionFromModuleReturnData(to: `0x${string}`, value: bigint, data: `0x${string}`, operation: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise<[boolean, `0x${string}`]> { return contract.simulate.execTransactionFromModuleReturnData([to, value, data, operation] as const, options) as Promise<[boolean, `0x${string}`]>; }, /** * Simulate removeOwner * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async removeOwner(prevOwner: `0x${string}`, owner: `0x${string}`, _threshold: bigint, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.removeOwner([prevOwner, owner, _threshold] as const, options) as Promise; }, /** * Simulate setFallbackHandler * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async setFallbackHandler(handler: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.setFallbackHandler([handler] as const, options) as Promise; }, /** * Simulate setGuard * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async setGuard(guard: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.setGuard([guard] as const, options) as Promise; }, /** * Simulate setup * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async setup(_owners: `0x${string}`[], _threshold: bigint, to: `0x${string}`, data: `0x${string}`, fallbackHandler: `0x${string}`, paymentToken: `0x${string}`, payment: bigint, paymentReceiver: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.setup([_owners, _threshold, to, data, fallbackHandler, paymentToken, payment, paymentReceiver] as const, options) as Promise; }, /** * Simulate simulateAndRevert * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async simulateAndRevert(targetContract: `0x${string}`, calldataPayload: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.simulateAndRevert([targetContract, calldataPayload] as const, options) as Promise; }, /** * Simulate swapOwner * Returns gas estimate and result without sending transaction * @param options Optional transaction parameters (value, gas, nonce, etc.) */ async swapOwner(prevOwner: `0x${string}`, oldOwner: `0x${string}`, newOwner: `0x${string}`, options?: { accessList?: import('viem').AccessList; authorizationList?: import('viem').AuthorizationList; chain?: import('viem').Chain | null; dataSuffix?: `0x${string}`; gas?: bigint; gasPrice?: bigint; maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint; nonce?: number; value?: bigint; }): Promise { return contract.simulate.swapOwner([prevOwner, oldOwner, newOwner] as const, options) as Promise; } }; } /** * Watch contract events * * @example * // Watch all Transfer events * const unwatch = contract.watch.Transfer((event) => { * console.log('Transfer:', event); * }); * * // Stop watching * unwatch(); */ get watch() { return { /** * Watch AddedOwner events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ AddedOwner: (callback: (event: { owner: `0x${string}` }) => void, filter?: { owner: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'AddedOwner', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ApproveHash events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ApproveHash: (callback: (event: { approvedHash: `0x${string}`; owner: `0x${string}` }) => void, filter?: { approvedHash: `0x${string}`; owner: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ApproveHash', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ChangedFallbackHandler events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ChangedFallbackHandler: (callback: (event: { handler: `0x${string}` }) => void, filter?: { handler: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ChangedFallbackHandler', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ChangedGuard events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ChangedGuard: (callback: (event: { guard: `0x${string}` }) => void, filter?: { guard: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ChangedGuard', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ChangedThreshold events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ChangedThreshold: (callback: (event: { threshold: bigint }) => void) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ChangedThreshold', onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch DisabledModule events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ DisabledModule: (callback: (event: { module: `0x${string}` }) => void, filter?: { module: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'DisabledModule', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch EnabledModule events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ EnabledModule: (callback: (event: { module: `0x${string}` }) => void, filter?: { module: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'EnabledModule', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ExecutionFailure events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ExecutionFailure: (callback: (event: { txHash: `0x${string}`; payment: bigint }) => void, filter?: { txHash: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ExecutionFailure', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ExecutionFromModuleFailure events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ExecutionFromModuleFailure: (callback: (event: { module: `0x${string}` }) => void, filter?: { module: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ExecutionFromModuleFailure', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ExecutionFromModuleSuccess events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ExecutionFromModuleSuccess: (callback: (event: { module: `0x${string}` }) => void, filter?: { module: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ExecutionFromModuleSuccess', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch ExecutionSuccess events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ ExecutionSuccess: (callback: (event: { txHash: `0x${string}`; payment: bigint }) => void, filter?: { txHash: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'ExecutionSuccess', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch RemovedOwner events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ RemovedOwner: (callback: (event: { owner: `0x${string}` }) => void, filter?: { owner: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'RemovedOwner', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch SafeReceived events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ SafeReceived: (callback: (event: { sender: `0x${string}`; value: bigint }) => void, filter?: { sender: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'SafeReceived', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch SafeSetup events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ SafeSetup: (callback: (event: { initiator: `0x${string}`; owners: `0x${string}`[]; threshold: bigint; initializer: `0x${string}`; fallbackHandler: `0x${string}` }) => void, filter?: { initiator: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'SafeSetup', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; }, /** * Watch SignMsg events * @param callback Function to call when event is emitted * @param filter Optional filter for indexed parameters * @returns Unwatch function to stop listening */ SignMsg: (callback: (event: { msgHash: `0x${string}` }) => void, filter?: { msgHash: `0x${string}` }) => { return this.publicClient.watchContractEvent({ address: this.contractAddress, abi: Safe_jsonAbi, eventName: 'SignMsg', args: filter, onLogs: (logs: any[]) => { logs.forEach((log: any) => { callback(log.args as any); }); }, }) as () => void; } }; } }