From 0d90d4e64b1a55be06f0ba64c7a0a11866aea417 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 13 Aug 2024 20:14:30 +0100 Subject: [PATCH 1/2] refactor: don't adjust `payload.value` that SDK already handles --- .../pages/state-managed-bridge/index.tsx | 16 +--------------- packages/synapse-interface/pages/swap/index.tsx | 16 +--------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/packages/synapse-interface/pages/state-managed-bridge/index.tsx b/packages/synapse-interface/pages/state-managed-bridge/index.tsx index 972698b47a..6e452001d0 100644 --- a/packages/synapse-interface/pages/state-managed-bridge/index.tsx +++ b/packages/synapse-interface/pages/state-managed-bridge/index.tsx @@ -433,7 +433,7 @@ const StateManagedBridge = () => { ? destinationAddress : address - const data = await synapseSDK.bridge( + const payload = await synapseSDK.bridge( toAddress, bridgeQuote.routerAddress, fromChainId, @@ -444,20 +444,6 @@ const StateManagedBridge = () => { bridgeQuote.destQuery ) - const payload = - fromToken?.addresses[fromChainId as keyof Token['addresses']] === - zeroAddress || - fromToken?.addresses[fromChainId as keyof Token['addresses']] === '' - ? { - data: data.data, - to: data.to, - value: stringToBigInt( - debouncedFromValue, - fromToken?.decimals[fromChainId] - ), - } - : data - /** Setting custom gas limit for only Polygon transactions */ let gasEstimate = undefined diff --git a/packages/synapse-interface/pages/swap/index.tsx b/packages/synapse-interface/pages/swap/index.tsx index 210c036b70..f89061f662 100644 --- a/packages/synapse-interface/pages/swap/index.tsx +++ b/packages/synapse-interface/pages/swap/index.tsx @@ -269,7 +269,7 @@ const StateManagedSwap = () => { chainId: swapChainId, }) - const data = await synapseSDK.swap( + const payload = await synapseSDK.swap( swapChainId, address, swapFromToken.addresses[swapChainId], @@ -277,20 +277,6 @@ const StateManagedSwap = () => { swapQuote.quote ) - const payload = - swapFromToken.addresses[swapChainId as keyof Token['addresses']] === - zeroAddress || - swapFromToken.addresses[swapChainId as keyof Token['addresses']] === '' - ? { - data: data.data, - to: data.to, - value: stringToBigInt( - swapFromValue, - swapFromToken.decimals[swapChainId] - ), - } - : data - const tx = await wallet.sendTransaction(payload) const originChainName = CHAINS_BY_ID[swapChainId]?.name From d8b2f7977346722070763c9c01f4997e2c0efae1 Mon Sep 17 00:00:00 2001 From: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com> Date: Tue, 13 Aug 2024 20:16:18 +0100 Subject: [PATCH 2/2] refactor: same cleanup for gas estimation --- .../utils/hooks/useGasEstimator.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/synapse-interface/utils/hooks/useGasEstimator.ts b/packages/synapse-interface/utils/hooks/useGasEstimator.ts index 3bca6a8f10..9f6adccd24 100644 --- a/packages/synapse-interface/utils/hooks/useGasEstimator.ts +++ b/packages/synapse-interface/utils/hooks/useGasEstimator.ts @@ -184,7 +184,7 @@ const getBridgePayload = async ( if (!bridgeQuote) return null try { - const data = await synapseSDK.bridge( + const payload = await synapseSDK.bridge( address, bridgeQuote.routerAddress, fromChainId, @@ -194,18 +194,6 @@ const getBridgePayload = async ( bridgeQuote.originQuery, bridgeQuote.destQuery ) - - const payload = - fromToken?.addresses[fromChainId as keyof Token['addresses']] === - zeroAddress || - fromToken?.addresses[fromChainId as keyof Token['addresses']] === '' - ? { - data: data.data, - to: data.to, - value: stringToBigInt(amount, fromToken?.decimals[fromChainId]), - } - : data - return payload } catch (error) { console.error('getBridgePayload: ', error)