[v0.39.0] Sync master with release - #889
Conversation
Release candidate v0.39.0-rc.1
* fix: version field missing when importing tokens with the import tokens modal * fix: build tx behavior in the send tokens flow * chore: pot files * refact: simplify the release utxos * refact: simplify the release utxos * chore: update pot files
…delayed loading modal in confirm send screen (#878)
[v0.39.0] Start public release
📝 WalkthroughWalkthroughVersion bumped to 0.39.0 across all platform manifests. The send flow is refactored: fee/UTXO calculation is removed from Changesv0.39.0 Feature Changes
Sequence DiagramsequenceDiagram
participant User
participant SendAmountInput
participant SendConfirmScreen
participant WalletLib
participant PinScreen
participant FeedbackModal
User->>SendAmountInput: enter address, amount, token
SendAmountInput->>SendConfirmScreen: navigate(address, amount, token)
SendConfirmScreen->>WalletLib: prepare-tx on mount
alt build fails
WalletLib-->>SendConfirmScreen: error
SendConfirmScreen->>FeedbackModal: show PHASE.ERROR + mapTxError(err)
FeedbackModal-->>User: dismiss → navigateBack
else build succeeds
WalletLib-->>SendConfirmScreen: sendTx instance
SendConfirmScreen->>FeedbackModal: show PHASE.READY (tx summary)
User->>SendConfirmScreen: press Send (isSending=true)
SendConfirmScreen->>PinScreen: navigate
PinScreen-->>SendConfirmScreen: focus return → isSending reset
SendConfirmScreen->>WalletLib: signAndSendTx(pin)
WalletLib-->>FeedbackModal: success or mapped error
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/sagas/tokenImport.js (1)
62-62: 💤 Low valueMinor: Fallback lacks explicit
versionfield.The fallback path returns
{ uid, name, symbol }withoutversion, causingdetails.versionto beundefinedat lines 105, 140, and 178. This works correctly sincestripTokenMetadataintokens.jsomitsundefinedfields, but addingversion: undefinedhere would make the contract explicit.💡 Optional: make version explicit
- return { uid, name: uid.slice(0, 8), symbol: '???' }; + return { uid, name: uid.slice(0, 8), symbol: '???', version: undefined };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/sagas/tokenImport.js` at line 62, The fallback return statement in the tokenImport.js file returns an object with uid, name, and symbol fields but omits the version field. Add version: undefined to the returned object at the return statement (the one returning { uid, name: uid.slice(0, 8), symbol: '???' }) to make the contract explicit and clarify that the version field is intentionally undefined in this fallback path.locale/pt-br/texts.po (1)
1013-1023: 💤 Low valueMinor punctuation inconsistency in translation.
Line 1023 translation "Falha ao processar a transação" is missing the trailing period that exists in the English source "Failed to process transaction." This is a minor inconsistency with other translations that include punctuation.
📝 Optional fix
#: src/screens/SendConfirmScreen.js:59 msgid "Failed to process transaction." -msgstr "Falha ao processar a transação" +msgstr "Falha ao processar a transação."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@locale/pt-br/texts.po` around lines 1013 - 1023, The Portuguese Brazilian translation for the message "Failed to process transaction." (corresponding to src/screens/SendConfirmScreen.js:59) is missing a trailing period. Update the translation "Falha ao processar a transação" to include a period at the end to match the punctuation of the English source and maintain consistency with the other translations in the same section that include proper punctuation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/screens/SendConfirmScreen.js`:
- Around line 88-89: Replace the hardcoded native token symbol sourcing from
hathorLib.constants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol with the server-provided
symbol from serverInfo.native_token.symbol in the SendConfirmScreen component.
Update the nativeSymbol constant assignment at line 88 to use
serverInfo.native_token.symbol instead, and apply the same fix to the other
occurrences around lines 360-362 to ensure all user-facing references to the
native token symbol use the actual network metadata rather than default
configuration values.
- Around line 96-117: The catch block handling errors from
sendTransaction.run('prepare-tx') does not release locked UTXOs before exiting
the error path, leaving them in a locked state for subsequent transactions. Add
a UTXO cleanup call to the catch block by invoking await
sendTransaction.releaseUtxos() wrapped in a try-catch block (matching the
pattern already implemented in the cancellation handler at lines 107-109),
before the setBuildError and setPhase calls, to ensure resources are properly
released even when an error occurs.
---
Nitpick comments:
In `@locale/pt-br/texts.po`:
- Around line 1013-1023: The Portuguese Brazilian translation for the message
"Failed to process transaction." (corresponding to
src/screens/SendConfirmScreen.js:59) is missing a trailing period. Update the
translation "Falha ao processar a transação" to include a period at the end to
match the punctuation of the English source and maintain consistency with the
other translations in the same section that include proper punctuation.
In `@src/sagas/tokenImport.js`:
- Line 62: The fallback return statement in the tokenImport.js file returns an
object with uid, name, and symbol fields but omits the version field. Add
version: undefined to the returned object at the return statement (the one
returning { uid, name: uid.slice(0, 8), symbol: '???' }) to make the contract
explicit and clarify that the version field is intentionally undefined in this
fallback path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d2b3db1f-dda7-4a76-8fdb-4a758180bf82
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (15)
android/app/build.gradleios/HathorMobile.xcodeproj/project.pbxprojlocale/da/texts.polocale/pt-br/texts.polocale/ru-ru/texts.polocale/texts.potpackage.jsonsrc/components/AmountTextInput.jssrc/sagas/tokenImport.jssrc/sagas/tokens.jssrc/screens/CreateTokenConfirm.jssrc/screens/MainScreen.jssrc/screens/SendAmountInput.jssrc/screens/SendConfirmScreen.jssrc/screens/Settings.js
| const nativeSymbol = hathorLib.constants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol; | ||
|
|
There was a problem hiding this comment.
Use server-provided native token symbol in the Total line.
nativeSymbol is sourced from DEFAULT_NATIVE_TOKEN_CONFIG, which can diverge from the connected network metadata and show the wrong symbol in user-facing text.
Proposed fix
- const nativeSymbol = hathorLib.constants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol;
+ const nativeSymbol = useSelector((state) => state.serverInfo?.native_token?.symbol)
+ ?? hathorLib.constants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol;Based on learnings: do not hardcode native token symbol in user-facing UI; use serverInfo.native_token.symbol.
Also applies to: 360-362
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/screens/SendConfirmScreen.js` around lines 88 - 89, Replace the hardcoded
native token symbol sourcing from
hathorLib.constants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol with the server-provided
symbol from serverInfo.native_token.symbol in the SendConfirmScreen component.
Update the nativeSymbol constant assignment at line 88 to use
serverInfo.native_token.symbol instead, and apply the same fix to the other
occurrences around lines 360-362 to ensure all user-facing references to the
native token symbol use the actual network metadata rather than default
configuration values.
Source: Learnings
| (async () => { | ||
| try { | ||
| const outputs = [{ address, value: amount, token: token.uid }]; | ||
| const sendTransaction = useWalletService | ||
| ? new hathorLib.SendTransactionWalletService(wallet, { outputs }) | ||
| : new hathorLib.SendTransaction({ storage: wallet.storage, outputs }); | ||
|
|
||
| await sendTransaction.run('prepare-tx'); | ||
|
|
||
| if (cancelled) { | ||
| try { await sendTransaction.releaseUtxos(); } catch (e) { console.error(e); } | ||
| return; | ||
| } | ||
|
|
||
| setSendTx(sendTransaction); | ||
| setPhase(PHASE.READY); | ||
| } catch (err) { | ||
| if (cancelled) return; | ||
| console.error(err); | ||
| setBuildError({ message: mapTxError(err) }); | ||
| setPhase(PHASE.ERROR); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In @hathor/wallet-lib v3.1.1, if SendTransaction.run('prepare-tx') throws, can selected UTXOs remain reserved and require an explicit releaseUtxos() call?
💡 Result:
In @hathor/wallet-lib v3.1.1, if a process such as SendTransaction.run('prepare-tx') fails, it is possible for selected UTXOs to remain in a reserved or "selected" state within the wallet's internal storage [1]. The library architecture often requires explicit handling to ensure these UTXOs are returned to the available pool if a transaction proposal or preparation step is aborted [2][3][4]. Because the library maintains internal tracking of UTXOs being used in current transactions to prevent double-spending, an unhandled exception during the preparation phase may prevent the automatic release of these locks [1]. Developers should implement robust error handling—typically within a try/catch block—to call the appropriate release or cleanup method if the transaction process fails to complete successfully [2]. If the application does not explicitly release these UTXOs, they may remain effectively locked, preventing them from being used in subsequent transactions until the wallet state is synchronized or the UTXOs are manually released [3][5].
Citations:
- 1: https://wallet-headless-api.docs.hathor.network/
- 2: HathorNetwork/hathor-rpc-lib@e85e8af
- 3: HathorNetwork/hathor-rpc-lib@574768e
- 4: HathorNetwork/hathor-rpc-lib@a2506b1
- 5: fix: we should unspend transaction tx outputs when the tx spending it… hathor-wallet-service#281
Add UTXO cleanup to error handler.
The catch block at lines 110–117 discards the sendTransaction instance without calling releaseUtxos(). If run('prepare-tx') throws, selected UTXOs remain locked in the wallet's internal state and cannot be used in subsequent transactions. Call releaseUtxos() before exiting the error path, matching the cleanup already present in the cancellation handler at lines 107–109.
🧰 Tools
🪛 ast-grep (0.43.0)
[warning] 109-109: Avoid using the initial state variable in setState
Context: setSendTx(sendTransaction)
Note: [CWE-710] Improper Adherence to Coding Standards. Security best practice.
(setstate-same-var)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/screens/SendConfirmScreen.js` around lines 96 - 117, The catch block
handling errors from sendTransaction.run('prepare-tx') does not release locked
UTXOs before exiting the error path, leaving them in a locked state for
subsequent transactions. Add a UTXO cleanup call to the catch block by invoking
await sendTransaction.releaseUtxos() wrapped in a try-catch block (matching the
pattern already implemented in the cancellation handler at lines 107-109),
before the setBuildError and setPhase calls, to ensure resources are properly
released even when an error occurs.
Sync
releaseback intomasterafter the v0.39.0 stable release. Must be merged with a merge commit, not squash.Summary by CodeRabbit
New Features
Bug Fixes
Improvements
Chores