mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Add validation amount on Remit (#27)
This commit is contained in:
@@ -2,7 +2,7 @@ import { ValidationError } from '../../errors'
|
||||
import { AmountEntry, MintURIToken } from '../common/xahau'
|
||||
import { isHex } from '../utils'
|
||||
|
||||
import { BaseTransaction, validateBaseTransaction } from './common'
|
||||
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
|
||||
|
||||
const MAX_URI_LENGTH = 512
|
||||
const DIGEST_LENGTH = 64
|
||||
@@ -118,6 +118,10 @@ function checkAmounts(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('Remit: invalid Amounts.AmountEntry')
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- ignore
|
||||
if (!isAmount(amount.AmountEntry.Amount)) {
|
||||
throw new ValidationError('Remit: invalid Amounts.AmountEntry.Amount')
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- ignore
|
||||
if (typeof amount.AmountEntry.Amount === 'string') {
|
||||
// eslint-disable-next-line max-depth -- ignore
|
||||
if (seenXrp) {
|
||||
|
||||
@@ -157,6 +157,14 @@ describe('Remit', function () {
|
||||
'Remit: Duplicate amounts are not allowed',
|
||||
)
|
||||
})
|
||||
it(`throws w/ Bad Amount`, function () {
|
||||
remit.Amounts = [{ AmountEntry: { Amount: 1234 } }]
|
||||
assert.throws(
|
||||
() => validateRemit(remit),
|
||||
ValidationError,
|
||||
'Remit: invalid Amounts.AmountEntry.Amount',
|
||||
)
|
||||
})
|
||||
it(`throws w/ Bad URITokenIDs`, function () {
|
||||
remit.URITokenIDs = {}
|
||||
assert.throws(
|
||||
|
||||
Reference in New Issue
Block a user