From 4f93aa800c7c0f1152538cacb42b0ba943c568d2 Mon Sep 17 00:00:00 2001 From: tequ Date: Fri, 6 Sep 2024 10:42:00 +0900 Subject: [PATCH] fix lint error --- packages/xrpl/src/models/transactions/common.ts | 8 +++++++- packages/xrpl/test/wallet/index.test.ts | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/xrpl/src/models/transactions/common.ts b/packages/xrpl/src/models/transactions/common.ts index 8189cf168b..4b86d2717c 100644 --- a/packages/xrpl/src/models/transactions/common.ts +++ b/packages/xrpl/src/models/transactions/common.ts @@ -363,7 +363,13 @@ export function validateTxAgainstCustomDefintions( definitions: XrplDefinitionsBase, ): void { // Validate just transaction type for now, leaving it open for further validations against the custom definition spec. - const txType = tx.TransactionType + const txType = tx.TransactionType + if (typeof txType !== 'string') { + throw new ValidationError( + 'TransactionType field is not specified or not a string', + ) + } + if (!definitions.transactionType[txType]) { throw new ValidationError(`Invalid transaction type: ${txType}`) } diff --git a/packages/xrpl/test/wallet/index.test.ts b/packages/xrpl/test/wallet/index.test.ts index f4c0e60fd1..53a578c68e 100644 --- a/packages/xrpl/test/wallet/index.test.ts +++ b/packages/xrpl/test/wallet/index.test.ts @@ -1211,6 +1211,8 @@ describe('Wallet', function () { value: '1', }, } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- for unknown transaction const result = wallet.sign(tx as any, false, customDefinition) assert.deepEqual(result, { tx_blob: RESPONSE_FIXTURES.signCustomDefinition.signedTransaction, @@ -1242,6 +1244,7 @@ describe('Wallet', function () { }, } assert.throws(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- for unknown transaction wallet.sign(tx as any, false, customDefinition) }, /^Invalid transaction type: SomeUnknown$/u) }) @@ -1251,6 +1254,7 @@ describe('Wallet', function () { rippled.definitions.customDefinition, ) const result = wallet.sign( + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- for unknown transaction REQUEST_FIXTURES.signAsCustomDefinition as any, true, customDefinition,