Skip to content

feat: migrate callback API to onProgress with typed responses #91

@SgtPooki

Description

@SgtPooki

progressCallbacks?: {
onProviderSelected?: (provider: any) => void
onDataSetCreationStarted?: (transaction: any) => void
onDataSetResolved?: (info: { dataSetId: number; isExisting: boolean }) => void
}

Instead of surfacing the granularity of callbacks that exist in synapse-sdk, we should allow consumers to pass an onProgress handler that receives an event for any of the callbacks. Similar to what we have in checkUploadReadiness:

/**
 * Options for evaluating whether an upload can proceed.
 */
export type UploadReadinessProgressEvent =
  | { type: 'checking-balances' }
  | { type: 'checking-allowances' }
  | { type: 'configuring-allowances' }
  | { type: 'allowances-configured'; transactionHash?: string }
  | { type: 'validating-capacity' }

export interface UploadReadinessOptions {
  /** Initialized Synapse instance. */
  synapse: Synapse
  /** Size of the CAR file (bytes). */
  fileSize: number
  /**
   * Automatically configure allowances when they are missing.
   * Defaults to `true` to match current CLI/action behaviour.
   */
  autoConfigureAllowances?: boolean
  /** Optional callback for progress updates. */
  onProgress?: (event: UploadReadinessProgressEvent) => void
}

what do you think @rvagg ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    team/filecoin-pin"Filecoin Pin" project is a stakeholder for this work.team/fs-wgFOC working group is a stakeholder for this work, and thus wants to track it on their project board.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions