Skip to content

feat(sdk): implement complete deposit flow with transaction lifecycle…#244

Open
Litezy wants to merge 1 commit intoANAVHEOBA:mainfrom
Litezy:feat/deposit-flow
Open

feat(sdk): implement complete deposit flow with transaction lifecycle…#244
Litezy wants to merge 1 commit intoANAVHEOBA:mainfrom
Litezy:feat/deposit-flow

Conversation

@Litezy
Copy link
Copy Markdown
Contributor

@Litezy Litezy commented Apr 23, 2026

🚀 Overview

This PR implements the full end-to-end deposit flow in the SDK, covering everything from note generation to transaction confirmation and receipt parsing.

It provides a clean, production-ready abstraction for interacting with the deposit contract.


✅ What’s Included

Closes #10

Core Features

  • deposit() – orchestrates the full deposit lifecycle
  • buildDepositTransaction() – constructs unsigned transaction
  • submitTransaction() – submits + polls until confirmation
  • parseDepositReceipt() – extracts leaf index + Merkle root from result
  • estimateDepositCost() – estimates gas via simulation

Flow Implementation

  1. Generate a new privacy note
  2. Compute commitment
  3. Build deposit transaction
  4. Sign transaction (via injected signer)
  5. Submit to network
  6. Wait for confirmation (with retry + timeout handling)
  7. Parse receipt (leaf index, tx hash, root)

Reliability & Error Handling

  • Simulation failure handling
  • Transaction failure detection
  • Timeout handling for pending txs
  • Retry logic with exponential backoff
  • Contract error mapping (e.g. insufficient balance, pool paused, tree full)

Testing

  • ✅ Transaction building
  • ✅ Receipt parsing
  • ✅ Error scenarios (simulation + submission failures)
  • ✅ Gas estimation
  • ✅ Mock contract deposit flow
  • ⚙️ Optional testnet integration

📦 Developer Experience

  • Fully typed TypeScript API
  • Modular functions for flexibility
  • Clear separation of concerns (build / submit / parse)
  • SDK-safe abstractions (handles Soroban inconsistencies internally)

📖 Example Usage

await deposit({
  server,
  signer,
  contractId,
  amount,
});

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.

1 participant