diff --git a/contracts/sei-tester/src/contract.rs b/contracts/sei-tester/src/contract.rs index 0978a61..1a98629 100644 --- a/contracts/sei-tester/src/contract.rs +++ b/contracts/sei-tester/src/contract.rs @@ -1,14 +1,15 @@ +use cosmwasm_std::to_json_binary; #[cfg(not(feature = "library"))] use cosmwasm_std::{ - coin, entry_point, to_binary, BankMsg, Binary, Coin, Decimal, Deps, DepsMut, Env, MessageInfo, - Reply, Response, StdError, StdResult, SubMsg, SubMsgResponse, Uint128, Order as IteratorOrder, Attribute + coin, entry_point, Attribute, BankMsg, Binary, Coin, Decimal, Deps, DepsMut, Env, MessageInfo, + Order as IteratorOrder, Reply, Response, StdError, StdResult, SubMsg, SubMsgResponse, Uint128, }; use cw_storage_plus::Bound; use crate::{ msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, + state::{PARALLEL_VALS, USER_SUMS, VALUES}, types::{OrderData, PositionEffect}, - state::{VALUES, USER_SUMS, PARALLEL_VALS}, }; use protobuf::Message; use sei_cosmwasm::{ @@ -65,8 +66,12 @@ pub fn execute( ExecuteMsg::Burn {} => burn(deps, env, info), ExecuteMsg::ChangeAdmin {} => change_admin(deps, env, info), ExecuteMsg::SetMetadata {} => set_metadata(deps, env, info), - ExecuteMsg::TestOccIteratorWrite { values } => test_occ_iterator_write(deps, env, info, values), - ExecuteMsg::TestOccIteratorRange { start, end } => test_occ_iterator_range(deps, env, info, start, end), + ExecuteMsg::TestOccIteratorWrite { values } => { + test_occ_iterator_write(deps, env, info, values) + } + ExecuteMsg::TestOccIteratorRange { start, end } => { + test_occ_iterator_range(deps, env, info, start, end) + } ExecuteMsg::TestOccParallelism { value } => test_occ_parallelism(deps, env, info, value), } } @@ -74,9 +79,9 @@ pub fn execute( fn test_occ_iterator_write( deps: DepsMut, _env: Env, - info: MessageInfo, + _info: MessageInfo, values: Vec<(u64, u64)>, -) -> Result, StdError> { +) -> Result, StdError> { // writes all of the values (index, value) to the store for (key, value) in values { VALUES.save(deps.storage, key, &value)?; @@ -90,15 +95,18 @@ fn test_occ_iterator_range( info: MessageInfo, start: u64, end: u64, -) -> Result, StdError> { +) -> Result, StdError> { // iterates through the `VALUES` and for all that exist, sums them and writes them to user_sums for the sender let mut sum: u64 = 0; - let values: Vec<(u64, u64)> = VALUES.range( - deps.storage, - Some(Bound::inclusive(start)), - Some(Bound::inclusive(end)), - IteratorOrder::Ascending - ).collect::, StdError>>().unwrap(); + let values: Vec<(u64, u64)> = VALUES + .range( + deps.storage, + Some(Bound::inclusive(start)), + Some(Bound::inclusive(end)), + IteratorOrder::Ascending, + ) + .collect::, StdError>>() + .unwrap(); let mut value_attrs: Vec = vec![]; for (key, val) in values { @@ -110,8 +118,7 @@ fn test_occ_iterator_range( Ok(Response::new() .add_attribute("user", info.sender.to_string()) .add_attribute("sum", sum.to_string()) - .add_attributes(value_attrs) - ) + .add_attributes(value_attrs)) } fn test_occ_parallelism( @@ -119,13 +126,12 @@ fn test_occ_parallelism( _env: Env, info: MessageInfo, value: u64, -) -> Result, StdError> { +) -> Result, StdError> { // writes the value to the store for the sender PARALLEL_VALS.save(deps.storage, info.sender.clone(), &value)?; Ok(Response::new() .add_attribute("user", info.sender.to_string()) - .add_attribute("val", value.to_string()) - ) + .add_attribute("val", value.to_string())) } pub fn place_orders( @@ -385,29 +391,29 @@ pub fn handle_place_order_reply( #[cfg_attr(not(feature = "library"), entry_point)] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - QueryMsg::ExchangeRates {} => to_binary(&query_exchange_rates(deps)?), + QueryMsg::ExchangeRates {} => to_json_binary(&query_exchange_rates(deps)?), QueryMsg::OracleTwaps { lookback_seconds } => { - to_binary(&query_oracle_twaps(deps, lookback_seconds)?) + to_json_binary(&query_oracle_twaps(deps, lookback_seconds)?) } QueryMsg::DexTwaps { contract_address, lookback_seconds, - } => to_binary(&query_dex_twaps(deps, contract_address, lookback_seconds)?), + } => to_json_binary(&query_dex_twaps(deps, contract_address, lookback_seconds)?), QueryMsg::OrderSimulation { order, contract_address, - } => to_binary(&query_order_simulation(deps, order, contract_address)?), - QueryMsg::Epoch {} => to_binary(&query_epoch(deps)?), + } => to_json_binary(&query_order_simulation(deps, order, contract_address)?), + QueryMsg::Epoch {} => to_json_binary(&query_epoch(deps)?), QueryMsg::GetOrders { contract_address, account, - } => to_binary(&query_get_orders(deps, contract_address, account)?), + } => to_json_binary(&query_get_orders(deps, contract_address, account)?), QueryMsg::GetOrderById { contract_address, price_denom, asset_denom, id, - } => to_binary(&query_get_order_by_id( + } => to_json_binary(&query_get_order_by_id( deps, contract_address, price_denom, @@ -418,17 +424,17 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult contract_address, price_denom, asset_denom, - } => to_binary(&query_get_latest_price( + } => to_json_binary(&query_get_latest_price( deps, contract_address, price_denom, asset_denom, )?), QueryMsg::GetDenomAuthorityMetadata { denom } => { - to_binary(&query_denom_authority_metadata(deps, denom)?) + to_json_binary(&query_denom_authority_metadata(deps, denom)?) } QueryMsg::GetDenomsFromCreator { creator } => { - to_binary(&query_denoms_from_creator(deps, creator)?) + to_json_binary(&query_denoms_from_creator(deps, creator)?) } } } diff --git a/contracts/sei-tester/src/lib.rs b/contracts/sei-tester/src/lib.rs index 261db7a..f2f9715 100644 --- a/contracts/sei-tester/src/lib.rs +++ b/contracts/sei-tester/src/lib.rs @@ -1,4 +1,4 @@ pub mod contract; pub mod msg; -pub mod types; pub mod state; +pub mod types; diff --git a/contracts/sei-tester/src/msg.rs b/contracts/sei-tester/src/msg.rs index 4b88e53..a4a9910 100644 --- a/contracts/sei-tester/src/msg.rs +++ b/contracts/sei-tester/src/msg.rs @@ -15,16 +15,9 @@ pub enum ExecuteMsg { Burn {}, ChangeAdmin {}, SetMetadata {}, - TestOccIteratorWrite { - values: Vec<(u64,u64)> - }, - TestOccIteratorRange { - start: u64, - end: u64, - }, - TestOccParallelism { - value: u64, - } + TestOccIteratorWrite { values: Vec<(u64, u64)> }, + TestOccIteratorRange { start: u64, end: u64 }, + TestOccParallelism { value: u64 }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] diff --git a/contracts/sei-tester/src/state.rs b/contracts/sei-tester/src/state.rs index b47a4cd..762eddc 100644 --- a/contracts/sei-tester/src/state.rs +++ b/contracts/sei-tester/src/state.rs @@ -1,15 +1,8 @@ -use cosmwasm_std::{Addr, Decimal, Uint128, Uint64}; -use cw_storage_plus::{Item, Map}; -use schemars::JsonSchema; -use sei_cosmwasm::ExchangeRatesResponse; -use serde::{Deserialize, Serialize}; +use cosmwasm_std::Addr; +use cw_storage_plus::Map; +pub const VALUES: Map = Map::new("values"); -pub const VALUES: Map = - Map::new("values"); +pub const USER_SUMS: Map = Map::new("user_sums"); -pub const USER_SUMS: Map = - Map::new("user_sums"); - -pub const PARALLEL_VALS: Map = - Map::new("parallel_vals"); \ No newline at end of file +pub const PARALLEL_VALS: Map = Map::new("parallel_vals"); diff --git a/contracts/sei-tester/tests/sei_tester_integration_tests.rs b/contracts/sei-tester/tests/sei_tester_integration_tests.rs index deaa95e..07e3ddd 100644 --- a/contracts/sei-tester/tests/sei_tester_integration_tests.rs +++ b/contracts/sei-tester/tests/sei_tester_integration_tests.rs @@ -10,7 +10,7 @@ use cw_multi_test::{ StakeKeeper, WasmKeeper, }; use sei_cosmwasm::{ - DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, EpochResponse, + Cancellation, DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, EpochResponse, ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleExchangeRate, OracleTwapsResponse, Order, OrderSimulationResponse, OrderStatus, OrderType, PositionDirection, SeiMsg, SeiQuery, SeiQueryWrapper, SeiRoute, SudoMsg as SeiSudoMsg, @@ -229,13 +229,6 @@ fn test_epoch_query() { assert_eq!(res.epoch.current_epoch, 1); assert_eq!(res.epoch.current_epoch_start_time, "".to_string()); assert_eq!(res.epoch.current_epoch_height, 1); - - // // Also compiles but doesn't write to SeiModule - app.wasm_sudo( - sei_tester_addr.clone(), - &(SeiSudoMsg::NewBlock { epoch: 100 }), - ) - .unwrap(); } /// Dex Module - place and get orders @@ -421,10 +414,24 @@ fn test_dex_module_integration_orders() { // CancelOrders for a contract address that doesn't exist let mut nonexistent_order_ids: Vec = Vec::new(); nonexistent_order_ids.push(3); + let cancellations: Vec = nonexistent_order_ids + .iter() + .map(|id| -> Cancellation { + Cancellation { + id: *id, + contract_address: "test contract".to_string(), + price: Decimal::zero(), + price_denom: "pd".to_string(), + asset_denom: "ad".to_string(), + order_type: OrderType::Limit, + position_direction: PositionDirection::Long, + } + }) + .collect(); let res = app.execute_multi( Addr::unchecked(ADMIN), vec![CosmosMsg::Custom(SeiMsg::CancelOrders { - order_ids: nonexistent_order_ids, + cancellations: cancellations, contract_address: Addr::unchecked("fake_contract_addr".to_string()), })], ); @@ -434,11 +441,25 @@ fn test_dex_module_integration_orders() { // CancelOrders for order id 1 let mut cancel_order_ids: Vec = Vec::new(); cancel_order_ids.push(0); + let cancellations: Vec = cancel_order_ids + .iter() + .map(|id| -> Cancellation { + Cancellation { + id: *id, + contract_address: "test contract".to_string(), + price: Decimal::zero(), + price_denom: "pd".to_string(), + asset_denom: "ad".to_string(), + order_type: OrderType::Limit, + position_direction: PositionDirection::Long, + } + }) + .collect(); let arr = app .execute_multi( Addr::unchecked(ADMIN), vec![CosmosMsg::Custom(SeiMsg::CancelOrders { - order_ids: cancel_order_ids, + cancellations: cancellations, contract_address: Addr::unchecked(&contract_addr), })], ) @@ -678,6 +699,7 @@ fn test_oracle_module_query_exchange_rate() { oracle_exchange_rate: OracleExchangeRate { exchange_rate: Decimal::percent(80), last_update: Uint64::zero(), + last_update_timestamp: 0, }, }, DenomOracleExchangeRatePair { @@ -685,6 +707,7 @@ fn test_oracle_module_query_exchange_rate() { oracle_exchange_rate: OracleExchangeRate { exchange_rate: Decimal::percent(70), last_update: Uint64::zero(), + last_update_timestamp: 0, }, }, DenomOracleExchangeRatePair { @@ -692,6 +715,7 @@ fn test_oracle_module_query_exchange_rate() { oracle_exchange_rate: OracleExchangeRate { exchange_rate: Decimal::percent(90), last_update: Uint64::new(1), + last_update_timestamp: 0, }, }, ], @@ -713,6 +737,7 @@ fn test_oracle_module_query_exchange_rate() { OracleExchangeRate { exchange_rate: Decimal::percent(70), last_update: Uint64::zero(), + last_update_timestamp: 0, } ); } @@ -722,6 +747,7 @@ fn test_oracle_module_query_exchange_rate() { OracleExchangeRate { exchange_rate: Decimal::percent(90), last_update: Uint64::new(1), + last_update_timestamp: 0, } ); } @@ -741,6 +767,7 @@ fn test_oracle_module_query_twaps() { oracle_exchange_rate: OracleExchangeRate { exchange_rate: Decimal::percent(80), last_update: Uint64::new(1_571_797_411), + last_update_timestamp: 0, }, }, DenomOracleExchangeRatePair { @@ -748,6 +775,7 @@ fn test_oracle_module_query_twaps() { oracle_exchange_rate: OracleExchangeRate { exchange_rate: Decimal::percent(70), last_update: Uint64::zero(), + last_update_timestamp: 0, }, }, DenomOracleExchangeRatePair { @@ -755,6 +783,7 @@ fn test_oracle_module_query_twaps() { oracle_exchange_rate: OracleExchangeRate { exchange_rate: Decimal::percent(90), last_update: Uint64::new(1_571_797_415), + last_update_timestamp: 0, }, }, ], diff --git a/packages/sei-cosmwasm/Cargo.toml b/packages/sei-cosmwasm/Cargo.toml index bd8f5b2..bc70a58 100644 --- a/packages/sei-cosmwasm/Cargo.toml +++ b/packages/sei-cosmwasm/Cargo.toml @@ -15,6 +15,7 @@ schemars = "0.8.3" serde = { version = "1.0.127", default-features = false, features = ["derive"] } serde_repr = "0.1.8" protobuf = { version = "=3.2.0", features = ["with-bytes"] } +cw20 = "1.1.2" [dev-dependencies] cosmwasm-schema = "1.0.0" diff --git a/packages/sei-cosmwasm/src/msg.rs b/packages/sei-cosmwasm/src/msg.rs index 58c9935..c6db857 100644 --- a/packages/sei-cosmwasm/src/msg.rs +++ b/packages/sei-cosmwasm/src/msg.rs @@ -1,5 +1,5 @@ use crate::sei_types::{Cancellation, DepositInfo, Metadata, Order, SettlementEntry}; -use cosmwasm_std::{Addr, Coin, CosmosMsg, CustomMsg}; +use cosmwasm_std::{Addr, Coin, CosmosMsg, CustomMsg, Uint128}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -41,6 +41,15 @@ pub enum SeiMsg { SetMetadata { metadata: Metadata, }, + DelegateCallEvm { + to: String, + data: String, // base64 encoded + }, + CallEvm { + value: Uint128, + to: String, + data: String, // base64 encoded + }, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] diff --git a/packages/sei-cosmwasm/src/querier.rs b/packages/sei-cosmwasm/src/querier.rs index bd50636..dddab63 100644 --- a/packages/sei-cosmwasm/src/querier.rs +++ b/packages/sei-cosmwasm/src/querier.rs @@ -1,9 +1,12 @@ -use cosmwasm_std::{Addr, QuerierWrapper, StdResult}; +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, + OracleTwapsResponse, OrderSimulationResponse, SeiQuery, SeiQueryWrapper, StaticCallResponse, }; use crate::route::SeiRoute; use crate::Order; @@ -167,4 +170,267 @@ impl<'a> SeiQuerier<'a> { .into(); self.querier.query(&request) } + + pub fn static_call( + &self, + from: String, + to: String, + data: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::StaticCall { from, to, data }, + } + .into(); + + self.querier.query(&request) + } + + // returns base64-encoded bytes + pub fn erc20_transfer_payload( + &self, + recipient: String, + amount: Uint128, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc20TransferPayload { recipient, amount }, + } + .into(); + + self.querier.query(&request) + } + + // returns base64-encoded bytes + pub fn erc20_transfer_from_payload( + &self, + owner: String, + recipient: String, + amount: Uint128, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc20TransferFromPayload { + owner, + recipient, + amount, + }, + } + .into(); + + self.querier.query(&request) + } + + // returns base64-encoded bytes + pub fn erc20_approve_payload( + &self, + spender: String, + amount: Uint128, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc20ApprovePayload { spender, amount }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc20_allowance( + &self, + contract_address: String, + owner: String, + spender: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc20Allowance { + contract_address, + owner, + spender, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc20_token_info( + &self, + contract_address: String, + caller: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc20TokenInfo { + contract_address, + caller, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc20_balance( + &self, + contract_address: String, + account: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc20Balance { + contract_address, + account, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc721_owner( + &self, + caller: String, + contract_address: String, + token_id: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721Owner { + caller, + contract_address, + token_id, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc721_approved( + &self, + caller: String, + contract_address: String, + token_id: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721Approved { + caller, + contract_address, + token_id, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc721_is_approved_for_all( + &self, + caller: String, + contract_address: String, + owner: String, + operator: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721IsApprovedForAll { + caller, + contract_address, + owner, + operator, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc721_name_symbol( + &self, + caller: String, + contract_address: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721NameSymbol { + caller, + contract_address, + }, + } + .into(); + + self.querier.query(&request) + } + + pub fn erc721_uri( + &self, + caller: String, + contract_address: String, + token_id: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721Uri { + caller, + contract_address, + token_id, + }, + } + .into(); + + self.querier.query(&request) + } + + // returns base64-encoded bytes + pub fn erc721_transfer_payload( + &self, + from: String, + recipient: String, + token_id: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721TransferPayload { + from, + recipient, + token_id, + }, + } + .into(); + + self.querier.query(&request) + } + + // returns base64-encoded bytes + pub fn erc721_approve_payload( + &self, + spender: String, + token_id: String, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721ApprovePayload { spender, token_id }, + } + .into(); + + self.querier.query(&request) + } + + // returns base64-encoded bytes + pub fn erc721_set_approval_all_payload( + &self, + to: String, + approved: bool, + ) -> StdResult { + let request = SeiQueryWrapper { + route: SeiRoute::Evm, + query_data: SeiQuery::Erc721SetApprovalAllPayload { to, approved }, + } + .into(); + + self.querier.query(&request) + } } diff --git a/packages/sei-cosmwasm/src/query.rs b/packages/sei-cosmwasm/src/query.rs index 2fefeec..b1f7304 100644 --- a/packages/sei-cosmwasm/src/query.rs +++ b/packages/sei-cosmwasm/src/query.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Addr, CustomQuery, Decimal}; +use cosmwasm_std::{Addr, CustomQuery, Decimal, Uint128}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -56,6 +56,75 @@ pub enum SeiQuery { DenomsFromCreator { creator: Addr, }, + StaticCall { + from: String, + to: String, + data: String, // base64 + }, + Erc20TransferPayload { + recipient: String, + amount: Uint128, + }, + Erc20TransferFromPayload { + owner: String, + recipient: String, + amount: Uint128, + }, + Erc20ApprovePayload { + spender: String, + amount: Uint128, + }, + Erc20Allowance { + contract_address: String, + owner: String, + spender: String, + }, + Erc20TokenInfo { + contract_address: String, + caller: String, + }, + Erc20Balance { + contract_address: String, + account: String, + }, + Erc721TransferPayload { + from: String, + recipient: String, + token_id: String, + }, + Erc721ApprovePayload { + spender: String, + token_id: String, + }, + Erc721Owner { + caller: String, + contract_address: String, + token_id: String, + }, + Erc721Approved { + caller: String, + contract_address: String, + token_id: String, + }, + Erc721IsApprovedForAll { + caller: String, + contract_address: String, + owner: String, + operator: String, + }, + Erc721SetApprovalAllPayload { + to: String, + approved: bool, + }, + Erc721NameSymbol { + caller: String, + contract_address: String, + }, + Erc721Uri { + caller: String, + contract_address: String, + token_id: String, + }, } /// ExchangeRatesResponse is data format returned from OracleRequest::ExchangeRates query @@ -126,3 +195,44 @@ pub struct DenomAuthorityMetadataResponse { pub struct DenomsFromCreatorResponse { pub denoms: Vec, } + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct StaticCallResponse { + pub data: String, // base64 +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct ErcPayloadResponse { + pub encoded_payload: String, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Erc20AllowanceResponse { + pub allowance: Uint128, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Erc721OwnerResponse { + pub owner: String, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Erc721ApprovedResponse { + pub approved: String, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Erc721IsApprovedForAllResponse { + pub is_approved: bool, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Erc721NameSymbolResponse { + pub name: String, + pub symbol: String, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Erc721UriResponse { + pub uri: String, +} diff --git a/packages/sei-cosmwasm/src/route.rs b/packages/sei-cosmwasm/src/route.rs index 9036f20..39be8a7 100644 --- a/packages/sei-cosmwasm/src/route.rs +++ b/packages/sei-cosmwasm/src/route.rs @@ -9,4 +9,5 @@ pub enum SeiRoute { Dex, Epoch, Tokenfactory, + Evm, } diff --git a/packages/sei-integration-tests/src/module.rs b/packages/sei-integration-tests/src/module.rs index 73220f1..5e94de7 100644 --- a/packages/sei-integration-tests/src/module.rs +++ b/packages/sei-integration-tests/src/module.rs @@ -6,8 +6,8 @@ use cosmwasm_std::{ use cw_multi_test::{AppResponse, BankSudo, CosmosRouter, Module, SudoMsg}; use schemars::JsonSchema; use sei_cosmwasm::{ - DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, Epoch, EpochResponse, - ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleTwap, + Cancellation, DenomOracleExchangeRatePair, DexPair, DexTwap, DexTwapsResponse, Epoch, + EpochResponse, ExchangeRatesResponse, GetOrderByIdResponse, GetOrdersResponse, OracleTwap, OracleTwapsResponse, Order, OrderResponse, OrderSimulationResponse, OrderStatus, PositionDirection, SeiMsg, SeiQuery, SeiQueryWrapper, SudoMsg as SeiSudoMsg, }; @@ -110,10 +110,10 @@ impl Module for SeiModule { ); } SeiMsg::CancelOrders { - order_ids, + cancellations, contract_address, } => { - return execute_cancel_orders_helper(storage, order_ids, contract_address); + return execute_cancel_orders_helper(storage, cancellations, contract_address); } SeiMsg::CreateDenom { subdenom } => { return execute_create_denom_helper(storage, sender, subdenom); @@ -195,6 +195,7 @@ impl Module for SeiModule { SeiQuery::DenomsFromCreator { .. } => { panic!("Denoms From Creator not implemented") } + _ => panic!("Unexpected custom query msg"), } } @@ -284,6 +285,9 @@ fn execute_place_orders_helper( order_type: order.order_type, position_direction: order.position_direction, data: order.data.clone(), + account: "test account".to_string(), + contract_address: "test contract".to_string(), + status_description: "desc".to_string(), }; order_responses.push(order_response.clone()); @@ -332,7 +336,7 @@ fn execute_place_orders_helper( // Execute: CancelOrders() fn execute_cancel_orders_helper( storage: &mut dyn Storage, - order_ids: Vec, + cancellations: Vec, contract_address: Addr, ) -> AnyResult { // get existing orders @@ -349,7 +353,8 @@ fn execute_cancel_orders_helper( serde_json::from_slice(&existing_order_responses.clone().unwrap()).unwrap(); let mut order_responses: Vec = serde_json::from_str(&responses_json).unwrap(); - for order_id in &order_ids.clone() { + let order_ids: Vec = cancellations.iter().map(|c| -> u64 { c.id }).collect(); + for order_id in order_ids.clone() { let order_response: Vec = order_responses .clone() .into_iter()