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(x/wasm): add AllKeys query binding #185

Merged
merged 14 commits into from
Apr 18, 2024

Conversation

r0t0r-r0t0r
Copy link
Contributor

@r0t0r-r0t0r r0t0r-r0t0r commented Apr 16, 2024

Added the ability to call the AllKeys request of the warden module from contracts.

Summary by CodeRabbit

  • New Features

    • Implemented new querying functionalities for WardenProtocol, including the ability to retrieve all keys with pagination.
    • Enhanced message encoding for the Warden protocol within the Cosmos SDK.
  • Refactor

    • Reorganized contract structure and refined function signatures to enhance type specificity and clarity.
    • Introduced new modules and types in the bindings package to support expanded querying capabilities.
  • Documentation

    • Updated import statements and added new query types in documentation to reflect current module usage and functionalities.

Pavel Afanasyev added 6 commits April 15, 2024 09:55
# Conflicts:
#	contracts/contracts/sample/src/bin/schema.rs
#	contracts/contracts/sample/src/contract.rs
#	contracts/contracts/sample/src/msg.rs
#	contracts/packages/bindings/src/bin/schema.rs
#	contracts/packages/bindings/src/lib.rs
#	contracts/packages/bindings/src/msg.rs
#	warden/app/legacy.go
Copy link
Contributor

coderabbitai bot commented Apr 16, 2024

Walkthrough

Walkthrough

The updates across various files introduce new functionalities and reorganize existing ones to enhance querying and handling of keys in the Warden protocol. Changes include new query types, enhanced message encoding for the Cosmos SDK, and structural improvements in contract management. These modifications aim to streamline interactions and data handling within the blockchain framework, focusing on efficiency and scalability.

Changes

Files Changes
.../src/contract.rs, .../src/msg.rs Updated function signatures, added new query functions, and reorganized imports. Introduced a new enum variant for querying.
.../bindings/src/... Added new modules (query, querier, key) and types (WardenProtocolQuery, QueryKeysResponse, WardenQuerier) to support enhanced querying capabilities.
.../schema.rs, .../lib.rs Extended schema exports and exposed new functionalities for external use.
warden/app/... Replaced and added functionalities for message encoding and custom queries in Go, adapting to the Warden protocol enhancements.

Recent Review Details

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 8bbfb86 and caed97e.
Files selected for processing (10)
  • CHANGELOG.md (2 hunks)
  • contracts/README.md (2 hunks)
  • contracts/contracts/sample/README.md (1 hunks)
  • contracts/contracts/sample/src/contract.rs (4 hunks)
  • contracts/contracts/sample/src/msg.rs (2 hunks)
  • contracts/packages/bindings/README.md (1 hunks)
  • contracts/packages/bindings/src/bin/schema.rs (2 hunks)
  • contracts/packages/bindings/src/lib.rs (1 hunks)
  • contracts/packages/bindings/src/querier.rs (1 hunks)
  • contracts/packages/bindings/src/query.rs (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • contracts/contracts/sample/src/contract.rs
  • contracts/contracts/sample/src/msg.rs
  • contracts/packages/bindings/src/bin/schema.rs
  • contracts/packages/bindings/src/lib.rs
  • contracts/packages/bindings/src/querier.rs
  • contracts/packages/bindings/src/query.rs
Additional Context Used
Path-based Instructions (4)
contracts/contracts/sample/README.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

contracts/packages/bindings/README.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

contracts/README.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Additional comments not posted (4)
contracts/contracts/sample/README.md (1)

2-8: The description in the README is clear and effectively communicates the purpose and capabilities of the sample contract. It's good to see the functionalities like NewKeyRequest and AllKeys being highlighted, which aligns with the PR's objectives to enhance Warden Protocol interactions.

contracts/packages/bindings/README.md (1)

2-9: The README clearly outlines the purpose of the bindings and their current capabilities. The reference to the sample contract is helpful for users looking to implement these bindings in their own projects. It's important that the documentation stays up-to-date with the actual functionalities provided.

contracts/README.md (1)

35-94: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [3-94]

The README file is well-structured and provides a thorough guide for developers on how to work with the Warden Protocol. It covers a wide range of necessary topics from building to deploying and interacting with contracts. This will be very useful for new developers entering the project or for those who are setting up their development environment for the first time.

CHANGELOG.md (1)

68-75: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [71-84]

The changelog entries are correctly documented and provide a clear history of the changes, especially the recent additions related to the CosmWasm integration. It's important to maintain this level of detail to ensure that all stakeholders can track the evolution of the project and its features.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Actionable comments outside the diff hunks (2)
CHANGELOG.md (2)

Line range hint 41-41: Remove excessive blank lines to maintain a clean and professional appearance of the changelog.

There are multiple consecutive blank lines which should be reduced to a single blank line to keep the document tidy and consistent.

- 
-
+ 

Line range hint 118-118: Remove excessive blank lines to maintain a clean and professional appearance of the changelog.

There are three consecutive blank lines which should be reduced to a single blank line to keep the document tidy and consistent.

- 
- 
- 
+ 

CHANGELOG.md Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8


You can deploy it by itself, or you can use it as a starting point for your own contract.

Not that this is a preview, so only limited functionality available right now.
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the typo in "Not that this is a preview" to "Note that this is a preview."

- Not that this is a preview, so only limited functionality available right now.
+ Note that this is a preview, so only limited functionality available right now.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Not that this is a preview, so only limited functionality available right now.
Note that this is a preview, so only limited functionality available right now.

This crate provides bindings for the Warden Protocol blockchain core functionality.
You can use it in your own contracts to interact with a Warden Protocol.

Not that this is a preview, so only limited functionality available right now.
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the typo in "Not that this is a preview" to "Note that this is a preview."

- Not that this is a preview, so only limited functionality available right now.
+ Note that this is a preview, so only limited functionality available right now.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Not that this is a preview, so only limited functionality available right now.
Note that this is a preview, so only limited functionality available right now.

Not that this is a preview, so only limited functionality available right now.
You can execute `NewKeyRequest` and query `AllKeys`, but more on the way!

To start using Warden Protocol from the CosmWasm contracts, please refer to sample contract.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the missing article "the" before "sample contract."

- To start using Warden Protocol from the CosmWasm contracts, please refer to sample contract.
+ To start using Warden Protocol from the CosmWasm contracts, please refer to the sample contract.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
To start using Warden Protocol from the CosmWasm contracts, please refer to sample contract.
To start using Warden Protocol from the CosmWasm contracts, please refer to the sample contract.

Ensure the file ends with a newline character to comply with POSIX standards.


## Deploy a Contract

We assume that your have a `wardend` executable's directory in your `$PATH` environment variable in order to perform following steps.
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the typo "your" to "you" in the deployment instructions.

- We assume that your have a `wardend` executable's directory in your `$PATH` environment variable in order to perform following steps.
+ We assume that you have a `wardend` executable's directory in your `$PATH` environment variable in order to perform following steps.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
We assume that your have a `wardend` executable's directory in your `$PATH` environment variable in order to perform following steps.
We assume that you have a `wardend` executable's directory in your `$PATH` environment variable in order to perform following steps.

wardend query wasm list-contract-by-code 100
```

Let's assume it's address is `warden1ghd753shjuwexxywmgs4xz7x2q732vcnkm6h2pyv9s6ah3hylvrqtn83hn`
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct "it's address is" to "its address is" to use the correct possessive form.

- Let's assume it's address is `warden1ghd753shjuwexxywmgs4xz7x2q732vcnkm6h2pyv9s6ah3hylvrqtn83hn`
+ Let's assume its address is `warden1ghd753shjuwexxywmgs4xz7x2q732vcnkm6h2pyv9s6ah3hylvrqtn83hn`

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Let's assume it's address is `warden1ghd753shjuwexxywmgs4xz7x2q732vcnkm6h2pyv9s6ah3hylvrqtn83hn`
Let's assume its address is `warden1ghd753shjuwexxywmgs4xz7x2q732vcnkm6h2pyv9s6ah3hylvrqtn83hn`

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Actionable comments outside the diff hunks (2)
CHANGELOG.md (2)

Line range hint 41-41: Reduce consecutive blank lines to a single blank line to maintain consistency and readability.

-  

Line range hint 57-57: Adjust the indentation of the unordered list to 2 spaces to match the standard used elsewhere in the document.

-    * x/warden can now resolve `warden.space.owners` in Intent definitions into the list of owners of the space
+  * x/warden can now resolve `warden.space.owners` in Intent definitions into the list of owners of the space

CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

contracts/contracts/sample/README.md Show resolved Hide resolved
You can deploy it by itself, or you can use it as a starting point for your own contract.

Note that this is a preview, so only limited functionality available right now.
The sample contract exposes `NewKeyRequest` transaction and `AllKeys` query, but more on the way!
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the spelling mistake in "more on the way!" to ensure clarity and professionalism in documentation.

- but more on the way!
+ but more features are on the way!

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
The sample contract exposes `NewKeyRequest` transaction and `AllKeys` query, but more on the way!
The sample contract exposes `NewKeyRequest` transaction and `AllKeys` query, but more features are on the way!

This crate provides bindings for the Warden Protocol blockchain core functionality.
You can use it in your own contracts to interact with a Warden Protocol.

Note that this is a preview, so only limited functionality available right now.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure the file ends with a newline character to comply with POSIX standards.

Note that this is a preview, so only limited functionality available right now.
You can execute `NewKeyRequest` and query `AllKeys`, but more on the way!

To start using Warden Protocol from the CosmWasm contracts, please refer to the sample contract.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the missing article "the" before "sample contract" to improve readability and grammatical correctness.

- please refer to sample contract.
+ please refer to the sample contract.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
To start using Warden Protocol from the CosmWasm contracts, please refer to the sample contract.
To start using Warden Protocol from the CosmWasm contracts, please refer to the sample contract.

wardend tx wasm execute $contract '{ "new_key_request": { "space_id": 1, "keychain_id": 2, "key_type": 1, "btl": 888, "intent_id": 0 } }' --from alice -y --chain-id warden
```

Note that `space_id` 1 and `keychain_id` 2 should already exist before your transaction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure the file ends with a newline character to comply with POSIX standards.


# Interacting with Contract

You can query it's state, for example, let's list all existing keys:
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the misuse of "it's" to "its" to use the correct possessive form.

- You can query it's state, for example, let's list all existing keys:
+ You can query its state, for example, let's list all existing keys:

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
You can query it's state, for example, let's list all existing keys:
You can query its state, for example, let's list all existing keys:


pub fn query_warden_all_keys(deps: Deps<WardenProtocolQuery>, pagination: PageRequest, derive_wallets: Vec<WalletType>) -> StdResult<AllKeysResponse> {
let querier = WardenQuerier::new(&deps.querier);
let respnose = querier.query_warden_all_keys(pagination, derive_wallets)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let respnose = querier.query_warden_all_keys(pagination, derive_wallets)?;
let response = querier.query_warden_all_keys(pagination, derive_wallets)?;

AllKeys { pagination: PageRequest, derive_wallets: Vec<WalletType> },
}

pub type WalletType = i32;
Copy link
Contributor

Choose a reason for hiding this comment

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

I made some changes so we don't have "wallets" anymore. This particular case has been replaced by "addresses" (in short: WalletType became AddressType).

Please update all the definitions in this file to reflect the new protobufs.

@@ -0,0 +1,47 @@
package wasm_interop
Copy link
Contributor

Choose a reason for hiding this comment

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

is this replacing custom_msg/custom_msg.go? I don't see any file deleted by this PR. Do we need both?


cd ../..

# generate sapmle contract schema
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# generate sapmle contract schema
# generate sample contract schema

## Deploy a Contract

We assume that you have a `wardend` executable's directory in your `$PATH` environment variable in order to perform following steps.
Also, your account should be added to the `wardend`'s keychain. Following commands use `alice` name for such account.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is correct. Anyone can request a key from any keychain.

Also, your account should be added to the `wardend`'s keychain. Following commands use `alice` name for such account.

```shell
wardend tx wasm store artifacts/sample.wasm --from alice -y -b sync --chain-id warden --gas 2000000
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
wardend tx wasm store artifacts/sample.wasm --from alice -y -b sync --chain-id warden --gas 2000000
wardend tx wasm store artifacts/sample.wasm --from alice -y --chain-id warden --gas 2000000

deprecated flag

wardend tx wasm store artifacts/sample.wasm --from alice -y -b sync --chain-id warden --gas 2000000
```

Now you should find an id that system assigned to your code.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Now you should find an id that system assigned to your code.
Now you should find the id that the system assigned to your code.

```

Now you should find an id that system assigned to your code.
One of the methods to do this is simply list all stored code bundles and find the last one.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
One of the methods to do this is simply list all stored code bundles and find the last one.
One of the methods to do this is to list all stored code bundles and find the last one.

let's avoid terms like "simply" as there's nothing simple about deploying a contract 😛
(https://justsimply.dev/)


# Interacting with Contract

You can query it's state, for example, let's list all existing keys:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You can query it's state, for example, let's list all existing keys:
You can query its state, for example, let's list all existing keys:

You can query it's state, for example, let's list all existing keys:

```shell
wardend query wasm contract-state smart $contract '{ "warden_all_keys": {"pagination":{"limit":0,"reverse":false}, "derive_wallets":[]} }'--chain-id warden
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
wardend query wasm contract-state smart $contract '{ "warden_all_keys": {"pagination":{"limit":0,"reverse":false}, "derive_wallets":[]} }'--chain-id warden
wardend query wasm contract-state smart $contract '{ "warden_all_keys": {"pagination":{"limit":0,"reverse":false}, "derive_wallets":[]} }'

no need for chain id in queries

@Pitasi Pitasi self-requested a review April 17, 2024 11:42
Copy link
Contributor

@Pitasi Pitasi left a comment

Choose a reason for hiding this comment

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

utACK

@Pitasi Pitasi changed the title Query warden from wasm feat(x/wasm): add AllKeys query binding Apr 18, 2024
@Pitasi Pitasi merged commit c96080d into warden-protocol:main Apr 18, 2024
5 of 7 checks passed
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.

2 participants