Skip to content

Add serializers, unify flow for transactions#56

Merged
MastaP merged 6 commits into
revert-bigint-fixesfrom
unify-offline-commit
Jul 3, 2025
Merged

Add serializers, unify flow for transactions#56
MastaP merged 6 commits into
revert-bigint-fixesfrom
unify-offline-commit

Conversation

@martti007

Copy link
Copy Markdown
Collaborator

No description provided.

@martti007
martti007 requested review from MastaP and Copilot June 30, 2025 11:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/toCBOR methods and deserializer classes; update StateTransitionClient to use a new submitCommitment API
  • 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 deserializer but implements ITokenSerializer (which actually performs deserialization). Consider renaming it to tokenSerializer or renaming the interface to ITokenDeserializer to avoid confusion.
import { PredicateType } from '../predicate/PredicateType.js';

src/serializer/token/ITokenSerializer.ts:9

  • [nitpick] This interface is named ITokenSerializer but defines a deserialize method. Renaming it to ITokenDeserializer would 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 reference salt in docs and describe that it maps to the private _salt field for consistency.
   * @param _salt             Salt for current transaction

src/serializer/json/transaction/TransactionJsonSerializer.ts:33

  • Consider adding unit tests for TransactionJsonSerializer.serialize and deserialize to verify that the round-trip between object and JSON works correctly.
  public static serialize(transaction: Transaction<TransactionData>): ITransactionJson<ITransactionDataJson> {

@MastaP

MastaP commented Jul 1, 2025

Copy link
Copy Markdown
Member

@martti007 need to keep Readme in sync

@MastaP
MastaP merged commit 4f208ce into revert-bigint-fixes Jul 3, 2025
1 check passed
@MastaP
MastaP deleted the unify-offline-commit branch July 3, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants