Skip to content

Commit

Permalink
Merge pull request #360 from oraidex/feat/pump-cosmjs
Browse files Browse the repository at this point in the history
Feat/pump cosmjs
  • Loading branch information
haunv3 authored Nov 12, 2024
2 parents dce3d42 + 8386430 commit c48d0b8
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 102 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"node": ">=18.18.0"
},
"dependencies": {
"@cosmjs/amino": "0.31.3",
"@cosmjs/cosmwasm-stargate": "0.31.3",
"@cosmjs/crypto": "0.31.3",
"@cosmjs/proto-signing": "0.31.3",
"@cosmjs/stargate": "0.31.3",
"@cosmjs/tendermint-rpc": "0.31.3",
"@cosmjs/amino": "^0.32.4",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/crypto": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"@oraichain/common-contracts-build": "1.0.35",
"@oraichain/common-contracts-sdk": "1.0.31"
},
"devDependencies": {
"@babel/traverse": "7.24.1",
"@cosmjs/encoding": "0.31.3",
"@cosmjs/encoding": "^0.32.4",
"@oraichain/cw-simulate": "^2.8.68",
"@swc/core": "^1.4.11",
"@swc/jest": "^0.2.36",
Expand All @@ -44,7 +44,7 @@
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitest/coverage-v8": "^2.0.2",
"cosmjs-types": "0.8.0",
"cosmjs-types": "^0.9.0",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-contracts-sdk",
"version": "1.0.53",
"version": "1.0.55",
"main": "build/index.js",
"files": [
"build/",
Expand Down
41 changes: 40 additions & 1 deletion packages/contracts-sdk/src/OraiswapV3.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import {Addr, Percentage, InstantiateMsg, ExecuteMsg, Liquidity, SqrtPrice, TokenAmount, Binary, Expiration, Timestamp, Uint64, AssetInfo, PoolKey, FeeTier, SwapHop, NftExtensionMsg, QueryMsg, MigrateMsg, FeeGrowth, AllNftInfoResponse, OwnerOfResponse, Approval, NftInfoResponse, Position, PositionIncentives, ArrayOfPosition, TokensResponse, ApprovedForAllResponse, Boolean, ArrayOfFeeTier, ArrayOfLiquidityTick, LiquidityTick, Uint32, NumTokensResponse, Pool, IncentiveRecord, ArrayOfPoolWithPoolKey, PoolWithPoolKey, Uint128, ArrayOfAsset, Asset, ArrayOfPositionTick, PositionTick, QuoteResult, Tick, TickIncentive, ArrayOfTupleOfUint16AndUint64} from "./OraiswapV3.types";
import {Addr, Percentage, InstantiateMsg, ExecuteMsg, Liquidity, SqrtPrice, TokenAmount, Binary, Expiration, Timestamp, Uint64, AssetInfo, PoolStatus, PoolKey, FeeTier, SwapHop, NftExtensionMsg, QueryMsg, MigrateMsg, FeeGrowth, AllNftInfoResponse, OwnerOfResponse, Approval, NftInfoResponse, Position, PositionIncentives, ArrayOfPosition, TokensResponse, ApprovedForAllResponse, Boolean, ArrayOfFeeTier, ArrayOfLiquidityTick, LiquidityTick, Uint32, NumTokensResponse, Pool, IncentiveRecord, ArrayOfPoolWithPoolKey, PoolWithPoolKey, Uint128, ArrayOfAsset, Asset, ArrayOfPositionTick, PositionTick, QuoteResult, Tick, TickIncentive, ArrayOfTupleOfUint16AndUint64} from "./OraiswapV3.types";
export interface OraiswapV3ReadOnlyInterface {
contractAddress: string;
admin: () => Promise<Addr>;
Expand Down Expand Up @@ -631,6 +631,11 @@ export interface OraiswapV3Interface extends OraiswapV3ReadOnlyInterface {
}: {
poolKey: PoolKey;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
withdrawAllProtocolFee: ({
receiver
}: {
receiver?: Addr;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
changeProtocolFee: ({
protocolFee
}: {
Expand Down Expand Up @@ -807,6 +812,13 @@ export interface OraiswapV3Interface extends OraiswapV3ReadOnlyInterface {
}: {
index: number;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
updatePoolStatus: ({
poolKey,
status
}: {
poolKey: PoolKey;
status?: PoolStatus;
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
}
export class OraiswapV3Client extends OraiswapV3QueryClient implements OraiswapV3Interface {
client: SigningCosmWasmClient;
Expand All @@ -820,6 +832,7 @@ export class OraiswapV3Client extends OraiswapV3QueryClient implements OraiswapV
this.contractAddress = contractAddress;
this.changeAdmin = this.changeAdmin.bind(this);
this.withdrawProtocolFee = this.withdrawProtocolFee.bind(this);
this.withdrawAllProtocolFee = this.withdrawAllProtocolFee.bind(this);
this.changeProtocolFee = this.changeProtocolFee.bind(this);
this.changeFeeReceiver = this.changeFeeReceiver.bind(this);
this.createPosition = this.createPosition.bind(this);
Expand All @@ -842,6 +855,7 @@ export class OraiswapV3Client extends OraiswapV3QueryClient implements OraiswapV
this.createIncentive = this.createIncentive.bind(this);
this.updateIncentive = this.updateIncentive.bind(this);
this.claimIncentive = this.claimIncentive.bind(this);
this.updatePoolStatus = this.updatePoolStatus.bind(this);
}

changeAdmin = async ({
Expand All @@ -866,6 +880,17 @@ export class OraiswapV3Client extends OraiswapV3QueryClient implements OraiswapV
}
}, _fee, _memo, _funds);
};
withdrawAllProtocolFee = async ({
receiver
}: {
receiver?: Addr;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
withdraw_all_protocol_fee: {
receiver
}
}, _fee, _memo, _funds);
};
changeProtocolFee = async ({
protocolFee
}: {
Expand Down Expand Up @@ -1207,4 +1232,18 @@ export class OraiswapV3Client extends OraiswapV3QueryClient implements OraiswapV
}
}, _fee, _memo, _funds);
};
updatePoolStatus = async ({
poolKey,
status
}: {
poolKey: PoolKey;
status?: PoolStatus;
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
update_pool_status: {
pool_key: poolKey,
status
}
}, _fee, _memo, _funds);
};
}
11 changes: 11 additions & 0 deletions packages/contracts-sdk/src/OraiswapV3.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export type ExecuteMsg = {
withdraw_protocol_fee: {
pool_key: PoolKey;
};
} | {
withdraw_all_protocol_fee: {
receiver?: Addr | null;
};
} | {
change_protocol_fee: {
protocol_fee: Percentage;
Expand Down Expand Up @@ -133,6 +137,11 @@ export type ExecuteMsg = {
claim_incentive: {
index: number;
};
} | {
update_pool_status: {
pool_key: PoolKey;
status?: PoolStatus | null;
};
};
export type Liquidity = string;
export type SqrtPrice = string;
Expand All @@ -156,6 +165,7 @@ export type AssetInfo = {
denom: string;
};
};
export type PoolStatus = "opening" | "paused" | "swap_only" | "lp_only";
export interface PoolKey {
fee_tier: FeeTier;
token_x: string;
Expand Down Expand Up @@ -382,6 +392,7 @@ export interface Pool {
liquidity: Liquidity;
sqrt_price: SqrtPrice;
start_timestamp: number;
status?: PoolStatus | null;
}
export interface IncentiveRecord {
id: number;
Expand Down
4 changes: 2 additions & 2 deletions packages/ibc-routing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/ibc-routing",
"version": "1.0.0",
"version": "1.0.1",
"main": "build/index.js",
"files": [
"build/"
Expand All @@ -27,7 +27,7 @@
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/ws": "^8.5.4",
"cosmjs-types": "^0.8.0",
"cosmjs-types": "^0.9.0",
"dotenv": "^16.3.1",
"hardhat": "^2.18.2",
"jest-websocket-mock": "^2.5.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/oraidex-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-common",
"version": "1.1.28",
"version": "1.1.29",
"main": "build/index.js",
"files": [
"build/"
Expand All @@ -16,14 +16,14 @@
"@ethersproject/providers": "^5.0.10",
"ethers": "^5.0.15",
"@keplr-wallet/types": "^0.11.38",
"@cosmjs/amino": "0.31.3",
"@cosmjs/cosmwasm-stargate": "0.31.3",
"@cosmjs/crypto": "0.31.3",
"@cosmjs/proto-signing": "0.31.3",
"@cosmjs/stargate": "0.31.3",
"@cosmjs/tendermint-rpc": "0.31.3",
"@cosmjs/amino": "^0.32.4",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/crypto": "^0.32.4",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"bignumber.js": "^9.1.2",
"cosmjs-types": "0.8.0",
"cosmjs-types": "^0.9.0",
"@oraichain/oraidex-contracts-sdk": "latest",
"@injectivelabs/sdk-ts": "1.12.1",
"tronweb": "6.0.0-beta.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/oraidex-common/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export abstract class CosmosWallet {
if (chainId === "injective-1") {
client = await Stargate.InjectiveSigningStargateClient.createWithSigner(
tmClient as any,
wallet,
wallet as any,
optionsClient as any
);
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/oraiswap-v3/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraiswap-v3",
"version": "0.1.22",
"version": "1.1.0",
"main": "build/index.js",
"files": [
"build/"
Expand All @@ -11,8 +11,8 @@
},
"license": "MIT",
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.31.0",
"@oraichain/oraidex-contracts-sdk": "^1.0.53",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@oraichain/oraidex-contracts-sdk": "^1.0.54",
"@oraichain/oraidex-common": "^1.1.27"
}
}
4 changes: 2 additions & 2 deletions packages/universal-swap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-universal-swap",
"version": "1.1.19",
"version": "1.1.20",
"main": "build/index.js",
"files": [
"build/"
Expand All @@ -21,7 +21,7 @@
"@oraichain/osor-api-contracts-sdk": "^1.0.2"
},
"devDependencies": {
"cosmjs-types": "0.8.0",
"cosmjs-types": "^0.9.0",
"ts-results": "^3.3.0",
"protobufjs": "7.2.6"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/universal-swap/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class UniversalSwapHandler {
sender: sender,
receiver: ibcReceiveAddr,
memo: "",
timeoutTimestamp: timeoutTimestamp ?? calculateTimeoutTimestamp(ibcInfo.timeout)
timeoutTimestamp: BigInt(timeoutTimestamp ?? calculateTimeoutTimestamp(ibcInfo.timeout))
})
}
];
Expand Down Expand Up @@ -302,7 +302,7 @@ export class UniversalSwapHandler {
sender: this.swapData.sender.cosmos,
receiver: toAddress,
memo: ibcMemo,
timeoutTimestamp: calculateTimeoutTimestamp(ibcInfos.timeout, this.currentTimestamp)
timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfos.timeout, this.currentTimestamp))
})
};
return [...msgExecuteSwap, ...getEncodedExecuteMsgs, msgTransfer];
Expand Down Expand Up @@ -1119,7 +1119,7 @@ export class UniversalSwapHandler {
}
}
}),
timeoutTimestamp: calculateTimeoutTimestamp(ibcInfo.timeout)
timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfo.timeout))
});

// check if from chain is noble, use ibc-wasm instead of ibc-hooks
Expand Down
14 changes: 10 additions & 4 deletions packages/universal-swap/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,11 @@ describe("test universal swap handler functions", () => {
token: { denom: OSMOSIS_ORAICHAIN_DENOM, amount: simulateAmount }, //osmosis denom
sender: testSenderAddress,
receiver: "osmo1234",
timeoutHeight: undefined,
timeoutTimestamp: new Long(0),
timeoutHeight: {
revisionHeight: 0n,
revisionNumber: 0n
},
timeoutTimestamp: 0n,
memo: ""
}
}
Expand Down Expand Up @@ -436,8 +439,11 @@ describe("test universal swap handler functions", () => {
token: { denom: OSMOSIS_ORAICHAIN_DENOM, amount: simulateAmount },
sender: testSenderAddress,
receiver: "osmo1234",
timeoutHeight: undefined,
timeoutTimestamp: new Long(0),
timeoutHeight: {
revisionHeight: 0n,
revisionNumber: 0n
},
timeoutTimestamp: 0n,
memo: ""
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
diff --git a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts
index 3aebdc5..d5cbeec 100644
index a770785..3f427c8 100644
--- a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts
+++ b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts
@@ -56,6 +56,7 @@ export declare class CosmWasmClient {
*/
static create(tmClient: TendermintClient): Promise<CosmWasmClient>;
protected constructor(tmClient: TendermintClient | undefined);
@@ -58,6 +58,7 @@ export declare class CosmWasmClient {
protected constructor(cometClient: CometClient | undefined);
protected getCometClient(): CometClient | undefined;
protected forceGetCometClient(): CometClient;
+ public setQueryClientWithHeight(height?: number): void;
protected getTmClient(): TendermintClient | undefined;
protected forceGetTmClient(): TendermintClient;
protected getQueryClient(): (QueryClient & AuthExtension & BankExtension & TxExtension & WasmExtension) | undefined;
protected forceGetQueryClient(): QueryClient & AuthExtension & BankExtension & TxExtension & WasmExtension;
getChainId(): Promise<string>;
diff --git a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js
index 8f6305b..90cedba 100644
index af8341d..bc91fbc 100644
--- a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js
+++ b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js
@@ -46,6 +46,13 @@ class CosmWasmClient {
this.queryClient = stargate_1.QueryClient.withExtensions(tmClient, stargate_1.setupAuthExtension, stargate_1.setupBankExtension, modules_1.setupWasmExtension, stargate_1.setupTxExtension);
@@ -35,6 +35,13 @@ class CosmWasmClient {
this.queryClient = stargate_1.QueryClient.withExtensions(cometClient, stargate_1.setupAuthExtension, stargate_1.setupBankExtension, modules_1.setupWasmExtension, stargate_1.setupTxExtension);
}
}
+
Expand All @@ -25,17 +25,36 @@ index 8f6305b..90cedba 100644
+ }
+ }
+
getTmClient() {
return this.tmClient;
getCometClient() {
return this.cometClient;
}
@@ -120,12 +127,12 @@ class CosmWasmClient {
else if ((0, stargate_1.isSearchTxQueryArray)(query)) {
rawQuery = query
.map((t) => {
- // numeric values must not have quotes https://github.com/cosmos/cosmjs/issues/1462
- if (typeof t.value === "string")
- return `${t.key}='${t.value}'`;
- else
- return `${t.key}=${t.value}`;
- })
+ // numeric values must not have quotes https://github.com/cosmos/cosmjs/issues/1462
+ if (typeof t.value === "string")
+ return `${t.key}='${t.value}'`;
+ else
+ return `${t.key}=${t.value}`;
+ })
.join(" AND ");
}
else {
diff --git a/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js b/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js
index c060369..41029c3 100644
index e5bf448..878f7e4 100644
--- a/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js
+++ b/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js
@@ -8,8 +8,8 @@ const encoding_1 = require("@cosmjs/encoding");
@@ -4,8 +4,8 @@ exports.setupWasmExtension = void 0;
const encoding_1 = require("@cosmjs/encoding");
const stargate_1 = require("@cosmjs/stargate");
const query_1 = require("cosmjs-types/cosmwasm/wasm/v1/query");
const long_1 = __importDefault(require("long"));
-function setupWasmExtension(base) {
- const rpc = (0, stargate_1.createProtobufRpcClient)(base);
+function setupWasmExtension(base, height) {
Expand Down
Loading

0 comments on commit c48d0b8

Please sign in to comment.