From 1d51933806f22ad9c7e1520ad64d1b0daeda1980 Mon Sep 17 00:00:00 2001 From: Shriya Tyagi Date: Tue, 7 Jun 2022 15:04:42 +0530 Subject: [PATCH] minor updates --- contracts/mainnet/connectors/socket/main.sol | 9 ++++++--- test/mainnet/socket/socket.test.ts | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/contracts/mainnet/connectors/socket/main.sol b/contracts/mainnet/connectors/socket/main.sol index 326280ca..a5899fbb 100644 --- a/contracts/mainnet/connectors/socket/main.sol +++ b/contracts/mainnet/connectors/socket/main.sol @@ -11,7 +11,7 @@ import { Basic } from "../../common/basic.sol"; import { TokenInterface } from "../../common/interfaces.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./events.sol"; - +import "hardhat/console.sol"; abstract contract SocketConnector is Basic { struct BridgeParams { @@ -43,9 +43,12 @@ abstract contract SocketConnector is Basic { ? _tokenContract.balanceOf(address(this)) : _params.amount; - - _tokenContract.approve(_params.to, _params.amount); + console.log("address this balance: ", _tokenContract.balanceOf(address(this))); + console.log("_params.allowanceTarget: ", _params.allowanceTarget); + console.log("_params.amount: ", _params.amount); + _tokenContract.approve(_params.allowanceTarget, _params.amount); (bool success, ) = _params.to.call(_params.txData); + console.log("success: ", success); require(success); } diff --git a/test/mainnet/socket/socket.test.ts b/test/mainnet/socket/socket.test.ts index 8313c6eb..f6e3ed16 100644 --- a/test/mainnet/socket/socket.test.ts +++ b/test/mainnet/socket/socket.test.ts @@ -187,13 +187,13 @@ describe("Socket Connector", function () { const quote = await getQuote(fromChainId, DAI_ADDR_ETH, toChainId, DAI_ADDR_POLYGON, "10000000000000000000", dsaWallet0.address, recipient, "true"); console.log("quote: ", quote) const route = quote.result.routes[0]; - console.log("route: ", route[0]) + console.log("route: ", quote.result.routes[0]) const apiReturnData = await getRouteTransactionData(route); console.log("build-tx: ", apiReturnData) const { allowanceTarget, minimumApprovalAmount } = apiReturnData.result.approvalData; const dsa_signer = await ethers.getSigner(dsaWallet0.address) - const _params: any = [recipient, apiReturnData.result?.txData, DAI_ADDR_ETH, allowanceTarget, "10000000000000000000"]; + const _params: any = [apiReturnData.result.txTarget, apiReturnData.result?.txData, DAI_ADDR_ETH, allowanceTarget, "10000000000000000000"]; const spells = [ { @@ -209,8 +209,9 @@ describe("Socket Connector", function () { if (allowanceTarget !== null) { const allowanceCheckStatus = await checkAllowance(fromChainId, dsaWallet0.address, allowanceTarget, DAI_ADDR_ETH) + console.log("allowanceCheckStatus: ", allowanceCheckStatus); const allowanceValue = allowanceCheckStatus.result?.value; - console.log("allowanceValue: ", allowanceValue); + // console.log("allowanceValue: ", allowanceValue); if (minimumApprovalAmount > allowanceValue) { const approvalTransactionData = await getApprovalTransactionData(fromChainId, dsaWallet0.address, allowanceTarget, DAI_ADDR_ETH, minimumApprovalAmount);