Skip to content

Implement newCommit method in Network interface#1057

Open
akash-R-A-J wants to merge 2 commits intohyperledger:mainfrom
akash-R-A-J:akash-R-A-J-patch-1
Open

Implement newCommit method in Network interface#1057
akash-R-A-J wants to merge 2 commits intohyperledger:mainfrom
akash-R-A-J:akash-R-A-J-patch-1

Conversation

@akash-R-A-J
Copy link

This PR implements the newCommit method in the Network interface as requested in issue #195.

Changes Made:

  • Added newCommit(transactionId: string): Commit method to the Network interface
  • Implemented the method in NetworkImpl class to create Commit objects for existing transactions
  • Added necessary imports for Commit and CommitImpl types
  • Included comprehensive JSDoc documentation with usage example

Implementation Details:

The method creates a new CommitImpl instance with the required parameters:

  • client: Gateway client for communication
  • signingIdentity: Identity for signing operations
  • transactionId: The ID of the transaction to create a Commit for
  • channelName: The channel where the transaction exists

This allows users to create Commit objects for transactions that have already been submitted, enabling them to query transaction status and access transaction details.

Testing:

The implementation follows the same pattern as other factory methods in the Network class (e.g., newChaincodeEventsRequest, newBlockEventsRequest) and integrates seamlessly with the existing codebase.

Fixes #195

Added newCommit method to create Commit objects for transactions.

Signed-off-by: Akash Raj <103271263+akash-R-A-J@users.noreply.github.com>
@akash-R-A-J akash-R-A-J requested a review from a team as a code owner December 30, 2025 06:58
@akash-R-A-J
Copy link
Author

Scenario tests are failing for Go 1.25. Investigating integration behavior around commit handling and will push a fix.

- Add gateway import to fabric-protos imports
- Implement #newSignedCommitStatusRequest() helper method
- Implement #newCommitStatusRequest() helper method
- Follow exact pattern from Transaction class (lines 123-135)
- Remove direct channelName parameter from CommitImpl constructor
- Pass signedRequest containing channelId, transactionId, and identity

Fixes TypeScript compilation error TS2353:
  Object literal may only specify known properties,
  and 'channelName' does not exist in type 'Readonly<CommitImplOptions>'

Resolves hyperledger#195

Signed-off-by: Akash Raj <103271263+akash-R-A-J@users.noreply.github.com>
@akash-R-A-J
Copy link
Author

Update:

Since the initial version of this PR, the newCommit implementation has been corrected to align with existing Gateway patterns.

The earlier approach attempted to pass channelName directly into CommitImpl, which does not match the CommitImplOptions contract. The current implementation now constructs and signs a SignedCommitStatusRequest containing channelId and transactionId, following the same pattern used by Transaction.

This resolves the TypeScript compilation error (TS2353) and aligns the implementation with the expected constructor inputs. No API surface changes were introduced beyond what’s described in issue #195.

@akash-R-A-J
Copy link
Author

@bestbeforetoday could you please review this PR?

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.

Create a Commit object for a given transaction ID

1 participant