Skip to content

chore: add preload accounts helper in TransactionService#52

Open
stanleyyconsensys wants to merge 2 commits intomainfrom
chore-load-accounts
Open

chore: add preload accounts helper in TransactionService#52
stanleyyconsensys wants to merge 2 commits intomainfrom
chore-load-accounts

Conversation

@stanleyyconsensys
Copy link
Copy Markdown
Collaborator

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@stanleyyconsensys stanleyyconsensys requested a review from a team as a code owner May 6, 2026 06:26
@stanleyyconsensys stanleyyconsensys requested a review from Copilot May 6, 2026 06:26
@stanleyyconsensys stanleyyconsensys changed the title chore: add preload accounts helper chore: add preload accounts helper in TransactionService May 6, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.createValidatedSwapTransaction to deserialize XDR, compute Soroban fees via simulation, and validate the resulting transaction.
  • Added NetworkService.loadOnChainAccounts (batched allSettled) plus unit tests to load multiple Horizon accounts while preserving input order and mapping failures to null.
  • Updated Transaction account-tracking helpers and switched assertAccountInvolvesTransaction to 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

  • assertAccountInvolvesTransaction is documented/used (e.g. SignTransactionHandler) to allow signing when the wallet participates as tx source, fee source, or an operation source. Switching from hasParticipatingAccount to isInvokedByAccount currently rejects valid cases where the wallet is only an op source, because Transaction.isInvokedByAccount only tracks tx source + fee source. Consider either reverting to hasParticipatingAccount, or extending isInvokedByAccount/#invokedByAccounts to 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.

Comment thread packages/snap/src/services/transaction/TransactionService.ts Outdated
Comment thread packages/snap/src/services/transaction/TransactionService.ts Outdated
Comment thread packages/snap/src/services/transaction/TransactionService.ts Outdated
Comment thread packages/snap/src/services/transaction/Transaction.ts Outdated
Comment thread packages/snap/src/services/transaction/Transaction.ts
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.

2 participants