mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 11:45:49 +00:00
Fixed NFTokenMinter field validation error in AccountSet Transaction (#2201)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user