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

Handle DTO's undefined and client-side exception #3

Open
1 task
bibishan-pandey opened this issue Apr 24, 2024 · 0 comments
Open
1 task

Handle DTO's undefined and client-side exception #3

bibishan-pandey opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@bibishan-pandey
Copy link
Collaborator

This issue is not always reproducible, but the data coming in from the API or the real-time data from the WebSocket is sometimes undefined inside the object itself, which needs to be correctly handled in the interface for the DTOs in the TypeScript.

What I mean by that is we have some DTOs that look like this:

export interface FollowupBodyType {
    auxiliary_data_hash: string;
    certs: string | undefined;
    collateral: Array<any>;
    collateral_return: Object;
    fee: string;
    inputs: Array<InputTypes>;
    mint: Array<any>;
    network_id: string | undefined;
    outputs: Array<OutputTypes>;
    reference_inputs: Array<any> | undefined;
    required_signers: Array<any> | undefined;
    script_data_hash: string;
    total_collateral: string;
    ttl: string;
    update: undefined | boolean;
    validity_start_interval: undefined | string;
    withdrawals: any;
    is_valid: boolean;
    witness_set: any;
}

If we look closely, collateral_return: Object; this property expects the Object as its data type, and we can have anything inside this. So, these interface and property data types might likely be the root cause for these exceptions.

Solution

  • Properly define the DTOs and their properties and handle them gracefully.
@bibishan-pandey bibishan-pandey added the bug Something isn't working label Apr 24, 2024
@bibishan-pandey bibishan-pandey self-assigned this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant