Repository navigation
fix(modules/usdt): place required backup argument before default bridge_url in UsdtWallet constructor - #198
Conversation
…ge_url in UsdtWallet constructor Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
talosmachina
left a comment
There was a problem hiding this comment.
2 findings (2 P1). Moves backup ahead of the defaulted bridge_url in the UniFFI constructor UsdtWallet::new so the generated Python __init__ is valid, and updates the Rust test call sites. Reviewed 0c891cb, full tier.
What I checked, and 1 candidate I ruled out
Read in full: src/modules/usdt/wallet.rs (constructor), the six updated call sites in src/modules/usdt/tests.rs and tests/backup.rs, .github/workflows/ios-bindgen.yml, the committed bindings/ios/bitkitcore.swift and bitkitcoreFFI.h constructor
Consumers traced: synonymdev/bitkit-ios master (UsdtWalletManager.swift plus two test files, positional-order labels) and synonymdev/bitkit-android master (UsdtService.kt, UsdtNativeRecoveryIntegrationTest.kt, named arguments)
Build: skipped, talos-pr-run refuses a fork head (Tyagiquamar/bitkit-core), so this review is static and nothing was compiled or run here
CI at review time: script/manifest, paykit-route and wake jobs green; iOS Bindgen, Android Bindgen and usdt-tests still pending
Cold reader: both findings stood. It argued the stale-bindings one would fail loudly at runtime through the UniFFI checksum rather than misroute the arguments, which is why that finding is about CI only.
Ruled out
- Rust call sites missed: every
UsdtWallet::newin the crate is updated; the Rust compiler would catch a missed one anyway.
Merge confidence: 2/5, two P1s: the Swift API break for bitkit-ios and the stale committed iOS bindings.
| rpc_url: String, | ||
| bundler_url: String, | ||
| bridge_url: Option<String>, | ||
| backup: Arc<dyn super::UsdtBackup>, |
There was a problem hiding this comment.
Reordering breaks every Swift caller of
UsdtWallet(...)
UniFFI keeps the Rust parameter order in the Swift initializer, so this becomes init(address:storagePath:rpcUrl:bundlerUrl:backup:bridgeUrl:), and Swift requires labeled arguments in declaration order even when one has a default. synonymdev/bitkit-ios master passes bridgeUrl: before backup: in Bitkit/Managers/UsdtWalletManager.swift:619-626, BitkitTests/UsdtNativeRecoveryIntegrationTests.swift:58-62 and BitkitTests/UsdtWalletManagerTests.swift:376-381, so the first bitkit-core bump carrying this change stops compiling there ("argument 'backup' must precede argument 'bridgeUrl'"). Kotlin callers in bitkit-android use named arguments and are fine. #194 asks to keep Swift/Kotlin compatibility or document the migration; this PR does neither. Since every Swift and Kotlin caller already passes bridgeUrl explicitly, keeping the original order and dropping default(bridge_url = None) fixes the Python SyntaxError with no caller change.
Verified by: the current initializer at bindings/ios/bitkitcore.swift:3140 mirrors the Rust order; grepped UsdtWallet( on bitkit-ios and bitkit-android master for every call site.
| bundler_url: String, | ||
| bridge_url: Option<String>, | ||
| backup: Arc<dyn super::UsdtBackup>, | ||
| bridge_url: Option<String>, |
There was a problem hiding this comment.
Regenerate the committed iOS interface files for the new order
bindings/ios/bitkitcore.swift:3140-3150 still declares init(..., bridgeUrl: String? = nil, backup: UsdtBackup) and lowers bridgeUrl before backup, and bindings/ios/bitkitcoreFFI.h:749 still declares (..., RustBuffer bridge_url, void* backup, ...). .github/workflows/ios-bindgen.yml runs on any **/*.rs change, runs ./build_ios.sh, then fails the "Check committed iOS interface files" step on git diff --quiet over exactly these files, so iOS Bindgen goes red on this PR until they are regenerated and committed (with Package.swift restored, per the workflow's own message).
Verified by: the PR touches only the three .rs files (git diff --stat master...0c891cb); read the workflow's trigger paths and check step.
…to preserve Swift parameter order
|
Sorry for the delay - the reorder is reverted in 6432186: Remaining: the committed iOS interface files under bindings/ios/ are stale for the same change (bridge_url lost its default). The iOS Bindgen workflow generates them on macOS via ./build_ios.sh, but I cannot run it on this machine (the crate does not build for our target - no dlltool/Apple SDK available here). If you can run ./build_ios.sh there, please do; otherwise let me know whether you can grant a macOS runner or which generator entry point to use and I will regenerate. |
Summary
Fixes #194 by reordering the parameters of the exported
UsdtWallet::newconstructor so that required parameters precede default/optional parameters.Root Cause and Problem
In
src/modules/usdt/wallet.rs, theUsdtWallet::newconstructor had the following signature:Because
bridge_urlwas annotated withdefault(bridge_url = None)but placed beforebackup, UniFFI generated the Python__init__constructor signature with a defaulted parameter before a non-default parameter:In Python, this is a syntax error (
SyntaxError: non-default argument follows default argument), which preventedbitkitcorefrom being imported into Python at all.Technical Solution
Reordered the constructor parameters so that all non-default arguments come first and default arguments are positioned at the end of the argument list:
Updated internal Rust call sites in
src/modules/usdt/tests.rsandsrc/modules/usdt/tests/backup.rsto match the new argument order.Test Plan
cargo check --libwith UCRT64 toolchain: passed cleanly with zero errors.cargo fmt --check: passed with zero formatting diffs.modules::usdtcovering wallet instantiation, payment proof bindings, mock chain wallet instances, and remote backups: all targeted constructor tests passed.