-
Notifications
You must be signed in to change notification settings - Fork 111
Feature/prevent gas refresh once calculated #5973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a feature to prevent unnecessary gas fee recalculation by caching the TipGas object once it's been calculated. The main optimization is that when gas has already been estimated in InputFragment, it's passed along to BrowserWalletBottomSheetDialogFragment to avoid recalculating during the periodic refresh cycle.
Key changes:
- Added
TipGascaching and passing between fragments to avoid redundant gas calculations - Made
TipGasparcelable to support passing via bundle arguments - Improved fee display consistency by always showing the fee symbol, even when fee is zero
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| InputFragment.kt | Stores calculated tipGas and passes it to the browser wallet dialog |
| Web3ViewModel.kt | Adds calcFeeWithTipGas() method to return both fee and TipGas object |
| BrowserWalletBottomSheetDialogFragment.kt | Conditionally skips gas estimation if tipGas is already provided |
| TipGas.kt | Makes the data class Parcelable for bundle passing |
| SessionRequestPage.kt | Ensures fee symbol is displayed even when fee is zero |
| BrowserPage.kt | Ensures fee symbol is displayed even when fee is zero |
| Component.kt | Adjusts loading indicator size and adds placeholder text for alignment |
| Theme.kt | Adds inspection mode support to prevent initialization issues in previews |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| suspend fun calcFeeWithTipGas( | ||
| token: Web3TokenItem, | ||
| transaction: JsSignMessage, | ||
| fromAddress: String, | ||
| ): Pair<BigDecimal?, TipGas?> { | ||
| val chain = token.getChainFromName() | ||
| if (chain == Chain.Solana) { | ||
| val tx = VersionedTransactionCompat.from(transaction.data ?: "") | ||
| val fee = tx.calcFee(fromAddress) | ||
| return Pair(fee, null) | ||
| } else { | ||
| val r = withContext(Dispatchers.IO) { | ||
| runCatching { | ||
| web3Repository.estimateFee( | ||
| EstimateFeeRequest( | ||
| token.chainId, | ||
| null, | ||
| transaction.data ?: transaction.wcEthereumTransaction?.data, | ||
| fromAddress, | ||
| transaction.wcEthereumTransaction?.to, | ||
| transaction.wcEthereumTransaction?.value, | ||
| ) | ||
| ) | ||
| }.getOrNull() | ||
| } | ||
| if (r?.isSuccess != true) return Pair(BigDecimal.ZERO, null) | ||
| return withContext(Dispatchers.IO) { | ||
| val tipGas = buildTipGas(chain.chainId, r.data!!) | ||
| val fee = tipGas.displayValue(transaction.wcEthereumTransaction?.maxFeePerGas) ?: BigDecimal.ZERO | ||
| Pair(fee, tipGas) | ||
| } | ||
| } | ||
| } |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calcFeeWithTipGas method duplicates most of the logic from the existing calcFee method (lines 291-322). Consider refactoring calcFee to use calcFeeWithTipGas internally and return only the first element of the pair, or extract the common logic to avoid duplication.
| Text( | ||
| text = " ", //holder | ||
| color = MixinAppTheme.colors.textAssist, | ||
| maxLines = 1, | ||
| fontSize = 12.sp, | ||
| ) |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'holder' in comment to 'placeholder'.
486fcf4 to
8babd62
Compare
8babd62 to
f109aea
Compare
…-refresh-once-calculated
No description provided.