Skip to content

[SDK] TypeScript SDK Client-Side Signing & Transaction Builder Extensions #1453

Description

@blurbeast

Overview & Background

packages/flowfi-sdk provides basic interfaces and generated bindings, but lacks high-level transaction construction, client-side wallet signing abstractions, and simulation pipelines. For third-party dApps, payroll providers, and automated bots to integrate with FlowFi without routing through the FlowFi backend API, the SDK needs full standalone transaction building capabilities.


Detailed Problem Statement

  1. High Barrier for Third-Party Integrations:
    • External developers must manually build raw Soroban XDR operations and handle footprint resource estimation.
  2. Tight Backend Coupling:
    • Currently, dApps are forced to depend on FlowFi's central backend API for stream operations rather than communicating directly with the Stellar ledger.

Technical Specification & Architecture

1. High-Level FlowFiClient API

Implement in packages/flowfi-sdk/src/client.ts:

export class FlowFiClient {
  constructor(config: { rpcUrl: string; networkPassphrase: string; contractId: string });

  async createStream(params: CreateStreamParams, signer: Signer): Promise<StreamResult>;
  async batchWithdraw(streamIds: bigint[], signer: Signer): Promise<WithdrawResult>;
  async topUpStream(streamId: bigint, amount: bigint, signer: Signer): Promise<void>;
  async cancelStream(streamId: bigint, signer: Signer): Promise<void>;
  async getStream(streamId: bigint): Promise<StreamDetails>;
  async getClaimableAmount(streamId: bigint): Promise<bigint>;
}

2. Modular Signer Adapters

Implement in packages/flowfi-sdk/src/signers/:

  • FreighterSigner: In-browser extension signing.
  • KeypairSigner: Node.js secret key signing for automated payroll daemons.
  • CustomSigner: Generic interface for WalletConnect / hardware wallets.

3. Automatic Resource Simulation & Fee Padding

  • Automatically invokes simulateTransaction on Soroban RPC.
  • Attaches computed authorization entries and foot-print keys.
  • Adds configurable safety resource fee buffer.

Target Files

  • packages/flowfi-sdk/src/client.ts
  • packages/flowfi-sdk/src/builder.ts
  • packages/flowfi-sdk/src/signers/index.ts
  • packages/flowfi-sdk/README.md
  • packages/flowfi-sdk/tests/client.test.ts

Acceptance Criteria

  • External dApps can create, withdraw, top-up, and cancel streams with 3 lines of TypeScript code.
  • Works seamlessly in both browser and Node.js environments.
  • Includes comprehensive mock tests for transaction building and simulation.
  • Complete SDK documentation and quickstart examples added to SDK README.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions