Skip to content

Commit

Permalink
feat(dataverse): use Addr type for triple store state address
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Nov 16, 2023
1 parent 31340f2 commit 89a55ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions contracts/okp4-dataverse/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ pub fn instantiate(
.query_wasm_code_info(msg.triplestore_config.code_id.u64())?;
let salt = Binary::from(msg.name.as_bytes());

let triplestore_address = instantiate2_address(&checksum, &creator, &salt)?;
let _triplestore_address = instantiate2_address(&checksum, &creator, &salt)?;

// Necessary stuff for testing purposes, see: https://github.com/CosmWasm/cosmwasm/issues/1648
let triplestore_address = {

Check warning on line 35 in contracts/okp4-dataverse/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/contract.rs#L35

Added line #L35 was not covered by tests
#[cfg(not(test))]
{
deps.api.addr_humanize(&triplestore_address)?
deps.api.addr_humanize(&_triplestore_address)?
}
#[cfg(test)]
cosmwasm_std::Addr::unchecked("predicted address")
Expand All @@ -45,12 +45,12 @@ pub fn instantiate(
deps.storage,
&Dataverse {
name: msg.name.clone(),
triplestore_address: triplestore_address.to_string(),
triplestore_address: triplestore_address.clone(),
},
)?;

Check warning on line 50 in contracts/okp4-dataverse/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/okp4-dataverse/src/contract.rs#L45-L50

Added lines #L45 - L50 were not covered by tests

Ok(Response::new()
.add_attribute("triplestore_address", triplestore_address)
.add_attribute("triplestore_address", triplestore_address.to_string())
.add_message(WasmMsg::Instantiate2 {
admin: Some(env.contract.address.to_string()),
code_id: msg.triplestore_config.code_id.u64(),
Expand Down Expand Up @@ -88,8 +88,8 @@ mod tests {
use crate::msg::{TripleStoreConfig, TripleStoreLimitsInput};
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
use cosmwasm_std::{
Attribute, ContractResult, HexBinary, SubMsg, SystemError, SystemResult, Uint128, Uint64,
WasmQuery,
Addr, Attribute, ContractResult, HexBinary, SubMsg, SystemError, SystemResult, Uint128,
Uint64, WasmQuery,
};

#[test]
Expand Down Expand Up @@ -148,7 +148,7 @@ mod tests {
DATAVERSE.load(&deps.storage).unwrap(),
Dataverse {
name: "my-dataverse".to_string(),
triplestore_address: "predicted address".to_string(),
triplestore_address: Addr::unchecked("predicted address"),
}
)
}
Expand Down
3 changes: 2 additions & 1 deletion contracts/okp4-dataverse/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cosmwasm_std::Addr;
use cw_storage_plus::Item;
use serde::{Deserialize, Serialize};

Expand All @@ -6,5 +7,5 @@ pub const DATAVERSE: Item<'_, Dataverse> = Item::new("dataverse");
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct Dataverse {
pub name: String,
pub triplestore_address: String,
pub triplestore_address: Addr,
}

0 comments on commit 89a55ee

Please sign in to comment.