chore: add preload accounts helper in TransactionService#52
Open
stanleyyconsensys wants to merge 2 commits intomainfrom
Open
chore: add preload accounts helper in TransactionService#52stanleyyconsensys wants to merge 2 commits intomainfrom
stanleyyconsensys wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the transaction/network services to support swap-transaction validation from XDR and introduces a batched helper for preloading multiple on-chain accounts, alongside tweaks to how transactions track “involved” accounts.
Changes:
- Added
TransactionService.createValidatedSwapTransactionto deserialize XDR, compute Soroban fees via simulation, and validate the resulting transaction. - Added
NetworkService.loadOnChainAccounts(batchedallSettled) plus unit tests to load multiple Horizon accounts while preserving input order and mapping failures tonull. - Updated
Transactionaccount-tracking helpers and switchedassertAccountInvolvesTransactionto use the new “invoked by” concept.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/snap/src/services/transaction/utils.ts | Changes signing-involvement check to use isInvokedByAccount. |
| packages/snap/src/services/transaction/TransactionService.ts | Adds swap transaction validation from XDR plus a helper to preload accounts. |
| packages/snap/src/services/transaction/Transaction.ts | Adds #invokedByAccounts tracking and expands participating accounts for path payment destinations. |
| packages/snap/src/services/network/NetworkService.ts | Adds batched multi-account loading (loadOnChainAccounts). |
| packages/snap/src/services/network/NetworkService.test.ts | Adds test coverage for loadOnChainAccounts. |
Comments suppressed due to low confidence (1)
packages/snap/src/services/transaction/utils.ts:103
assertAccountInvolvesTransactionis documented/used (e.g. SignTransactionHandler) to allow signing when the wallet participates as tx source, fee source, or an operation source. Switching fromhasParticipatingAccounttoisInvokedByAccountcurrently rejects valid cases where the wallet is only an op source, becauseTransaction.isInvokedByAccountonly tracks tx source + fee source. Consider either reverting tohasParticipatingAccount, or extendingisInvokedByAccount/#invokedByAccountsto include each operation’s effective source so the check matches the intended signing rules.
* Ensures the given wallet account is involved by tx source, fee source, or any operation source.
*
* @param transaction - Wrapped Stellar transaction.
* @param accountId - Wallet account id expected to participate in signing.
* @throws {TransactionValidationException} When the wallet account is not involved in the transaction.
*/
export function assertAccountInvolvesTransaction(
transaction: Transaction,
accountId: string,
): void {
if (transaction.isInvokedByAccount(accountId)) {
return;
}
throw new TransactionValidationException(
'Transaction does not involve this wallet account',
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
References
Checklist