Fixed NFTokenMinter field validation error in AccountSet Transaction (#2201)

This commit is contained in:
Tushar Pardhe
2023-03-01 20:35:48 +00:00
committed by GitHub
parent 5d34746f12
commit 0fa5415d29
3 changed files with 27 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
* Fixed missing reason code in websocket implemntation on websocket disconnect
* Fix timeout error in request manager
* Improved typescript typing
* Fixed empty value condition for NFTokenMinter field in AccountSet transaction
### Added
- `getNFTokenID` lets you get the NFTokenID after minting an NFT

View File

@@ -1,4 +1,7 @@
/* eslint-disable complexity -- Necessary for validateAccountSet */
import { isValidClassicAddress } from 'ripple-address-codec'
import { ValidationError } from '../../errors'
import { BaseTransaction, validateBaseTransaction } from './common'
@@ -164,10 +167,17 @@ const MAX_TICK_SIZE = 15
* @param tx - An AccountSet Transaction.
* @throws When the AccountSet is Malformed.
*/
// eslint-disable-next-line max-lines-per-function -- okay for this method, only a little over
// eslint-disable-next-line max-lines-per-function, max-statements -- okay for this method, only a little over
export function validateAccountSet(tx: Record<string, unknown>): void {
validateBaseTransaction(tx)
if (
tx.NFTokenMinter !== undefined &&
!isValidClassicAddress(String(tx.NFTokenMinter))
) {
throw new ValidationError('AccountSet: invalid NFTokenMinter')
}
if (tx.ClearFlag !== undefined) {
if (typeof tx.ClearFlag !== 'number') {
throw new ValidationError('AccountSet: invalid ClearFlag')

View File

@@ -148,4 +148,19 @@ describe('AccountSet', function () {
'AccountSet: invalid TickSize',
)
})
it(`throws w/ invalid NFTokenMinter`, function () {
account.NFTokenMinter = ''
assert.throws(
() => validateAccountSet(account),
ValidationError,
'AccountSet: invalid NFTokenMinter',
)
assert.throws(
() => validate(account),
ValidationError,
'AccountSet: invalid NFTokenMinter',
)
})
})