-
Notifications
You must be signed in to change notification settings - Fork 19
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
refactor: remove unused oracle addresses #125
Conversation
WalkthroughThe update primarily involves a version increment and refactoring related to oracle integration across various components of a staking contract. Key changes include the removal of redundant oracle address fields, simplification of function parameters, and introduction of a new migration module to handle transitions between contract versions. The restructuring enhances modularity and clarity, focusing on streamlined configurations and error handling. Changes
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 Configration File (
|
@@ -2,7 +2,7 @@ | |||
members = ["contracts/*", "packages/*"] | |||
|
|||
[workspace.package] | |||
version = "0.4.18" | |||
version = "0.4.19" |
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.
I have bumped this just to have an higher version and test everithing. Let me know if I should change it.
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
Out of diff range and nitpick comments (1)
contracts/staking/src/execute.rs (1)
Line range hint
94-117
: Modified functionupdate_oracle_msgs
to remove old oracle addresses and use neworacle_address
.- contract: config.oracle_contract_address.clone().unwrap().to_string(), + contract: config.oracle_address.clone().unwrap().to_string(),Ensure that the new
oracle_address
is correctly used and initialized elsewhere in the codebase to prevent runtime errors.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (11)
- Cargo.toml (1 hunks)
- contracts/staking/src/contract.rs (9 hunks)
- contracts/staking/src/error.rs (2 hunks)
- contracts/staking/src/execute.rs (8 hunks)
- contracts/staking/src/lib.rs (1 hunks)
- contracts/staking/src/migrations/mod.rs (1 hunks)
- contracts/staking/src/migrations/v0_4_19.rs (1 hunks)
- contracts/staking/src/msg.rs (3 hunks)
- contracts/staking/src/state.rs (2 hunks)
- contracts/staking/src/tests/instantiate_tests.rs (5 hunks)
- contracts/staking/src/tests/test_helper.rs (1 hunks)
Files skipped from review due to trivial changes (5)
- Cargo.toml
- contracts/staking/src/lib.rs
- contracts/staking/src/migrations/mod.rs
- contracts/staking/src/tests/instantiate_tests.rs
- contracts/staking/src/tests/test_helper.rs
Additional comments not posted (10)
contracts/staking/src/migrations/v0_4_19.rs (2)
11-39
: The definition of thev0_4_18_state
module with the deprecated fields clearly marked and the use ofItem
forCONFIG
is appropriate and follows CosmWasm conventions.
41-69
: Themigrate
function correctly asserts the contract version, transforms the configuration from the old to the new format, and constructs a response that is informative of the migration action and versions involved.contracts/staking/src/error.rs (1)
136-137
: The addition of theVersion
error type is appropriate and aligns with the new migration logic that involves version checks. UsingVersionError
fromcw2
ensures standardized error handling.contracts/staking/src/state.rs (1)
Line range hint
1-14
: The modifications to theConfig
struct, including the removal of deprecated oracle addresses and the adjustment of field order, align with the PR's objectives to simplify and update the contract's configuration.contracts/staking/src/msg.rs (1)
195-197
: The transformation ofMigrateMsg
from a struct to an enum to handle different migration scenarios, starting withV0_4_18ToV0_4_19
, is a significant improvement that enhances the flexibility and clarity of migration handling.contracts/staking/src/contract.rs (1)
38-39
: Changing the visibility ofCONTRACT_NAME
andCONTRACT_VERSION
to public is appropriate as it allows for consistent version handling across different modules of the contract.contracts/staking/src/execute.rs (4)
7-7
: Import ofOracle
is added.This change aligns with the PR's objective to refactor oracle usage.
15-16
: Updated imports to includeSubMsg
,SubMsgResponse
, andSubMsgResult
.These changes are necessary for the new sub-message handling logic introduced in other parts of the code.
Line range hint
94-117
: Refactoredupdate_oracle_msgs
to use the neworacle_address
from the config.This change is consistent with the PR's objective to streamline oracle interactions and remove outdated addresses.
459-459
: Added a call toadd_messages
to concatenate messages and oracle updates inexecute_withdraw
.This change ensures that all necessary messages are sent together, improving the function's efficiency and clarity.
@@ -9,7 +9,6 @@ pub struct Config { | |||
pub native_token_denom: String, | |||
pub liquid_stake_token_denom: String, | |||
pub treasury_address: Addr, | |||
pub operators: Option<Vec<Addr>>, //depr |
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.
I have removed also this since was marked as deprecated
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.
LGTM!
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.
Looks good to me!
Overview
This PR removes all references to the old oracles from the messages and the contract config.
Additionally, to properly remove the old oracle addresses from the config, the migration logic has been updated and
the
MsgMigrate
has been converted to an enum to support future migration logics.To migrate the contract from the version
v0.4.18
the following migrate message must be sent:{ "v0_4_18_to_v0_4_19": {} }
closes: MILKTIA-32
What changes have been made in this PR?
Checklist