feat: fetch gasless transactions for BatchSell quotes#8805
Conversation
812aa2e to
c01f799
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 28e4c4c. Configure here.
| selectExchangeRateByAssetId( | ||
| state, | ||
| state.batchSellTrades?.fee.asset?.assetId, | ||
| ), |
There was a problem hiding this comment.
Missing optional chaining on fee causes runtime crash
Medium Severity
The selectBatchSellFees input selectors access state.batchSellTrades?.fee.amount, state.batchSellTrades?.fee.asset, and state.batchSellTrades?.fee.asset?.assetId without optional chaining after fee. The BatchSellTradesResponseSchema defines fee as optional(...), so when batchSellTrades is non-null but fee is undefined, these expressions throw a TypeError because .amount / .asset is accessed on undefined. The combiner's truthiness check doesn't help since the crash occurs in the input selectors before the combiner runs.
Reviewed by Cursor Bugbot for commit 28e4c4c. Configure here.


Explanation
Implements the
updateBatchSellTradeshandler which calls theobtainGaslessBatchto estimate network fees for BatchSell quotes. Clients will need to call the handler whenever the selectBatchQuotes selector's recommended quotes changeA new selector
selectBatchSellTradeshas also been added, which returns whether a batch is submittable, and thetotalNetworkFeeprovided by theobtainGaslessBatchendpoint and its converted valuesReferences
Fixes https://consensyssoftware.atlassian.net/browse/SWAPS-4444
Checklist
Note
Medium Risk
Adds a new async fetch path and state for BatchSell gasless trade/fee data, including abort/error handling and new API response validation. Risk is moderate because it changes quote-related state shape and moves
totalNetworkFeefor batch sells to a new selector/endpoint.Overview
Adds BatchSell gasless trade/fee fetching via
BridgeController:updateBatchSellTrades, calling the bridge APIPOST /obtainGaslessBatchand storing results in new state fieldsbatchSellTradesandbatchSellTradesLoadingStatus(with abort-on-new-fetch/reset and stale-data clearing on new quote requests).Introduces
selectBatchSellTradesto surface batch submittability and a computedtotalNetworkFee(with currency conversions); breaking: removestotalNetworkFeefromselectBatchSellQuotes.Extends types/validators to model and validate the new response (
BatchSellTradesResponse, fee schema, txtype, gas limit fields) and updates tests/snapshots accordingly; also removes some unnecessaryHextype assertions inbridge-status-controllerandtransaction-pay-controller.Reviewed by Cursor Bugbot for commit 28e4c4c. Bugbot is set up for automated code reviews on this repo. Configure here.