Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
vuonghuuhung committed Oct 3, 2024
2 parents 302e298 + c8e6eb5 commit dfa75cf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion 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.19-beta.2",
"version": "0.1.20-beta.1",
"main": "build/index.js",
"files": [
"build/"
Expand Down
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.9",
"version": "1.1.11",
"main": "build/index.js",
"files": [
"build/"
Expand All @@ -11,7 +11,7 @@
},
"license": "MIT",
"dependencies": {
"@oraichain/oraidex-common": "^1.0.91",
"@oraichain/oraidex-common": "^1.1.21",
"@oraichain/oraidex-contracts-sdk": "^1.0.49",
"bech32": "1.1.4",
"ethers": "^5.0.15",
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
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3657,6 +3657,11 @@
resolved "https://registry.yarnpkg.com/@oraichain/immutable/-/immutable-4.3.9.tgz#ff8d5a7b39b5b01f3f72a902cffbfea32ccb20c3"
integrity sha512-INpHnhL970OCkR7I71Kssb2aLl2l4Y/x8W6FlyRO0KmC8GHjxc/hlNB1t44BiI7lkOYmcWMRQoC8dwParsp1RQ==

"@oraichain/oraidex-contracts-sdk@^1.0.24", "@oraichain/oraidex-contracts-sdk@^1.0.49":
version "1.0.51"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.51.tgz#395261248398a4cac15625923c4f97888115ca28"
integrity sha512-a/ajIST9JuJAB9yU/OwFhd3RjBlDPvAunMi19XSljiP4y9FLvo8Lht3KEnwELuQp1kVW1Iw1/B/S5dxmlcM4SQ==

"@oraichain/oraidex-contracts-sdk@latest":
version "1.0.44"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-contracts-sdk/-/oraidex-contracts-sdk-1.0.44.tgz#9ff41ec388dd92ba112c2eef545d11fd6e18c684"
Expand Down Expand Up @@ -17722,4 +17727,4 @@ [email protected]:
zstd-codec@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/zstd-codec/-/zstd-codec-0.1.4.tgz#6abb311b63cfacbd06e72797ee6c6e1c7c65248c"
integrity sha512-KYnWoFWgGtWyQEKNnUcb3u8ZtKO8dn5d8u+oGpxPlopqsPyv60U8suDyfk7Z7UtAO6Sk5i1aVcAs9RbaB1n36A==
integrity sha512-KYnWoFWgGtWyQEKNnUcb3u8ZtKO8dn5d8u+oGpxPlopqsPyv60U8suDyfk7Z7UtAO6Sk5i1aVcAs9RbaB1n36A==

0 comments on commit dfa75cf

Please sign in to comment.