From 0773f6885a5e8d7886042838b0edc775eb4d5c06 Mon Sep 17 00:00:00 2001 From: Stanley Yuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Thu, 5 Nov 2026 10:40:05 +0800 Subject: [PATCH 1/2] fix(stellar): fix the onAmountInput param --- .../docs/use-cases/client-request/onAmountInput.md | 4 ++-- .../src/handlers/clientRequest/api.test.ts | 2 +- .../stellar-wallet-snap/src/handlers/clientRequest/api.ts | 2 +- .../src/handlers/clientRequest/onAmountInput.test.ts | 6 +++--- .../src/handlers/clientRequest/onAmountInput.ts | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/stellar-wallet-snap/docs/use-cases/client-request/onAmountInput.md b/packages/stellar-wallet-snap/docs/use-cases/client-request/onAmountInput.md index 36b5f1cdb..84ea218f5 100644 --- a/packages/stellar-wallet-snap/docs/use-cases/client-request/onAmountInput.md +++ b/packages/stellar-wallet-snap/docs/use-cases/client-request/onAmountInput.md @@ -16,7 +16,7 @@ Preflight-validates a send amount while the user types (balance and fee checks o - `accountId` — keyring account UUID - `assetId` — CAIP-19 classic / SEP-41 / slip44 asset (`scope` is derived from `assetId`) - `value` — positive amount string (human-readable units) -- `to` — optional Stellar destination; ignored for preflight (always a self-transfer so destination errors surface in `confirmSend`) +- `toAddress` — optional Stellar destination; ignored for preflight (always a self-transfer so destination errors surface in `confirmSend`) **Response** @@ -67,7 +67,7 @@ sequenceDiagram participant Meta as AssetMetadataService participant Tx as TransactionService - Client->>Handler: onAmountInput { accountId, assetId, value, to? } + Client->>Handler: onAmountInput { accountId, assetId, value, toAddress? } Handler->>Resolver: resolve from keyring state Resolver-->>Handler: account, wallet, onChainAccount Handler->>Meta: resolve(assetId) diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.test.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.test.ts index 7620bfaa5..30ba8e5f4 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.test.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.test.ts @@ -571,7 +571,7 @@ describe('OnAmountInputJsonRpcRequestStruct', () => { ...baseWireRequest.params, assetId: slip44AssetId, value: '1.0000001', - to: stellarAddress, + toAddress: stellarAddress, }, }, expectedScope: 'stellar:pubnet', diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts index b355b7e46..827e6411a 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/api.ts @@ -242,7 +242,7 @@ const OnAmountInputParamsWireStruct = object({ KnownCaip19Slip44IdStruct, ]), value: nonempty(string()), - to: optional(StellarAddressStruct), + toAddress: optional(StellarAddressStruct), }); const OnAmountInputParamsStruct = assign( diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts index b1a87cf3d..e8d09d3dd 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts @@ -130,7 +130,7 @@ describe('OnAmountInputHandler', () => { overrides: Partial< Pick< OnAmountInputJsonRpcRequest['params'], - 'accountId' | 'assetId' | 'value' | 'to' + 'accountId' | 'assetId' | 'value' | 'toAddress' > > = {}, ) { @@ -221,10 +221,10 @@ describe('OnAmountInputHandler', () => { ); }); - it('uses the sender as destination even when params.to is set', async () => { + it('uses the sender as destination even when params.toAddress is set', async () => { const { handler, onChainAccount, createValidatedSendTransaction } = setup(); - await handler.handle(baseRequest({ to: destinationAddress })); + await handler.handle(baseRequest({ toAddress: destinationAddress })); expect(createValidatedSendTransaction).toHaveBeenCalledWith({ onChainAccount, diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.ts index 42bbdf6e3..86f4a88d6 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.ts @@ -64,7 +64,7 @@ export class OnAmountInputHandler extends BaseClientRequestHandler< * repeated amount checks stay responsive. * * @param resolved - Keyring account, persisted on-chain snapshot, and wallet. - * @param request - JSON-RPC request with `assetId` and `value` (positive amount string). Optional `to` is ignored; destination validation happens in `confirmSend` (`scope` is derived from `assetId`). + * @param request - JSON-RPC request with `assetId` and `value` (positive amount string). Optional `toAddress` is ignored; destination validation happens in `confirmSend` (`scope` is derived from `assetId`). * @returns Validation result with `valid` and optional error codes. */ protected async execute( From 98c2234e8b38ff882f8736fb5e5f222d30373089 Mon Sep 17 00:00:00 2001 From: Stanley Yuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Thu, 5 Nov 2026 10:50:32 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md --- packages/stellar-wallet-snap/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/stellar-wallet-snap/CHANGELOG.md b/packages/stellar-wallet-snap/CHANGELOG.md index e2435dfd6..1e2c5e068 100644 --- a/packages/stellar-wallet-snap/CHANGELOG.md +++ b/packages/stellar-wallet-snap/CHANGELOG.md @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Retry transient RPC and Horizon failures with bounded timeouts and circuit breaking ([#551](https://github.com/MetaMask/internal-snaps/pull/551)) - Transaction submission still uses the raw RPC client and does not apply the fetch policy. +### Fixed + +- Fix `onAmountInput` to accept optional destination as `toAddress` instead of `to` ([#558](https://github.com/MetaMask/internal-snaps/pull/558)) + ## [2.0.0] ### Added