Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client/v2): factory #20623

Merged
merged 49 commits into from
Oct 3, 2024
Merged

feat(client/v2): factory #20623

merged 49 commits into from
Oct 3, 2024

Conversation

JulianToledano
Copy link
Contributor

@JulianToledano JulianToledano commented Jun 11, 2024

Description

Ref:
#18580
#19738

Closes:
#19433


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Introduced new methods KeyType and KeyInfo to the keyring interface for retrieving key type and key information.
    • Added functionality for retrieving account details necessary for transaction signing.
    • Implemented a comprehensive transaction handling system, including tools for generating, signing, and broadcasting transactions.
    • Added functions for managing transaction parameters, including gas and fee configurations.
  • Improvements

    • Enhanced keyring initialization by accepting an address codec parameter.
    • Introduced utility functions for handling coin-related operations, including parsing and normalization.
    • Improved transaction flag management with flexible gas settings.
  • Bug Fixes

    • Addressed keyring initialization issues by modifying the sign function.
  • Tests

    • Added various test functions related to transaction preparation, building unsigned transactions, gas calculations, and transaction simulations.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The recent changes enhance the client functionality of a Cosmos SDK-based application. Key modifications include the integration of address codecs into keyring management, the addition of methods for retrieving key type and information, and improvements in transaction handling with new utilities for account and coin operations. The changes also introduce tests to validate these functionalities, and the go.mod file has been updated to streamline dependencies.

Changes

File(s) Change Summary
client/v2/autocli/flag/address.go Modified getKeyringFromCtx to accept an additional address.Codec parameter.
client/v2/autocli/keyring/interface.go, client/v2/autocli/keyring/keyring.go, client/v2/autocli/keyring/no_keyring.go Added KeyType and KeyInfo methods to the Keyring interface and its implementations.
client/v2/go.mod Removed the // indirect directive from github.com/cosmos/go-bip39 dependency.
client/v2/internal/account/retriever.go Introduced account retrieval functionality for transaction signing.
client/v2/internal/coins/util.go, client/v2/internal/coins/util_test.go Added functions for coin operations and corresponding tests for IsZero.
client/v2/internal/grpc/client.go Introduced ClientConn struct implementing gogogrpc.ClientConn interface.
client/v2/offchain/sign.go Updated sign function to include address.Codec in keyring initialization.
client/v2/tx/README.md, client/v2/tx/builder.go, client/v2/tx/flags.go, client/v2/tx/tx.go, client/v2/tx/types.go Documented transaction architecture, enhanced transaction management, and introduced comprehensive transaction handling functionalities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Keyring
    participant TxFactory
    participant Network

    User->>CLI: Request to build transaction
    CLI->>Keyring: Initialize keyring with address codec
    Keyring-->>CLI: Keyring instance
    CLI->>TxFactory: Prepare transaction
    TxFactory->>Network: Retrieve account info
    Network-->>TxFactory: Account details
    TxFactory->>CLI: Unsigned transaction
    CLI->>Keyring: Sign transaction
    Keyring-->>CLI: Signed transaction
    CLI->>Network: Broadcast transaction
    Network-->>CLI: Transaction response
    CLI-->>User: Response details
Loading

Possibly related PRs

  • refactor: decouple comet from modules #21382: The changes in the main PR involve modifications to the getKeyringFromCtx function, which may relate to the overall structure and handling of keyring functionalities, similar to the refactoring efforts in this PR that aim to enhance modularity within the Cosmos SDK.
  • fix(unorderedtx): issues reported in audit #21467: This PR addresses issues related to unordered transactions, which may connect to the changes in the main PR that involve keyring functionalities, as both are part of the broader transaction management system within the SDK.
  • refactor(x/bank/v2): migrate to handlers #21659: The migration to a handler-based architecture in this PR could relate to the changes in the main PR, as both involve enhancing the modularity and maintainability of the codebase, particularly in how transactions and keyring functionalities are managed.
  • feat(auth): support accounts from auth #21688: The introduction of querying accounts from the auth module in this PR may connect to the changes in the main PR, as both involve enhancements to account management and keyring functionalities within the Cosmos SDK.
  • refactor(mempool)!: match server/v2/cometbft and sdk mempool interface #21744: The refactoring of the mempool interface in this PR may relate to the changes in the main PR, as both involve improving transaction handling and management within the SDK.
  • fix(sims): TestAppSimulationAfterImport and legacy proposal handling #21800: The fixes related to simulation and legacy proposal handling in this PR may connect to the changes in the main PR, as both involve ensuring the integrity and functionality of transaction management systems within the Cosmos SDK.

Suggested labels

C:x/accounts, C:x/auth, C:x/bank, C:x/genutil, C:x/feegrant, C:x/staking, C:x/gov, C:x/group, C:x/authz

Suggested reviewers

  • julienrbrt
  • sontrinh16
  • akhilkumarpilli
  • kocubinski
  • facundomedica
  • testinginprod

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the C:CLI label Jun 11, 2024
client/v2/tx/types.go Fixed Show fixed Hide fixed
Copy link
Contributor

@raynaudoe raynaudoe left a comment

Choose a reason for hiding this comment

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

Left a few comments, looks very good 🚀

client/v2/tx/builder.go Outdated Show resolved Hide resolved
client/v2/tx/builder.go Outdated Show resolved Hide resolved
client/v2/tx/config.go Outdated Show resolved Hide resolved
client/v2/tx/config.go Outdated Show resolved Hide resolved
client/v2/tx/config.go Show resolved Hide resolved
client/v2/tx/factory.go Outdated Show resolved Hide resolved
client/v2/tx/factory.go Outdated Show resolved Hide resolved
client/v2/tx/factory.go Outdated Show resolved Hide resolved
client/v2/tx/factory.go Fixed Show fixed Hide fixed
client/v2/tx/types.go Fixed Show fixed Hide fixed
@JulianToledano JulianToledano changed the title [WIP] client/v2: factory and txBuilder feat(client/v2): factory and txBuilder Jun 21, 2024
@JulianToledano JulianToledano marked this pull request as ready for review June 21, 2024 12:59
@JulianToledano JulianToledano requested a review from a team as a code owner June 21, 2024 12:59
@JulianToledano JulianToledano changed the title feat(client/v2): factory and txBuilder feat(client/v2): factory Oct 2, 2024
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

ACK! we can simplify more in follow-ups if needed

@julienrbrt
Copy link
Member

@Mergifyio backport release/v0.52.x

Copy link
Contributor

mergify bot commented Nov 4, 2024

backport release/v0.52.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 4, 2024
Co-authored-by: Julien Robert <julien@rbrt.fr>
(cherry picked from commit c8f4cf7)
@mergify mergify bot mentioned this pull request Nov 4, 2024
12 tasks
julienrbrt pushed a commit that referenced this pull request Nov 4, 2024
Co-authored-by: Julián Toledano <JulianToledano@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants