Skip to content

Commit

Permalink
refactor: sa gas availability check logics for swaps (#3175)
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk authored Oct 31, 2024
1 parent f0877f7 commit 132a9bb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
24 changes: 24 additions & 0 deletions .changeset/silver-laws-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@reown/appkit-core': patch
'@apps/demo': patch
'@apps/gallery': patch
'@apps/laboratory': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-polkadot': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-common': patch
'@reown/appkit-experimental': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
---

Fixes swap gas availability check for smart accounts
15 changes: 8 additions & 7 deletions packages/core/src/controllers/SwapController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,19 +815,20 @@ export const SwapController = {
state.myTokensWithBalance
)

// Smart Accounts may pay gas in any ERC20 token
let insufficientNetworkTokenForGas = true
if (
AccountController.state.preferredAccountType ===
W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT
) {
return true
// Smart Accounts may pay gas in any ERC20 token
insufficientNetworkTokenForGas = false
} else {
insufficientNetworkTokenForGas = SwapCalculationUtil.isInsufficientNetworkTokenForGas(
state.networkBalanceInUSD,
state.gasPriceInUSD
)
}

const insufficientNetworkTokenForGas = SwapCalculationUtil.isInsufficientNetworkTokenForGas(
state.networkBalanceInUSD,
state.gasPriceInUSD
)

return insufficientNetworkTokenForGas || isInsufficientSourceTokenForSwap
},

Expand Down

0 comments on commit 132a9bb

Please sign in to comment.