feat: add confirmSend RPC#76
Conversation
…ss-input-validate
There was a problem hiding this comment.
Pull request overview
Adds a new confirmSend client-request/RPC flow for Stellar “Unified Non‑EVM Send”, including a dedicated confirmation UI and handler wiring so a client can validate, confirm, sign, submit, and track a send transaction.
Changes:
- Introduces
ConfirmSendHandlerand JSON-RPC structs/types forconfirmSend, plus unit tests. - Adds a new confirmation view (
ConfirmSendTransaction) and user-input event handlers to resolve confirm/cancel. - Updates routing/wiring (controller, context, dev-site) to expose and exercise
stellar_confirmSend.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/snap/src/ui/confirmation/views/ConfirmSendTransaction/events.tsx | Adds user-input handlers + form names for the confirm/cancel buttons. |
| packages/snap/src/ui/confirmation/views/ConfirmSendTransaction/ConfirmSendTransaction.tsx | Implements the confirmation UI for send transactions (to/from/amount/network/fees). |
| packages/snap/src/ui/confirmation/utils.ts | Adds getAccountExplorerUrl and updates fee formatting to use toDisplayBalance. |
| packages/snap/src/ui/confirmation/controller.tsx | Registers the new confirmation interface key as a fee-bearing dialog and renders the new view. |
| packages/snap/src/ui/confirmation/api.ts | Adds ConfirmSendTransaction to ConfirmationInterfaceKey. |
| packages/snap/src/index.ts | Routes dev-only stellar_confirmSend (and related methods) through clientRequestHandler. |
| packages/snap/src/handlers/user-input/userInput.ts | Registers the new confirm-send UI event handlers. |
| packages/snap/src/handlers/clientRequest/onAmountInput.ts | Consumes coerced scope from request params rather than deriving it in-handler. |
| packages/snap/src/handlers/clientRequest/onAmountInput.test.ts | Updates tests for new scope derivation + adds additional assertions. |
| packages/snap/src/handlers/clientRequest/confirmSend.ts | New handler: builds validated send tx, renders confirmation UI, signs, submits, saves pending tx, schedules tracking. |
| packages/snap/src/handlers/clientRequest/confirmSend.test.ts | Adds unit tests covering success, rejection, and error mappings. |
| packages/snap/src/handlers/clientRequest/api.ts | Adds ConfirmSend method + request/response structs; coerces scope and accountId. |
| packages/snap/src/handlers/clientRequest/api.test.ts | Adds request/response struct tests for confirmSend; updates onAmountInput coercion tests. |
| packages/snap/src/context.ts | Wires ConfirmSendHandler into the client request method map. |
| packages/site/src/pages/index.tsx | Adds a dev-dapp card/workflow to validate address/amount and call stellar_confirmSend. |
Comments suppressed due to low confidence (1)
packages/snap/src/ui/confirmation/views/ConfirmSendTransaction/events.tsx:25
- The JSDoc says the handler context is from
confirmSend, but these UI event handlers are invoked via the SnaponUserInputentrypoint. Consider updating the reference toonUserInputfor consistency and accuracy.
* Handles the click event for the confirm button.
*
* @param options - The user input handler context from `confirmSend`.
* @returns A promise that resolves when the interface has been updated.
*/
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Handles the click event for the cancel button. | ||
| * | ||
| * @param options - The user input handler context from `confirmSend`. | ||
| * @returns A promise that resolves when the interface has been updated. | ||
| */ |
There was a problem hiding this comment.
i think it is make sense and correct
| } | ||
|
|
||
| const transaction = | ||
| await this.#transactionService.createValidatedSendTransaction({ |
There was a problem hiding this comment.
We build and validate the send tx before the confirmation dialog, then sign that same envelope after the user clicks Confirm. If they wait on the dialog, sequence/balance/fees can change. Can we move createValidatedSendTransaction to after confirm (or rebuild + re-validate right before sign)?
There was a problem hiding this comment.
thats good idea, but it will invalid the idea that u sign what you are seeing (fee change)
like sol / btc, they didnt do that too
created a spike in JIRA https://consensyssoftware.atlassian.net/browse/NEB-1259 to discuss
| }); | ||
|
|
||
| const ConfirmSendParamsStruct = object({ | ||
| fromAccountId: UuidStruct, |
There was a problem hiding this comment.
Small API nit: onAmountInput uses accountId, confirmSend uses fromAccountId. Can we align on one name across the send flow?
There was a problem hiding this comment.
can not, it is shared across all non-evm, they using that name
|
|
||
| wallet.signTransaction(transaction); | ||
| // refresh the account to get the latest balance and sequence to validate the transaction. | ||
| const finalizedTransaction = |
There was a problem hiding this comment.
it will regenerate the txn with latest
fee
account sequence
validation with latest account state (include sep41 balance)
This reverts commit b86ddd4.
|
Follow up: Adding transaction refresh if transaction confirm it is necessary |
Explanation
Adds a new confirmSend client-request/RPC flow for Stellar “Unified Non‑EVM Send”, including a dedicated confirmation UI and handler wiring so a client can validate, confirm, sign, submit, and track a send transaction.
References
Checklist