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 1df9d9b
Show file tree
Hide file tree
Showing 2 changed files with 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function SendTransaction(props: SendTransactionProps) {
type="submit"
label={t('account.sendTransaction.send', 'Send')}
onClick={onSubmit}
// disabled={!amount}
primary
/>
</Box>
Expand Down

0 comments on commit 1df9d9b

Please sign in to comment.