From c4504bc7399bb3b83c1a9a4977310e73630b6a27 Mon Sep 17 00:00:00 2001 From: Luca Nicola Debiasi <63785793+lucanicoladebiasi@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:48:23 +0000 Subject: [PATCH] fix: en_1 recommendations (#1746) --- packages/core/src/transaction/Transaction.ts | 15 +++++++++------ packages/core/src/vcdm/hash/Keccak256.ts | 2 +- .../vechain-private-key-signer.ts | 13 +++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/core/src/transaction/Transaction.ts b/packages/core/src/transaction/Transaction.ts index 3e36b9e13..28f017aae 100644 --- a/packages/core/src/transaction/Transaction.ts +++ b/packages/core/src/transaction/Transaction.ts @@ -284,7 +284,10 @@ class Transaction { */ public get isSigned(): boolean { if (this.signature !== undefined) { - return Transaction.isSignatureValid(this.body, this.signature); + return Transaction.isSignatureLengthValid( + this.body, + this.signature + ); } return false; } @@ -856,13 +859,13 @@ class Transaction { } /** - * Return Returns true if the signature is valid, otherwise false. + * Validates the length of a given signature against the expected length. * - * @param {TransactionBody} body - The transaction body to be checked. - * @param {Uint8Array} signature - The signature to validate. - * @return {boolean} - Returns true if the signature is valid, otherwise false. + * @param {TransactionBody} body - The body of the transaction being validated. + * @param {Uint8Array} signature - The signature to verify the length of. + * @return {boolean} Returns true if the signature length matches the expected length, otherwise false. */ - private static isSignatureValid( + private static isSignatureLengthValid( body: TransactionBody, signature: Uint8Array ): boolean { diff --git a/packages/core/src/vcdm/hash/Keccak256.ts b/packages/core/src/vcdm/hash/Keccak256.ts index 83a75d5b4..62af9ecbf 100644 --- a/packages/core/src/vcdm/hash/Keccak256.ts +++ b/packages/core/src/vcdm/hash/Keccak256.ts @@ -10,7 +10,7 @@ import { HexUInt } from '../HexUInt'; */ class Keccak256 extends HexUInt { /** - * Generates the [SHA-3](https://en.wikipedia.org/wiki/SHA-3) [KECCAK 256](https://keccak.team/keccak.html) hash of the given input. + * Generates the [KECCAK 256](https://eth-hash.readthedocs.io/en/stable/) hash of the given input. * * @param {bigint | number | string | Uint8Array | Hex} exp - The input value to hash. * diff --git a/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts b/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts index 9c1828754..c4483d2af 100644 --- a/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts +++ b/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts @@ -114,13 +114,14 @@ class VeChainPrivateKeySigner extends VeChainAbstractSigner { } /** - * Sends %%transactionToSend%% to the Network. The ``signer.populateTransaction(transactionToSend)`` - * is called first to ensure all necessary properties for the - * transaction to be valid have been populated first. + * Sends a transaction to the blockchain. * - * @param transactionToSend - The transaction to send - * @returns The transaction response - * @throws {JSONRPCInvalidParams} + * @param {TransactionRequestInput} transactionToSend - The transaction object to be sent. + * This includes all the necessary details such as `to`, `value`, `data`, `gasLimit`, etc. + * @return {Promise} A promise that resolves to the transaction hash as a string + * once the transaction is successfully sent. + * @throws {JSONRPCInvalidParams} Throws an error if the provider is not attached + * to the signer, indicating the signer's inability to send the transaction. */ async sendTransaction( transactionToSend: TransactionRequestInput