Open mdjakovic0920 opened 3 weeks ago
[!NOTE] Currently processing new changes in this PR. This may take a few minutes, please wait...
Commits
Files that changed from the base of the PR and between 5dc7e606016509086c8fb975c3044a4c4d9840bd and e86b8db844c7cd03bdb23438d5052fa960e6888e.Files selected for processing (3)
* cw721-timelock/src/contract.rs (1 hunks) * cw721-timelock/src/state.rs (1 hunks) * cw721-timelock/src/testing/tests.rs (1 hunks)________________________________________________________________________________________________________________________________________ < Use assertions to prevent the impossible. Assertions validate your assumptions. Use them to protect your code from an uncertain world. > ---------------------------------------------------------------------------------------------------------------------------------------- \ \ \ \ /\ ( ) .( o ).
The updates introduce a CW721 Timelock functionality to lock and claim NFTs within smart contracts. Key modifications include new configuration files for Cargo and CI/CD, added dependencies, message and state logic for NFT timelocks, and extensive test coverage for various scenarios.
Files/Groups | Change Summary |
---|---|
.cargo/config |
Introduced command aliases for build and test operations for convenience. |
.circleci/config.yml , .github/workflows |
Added CircleCI and GitHub Actions configurations for building, testing, and releasing Docker images and WASM artifacts. |
.editorconfig , .gitignore , LICENSE , NOTICE |
Added configuration, ignore rules, and license/notice files for better project management. |
Cargo.toml |
Updated with new dependencies, features, and configurations for the Rust project. |
README.md |
Added documentation outlining CW721 Timelock functionality and usage. |
examples/schema.rs |
Introduced schema generation for contract messages. |
src/contract.rs , src/lib.rs , src/msg.rs , src/state.rs |
Added core logic for contract instantiation, execution, state management, and message handling. |
src/testing |
Added test cases covering various scenarios such as instantiation, timelocks, claims, and NFT detail queries. |
sequenceDiagram
participant User
participant Contract
participant State
participant CW721Contract
User->>+Contract: Instantiate contract with authorized addresses
Contract->>State: Initialize state
User->>+Contract: Receive NFT and lock it
Contract->>State: Save timelock details
User->>+Contract: Claim NFT after lock expires
Contract->>State: Verify lock expiration
Contract->>+CW721Contract: Transfer NFT to user
CW721Contract->>-User: NFT received
User->>+Contract: Query NFT details
Contract->>State: Retrieve timelock info
Contract->>-User: Respond with NFT details and unlock time
In fields of code, we hop with glee, Unraveling secrets, bit by bit, Unlocking NFTs, let time run free, Claim your treasures, if they fit! With tests so robust and CI so neat, Our journey's complete, oh what a feat!
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?
Looks good to me, would be nice to have it tried on testnet. With each step documented along its tx
.
Contact Information
Summary: With the CW721 Timelock, you can lock an NFT (CW721) with a contract for a certain amount of time (currently between one day & one year). Once the timelock has expired, anyone can call the claim function to send the NFT to the defined recipient. Each locked NFT has a specific lock ID comprising the CW721 contract address concatenated with the token_id.
This is the solution of https://github.com/andromedaprotocol/ado-database/issues/7
Messages
Instantiation (What is specified and stored at instantiation)
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)
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.
cw721_contract: The address of the CW721 contract. token_id: The ID of the token to be claimed.
Query Messages (What are the messages that can be queried, what does each return)
cw721_contract: The address of the CW721 contract. token_id: The ID of the token.
Returns:
unlock_time: The time at which the NFT can be claimed.
cw721_contract: The address of the CW721 contract. token_id: The ID of the token.
Returns:
unlock_time: The time at which the NFT can be claimed. recipient: The address of the recipient who can claim the NFT after the unlock time.
State
The contract maintains the following state:
TimelockInfo: Structure holding the unlock time and the recipient address for each locked NFT. TIMELOCKS: A mapping from token IDs to their respective TimelockInfo.
This state ensures that each NFT has its own lock period and designated recipient.
Summary by CodeRabbit