From f3004b033574af54f18665aa27e9e6661b7c7d99 Mon Sep 17 00:00:00 2001 From: zgrguric Date: Wed, 12 Nov 2025 21:47:43 +0100 Subject: [PATCH 1/2] Fix HookStateScale validation --- .../xahau/src/models/transactions/accountSet.ts | 13 ++++++++++++- packages/xahau/test/models/accountSet.test.ts | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/xahau/src/models/transactions/accountSet.ts b/packages/xahau/src/models/transactions/accountSet.ts index 6c16552394..7b9b942236 100644 --- a/packages/xahau/src/models/transactions/accountSet.ts +++ b/packages/xahau/src/models/transactions/accountSet.ts @@ -173,6 +173,7 @@ export interface AccountSet extends BaseTransaction { const MIN_TICK_SIZE = 3 const MAX_TICK_SIZE = 15 const MAX_HOOK_STATE_SCALE = 16 +const MIN_HOOK_STATE_SCALE = 1 /** * Verify the form and type of an AccountSet at runtime. @@ -233,12 +234,22 @@ export function validateAccountSet(tx: Record): void { } validateOptionalField(tx, 'HookStateScale', isNumber) + if ( typeof tx.HookStateScale === 'number' && tx.HookStateScale > MAX_HOOK_STATE_SCALE ) { throw new ValidationError( - `AccountSet: HookStateScale must be less than ${MAX_HOOK_STATE_SCALE}`, + `AccountSet: HookStateScale must be less than or equal to ${MAX_HOOK_STATE_SCALE}`, + ) + } + + if ( + typeof tx.HookStateScale === 'number' && + tx.HookStateScale < MIN_HOOK_STATE_SCALE + ) { + throw new ValidationError( + `AccountSet: HookStateScale must be greater than or equal to ${MIN_HOOK_STATE_SCALE}`, ) } } diff --git a/packages/xahau/test/models/accountSet.test.ts b/packages/xahau/test/models/accountSet.test.ts index 947615d41d..03ac3efcca 100644 --- a/packages/xahau/test/models/accountSet.test.ts +++ b/packages/xahau/test/models/accountSet.test.ts @@ -182,12 +182,25 @@ describe('AccountSet', function () { assert.throws( () => validateAccountSet(account), ValidationError, - 'AccountSet: HookStateScale must be less than 16', + 'AccountSet: HookStateScale must be less than or equal to 16', ) assert.throws( () => validate(account), ValidationError, - 'AccountSet: HookStateScale must be less than 16', + 'AccountSet: HookStateScale must be less than or equal to 16', ) + + account.HookStateScale = 0 + assert.throws( + () => validateAccountSet(account), + ValidationError, + 'AccountSet: HookStateScale must be greater than or equal to 1', + ) + assert.throws( + () => validate(account), + ValidationError, + 'AccountSet: HookStateScale must be greater than or equal to 1', + ) + }) }) From f5e0ffdb9c525daba92bb49834d2a96774e3169c Mon Sep 17 00:00:00 2001 From: zgrguric Date: Sun, 16 Nov 2025 11:04:15 +0100 Subject: [PATCH 2/2] Fix new line in accountSet test Attempt to fix lint check --- packages/xahau/test/models/accountSet.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/xahau/test/models/accountSet.test.ts b/packages/xahau/test/models/accountSet.test.ts index 03ac3efcca..d12a35dbd6 100644 --- a/packages/xahau/test/models/accountSet.test.ts +++ b/packages/xahau/test/models/accountSet.test.ts @@ -201,6 +201,5 @@ describe('AccountSet', function () { ValidationError, 'AccountSet: HookStateScale must be greater than or equal to 1', ) - }) })