Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JST-651/disallow any in sdk source #722

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

SewerynKras
Copy link
Contributor

No description provided.

@SewerynKras SewerynKras requested a review from a team December 14, 2023 09:34
src/events/events.ts Show resolved Hide resolved
src/utils/logger/logger.ts Show resolved Hide resolved
if (payload.providerName) {
return payload;
return payload as ProviderInfo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of casting, you could implement a simple type guard like that:

import { AbstractAggregator } from "./abstract_aggregator";

export interface ProviderInfo {
  id: string;
  providerName: string;
}

interface Payload {
  id: string;
  providerName?: string;
}

function isProviderInfo(input: Payload): input is ProviderInfo {
  return input.providerName !== undefined;
}

export class Providers extends AbstractAggregator<Payload, ProviderInfo> {
  beforeAdd(payload: Payload): ProviderInfo {
    if (isProviderInfo(payload)) {
      return payload;
    }

    const provider = this.getById(payload.id);
    return {
      id: payload.id,
      providerName: provider?.providerName || "unknown",
    };
  }
}

This way we will get rid of a "dirty" assertion here :)

src/script/command.ts Show resolved Hide resolved
src/market/proposal.ts Show resolved Hide resolved
src/market/service.ts Show resolved Hide resolved
@SewerynKras SewerynKras merged commit 5032fd1 into beta Dec 15, 2023
8 checks passed
@SewerynKras SewerynKras deleted the feature/JST-651/disallow-any-in-sdk-source branch December 15, 2023 14:48
Copy link

🎉 This PR is included in version 2.0.0-beta.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants