Skip to content

Commit

Permalink
When amount is an empty string, interpret it as 0
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Sep 27, 2022
1 parent 6a0320a commit 1f2a7a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ export function concat(...parts: Uint8Array[]) {
return result
}

/**
* Parse a ROSE (or TEST) amount from a string.
*
* An empty string will be interpreted as 0.
*/
export function parseRoseStringToBaseUnitString(value: string): StringifiedBigInt {
const baseUnitBN = new BigNumber(value).shiftedBy(9) // * 10 ** 9
const baseUnitBN = new BigNumber(value || '0').shiftedBy(9) // * 10 ** 9
if (baseUnitBN.isNaN()) {
throw new Error(`not a number in parseRoseStringToBaseUnitString(${value})`)
}
Expand Down

0 comments on commit 1f2a7a9

Please sign in to comment.