Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed NFTokenMinter field validation error in AccountSet Transaction #2201

Merged
merged 10 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/xrpl/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion packages/xrpl/src/models/transactions/accountSet.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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')
Expand Down
10 changes: 10 additions & 0 deletions packages/xrpl/test/models/accountSet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,14 @@ describe('AccountSet', function () {
'AccountSet: invalid TickSize',
)
})

it(`throws w/ invalid NFTokenMinter`, function () {
account.NFTokenMinter = ''

assert.throws(
() => validateAccountSet(account),
ValidationError,
'AccountSet: invalid NFTokenMinter',
)
TusharPardhe marked this conversation as resolved.
Show resolved Hide resolved
})
})