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

Update contract to provwasm 2.0 #7

Merged
merged 6 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,216 changes: 1,032 additions & 184 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions crates/contract-controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ incremental = false
overflow-checks = true

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

Expand All @@ -45,20 +43,20 @@ optimize-arm = """docker run --rm -v "$(pwd)":/code \
"""

[dependencies]
provwasm-std = { version = "1.1.0" }
cw-utils = {version = "1.0.1"}
cosmwasm-schema = "1.1.3"
cosmwasm-std = { version = "1.1.3", features = ["cosmwasm_1_1"] }
cosmwasm-storage = "1.1.3"
cw-storage-plus = { version = "1.0.1", features = ["iterator"]}
cw2 = "1.0.1"
provwasm-std = { version = "2.3.0" }
cw-utils = {version = "2.0.0"}
cosmwasm-schema = "2.1.3"
cosmwasm-std = { version = "2.1.3" }
cosmwasm-storage = "1.5.2"
cw-storage-plus = { version = "2.0.0", features = ["iterator"]}
cw2 = "2.0.0"
schemars = "0.8.10"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.31" }
semver = "1"

[dev-dependencies]
provwasm-mocks = { version = "1.1.0" }
provwasm-mocks = { version = "2.3.0" }
cw-multi-test = "0.16.2"
prost = "0.11.0"
anyhow = "1.0.65"
8 changes: 1 addition & 7 deletions crates/contract-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,4 @@ ifeq ($(UNAME_M),arm64)
@docker run --rm -v $(CURDIR):/code \
--mount type=volume,source="contract_controller_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer-arm64:0.12.8
else
@docker run --rm -v $(CURDIR):/code \
--mount type=volume,source="contract_controller_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.8
endif
cosmwasm/rust-optimizer:0.16.0
11 changes: 5 additions & 6 deletions crates/contract-controller/src/core/aliases.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use cosmwasm_std::{Binary, CosmosMsg, Deps, DepsMut, Response, SubMsg};
use provwasm_std::{ProvenanceMsg, ProvenanceQuery};

use super::error::ContractError;

pub type ProvDeps<'a> = Deps<'a, ProvenanceQuery>;
pub type ProvDepsMut<'a> = DepsMut<'a, ProvenanceQuery>;
pub type ProvTxResponse = Result<Response<ProvenanceMsg>, ContractError>;
pub type ProvDeps<'a> = Deps<'a>;
pub type ProvDepsMut<'a> = DepsMut<'a>;
pub type ProvTxResponse = Result<Response, ContractError>;
pub type ProvQueryResponse = Result<Binary, ContractError>;
pub type ProvMsg = CosmosMsg<ProvenanceMsg>;
pub type ProvSubMsg = SubMsg<ProvenanceMsg>;
pub type ProvMsg = CosmosMsg;
pub type ProvSubMsg = SubMsg;
12 changes: 6 additions & 6 deletions crates/contract-controller/src/execute/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Validate for ExecuteMsg {

#[cfg(test)]
mod tests {
use cosmwasm_std::Coin;
use cosmwasm_std::{Coin, Uint128};

use crate::{
core::error::ContractError,
Expand Down Expand Up @@ -76,7 +76,7 @@ mod tests {
fn test_add_contracts_should_not_have_funds() {
let message = test_add_contracts_message();
let error = message
.validate_msg_funds(&[Coin::new(5, "nhash")])
.validate_msg_funds(&[Coin::new(Uint128::new(5), "nhash")])
.unwrap_err();
assert_eq!(
ContractError::UnexpectedFunds {}.to_string(),
Expand Down Expand Up @@ -110,7 +110,7 @@ mod tests {
fn test_remove_contracts_should_not_have_funds() {
let message = test_remove_contracts_message();
let error = message
.validate_msg_funds(&[Coin::new(5, "nhash")])
.validate_msg_funds(&[Coin::new(Uint128::new(5), "nhash")])
.unwrap_err();
assert_eq!(
ContractError::UnexpectedFunds {}.to_string(),
Expand Down Expand Up @@ -144,7 +144,7 @@ mod tests {
fn test_migrate_contracts_should_not_have_funds() {
let message = test_migrate_contracts_message();
let error = message
.validate_msg_funds(&[Coin::new(5, "nhash")])
.validate_msg_funds(&[Coin::new(Uint128::new(5), "nhash")])
.unwrap_err();
assert_eq!(
ContractError::UnexpectedFunds {}.to_string(),
Expand All @@ -168,7 +168,7 @@ mod tests {
fn test_migrate_all_contracts_should_not_have_funds() {
let message = test_migrate_all_contracts_message();
let error = message
.validate_msg_funds(&[Coin::new(5, "nhash")])
.validate_msg_funds(&[Coin::new(Uint128::new(5), "nhash")])
.unwrap_err();
assert_eq!(
ContractError::UnexpectedFunds {}.to_string(),
Expand All @@ -192,7 +192,7 @@ mod tests {
fn test_modify_batch_size_should_not_have_funds() {
let message = test_modify_batch_size_message();
let error = message
.validate_msg_funds(&[Coin::new(5, "nhash")])
.validate_msg_funds(&[Coin::new(Uint128::new(5), "nhash")])
.unwrap_err();
assert_eq!(
ContractError::UnexpectedFunds {}.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions crates/contract-controller/src/instantiate/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod tests {
Attribute,
};
use cw2::get_contract_version;
use provwasm_mocks::mock_dependencies;
use provwasm_mocks::mock_provenance_dependencies;

use crate::{
core::constants::{CONTRACT_NAME, CONTRACT_VERSION},
Expand All @@ -41,7 +41,7 @@ mod tests {

#[test]
fn test_proper_instantiation() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let info = mock_info("sender", &[]);
let msg = test_init_message();
Expand Down
4 changes: 2 additions & 2 deletions crates/contract-controller/src/instantiate/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Validate for InstantiateMsg {

#[cfg(test)]
mod tests {
use cosmwasm_std::Coin;
use cosmwasm_std::{Coin, Uint128};

use crate::{
core::error::ContractError,
Expand All @@ -37,7 +37,7 @@ mod tests {
fn test_funds_throw_error() {
let message = test_init_message();
let error = message
.validate_msg_funds(&[Coin::new(50, "nhash")])
.validate_msg_funds(&[Coin::new(Uint128::new(50), "nhash")])
.unwrap_err();
assert_eq!(
ContractError::UnexpectedFunds {}.to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn handle(storage: &dyn Storage, uuid: String) -> ProvQueryResponse {
#[cfg(test)]
mod tests {
use cosmwasm_std::{from_binary, testing::mock_env, Addr};
use provwasm_mocks::mock_dependencies;
use provwasm_mocks::mock_provenance_dependencies;

use crate::{
core::msg::QueryContractAddressResponse,
Expand All @@ -25,7 +25,7 @@ mod tests {

#[test]
fn test_query_contracts_handles_invalid() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let _ = instantiate_contract(deps.as_mut(), env).unwrap();
handle(&deps.storage, "bad_address".to_string()).unwrap_err();
Expand Down
4 changes: 2 additions & 2 deletions crates/contract-controller/src/query/query_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn handle(storage: &dyn Storage) -> ProvQueryResponse {
#[cfg(test)]
mod tests {
use cosmwasm_std::{from_binary, testing::mock_env, Addr};
use provwasm_mocks::mock_dependencies;
use provwasm_mocks::mock_provenance_dependencies;

use crate::{
core::msg::QueryContractsResponse,
Expand All @@ -25,7 +25,7 @@ mod tests {

#[test]
fn test_query_contracts_handles_empty() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let _ = instantiate_contract(deps.as_mut(), env).unwrap();
let bin_response = handle(&deps.storage).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/contract-controller/src/query/query_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn handle(storage: &dyn Storage) -> ProvQueryResponse {
#[cfg(test)]
mod tests {
use cosmwasm_std::{from_binary, testing::mock_env, Uint128};
use provwasm_mocks::mock_dependencies;
use provwasm_mocks::mock_provenance_dependencies;

use crate::{
core::msg::QueryStateResponse, query::query_state::handle,
Expand All @@ -26,7 +26,7 @@ mod tests {

#[test]
fn test_query_state_has_correct_default_values() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let _ = instantiate_contract(deps.as_mut(), env).unwrap();
let bin_response = handle(&deps.storage).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/contract-controller/src/query/query_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn handle(storage: &dyn Storage) -> ProvQueryResponse {
#[cfg(test)]
mod tests {
use cosmwasm_std::{from_binary, testing::mock_env};
use provwasm_mocks::mock_dependencies;
use provwasm_mocks::mock_provenance_dependencies;

use crate::{
core::{
Expand All @@ -27,7 +27,7 @@ mod tests {

#[test]
fn test_query_version_has_correct_version() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let _ = instantiate_contract(deps.as_mut(), env).unwrap();
let bin_response = handle(&deps.storage).unwrap();
Expand Down
8 changes: 4 additions & 4 deletions crates/contract-controller/src/query/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn route(deps: ProvDeps, _env: Env, msg: QueryMsg) -> ProvQueryResponse {
#[cfg(test)]
mod tests {
use cosmwasm_std::{from_binary, testing::mock_env};
use provwasm_mocks::mock_dependencies;
use provwasm_mocks::mock_provenance_dependencies;

use crate::{
core::msg::{
Expand All @@ -34,7 +34,7 @@ mod tests {

#[test]
fn test_query_version_has_correct_response() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let message = QueryMsg::QueryVersion {};
instantiate_contract(deps.as_mut(), env.clone()).unwrap();
Expand All @@ -44,7 +44,7 @@ mod tests {

#[test]
fn test_query_state_has_correct_response() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let message = QueryMsg::QueryState {};
instantiate_contract(deps.as_mut(), env.clone()).unwrap();
Expand All @@ -54,7 +54,7 @@ mod tests {

#[test]
fn test_query_contracts_has_correct_response() {
let mut deps = mock_dependencies(&[]);
let mut deps = mock_provenance_dependencies();
let env = mock_env();
let message = QueryMsg::QueryContracts {};
instantiate_contract(deps.as_mut(), env.clone()).unwrap();
Expand Down
Loading
Loading