Skip to content

feat(backend): implement SorobanVaultChainInvoker — wire on-chain vault pause/unpause#281

Merged
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom
Salmatcre8:feature/issue-242-soroban-vault-chain-invoker
Apr 23, 2026
Merged

feat(backend): implement SorobanVaultChainInvoker — wire on-chain vault pause/unpause#281
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom
Salmatcre8:feature/issue-242-soroban-vault-chain-invoker

Conversation

@Salmatcre8
Copy link
Copy Markdown
Contributor

Summary

  • Adds internal/stellar package with ContractInvoker: builds and submits InvokeHostFunction transactions to a Soroban RPC node using simulate → patch soroban data → sign → send → poll flow
  • Adds SorobanVaultChainInvoker in internal/service that implements VaultChainInvoker by calling pause/unpause on the on-chain vault contract
  • Wires the real invoker in main.go when STELLAR_OPERATOR_SECRET is set; falls back to NoopVaultChainInvoker when it is absent (preserves backward-compat for envs without a configured operator key)
  • Adds STELLAR_OPERATOR_SECRET optional config field (loaded from env, no validation — empty is valid)

How it works

AdminService.PauseVault
  → SorobanVaultChainInvoker.PauseVault(ctx, contractAddress)
    → ContractInvoker.InvokeVoidFunction(ctx, contractAddress, "pause")
      1. GET /accounts/{operator} from Horizon → sequence number
      2. Build InvokeHostFunction tx (caller = operator keypair)
      3. POST simulateTransaction → get SorobanTransactionData + minResourceFee
      4. Patch envelope with soroban data and bumped fee
      5. Sign with operator keypair
      6. POST sendTransaction
      7. Poll getTransaction until SUCCESS / FAILED
  → repository.UpdateVaultStatus(ctx, id, StatusPaused)

Test plan

  • go test ./internal/stellar/... — 7 unit tests pass (address encoding, simulate-error path, send-error path)
  • go test ./internal/service/... — invoker construction, invalid-contract rejection, RPC error propagation, noop default
  • GOOS=linux go build ./... — clean Linux build

Closes #242

…pause/unpause

Replaces the NoopVaultChainInvoker used in production with a real
Soroban RPC invoker. When STELLAR_OPERATOR_SECRET is set the API now
submits an InvokeHostFunction transaction (simulate → patch soroban
data → sign → send → poll) to call pause/unpause on the on-chain vault
contract before updating the database record.

Closes Suncrest-Labs#242
@Salmatcre8 Salmatcre8 requested a review from 0xDeon as a code owner April 23, 2026 15:56
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@Salmatcre8 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown
Contributor

@0xDeon 0xDeon left a comment

Choose a reason for hiding this comment

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

Lgtm

@0xDeon 0xDeon merged commit c261a88 into Suncrest-Labs:main Apr 23, 2026
6 checks passed
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.

[Backend] Admin vault pause/unpause uses NoopVaultChainInvoker — on-chain vault remains active during declared emergencies

2 participants