Skip to content

Commit

Permalink
refactor: extract variables to const
Browse files Browse the repository at this point in the history
Signed-off-by: Ivaylo Nikolov <[email protected]>
  • Loading branch information
ivaylonikolov7 committed Oct 29, 2024
1 parent 1f4f32a commit 9682128
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/transaction/NodeAccountIdSignatureMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ export default class NodeAccountIdSignatureMap extends ObjectMap {
* @param {Uint8Array} signature
*/
addSignature(txId, publicKey, signature) {
if (!this.get(txId)) {
const sigPairMap = this.get(txId);
if (sigPairMap) {
sigPairMap.addSignature(publicKey, signature);

Check warning on line 73 in src/transaction/NodeAccountIdSignatureMap.js

View check run for this annotation

Codecov / codecov/patch

src/transaction/NodeAccountIdSignatureMap.js#L73

Added line #L73 was not covered by tests
} else {
this._set(
txId,
new SignaturePairMap().addSignature(publicKey, signature),
);
} else {
this.get(txId)?.addSignature(publicKey, signature);
}
}
}
10 changes: 4 additions & 6 deletions src/transaction/SignatureMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,18 @@ export default class SignatureMap extends ObjectMap {
* @returns {SignatureMap}
*/
addSignature(nodeId, txId, publicKey, signature) {
if (!this.get(nodeId)) {
this._set(nodeId, new NodeAccountIdSignatureMap());
}
let nodeAccountIdSigdMap = this.get(nodeId);

const nodeAccountIdSigdMap = this.get(nodeId);
if (!nodeAccountIdSigdMap) {
throw new Error("Node Account ID Signature Map not found");
nodeAccountIdSigdMap = new NodeAccountIdSignatureMap();
this._set(nodeId, nodeAccountIdSigdMap);
}

nodeAccountIdSigdMap.addSignature(txId, publicKey, signature);
this._set(nodeId, nodeAccountIdSigdMap);

return this;
}

/**
* @returns {SignaturePairMap[]}
*/
Expand Down

0 comments on commit 9682128

Please sign in to comment.