Skip to content

feat: canton-sdk skeleton + ledger client#108

Open
sadiq1971 wants to merge 7 commits intomainfrom
feat/canton-sdk-init
Open

feat: canton-sdk skeleton + ledger client#108
sadiq1971 wants to merge 7 commits intomainfrom
feat/canton-sdk-init

Conversation

@sadiq1971
Copy link
Member

Closes #93
Apart from the issue also added lint only for this canton-sdk which will be extended later for all directory.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sadiq1971, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the groundwork for a new Go SDK to interact with the Canton ledger. It provides a structured client architecture, robust gRPC communication setup with TLS and OAuth2 authentication, and integrates comprehensive linting to ensure code quality for the new SDK components.

Highlights

  • Canton SDK Skeleton: Introduced the foundational structure for a new Canton SDK in Go, including high-level client and low-level ledger client packages.
  • Ledger Client Implementation: Implemented the core logic for interacting with the Canton Ledger API, managing gRPC connectivity, TLS configuration, and OAuth2 authentication with token caching.
  • Linting Configuration: Added a new .golangci.yml configuration file for golangci-lint specifically for the canton-sdk package, and updated the Makefile to automate linter installation and execution.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .golangci.yml
    • Added a new golangci-lint configuration file with a wide array of linters enabled and specific exclusions for various packages, including the new canton-sdk.
  • Makefile
    • Added a get_lint target to download and install golangci-lint locally.
    • Modified the lint target to depend on get_lint and execute the locally installed linter binary.
  • pkg/canton-sdk/client/client.go
    • Added the main high-level Canton SDK client, Client, which aggregates underlying service clients.
    • Implemented New and NewFromAppConfig constructors for flexible client initialization.
  • pkg/canton-sdk/client/config.go
    • Added the Config structure for the high-level SDK client, encapsulating sub-component configurations.
  • pkg/canton-sdk/client/options.go
    • Added functional options (Option) for configuring the high-level SDK client, allowing custom loggers and HTTP clients.
  • pkg/canton-sdk/ledger/auth.go
    • Added an AuthProvider interface and an OAuthClientCredentialsProvider implementation for OAuth2 client credentials flow, including token caching and refresh logic.
  • pkg/canton-sdk/ledger/client.go
    • Added the low-level Canton Ledger API client, Client, managing gRPC connections and providing access to State, Command, Update, PartyAdmin, and UserAdmin services.
    • Implemented methods for authentication context attachment, ledger end retrieval, and active contract querying.
  • pkg/canton-sdk/ledger/config.go
    • Added configuration structures for the ledger client, including Config, TLSConfig, and AuthConfig.
  • pkg/canton-sdk/ledger/dial.go
    • Added dialOptions function to configure gRPC dial options based on TLS settings and message size.
    • Implemented loadTLSConfig to handle loading TLS certificates and CA files.
  • pkg/canton-sdk/ledger/options.go
    • Added functional options (Option) for configuring the low-level ledger client, including custom loggers, HTTP clients, gRPC dial options, and an optional authentication provider override.
  • pkg/canton-sdk/values/values.go
    • Added a placeholder package for Canton Ledger API value type utilities.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Canton SDK with a ledger client and a golangci-lint configuration. A high-severity security issue was identified in the TLS configuration where certificate verification is disabled by default, making the gRPC connection vulnerable to Man-in-the-Middle attacks. Additionally, there's a critical fix for the Makefile to use a valid golangci-lint version, a bug fix in error handling for gRPC streams, and minor improvements for consistency and deprecated function usage.

@sadiq1971
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the initial skeleton for the Canton SDK and a ledger client, which is a significant and well-structured addition. While the new packages are cleanly laid out and follow good practices, a security audit identified critical issues related to insecure data handling and authentication logic. Specifically, the OAuth2 client credentials flow does not enforce HTTPS for the token endpoint, risking client secret leakage. Authentication failures are handled silently, potentially leading to unintended unauthenticated requests, and the TLS configuration allows disabling certificate verification, posing a MitM risk in production. Additionally, feedback includes suggestions to improve the golangci-lint configuration, fix a potential issue in the Makefile, and a minor point in the Go code for improved robustness. Addressing these security and code quality concerns will significantly enhance the SDK.

@salindne salindne self-requested a review February 12, 2026 16:47
@salindne
Copy link
Contributor

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a well-structured skeleton for the Canton SDK and a ledger client, along with a new linting configuration. The code is generally clean and follows good practices. My review focuses on a few key areas: fixing a critical issue in the Makefile that would prevent the linter from being installed, modernizing the gRPC client creation to use current best practices, and aligning a function's behavior with the Ledger API specification. These changes will improve the correctness and maintainability of the new SDK.

Copy link

@dilankanetuli-source dilankanetuli-source left a comment

Choose a reason for hiding this comment

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

Delete all

Copy link

@dilankanetuli-source dilankanetuli-source left a comment

Choose a reason for hiding this comment

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

All SDK remove and delete

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.

[canton-sdk] Create pkg/canton-sdk foundation (SDK skeleton + ledger core)

3 participants