-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
import { OraiswapTokenTypes, OraiswapRouterTypes, OraiswapStakingTypes, OraiswapLimitOrderTypes, OraiswapOracleTypes, OraiswapFactoryTypes, OraiswapRewarderTypes, OraiswapPairTypes } from '@oraichain/oraidex-contracts-sdk'; | ||
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate'; | ||
import { readFileSync } from 'fs'; | ||
import path from 'path'; | ||
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; | ||
import { readFileSync } from "fs"; | ||
import path from "path"; | ||
|
||
export type ContractName = 'oraiswap_token' | 'oraiswap_limit_order' | 'oraiswap_pair' | 'oraiswap_oracle' | 'oraiswap_converter' | 'oraiswap_factory' | 'oraiswap_rewarder' | 'oraiswap_router' | 'oraiswap_staking'; | ||
export type ContractName = | ||
| "oraiswap_token" | ||
| "oraiswap_limit_order" | ||
| "oraiswap_pair" | ||
| "oraiswap_oracle" | ||
| "oraiswap_converter" | ||
| "oraiswap_factory" | ||
| "oraiswap_rewarder" | ||
| "oraiswap_router" | ||
| "oraiswap_staking" | ||
| "oraidex-listing-contract"; | ||
|
||
export type InstantiateMsg = | ||
| OraiswapTokenTypes.InstantiateMsg | ||
| OraiswapLimitOrderTypes.InstantiateMsg | ||
| OraiswapPairTypes.InstantiateMsg | ||
| OraiswapOracleTypes.InstantiateMsg | ||
| OraiswapFactoryTypes.InstantiateMsg | ||
| OraiswapRewarderTypes.InstantiateMsg | ||
| OraiswapRouterTypes.InstantiateMsg | ||
| OraiswapStakingTypes.InstantiateMsg; | ||
const contractDir = path.join(path.dirname(module.filename), "..", "data"); | ||
|
||
const contractDir = path.join(path.dirname(module.filename), '..', 'data'); | ||
|
||
export const getContractDir = (name: ContractName = 'oraiswap_limit_order') => { | ||
return path.join(contractDir, name + '.wasm'); | ||
export const getContractDir = (name: ContractName = "oraiswap_limit_order") => { | ||
return path.join(contractDir, name + ".wasm"); | ||
}; | ||
|
||
export const deployContract = async (client: SigningCosmWasmClient, senderAddress: string, msg?: InstantiateMsg, label?: string, contractName?: ContractName) => { | ||
export const deployContract = async <T>( | ||
client: SigningCosmWasmClient, | ||
senderAddress: string, | ||
msg?: T, | ||
label?: string, | ||
contractName?: ContractName | ||
) => { | ||
// upload and instantiate the contract | ||
const wasmBytecode = readFileSync(getContractDir(contractName)); | ||
const uploadRes = await client.upload(senderAddress, wasmBytecode, 'auto'); | ||
const initRes = await client.instantiate(senderAddress, uploadRes.codeId, msg ?? {}, label ?? contractName, 'auto'); | ||
const uploadRes = await client.upload(senderAddress, wasmBytecode, "auto"); | ||
const initRes = await client.instantiate(senderAddress, uploadRes.codeId, msg ?? {}, label ?? contractName, "auto"); | ||
return { ...uploadRes, ...initRes }; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* This file was automatically generated by @oraichain/ts-codegen@0.35.8. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
* and run the @oraichain/ts-codegen generate command to regenerate this file. | ||
*/ | ||
|
||
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; | ||
import { Coin, StdFee } from "@cosmjs/amino"; | ||
import {Uint128, AssetInfo, Addr, Logo, EmbeddedLogo, Binary, Asset, InstantiateMarketingInfo} from "./types"; | ||
import {InstantiateMsg, ExecuteMsg, ListTokenMsg, MinterResponse, QueryMsg, MigrateMsg, Config} from "./OraidexListingContract.types"; | ||
export interface OraidexListingContractReadOnlyInterface { | ||
contractAddress: string; | ||
config: () => Promise<Config>; | ||
} | ||
export class OraidexListingContractQueryClient implements OraidexListingContractReadOnlyInterface { | ||
client: CosmWasmClient; | ||
contractAddress: string; | ||
|
||
constructor(client: CosmWasmClient, contractAddress: string) { | ||
this.client = client; | ||
this.contractAddress = contractAddress; | ||
this.config = this.config.bind(this); | ||
} | ||
|
||
config = async (): Promise<Config> => { | ||
return this.client.queryContractSmart(this.contractAddress, { | ||
config: {} | ||
}); | ||
}; | ||
} | ||
export interface OraidexListingContractInterface extends OraidexListingContractReadOnlyInterface { | ||
contractAddress: string; | ||
sender: string; | ||
listToken: ({ | ||
label, | ||
liquidityPoolRewardAssets, | ||
marketing, | ||
mint, | ||
symbol | ||
}: { | ||
label?: string; | ||
liquidityPoolRewardAssets: Asset[]; | ||
marketing?: InstantiateMarketingInfo; | ||
mint?: MinterResponse; | ||
symbol: string; | ||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||
} | ||
export class OraidexListingContractClient extends OraidexListingContractQueryClient implements OraidexListingContractInterface { | ||
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.listToken = this.listToken.bind(this); | ||
} | ||
|
||
listToken = async ({ | ||
label, | ||
liquidityPoolRewardAssets, | ||
marketing, | ||
mint, | ||
symbol | ||
}: { | ||
label?: string; | ||
liquidityPoolRewardAssets: Asset[]; | ||
marketing?: InstantiateMarketingInfo; | ||
mint?: MinterResponse; | ||
symbol: string; | ||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||
return await this.client.execute(this.sender, this.contractAddress, { | ||
list_token: { | ||
label, | ||
liquidity_pool_reward_assets: liquidityPoolRewardAssets, | ||
marketing, | ||
mint, | ||
symbol | ||
} | ||
}, _fee, _memo, _funds); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Uint128, AssetInfo, Addr, Logo, EmbeddedLogo, Binary, Asset, InstantiateMarketingInfo} from "./types"; | ||
export interface InstantiateMsg { | ||
cw20_code_id: number; | ||
factory_addr: string; | ||
} | ||
export type ExecuteMsg = { | ||
list_token: ListTokenMsg; | ||
}; | ||
export interface ListTokenMsg { | ||
label?: string | null; | ||
liquidity_pool_reward_assets: Asset[]; | ||
marketing?: InstantiateMarketingInfo | null; | ||
mint?: MinterResponse | null; | ||
symbol: string; | ||
} | ||
export interface MinterResponse { | ||
cap?: Uint128 | null; | ||
minter: string; | ||
} | ||
export type QueryMsg = { | ||
config: {}; | ||
}; | ||
export interface MigrateMsg {} | ||
export interface Config { | ||
cw20_code_id: number; | ||
factory_addr: Addr; | ||
owner: Addr; | ||
} |