Skip to content

feat: show estimated balance changes in confirmation dialog#118

Merged
9 commits merged into
mainfrom
feat/sign-transaction-local-fund-flow
Jun 26, 2026
Merged

feat: show estimated balance changes in confirmation dialog#118
9 commits merged into
mainfrom
feat/sign-transaction-local-fund-flow

Conversation

@wantedsystem

@wantedsystem wantedsystem commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Use Blockaid remote simulation first for estimated balance changes on sign-transaction and MM send, with local fallback when remote simulation is missing, empty, or unsupported.
  • Unify the confirmation UI: both flows use the shared EstimatedChanges component, aligned with Tron/Solana.
  • Send flow: replace the old inline “You send” asset row with the same estimated-changes section used on sign-tx.
  • Sign-tx: seed a local estimate at dialog open, the scan refresher replaces it when Blockaid returns displayable asset rows.
  • Send: seed a one-row local fallback from the known send amount/asset, Blockaid can override when simulation returns rows.
  • Add Tron-parity loading UX in EstimatedChanges: skeleton while the scan is in flight, plus explicit “not available” / “no changes” states when appropriate.
Screenshot 2026-06-19 at 11 11 17 Screenshot 2026-06-19 at 11 14 42

Notes

  • Remote estimated changes win when Blockaid returns non-empty assets. Otherwise the locally seeded fallback stays visible.
  • Fees stay in the Network fee row, not in estimated change rows.
  • Blockaid validation is unchanged and still drives security alerts only (no change to malicious/warning detection).
  • Change-trust still requests validation only — no remote simulation.

@wantedsystem wantedsystem requested a review from a team as a code owner June 17, 2026 15:06
@wantedsystem wantedsystem requested a review from Copilot June 17, 2026 15:07
@wantedsystem wantedsystem changed the title Feat/sign transaction local fund flow Sign transaction local fund flow Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a local, best-effort Stellar simulation path to surface estimated balance changes on the signTransaction confirmation screen, while keeping Blockaid as validation-only and ensuring the UI hides the section when no usable deltas are available.

Changes:

  • Seed the confirmation context with locally-derived estimatedChanges so fund-flow can render immediately, independent of remote scan timing.
  • Introduce local simulation endpoint diffing + mapping (SimulationStateTransactionScanEstimatedChanges) and wire it into signTransaction.
  • Update the scan refresher to request validation only and to preserve locally-derived estimatedChanges across remote refreshes.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/snap/src/ui/confirmation/views/ConfirmSignTransaction/ConfirmSignTransaction.tsx Renders the new estimated-changes section in the sign-transaction confirmation flow.
packages/snap/src/ui/confirmation/controller.tsx Adds initialScan seeding and gates remote scan scheduling on useSecurityAlerts (validation-only).
packages/snap/src/ui/confirmation/components/index.ts Exposes the new EstimatedChanges component via the components barrel.
packages/snap/src/ui/confirmation/components/EstimatedChanges/EstimatedChanges.tsx New UI component to display send/receive asset deltas.
packages/snap/src/ui/confirmation/components/EstimatedChanges/EstimatedChanges.test.tsx Unit tests for EstimatedChanges rendering/hiding behavior.
packages/snap/src/services/transaction/TransactionSimulator.ts Adds simulateEndpoints and supports operation-source-only simulation via option flag.
packages/snap/src/services/transaction/TransactionSimulator.test.ts Tests simulateEndpoints to ensure fee is excluded from estimated-change delta baseline.
packages/snap/src/services/transaction/TransactionService.ts Adds deriveEstimatedChanges and injects assetMetadataService for SEP-41 metadata mapping.
packages/snap/src/services/transaction/TransactionService.test.ts Tests local estimated-changes derivation across multiple sign-transaction scenarios.
packages/snap/src/services/transaction/mapSimulationToEstimatedChanges.ts New mapper converting simulation snapshot deltas into TransactionScanAssetChange[].
packages/snap/src/services/transaction/mapSimulationToEstimatedChanges.test.ts Unit tests for native + classic mapping and empty/no-signer scenarios.
packages/snap/src/services/transaction/index.ts Re-exports the new mapper.
packages/snap/src/services/transaction/mocks/transaction.fixtures.ts Updates TransactionService test fixture construction with assetMetadataService.
packages/snap/src/handlers/keyring/signTransaction.ts Computes local estimated changes and seeds them into initialScan for the confirmation dialog.
packages/snap/src/handlers/cronjob/refreshConfirmationContext/scanRefresher.ts Changes refresher behavior to validation-only and preserves local estimatedChanges.
packages/snap/src/handlers/cronjob/refreshConfirmationContext/scanRefresher.test.ts Updates/adds tests for validation-only options and preservation of local changes.
packages/snap/src/context.ts Wires assetMetadataService into TransactionService construction.
packages/snap/snap.manifest.json Updates bundle shasum for the new build output.
packages/site/.env.development Sets SNAP_ORIGIN for local dev site configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wantedsystem wantedsystem changed the title Sign transaction local fund flow Show estimated balance changes Jun 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 27 changed files in this pull request and generated 5 comments.

Comment thread packages/site/.env.development Outdated
@stanleyyconsensys stanleyyconsensys changed the title Show estimated balance changes feat: show estimated balance changes Jun 23, 2026
@stanleyyconsensys stanleyyconsensys changed the title feat: show estimated balance changes feat: show estimated balance changes in confirmation dialog Jun 23, 2026

@stanleyyconsensys stanleyyconsensys 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.

i think the idea is a not align with our dicussion

  • sign txn: always use remote simulation
  • chg trust / send : always use local simulation

return {
assets: [
{
type: 'out',

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.

can we have a enum for out

preferences.useExternalPricingData &&
tokenPrices !== undefined;

const canUseRemoteSimulation =

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.

it looks more clear if we do it via renderOptions
current is

{
      loadPrice: true,
      scanTxn: true,
      validateTxn: true,
 },

to (with some renaming)

// Change trust / confirm send
{
      loadPrice: true,
      securityScanning: true,
      localSimulation: true,
      remoteSimulation: false
 }

// sign txn
{
      loadPrice: true,
      securityScanning: true,
      localSimulation: false,
      remoteSimulation: true
 },

const { asset_type: assetType, asset } = assetDiff;

if (
assetType === 'NATIVE' ||

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 question why we need to check assetType and asset.type?

* @returns The post-fee initial state and the final state after all operations.
* @throws {TransactionValidationException} When simulation produces no states.
*/
simulateEndpoints(

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.

this method does not seem useful,
as simulate already give us all the state

* this scoped to sign-transaction estimated changes; normal validation still
* requires the wallet account to be the transaction or fee source.
*/
allowOperationSourceAccount?: boolean;

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.

sign txn is only using security scan, why we need this?

* @param params.signerAddress - The Stellar address whose changes are surfaced.
* @returns The estimated changes, or `{ assets: [] }` when they cannot be derived.
*/
async deriveEstimatedChanges(params: {

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.

again, doesnt we said sign txn is using security scanning?

// Seed a local estimate so the dialog can render immediately. If Blockaid
// later returns displayable simulation results, the scan refresher replaces
// this fallback with the remote estimate.
const estimatedChanges = await this.#deriveEstimatedChanges(

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.

may be we can remove this and let security api to do the work

@wantedsystem wantedsystem closed this pull request by merging all changes into main in 7cf0a1f Jun 26, 2026
@wantedsystem wantedsystem deleted the feat/sign-transaction-local-fund-flow branch June 26, 2026 08:08
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.

3 participants