diff --git a/src/contract.rs b/src/contract.rs index 9fd0657..e4fefdc 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -134,7 +134,6 @@ pub mod execute { coin.amount.into() }; let asked_asset = pair_info.1.clone(); - // Pair of hINJ-INJ on testnet let swap_astro_msg = pair::ExecuteMsg::Swap { offer_asset: Asset::native(&offer_asset, amount), @@ -149,7 +148,6 @@ pub mod execute { msg: to_json_binary(&swap_astro_msg)?, funds: coins(amount, &offer_asset), }; - assert!(offer_asset == "inj"); let submessage = SubMsg::reply_on_success(exec_cw20_mint_msg, SWAP_REPLY_ID); let res = Response::new() .add_submessage(submessage) @@ -200,12 +198,12 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { } pub mod query { + use crate::contract::*; use crate::msg::{GetPairResponse, GetPoolAddrResponse}; use crate::state::POOL_INFO; - use crate::{contract::*, error}; use cosmwasm_std::StdResult; - pub fn query_pair(deps: Deps, env: Env, pool_address: String) -> StdResult { + pub fn query_pair(deps: Deps, _env: Env, pool_address: String) -> StdResult { let pair: Vec<_> = POOL_INFO .idx .address @@ -228,7 +226,7 @@ pub mod query { } pub fn query_pool_addr( deps: Deps, - env: Env, + _env: Env, token_1: String, token_2: String, ) -> StdResult { @@ -252,7 +250,7 @@ pub mod query { .iter() .map(|pool_info| pool_info.1.address.to_string().clone()) .collect::>(); - return Ok(GetPoolAddrResponse { pool_addresses }); + Ok(GetPoolAddrResponse { pool_addresses }) } } @@ -261,7 +259,6 @@ mod tests { use crate::msg::GetPairResponse; use super::*; - use cosmwasm_std::coins; use cosmwasm_std::Addr; use cw_multi_test::{App, ContractWrapper, Executor}; diff --git a/ts/LqExpress.client.ts b/ts/LqExpress.client.ts new file mode 100644 index 0000000..c7dcd1d --- /dev/null +++ b/ts/LqExpress.client.ts @@ -0,0 +1,122 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; +import { Coin, StdFee } from "@cosmjs/amino"; +import { InstantiateMsg, ExecuteMsg, QueryMsg, GetPairResponse, GetPoolAddrResponse } from "./LqExpress.types"; +export interface LqExpressReadOnlyInterface { + contractAddress: string; + getPair: ({ + poolAddress + }: { + poolAddress: string; + }) => Promise; + getPoolAddr: ({ + token1, + token2 + }: { + token1: string; + token2: string; + }) => Promise; +} +export class LqExpressQueryClient implements LqExpressReadOnlyInterface { + client: CosmWasmClient; + contractAddress: string; + + constructor(client: CosmWasmClient, contractAddress: string) { + this.client = client; + this.contractAddress = contractAddress; + this.getPair = this.getPair.bind(this); + this.getPoolAddr = this.getPoolAddr.bind(this); + } + + getPair = async ({ + poolAddress + }: { + poolAddress: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + get_pair: { + pool_address: poolAddress + } + }); + }; + getPoolAddr = async ({ + token1, + token2 + }: { + token1: string; + token2: string; + }): Promise => { + return this.client.queryContractSmart(this.contractAddress, { + get_pool_addr: { + token_1: token1, + token_2: token2 + } + }); + }; +} +export interface LqExpressInterface extends LqExpressReadOnlyInterface { + contractAddress: string; + sender: string; + astro: ({ + pairAddress + }: { + pairAddress: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + addSupportedPool: ({ + poolAddress, + token1, + token2 + }: { + poolAddress: string; + token1: string; + token2: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; +} +export class LqExpressClient extends LqExpressQueryClient implements LqExpressInterface { + client: SigningCosmWasmClient; + sender: string; + contractAddress: string; + + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { + super(client, contractAddress); + this.client = client; + this.sender = sender; + this.contractAddress = contractAddress; + this.astro = this.astro.bind(this); + this.addSupportedPool = this.addSupportedPool.bind(this); + } + + astro = async ({ + pairAddress + }: { + pairAddress: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + astro: { + pair_address: pairAddress + } + }, fee, memo, _funds); + }; + addSupportedPool = async ({ + poolAddress, + token1, + token2 + }: { + poolAddress: string; + token1: string; + token2: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + add_supported_pool: { + pool_address: poolAddress, + token_1: token1, + token_2: token2 + } + }, fee, memo, _funds); + }; +} \ No newline at end of file diff --git a/ts/LqExpress.types.ts b/ts/LqExpress.types.ts new file mode 100644 index 0000000..00663e5 --- /dev/null +++ b/ts/LqExpress.types.ts @@ -0,0 +1,35 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@0.35.3. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +export interface InstantiateMsg {} +export type ExecuteMsg = { + astro: { + pair_address: string; + }; +} | { + add_supported_pool: { + pool_address: string; + token_1: string; + token_2: string; + }; +}; +export type QueryMsg = { + get_pair: { + pool_address: string; + }; +} | { + get_pool_addr: { + token_1: string; + token_2: string; + }; +}; +export interface GetPairResponse { + token_1: string; + token_2: string; +} +export interface GetPoolAddrResponse { + pool_addresses: string[]; +} \ No newline at end of file