import { BN , units } from "@zilliqa-js/util" ; const DECIMALS = 10 ** 6 ; interface WalletFields { address ? : string ; privateKey ? : string ; balance ? : number ; nonce ? : number ; } export class Wallet { address : string ; privateKey : string ; balance : number ; nonce : number ; constructor ( fields ? ) { if ( ! fields ) { return ; } this . address = fields . address || "" ; this . privateKey = fields . privateKey || "" ; this . balance = fields . balance || 0 ; this . nonce = fields . nonce || 0 ; } getZilBalance ( ) { const inQa = new BN ( this . balance ) ; const inZil = units . fromQa ( inQa , units . Units . Zil ) ; return Math . round ( parseFloat ( inZil ) * DECIMALS ) / DECIMALS ; } }