-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add typescript for contract interaction
- Loading branch information
1 parent
a84c917
commit 18c9e0e
Showing
3 changed files
with
161 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/** | ||
* This file was automatically generated by @cosmwasm/[email protected]. | ||
* 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<GetPairResponse>; | ||
getPoolAddr: ({ | ||
token1, | ||
token2 | ||
}: { | ||
token1: string; | ||
token2: string; | ||
}) => Promise<GetPoolAddrResponse>; | ||
} | ||
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<GetPairResponse> => { | ||
return this.client.queryContractSmart(this.contractAddress, { | ||
get_pair: { | ||
pool_address: poolAddress | ||
} | ||
}); | ||
}; | ||
getPoolAddr = async ({ | ||
token1, | ||
token2 | ||
}: { | ||
token1: string; | ||
token2: string; | ||
}): Promise<GetPoolAddrResponse> => { | ||
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<ExecuteResult>; | ||
addSupportedPool: ({ | ||
poolAddress, | ||
token1, | ||
token2 | ||
}: { | ||
poolAddress: string; | ||
token1: string; | ||
token2: string; | ||
}, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||
} | ||
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<ExecuteResult> => { | ||
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<ExecuteResult> => { | ||
return await this.client.execute(this.sender, this.contractAddress, { | ||
add_supported_pool: { | ||
pool_address: poolAddress, | ||
token_1: token1, | ||
token_2: token2 | ||
} | ||
}, fee, memo, _funds); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* This file was automatically generated by @cosmwasm/[email protected]. | ||
* 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[]; | ||
} |