Skip to content

Commit

Permalink
Merge pull request #380 from oraidex/fix/optimize
Browse files Browse the repository at this point in the history
fix bridge injective
  • Loading branch information
haunv3 authored Dec 12, 2024
2 parents eb14329 + 30ef33c commit 7ffb596
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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.24",
"version": "1.1.25",
"main": "build/index.js",
"files": [
"build/"
Expand Down
13 changes: 11 additions & 2 deletions packages/universal-swap/src/handler.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion packages/universal-swap/src/msg/msgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit 7ffb596

Please sign in to comment.