Skip to content

feat(blockchain): Implement Stellar account merge and trustline management endpoints - #312

Merged
milah-247 merged 2 commits into
Afro-Pay:mainfrom
B-Hands:feat/wallet-trustlines
Aug 30, 2026
Merged

feat(blockchain): Implement Stellar account merge and trustline management endpoints#312
milah-247 merged 2 commits into
Afro-Pay:mainfrom
B-Hands:feat/wallet-trustlines

Conversation

@Anuoluwapo25

Copy link
Copy Markdown
Contributor

Summary

  • WalletService.createWallet now funds new accounts via Friendbot when STELLAR_NETWORK=testnet, without failing wallet creation if Friendbot is unreachable.
  • Added POST /wallet/trustline (AddTrustlineDto: { assetCode, assetIssuer, limit? }) backed by WalletService.addTrustline, which reuses the existing ensureTrustline helper in anchor/trustline.utils.ts (built on Operation.changeTrust), now extended to support an optional custom limit.
  • WalletService.getBalances returns [] for unfunded/not-found Horizon accounts instead of throwing NotFoundError.
  • assetIssuer is validated as a Stellar G-address via a custom class-validator decorator (StrKey.isValidEd25519PublicKey).
  • Unit tests added for Friendbot funding (success/failure), addTrustline (created/no-op/trustline-error/missing-wallet), and getBalances (mapped balances/empty-on-404/missing-wallet).

Closes #39

Note for reviewers

wallet.service.ts has several pre-existing, unrelated compile issues on main that block a full tsc/jest run for the whole file: a missing nestjs-pino dependency (not installed), a Prisma Wallet model missing multisigEnabled/isFrozen/name columns used by enableMultisig/freezeWallet, and dead code in exportWallet/importWallet referencing undefined AuditCategory/AuditOperation/this.auditLog. These predate this PR and are out of scope for #39, so I left them untouched — flagging here so they're not mistaken for something this PR introduced. I verified this PR's new code introduces no new type errors and resolves the prior getBalances-missing-on-service error in the controller.

Test plan

  • Added unit tests for createWallet Friendbot funding (success + failure paths)
  • Added unit tests for addTrustline (created, no-op/already-exists, trustline error → 400, missing wallet → 404)
  • Added unit tests for getBalances (mapped balances, empty array on Horizon 404, missing wallet → 404)
  • Full npm test currently can't run end-to-end due to pre-existing unrelated breakage noted above — reviewer should confirm once that's resolved separately

- WalletService.createWallet now funds new accounts via Friendbot when
  STELLAR_NETWORK=testnet, without failing wallet creation if funding fails.
- Add POST /wallet/trustline with WalletService.addTrustline, backed by the
  existing anchor/trustline.utils ensureTrustline (Operation.changeTrust),
  now with optional custom limit support.
- WalletService.getBalances returns [] for unfunded/not-found Horizon
  accounts instead of throwing.
- Validate assetIssuer as a Stellar G-address via a custom class-validator
  decorator.
- Add unit tests for Friendbot funding, addTrustline, and getBalances.

Closes Afro-Pay#39

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Anuoluwapo25 is attempting to deploy a commit to the milah's projects Team on Vercel.

A member of the Team first needs to authorize it.

@milah-247
milah-247 merged commit 3479426 into Afro-Pay:main Aug 30, 2026
1 check failed
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.

feat(blockchain): Implement Stellar account merge and trustline management endpoints

2 participants