-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor SignatureMap for Multi-Transaction Support in _signedT…
…ransactions (#2601) * feat: init commit for signing of tx changes Signed-off-by: Ivaylo Nikolov <[email protected]> * wip: working stage for tx tool Signed-off-by: Ivaylo Nikolov <[email protected]> * fix: circular dependancy Signed-off-by: Ivaylo Nikolov <[email protected]> * refactor: remove repeating check Signed-off-by: Ivaylo Nikolov <[email protected]> * refactor: add error Signed-off-by: Ivaylo Nikolov <[email protected]> * style: lines Signed-off-by: Ivaylo Nikolov <[email protected]> * feat: add flattener for signatures Signed-off-by: Ivaylo Nikolov <[email protected]> * refacotr: sigmap exports and returns Signed-off-by: Ivaylo Nikolov <[email protected]> * refactor: sigpairmap exports and returns Signed-off-by: Ivaylo Nikolov <[email protected]> * fix: node account id sig map didnt work with empty tx ids Signed-off-by: Ivaylo Nikolov <[email protected]> * fix: freeze if not frozen Signed-off-by: Ivaylo Nikolov <[email protected]> * test: fix tests Signed-off-by: Ivaylo Nikolov <[email protected]> * feat: export SignatureMap Signed-off-by: Svetoslav Borislavov <[email protected]> * style: remove empty lines Signed-off-by: Ivaylo Nikolov <[email protected]> * style: equals instead of equal Signed-off-by: Ivaylo Nikolov <[email protected]> * fix: incomplete file append with multiple node account ids Signed-off-by: Svetoslav Borislavov <[email protected]> * fix: max chunks from protobuf Signed-off-by: Svetoslav Borislavov <[email protected]> * refactor: code comments and jsdocs Signed-off-by: Ivaylo Nikolov <[email protected]> * refactor: extract to 3 constants Signed-off-by: Ivaylo Nikolov <[email protected]> * test: check if sigs are passed correctly Signed-off-by: Ivaylo Nikolov <[email protected]> * refactor: extract variables to const Signed-off-by: Ivaylo Nikolov <[email protected]> --------- Signed-off-by: Ivaylo Nikolov <[email protected]> Signed-off-by: Svetoslav Borislavov <[email protected]> Co-authored-by: Svetoslav Borislavov <[email protected]>
- Loading branch information
1 parent
5d11526
commit 0d36abe
Showing
14 changed files
with
525 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import ObjectMap from "../ObjectMap.js"; | ||
import PublicKey from "../PublicKey.js"; | ||
|
||
/** | ||
* @augments {ObjectMap<PublicKey, Uint8Array>} | ||
*/ | ||
export default class SignaturePairMap extends ObjectMap { | ||
constructor() { | ||
super((s) => PublicKey.fromString(s)); | ||
} | ||
|
||
/** | ||
* This function is used to create a SignaturePairMap from an already built transaction. | ||
* @param {import("@hashgraph/proto").proto.ISignatureMap} sigMap | ||
* @returns {SignaturePairMap} | ||
*/ | ||
static _fromTransactionSigMap(sigMap) { | ||
const signatures = new SignaturePairMap(); | ||
|
||
const sigPairs = sigMap.sigPair != null ? sigMap.sigPair : []; | ||
|
||
for (const sigPair of sigPairs) { | ||
if (sigPair.pubKeyPrefix == null) { | ||
continue; | ||
} | ||
|
||
if (sigPair.ed25519 != null) { | ||
signatures._set( | ||
PublicKey.fromBytesED25519(sigPair.pubKeyPrefix), | ||
sigPair.ed25519, | ||
); | ||
} else if (sigPair.ECDSASecp256k1 != null) { | ||
signatures._set( | ||
PublicKey.fromBytesECDSA(sigPair.pubKeyPrefix), | ||
sigPair.ECDSASecp256k1, | ||
); | ||
} | ||
} | ||
|
||
return signatures; | ||
} | ||
|
||
/** | ||
* | ||
* @param {PublicKey} pubKey | ||
* @param {Uint8Array} signature | ||
* @returns {SignaturePairMap} | ||
*/ | ||
addSignature(pubKey, signature) { | ||
this._set(pubKey, signature); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.