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 to make compatible with Provenance 1.19 #131

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
990 changes: 704 additions & 286 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ats-smart-contract"
version = "1.0.0"
version = "1.0.1"
authors = ["Ken Talley <[email protected]>"]
edition = "2018"

Expand Down Expand Up @@ -28,9 +28,9 @@ overflow-checks = true
#backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-std = { version = "1.3.3" }
cw-storage-plus = { version = "1.1.0" }
provwasm-std = { version = "2.0.0" }
cosmwasm-std = { version = "2.1.0" }
jtolotti-figure marked this conversation as resolved.
Show resolved Hide resolved
cw-storage-plus = { version = "2.0.0" }
provwasm-std = { version = "2.3.0" }
rust_decimal = "1.29.0"
schemars = "0.8.11"
semver = "1.0.16"
Expand All @@ -41,5 +41,5 @@ uuid = { version = "1.3.3" }
prost = { version = "=0.11.9", default-features = false }

[dev-dependencies]
cosmwasm-schema = { version = "1.2.6" }
provwasm-mocks = { version = "2.0.0" }
cosmwasm-schema = { version = "2.1.0" }
provwasm-mocks = { version = "2.3.0" }
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ optimize:
$(CONTAINER_RUNTIME) run --rm -v $(CURDIR):/code:Z \
--mount type=volume,source=ats-smart-contract_cache,target=/code/target \
--mount type=volume,source=ats-smart-contract_registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.12
cosmwasm/rust-optimizer:0.15.0
jtolotti-figure marked this conversation as resolved.
Show resolved Hide resolved
#
.PHONY: optimize-arm
optimize-arm:
$(CONTAINER_RUNTIME) run --rm -v $(CURDIR):/code:Z \
--mount type=volume,source=ats-smart-contract_cache,target=/code/target \
--mount type=volume,source=ats-smart-contract_registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer-arm64:0.12.12
cosmwasm/rust-optimizer-arm64:0.15.0

.PHONY: install
install: optimize
Expand Down
9 changes: 3 additions & 6 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,12 +1143,9 @@ fn execute_match(
);

// subtract the fees and assign to net proceeds
net_proceeds =
net_proceeds
.checked_sub(Uint128::new(fee_total))
.map_err(|error| {
ContractError::Std(StdError::Overflow { source: error })
})?;
net_proceeds = net_proceeds
.checked_sub(Uint128::new(fee_total))
.map_err(|error| StdError::overflow(error))?;

Some(ask_fee)
}
Expand Down
33 changes: 22 additions & 11 deletions src/contract_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,17 @@ mod tests {
base_denom: "base_denom".into(),
convertible_base_denoms: vec!["con_base_1".into(), "con_base_2".into()],
supported_quote_denoms: vec!["quote_1".into(), "quote_2".into()],
approvers: vec![Addr::unchecked("approver_1"), Addr::unchecked("approver_2")],
executors: vec![Addr::unchecked("exec_1"), Addr::unchecked("exec_2")],
approvers: vec![
deps.api.addr_make("approver_1"),
deps.api.addr_make("approver_2"),
],
executors: vec![deps.api.addr_make("exec_1"), deps.api.addr_make("exec_2")],
ask_fee_info: Some(FeeInfo {
account: Addr::unchecked("ask_fee_account"),
account: deps.api.addr_make("ask_fee_account"),
rate: "0.01".into(),
}),
bid_fee_info: Some(FeeInfo {
account: Addr::unchecked("bid_fee_account"),
account: deps.api.addr_make("bid_fee_account"),
rate: "0.02".into(),
}),
ask_required_attributes: vec!["ask_tag_1".into(), "ask_tag_2".into()],
Expand All @@ -505,15 +508,20 @@ mod tests {
},
)?;

let approver_3_addr = deps.api.addr_make("approver_3").to_string();
let approver_4_addr = deps.api.addr_make("approver_4").to_string();
let new_ask_fee_account_addr = deps.api.addr_make("new_ask_fee_account").to_string();
let new_bid_fee_account_addr = deps.api.addr_make("new_bid_fee_account").to_string();

// migrate with new fees
migrate_contract_info(
deps.as_mut(),
&MigrateMsg {
approvers: Some(vec!["approver_3".into(), "approver_4".into()]),
approvers: Some(vec![approver_3_addr.clone(), approver_4_addr.clone()]),
ask_fee_rate: Some("0.03".into()),
ask_fee_account: Some("new_ask_fee_account".into()),
ask_fee_account: Some(new_ask_fee_account_addr),
bid_fee_rate: Some("0.04".into()),
bid_fee_account: Some("new_bid_fee_account".into()),
bid_fee_account: Some(new_bid_fee_account_addr),
ask_required_attributes: Some(vec!["ask_tag_3".into(), "ask_tag_4".into()]),
bid_required_attributes: Some(vec!["bid_tag_3".into(), "bid_tag_4".into()]),
},
Expand All @@ -527,14 +535,17 @@ mod tests {
base_denom: "base_denom".into(),
convertible_base_denoms: vec!["con_base_1".into(), "con_base_2".into()],
supported_quote_denoms: vec!["quote_1".into(), "quote_2".into()],
approvers: vec![Addr::unchecked("approver_3"), Addr::unchecked("approver_4")],
executors: vec![Addr::unchecked("exec_1"), Addr::unchecked("exec_2")],
approvers: vec![
deps.api.addr_make("approver_3"),
deps.api.addr_make("approver_4"),
],
executors: vec![deps.api.addr_make("exec_1"), deps.api.addr_make("exec_2")],
ask_fee_info: Some(FeeInfo {
account: Addr::unchecked("new_ask_fee_account"),
account: deps.api.addr_make("new_ask_fee_account"),
rate: "0.03".into(),
}),
bid_fee_info: Some(FeeInfo {
account: Addr::unchecked("new_bid_fee_account"),
account: deps.api.addr_make("new_bid_fee_account"),
rate: "0.04".into(),
}),
ask_required_attributes: vec!["ask_tag_3".into(), "ask_tag_4".into()],
Expand Down
4 changes: 1 addition & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ pub enum ContractError {

impl From<ContractError> for StdError {
fn from(error: ContractError) -> Self {
StdError::GenericErr {
msg: error.to_string(),
}
StdError::generic_err(error.to_string())
}
}
5 changes: 5 additions & 0 deletions src/tests/execute/create_ask_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ mod create_ask_tests {
value: "ask_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "ask_tag_2".to_string(),
value: "ask_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -205,12 +207,14 @@ mod create_ask_tests {
value: "ask_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "ask_tag_2".to_string(),
value: "ask_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -918,6 +922,7 @@ mod create_ask_tests {
value: "ask_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
}],
pagination: None,
},
Expand Down
11 changes: 11 additions & 0 deletions src/tests/execute/create_bid_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,14 @@ mod create_bid_tests {
value: "bid_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "bid_tag_2".to_string(),
value: "bid_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -489,12 +491,14 @@ mod create_bid_tests {
value: "bid_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "bid_tag_2".to_string(),
value: "bid_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -639,12 +643,14 @@ mod create_bid_tests {
value: "bid_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "bid_tag_2".to_string(),
value: "bid_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -789,12 +795,14 @@ mod create_bid_tests {
value: "bid_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "bid_tag_2".to_string(),
value: "bid_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -1145,12 +1153,14 @@ mod create_bid_tests {
value: "bid_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
Attribute {
name: "bid_tag_2".to_string(),
value: "bid_tag_2_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
},
],
pagination: None,
Expand Down Expand Up @@ -1481,6 +1491,7 @@ mod create_bid_tests {
value: "bid_tag_1_value".as_bytes().to_vec(),
attribute_type: AttributeType::String.into(),
address: "".to_string(),
expiration_date: None,
}],
pagination: None,
},
Expand Down
Loading
Loading