From 30ef33c22dc685ee4472e2117df7982742235d2c Mon Sep 17 00:00:00 2001 From: Hau Nguyen Van Date: Wed, 11 Dec 2024 18:10:38 +0700 Subject: [PATCH] fix bridge injective --- packages/universal-swap/package.json | 2 +- packages/universal-swap/src/handler.ts | 13 +++++++++++-- packages/universal-swap/src/msg/msgs.ts | 2 +- yarn.lock | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/universal-swap/package.json b/packages/universal-swap/package.json index 7d4a69d0..6e78231d 100644 --- a/packages/universal-swap/package.json +++ b/packages/universal-swap/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-universal-swap", - "version": "1.1.24", + "version": "1.1.25", "main": "build/index.js", "files": [ "build/" diff --git a/packages/universal-swap/src/handler.ts b/packages/universal-swap/src/handler.ts index a1adccb8..32305826 100644 --- a/packages/universal-swap/src/handler.ts +++ b/packages/universal-swap/src/handler.ts @@ -1,6 +1,7 @@ import { Coin, EncodeObject, coin } from "@cosmjs/proto-signing"; import { fromBech32, toBech32 } from "@cosmjs/encoding"; import { MsgTransfer } from "cosmjs-types/ibc/applications/transfer/v1/tx"; +import { MsgTransfer as MsgTransferInjective } from "@injectivelabs/sdk-ts/node_modules/cosmjs-types/ibc/applications/transfer/v1/tx"; import { ExecuteInstruction, ExecuteResult, toBinary } from "@cosmjs/cosmwasm-stargate"; import { TransferBackMsg } from "@oraichain/common-contracts-sdk/build/CwIcs20Latest.types"; import { @@ -709,7 +710,7 @@ export class UniversalSwapHandler { const swapRouteSplit = completeSwapRoute.split(":"); const swapRoute = swapRouteSplit.length === 1 ? "" : swapRouteSplit[1]; - let msgTransfer = MsgTransfer.fromPartial({ + const msgTransferObj = { sourcePort: ibcInfo.source, receiver: this.getCwIcs20ContractAddr(), sourceChannel: ibcInfo.channel, @@ -728,7 +729,15 @@ export class UniversalSwapHandler { } }), timeoutTimestamp: BigInt(calculateTimeoutTimestamp(ibcInfo.timeout)) - }); + }; + + let msgTransfer: MsgTransfer | MsgTransferInjective = MsgTransfer.fromPartial(msgTransferObj); + if (originalFromToken.chainId === "injective-1") { + msgTransfer = MsgTransferInjective.fromPartial({ + ...msgTransferObj, + timeoutTimestamp: calculateTimeoutTimestamp(ibcInfo.timeout) + }); + } // check if from chain is noble, use ibc-wasm instead of ibc-hooks if (originalFromToken.chainId === "noble-1") { diff --git a/packages/universal-swap/src/msg/msgs.ts b/packages/universal-swap/src/msg/msgs.ts index 7eeaab0f..fbf136e0 100644 --- a/packages/universal-swap/src/msg/msgs.ts +++ b/packages/universal-swap/src/msg/msgs.ts @@ -93,7 +93,7 @@ const buildExecuteMsg = ( let prefix = getDestPrefixForBridgeToEvmOnOrai(path.tokenOutChainId); const ORAIBRIDGE_SUBNET = "oraibridge-subnet-2"; let oBridgeAddress = addresses[ORAIBRIDGE_SUBNET]; - if (!oBridgeAddress) { + if (!oBridgeAddress && !isEvmChain(path.tokenOutChainId)) { throw generateError(`Missing oBridge address for ${ORAIBRIDGE_SUBNET}`); } diff --git a/yarn.lock b/yarn.lock index 4b13ec9d..89f07d01 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3744,7 +3744,7 @@ resolved "https://registry.yarnpkg.com/@oraichain/common-contracts-sdk/-/common-contracts-sdk-1.0.31.tgz#595f93b168438d69d64896909b37855c9afc92fb" integrity sha512-s8H20RXy5gCnu3DnM7L5ClQyj2mdQpbSBpZrXCpIAX9qY0LKsDdZG3sYaDQ8+VN333jz9Pp/qGWdFSYD+6PBsg== -"@oraichain/common@^1.1.4": +"@oraichain/common@^1.2.4": version "1.2.4" resolved "https://registry.yarnpkg.com/@oraichain/common/-/common-1.2.4.tgz#1a28dc288f3ada9d802541454585839e5c275deb" integrity sha512-/2TIpqDrJKgh/gb50s+sz5lhsffsj6QOVrJh1QrlIsRlup3yQnahm06vwsiVOX75rbdAMO5c7tJiXjKkHbfkww==