Skip to content

feat(sdk): add high-level balance/transaction manager interfaces#314

Merged
CharlVS merged 2 commits intodevfrom
codex/fix-open-findings-manager-layer
Mar 12, 2026
Merged

feat(sdk): add high-level balance/transaction manager interfaces#314
CharlVS merged 2 commits intodevfrom
codex/fix-open-findings-manager-layer

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Mar 12, 2026

Summary

  • add IBalanceManager watcher-coverage helpers for per-asset polling decisions
  • add a high-level merged transaction history stream API (watchTransactionHistoryMerged)
  • add shared transaction reconciliation utilities for pending->confirmed lifecycle handling
  • add activation cancellation API surface (cancelActivation, cancelAllActivations) through AssetManager

Why

This moves balance/transaction lifecycle complexity into SDK manager-level interfaces so app-layer blocs can stay high-level.

Validation

  • dart format on touched SDK files
  • flutter analyze on touched SDK files (info-level lint noise only, no new errors)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ccc430995

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

String reason = 'Activation cancelled by caller',
}) {
if (_isDisposed) return;
_cancelledActivations[assetId] = reason;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Ignore stale cancel requests when no activation is running

cancelActivation stores a cancellation token unconditionally, even if the asset has no in-flight activation. If a caller invokes cancel slightly after completion (or before a future retry), the next activateAssets call will hit the pre-check and emit ACTIVATION_CANCELLED immediately, cancelling a brand-new activation unexpectedly. This contradicts the in-flight-only contract and creates hard-to-reproduce false failures on later retries.

Useful? React with 👍 / 👎.

Comment on lines +107 to +111
_firstSeenAtByInternalId.putIfAbsent(
tx.internalId,
() => tx.timestamp.millisecondsSinceEpoch != 0
? tx.timestamp
: DateTime.now(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve pending first-seen order before merging replacement

The reconciler records incoming.internalId in _firstSeenAtByInternalId before it knows whether this incoming transaction replaces a pending one with a different internal ID. In the replacement path, _mergeInPlace then tries to move pendingFirstSeen with putIfAbsent, but that key is already populated, so the original first-seen timestamp is lost. This breaks the intended stable ordering for pending→confirmed transitions (especially when timestamps are zero and ordering relies on firstSeen).

Useful? React with 👍 / 👎.

@CharlVS
Copy link
Copy Markdown
Collaborator Author

CharlVS commented Mar 12, 2026

Addressed both review comments in commit cb1e623.

  1. cancelActivation now records cancellation only for in-flight activations (_activationCompleters.containsKey(assetId)), preventing stale cancel markers from cancelling future fresh activations.
  2. TransactionListReconciler.merge now calls _mergeInPlace before putIfAbsent on first-seen timestamps, preserving pending first-seen ordering when pending->confirmed replacement changes internalId.

Please re-review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 12, 2026

Visit the preview URL for this PR (updated for commit cb1e623):

https://komodo-playground--pr314-codex-fix-open-findi-h7o77ks8.web.app

(expires Thu, 19 Mar 2026 15:57:41 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2bfedd77fdea45b25ba7c784416e81f177aa5c47

@CharlVS CharlVS merged commit 54e1420 into dev Mar 12, 2026
2 of 5 checks passed
@CharlVS CharlVS deleted the codex/fix-open-findings-manager-layer branch March 12, 2026 16:05
CharlVS added a commit that referenced this pull request Apr 1, 2026
* feat(sdk): add high-level balance and tx manager interfaces

* fix(sdk): address pr review cancellation and ordering bugs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant