Add serializers, unify flow for transactions#56
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR replaces inline serialization methods with dedicated JSON/CBOR serializers for transactions, commitments, and tokens, and updates the client and tests to use a unified commitment workflow.
- Introduce
TransactionJsonSerializer,TransactionDataJsonSerializer,CommitmentJsonSerializer,TokenJsonSerializer, and their CBOR counterparts - Remove old
toJSON/toCBORmethods and deserializer classes; updateStateTransitionClientto use a newsubmitCommitmentAPI - Update tests to use new serializers and assert on
SubmitCommitmentStatus
Reviewed Changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/token/CommonTestFlow.ts | Swap out old offline client flow for new Commitment and serializers |
| tests/MintTokenUtils.ts | Change submitTransaction to Commitment.create + submitCommitment |
| src/transaction/TransactionData.ts | Remove embedded JSON/CBOR methods; expose getters; update toString |
| src/transaction/Transaction.ts | Drop inline serialization; rely on external serializers |
| src/transaction/Commitment.ts | Add Commitment.create factory and import SigningService |
| src/token/TokenFactory.ts | Switch from ITokenDeserializer to ITokenSerializer |
| src/token/Token.ts | Delegate .toJSON/.toCBOR to TokenJsonSerializer/TokenCborSerializer |
| src/serializer/json/... | Add JSON serializers for transactions, commitments, and tokens |
| src/serializer/cbor/... | Add CBOR serializers for transactions, commitments, and tokens |
| src/StateTransitionClient.ts | Replace old submitTransaction with submitCommitment workflows |
| src/OfflineStateTransitionClient.ts | Remove; offline flow moved into tests and new serializers |
Comments suppressed due to low confidence (4)
src/token/TokenFactory.ts:12
- [nitpick] The constructor parameter is named
deserializerbut implementsITokenSerializer(which actually performs deserialization). Consider renaming it totokenSerializeror renaming the interface toITokenDeserializerto avoid confusion.
import { PredicateType } from '../predicate/PredicateType.js';
src/serializer/token/ITokenSerializer.ts:9
- [nitpick] This interface is named
ITokenSerializerbut defines adeserializemethod. Renaming it toITokenDeserializerwould better reflect its responsibility and improve API clarity.
export interface ITokenSerializer {
src/transaction/TransactionData.ts:19
- [nitpick] The JSDoc parameter uses
_salt, which matches the private field but is unusual in public docs. You may want to referencesaltin docs and describe that it maps to the private_saltfield for consistency.
* @param _salt Salt for current transaction
src/serializer/json/transaction/TransactionJsonSerializer.ts:33
- Consider adding unit tests for
TransactionJsonSerializer.serializeanddeserializeto verify that the round-trip between object and JSON works correctly.
public static serialize(transaction: Transaction<TransactionData>): ITransactionJson<ITransactionDataJson> {
Member
|
@martti007 need to keep Readme in sync |
MastaP
approved these changes
Jul 3, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.