diff --git a/packages/xrpl/HISTORY.md b/packages/xrpl/HISTORY.md index c3191e2a..886a90a5 100644 --- a/packages/xrpl/HISTORY.md +++ b/packages/xrpl/HISTORY.md @@ -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 diff --git a/packages/xrpl/src/models/transactions/accountSet.ts b/packages/xrpl/src/models/transactions/accountSet.ts index 9b57b1c6..8512d9ff 100644 --- a/packages/xrpl/src/models/transactions/accountSet.ts +++ b/packages/xrpl/src/models/transactions/accountSet.ts @@ -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): 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') diff --git a/packages/xrpl/test/models/accountSet.test.ts b/packages/xrpl/test/models/accountSet.test.ts index 3d9ba484..3a072248 100644 --- a/packages/xrpl/test/models/accountSet.test.ts +++ b/packages/xrpl/test/models/accountSet.test.ts @@ -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', + ) + }) })