signature?: string
work?: string
- constructor (account: Account)
- constructor (account: unknown) {
+ constructor (account: string | Account, balance?: bigint | string, previous?: string, representative?: string | Account)
+ constructor (account: unknown, balance: unknown, previous: unknown, representative: unknown) {
+ if (typeof account === 'string') {
+ account = Account.import(account)
+ }
+ if (typeof representative === 'string') {
+ representative = Account.import(representative)
+ }
if (!(account instanceof Account)) {
throw new TypeError('Invalid account')
}
- if (account.balance == null) {
+ balance ??= account.balance
+ previous ??= account.frontier
+ representative ??= account.representative
+ if (typeof balance !== 'bigint' && typeof balance !== 'string') {
throw new TypeError('Account balance is unknown')
}
- if (account.frontier == null) {
+ if (typeof previous !== 'string') {
throw new TypeError('Account frontier is unknown')
}
- if (account.representative == null) {
+ if (!(representative instanceof Account)) {
throw new TypeError('Account representative is unknown')
}
this.account = account
- this.balance = account.balance
- this.previous = account.frontier
- this.representative = account.representative
+ this.balance = BigInt(balance)
+ this.previous = previous
+ this.representative = representative
}
/**