tasitlabs / tasit-sdk

A JavaScript / TypeScript SDK for making native mobile Ethereum dapps using React Native
https://tasit.dev
MIT License
97 stars 10 forks source link

Use config file (config/default.js or .env) to setup TasitSDK parameters #184

Open marcelomorgado opened 5 years ago

marcelomorgado commented 5 years ago

config and dotenv modules use some node.js APIs that are unavailable on react-native environment. For now, we are using programmatically config.

See more: https://github.com/expo/expo/issues/83 https://medium.com/@skiptomyhue/setting-up-environment-variables-for-react-native-builds-b66a2576a218 https://medium.com/@tacomanator/environments-with-create-react-app-7b645312c09d https://github.com/zetachang/react-native-dotenv https://www.reactnative.guide/6-conventions-and-code-style/6.3-environment-variables.html https://stackoverflow.com/questions/33117227/setting-environment-variable-in-react-native https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables https://stackoverflow.com/questions/33117227/setting-environment-variable-in-react-native/37823398 https://github.com/manoj-nama/expo-env https://medium.com/@peterpme/environment-variables-in-expo-using-release-channels-4934594c5307

pcowgill commented 5 years ago

@marcelomorgado Can we close this?

marcelomorgado commented 5 years ago

Maybe, the current solution just imports the config file parameters to a singleton object. With one of the packages above (like dotenv), the config is imported automagically and the parameters are exposed as global vars to the application.

pcowgill commented 5 years ago

Ah ok - we can keep it open then and continue to ponder it

marcelomorgado commented 5 years ago

A note: The current approach (reading config from a file manually) isn't working well on the tasit app if ProviderFactory is used (direct or indirectly) outside of a function. The solution used here should address that issue too.

Refs: https://github.com/tasitlabs/tasit/pull/269#discussion_r274048159 Related to: https://github.com/tasitlabs/tasit/issues/278