js-stellar-sdk
js-stellar-sdk copied to clipboard
StellarTomlResolver.resolve should offer better types
Is your feature request related to a problem? Please describe.
Its annoying when I try to parse the stellar.toml file with StellarTomlResolver and the resulting type defintion is { [key: string]: any }.
Describe the solution you'd like Extend the definition to include common stellar.toml fields.
Example:
interface StellarTOML {
AUTH_SERVER: string;
FEDERATION_SERVER: string;
/** etc... */
[key: string]: any;
}
Describe alternatives you've considered Making it readonly is also probably justified
interface StellarTOML {
readonly AUTH_SERVER: string;
readonly FEDERATION_SERVER: string;
/** etc... */
readonly [key: string]: any;
}
I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
I have 7 years of typescript development experience
How I plan on tackling this issue
` interface StellarTOML { readonly AUTH_SERVER: string; readonly FEDERATION_SERVER: string; readonly TRANSFER_SERVER?: string; readonly KYC_SERVER?: string; readonly WEB_AUTH_ENDPOINT?: string; readonly SIGNING_KEY?: string; readonly HORIZON_URL?: string; // Additional readonly fields can be added here as needed
readonly [key: string]: any; // Readonly support for other fields } `
I am applying to this issue via OnlyDust platform.
My background and how it can be leveraged
I'm a javascript/Typescript developer
How I plan on tackling this issue
so my approach to this will be that: The essential fields like AUTH_SERVER and FEDERATION_SERVER are marked as readonly and required. example interface StellarTOML{ readonly AUTH_SERVER: string; readonly FEDERATION_SERVER: string;
//Then, optional well-known fields can be as:// readonly TRANSFER_SERVER?: string; readonly WEB_AUTH_ENDPOINT?: string; readonly KYC_SERVER?: string; readonly SIGNING_KEY?: string; readonly HORIZON_URL?: string; readonly ACCOUNTS?: string[];
//finally, other fields can be allowed dynamically with strict types as:// readonly [key: string]: string | number | boolean | null | undefined | string[]; }
This approach can improve code intellsense, type safet and flexibility.
Can I jump on this task?
Could I try solving this?
Looks to be addressed in #794