import { ChainEpoch , Cid , KeyInfo , Message , MethodMultisig , NewAddressType , Signature , SignedMessage } from '../Types' ; import { BaseWalletProvider } from './BaseWalletProvider' ; import { MultisigProviderInterface , WalletProviderInterface } from "../ProviderInterfaces" ; import { LotusClient } from '../..' ; export class LotusWalletProvider extends BaseWalletProvider implements WalletProviderInterface , MultisigProviderInterface { constructor ( client ) { super ( client ) ; } param type public async newAddress ( type = NewAddressType . SECP256K1 ) { const ret = await this . client . wallet . new ( type ) ; return ret as string ; } param address public async deleteAddress ( address ) { const ret = await this . client . wallet . delete ( address ) ; return ret as boolean ; } /**
     * get wallet list
     */ public async getAddresses ( ) { const ret = await this . client . wallet . list ( ) ; return ret as string [ ] ; } param address public async hasAddress ( address ) { const ret = await this . client . wallet . has ( address ) ; return ret as boolean ; } param address public async setDefaultAddress ( address ) { const ret = await this . client . wallet . setDefault ( address ) ; return ret as undefined ; } /**
     * get default address
     */ public async getDefaultAddress ( ) { const ret = await this . client . wallet . getDefaultAddress ( ) ; return ret as string ; } param address public async exportPrivateKey ( address ) { const ret = await this . client . wallet . export ( address ) ; return ret as KeyInfo ; } param msg public async sendMessage ( msg ) { const ret = await this . client . mpool . pushMessage ( msg ) ; return ret as SignedMessage ; } param msg public async signMessage ( msg ) { const ret = await this . client . wallet . signMessage ( msg ) ; return ret as SignedMessage ; } param data public async sign ( data ) { const ret = await this . client . wallet . sign ( data ) ; return ret as Signature ; } param data param sign public async verify ( address , data , sign ) { const ret = await this . client . wallet . verify ( address , data , sign ) ; return ret as boolean ; } param requiredNumberOfSenders param approvingAddresses param startEpoch param unlockDuration param initialBalance param senderAddressOfCreateMsg public async msigCreate ( requiredNumberOfSenders , approvingAddresses , startEpoch , unlockDuration , initialBalance , senderAddressOfCreateMsg ) { const ret = await this . client . msig . create ( requiredNumberOfSenders , approvingAddresses , unlockDuration , initialBalance , senderAddressOfCreateMsg , '0' ) ; return ret ; } param address param recipientAddres param value param senderAddressOfProposeMsg public async msigProposeTransfer ( address , recipientAddres , value , senderAddressOfProposeMsg ) { const ret = await this . client . msig . propose ( address , recipientAddres , value , senderAddressOfProposeMsg , 0 , [ ] ) ; return ret ; } param address param proposedTransactionId param signerAddress public async msigApproveTransfer ( address , proposedTransactionId , signerAddress ) { const ret = await this . client . msig . approve ( address , proposedTransactionId , signerAddress ) ; return ret ; } param address param proposedMessageId param proposerAddress param recipientAddres param value param senderAddressOfApproveMsg public async msigApproveTransferTxHash ( address , proposedMessageId , proposerAddress , recipientAddres , value , senderAddressOfApproveMsg ) { const ret = await this . client . msig . approveTxnHash ( address , proposedMessageId , proposerAddress , recipientAddres , value , senderAddressOfApproveMsg , 0 , [ ] ) ; return ret ; } param address param proposedMessageId param proposerAddress param recipientAddres param value param senderAddressOfCancelMsg public async msigCancelTransfer ( address , senderAddressOfCancelMsg , proposedMessageId , recipientAddres , value ) { const ret = await this . client . msig . cancel ( address , proposedMessageId , senderAddressOfCancelMsg , recipientAddres , value , senderAddressOfCancelMsg , 0 , [ ] ) ; return ret ; } param address param senderAddressOfProposeMsg param newSignerAddress param increaseNumberOfRequiredSigners public async msigProposeAddSigner ( address , senderAddressOfProposeMsg , newSignerAddress , increaseNumberOfRequiredSigners ) { const ret = await this . client . msig . addPropose ( address , senderAddressOfProposeMsg , newSignerAddress , increaseNumberOfRequiredSigners ) ; return ret ; } param address param senderAddressOfApproveMsg param proposedMessageId param proposerAddress param newSignerAddress param increaseNumberOfRequiredSigners public async msigApproveAddSigner ( address , senderAddressOfApproveMsg , proposedMessageId , proposerAddress , newSignerAddress , increaseNumberOfRequiredSigners ) { const ret = await this . client . msig . addApprove ( address , senderAddressOfApproveMsg , proposedMessageId , proposerAddress , newSignerAddress , increaseNumberOfRequiredSigners ) ; return ret ; } param address param senderAddressOfCancelMsg param proposedMessageId param newSignerAddress param increaseNumberOfRequiredSigners public async msigCancelAddSigner ( address , senderAddressOfCancelMsg , proposedMessageId , newSignerAddress , increaseNumberOfRequiredSigners ) { const ret = await this . client . msig . addCancel ( address , senderAddressOfCancelMsg , proposedMessageId , newSignerAddress , increaseNumberOfRequiredSigners ) ; return ret ; } param address param senderAddressOfProposeMsg param oldSignerAddress param newSignerAddress public async msigProposeSwapSigner ( address , senderAddressOfProposeMsg , oldSignerAddress , newSignerAddress ) { const ret = await this . client . msig . swapPropose ( address , senderAddressOfProposeMsg , oldSignerAddress , newSignerAddress ) ; return ret ; } param address param senderAddressOfApproveMsg param proposedMessageId param proposerAddress param oldSignerAddress param newSignerAddress public async msigApproveSwapSigner ( address , senderAddressOfApproveMsg , proposedMessageId , proposerAddress , oldSignerAddress , newSignerAddress ) { const ret = await this . client . msig . swapApprove ( address , senderAddressOfApproveMsg , proposedMessageId , proposerAddress , oldSignerAddress , newSignerAddress ) ; return ret ; } param address param senderAddressOfCancelMsg param proposedMessageId param oldSignerAddress param newSignerAddress public async msigCancelSwapSigner ( address , senderAddressOfCancelMsg , proposedMessageId , oldSignerAddress , newSignerAddress ) { const ret = await this . client . msig . swapCancel ( address , senderAddressOfCancelMsg , proposedMessageId , oldSignerAddress , newSignerAddress ) ; return ret ; } param address param senderAddressOfProposeMsg param addressToRemove param decreaseNumberOfRequiredSigners public async msigProposeRemoveSigner ( address , senderAddressOfProposeMsg , addressToRemove , decreaseNumberOfRequiredSigners ) { const ret = await this . client . msig . removeSigner ( address , senderAddressOfProposeMsg , addressToRemove , decreaseNumberOfRequiredSigners ) ; return ret ; } ; param address param senderAddressOfApproveMsg param proposedMessageId param proposerAddress param addressToRemove param decreaseNumberOfRequiredSigners public async msigApproveRemoveSigner ( address , senderAddressOfApproveMsg , proposedMessageId , proposerAddress , addressToRemove , decreaseNumberOfRequiredSigners ) { return undefined as any ; } ; param address param senderAddressOfApproveMsg param proposedMessageId param addressToRemove param decreaseNumberOfRequiredSigners public async msigCancelRemoveSigner ( address , senderAddressOfCancelMsg , proposedMessageId , addressToRemove , decreaseNumberOfRequiredSigners ) { return undefined as any ; } ; param keyInfo public async walletImport ( keyInfo ) { const ret = await this . client . wallet . import ( keyInfo ) ; return ret as string ; } }