Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 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 |
|
Visit the preview URL for this PR (updated for commit 1fa903d): https://komodo-playground--pr264-zhtlc-sync-params-6heo42v1.web.app (expires Mon, 03 Nov 2025 21:04:20 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 2bfedd77fdea45b25ba7c784416e81f177aa5c47 |
|
Visit the preview URL for this PR (updated for commit 1fa903d): https://kdf-sdk--pr264-zhtlc-sync-params-fkmsz92c.web.app (expires Mon, 03 Nov 2025 21:04:18 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 9c1b6e6c010cf0b965c455ba7a69c4aedafa8a1d |
|
@cursoragent thoroughly consider and review the changes. |
Summary
Scope of changes
Behavior vs acceptance criteria
Key implementation details (code references)
// Apply one-shot sync_params only when explicitly provided via config form
// right before activation. This avoids caching and unintended rewinds.
if (params.mode?.rpcData != null) {
final oneShotSync = await configService.takeOneShotSyncParams(asset.id);
if (oneShotSync != null) {
final rpcData = params.mode!.rpcData!;
final updatedRpcData = ActivationRpcData(
lightWalletDServers: rpcData.lightWalletDServers,
electrum: rpcData.electrum,
syncParams: oneShotSync,
);
params = params.copyWith(
mode:
ActivationMode(rpc: params.mode!.rpc, rpcData: updatedRpcData),
);
}
}
JsonMap toJson() => {
'zcashParamsPath': zcashParamsPath,
'scanBlocksPerIteration': scanBlocksPerIteration,
'scanIntervalMs': scanIntervalMs,
if (taskStatusPollingIntervalMs != null)
'taskStatusPollingIntervalMs': taskStatusPollingIntervalMs,
};
static ZhtlcUserConfig fromJson(JsonMap json) => ZhtlcUserConfig(
zcashParamsPath: json.value<String>('zcashParamsPath'),
scanBlocksPerIteration:
json.valueOrNull<int>('scanBlocksPerIteration') ?? 1000,
scanIntervalMs: json.valueOrNull<int>('scanIntervalMs') ?? 0,
taskStatusPollingIntervalMs: json.valueOrNull<int>(
'taskStatusPollingIntervalMs',
),
);
Future<void> saveZhtlcConfig(AssetId id, ZhtlcUserConfig config) async {
final walletId = await _requireActiveWallet();
// If legacy callers provide syncParams in the config, convert it to
// a one-shot sync override and do not persist it.
if (config.syncParams != null) {
_oneShotSyncParams[_WalletAssetKey(walletId, id)] = config.syncParams;
}
await repo.saveConfig(walletId, id, config);
} /// Sets a one-shot sync params value for the next activation of [id].
/// This is not persisted and will be consumed and cleared on activation.
Future<void> setOneShotSyncParams(
AssetId id,
ZhtlcSyncParams? syncParams,
) async {
final walletId = await _requireActiveWallet();
_oneShotSyncParams[_WalletAssetKey(walletId, id)] = syncParams;
}
/// Returns and clears any pending one-shot sync params for [id].
Future<ZhtlcSyncParams?> takeOneShotSyncParams(AssetId id) async {
final walletId = await _requireActiveWallet();
final key = _WalletAssetKey(walletId, id);
final value = _oneShotSyncParams.remove(key);
return value;
}
final config = ZhtlcUserConfig(
zcashParamsPath: path,
scanBlocksPerIteration:
int.tryParse(blocksPerIterController.text) ?? 1000,
scanIntervalMs:
int.tryParse(intervalMsController.text) ?? 0,
);
result = ZhtlcConfigDialogResult(
config: config,
oneShotSync: syncParams,
);
Navigator.of(context).pop();
final dialogResult =
await ZhtlcConfigDialogHandler.handleZhtlcConfigDialog(
context,
asset,
);
if (!mounted) return;
if (dialogResult != null) {
if (dialogResult.oneShotSync != null) {
await sdk.activationConfigService.setOneShotSyncParams(
asset.id,
dialogResult.oneShotSync,
);
}
await sdk.activationConfigService.saveZhtlcConfig(
asset.id,
dialogResult.config,
);Review notes
Risks and edge cases
Recommendations
Tests to consider
Verdict
Learn more about Cursor Agents |
|
Cursor Agent can help with this pull request. Just |
CharlVS
left a comment
There was a problem hiding this comment.
Please change it to clear the stored values after sign-out
|
thanks @smk762 - I added some bits to clear / clean out one-shot sync params once the user signs out |
Closes #263
To test: