From 0656824cef0bd6ff2f6ce1a18957fc26b1dbfc34 Mon Sep 17 00:00:00 2001 From: _dssei_ Date: Fri, 5 Apr 2024 15:48:49 -0700 Subject: [PATCH] draft working version of getting EVM address --- Cargo.toml | 1 + contracts/sei-tester/src/contract.rs | 16 +++- contracts/sei-tester/src/msg.rs | 3 + .../tests/sei_tester_integration_tests.rs | 58 ++++++++---- packages/sei-cosmwasm/src/lib.rs | 1 + packages/sei-cosmwasm/src/querier.rs | 93 ++++++++++++------- packages/sei-cosmwasm/src/query.rs | 19 ++++ packages/sei-integration-tests/src/helper.rs | 9 +- packages/sei-integration-tests/src/module.rs | 53 ++++++----- 9 files changed, 175 insertions(+), 78 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2769c03..1f13b86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["packages/*", "contracts/*"] +resolver = "2" [profile.release.package.sei-cosmwasm] opt-level = 3 diff --git a/contracts/sei-tester/src/contract.rs b/contracts/sei-tester/src/contract.rs index 1a98629..df8cc5b 100644 --- a/contracts/sei-tester/src/contract.rs +++ b/contracts/sei-tester/src/contract.rs @@ -1,5 +1,5 @@ use cosmwasm_std::to_json_binary; -#[cfg(not(feature = "library"))] +// #[cfg(not(feature = "library"))] use cosmwasm_std::{ coin, entry_point, Attribute, BankMsg, Binary, Coin, Decimal, Deps, DepsMut, Env, MessageInfo, Order as IteratorOrder, Reply, Response, StdError, StdResult, SubMsg, SubMsgResponse, Uint128, @@ -18,6 +18,7 @@ use sei_cosmwasm::{ GetLatestPriceResponse, GetOrderByIdResponse, GetOrdersResponse, Metadata, MsgPlaceOrdersResponse, OracleTwapsResponse, Order, OrderSimulationResponse, OrderType, PositionDirection, SeiMsg, SeiQuerier, SeiQueryWrapper, SettlementEntry, SudoMsg, + EvmAddressResponse }; const PLACE_ORDER_REPLY_ID: u64 = 1; @@ -436,6 +437,8 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult QueryMsg::GetDenomsFromCreator { creator } => { to_json_binary(&query_denoms_from_creator(deps, creator)?) } + QueryMsg::GetEvmAddressBySeiAddress { sei_address } => + to_json_binary(&query_evm_address(deps, sei_address)?), } } @@ -549,3 +552,14 @@ pub fn query_denoms_from_creator( Ok(res) } + +pub fn query_evm_address( + deps: Deps, + sei_address: String, +) -> StdResult { + let valid_addr = deps.api.addr_validate(&sei_address)?; + let querier = SeiQuerier::new(&deps.querier); + let res = querier.get_evm_address(valid_addr.to_string())?; + + Ok(res) +} diff --git a/contracts/sei-tester/src/msg.rs b/contracts/sei-tester/src/msg.rs index a4a9910..dcff532 100644 --- a/contracts/sei-tester/src/msg.rs +++ b/contracts/sei-tester/src/msg.rs @@ -57,4 +57,7 @@ pub enum QueryMsg { GetDenomsFromCreator { creator: String, }, + GetEvmAddressBySeiAddress { + sei_address: String, + }, } diff --git a/contracts/sei-tester/tests/sei_tester_integration_tests.rs b/contracts/sei-tester/tests/sei_tester_integration_tests.rs index 07e3ddd..0f5225e 100644 --- a/contracts/sei-tester/tests/sei_tester_integration_tests.rs +++ b/contracts/sei-tester/tests/sei_tester_integration_tests.rs @@ -1,23 +1,14 @@ -use cosmwasm_std::{ - coin, from_binary, - testing::{MockApi, MockStorage}, - Addr, Api, BalanceResponse, Coin, CosmosMsg, Decimal, Empty, GovMsg, IbcMsg, IbcQuery, - QueryRequest, StdError, Storage, Uint128, -}; +use cosmwasm_std::{Addr, Api, BalanceResponse, coin, Coin, CosmosMsg, Decimal, Empty, from_json, GovMsg, IbcMsg, IbcQuery, QueryRequest, StdError, Storage, testing::{MockApi, MockStorage}, Uint128}; use cosmwasm_std::{BlockInfo, Uint64}; use cw_multi_test::{ App, BankKeeper, ContractWrapper, DistributionKeeper, Executor, FailingModule, Router, StakeKeeper, WasmKeeper, }; -use sei_cosmwasm::{ - Cancellation, DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, EpochResponse, - ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleExchangeRate, - OracleTwapsResponse, Order, OrderSimulationResponse, OrderStatus, OrderType, PositionDirection, - SeiMsg, SeiQuery, SeiQueryWrapper, SeiRoute, SudoMsg as SeiSudoMsg, -}; + +use sei_cosmwasm::{Cancellation, DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, EpochResponse, EvmAddressResponse, ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleExchangeRate, OracleTwapsResponse, Order, OrderSimulationResponse, OrderStatus, OrderType, PositionDirection, SeiMsg, SeiQuery, SeiQueryWrapper, SeiRoute}; use sei_integration_tests::{ helper::{get_balance, mock_app}, - module::SeiModule, + module::{SeiModule, EVM_ADDRESS} }; use sei_tester::{ contract::{execute, instantiate, query}, @@ -142,7 +133,7 @@ fn test_tokenfactory_integration_foundation() { let res = arr.first().unwrap().clone().data; let data = res.unwrap(); - let out: String = from_binary(&data).unwrap(); + let out: String = from_json(&data).unwrap(); assert_eq!(out.to_string(), "factory/admin/test"); app.execute_multi( @@ -306,7 +297,7 @@ fn test_dex_module_integration_orders() { .unwrap(); let res = arr.first().unwrap().clone().data; let data = res.unwrap(); - let out: String = from_binary(&data).unwrap(); + let out: String = from_json(&data).unwrap(); assert_eq!(out.to_string(), contract_addr.to_string()); // Query GetOrders() after order 1 @@ -466,7 +457,7 @@ fn test_dex_module_integration_orders() { .unwrap(); let res = arr.first().unwrap().clone().data; let data = res.unwrap(); - let out: String = from_binary(&data).unwrap(); + let out: String = from_json(&data).unwrap(); assert_eq!(out.to_string(), contract_addr.to_string()); // Query GetOrders() after order 0 cancelled @@ -931,3 +922,38 @@ fn test_dex_module_query_dex_twap() { assert_eq!(res, expected_twap); } + +/// EVM Module - query EVM address +#[test] +fn test_evm_address_query() { + let mut app = mock_app(init_default_balances, vec![]); + let sei_tester_addr = setup_test(&mut app); + + // Test associated EVM address + let res: EvmAddressResponse = app + .wrap() + .query_wasm_smart(sei_tester_addr.clone(), &QueryMsg::GetEvmAddressBySeiAddress { + sei_address: sei_tester_addr.to_string(), + }) + .unwrap(); + + let expected_res = EvmAddressResponse { + evm_address: EVM_ADDRESS.to_string(), + associated: true, + }; + assert_eq!(res, expected_res); + + // Test non-associated EVM address + let res: EvmAddressResponse = app + .wrap() + .query_wasm_smart(sei_tester_addr.clone(), &QueryMsg::GetEvmAddressBySeiAddress { + sei_address: "fake_address".to_string(), + }) + .unwrap(); + + let expected_res = EvmAddressResponse { + evm_address: String::new(), + associated: false, + }; + assert_eq!(res, expected_res); +} \ No newline at end of file diff --git a/packages/sei-cosmwasm/src/lib.rs b/packages/sei-cosmwasm/src/lib.rs index 3e7206f..56cb5e6 100644 --- a/packages/sei-cosmwasm/src/lib.rs +++ b/packages/sei-cosmwasm/src/lib.rs @@ -15,6 +15,7 @@ pub use query::{ DenomAuthorityMetadataResponse, DenomsFromCreatorResponse, DexTwapsResponse, EpochResponse, ExchangeRatesResponse, GetLatestPriceResponse, GetOrderByIdResponse, GetOrdersResponse, OracleTwapsResponse, OrderSimulationResponse, PriceResponse, SeiQuery, SeiQueryWrapper, + EvmAddressResponse }; pub use route::SeiRoute; pub use sei_types::{ diff --git a/packages/sei-cosmwasm/src/querier.rs b/packages/sei-cosmwasm/src/querier.rs index dddab63..65ce005 100644 --- a/packages/sei-cosmwasm/src/querier.rs +++ b/packages/sei-cosmwasm/src/querier.rs @@ -1,13 +1,7 @@ use cosmwasm_std::{Addr, QuerierWrapper, StdResult, Uint128}; use cw20::{BalanceResponse, TokenInfoResponse}; -use crate::query::{ - DenomAuthorityMetadataResponse, DenomsFromCreatorResponse, DexTwapsResponse, EpochResponse, - Erc20AllowanceResponse, Erc721ApprovedResponse, Erc721IsApprovedForAllResponse, - Erc721NameSymbolResponse, Erc721OwnerResponse, Erc721UriResponse, ErcPayloadResponse, - ExchangeRatesResponse, GetLatestPriceResponse, GetOrderByIdResponse, GetOrdersResponse, - OracleTwapsResponse, OrderSimulationResponse, SeiQuery, SeiQueryWrapper, StaticCallResponse, -}; +use crate::query::{DenomAuthorityMetadataResponse, DenomsFromCreatorResponse, DexTwapsResponse, EpochResponse, Erc20AllowanceResponse, Erc721ApprovedResponse, Erc721IsApprovedForAllResponse, Erc721NameSymbolResponse, Erc721OwnerResponse, Erc721UriResponse, ErcPayloadResponse, EvmAddressResponse, ExchangeRatesResponse, GetLatestPriceResponse, GetOrderByIdResponse, GetOrdersResponse, OracleTwapsResponse, OrderSimulationResponse, SeiQuery, SeiQueryWrapper, StaticCallResponse}; use crate::route::SeiRoute; use crate::Order; @@ -29,7 +23,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Oracle, query_data: SeiQuery::ExchangeRates {}, } - .into(); + .into(); self.querier.query(&request) } @@ -39,7 +33,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Oracle, query_data: SeiQuery::OracleTwaps { lookback_seconds }, } - .into(); + .into(); self.querier.query(&request) } @@ -59,7 +53,7 @@ impl<'a> SeiQuerier<'a> { lookback_seconds, }, } - .into(); + .into(); self.querier.query(&request) } @@ -76,7 +70,7 @@ impl<'a> SeiQuerier<'a> { order, }, } - .into(); + .into(); self.querier.query(&request) } @@ -93,7 +87,7 @@ impl<'a> SeiQuerier<'a> { account, }, } - .into(); + .into(); self.querier.query(&request) } @@ -113,7 +107,7 @@ impl<'a> SeiQuerier<'a> { id: order_id, }, } - .into(); + .into(); self.querier.query(&request) } @@ -125,7 +119,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Epoch, query_data: SeiQuery::Epoch {}, } - .into(); + .into(); self.querier.query(&request) } @@ -143,7 +137,7 @@ impl<'a> SeiQuerier<'a> { asset_denom, }, } - .into(); + .into(); self.querier.query(&request) } @@ -158,7 +152,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Tokenfactory, query_data: SeiQuery::DenomAuthorityMetadata { denom }, } - .into(); + .into(); self.querier.query(&request) } @@ -167,7 +161,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Tokenfactory, query_data: SeiQuery::DenomsFromCreator { creator }, } - .into(); + .into(); self.querier.query(&request) } @@ -181,7 +175,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Evm, query_data: SeiQuery::StaticCall { from, to, data }, } - .into(); + .into(); self.querier.query(&request) } @@ -196,7 +190,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Evm, query_data: SeiQuery::Erc20TransferPayload { recipient, amount }, } - .into(); + .into(); self.querier.query(&request) } @@ -216,7 +210,7 @@ impl<'a> SeiQuerier<'a> { amount, }, } - .into(); + .into(); self.querier.query(&request) } @@ -231,7 +225,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Evm, query_data: SeiQuery::Erc20ApprovePayload { spender, amount }, } - .into(); + .into(); self.querier.query(&request) } @@ -250,7 +244,7 @@ impl<'a> SeiQuerier<'a> { spender, }, } - .into(); + .into(); self.querier.query(&request) } @@ -267,7 +261,7 @@ impl<'a> SeiQuerier<'a> { caller, }, } - .into(); + .into(); self.querier.query(&request) } @@ -284,7 +278,7 @@ impl<'a> SeiQuerier<'a> { account, }, } - .into(); + .into(); self.querier.query(&request) } @@ -303,7 +297,7 @@ impl<'a> SeiQuerier<'a> { token_id, }, } - .into(); + .into(); self.querier.query(&request) } @@ -322,7 +316,7 @@ impl<'a> SeiQuerier<'a> { token_id, }, } - .into(); + .into(); self.querier.query(&request) } @@ -343,7 +337,7 @@ impl<'a> SeiQuerier<'a> { operator, }, } - .into(); + .into(); self.querier.query(&request) } @@ -360,7 +354,7 @@ impl<'a> SeiQuerier<'a> { contract_address, }, } - .into(); + .into(); self.querier.query(&request) } @@ -379,7 +373,7 @@ impl<'a> SeiQuerier<'a> { token_id, }, } - .into(); + .into(); self.querier.query(&request) } @@ -399,7 +393,7 @@ impl<'a> SeiQuerier<'a> { token_id, }, } - .into(); + .into(); self.querier.query(&request) } @@ -414,7 +408,7 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Evm, query_data: SeiQuery::Erc721ApprovePayload { spender, token_id }, } - .into(); + .into(); self.querier.query(&request) } @@ -429,7 +423,42 @@ impl<'a> SeiQuerier<'a> { route: SeiRoute::Evm, query_data: SeiQuery::Erc721SetApprovalAllPayload { to, approved }, } - .into(); + .into(); + + self.querier.query(&request) + } + + /// Queries the EVM (Ethereum Virtual Machine) address associated with a given Sei address. + /// + /// This function takes a `sei_address` as a parameter, which is a `String` representing the SEI address. + /// It returns a `StdResult`, which is a standard result type in the `cosmwasm_std` library. + /// The `EvmAddressResponse` struct contains the EVM address and a boolean indicating whether the EVM address is associated. + /// + /// # Arguments + /// + /// * `sei_address` - A `String` that represents the Sei address. + /// + /// # Returns + /// + /// * `StdResult` - A standard result that wraps the `EvmAddressResponse` struct. + /// `EvmAddressResponse` contains the EVM address and a boolean indicating whether the EVM address is associated. + /// If the Sei address is not associated with any EVM address, the EVM address will be an empty string. + /// + /// + /// # Errors + /// + /// This function will return an error if the query to the EVM fails. + pub fn get_evm_address( + &self, + sei_address: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::GetEvmAddress { + sei_address + }, + } + .into(); self.querier.query(&request) } diff --git a/packages/sei-cosmwasm/src/query.rs b/packages/sei-cosmwasm/src/query.rs index b1f7304..41f9044 100644 --- a/packages/sei-cosmwasm/src/query.rs +++ b/packages/sei-cosmwasm/src/query.rs @@ -125,6 +125,9 @@ pub enum SeiQuery { contract_address: String, token_id: String, }, + GetEvmAddress { + sei_address: String, + }, } /// ExchangeRatesResponse is data format returned from OracleRequest::ExchangeRates query @@ -236,3 +239,19 @@ pub struct Erc721NameSymbolResponse { pub struct Erc721UriResponse { pub uri: String, } + +/// `EvmAddressResponse` is a struct that represents a response containing an EVM address. +/// +/// It has two fields: +/// * `evm_address`: a `String` that represents the EVM address. +/// * `associated`: a `bool` that indicates whether the EVM address is associated or not. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct EvmAddressResponse { + /// The 20-byte EVM address associated to Sei address that's derived from the public part of a + /// public-private key pair. It's represented as a hex string. + /// Address is empty if the Sei address is not associated with any EVM address. + pub evm_address: String, + + /// A boolean value indicating whether the EVM address is associated. + pub associated: bool +} \ No newline at end of file diff --git a/packages/sei-integration-tests/src/helper.rs b/packages/sei-integration-tests/src/helper.rs index 24ca0f3..f3075c3 100644 --- a/packages/sei-integration-tests/src/helper.rs +++ b/packages/sei-integration-tests/src/helper.rs @@ -1,9 +1,4 @@ -use cosmwasm_std::{ - from_binary, - testing::{MockApi, MockQuerier, MockStorage}, - Api, BalanceResponse, BankQuery, BlockInfo, Empty, GovMsg, IbcMsg, IbcQuery, MemoryStorage, - Storage, Timestamp, -}; +use cosmwasm_std::{testing::{MockApi, MockQuerier, MockStorage}, Api, BalanceResponse, BankQuery, BlockInfo, Empty, GovMsg, IbcMsg, IbcQuery, MemoryStorage, Storage, Timestamp, from_json}; use cw_multi_test::{ App, AppBuilder, BankKeeper, DistributionKeeper, FailingModule, Module, Router, StakeKeeper, WasmKeeper, @@ -34,7 +29,7 @@ pub fn get_balance( }, ) }); - from_binary(&arr.unwrap()).unwrap() + from_json(&arr.unwrap()).unwrap() } // Mock app diff --git a/packages/sei-integration-tests/src/module.rs b/packages/sei-integration-tests/src/module.rs index 5e94de7..b8c468a 100644 --- a/packages/sei-integration-tests/src/module.rs +++ b/packages/sei-integration-tests/src/module.rs @@ -1,16 +1,8 @@ use anyhow::Result as AnyResult; -use cosmwasm_std::{ - from_binary, to_binary, Addr, Api, BankMsg, Binary, BlockInfo, Coin, CosmosMsg, CustomQuery, - Decimal, Querier, Storage, Uint128, Uint64, -}; +use cosmwasm_std::{Addr, Api, BankMsg, Binary, BlockInfo, Coin, CosmosMsg, CustomQuery, Decimal, Querier, Storage, Uint128, Uint64, to_json_binary, from_json}; use cw_multi_test::{AppResponse, BankSudo, CosmosRouter, Module, SudoMsg}; use schemars::JsonSchema; -use sei_cosmwasm::{ - Cancellation, DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, Epoch, - EpochResponse, ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleTwap, - OracleTwapsResponse, Order, OrderResponse, OrderSimulationResponse, OrderStatus, - PositionDirection, SeiMsg, SeiQuery, SeiQueryWrapper, SudoMsg as SeiSudoMsg, -}; +use sei_cosmwasm::{Cancellation, DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, Epoch, EpochResponse, EvmAddressResponse, ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleTwap, OracleTwapsResponse, Order, OrderResponse, OrderSimulationResponse, OrderStatus, PositionDirection, SeiMsg, SeiQuery, SeiQueryWrapper, SudoMsg as SeiSudoMsg}; use serde::de::DeserializeOwned; use std::{ collections::HashMap, @@ -31,6 +23,8 @@ const GENESIS_EPOCH: Epoch = Epoch { current_epoch_height: 1, }; +pub const EVM_ADDRESS: &str = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"; + impl SeiModule { pub fn new() -> Self { SeiModule { @@ -138,9 +132,9 @@ impl Module for SeiModule { ) -> AnyResult { match request.query_data { SeiQuery::ExchangeRates {} => { - Ok(to_binary(&get_exchange_rates(self.exchange_rates.clone()))?) + Ok(to_json_binary(&get_exchange_rates(self.exchange_rates.clone()))?) } - SeiQuery::OracleTwaps { lookback_seconds } => Ok(to_binary(&get_oracle_twaps( + SeiQuery::OracleTwaps { lookback_seconds } => Ok(to_json_binary(&get_oracle_twaps( block, self.exchange_rates.clone(), lookback_seconds, @@ -148,7 +142,7 @@ impl Module for SeiModule { SeiQuery::DexTwaps { contract_address, lookback_seconds, - } => Ok(to_binary(&get_dex_twaps( + } => Ok(to_json_binary(&get_dex_twaps( storage, block, contract_address, @@ -157,7 +151,7 @@ impl Module for SeiModule { SeiQuery::OrderSimulation { order, contract_address, - } => Ok(to_binary(&get_order_simulation( + } => Ok(to_json_binary(&get_order_simulation( storage, order, contract_address, @@ -187,6 +181,9 @@ impl Module for SeiModule { id, ); } + SeiQuery::GetEvmAddress { sei_address } => { + Ok(to_json_binary(&get_evm_address(sei_address))?) + } // TODO: Implement get denom authority metadata in integration tests SeiQuery::DenomAuthorityMetadata { .. } => { panic!("Denom Authority Metadata not implemented") @@ -329,7 +326,7 @@ fn execute_place_orders_helper( Ok(AppResponse { events: vec![], - data: Some(to_binary(&contract_address).unwrap()), + data: Some(to_json_binary(&contract_address).unwrap()), }) } @@ -388,7 +385,7 @@ fn execute_cancel_orders_helper( Ok(AppResponse { events: vec![], - data: Some(to_binary(&contract_address).unwrap()), + data: Some(to_json_binary(&contract_address).unwrap()), }) } @@ -480,7 +477,7 @@ fn get_dex_twaps( let mut dex_twaps: HashMap<(String, String), Decimal> = HashMap::new(); let mut prev_time = block.time.seconds(); - let order_response: GetOrdersResponse = from_binary( + let order_response: GetOrdersResponse = from_json( &query_get_orders_helper(storage, contract_address, Addr::unchecked("")).unwrap(), ) .unwrap(); @@ -551,7 +548,7 @@ fn get_order_simulation( ) -> OrderSimulationResponse { let mut executed_quantity = Decimal::zero(); - let orders: GetOrdersResponse = from_binary( + let orders: GetOrdersResponse = from_json( &query_get_orders_helper(storage, contract_address, Addr::unchecked("")).unwrap(), ) .unwrap(); @@ -601,7 +598,7 @@ fn query_get_orders_helper( let order_responses: Vec = serde_json::from_str(&responses_json).unwrap(); - return Ok(to_binary(&GetOrdersResponse { + return Ok(to_json_binary(&GetOrdersResponse { orders: order_responses, })?); } @@ -634,7 +631,7 @@ fn query_get_order_by_id_helper( let order_response: OrderResponse = serde_json::from_str(&response_json).unwrap(); - return Ok(to_binary(&GetOrderByIdResponse { + return Ok(to_json_binary(&GetOrderByIdResponse { order: order_response, })?); } @@ -645,9 +642,21 @@ fn get_epoch(epoch: Epoch) -> EpochResponse { EpochResponse { epoch: epoch } } +fn get_evm_address(sei_address: String) -> EvmAddressResponse { + let (evm_address, associated) = match sei_address.as_str() { + "contract0" => (EVM_ADDRESS.to_string(), true), + _ => (String::new(), false), // default case + }; + + EvmAddressResponse { + evm_address, + associated, + } +} + // Query: GetEpoch() fn query_get_epoch_helper(epoch: Epoch) -> AnyResult { - return Ok(to_binary(&get_epoch(epoch))?); + return Ok(to_json_binary(&get_epoch(epoch))?); } // TokenFactory Msg @@ -665,7 +674,7 @@ fn execute_create_denom_helper( storage.set(denom.as_bytes(), sender.to_string().as_bytes()); Ok(AppResponse { events: vec![], - data: Some(to_binary(&denom).unwrap()), + data: Some(to_json_binary(&denom).unwrap()), }) }