Skip to content

[Feature] Integrate Soroban milestone approval transactions (Closes #155) - #174

Open
jaymoneymanxl wants to merge 1 commit into
Lumina-eX:mainfrom
jaymoneymanxl:feat/milestone-approval-tx
Open

[Feature] Integrate Soroban milestone approval transactions (Closes #155)#174
jaymoneymanxl wants to merge 1 commit into
Lumina-eX:mainfrom
jaymoneymanxl:feat/milestone-approval-tx

Conversation

@jaymoneymanxl

Copy link
Copy Markdown

Overview

Integrates the TaskChain frontend with Soroban smart contracts to approve milestone completion on-chain. This ensures milestone approvals are cryptographically secure and recorded on the Stellar network, providing transparency and immutability for escrow releases.

Changes

📦 New: lib/soroban/milestone-approval.ts

Soroban Transaction Service — Builds, signs, submits, and tracks milestone approval transactions:

Build Transaction:

  • Constructs a Soroban contract call to approve_milestone(milestoneId)
  • Uses @stellar/stellar-sdk TransactionBuilder with proper Soroban data
  • Pre-simulates via prepareTransaction() to get accurate fee and footprint

User Signature:

  • Accepts a signTransaction callback for wallet integration (Freighter, Albedo, etc.)
  • Returns the unsigned XDR for the wallet to sign
  • Supports any wallet that provides an XDR signing interface

Submit Transaction:

  • Sends the signed XDR to the Soroban RPC endpoint
  • Handles network errors gracefully with descriptive messages

Transaction Status:

  • Real-time status updates via onStatusChange callback
  • States: idle → building → awaiting_signature → submitting → pending → confirmed | failed
  • Polls for confirmation with configurable timeout (60s default)

Type Safety:

  • Full TypeScript types for all states, params, and responses
  • MilestoneApprovalState union for discriminated status handling
  • MilestoneApprovalParams interface for type-safe configuration

Verification

cd TaskChain
npx tsc --noEmit lib/soroban/milestone-approval.ts
# Expected: No type errors

Integration Example

import { approveMilestoneOnChain } from "@/lib/soroban/milestone-approval"

const { status, txHash } = await approveMilestoneOnChain({
  clientAccountId: "GABCD...",
  contractId: "CC...",
  milestoneId: "milestone_123",
  networkPassphrase: Networks.TESTNET,
  rpcUrl: "https://soroban-testnet.stellar.org",
  signTransaction: async (xdr) => window.freighter.signTransaction(xdr),
  onStatusChange: (state) => setTxState(state),
})

Closes #155

Closes Lumina-eX#155

Add Soroban transaction builder, wallet signature flow, submission, and real-time status polling for on-chain milestone approval. Includes comprehensive TypeScript types and error handling.

Co-authored-by: Morenike2 <Morenike2@users.noreply.github.com>
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.

[Feature]: Milestone Approval Transactions

1 participant