diff --git a/contracts/sei-tester/Cargo.toml b/contracts/sei-tester/Cargo.toml index 54b57b9..b8e171b 100644 --- a/contracts/sei-tester/Cargo.toml +++ b/contracts/sei-tester/Cargo.toml @@ -50,6 +50,7 @@ serde_json = { version = "1.0", default-features = false, features = ["alloc"] } base64 = { version = "0.21.7" } thiserror = { version = "1.0.31" } protobuf = { version = "3.2.0", features = ["with-bytes"] } +cw20 = "1.1.2" [dev-dependencies] cosmwasm-schema = "1.0.0" diff --git a/contracts/sei-tester/src/contract.rs b/contracts/sei-tester/src/contract.rs index da9e50d..77cc1a9 100644 --- a/contracts/sei-tester/src/contract.rs +++ b/contracts/sei-tester/src/contract.rs @@ -1,6 +1,6 @@ +// #[cfg(not(feature = "library"))] use base64::{engine::general_purpose, Engine as _}; use cosmwasm_std::to_json_binary; -#[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, @@ -21,6 +21,7 @@ use sei_cosmwasm::{ OrderType, PositionDirection, SeiAddressResponse, SeiMsg, SeiQuerier, SeiQueryWrapper, SettlementEntry, StaticCallResponse, SudoMsg, }; +use cw20::{TokenInfoResponse}; const PLACE_ORDER_REPLY_ID: u64 = 1; // version info for migration info @@ -453,6 +454,10 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult QueryMsg::GetSeiAddressByEvmAddress { evm_address } => { to_json_binary(&query_sei_address(deps, evm_address)?) } + QueryMsg::Erc20TokenInfo { + contract_address, + caller, + } => to_json_binary(&query_erc20_token_info(deps, contract_address, caller)?), } } @@ -600,3 +605,9 @@ pub fn query_sei_address( Ok(res) } + +fn query_erc20_token_info(deps: Deps, contract_address: String, caller: String) -> StdResult { + let querier = SeiQuerier::new(&deps.querier); + let erc20_token_info = querier.erc20_token_info(contract_address, caller)?; + Ok(erc20_token_info) +} \ No newline at end of file diff --git a/contracts/sei-tester/src/msg.rs b/contracts/sei-tester/src/msg.rs index b08adb4..baedfb3 100644 --- a/contracts/sei-tester/src/msg.rs +++ b/contracts/sei-tester/src/msg.rs @@ -32,7 +32,7 @@ pub enum ExecuteMsg { value: Uint128, to: String, data: String, - }, + } } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -83,4 +83,8 @@ pub enum QueryMsg { GetSeiAddressByEvmAddress { evm_address: String, }, + Erc20TokenInfo { + contract_address: String, + caller: String, + }, } diff --git a/contracts/sei-tester/tests/sei_tester_integration_tests.rs b/contracts/sei-tester/tests/sei_tester_integration_tests.rs index 076a30c..c14a648 100644 --- a/contracts/sei-tester/tests/sei_tester_integration_tests.rs +++ b/contracts/sei-tester/tests/sei_tester_integration_tests.rs @@ -6,6 +6,7 @@ use cosmwasm_std::{ QueryRequest, StdError, Storage, Uint128, }; use cosmwasm_std::{BlockInfo, Uint64}; +use cw20::TokenInfoResponse; use cw_multi_test::{ App, BankKeeper, ContractWrapper, DistributionKeeper, Executor, FailingModule, Router, StakeKeeper, WasmKeeper, @@ -1039,3 +1040,28 @@ fn test_sei_address_query() { }; assert_eq!(res, expected_res); } + +#[test] +fn test_erc20_token_info_query() { + let mut app = mock_app(init_default_balances, vec![]); + let sei_tester_addr = setup_test(&mut app); + + let res: TokenInfoResponse = app + .wrap() + .query_wasm_smart( + sei_tester_addr.clone(), + &QueryMsg::Erc20TokenInfo { + contract_address: EVM_ADDRESS.to_string(), + caller: SEI_ADDRESS.to_string(), + }, + ) + .unwrap(); + + let expected_res = TokenInfoResponse { + name: "Erc20Token".to_string(), + symbol: "TT".to_string(), + decimals: 18, + total_supply: Uint128::new(1000000), + }; + assert_eq!(res, expected_res); +} diff --git a/packages/sei-integration-tests/Cargo.toml b/packages/sei-integration-tests/Cargo.toml index c37e7ed..f4770b7 100644 --- a/packages/sei-integration-tests/Cargo.toml +++ b/packages/sei-integration-tests/Cargo.toml @@ -17,3 +17,4 @@ serde = { version = "1.0.137", default-features = false, features = ["derive"] } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } [dependencies] base64 = "0.21.7" +cw20 = "1.1.2" \ No newline at end of file diff --git a/packages/sei-integration-tests/src/module.rs b/packages/sei-integration-tests/src/module.rs index 939783e..c2b835e 100644 --- a/packages/sei-integration-tests/src/module.rs +++ b/packages/sei-integration-tests/src/module.rs @@ -19,6 +19,7 @@ use std::{ fmt::Debug, ops::{Add, Div, Mul, Sub}, }; +use cw20::TokenInfoResponse; pub struct SeiModule { epoch: Epoch, @@ -199,6 +200,14 @@ impl Module for SeiModule { SeiQuery::GetSeiAddress { evm_address } => { Ok(to_json_binary(&get_sei_address(evm_address))?) } + SeiQuery::Erc20TokenInfo { .. } => { + Ok(to_json_binary(&TokenInfoResponse { + name: "Erc20Token".to_string(), + symbol: "TT".to_string(), + decimals: 18, + total_supply: Uint128::new(1000000), + })?) + } // TODO: Implement get denom authority metadata in integration tests SeiQuery::DenomAuthorityMetadata { .. } => { panic!("Denom Authority Metadata not implemented")