import { InvalidProviderResponseError , UnimplementedMethodError } from '@liquality/errors' ; import { Address , WalletProvider } from '@liquality/types' ; import { isArray } from 'lodash' ; export default class Wallet implements WalletProvider { client : any ; constructor ( client ) { this . client = client ; } param { number } startingIndex param { number } numAddresses param { boolean } change return { Promise < Address [ ] , InvalidProviderResponseError > } async getAddresses ( startingIndex ? , numAddresses ? , change ? ) { const addresses = await this . client . getMethod ( 'getAddresses' ) ( startingIndex , numAddresses , change ) ; if ( ! isArray ( addresses ) ) { throw new InvalidProviderResponseError ( 'Provider returned an invalid response' ) ; } return addresses ; } param { number } numAddressPerCall return { Promise < Address [ ] , InvalidProviderResponseError > } async getUsedAddresses ( numAddressPerCall ? ) { return this . client . getMethod ( 'getUsedAddresses' ) ( numAddressPerCall ) ; } param { boolean } change param { number } numAddressPerCall return { Promise < Address , InvalidProviderResponseError > } async getUnusedAddress ( change ? , numAddressPerCall ? ) { return this . client . getMethod ( 'getUnusedAddress' ) ( change , numAddressPerCall ) ; } param { ! string } message param { ! string } from return { Promise < string > } async signMessage ( message , from ) { return this . client . getMethod ( 'signMessage' ) ( message , from ) ; } return { Promise < any > } async getConnectedNetwork ( ) { return this . client . getMethod ( 'getConnectedNetwork' ) ( ) ; } return { Promise < Boolean > } async isWalletAvailable ( ) { return this . client . getMethod ( 'isWalletAvailable' ) ( ) ; } return { Promise < Boolean > } get canUpdateFee ( ) : boolean { try { return this . client . getMethod ( 'canUpdateFee' ) ( ) ; } catch ( e ) { if ( ! ( e instanceof UnimplementedMethodError ) ) throw e ; } return true ; } return { Promise < string > } exportPrivateKey ( ) { return this . client . getMethod ( 'exportPrivateKey' ) ( ) ; } }