Skip to content

types: flesh out CLNRest #3925

@kaloudis

Description

@kaloudis

To improve type safety and code clarity, it's best to avoid using any. Let's interfaces for the channel and peers, objects based on the expected structure from the CLN API response.

For example:

interface IClnClosedChannel {
  peer_id: string;
  total_msat: number;
  channel_id: string;
  short_channel_id: string;
  last_commitment_txid: string;
  opener: 'local' | 'remote';
  closer: 'local' | 'remote';
  private: boolean;
  // ... other properties
}

// ...

const formattedClosedChannels = data.closedchannels.map((channel: IClnClosedChannel) => ({
  // ...
}));

This leverages TypeScript's strengths to catch potential errors during development and makes the code easier to understand and maintain.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions