-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix schema generation for generic types #505
Conversation
WalkthroughThe recent changes emphasize enforcing exact versions for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Contract
participant Schema
User->>Contract: Interact with contract
Contract->>Schema: Validate input data
Schema-->>Contract: Return valid status
Contract->>User: Send response
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
5fecc07
to
7a29ab4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (6)
modules/resources/casper_contract_schemas/mock_cep78_transfer_filter_schema.json (2)
13-14
: Consider adding comments for empty sections.The types and errors sections are empty. Consider adding a comment to indicate that these sections are intentionally left empty.
"types": [], + // No types defined yet "errors": [], + // No errors defined yet
15-40
: Add descriptions for entry points.The
description
fields for the entry points are empty. Consider adding meaningful descriptions to improve documentation."entry_points": [ { "name": "set_return_value", - "description": "", + "description": "Sets the return value for the contract.", "is_mutable": true, "arguments": [ { "name": "return_value", "description": null, "ty": "U8", "optional": false } ], "return_ty": "Unit", "is_contract_context": true, "access": "public" }, { "name": "can_transfer", - "description": "", + "description": "Checks if the transfer can be performed.", "is_mutable": false, "arguments": [], "return_ty": "U8", "is_contract_context": true, "access": "public" } ]odra-macros/src/ast/event/mod.rs (1)
25-36
: Efficient uniqueness check using HashSet.The changes enhance the uniqueness check for custom types using a
HashSet
, which is more efficient.Consider renaming
tmp
tounique_types
for better clarity.- let mut tmp = HashSet::<String>::new(); + let mut unique_types = HashSet::<String>::new();odra-macros/src/ast/schema/custom_types.rs (1)
34-43
: Efficient uniqueness check using HashSet.The changes enhance the uniqueness check for schema types using a
HashSet
, which is more efficient.Consider renaming
tmp
tounique_types
for better clarity.- let mut tmp = HashSet::<String>::new(); + let mut unique_types = HashSet::<String>::new();modules/resources/casper_contract_schemas/ownable2_step_schema.json (1)
12-12
: Inconsistent Contract Version UpdateThe contract version update from "1.0.0" to "1.1.0" is not consistently applied across the codebase. The following files still contain the old version "1.0.0":
odra-casper/rpc-client/resources/test/cep18_schema.json
modules/resources/casper_contract_schemas/mock_contract_schema.json
modules/resources/casper_contract_schemas/mock_transfer_filter_contract_schema.json
examples/resources/casper_contract_schemas/token_schema.json
modules/resources/casper_contract_schemas/erc20_schema.json
examples/resources/casper_contract_schemas/signature_verifier_schema.json
examples/resources/casper_contract_schemas/time_lock_wallet_schema.json
examples/resources/casper_contract_schemas/public_wallet_schema.json
examples/resources/casper_contract_schemas/pauseable_counter_schema.json
examples/resources/casper_contract_schemas/dog_contract3_schema.json
examples/resources/casper_contract_schemas/owned_token_schema.json
examples/resources/casper_contract_schemas/owned_contract_schema.json
examples/resources/casper_contract_schemas/nested_odra_types_contract_schema.json
examples/resources/casper_contract_schemas/modules_contract_schema.json
examples/resources/casper_contract_schemas/party_contract_schema.json
examples/resources/casper_contract_schemas/math_engine_schema.json
examples/resources/casper_contract_schemas/livenet_contract_schema.json
examples/resources/casper_contract_schemas/token_manager_schema.json
examples/resources/casper_contract_schemas/dog_contract_schema.json
examples/resources/casper_contract_schemas/dog_contract2_schema.json
examples/resources/casper_contract_schemas/cross_contract_schema.json
examples/resources/casper_contract_schemas/cep18_schema.json
examples/resources/casper_contract_schemas/my_contract_schema.json
examples/resources/casper_contract_schemas/mock_moderated_schema.json
examples/resources/casper_contract_schemas/balance_checker_schema.json
examples/resources/test/cep18_schema.json
examples/resources/casper_contract_schemas/testing_contract_schema.json
examples/resources/casper_contract_schemas/reentrancy_mock_schema.json
examples/resources/casper_contract_schemas/host_contract_schema.json
Please update all instances of the contract version to "1.1.0" to ensure consistency.
Analysis chain
LGTM! But verify the consistency of the version update.
The version update from "1.0.0" to "1.1.0" is approved.
However, ensure that all references to the contract version are updated consistently across the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the consistency of the contract version update. # Test: Search for all occurrences of the contract version. Expect: Only occurrences of the new version. rg --type json '"contract_version": "1.0.0"'Length of output: 2930
modules/resources/casper_contract_schemas/cep18_client_contract_schema.json (1)
12-12
: Inconsistent contract version update detected.The contract version has been updated from "1.0.0" to "1.1.0" in
modules/resources/casper_contract_schemas/cep18_client_contract_schema.json
. However, there are multiple occurrences of the old version "1.0.0" across the codebase that need to be updated to ensure consistency.Please update the following files to reflect the new contract version "1.1.0":
examples/resources/casper_contract_schemas/cross_contract_schema.json
examples/resources/casper_contract_schemas/signature_verifier_schema.json
examples/resources/casper_contract_schemas/token_schema.json
examples/resources/casper_contract_schemas/token_manager_schema.json
examples/resources/casper_contract_schemas/reentrancy_mock_schema.json
examples/resources/casper_contract_schemas/party_contract_schema.json
examples/resources/casper_contract_schemas/public_wallet_schema.json
examples/resources/casper_contract_schemas/pauseable_counter_schema.json
examples/resources/casper_contract_schemas/owned_token_schema.json
examples/resources/casper_contract_schemas/nested_odra_types_contract_schema.json
examples/resources/casper_contract_schemas/my_contract_schema.json
examples/resources/casper_contract_schemas/modules_contract_schema.json
examples/resources/casper_contract_schemas/mock_moderated_schema.json
examples/resources/casper_contract_schemas/testing_contract_schema.json
examples/resources/casper_contract_schemas/time_lock_wallet_schema.json
examples/resources/casper_contract_schemas/owned_contract_schema.json
examples/resources/casper_contract_schemas/livenet_contract_schema.json
examples/resources/casper_contract_schemas/host_contract_schema.json
examples/resources/casper_contract_schemas/dog_contract3_schema.json
examples/resources/casper_contract_schemas/dog_contract_schema.json
examples/resources/casper_contract_schemas/balance_checker_schema.json
examples/resources/casper_contract_schemas/dog_contract2_schema.json
examples/resources/test/cep18_schema.json
examples/resources/casper_contract_schemas/cep18_schema.json
examples/resources/casper_contract_schemas/math_engine_schema.json
modules/resources/casper_contract_schemas/mock_contract_schema.json
modules/resources/casper_contract_schemas/mock_transfer_filter_contract_schema.json
modules/resources/casper_contract_schemas/erc20_schema.json
odra-casper/rpc-client/resources/test/cep18_schema.json
Analysis chain
LGTM! But verify the consistency of the version update.
The version update from "1.0.0" to "1.1.0" is approved.
However, ensure that all references to the contract version are updated consistently across the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the consistency of the contract version update. # Test: Search for all occurrences of the contract version. Expect: Only occurrences of the new version. rg --type json '"contract_version": "1.0.0"'Length of output: 2930
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (24)
- Cargo.toml (1 hunks)
- benchmark/Cargo.toml (1 hunks)
- justfile (2 hunks)
- modules/Cargo.toml (1 hunks)
- modules/resources/casper_contract_schemas/cep18_client_contract_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/cep18_schema.json (2 hunks)
- modules/resources/casper_contract_schemas/erc1155_receiver_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/erc1155_token_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/erc721_receiver_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/erc721_token_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/mock_cep78_operator_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/mock_cep78_transfer_filter_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/mock_dummy_contract_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/ownable2_step_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/ownable_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/test_cep78_schema.json (1 hunks)
- modules/resources/casper_contract_schemas/wrapped_native_token_schema.json (1 hunks)
- modules/resources/legacy/mock_cep78_operator_schema.json (1 hunks)
- modules/resources/legacy/mock_cep78_transfer_filter_schema.json (1 hunks)
- modules/src/lib.rs (1 hunks)
- odra-casper/rpc-client/Cargo.toml (1 hunks)
- odra-macros/src/ast/event/mod.rs (2 hunks)
- odra-macros/src/ast/schema/custom_types.rs (3 hunks)
- odra-schema/src/custom_type.rs (2 hunks)
Files skipped from review due to trivial changes (5)
- modules/resources/casper_contract_schemas/erc721_receiver_schema.json
- modules/resources/casper_contract_schemas/erc721_token_schema.json
- modules/resources/casper_contract_schemas/mock_dummy_contract_schema.json
- modules/resources/casper_contract_schemas/ownable_schema.json
- modules/resources/casper_contract_schemas/test_cep78_schema.json
Additional comments not posted (47)
modules/src/lib.rs (1)
Line range hint
1-12
:
Verify the impact of removing the recursion limit directive.The removal of
#![recursion_limit = "256"]
may affect the performance and behavior of recursive functions. Ensure that this change does not introduce stack overflow issues or other unintended side effects.modules/resources/legacy/mock_cep78_transfer_filter_schema.json (1)
1-30
: Verify the correctness and completeness of the JSON schema.Ensure that the schema is well-formed and adheres to the expected structure. Verify the field types, required attributes, and overall schema validity.
benchmark/Cargo.toml (1)
13-13
: LGTM! Verify the impact on dependency resolution.The change to enforce the use of a specific version of
serde_json
ensures consistency across different environments. Verify the impact on dependency resolution and ensure no conflicts arise.Verification successful
No conflicts found with
serde_json
dependency resolution.The enforced version of
serde_json
(=1.0.113
) is consistently used across the repository, ensuring no dependency conflicts arise.
Cargo.toml
:serde_json = { version = "=1.0.113", default-features = false }
odra-build/Cargo.toml
:serde_json = { workspace = true, default-features = false, features = ["alloc"] }
modules/Cargo.toml
:serde_json = { version = "=1.0.113", default-features = false }
odra-casper/rpc-client/Cargo.toml
:serde_json = { version = "=1.0.113", features = ["raw_value"] }
core/Cargo.toml
:serde_json = { workspace = true, default-features = false, features = ["alloc"] }
benchmark/Cargo.toml
:serde_json = "=1.0.113"
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact on dependency resolution. # Test: Check for dependency conflicts. Expect: No conflicts. cargo checkLength of output: 86
Script:
#!/bin/bash # Searching for all occurrences of serde_json in Cargo.toml files to identify potential conflicts or multiple versions rg 'serde_json' --glob '**/Cargo.toml' -A 2Length of output: 1054
odra-casper/rpc-client/Cargo.toml (2)
17-17
: Specify exact version forserde_json
.The version constraint for
serde_json
has been changed to=1.0.113
. This ensures the project uses a specific version, which may include critical bug fixes or features, but reduces flexibility.
18-18
: Referenceserde
from workspace.The
serde
dependency is now referenced from the workspace. This change can improve dependency management and integration with other components within the workspace.modules/Cargo.toml (2)
13-13
: Upgradeserde
to specific version.The
serde
dependency has been upgraded to=1.0.195
. This ensures the project uses a specific version, which may include critical bug fixes or features, but reduces flexibility.
14-14
: Upgradeserde_json
to specific version.The
serde_json
dependency has been upgraded to=1.0.113
. This ensures the project uses a specific version, which may include critical bug fixes or features, but reduces flexibility.Cargo.toml (2)
40-40
: Specify exact version forserde
.The version constraint for
serde
has been changed to=1.0.195
. This ensures the project uses a specific version, which may include critical bug fixes or features, but reduces flexibility.
41-41
: Specify exact version forserde_json
.The version constraint for
serde_json
has been changed to=1.0.113
. This ensures the project uses a specific version, which may include critical bug fixes or features, but reduces flexibility.modules/resources/casper_contract_schemas/mock_cep78_transfer_filter_schema.json (2)
1-12
: Metadata section looks good.The metadata section is correctly formatted and provides necessary information about the schema.
43-66
: Call section looks good.The call section is well-defined with necessary attributes and descriptions.
odra-macros/src/ast/event/mod.rs (1)
Line range hint
73-83
:
Function implementation looks good.The
custom_struct
function is well-implemented and does not require changes.odra-macros/src/ast/schema/custom_types.rs (1)
Line range hint
55-61
:
Function implementation looks good.The
try_from
function is well-implemented and does not require changes.modules/resources/legacy/mock_cep78_operator_schema.json (11)
1-2
: LGTM!The "name" field is set correctly.
3-3
: LGTM!The "events" field is set correctly.
5-20
: LGTM!The "set_address" entry point is well-formed and follows the expected structure.
21-43
: LGTM!The "mint" entry point is well-formed and follows the expected structure.
44-66
: LGTM!The "mint_with_hash" entry point is well-formed and follows the expected structure.
67-82
: LGTM!The "burn" entry point is well-formed and follows the expected structure.
83-105
: LGTM!The "mint_for" entry point is well-formed and follows the expected structure.
106-128
: LGTM!The "transfer" entry point is well-formed and follows the expected structure.
129-158
: LGTM!The "transfer_from" entry point is well-formed and follows the expected structure.
159-181
: LGTM!The "approve" entry point is well-formed and follows the expected structure.
182-197
: LGTM!The "revoke" entry point is well-formed and follows the expected structure.
modules/resources/casper_contract_schemas/erc1155_receiver_schema.json (1)
12-12
: Version Update: Ensure backward compatibility.The contract version has been updated from "1.0.0" to "1.1.0". Verify that this version update maintains backward compatibility and that all dependent systems are updated accordingly.
modules/resources/casper_contract_schemas/mock_cep78_operator_schema.json (1)
1-227
: New Schema: Verify completeness and correctness.This is a new JSON schema file for the
MockCep78Operator
contract. Ensure that:
- All entry points are correctly defined.
- Argument types and return types are accurate.
- There are no missing elements or inconsistencies.
justfile (2)
2-2
: Branch Update: Ensure compatibility with the new branch.The branch reference for
CARGO_ODRA_GIT_REPO
has been updated fromrelease/0.1.2
torelease/0.1.3
. Verify that this new branch is compatible with the rest of the codebase and does not introduce any breaking changes.
39-39
: Specify Stable Version forgrcov
Installation.The command for installing
grcov
has been updated to use the stable version of Cargo. This enhances stability and ensures compatibility with the latest version of the Cargo Odra repository.odra-schema/src/custom_type.rs (14)
58-62
: LGTM!The changes correctly update the trait bound and the
schema_types
method implementation.
64-68
: LGTM!The changes correctly update the trait bound and the
schema_types
method implementation.
70-77
: LGTM!The changes correctly update the trait bounds and the
schema_types
method implementation.
79-86
: LGTM!The changes correctly update the trait bounds and the
schema_types
method implementation.
88-92
: LGTM!The changes correctly update the trait bound and the
schema_types
method implementation.
94-101
: LGTM!The changes correctly update the trait bounds and the
schema_types
method implementation.
103-113
: LGTM!The changes correctly update the trait bounds and the
schema_types
method implementation.
183-187
: LGTM!The changes correctly update the trait bound and the
custom_types
method implementation.
189-193
: LGTM!The changes correctly update the trait bound and the
custom_types
method implementation.
195-202
: LGTM!The changes correctly update the trait bounds and the
custom_types
method implementation.
204-211
: LGTM!The changes correctly update the trait bounds and the
custom_types
method implementation.
213-217
: LGTM!The changes correctly update the trait bound and the
custom_types
method implementation.
219-226
: LGTM!The changes correctly update the trait bounds and the
custom_types
method implementation.
228-238
: LGTM!The changes correctly update the trait bounds and the
custom_types
method implementation.modules/resources/casper_contract_schemas/wrapped_native_token_schema.json (1)
12-12
: Verify the changes associated with the new contract version.The
contract_version
has been updated from "1.0.0" to "1.1.0". Ensure that all changes associated with the new version are correctly implemented and tested.modules/resources/casper_contract_schemas/erc1155_token_schema.json (1)
12-12
: Verify the changes associated with the new contract version.The
contract_version
has been updated from "1.0.0" to "1.1.0". Ensure that all changes associated with the new version are correctly implemented and tested.modules/resources/casper_contract_schemas/cep18_schema.json (3)
12-12
: Verify the version increment.The contract version has been updated from "1.0.0" to "1.1.0". Ensure that this version increment is consistent with the changes made in the contract.
203-222
: Verify the integration and usage ofCep18Modality
.The new enumeration
Cep18Modality
with variantsNone
andMintAndBurn
has been added. Ensure that this new enumeration is correctly integrated and used within the contract.
223-247
: Verify the integration and usage ofSecurityBadge
.The new enumeration
SecurityBadge
with variantsAdmin
,Minter
, andNone
has been added. Ensure that this new enumeration is correctly integrated and used within the contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Benchmark report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- benchmark/rust-toolchain (1 hunks)
- core/src/address.rs (1 hunks)
- modules/src/cep78/metadata.rs (1 hunks)
- modules/src/cep78/modalities.rs (1 hunks)
Files skipped from review due to trivial changes (3)
- benchmark/rust-toolchain
- modules/src/cep78/metadata.rs
- modules/src/cep78/modalities.rs
Additional comments not posted (1)
core/src/address.rs (1)
206-206
: Acknowledgement: Suppression of Clippy lint warning.The addition of
#[allow(clippy::to_string_trait_impl)]
suppresses the Clippy lint warning related to implementing theToString
trait. This indicates a conscious decision to maintain the implementation despite potential conflicts with the standard library'sToString
implementation.
Benchmark report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- examples/ourcoin/rust-toolchain (1 hunks)
- templates/blank/rust-toolchain (1 hunks)
- templates/cep18/rust-toolchain (1 hunks)
- templates/cep78/rust-toolchain (1 hunks)
- templates/full/rust-toolchain (1 hunks)
- templates/workspace/rust-toolchain (1 hunks)
Files skipped from review due to trivial changes (5)
- examples/ourcoin/rust-toolchain
- templates/blank/rust-toolchain
- templates/cep18/rust-toolchain
- templates/full/rust-toolchain
- templates/workspace/rust-toolchain
Additional comments not posted (1)
templates/cep78/rust-toolchain (1)
1-1
: Verify compatibility with the new Rust toolchain version.The Rust toolchain version has been updated to
nightly-2024-04-26
. Ensure that the codebase is compatible with this version and that there are no breaking changes introduced by the new nightly build.
Benchmark report
|
Summary by CodeRabbit
New Features
MockCep78Operator
andMockCep78TransferFilter
.Improvements
Bug Fixes
Chores