UNPKG

@dolaned/wallet-sdk-ts

Version:

Wallet SDK for the Nexa blockchain

57 lines (47 loc) 1.88 kB
import {AccountIndexes, AccountKeys, AddressKey, Balance} from "../../../models/wallet.entities"; import DefaultAccount from "../models/DefaultAccount"; import bigDecimal from "js-big-decimal"; import {AccountType} from "../../../utils/WalletUtils"; import {PrivateKey} from "libnexa-ts"; import {TransactionEntity} from "../../../models/transaction.entities"; export abstract class BaseAccount { get transactions(): Map<string, TransactionEntity> { return this._transactions; } set transactions(value: Map<string, TransactionEntity>) { this._transactions = value; } protected readonly _bip44Account: number; private _balance?: Balance; private _tokenBalances?: Record<string, Balance> = {}; private _transactions : Map<string, TransactionEntity> = new Map<string, TransactionEntity>() protected constructor(_bip44Account: number) { this._bip44Account = _bip44Account; this._balance = { confirmed: 0, unconfirmed: 0 } this._tokenBalances = {}; } abstract get accountIndexes(): AccountIndexes; abstract get accountKeys(): AccountKeys; abstract getNewChangeAddress(): string; abstract getNewAddress(): string; abstract getAccountStoreKey(): string; abstract getAccountType(): AccountType; abstract loadBalances(): Promise<void>; abstract getKeyFromAddress(address:string): AddressKey; abstract getTransactions(fromHeight?: number, address?:string): Promise<Map<string, TransactionEntity>>; get balance(): Balance { return this._balance!; } set balance(value: Balance) { this._balance = value; } get tokenBalances(): Record<string, Balance> { return this._tokenBalances!; } set tokenBalances(value: Record<string, Balance>) { this._tokenBalances = value; } }