import { Message , SignedMessage , Cid , MessagePartial , HeadChange , TipSet , BlockHeader , BlockMessages , MessageReceipt , WrappedMessage , ObjStat , TipSetKey , SyncState , MpoolUpdate , PeerID , Address , StorageAsk , Actor , ActorState , NetworkName , SectorOnChainInfo , DeadlineInfo , MinerPower , MinerInfo , Deadline , Partition , BitField , ChainEpoch , Fault , SectorPreCommitInfo , SectorNumber , SectorPreCommitOnChainInfo , SectorExpiration , SectorLocation , MsgLookup , MarketBalance , MarketDeal , DealID , MinerSectors , MsigVesting } from '../Types' ; import BigNumber from 'bignumber.js' ; import { LotusClient } from '../..' ; export class BaseWalletProvider { public client : LotusClient ; constructor ( client ) { this . client = client ; } public async release ( ) { return this . client . release ( ) ; } param address public async getBalance ( address ) { const ret = await this . client . wallet . balance ( address ) ; return ret as string ; } param address public async getNonce ( address ) { const ret = await this . client . mpool . getNonce ( address ) ; return ret as number ; } param msg public async sendSignedMessage ( msg ) { const ret = await this . client . mpool . push ( msg ) ; return ret as Cid ; } param message param nblocksincl public async estimateMessageGasFeeCap ( message , nblocksincl ) { const ret = await this . client . gasEstimate . feeCap ( message , nblocksincl ) ; return ret as string ; } param message public async estimateMessageGasLimit ( message ) { const ret = await this . client . gasEstimate . gasLimit ( message ) ; return ret as number ; } param nblocksincl param sender param gasLimit public async estimateMessageGasPremium ( nblocksincl , sender , gasLimit ) { const ret = await this . client . gasEstimate . gasPremium ( nblocksincl , sender , gasLimit ) ; return ret as string ; } param message public async estimateMessageGas ( message ) { const ret = await this . client . gasEstimate . messageGas ( message ) ; return ret as Message ; } param message public async createMessage ( message ) { let msg = { To : message . To , From : message . From , Value : message . Value ? message . Value : new BigNumber ( 0 ) , GasLimit : message . GasLimit ? message . GasLimit : 0 , GasFeeCap : message . GasFeeCap ? message . GasFeeCap : new BigNumber ( 0 ) , GasPremium : message . GasPremium ? message . GasPremium : new BigNumber ( 0 ) , Method : message . Method ? message . Method : 0 , Params : message . Params ? message . Params : '' , Version : message . Version ? message . Version : 0 , Nonce : message . Nonce ? message . Nonce : await this . getNonce ( message . From ) , } ; if ( msg . GasLimit === 0 ) msg = await this . estimateMessageGas ( msg ) ; return msg ; } param cb returns public async chainNotify ( cb ) { this . client . chain . chainNotify ( cb ) ; } /**
     * returns the current head of the chain
     */ public async getHead ( ) { const ret = await this . client . chain . getHead ( ) ; return ret as TipSet ; } param blockCid public async getBlock ( blockCid ) { const ret = await this . client . chain . getBlock ( blockCid ) ; return ret as BlockHeader ; } param blockCid public async getBlockMessages ( blockCid ) { const ret = await this . client . chain . getBlockMessages ( blockCid ) ; return ret as BlockMessages ; } param blockCid public async getParentReceipts ( blockCid ) { const ret = await this . client . chain . getParentReceipts ( blockCid ) ; return ret as MessageReceipt [ ] ; } param blockCid public async getParentMessages ( blockCid ) { const ret = await this . client . chain . getParentMessages ( blockCid ) ; return ret as WrappedMessage [ ] ; } param epochNumber public async getTipSetByHeight ( epochNumber ) { const ret = await this . client . chain . getTipSetByHeight ( epochNumber ) ; return ret ; } param cid public async readObj ( cid ) { const ret = await this . client . chain . readObj ( cid ) ; return ret as string ; } param cid public async hasObj ( cid ) { const ret = await this . client . chain . hasObj ( cid ) ; return ret as boolean ; } remarks public async statObj ( obj , base ? ) { const stat = await this . client . chain . statObj ( obj , base ) ; return stat ; } param tipSet public async getGenesis ( ) { const genesis = await this . client . chain . getGenesis ( ) ; return genesis ; } param tipSetKey public async getTipSetWeight ( tipSetKey ? ) { const weight = await this . client . chain . getTipSetWeight ( tipSetKey ) ; return weight ; } param messageCid public async getMessage ( messageCid ) { const ret = await this . client . chain . getMessage ( messageCid ) ; return ret as Message ; } param from param to public async getPath ( from , to ) { const path = await this . client . chain . getPath ( from , to ) ; return path ; } /**
     * returns the current status of the lotus sync system.
     */ public async state ( ) { const state = await this . client . sync . state ( ) ; return state ; } param cb public async incomingBlocks ( cb ) { await this . client . sync . incomingBlocks ( cb ) ; } param tipSetKey public async getMpoolPending ( tipSetKey ) { const ret = await this . client . mpool . getMpoolPending ( tipSetKey ) ; return ret ; } param tipSetKey param ticketQuality public async sub ( cb ) { await this . client . mpool . sub ( cb ) ; } param peerId param miner public async queryAsk ( peerId , miner ) { const queryAsk = await this . client . client . queryAsk ( peerId , miner ) ; return queryAsk ; } param address param tipSetKey public async getActor ( address , tipSetKey ? ) { const data = await this . client . state . getActor ( address , tipSetKey ) ; return data as Actor ; } param address param tipSetKey public async readState ( address , tipSetKey ? ) { const data = await this . client . state . readState ( address , tipSetKey ) ; return data as ActorState ; } param filter param tipSetKey param toHeight public async listMessages ( filter , tipSetKey ? , toHeight ? ) { const messages = await this . client . state . listMessages ( filter , tipSetKey , toHeight ) ; return messages ? messages : [ ] ; } /**
     * returns the name of the network the node is synced to
     */ public async networkName ( ) { const network = await this . client . state . networkName ( ) ; return network ; } param address param tipSetKey public async minerSectors ( address , tipSetKey ? ) { const sectorsInfo = await this . client . state . minerSectors ( address , tipSetKey ) ; return sectorsInfo ; } param address param tipSetKey public async minerActiveSectors ( address , tipSetKey ? ) { const activeSectors = await this . minerActiveSectors ( address , tipSetKey ) ; return activeSectors ; } param address param tipSetKey public async minerProvingDeadline ( address , tipSetKey ? ) { const provingDeadline = await this . client . state . minerProvingDeadline ( address , tipSetKey ) ; return provingDeadline ; } param address param tipSetKey public async minerPower ( address , tipSetKey ? ) { const power = await this . client . state . minerPower ( address , tipSetKey ) ; return power ; } param address param tipSetKey public async minerInfo ( address , tipSetKey ? ) { const minerInfo = await this . client . state . minerInfo ( address , tipSetKey ) ; return minerInfo ; } param address param tipSetKey public async minerDeadlines ( address , tipSetKey ? ) { const minerDeadlines = await this . client . state . minerDeadlines ( address , tipSetKey ) ; return minerDeadlines ; } param address param idx param tipSetKey public async minerPartitions ( address , idx ? , tipSetKey ? ) { const minerPartitions = await this . client . state . minerPartitions ( address , idx , tipSetKey ) ; return minerPartitions ; } param address param tipSetKey public async minerFaults ( address , tipSetKey ? ) { const minerFaults = await this . client . state . minerFaults ( address , tipSetKey ) ; return minerFaults ; } param epoch param tipSetKey public async allMinerFaults ( epoch , tipSetKey ? ) { const allFaults = await this . client . state . allMinerFaults ( epoch , tipSetKey ) ; return allFaults ; } param address param tipSetKey public async minerRecoveries ( address , tipSetKey ? ) { const recoveries = await this . client . state . minerRecoveries ( address , tipSetKey ) ; return recoveries ; } param address param sectorPreCommitInfo param tipSetKey public async minerPreCommitDepositForPower ( address , sectorPreCommitInfo , tipSetKey ? ) { const deposit = await this . client . state . minerPreCommitDepositForPower ( address , sectorPreCommitInfo , tipSetKey ) ; return deposit ; } param address param sectorPreCommitInfo param tipSetKey public async minerInitialPledgeCollateral ( address , sectorPreCommitInfo , tipSetKey ? ) { const deposit = await this . client . state . minerInitialPledgeCollateral ( address , sectorPreCommitInfo , tipSetKey ) ; return deposit ; } param address param tipSetKey public async minerAvailableBalance ( address , tipSetKey ? ) { const balance = await this . client . state . minerAvailableBalance ( address , tipSetKey ) ; return balance ; } param address param sector param tipSetKey public async sectorPreCommitInfo ( address , sector , tipSetKey ? ) { const preCommitInfo = await this . client . state . sectorPreCommitInfo ( address , sector , tipSetKey ) ; return preCommitInfo ; } param address param sector param tipSetKey remarks public async sectorGetInfo ( address , sector , tipSetKey ? ) { const sectorInfo = await this . client . state . sectorGetInfo ( address , sector , tipSetKey ) ; return sectorInfo ; } param address param sector param tipSetKey public async sectorExpiration ( address , sector , tipSetKey ? ) { const sectorExpiration = await this . client . state . sectorExpiration ( address , sector , tipSetKey ) ; return sectorExpiration ; } param address param sector param tipSetKey public async sectorPartition ( address , sector , tipSetKey ? ) { const sectorLocation = await this . client . state . sectorPartition ( address , sector , tipSetKey ) ; return sectorLocation ; } param cid public async searchMsg ( cid ) { const lookup = await this . client . state . searchMsg ( cid ) ; return lookup ; } param tipSetKey public async listMiners ( tipSetKey ? ) { const miners = await this . client . state . listMiners ( tipSetKey ) ; return miners ; } param tipSetKey public async listActors ( tipSetKey ? ) { const miners = await this . client . state . listActors ( tipSetKey ) ; return miners ; } param address param tipSetKey public async marketBalance ( address , tipSetKey ? ) { const marketBalance = await this . client . state . marketBalance ( address , tipSetKey ) ; return marketBalance ; } param tipSetKey public async marketParticipants ( tipSetKey ? ) { const marketBalanceMap = await this . client . state . marketParticipants ( tipSetKey ) ; return marketBalanceMap ; } param tipSetKey public async marketDeals ( tipSetKey ? ) { const marketDealsMap = await this . client . state . marketDeals ( tipSetKey ) ; return marketDealsMap ; } param dealId param tipSetKey public async marketStorageDeal ( dealId , tipSetKey ? ) { const marketDeal = await this . client . state . marketStorageDeal ( dealId , tipSetKey ) ; return marketDeal ; } param address param tipSetKey public async lookupId ( address , tipSetKey ? ) { const id = await this . client . state . lookupId ( address , tipSetKey ) ; return id ; } param address param tipSetKey public async accountKey ( address , tipSetKey ? ) { const key = await this . client . state . accountKey ( address , tipSetKey ) ; return key ; } param cid1 param cid2 public async changedActors ( cid1 ? , cid2 ? ) { const actors = await this . client . state . changedActors ( cid1 , cid2 ) ; return actors ; } param cid param tipSetKey public async getReceipt ( cid , tipSetKey ? ) { const receipt = await this . client . state . getReceipt ( cid , tipSetKey ) ; return receipt ; } param address param tipSetKey public async minerSectorCount ( address , tipSetKey ? ) { const sectors = await this . client . state . minerSectorCount ( address , tipSetKey ) ; return sectors ; } param address param tipSetKey public async msigGetVestingSchedule ( address , tipSetKey ) { const schedule = await this . client . msig . getVestingSchedule ( address , tipSetKey ) ; return schedule ; } param address param tipSetKey public async msigGetAvailableBalance ( address , tipSetKey ) { const ret = await this . client . msig . getAvailableBalance ( address , tipSetKey ) ; return ret ; } param address param startEpoch param endEpoch public async msigGetVested ( address , startEpoch , endEpoch ) { const ret = await this . client . msig . getVested ( address , startEpoch , endEpoch ) ; return ret ; } }