-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add migration for staked astro incentives (#187) * add migration for staked astro incentives * tidy * MP-2780. Perps migration (#188) * Update address-provider migration. * Update migration for account-nft. * Update credit-manager migration. * Update health migration. * Update incentives migration. * Update oracle migration. * Update red-bank migration. * Update rewards-collector migration. * Update swapper migration. * Update zapper migration. * Prepare params migration. * Update incentives state migration. * Update how we handle withdraw_enabled for RB. * Fix for missing init for next order id. (#189) * Fix for missing init for next order id. * Update audit. --------- Co-authored-by: Mark Watney <[email protected]>
- Loading branch information
1 parent
f59d3a7
commit 90ae9b0
Showing
73 changed files
with
1,103 additions
and
1,273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod contract; | ||
pub mod error; | ||
pub mod execute; | ||
pub mod migrations; | ||
pub mod query; | ||
pub mod state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod v2_2_0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use cosmwasm_std::{attr, testing::mock_env, Empty, Event}; | ||
use cw2::{ContractVersion, VersionError}; | ||
use mars_account_nft::{contract::migrate, error::ContractError}; | ||
use mars_testing::mock_dependencies; | ||
|
||
#[test] | ||
fn wrong_contract_name() { | ||
let mut deps = mock_dependencies(&[]); | ||
cw2::set_contract_version(deps.as_mut().storage, "contract_xyz", "2.1.0").unwrap(); | ||
|
||
let err = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap_err(); | ||
|
||
assert_eq!( | ||
err, | ||
ContractError::Version(VersionError::WrongContract { | ||
expected: "crates.io:mars-account-nft".to_string(), | ||
found: "contract_xyz".to_string() | ||
}) | ||
); | ||
} | ||
|
||
#[test] | ||
fn wrong_contract_version() { | ||
let mut deps = mock_dependencies(&[]); | ||
cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-account-nft", "4.1.0") | ||
.unwrap(); | ||
|
||
let err = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap_err(); | ||
|
||
assert_eq!( | ||
err, | ||
ContractError::Version(VersionError::WrongVersion { | ||
expected: "2.1.0".to_string(), | ||
found: "4.1.0".to_string() | ||
}) | ||
); | ||
} | ||
|
||
#[test] | ||
fn successful_migration() { | ||
let mut deps = mock_dependencies(&[]); | ||
cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-account-nft", "2.1.0") | ||
.unwrap(); | ||
|
||
let res = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap(); | ||
|
||
assert_eq!(res.messages, vec![]); | ||
assert_eq!(res.events, vec![] as Vec<Event>); | ||
assert!(res.data.is_none()); | ||
assert_eq!( | ||
res.attributes, | ||
vec![attr("action", "migrate"), attr("from_version", "2.1.0"), attr("to_version", "2.2.0")] | ||
); | ||
|
||
let new_contract_version = ContractVersion { | ||
contract: "crates.io:mars-account-nft".to_string(), | ||
version: "2.2.0".to_string(), | ||
}; | ||
assert_eq!(cw2::get_contract_version(deps.as_ref().storage).unwrap(), new_contract_version); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pub mod v2_0_0; | ||
pub mod v2_2_0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use cosmwasm_std::{DepsMut, Response}; | ||
use cw2::{assert_contract_version, set_contract_version}; | ||
|
||
use crate::{ | ||
contract::{CONTRACT_NAME, CONTRACT_VERSION}, | ||
error::ContractError, | ||
}; | ||
|
||
const FROM_VERSION: &str = "2.1.0"; | ||
|
||
pub fn migrate(deps: DepsMut) -> Result<Response, ContractError> { | ||
// make sure we're migrating the correct contract and from the correct version | ||
assert_contract_version(deps.storage, &format!("crates.io:{CONTRACT_NAME}"), FROM_VERSION)?; | ||
|
||
set_contract_version(deps.storage, format!("crates.io:{CONTRACT_NAME}"), CONTRACT_VERSION)?; | ||
|
||
Ok(Response::new() | ||
.add_attribute("action", "migrate") | ||
.add_attribute("from_version", FROM_VERSION) | ||
.add_attribute("to_version", CONTRACT_VERSION)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod v2_2_0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use cosmwasm_std::{DepsMut, Response}; | ||
use cw2::{assert_contract_version, set_contract_version}; | ||
|
||
use crate::{ | ||
contract::{CONTRACT_NAME, CONTRACT_VERSION}, | ||
error::ContractError, | ||
state::NEXT_TRIGGER_ID, | ||
}; | ||
|
||
const FROM_VERSION: &str = "2.1.0"; | ||
|
||
pub fn migrate(deps: DepsMut) -> Result<Response, ContractError> { | ||
// make sure we're migrating the correct contract and from the correct version | ||
assert_contract_version(deps.storage, &format!("crates.io:{CONTRACT_NAME}"), FROM_VERSION)?; | ||
|
||
NEXT_TRIGGER_ID.save(deps.storage, &1)?; | ||
|
||
set_contract_version(deps.storage, format!("crates.io:{CONTRACT_NAME}"), CONTRACT_VERSION)?; | ||
|
||
Ok(Response::new() | ||
.add_attribute("action", "migrate") | ||
.add_attribute("from_version", FROM_VERSION) | ||
.add_attribute("to_version", CONTRACT_VERSION)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use cosmwasm_std::{attr, testing::mock_env, Empty, Event}; | ||
use cw2::{ContractVersion, VersionError}; | ||
use mars_credit_manager::{contract::migrate, error::ContractError, state::NEXT_TRIGGER_ID}; | ||
use mars_testing::mock_dependencies; | ||
|
||
#[test] | ||
fn wrong_contract_name() { | ||
let mut deps = mock_dependencies(&[]); | ||
cw2::set_contract_version(deps.as_mut().storage, "contract_xyz", "2.1.0").unwrap(); | ||
|
||
let err = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap_err(); | ||
|
||
assert_eq!( | ||
err, | ||
ContractError::Version(VersionError::WrongContract { | ||
expected: "crates.io:mars-credit-manager".to_string(), | ||
found: "contract_xyz".to_string() | ||
}) | ||
); | ||
} | ||
|
||
#[test] | ||
fn wrong_contract_version() { | ||
let mut deps = mock_dependencies(&[]); | ||
cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-credit-manager", "4.1.0") | ||
.unwrap(); | ||
|
||
let err = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap_err(); | ||
|
||
assert_eq!( | ||
err, | ||
ContractError::Version(VersionError::WrongVersion { | ||
expected: "2.1.0".to_string(), | ||
found: "4.1.0".to_string() | ||
}) | ||
); | ||
} | ||
|
||
#[test] | ||
fn successful_migration() { | ||
let mut deps = mock_dependencies(&[]); | ||
cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-credit-manager", "2.1.0") | ||
.unwrap(); | ||
|
||
let res = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap(); | ||
|
||
let order_id = NEXT_TRIGGER_ID.load(deps.as_ref().storage).unwrap(); | ||
assert_eq!(order_id, 1); | ||
|
||
assert_eq!(res.messages, vec![]); | ||
assert_eq!(res.events, vec![] as Vec<Event>); | ||
assert!(res.data.is_none()); | ||
assert_eq!( | ||
res.attributes, | ||
vec![attr("action", "migrate"), attr("from_version", "2.1.0"), attr("to_version", "2.2.0")] | ||
); | ||
|
||
let new_contract_version = ContractVersion { | ||
contract: "crates.io:mars-credit-manager".to_string(), | ||
version: "2.2.0".to_string(), | ||
}; | ||
assert_eq!(cw2::get_contract_version(deps.as_ref().storage).unwrap(), new_contract_version); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod compute; | ||
pub mod contract; | ||
pub mod migrations; | ||
pub mod querier; | ||
pub mod state; | ||
pub mod update_config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod v2_2_0; |
Oops, something went wrong.