Skip to content

Commit

Permalink
refactor: Cleared some unnecessary comments and changed variable assi…
Browse files Browse the repository at this point in the history
…gment

Signed-off-by: ivaylogarnev-limechain <[email protected]>
  • Loading branch information
ivaylogarnev-limechain committed Aug 27, 2024
1 parent 3e2f070 commit 5adbfda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/transaction/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,12 +876,9 @@ export default class Transaction extends Executable {
if (transaction.sigMap && transaction.sigMap.sigPair) {
transaction.sigMap.sigPair = transaction.sigMap.sigPair.filter(
(sigPair) => {

Check warning on line 878 in src/transaction/Transaction.js

View workflow job for this annotation

GitHub Actions / Integration Tests on Node 16

Do not create function within loops (IE11 compatibility)

Check warning on line 878 in src/transaction/Transaction.js

View workflow job for this annotation

GitHub Actions / Build using Node 16

Do not create function within loops (IE11 compatibility)

Check warning on line 878 in src/transaction/Transaction.js

View workflow job for this annotation

GitHub Actions / Integration Tests on Node 18

Do not create function within loops (IE11 compatibility)

Check warning on line 878 in src/transaction/Transaction.js

View workflow job for this annotation

GitHub Actions / Test using Node 16

Do not create function within loops (IE11 compatibility)

Check warning on line 878 in src/transaction/Transaction.js

View workflow job for this annotation

GitHub Actions / Build using Node 18

Do not create function within loops (IE11 compatibility)
let sigPairPublicKeyHex;
if (sigPair.pubKeyPrefix) {
sigPairPublicKeyHex = hex.encode(
sigPair.pubKeyPrefix,
);
}
let sigPairPublicKeyHex = hex.encode(
sigPair?.pubKeyPrefix || new Uint8Array(),
);

const matchesPublicKey =
sigPairPublicKeyHex === publicKeyHex;
Expand Down Expand Up @@ -944,9 +941,9 @@ export default class Transaction extends Executable {
}

// Clear the internal tracking of signer public keys and other relevant arrays
this._signerPublicKeys.clear(); // Clear the map of signer public keys
this._publicKeys = []; // Clear the array of public keys
this._transactionSigners = []; // Clear the array of transaction signers
this._signerPublicKeys.clear();
this._publicKeys = [];
this._transactionSigners = [];

return this;
}
Expand Down
6 changes: 4 additions & 2 deletions test/unit/Transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe("Transaction", function () {
});
});

describe.only("Transaction removeSignature/clearAllSignatures methods", function () {
describe("Transaction removeSignature/clearAllSignatures methods", function () {
let key1, key2, key3;
let transaction;

Expand Down Expand Up @@ -354,6 +354,7 @@ describe("Transaction", function () {
key3,
);

//Check if the transaction internal tracking of signer public keys is correct
expect(transaction._signerPublicKeys.size).to.equal(3);
expect(transaction._publicKeys.length).to.equal(3);
expect(transaction._transactionSigners.length).to.equal(3);
Expand All @@ -368,6 +369,7 @@ describe("Transaction", function () {
//Check if the transaction is frozen
expect(transaction.isFrozen()).to.be.true;

//Check if the transaction internal tracking of signer public keys is correct
expect(transaction._signerPublicKeys.size).to.equal(2);
expect(transaction._publicKeys.length).to.equal(2);
expect(transaction._transactionSigners.length).to.equal(2);
Expand All @@ -391,7 +393,7 @@ describe("Transaction", function () {
//Check if the transaction is frozen
expect(transaction.isFrozen()).to.be.true;

//Check if the transaction keys are empty
//Check if the transaction internal tracking of signer public keys is cleared
expect(transaction._signerPublicKeys.size).to.equal(0);
expect(transaction._publicKeys.length).to.equal(0);
expect(transaction._transactionSigners.length).to.equal(0);
Expand Down

0 comments on commit 5adbfda

Please sign in to comment.