From 89a55eeb39af3a1581d33f27fbff2c6716819ca7 Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Thu, 16 Nov 2023 10:17:26 +0100 Subject: [PATCH] feat(dataverse): use Addr type for triple store state address --- contracts/okp4-dataverse/src/contract.rs | 14 +++++++------- contracts/okp4-dataverse/src/state.rs | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/contracts/okp4-dataverse/src/contract.rs b/contracts/okp4-dataverse/src/contract.rs index bbb1ea1c..d1494d45 100644 --- a/contracts/okp4-dataverse/src/contract.rs +++ b/contracts/okp4-dataverse/src/contract.rs @@ -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 = { #[cfg(not(test))] { - deps.api.addr_humanize(&triplestore_address)? + deps.api.addr_humanize(&_triplestore_address)? } #[cfg(test)] cosmwasm_std::Addr::unchecked("predicted address") @@ -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(), }, )?; 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(), @@ -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] @@ -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"), } ) } diff --git a/contracts/okp4-dataverse/src/state.rs b/contracts/okp4-dataverse/src/state.rs index b27549b1..7774dfb8 100644 --- a/contracts/okp4-dataverse/src/state.rs +++ b/contracts/okp4-dataverse/src/state.rs @@ -1,3 +1,4 @@ +use cosmwasm_std::Addr; use cw_storage_plus::Item; use serde::{Deserialize, Serialize}; @@ -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, }