Skip to content

Commit

Permalink
Added quantity getter to access only string value without symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Jun 20, 2024
1 parent ecf7e9b commit 6242a3f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/chain/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ export class Asset implements ABISerializableObject {
this.units = this.symbol.convertFloat(newValue)
}

toABI(encoder: ABIEncoder) {
this.units.toABI(encoder)
this.symbol.toABI(encoder)
}

toString() {
get quantity(): string {
const digits = this.units.toString().split('')
let negative = false
if (digits[0] === '-') {
Expand All @@ -103,7 +98,16 @@ export class Asset implements ABISerializableObject {
if (negative) {
rv = '-' + rv
}
return rv + ' ' + this.symbol.name
return rv
}

toABI(encoder: ABIEncoder) {
this.units.toABI(encoder)
this.symbol.toABI(encoder)
}

toString() {
return this.quantity + ' ' + this.symbol.name
}

toJSON() {
Expand Down

0 comments on commit 6242a3f

Please sign in to comment.