Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/stellar-wallet-snap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **BREAKING:** Return classic keyring balance metadata `limit` in integer stroop string ([#495](https://github.com/MetaMask/internal-snaps/pull/495))
- Keyring method `getAccountBalances` and the Keyring event `AccountBalancesUpdated` now return this `limit` in stroops.

### Fixed

- Keep in-progress memo edits in `memoDraft` so Back does not commit unsaved memo text on send confirmation. ([#406](https://github.com/MetaMask/internal-snaps/pull/406))

## [1.3.0]

### Added
Expand Down
3 changes: 3 additions & 0 deletions packages/stellar-wallet-snap/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
"confirmation.memo.error.tooLong": {
"message": "Memo must be 28 bytes or fewer"
},
"confirmation.memo.error.saveFailed": {
"message": "Could not save memo. Please try again."
},
"confirmation.asset": {
"message": "Asset"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/stellar-wallet-snap/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
"confirmation.memo.error.tooLong": {
"message": "Memo must be 28 bytes or fewer"
},
"confirmation.memo.error.saveFailed": {
"message": "Could not save memo. Please try again."
},
"confirmation.asset": {
"message": "Asset"
},
Expand Down Expand Up @@ -395,7 +398,7 @@
"message": "Function"
},
"confirmation.transaction.param.deployer": {
"message": "Desplegador"
"message": "Deployer"
},
"confirmation.transaction.param.salt": {
"message": "Salt"
Expand Down
3 changes: 3 additions & 0 deletions packages/stellar-wallet-snap/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
"confirmation.memo.error.tooLong": {
"message": "Memo must be 28 bytes or fewer"
},
"confirmation.memo.error.saveFailed": {
"message": "Could not save memo. Please try again."
},
"confirmation.asset": {
"message": "Asset"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/stellar-wallet-snap/src/ui/confirmation/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export type ConfirmationBaseProps = Partial<ContextWithPrices> & {
memoScreen?: boolean;
// Saved memo for the pending send (UI-owned; not on confirmSend RPC params).
memo?: string;
// In-progress memo edit text (not committed until Save succeeds).
memoDraft?: string | null;
// Locale key for memo validation errors on the edit screen.
memoError?: LocalizedMessage | null;
// When false, hide Add/Update memo controls.
Expand All @@ -166,4 +168,9 @@ export type ConfirmationBaseProps = Partial<ContextWithPrices> & {
* of stacking parallel refresh chains (e.g. MemoEdit Save vs open cron).
*/
backgroundEventId?: string;
/**
* Preference- and flow-enabled refresher keys resolved at dialog open.
* MemoEdit Save reuses this snapshot for restart.
*/
enabledRefresherKeys?: string[];
};
27 changes: 20 additions & 7 deletions packages/stellar-wallet-snap/src/ui/confirmation/controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,23 @@ export class ConfirmationUXController {
tokenPrices,
};

// Preference/flow-enabled keys for MemoEdit Save (ungated).
const enabledRefresherKeys: ConfirmationContextRefresherKey[] = [];
if (enablePricing) {
enabledRefresherKeys.push(ConfirmationContextRefresherKey.Prices);
}
if (enableSecurityScan) {
enabledRefresherKeys.push(ConfirmationContextRefresherKey.Scan);
}
if (enableLocalSimulation) {
enabledRefresherKeys.push(ConfirmationContextRefresherKey.Transaction);
}

// 1. Initial context with loading state
const context = {
...defaultContext,
...renderContext,
...(enabledRefresherKeys.length > 0 ? { enabledRefresherKeys } : {}),
};

// 2. Initial render with loading skeleton (always show loading if pricing enabled)
Expand All @@ -264,38 +277,38 @@ export class ConfirmationUXController {
return dialogPromise;
}

// 5. Schedule background context refresh for enabled refreshers only.
// 5. Schedule background context refresh for this-tick keys only.
// Skip Scan / Transaction when renderContext already marked them Error
// (e.g. RequiresMemo on open): a pending open cron would race
// MemoEdit's restart and double-hit Blockaid after the user saves a memo.
// Read the Error overrides from `renderContext` (not merged `context`):
// `defaultContext` only ever sets Fetched/Fetching, so TS narrows those
// fields and rejects a comparison against Error on the merged object.
const refresherKeys: ConfirmationContextRefresherKey[] = [];
const scheduledKeys: ConfirmationContextRefresherKey[] = [];
if (enablePricing) {
refresherKeys.push(ConfirmationContextRefresherKey.Prices);
scheduledKeys.push(ConfirmationContextRefresherKey.Prices);
Comment thread
khanti42 marked this conversation as resolved.
}
if (
enableSecurityScan &&
renderContext.scanFetchStatus !== FetchStatus.Error
) {
refresherKeys.push(ConfirmationContextRefresherKey.Scan);
scheduledKeys.push(ConfirmationContextRefresherKey.Scan);
}
if (
enableLocalSimulation &&
renderContext.transactionsFetchStatus !== FetchStatus.Error
) {
refresherKeys.push(ConfirmationContextRefresherKey.Transaction);
scheduledKeys.push(ConfirmationContextRefresherKey.Transaction);
}

if (refresherKeys.length > 0) {
if (scheduledKeys.length > 0) {
const backgroundEventId =
await RefreshConfirmationContextHandler.scheduleBackgroundEvent(
{
scope,
interfaceId: id,
interfaceKey,
refresherKeys,
refresherKeys: scheduledKeys,
},
Duration.OneSecond,
);
Expand Down
Loading
Loading