Skip to content

Commit

Permalink
fix(synapse-interface): don't adjust payload.value that SDK already…
Browse files Browse the repository at this point in the history
… handles (#3015)

* refactor: don't adjust `payload.value` that SDK already handles

* refactor: same cleanup for gas estimation
  • Loading branch information
ChiTimesChi authored Aug 14, 2024
1 parent 751857d commit 77f5863
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
16 changes: 1 addition & 15 deletions packages/synapse-interface/pages/state-managed-bridge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ const StateManagedBridge = () => {
? destinationAddress
: address

const data = await synapseSDK.bridge(
const payload = await synapseSDK.bridge(
toAddress,
bridgeQuote.routerAddress,
fromChainId,
Expand All @@ -448,20 +448,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

Expand Down
16 changes: 1 addition & 15 deletions packages/synapse-interface/pages/swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,28 +278,14 @@ const StateManagedSwap = () => {
chainId: swapChainId,
})

const data = await synapseSDK.swap(
const payload = await synapseSDK.swap(
swapChainId,
address,
swapFromToken.addresses[swapChainId],
stringToBigInt(swapFromValue, swapFromToken.decimals[swapChainId]),
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
Expand Down
14 changes: 1 addition & 13 deletions packages/synapse-interface/utils/hooks/useGasEstimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 77f5863

Please sign in to comment.