You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently adding tests to chakra-components library, and I have had to copy-paste the constants of the urls, so I can properly test behavior changes (like, if I set a proper environment). Since the only way to see these kind of changes right now is by checking the defined urls, I ended up copy-pasting these constants to my tests, so I could make em.
A better solution would be to have the environment set internally in the VocdoniSDKClient instance, and be able to access it, but this implies changing the way the urls are accessed internally (since right now they are defined when creating the instance).
Motivation
Testing
Proposal
I think the best approach is to change the way we're using the environment internally.
IMHO we should allow setting each available URL in an (optional) associative array in the constructor. We could maintain the env argument, as something optional, that could automatically set these URLs based on our current environments.
exporttypeClientOptions={env?: EnvOptions;wallet?: Wallet|Signer;electionId?: string;faucet?: FaucetOptions;tx_wait?: TxWaitOptions;urls?: Partial<ApiUris>};exporttypeApiUris={main: string;faucet: string;// maybe some aren't required actually, this is just an example and you can organize the defaults as you wantexplorer: string;// [...]};// somewhere have a const with default urls set as type ApiUris// then, in the constructor...constructor(opts: ClientOptions){if(!opts.env&&!opts.urls){throwError()}// use opts.url as default values.// if none are passed, use `env` to define defaults// [...]}
Note that, for the part of the urls, instead of creating the urls every time on each call, an axios instance with the baseUrl defined could be created when creating the VocdoniSDKClient, and then use that instance for the calls, removing the need to create the urls using the defined base every single time.
Components affected
client.ts
census3.ts
The text was updated successfully, but these errors were encountered:
Describe the feature
I'm currently adding tests to chakra-components library, and I have had to copy-paste the constants of the urls, so I can properly test behavior changes (like, if I set a proper environment). Since the only way to see these kind of changes right now is by checking the defined urls, I ended up copy-pasting these constants to my tests, so I could make em.
A better solution would be to have the environment set internally in the
VocdoniSDKClient
instance, and be able to access it, but this implies changing the way the urls are accessed internally (since right now they are defined when creating the instance).Motivation
Testing
Proposal
I think the best approach is to change the way we're using the environment internally.
IMHO we should allow setting each available URL in an (optional) associative array in the constructor. We could maintain the
env
argument, as something optional, that could automatically set these URLs based on our current environments.Components affected
The text was updated successfully, but these errors were encountered: