Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/to adress tron #342

Merged
merged 10 commits into from
Sep 27, 2024
Merged
67 changes: 0 additions & 67 deletions .github/workflows/publish_oraiswap_v3.yml

This file was deleted.

4 changes: 2 additions & 2 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.8",
"version": "0.1.20",
"main": "build/index.js",
"files": [
"build/"
Expand All @@ -13,6 +13,6 @@
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.31.0",
"@oraichain/oraidex-contracts-sdk": "^1.0.52",
"@oraichain/oraidex-common": "^1.1.6"
"@oraichain/oraidex-common": "^1.1.21"
}
}
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.10",
"version": "1.1.11",
"main": "build/index.js",
"files": [
"build/"
Expand Down
27 changes: 14 additions & 13 deletions packages/universal-swap/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ import {
IBC_WASM_CONTRACT,
IBC_WASM_CONTRACT_TEST,
tokenMap,
AmountDetails,
buildMultipleExecuteMessages,
ibcInfosOld,
checkValidateAddressWithNetwork,
BigDecimal,
OSMOSIS_ROUTER_CONTRACT,
cosmosChains,
parseAssetInfoFromContractAddrOrDenom,
TON_ORAICHAIN_DENOM,
toDisplay
toDisplay,
ChainIdEnum
} from "@oraichain/oraidex-common";
import { ethers } from "ethers";
import { UniversalSwapHelper } from "./helper";
Expand Down Expand Up @@ -233,7 +231,8 @@ export class UniversalSwapHandler {
if (recipientAddress) {
const isValidRecipient = checkValidateAddressWithNetwork(this.swapData.recipientAddress, toToken.originalChainId);
if (!isValidRecipient.isValid) throw generateError("Recipient address invalid!");
transferAddress = recipientAddress;
transferAddress =
toToken.originalChainId === ChainIdEnum.TRON ? tronToEthAddress(recipientAddress) : recipientAddress;
} else {
transferAddress = this.getTranferAddress(metamaskAddress, tronAddress, channel);
}
Expand Down Expand Up @@ -1152,20 +1151,22 @@ export class UniversalSwapHandler {

async processUniversalSwap() {
const { evm, tron } = this.swapData.sender;
const { originalFromToken, originalToToken, simulateAmount, relayerFee } = this.swapData;
const { originalFromToken, originalToToken, simulateAmount, recipientAddress, relayerFee } = this.swapData;
const { swapOptions } = this.config;
let toAddress = "";
const currentToNetwork = this.swapData.originalToToken.chainId;
const currentToNetwork = originalToToken.chainId;

if (this.swapData.recipientAddress) {
const isValidRecipient = checkValidateAddressWithNetwork(this.swapData.recipientAddress, currentToNetwork);
const isValidRecipient = checkValidateAddressWithNetwork(recipientAddress, currentToNetwork);

if (!isValidRecipient.isValid) {
throw generateError("Recipient address invalid!");
}
toAddress = this.swapData.recipientAddress;
if (!isValidRecipient.isValid) throw generateError("Recipient address invalid!");

toAddress =
originalToToken.chainId === ChainIdEnum.TRON
? tronToEthAddress(recipientAddress)
: this.swapData.recipientAddress;
} else {
toAddress = await this.getUniversalSwapToAddress(this.swapData.originalToToken.chainId, {
toAddress = await this.getUniversalSwapToAddress(originalToToken.chainId, {
metamaskAddress: evm,
tronAddress: tron
});
Expand Down
Loading