UNPKG

0xweb

Version:

Contract package manager and other web3 tools

178 lines (143 loc) 7.06 kB
/** * AUTO-Generated Class: 2024-05-17 00:25 * Implementation: https://etherscan.io/address/undefined#code */ import di from 'a-di'; import { TAddress } from '@dequanto/models/TAddress'; import { TAccount } from '@dequanto/models/TAccount'; import { TBufferLike } from '@dequanto/models/TBufferLike'; import { ClientEventsStream, TClientEventsStreamData } from '@dequanto/clients/ClientEventsStream'; import { ContractBase } from '@dequanto/contracts/ContractBase'; import { ContractBaseUtils } from '@dequanto/contracts/utils/ContractBaseUtils'; import { ContractStorageReaderBase } from '@dequanto/contracts/ContractStorageReaderBase'; import { TxWriter } from '@dequanto/txs/TxWriter'; import { ITxLogItem } from '@dequanto/txs/receipt/ITxLogItem'; import { Web3Client } from '@dequanto/clients/Web3Client'; import { IBlockchainExplorer } from '@dequanto/explorer/IBlockchainExplorer'; import { SubjectStream } from '@dequanto/class/SubjectStream'; import type { ContractWriter } from '@dequanto/contracts/ContractWriter'; import type { TAbiItem } from '@dequanto/types/TAbi'; import type { TEth } from '@dequanto/models/TEth'; import type { TOverrideReturns } from '@dequanto/utils/types'; import { Etherscan } from '@dequanto/explorer/Etherscan' import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client' export class Ownable extends ContractBase { constructor( public address: TEth.Address = null, public client: Web3Client = di.resolve(EthWeb3Client, ), public explorer: IBlockchainExplorer = di.resolve(Etherscan, ), ) { super(address, client, explorer) } Types: TOwnableTypes; $meta = { "class": "./src/prebuilt/openzeppelin/Ownable.ts" } // 0x8da5cb5b async owner (): Promise<TAddress> { return this.$read(this.$getAbiItem('function', 'owner')); } // 0x715018a6 async renounceOwnership (sender: TSender, ): Promise<TxWriter> { return this.$write(this.$getAbiItem('function', 'renounceOwnership'), sender); } // 0xf2fde38b async transferOwnership (sender: TSender, newOwner: TAddress): Promise<TxWriter> { return this.$write(this.$getAbiItem('function', 'transferOwnership'), sender, newOwner); } $call () { return super.$call() as IOwnableTxCaller; } $signed (): TOverrideReturns<IOwnableTxCaller, Promise<{ signed: TEth.Hex, error?: Error & { data?: { type: string, params } } }>> { return super.$signed() as any; } $data (): IOwnableTxData { return super.$data() as IOwnableTxData; } $gas (): TOverrideReturns<IOwnableTxCaller, Promise<{ gas?: bigint, price?: bigint, error?: Error & { data?: { type: string, params } } }>> { return super.$gas() as any; } onTransaction <TMethod extends keyof TOwnableTypes['Methods']> (method: TMethod, options: Parameters<ContractBase['$onTransaction']>[0]): SubjectStream<{ tx: TEth.Tx block: TEth.Block<TEth.Hex> calldata: { method: TMethod arguments: TOwnableTypes['Methods'][TMethod]['arguments'] } }> { options ??= {}; options.filter ??= {}; options.filter.method = method; return <any> this.$onTransaction(options); } onLog (event: keyof TEvents, cb?: (event: TClientEventsStreamData) => void): ClientEventsStream<TClientEventsStreamData> { return this.$onLog(event, cb); } async getPastLogs <TEventName extends keyof TEvents> ( events: TEventName[] , options?: TEventLogOptions<TEventParams<TEventName>> ): Promise<ITxLogItem<TEventParams<TEventName>, TEventName>[]> async getPastLogs <TEventName extends keyof TEvents> ( event: TEventName , options?: TEventLogOptions<TEventParams<TEventName>> ): Promise<ITxLogItem<TEventParams<TEventName>, TEventName>[]> async getPastLogs (mix: any, options?): Promise<any> { return await super.getPastLogs(mix, options) as any; } onOwnershipTransferred (fn?: (event: TClientEventsStreamData<TEventArguments<'OwnershipTransferred'>>) => void): ClientEventsStream<TClientEventsStreamData<TEventArguments<'OwnershipTransferred'>>> { return this.$onLog('OwnershipTransferred', fn); } extractLogsOwnershipTransferred (tx: TEth.TxReceipt): ITxLogItem<TEventParams<'OwnershipTransferred'>>[] { let abi = this.$getAbiItem('event', 'OwnershipTransferred'); return this.$extractLogs(tx, abi) as any as ITxLogItem<TEventParams<'OwnershipTransferred'>>[]; } async getPastLogsOwnershipTransferred (options?: { fromBlock?: number | Date toBlock?: number | Date params?: { previousOwner?: TAddress,newOwner?: TAddress } }): Promise<ITxLogItem<TEventParams<'OwnershipTransferred'>>[]> { return await this.$getPastLogsParsed('OwnershipTransferred', options) as any; } abi: TAbiItem[] = [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] } type TSender = TAccount & { value?: string | number | bigint } type TEventLogOptions<TParams> = { fromBlock?: number | Date toBlock?: number | Date params?: TParams } export type TOwnableTypes = { Events: { OwnershipTransferred: { outputParams: { previousOwner: TAddress, newOwner: TAddress }, outputArgs: [ previousOwner: TAddress, newOwner: TAddress ], } }, Methods: { owner: { method: "owner" arguments: [ ] } renounceOwnership: { method: "renounceOwnership" arguments: [ ] } transferOwnership: { method: "transferOwnership" arguments: [ newOwner: TAddress ] } } } interface IOwnableTxCaller { renounceOwnership (sender: TSender, ): Promise<{ error?: Error & { data?: { type: string, params } }, result? }> transferOwnership (sender: TSender, newOwner: TAddress): Promise<{ error?: Error & { data?: { type: string, params } }, result? }> } interface IOwnableTxData { renounceOwnership (sender: TSender, ): Promise<TEth.TxLike> transferOwnership (sender: TSender, newOwner: TAddress): Promise<TEth.TxLike> } type TEvents = TOwnableTypes['Events']; type TEventParams<TEventName extends keyof TEvents> = Partial<TEvents[TEventName]['outputParams']>; type TEventArguments<TEventName extends keyof TEvents> = Partial<TEvents[TEventName]['outputArgs']>;