/* Copyright 2021 The caver-js Authors This file is part of the caver-js library. The caver-js library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The caver-js library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the caver-js. If not, see . */ import BN = require('bn.js') import BigNumber from 'bignumber.js' import { AccountKey } from '../../caver-account/src' import { Block, Header, BlockNumber, Rewards, ChainConfig, GovernanceItems, StakingInformation, TransactionReceipt, BlockWithConsensusInfo, TransactionForRPC, PromiEvent, TransactionForSendRPC, RLPEncodedTransaction, DecodedAnchoringTransaction, Log, LogsOptions, LogObject, CallObject, FeeHistoryResult, } from '../../caver-core/src' import { Transaction, FeeDelegatedTransaction, AccessListResult } from '../../caver-transaction/src' export interface AccountForRPC { accType: number account: { nonce: number balance: string humanReadable: boolean key: AccountKeyForRPC } } export interface PublicKeyForRPC { x: string y: string } export interface WeightedPublicKeyForRPC { weight: number key: PublicKeyForRPC } export interface WeightedMultiSigKeyForRPC { threshold: number keys: WeightedPublicKeyForRPC[] } export interface AccountKeyForRPC { keyType?: number nonce?: number key?: PublicKeyForRPC | WeightedMultiSigKeyForRPC | AccountKeyForRPC | AccountKeyForRPC[] } export interface Syncing { startingBlock: number currentBlock: number highestBlock: number knownStates: number pulledStates: number } export interface KlaytnCall { getAccountKey: Klay['getAccountKey'] getChainId: Klay['getChainId'] getGasPrice: Klay['getGasPrice'] getHeaderByNumber: Klay['getHeaderByNumber'] getTransactionByHash: Klay['getTransactionByHash'] getTransactionCount: Klay['getTransactionCount'] getMaxPriorityFeePerGas: Klay['getMaxPriorityFeePerGas'] } export class Klay { constructor(...args: any[]) klaytnCall: KlaytnCall accountCreated(address: string, callback?: (error: Error, result: boolean) => void): Promise accountCreated(address: string, blockNumber: BlockNumber, callback?: (error: Error, result: boolean) => void): Promise getAccounts(callback?: (error: Error, result: string[]) => void): Promise encodeAccountKey(accountKey: AccountKeyForRPC | AccountKey, callback?: (error: Error, result: string) => void): Promise decodeAccountKey(encodedAccountKey: string, callback?: (error: Error, result: AccountKeyForRPC) => void): Promise getAccount(address: string, callback?: (error: Error, result: AccountForRPC) => void): Promise getAccount(address: string, blockNumber: BlockNumber, callback?: (error: Error, result: AccountForRPC) => void): Promise getAccountKey(address: string, callback?: (error: Error, result: AccountKeyForRPC) => void): Promise getAccountKey( address: string, blockNumber: BlockNumber, callback?: (error: Error, result: AccountKeyForRPC) => void ): Promise getBalance(address: string, callback?: (error: Error, result: string) => void): Promise getBalance(address: string, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise getCode(address: string, callback?: (error: Error, result: string) => void): Promise getCode(address: string, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise getTransactionCount(address: string, callback?: (error: Error, result: string) => void): Promise getTransactionCount(address: string, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise isContractAccount(address: string, callback?: (error: Error, result: boolean) => void): Promise isContractAccount(address: string, blockNumber: BlockNumber, callback?: (error: Error, result: boolean) => void): Promise sign(address: string, message: string, callback?: (error: Error, result: string) => void): Promise sign(address: string, message: string, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise getBlockNumber(callback?: (error: Error, result: string) => void): Promise getBlock(blockNumber: BlockNumber, callback?: (error: Error, result: Block) => void): Promise getBlock(blockNumber: BlockNumber, returnTransactionObjects: boolean, callback?: (error: Error, result: Block) => void): Promise getBlockByNumber( blockNumber: 'genesis' | 'latest' | number | BN | BigNumber, callback?: (error: Error, result: Block) => void ): Promise getBlockByNumber( blockNumber: 'genesis' | 'latest' | number | BN | BigNumber, returnTransactionObjects: boolean, callback?: (error: Error, result: Block) => void ): Promise getBlockByHash(blockHash: string, callback?: (error: Error, result: Block) => void): Promise getBlockByHash(blockHash: string, returnTransactionObjects: boolean, callback?: (error: Error, result: Block) => void): Promise getHeader(blockNumber: BlockNumber, callback?: (error: Error, result: Header) => void): Promise
getHeaderByNumber(blockNumber: BlockNumber, callback?: (error: Error, result: Header) => void): Promise
getHeaderByHash(blockHash: string, callback?: (error: Error, result: Header) => void): Promise
getRewards(blockNumber: BlockNumber, callback?: (error: Error, result: Header) => void): Promise getParams(callback?: (error: Error, result: GovernanceItems) => void): Promise getParams(blockNumber: BlockNumber, callback?: (error: Error, result: GovernanceItems) => void): Promise getChainConfig(callback?: (error: Error, result: ChainConfig) => void): Promise getChainConfig(blockNumber: BlockNumber, callback?: (error: Error, result: ChainConfig) => void): Promise getChainConfigAt(callback?: (error: Error, result: ChainConfig) => void): Promise // TODO-caver getChainConfigAt will be deleted in v1.11.0 getChainConfigAt(blockNumber: BlockNumber, callback?: (error: Error, result: ChainConfig) => void): Promise getNodeAddress(callback?: (error: Error, result: string) => void): Promise // TODO-caver getGovParamsAt will be deleted in v1.11.0 getGovParamsAt(callback?: (error: Error, result: GovernanceItems) => void): Promise getGovParamsAt(blockNumber: BlockNumber, callback?: (error: Error, result: GovernanceItems) => void): Promise getStakingInfo(callback?: (error: Error, result: StakingInformation) => void): Promise getStakingInfo(blockNumber: BlockNumber, callback?: (error: Error, result: StakingInformation) => void): Promise getBlockReceipts(blockHash: string, callback?: (error: Error, result: TransactionReceipt[]) => void): Promise getBlockTransactionCount(blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise getBlockTransactionCountByNumber( blockNumber: 'genesis' | 'latest' | number | BN | BigNumber, callback?: (error: Error, result: string) => void ): Promise getBlockTransactionCountByHash(blockHash: string, callback?: (error: Error, result: string) => void): Promise getBlockWithConsensusInfo( blockNumber: BlockNumber, callback?: (error: Error, result: BlockWithConsensusInfo) => void ): Promise getBlockWithConsensusInfoByNumber( blockNumber: 'genesis' | 'latest' | number | BN | BigNumber, callback?: (error: Error, result: BlockWithConsensusInfo) => void ): Promise getBlockWithConsensusInfoByHash( blockHash: string, callback?: (error: Error, result: BlockWithConsensusInfo) => void ): Promise getCommittee(blockNumber?: BlockNumber, callback?: (error: Error, result: string[]) => void): Promise getCommitteeSize(blockNumber?: BlockNumber, callback?: (error: Error, result: number) => void): Promise getCouncil(blockNumber?: BlockNumber, callback?: (error: Error, result: string[]) => void): Promise getCouncilSize(blockNumber?: BlockNumber, callback?: (error: Error, result: number) => void): Promise getStorageAt(address: string, position: number, callback?: (error: Error, result: string) => void): Promise getStorageAt( address: string, position: number, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void ): Promise isMining(callback?: (error: Error, result: boolean) => void): Promise isSyncing(callback?: (error: Error, result: Syncing | boolean) => void): Promise call(callObject: CallObject, callback?: (error: Error, result: string) => void): Promise call(callObject: CallObject, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise estimateGas(callObject: CallObject, callback?: (error: Error, result: string) => void): Promise estimateGas(callObject: CallObject, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise estimateComputationCost(callObject: CallObject, callback?: (error: Error, result: string) => void): Promise estimateComputationCost( callObject: CallObject, blockNumber: BlockNumber, callback?: (error: Error, result: string) => void ): Promise getTransactionFromBlock( blockNumber: BlockNumber, index: number, callback?: (error: Error, result: TransactionForRPC) => void ): Promise getTransactionByBlockNumberAndIndex( blockNumber: 'genesis' | 'latest' | number | BN | BigNumber, index: number, callback?: (error: Error, result: TransactionForRPC) => void ): Promise getTransactionByBlockHashAndIndex( blockHash: string, index: number, callback?: (error: Error, result: TransactionForRPC) => void ): Promise getTransaction( transactionHash: string, callback?: (error: Error, result: TransactionForRPC | null) => void ): Promise getTransactionByHash( transactionHash: string, callback?: (error: Error, result: TransactionForRPC | null) => void ): Promise getTransactionBySenderTxHash( senderTxHash: string, callback?: (error: Error, result: TransactionForRPC | null) => void ): Promise getTransactionReceipt( transactionHash: string, callback?: (error: Error, result: TransactionReceipt | null) => void ): Promise getTransactionReceiptBySenderTxHash( senderTxHash: string, callback?: (error: Error, result: TransactionReceipt | null) => void ): Promise submitTransaction( signedTransaction: string | Transaction, callback?: (error: Error, hash: string) => void ): PromiEvent sendRawTransaction( signedTransaction: string | Transaction, callback?: (error: Error, hash: string) => void ): PromiEvent sendTransaction( transaction: TransactionForSendRPC | Transaction, callback?: (error: Error, hash: string) => void ): PromiEvent sendTransactionAsFeePayer( transaction: TransactionForSendRPC | Transaction, callback?: (error: Error, hash: string) => void ): PromiEvent signTransaction( transaction: TransactionForSendRPC | Transaction, callback?: (error: Error, result: RLPEncodedTransaction) => void ): Promise signTransactionAsFeePayer( transaction: TransactionForSendRPC | FeeDelegatedTransaction, callback?: (error: Error, result: RLPEncodedTransaction) => void ): Promise getDecodedAnchoringTransactionByHash( transactionHash: string, callback?: (error: Error, result: DecodedAnchoringTransaction) => void ): Promise getFeeHistory( blockCount: string | number | BN | BigNumber, latestBlock: BlockNumber, rewardPercentiles: number[], callback?: (error: Error, result: FeeHistoryResult) => void ): Promise getMaxPriorityFeePerGas( callback?: (error: Error, result: string) => void ): Promise getUpperBoundGasPrice( callback?: (error: Error, result: string) => void ): Promise getLowerBoundGasPrice( callback?: (error: Error, result: string) => void ): Promise createAccessList( callObject: CallObject, blockNumber: BlockNumber, callback?: (error: Error, result: AccessListResult) => void ): Promise getChainId(callback?: (error: Error, result: string) => void): Promise getClientVersion(callback?: (error: Error, result: string) => void): Promise getGasPrice(callback?: (error: Error, result: string) => void): Promise getGasPriceAt(callback?: (error: Error, result: string) => void): Promise getGasPriceAt(blockNumber: BlockNumber, callback?: (error: Error, result: string) => void): Promise isParallelDBWrite(callback?: (error: Error, result: boolean) => void): Promise isSenderTxHashIndexingEnabled(callback?: (error: Error, result: boolean) => void): Promise getProtocolVersion(callback?: (error: Error, result: string) => void): Promise getRewardbase(callback?: (error: Error, result: string) => void): Promise getFilterChanges(filterId: string, callback?: (error: Error, result: LogObject[]) => void): Promise getFilterLogs(filterId: string, callback?: (error: Error, result: LogObject[]) => void): Promise getLogs(options: LogsOptions, callback?: (error: Error, result: Log[]) => void): Promise newBlockFilter(callback?: (error: Error, result: string) => void): Promise newFilter(options: LogsOptions, callback?: (error: Error, result: string) => void): Promise newPendingTransactionFilter(callback?: (error: Error, result: string) => void): Promise uninstallFilter(filterId: string, callback?: (error: Error, result: boolean) => void): Promise sha3(data: string, callback?: (error: Error, result: string) => void): Promise }