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

Wrapped Cw721 #12

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mdjakovic0920
Copy link

@mdjakovic0920 mdjakovic0920 commented Jul 30, 2024

Contact Information

Summary: The Wrapped CW721 ADO is a smart contract that wraps CW721 tokens.

One simple example is if a user wants to leverage TransferAgreement functionality to make a trade without the need of a marketplace or escrow service. In this case, the user can wrap the token, sell the wrapped token, and then the new owner can unwrap to get the original.

The user can send or deposit any CW721 token and get back a "wrapped" version. They can also be "unwrapped" back to the underlying token by depositing the wrapped token in the contract (the creator of the contract can specify if unwrapping should be allowed or not as there are some instances where they may want to permanently wrap a token).

This is the solution of #10

Messages

Instantiation (What is specified and stored at instantiation)

pub struct InstantiateMsg {
    pub kernel_address: String,
    pub owner: Option<String>,
    pub authorized_token_addresses: Option<Vec<AndrAddr>>,
}

authorized_token_addresses: An optional vector of addresses that are authorized to interact with the contract. If not specified, any address can interact.

Execute Messages (What are the messages that can be executed)

  1. ReceiveNft: Handles the receipt of an NFT and locks it for a specified duration.
ReceiveNft(Cw721ReceiveMsg),

pub enum Cw721HookMsg {
    MintWrappedNft {
        sender: AndrAddr,
        wrapped_token_owner: String,
        unwrappable: bool,
    },
    UnwrapNft {
        recipient: AndrAddr,
        wrapped_token: AndrAddr,
        wrapped_token_id: String,
    },
}

Cw721ReceiveMsg: The message received when an NFT is sent to this contract. This message includes the sender, the token ID, and a message for further handling.

  1. SetWrappedNftAddress: Sets the wrapped version of nft which is linked to this ADO.
SetWrappedNftAddress {
        wrapped_nft_address: AndrAddr,
},

Query Messages (What are the messages that can be queried, what does each return)

pub enum QueryMsg {
    #[returns(OriginCw721InfoResponse)]
    GetOriginCw721 {
        wrapped_token: AndrAddr,
        wrapped_token_id: String,
    },

    #[returns(WrappedCw721InfoResponse)]
    GetWrappedCw721 {
        origin_token: AndrAddr,
        origin_token_id: String,
    },

    #[returns(bool)]
    IsUnwrappable {
        wrapped_token: AndrAddr,
        wrapped_token_id: String,
    },

    #[returns(u64)]
    GetWrappedNftCount {},

    #[returns(AndrAddr)]
    GetWrappedNftAddress {},

    #[returns(Option<Vec<AndrAddr>>)]
    GetAuthorizedTokenAddresses {},
}
  1. **GetOriginCw721 **: Returns the origin version of nft.
  2. **GetWrappedCw721 **: Returns the wrapped version of nft.
  3. **IsUnwrappable **: Returns the availability for unwrapping of wrapped version of nft.
  4. **GetWrappedNftCount **: Returns the amount of wrapped NFTs that are wrapped by this ADO .
  5. **GetWrappedNftAddress **: Returns wrapped version of NFT contract address that is linked to this ADO.
  6. **GetAuthorizedTokenAddresses **: Returns authorized token addresses at instantiation.

State

The contract maintains the following state:

pub const WRAPPED_NFT_ADDRESS: Item<AndrAddr> = Item::new("wrapped_token_address");
pub const WRAPPED_NFT_COUNT: Item<u64> = Item::new("wrapped_token_count");
pub const AUTHORIED_TOKEN_ADDRESSES: Item<Vec<AndrAddr>> = Item::new("authorized_token_addresses");

pub const WRAPPED_INFO: Map<(&Addr, &str), WrappedInfo> = Map::new("wrapped_info");
pub const ORIGIN_INFO: Map<(&Addr, &str), OriginInfo> = Map::new("origin_info");

#[cw_serde]
pub struct WrappedInfo {
    pub wrapped_token: AndrAddr,
    pub wrapped_token_id: String,
    pub unwrappable: bool,
}

#[cw_serde]
pub struct OriginInfo {
    pub origin_token: AndrAddr,
    pub origin_token_id: String,
    pub unwrappable: bool,
}

Dependencies

The dependencies are listed in the Cargo.toml file under the dependencies section.

Future Work.

The Andromeda modules like rates and address-list can be added to this ADO for specific purpose.

Summary by CodeRabbit

  • New Features

    • Introduced a configuration file for efficient project management, including aliases for building and testing.
    • Added GitHub Actions and CircleCI workflows for automated testing and release management.
    • Created a comprehensive README to guide developers in using the Wrapped CW721 ADO and its operational workflow.
    • Implemented a smart contract for managing wrapped NFTs, allowing minting, unwrapping, and querying functionalities.
    • Established JSON schemas for validating messages and responses related to wrapped NFTs.
  • Bug Fixes

    • Added mechanisms to improve permission management and error handling within smart contract operations.
  • Documentation

    • Added a README file with detailed instructions on wrapping CW721 tokens and relevant considerations for users.
    • Included a LICENSE file and NOTICE for legal compliance.
  • Tests

    • Developed integration and unit tests to validate the functionality of wrapped NFTs and contract interactions.
  • Chores

    • Implemented a .gitignore file to maintain a clean repository by ignoring unnecessary files.

Copy link

coderabbitai bot commented Jul 30, 2024

Walkthrough

This update enriches the wrapped-cw721 Rust project by implementing enhanced development configurations, automated CI/CD pipelines, and a structured testing framework. It adds robust features for managing wrapped NFTs, including refined message handling and comprehensive documentation. These changes optimize development workflows, improve code quality checks, streamline deployment strategies, and enhance the onboarding experience for developers.

Changes

Files Change Summary
wrapped-cw721/.cargo/config Added aliases for building WASM, running unit tests, and executing schema generation to simplify development tasks.
wrapped-cw721/.circleci/config.yml Created a CI/CD pipeline for building and tagging Docker images based on commits and tags for efficient version management.
wrapped-cw721/.editorconfig Established coding style guidelines including indentation and whitespace management for consistent coding practices.
wrapped-cw721/.github/workflows/Basic.yml Introduced a GitHub Actions workflow for running tests and lint checks to maintain code quality.
wrapped-cw721/.github/workflows/Release.yml Automated release process for uploading optimized WASM binaries to GitHub when a new release is created.
wrapped-cw721/.gitignore Added patterns to ignore unnecessary files like build outputs and system files to keep the repository clean.
wrapped-cw721/Cargo.toml Configured package settings, dependencies, and optimizations for the library versioning and performance.
wrapped-cw721/LICENSE Introduced the Apache License 2.0 to outline usage and distribution terms for the project.
wrapped-cw721/NOTICE Added copyright and licensing details for clarity in legal usage and compliance.
wrapped-cw721/README.md Created a comprehensive guide for developers to set up and use the CosmWasm framework for smart contracts, including CI configuration details.
wrapped-cw721/examples/schema.rs Added functionality for generating API schemas for contract messages to enhance interoperability.
wrapped-cw721/src/contract.rs Implemented core smart contract logic for managing wrapped NFTs, including instantiation, execution, querying, and migration functionalities.
wrapped-cw721/src/lib.rs Structured the library with modules for better organization, focusing on contract logic, message handling, state management, and testing.
wrapped-cw721/src/msg.rs Defined message structures for initialization, execution, and querying of wrapped NFTs, enhancing contract interactions.
wrapped-cw721/src/state.rs Established storage structures for managing wrapped NFT data and associated addresses efficiently.
wrapped-cw721/src/testing/* Introduced various testing modules for robust unit and integration testing of the wrapped NFT functionalities, ensuring reliability.
wrapped-cw721/README.md (new) Added a detailed overview of the Wrapped CW721 ADO, including its purpose, functionality, and operational workflow.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Contract
    participant NFT_Contract

    User->>Contract: wrapNFT(originalNFT)
    Contract->>NFT_Contract: mintWrappedNFT(originalNFT)
    NFT_Contract-->>Contract: wrappedNFT
    Contract-->>User: return wrappedNFT

    User->>Contract: unwrapNFT(wrappedNFT)
    Contract->>NFT_Contract: transferOriginalNFT(wrappedNFT)
    NFT_Contract-->>Contract: originalNFT
    Contract-->>User: return originalNFT
Loading

🐇 In a world of code and light,
Wrapped NFTs take flight,
With tests and builds so neat,
Our smart contracts can't be beat!
Hop along, let’s code away,
In the Andromeda sun, we play! 🌟


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.
    • @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 as 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.

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

CodeRabbit Configuration 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

@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: 0

Outside diff range, codebase verification and nitpick comments (6)
wrapped-cw721/src/lib.rs (1)

8-9: Commented code: Consider removing or explaining.

The commented code for the mock module is not explained. If it is not needed, consider removing it. If it is needed for future use, add a comment explaining its purpose.

-// #[cfg(all(not(target_arch = "wasm32"), feature = "testing"))]
-// pub mod mock;
+// Uncomment the following lines if the mock module is needed for testing in non-WASM environments.
+// #[cfg(all(not(target_arch = "wasm32"), feature = "testing"))]
+// pub mod mock;
wrapped-cw721/.circleci/config.yml (1)

28-41: Ensure proper tagging and pushing of Docker images.

The steps for tagging and pushing Docker images are mostly correct, but there is a missing repository and tag in the docker push command. Ensure that the docker push command includes the repository and tag to avoid issues.

  • File: wrapped-cw721/.circleci/config.yml
  • Lines: 37-38
docker push "cosmwasm/cw-gitpod-base:${CIRCLE_TAG}"
Analysis chain

Ensure proper tagging and pushing of Docker images.

The steps for tagging and pushing Docker images seem correct. Ensure that the tags are appropriately managed and the images are pushed to the correct repository.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Docker image tagging and pushing process.

# Test: List Docker images and tags. Expect: Ensure images are tagged correctly.
docker images | grep "cosmwasm/cw-gitpod-base"

Length of output: 120


Script:

#!/bin/bash
# Extract the relevant section of the CircleCI config file for review
fd config.yml -e yml --exec cat

Length of output: 33


Script:

#!/bin/bash
# Locate and display the CircleCI config file
find . -name "config.yml" -exec cat {} +

Length of output: 1733

wrapped-cw721/.github/workflows/Basic.yml (1)

9-31: Update Rust toolchain version.

The current Rust toolchain version specified (1.60.0) is outdated. The latest stable version is 1.80.0. It is recommended to update the toolchain version in the GitHub Actions workflow to ensure compatibility, security, and access to the latest features.

  • Update the Rust toolchain version in the wrapped-cw721/.github/workflows/Basic.yml file from 1.60.0 to 1.80.0.
Analysis chain

Ensure correct toolchain and test configuration.

The steps for checking out the code, installing the toolchain, and running unit tests are correctly configured. Ensure the specified toolchain version 1.60.0 is appropriate and up-to-date.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Rust toolchain version.

# Test: List available Rust toolchain versions. Expect: Ensure `1.60.0` is up-to-date.
rustup toolchain list | grep "1.60.0"

Length of output: 111


Script:

#!/bin/bash
# Search for the Rust toolchain version 1.60.0 in the repository
rg "1.60.0"

Length of output: 11


Script:

#!/bin/bash
# Fetch the latest stable Rust toolchain version
curl -s https://static.rust-lang.org/dist/channel-rust-stable.toml | grep "version ="

Length of output: 797

wrapped-cw721/README.md (3)

18-30: Fix grammatical issues.

There are minor grammatical issues in this section.

- ## Creating a new repo from template
+ ## Creating a new repo from the template

- Assuming you have a recent version of Rust and Cargo installed
+ Assuming you have a recent version of Rust and Cargo installed,
Tools
LanguageTool

[uncategorized] ~18-~18: You might be missing the article “a” here.
Context: ...et coding. ## Creating a new repo from template Assuming you have a recent version of ...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


50-64: Fix grammatical issues.

There are minor grammatical issues in this section.

- After generating, you have a initialized local git repo, but no commits, and no remote.
+ After generating, you have an initialized local git repo, but no commits, and no remote.

- Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below).
+ Go to a server (e.g., GitHub) and create a new upstream repo (called `YOUR-GIT-URL` below).
Tools
LanguageTool

[misspelling] ~52-~52: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...eate a Repo After generating, you have a initialized local git repo, but no comm...

(EN_A_VS_AN)


[uncategorized] ~53-~53: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...commits, and no remote. Go to a server (eg. github) and create a new upstream repo ...

(E_G)


66-78: Improve clarity and conciseness.

The section can be made more concise.

- One note is that the CI runs all `cargo` commands
- with `--locked` to ensure it uses the exact same versions as you have locally. This also means
- you must have an up-to-date `Cargo.lock` file, which is not auto-generated.
+ Note: The CI runs all `cargo` commands with `--locked` to ensure it uses the same versions as you have locally. This means you must have an up-to-date `Cargo.lock` file, which is not auto-generated.

- The first time you set up the project (or after adding any dep), you should ensure the
- `Cargo.lock` file is updated, so the CI will test properly. This can be done simply by
- running `cargo check` or `cargo unit-test`.
+ The first time you set up the project (or after adding any dependency), ensure the `Cargo.lock` file is updated by running `cargo check` or `cargo unit-test`.
Tools
LanguageTool

[style] ~73-~73: ‘exact same’ might be wordy. Consider a shorter alternative.
Context: ...s with --locked to ensure it uses the exact same versions as you have locally. This also...

(EN_WORDINESS_PREMIUM_EXACT_SAME)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 63d9a0c and 984da74.

Files ignored due to path filters (1)
  • wrapped-cw721/Cargo.lock is excluded by !**/*.lock
Files selected for processing (19)
  • wrapped-cw721/.cargo/config (1 hunks)
  • wrapped-cw721/.circleci/config.yml (1 hunks)
  • wrapped-cw721/.editorconfig (1 hunks)
  • wrapped-cw721/.github/workflows/Basic.yml (1 hunks)
  • wrapped-cw721/.github/workflows/Release.yml (1 hunks)
  • wrapped-cw721/.gitignore (1 hunks)
  • wrapped-cw721/Cargo.toml (1 hunks)
  • wrapped-cw721/LICENSE (1 hunks)
  • wrapped-cw721/NOTICE (1 hunks)
  • wrapped-cw721/README.md (1 hunks)
  • wrapped-cw721/examples/schema.rs (1 hunks)
  • wrapped-cw721/src/contract.rs (1 hunks)
  • wrapped-cw721/src/lib.rs (1 hunks)
  • wrapped-cw721/src/msg.rs (1 hunks)
  • wrapped-cw721/src/state.rs (1 hunks)
  • wrapped-cw721/src/testing/integration_testing.rs (1 hunks)
  • wrapped-cw721/src/testing/mock_querier.rs (1 hunks)
  • wrapped-cw721/src/testing/mod.rs (1 hunks)
  • wrapped-cw721/src/testing/tests.rs (1 hunks)
Files skipped from review due to trivial changes (6)
  • wrapped-cw721/.cargo/config
  • wrapped-cw721/.editorconfig
  • wrapped-cw721/.gitignore
  • wrapped-cw721/Cargo.toml
  • wrapped-cw721/LICENSE
  • wrapped-cw721/NOTICE
Additional context used
LanguageTool
wrapped-cw721/README.md

[uncategorized] ~18-~18: You might be missing the article “a” here.
Context: ...et coding. ## Creating a new repo from template Assuming you have a recent version of ...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[misspelling] ~52-~52: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...eate a Repo After generating, you have a initialized local git repo, but no comm...

(EN_A_VS_AN)


[uncategorized] ~53-~53: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...commits, and no remote. Go to a server (eg. github) and create a new upstream repo ...

(E_G)


[style] ~73-~73: ‘exact same’ might be wordy. Consider a shorter alternative.
Context: ...s with --locked to ensure it uses the exact same versions as you have locally. This also...

(EN_WORDINESS_PREMIUM_EXACT_SAME)

Markdownlint
wrapped-cw721/README.md

35-35: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

Additional comments not posted (57)
wrapped-cw721/src/testing/mod.rs (1)

1-3: Modules are correctly declared.

The module declarations for tests, mock_querier, and integration_testing are correct. Ensure that the corresponding modules are implemented correctly.

wrapped-cw721/src/lib.rs (2)

1-3: Modules are correctly declared.

The module declarations for contract, msg, and state are correct. Ensure that the corresponding modules are implemented correctly.


5-6: Testing module is correctly declared.

The conditional compilation attribute and the module declaration for testing are correct. Ensure that the testing module is implemented correctly.

wrapped-cw721/examples/schema.rs (4)

1-2: Imports are correct.

The import for current_dir from std::env is correct and necessary for the functionality.


3-4: Imports are correct.

The imports for cosmwasm_schema macros and functions are correct and necessary for schema generation.


5-6: Imports are correct.

The imports for message types from andromeda_wrapped_cw721::msg are correct and necessary for schema generation.


7-16: Main function is correct.

The main function correctly generates the schema files for the specified message types. Ensure that the output directory exists and is writable.

wrapped-cw721/src/state.rs (4)

1-4: Imports look good.

The necessary modules for state management are imported correctly.


6-8: State constants are defined correctly.

The constants for storing wrapped NFT address, count, and authorized token addresses are appropriately defined.


10-11: State maps are defined correctly.

The maps for storing wrapped and origin info are appropriately defined.


13-25: Data structures are defined correctly.

The data structures for WrappedInfo and OriginInfo are appropriately defined.

wrapped-cw721/.github/workflows/Release.yml (3)

1-5: Workflow name and trigger are defined correctly.

The workflow is named "release wasm" and is triggered on release creation.


7-9: Job definition is correct.

The job is defined to run on the latest Ubuntu version.


11-35: Job steps are defined correctly.

The steps include checking out the source, installing cargo-run-script, running cargo optimize, getting the release ID, and uploading the optimized WASM. All steps are necessary and correctly defined.

wrapped-cw721/src/msg.rs (6)

1-6: Imports look good.

The necessary modules for message handling are imported correctly.


7-11: Instantiation message is defined correctly.

The instantiation message includes an optional list of authorized token addresses and is correctly defined.


13-20: Execution messages are defined correctly.

The execution messages include receiving NFTs and setting the wrapped NFT address. They are correctly defined.


22-33: CW721 hook messages are defined correctly.

The CW721 hook messages include minting and unwrapping wrapped NFTs. They are correctly defined.


36-66: Query messages are defined correctly.

The query messages include getting origin and wrapped CW721 info, checking if a token is unwrappable, getting the wrapped NFT count, wrapped NFT address, and authorized token addresses. They are correctly defined.


68-78: Response structures are defined correctly.

The response structures include OriginCw721InfoResponse and WrappedCw721InfoResponse. They are correctly defined.

wrapped-cw721/.circleci/config.yml (3)

42-61: Ensure correct branch and tag filters.

The filters for branches and tags are correctly set to run on master and version tags only.


3-7: Verify the Docker image version.

The buildpack-deps:trusty image is quite old and may not have the latest security updates. Consider using a more recent image.

Verification successful

Consider updating the Docker image version.

The buildpack-deps:trusty image is outdated. Consider using a more recent image such as buildpack-deps:24.04 to ensure up-to-date dependencies and security patches.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Docker image version.

# Test: List available tags for the buildpack-deps image. Expect: Identify a more recent image.
curl -s https://registry.hub.docker.com/v1/repositories/buildpack-deps/tags | jq -r '.[].name' | sort -V

Length of output: 163


Script:

#!/bin/bash
# Description: Verify the Docker image version using a different API endpoint.

# Test: List available tags for the buildpack-deps image. Expect: Identify a more recent image.
curl -s https://hub.docker.com/v2/repositories/library/buildpack-deps/tags/?page_size=100 | jq -r '.results[].name' | sort -V

Length of output: 1121


9-26: Ensure secure handling of Docker credentials.

The Docker login command uses --password-stdin which is good practice. Ensure that $DOCKER_USER and $DOCKER_PASS are securely stored and managed.

wrapped-cw721/.github/workflows/Basic.yml (2)

3-5: Ensure appropriate workflow triggers.

The workflow is triggered on push and pull request events, which is appropriate for running tests and lints.


40-75: Ensure correct lint configuration.

The steps for checking out the code, installing the toolchain, and running cargo fmt, cargo clippy, and schema generation are correctly configured. Ensure the specified toolchain version 1.60.0 is appropriate and up-to-date.

wrapped-cw721/README.md (2)

1-7: Ensure clarity and accuracy in the introductory section.

The introductory section provides a clear overview of the project and its documentation. No issues found.


79-93: Ensure clarity and accuracy in the Using your project section.

The section provides clear and accurate information about using the project. No issues found.

wrapped-cw721/src/testing/integration_testing.rs (6)

1-13: Imports look good!

The necessary modules for contract, messages, and testing utilities are appropriately imported.


17-31: Mock application initialization looks good!

The mock_app function correctly initializes the mock application with initial balance setup.


33-36: Contract wrapper initialization looks good!

The contract function correctly wraps the main contract's execute, instantiate, and query functions.


38-41: CW721 contract wrapper initialization looks good!

The cw721 function correctly wraps the CW721 contract's execute, instantiate, and query functions.


43-45: Mock address generation looks good!

The generate_mock_address function correctly generates mock addresses using MockApiBech32.


47-207: Integration test case looks comprehensive!

The wrapped_cw721_test test case covers the instantiation of contracts, minting of tokens, setting wrapped NFT address, sending NFTs, and querying ownership. It is well-structured and comprehensive.

wrapped-cw721/src/testing/mock_querier.rs (3)

1-15: Imports look good!

The necessary modules for mocking and querying are appropriately imported.


36-63: Mock dependencies initialization looks good!

The mock_dependencies_custom function correctly initializes the mock dependencies and instantiates the ADO contract.


65-231: WasmMockQuerier implementation looks comprehensive!

The WasmMockQuerier struct and its implementation cover handling of smart and raw queries, and specific token and kernel queries. It is well-structured and comprehensive.

wrapped-cw721/src/contract.rs (10)

1-27: Imports and constants look good!

The necessary modules for contract functionality are appropriately imported. Constants for contract name, version, and default values are well-defined.


29-77: Contract instantiation looks good!

The instantiate function correctly initializes the contract with the provided parameters and sets permissions for authorized token addresses.


79-95: Execute function looks good!

The execute function correctly handles various execute messages and delegates to the appropriate handler.


98-105: Handle execute function looks good!

The handle_execute function correctly matches the execute message and calls the corresponding handler.


107-130: Set wrapped NFT address function looks good!

The execute_set_wrapped_nft_address function correctly sets the wrapped NFT address and updates permissions.


132-157: Handle receive CW721 function looks good!

The handle_receive_cw721 function correctly matches the CW721 hook message and calls the corresponding handler.


159-230: Mint wrapped CW721 function looks good!

The execute_mint_wrapped_cw721 function correctly mints the wrapped CW721 token and updates the state.


232-291: Unwrap CW721 function looks good!

The execute_unwrap_cw721 function correctly unwraps the CW721 token and updates the state.


295-316: Query function looks good!

The query function correctly handles various query messages and delegates to the appropriate handler.


319-377: Query helper functions look good!

The query helper functions correctly retrieve information about origin and wrapped CW721 tokens, unwrappability, and authorized token addresses.

wrapped-cw721/src/testing/tests.rs (11)

62-101: LGTM!

The test function correctly tests the instantiation of the contract without any authorized token addresses.


103-121: LGTM!

The test function correctly tests the instantiation of the contract with an empty list of authorized token addresses.


123-149: LGTM!

The test function correctly tests the instantiation of the contract with a list of authorized token addresses.


151-206: LGTM!

The test function correctly tests the minting of wrapped NFTs without any authorized token addresses at the time of instantiation.


208-272: LGTM!

The test function correctly tests the minting of wrapped NFTs with authorized token addresses.


274-324: LGTM!

The test function correctly tests the unwrapping of NFTs.


326-363: LGTM!

The test function correctly tests the unwrapping of NFTs that are not unwrappable.


365-413: LGTM!

The test function correctly tests the query to check if an NFT is unwrappable.


22-30: LGTM!

The helper function correctly initializes the contract with the given parameters.


32-46: LGTM!

The helper function correctly executes the wrapping of NFTs.


48-60: LGTM!

The helper function correctly executes the unwrapping of NFTs.

@mdjakovic0920 mdjakovic0920 added the ADO Submission Submission of an ADO label Aug 13, 2024
Copy link

@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: 0

Outside diff range, codebase verification and nitpick comments (5)
wrapped-cw721/README.md (5)

2-2: Simplify wording for clarity.

Consider replacing "a variety of" with "various" to make the writing clearer.

- This functionality enables a variety of use cases, such as creating temporary representations of NFTs...
+ This functionality enables various use cases, such as creating temporary representations of NFTs...
Tools
LanguageTool

[style] ~2-~2: The phrase “a variety of” may be wordy. To make your writing clearer, consider replacing it.
Context: ... unwrapping. This functionality enables a variety of use cases, such as creating temporary r...

(A_VARIETY_OF)


7-8: Add a question mark for consistency.

The section title should end with a question mark for consistency with other titles.

- **Are you planning to build this ADO yourself, or by the Andromeda team**
+ **Are you planning to build this ADO yourself, or by the Andromeda team?**
Tools
LanguageTool

[typographical] ~8-~8: Should there be a question mark at the end of this sentence?
Context: ...* I am planning to build this ADO myself. **Credits/Associations - Is this ADO b...

(MISSING_QUESTION_MARK2)


13-16: Format URLs as hyperlinks.

To improve readability, format the URLs as hyperlinks.

- CW721 Documentation(https://docs.andromedaprotocol.io/andromeda/andromeda-digital-objects/cw721)
- https://docs.ethos.wiki/ethereansos-docs/items/items/item-v2-protocol-overview/wrapped-items/erc721-wrapper
- https://kaigani.medium.com/wrapped-nfts-the-next-phase-in-crypto-collectibles-8253feeaabba
+ [CW721 Documentation](https://docs.andromedaprotocol.io/andromeda/andromeda-digital-objects/cw721)
+ [EthereansOS Docs](https://docs.ethos.wiki/ethereansos-docs/items/items/item-v2-protocol-overview/wrapped-items/erc721-wrapper)
+ [Medium Article on Wrapped NFTs](https://kaigani.medium.com/wrapped-nfts-the-next-phase-in-crypto-collectibles-8253feeaabba)
Tools
LanguageTool

[uncategorized] ~13-~13: If this is a question, use a question mark.
Context: ...n idea of the ADO and how/why it is used.** - CW721 Documentation(https://docs.an...

(QUESTION_MARK)

Markdownlint

14-14: null
Bare URL used

(MD034, no-bare-urls)


15-15: null
Bare URL used

(MD034, no-bare-urls)


16-16: null
Bare URL used

(MD034, no-bare-urls)


29-35: Rephrase for variety.

Consider rephrasing to avoid starting multiple points with "Get."

- Get wrapped token count: Retrieve the total number of wrapped tokens.
- Get wrapped token address: Obtain the address of the wrapped token contract.
- Get contract's owner.
+ Wrapped token count: Retrieve the total number of wrapped tokens.
+ Wrapped token address: Obtain the address of the wrapped token contract.
+ Contract's owner: Identify the owner of the contract.
Tools
LanguageTool

[typographical] ~30-~30: Except for inverted sentences, ‘will you’ requires a question mark at the end of the sentence.
Context: ...21 token associated with a wrapped token. - Check wrapped token details: Retrieve...

(MD_PRP_QUESTION_MARK)


[style] ~35-~35: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ddress of the wrapped token contract. - Get contract's owner. **Considerations/Con...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


48-50: Address style issues for clarity.

Add a period after "etc" and consider using a hyphen for "third-party."

- (Ex. Will this ADO need to work with anything off chain, a different app, etc?):**
+ (Ex. Will this ADO need to work with anything off-chain, a different app, etc.?):**
Tools
LanguageTool

[uncategorized] ~48-~48: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...al intervention. **Any Dependencies or Third Party Integrations? (Ex. Will this ADO need t...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[style] ~48-~48: In American English, abbreviations like “etc.” require a period.
Context: ...th anything off chain, a different app, etc?):** - CW721 Standard Contract: Depende...

(ETC_PERIOD)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 984da74 and fdc922b.

Files selected for processing (1)
  • wrapped-cw721/README.md (1 hunks)
Additional context used
LanguageTool
wrapped-cw721/README.md

[style] ~2-~2: The phrase “a variety of” may be wordy. To make your writing clearer, consider replacing it.
Context: ... unwrapping. This functionality enables a variety of use cases, such as creating temporary r...

(A_VARIETY_OF)


[typographical] ~8-~8: Should there be a question mark at the end of this sentence?
Context: ...* I am planning to build this ADO myself. **Credits/Associations - Is this ADO b...

(MISSING_QUESTION_MARK2)


[uncategorized] ~13-~13: If this is a question, use a question mark.
Context: ...n idea of the ADO and how/why it is used.** - CW721 Documentation(https://docs.an...

(QUESTION_MARK)


[typographical] ~30-~30: Except for inverted sentences, ‘will you’ requires a question mark at the end of the sentence.
Context: ...21 token associated with a wrapped token. - Check wrapped token details: Retrieve...

(MD_PRP_QUESTION_MARK)


[style] ~35-~35: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ddress of the wrapped token contract. - Get contract's owner. **Considerations/Con...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[uncategorized] ~48-~48: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...al intervention. **Any Dependencies or Third Party Integrations? (Ex. Will this ADO need t...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[style] ~48-~48: In American English, abbreviations like “etc.” require a period.
Context: ...th anything off chain, a different app, etc?):** - CW721 Standard Contract: Depende...

(ETC_PERIOD)

Markdownlint
wrapped-cw721/README.md

14-14: null
Bare URL used

(MD034, no-bare-urls)


15-15: null
Bare URL used

(MD034, no-bare-urls)


16-16: null
Bare URL used

(MD034, no-bare-urls)

Additional comments not posted (4)
wrapped-cw721/README.md (4)

4-5: Well-written section!

The explanation of the ADO's standalone and integrated capabilities is clear and concise.


10-11: Clear and informative section!

The credits and associations are clearly mentioned, providing useful context.


37-41: Comprehensive considerations!

The considerations and concerns are well-addressed, ensuring robust security and integrity.


43-47: Forward-thinking enhancements!

The suggested future work and iterations are clear and forward-thinking.

Copy link

@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

Outside diff range, codebase verification and nitpick comments (1)
wrapped-cw721/schema/raw/response_to_permissions.json (1)

16-16: Clarify enum description formatting.

The description for the Permission enum is quite detailed but could benefit from improved formatting for readability. Consider using markdown lists or clearer separation of items.

- "An enum to represent a user's permission for an action\n\n- **Blacklisted** - The user cannot perform the action until after the provided expiration - **Limited** - The user can perform the action while uses are remaining and before the provided expiration **for a permissioned action** - **Whitelisted** - The user can perform the action until the provided expiration **for a permissioned action**\n\nExpiration defaults to `Never` if not provided"
+ "An enum to represent a user's permission for an action:\n\n- **Blacklisted**: The user cannot perform the action until after the provided expiration.\n- **Limited**: The user can perform the action while uses are remaining and before the provided expiration for a permissioned action.\n- **Whitelisted**: The user can perform the action until the provided expiration for a permissioned action.\n\nExpiration defaults to `Never` if not provided."
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fdc922b and d6d3714.

Files selected for processing (22)
  • wrapped-cw721/.gitignore (1 hunks)
  • wrapped-cw721/schema/andromeda-wrapped-cw721.json (1 hunks)
  • wrapped-cw721/schema/cw721receive.json (1 hunks)
  • wrapped-cw721/schema/raw/execute.json (1 hunks)
  • wrapped-cw721/schema/raw/instantiate.json (1 hunks)
  • wrapped-cw721/schema/raw/query.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_app_contract.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_block_height_upon_creation.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_get_authorized_token_addresses.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_get_origin_cw721.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_get_wrapped_cw721.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_get_wrapped_nft_address.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_get_wrapped_nft_count.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_is_unwrappable.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_kernel_address.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_original_publisher.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_owner.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_ownership_request.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_permissioned_actions.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_permissions.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_type.json (1 hunks)
  • wrapped-cw721/schema/raw/response_to_version.json (1 hunks)
Files skipped from review due to trivial changes (9)
  • wrapped-cw721/.gitignore
  • wrapped-cw721/schema/raw/response_to_block_height_upon_creation.json
  • wrapped-cw721/schema/raw/response_to_get_wrapped_nft_count.json
  • wrapped-cw721/schema/raw/response_to_is_unwrappable.json
  • wrapped-cw721/schema/raw/response_to_original_publisher.json
  • wrapped-cw721/schema/raw/response_to_owner.json
  • wrapped-cw721/schema/raw/response_to_permissioned_actions.json
  • wrapped-cw721/schema/raw/response_to_type.json
  • wrapped-cw721/schema/raw/response_to_version.json
Additional comments not posted (21)
wrapped-cw721/schema/raw/response_to_get_wrapped_nft_address.json (1)

1-7: Ensure regex pattern correctness and clarity.

The regex pattern is quite complex and aims to validate different formats of addresses. Ensure it has been thoroughly tested to match all intended address formats and does not allow unintended ones. Consider adding examples in the description for better clarity.

wrapped-cw721/schema/raw/response_to_get_authorized_token_addresses.json (1)

1-17: Validate nullable array handling.

The schema correctly allows for a nullable array of AndrAddr objects. Ensure that the handling of null values is consistent with the application's logic and does not lead to unexpected behavior.

wrapped-cw721/schema/raw/response_to_app_contract.json (1)

1-20: Confirm Addr description accuracy and usage.

The description of Addr is detailed and informative. Verify that it accurately reflects the intended use within the application and that all necessary constraints are enforced by the schema.

wrapped-cw721/schema/raw/response_to_kernel_address.json (1)

1-20: Schema is well-structured and follows best practices.

The JSON schema is correctly defined with a clear structure and detailed documentation for the Addr type. The use of $ref for reusable components and additionalProperties: false for strict validation are good practices.

wrapped-cw721/schema/raw/response_to_get_origin_cw721.json (1)

1-25: Schema is well-structured and follows best practices.

The JSON schema is correctly defined with a clear structure and includes a detailed pattern for the AndrAddr type. The use of $ref for reusable components and additionalProperties: false for strict validation are good practices.

wrapped-cw721/schema/raw/response_to_get_wrapped_cw721.json (1)

1-25: Schema is well-structured and follows best practices.

The JSON schema is correctly defined with a clear structure and includes a detailed pattern for the AndrAddr type. The use of $ref for reusable components and additionalProperties: false for strict validation are good practices.

wrapped-cw721/schema/raw/instantiate.json (1)

1-36: Schema is well-defined and adheres to standards.

The JSON schema for InstantiateMsg is correctly structured. It includes necessary properties and uses the AndrAddr definition for address validation. The use of additionalProperties: false ensures no extra properties are allowed, which is a good practice for strict schema validation.

wrapped-cw721/schema/raw/response_to_ownership_request.json (1)

1-40: Schema is well-defined and adheres to standards.

The JSON schema for ContractPotentialOwnerResponse is correctly structured. It uses anyOf to handle nullable properties and includes detailed definitions for Addr and Milliseconds. The use of additionalProperties: false ensures strict schema validation.

wrapped-cw721/schema/cw721receive.json (1)

1-71: Schema is well-defined and adheres to standards.

The JSON schema for CW721 receive messages is correctly structured. It uses oneOf to define mutually exclusive message types and includes necessary properties for each type. The AndrAddr definition is used for address validation, and additionalProperties: false ensures strict schema validation.

wrapped-cw721/schema/raw/response_to_permissions.json (2)

2-2: Ensure correct schema version usage.

The schema uses draft-07, which is generally fine, but ensure compatibility with any tools or libraries you are using that may require a different version.


91-110: Ensure completeness of PermissionInfo properties.

The PermissionInfo object requires action, actor, and permission. Ensure these fields are sufficient for all intended use cases and consider if additional metadata might be needed.

wrapped-cw721/schema/raw/query.json (3)

2-2: Ensure correct schema version usage.

The schema uses draft-07, which is generally fine, but ensure compatibility with any tools or libraries you are using that may require a different version.


4-271: Verify query message structure and coverage.

The QueryMsg schema includes multiple query types. Ensure that all necessary queries for the wrapped CW721 functionality are covered and that the structure aligns with the expected contract queries.


273-277: Validate AndrAddr pattern complexity.

The regex pattern for AndrAddr is complex. Ensure that it accurately captures all valid address formats and test it against expected inputs to confirm its correctness.

wrapped-cw721/schema/raw/execute.json (3)

2-2: Ensure correct schema version usage.

The schema uses draft-07, which is generally fine, but ensure compatibility with any tools or libraries you are using that may require a different version.


4-116: Verify execute message structure and coverage.

The ExecuteMsg schema includes multiple execution types. Ensure that all necessary operations for the wrapped CW721 functionality are covered and that the structure aligns with the expected contract executions.


241-260: Review AMPPkt message batching logic.

The AMPPkt allows for message batching. Ensure that this logic is correctly implemented in the contract and that the schema accurately reflects the expected data structure.

wrapped-cw721/schema/andromeda-wrapped-cw721.json (4)

5-40: Instantiation Message Schema is Well-Defined.

The instantiation message schema correctly specifies the required fields and uses appropriate types for each property. The use of AndrAddr for addresses is consistent with the Andromeda ecosystem.


41-155: Execution Message Schema is Comprehensive.

The execution message schema effectively uses oneOf to manage multiple message types. Each message type is well-defined with its own required fields and properties.


631-900: Query Message Schema is Thorough.

The query message schema is well-structured, with clear definitions for various query types. Each query type has specific required fields and properties, providing a comprehensive interface for querying the contract's state.


912-1271: Response Schema is Detailed and Consistent.

The response schema is well-defined, with appropriate use of references to defined types. It includes all necessary fields for each response type, ensuring consistency and completeness.

"description": "Represents time in milliseconds.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
Copy link

Choose a reason for hiding this comment

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

Check integer type minimum value.

The minimum value for integer types is set to 0.0, which should be an integer (0) instead. JSON Schema expects integer values for integer types.

- "minimum": 0.0
+ "minimum": 0

Also applies to: 62-62

Comment on lines +327 to +331
"Milliseconds": {
"description": "Represents time in milliseconds.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
Copy link

Choose a reason for hiding this comment

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

Check integer type minimum value.

The minimum value for integer types is set to 0.0, which should be an integer (0) instead. JSON Schema expects integer values for integer types.

- "minimum": 0.0
+ "minimum": 0
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Milliseconds": {
"description": "Represents time in milliseconds.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
"Milliseconds": {
"description": "Represents time in milliseconds.",
"type": "integer",
"format": "uint64",
"minimum": 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADO Submission Submission of an ADO
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant