Skip to content

feat(transfer): add structured progress callbacks to transfer() - #49

Closed
sparkysolutions10-pixel wants to merge 1 commit into
Parabola-org:mainfrom
sparkysolutions10-pixel:feat/transfer-progress-callbacks
Closed

sparkysolutions10-pixel wants to merge 1 commit into
Parabola-org:mainfrom
sparkysolutions10-pixel:feat/transfer-progress-callbacks

Conversation

@sparkysolutions10-pixel

Copy link
Copy Markdown

Summary

Closes #6
Bounty Claim: /claim #6

This PR adds structured, stage-level progress callbacks to transfer() via options.onProgress?: (event: TransferProgressEvent) => void.

Changes Made

  • Discriminated Union & Types (src/types.ts):
    • Defined TransferProgressStage = "recipient-check" | "approve" | "burn-submitted" | "burn-confirmed" | "attestation" | "mint-submitted" | "mint-confirmed".
    • Defined TransferProgressEvent discriminated union with stage-specific payloads:
      • recipient-check: stage, timestamp
      • approve: stage, timestamp
      • burn-submitted: stage, burnTxHash, timestamp
      • burn-confirmed: stage, burnTxHash, timestamp
      • attestation: stage, burnTxHash, attestationHash?, timestamp
      • mint-submitted: stage, burnTxHash, attestationHash?, mintTxHash?, timestamp
      • mint-confirmed: stage, burnTxHash, attestationHash, mintTxHash, timestamp
    • Added optional onProgress callback to TransferOptionsBase and CompleteMintOptions.
  • Public Exports (src/index.ts):
    • Exported TransferProgressStage, TransferProgressEvent, and individual event interfaces.
  • Stage Boundaries & Safe Invocation (src/transfer.ts):
    • Emitted events in exact chronological order across transfer stages.
    • Safe error boundary (safeEmit): Any exceptions thrown inside caller's onProgress callback are swallowed to ensure observer errors never abort or alter the cross-chain transfer.
    • No control flow altered when onProgress is omitted.
  • Test Suite (tests/progress.test.ts & tests/types.test.ts):
    • Verified full mock transfer emits all 7 stages in order with burnTxHash present from burn-submitted onward.
    • Verified Stellar -> Arc stage emissions.
    • Verified omitted destinationSigner emits up to attestation.
    • Verified error swallowing when onProgress throws on every callback.
    • Verified error swallowing during transfer failure preserves underlying transfer errors.
    • Verified TypeScript compile-time union narrowing and type discrimination.

Verification

  • pnpm typecheck passed cleanly (tsc --noEmit).
  • pnpm test passed 10/10 test files (120/120 tests).
  • pnpm build (tsup) built ESM, CJS, and DTS bundles cleanly.

Signed-off-by: sparkysolutions10-pixelmy [email protected]

🪙 Base USDC / EVM Wallet: 0x40B7d9273092822341860F5610168861351e71eb
🔗 Direct Razorpay: https://razorpay.me/@sparkydigitalservices

- Define TransferProgressStage and TransferProgressEvent discriminated union in src/types.ts
- Add onProgress option to TransferOptionsBase and CompleteMintOptions
- Export TransferProgressEvent and stage variants from src/index.ts
- Emit progress events at existing transfer stage boundaries
- Ensure onProgress exceptions are swallowed without altering transfer outcome
- Add tests in tests/progress.test.ts and tests/types.test.ts
- Resolves Parabola-org#6

Signed-off-by: sparkysolutions10-pixelmy <[email protected]>
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