Skip to content

fix(wallet): stabilize dashboard transaction direction - #620

Open
moatus wants to merge 2 commits into
canopy-network:developmentfrom
moatus:fix/wallet-transaction-direction
Open

moatus wants to merge 2 commits into
canopy-network:developmentfrom
moatus:fix/wallet-transaction-direction

Conversation

@moatus

@moatus moatus commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Description

Transfers between two accounts in the wallet can alternate between Send and Receive on each dashboard refresh. Account histories load concurrently, and deduplication retains whichever account's result arrives first.

Determine whether a received transaction's sender belongs to the wallet before overriding its type. Wallet-originated transactions retain their original type regardless of response order; transfers from external senders continue to display Receive.

Related Issues

No linked issue. Reproduced in the dashboard's Recent Transactions table.

Changes Made

  • Check sender ownership when processing received transactions in useDashboard.
  • Preserve existing transaction type inference, including memo-based actions.
  • Keep the change confined to one file, with no config, dependency, or changelog changes.

Checklist

  • I have tested the changes locally and verified they work as intended.
  • I have appropriately titled my branch issue-#<issue-number>. (No issue number; branch is fix/wallet-transaction-direction.)
  • I have re-built the web-wallet.
  • I have formatted the changed code with Prettier. (npm run prettier is not configured; used Prettier directly on the changed range.)
  • I have updated documentation where applicable. (Inline explanation; no public API changes.)
  • I have included tests for the changes. (No test runner is configured in this wallet; regression checks were run locally as described below.)

Additional Notes

Validation:

  • npm run build passed, including TypeScript checks and the Vite production build.
  • A temporary regression harness executing the actual hook query reproduced the original Send/Receive flip by reversing account response order. The fix passed both orders for internal transfers, external incoming/outgoing transfers, self-transfers, staking and memo-derived types. It also preserved the internal transfer type when the sent-history request failed.
  • Verified the local Vite app in Brave against live read-only transaction queries. Delayed sender responses by 700 ms, then recipient responses by 700 ms; the affected transfer stayed Send on initial load and after polling in both cases.
  • git diff --check passed.

To reproduce manually, view Recent Transactions with both sides of a transfer present in the wallet, then reverse which account's history requests finish first. Before this change, the row can switch between Send with a negative amount and Receive with a positive amount. Afterward, it consistently displays Send. External incoming transfers still display Receive.

No chain.json or manifest.json compatibility changes. This preserves the existing Send/Receive presentation and does not introduce a new transfer type or change the layout.

@pablocampogo pablocampogo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a small change

// Keep wallet-originated transactions consistent regardless of response order.
const isWalletSender =
typeof item.sender === "string" &&
allAddresses.includes(item.sender);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor: since this runs for every received item, allAddresses.includes(...) is a linear scan each time. A Set built once would make it O(1):

const walletAddresses = new Set(allAddresses);
// ...
const isWalletSender =
  typeof item.sender === "string" && walletAddresses.has(item.sender);

This branch has not been deployed

No deployments
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.

2 participants