Skip to content

Conversation

@justinbarry
Copy link
Contributor

This pull request introduces support for managing params in the Treasury contract by adding it to the instantiation process, validating it, and enabling updates. The changes span multiple files and functions to ensure proper integration and validation of the new params field.

Enhancements to params management:

  • Added params to instantiation:

    • Updated pub fn instantiate in contracts/treasury/src/contract.rs to include msg.params in the instantiation process.
    • Modified the InstantiateMsg struct in contracts/treasury/src/msg.rs to include a new params field.
  • Validation and storage of params:

    • Introduced validate_params function in contracts/treasury/src/execute.rs to validate URLs and metadata in the params field.
    • Updated pub fn init in contracts/treasury/src/execute.rs to validate and store params during initialization.
  • Support for updating params:

    • Refactored pub fn update_params in contracts/treasury/src/execute.rs to include validation using the new validate_params function before saving updated params.

@justinbarry justinbarry requested review from ash-burnt and Copilot May 8, 2025 22:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for managing a new params field in the Treasury contract instantiation, validation, and update processes.

  • Adds params field to the InstantiateMsg struct.
  • Updates the instantiation and init functions to validate and store params.
  • Refactors update_params to reuse the newly introduced validate_params helper.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
contracts/treasury/src/msg.rs Added the params field to InstantiateMsg.
contracts/treasury/src/execute.rs Introduced validate_params and updated init and update_params to include params validation/storage.
contracts/treasury/src/contract.rs Updated instantiation to forward msg.params correctly.
Comments suppressed due to low confidence (1)

contracts/treasury/src/execute.rs:221

  • Consider validating metadata against its expected schema rather than deserializing to the unit type, to catch potential structure errors more accurately.
serde_json::from_str::<()>(params.metadata.as_str())?;

@justinbarry justinbarry merged commit 34d4d2b into fix/contract-upgrade May 14, 2025
2 checks passed
@justinbarry justinbarry deleted the update-params-and-init branch May 14, 2025 19:26
justinbarry added a commit that referenced this pull request May 23, 2025
* allow a contract to migrate itself

* expose migrate fn in contract.rs

* Require params as part of the init message (#66)

* Require params as part of the init message

* fix JSON parsing issue on metadata params validation

---------

Co-authored-by: Burnt Val <val@burnt.com>
Co-authored-by: Justin <328965+justinbarry@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants