-
Notifications
You must be signed in to change notification settings - Fork 176
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
ADD defaults & check for valid NEAR_WALLET_ENV #2299
Conversation
Your Render PR Server URL is https://near-wallet-pr-2299.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-c6p8ovvs437g6pticab0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at all of the duplicated OR cases with process.env
references repeated in every file, it feels untenable to leave so many places with duplicated references in place.
Let's do this:
- Create a 'global' hash of all
config
keys and their associated references toprocess.env.XXX_YYYYY
; this should exist in a central file because the references toprocess.env
are always the same, no matter what value is inNEAR_WALLET_ENV
. - When defining per-environment defaults, don't include the reference to
process.env
. Instead, let's merge the values from the 'global' hash of allconfig
keys that have been loaded from the process environment with the defaults for the current environment, using Lodash.defaults(), where our 'global' hash populated from the process.env is the first argument and the current environment's hash is the second. (see https://lodash.com/docs/4.17.15#defaults) - As a result of # 1 and # 2 above, if any config value's associated
process.env
mapping has a value, it will always take precedence over any per-environment defaults (they will truly be defaults). If nothing is defined in theprocess.env
key associated with a particular config entry, then the per-environment default will be applied.
HMU directly with any questions/concerns about this :). I think it will be really good to have all of our process.env
parsing in a centralized file and have all of our per-environment config files just be a raw hash of values with no process.env fallback logic -- just default values per key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Just a few minor comments inline 🙂
New changes look good to me but bundling is failing because Since this is a breaking change do we also need a value for this in |
@andy-haynes I'll be adding functionality to compute |
Perfect, thanks for the clarification! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, mostly minor comments but I still think we need to find a way to ensure NEAR_WALLET_ENV
is set in the mainnet*
environments as well as testnet_STAGING
(which currently just uses testnet
). I'm happy to sync up when we have some good schedule overlap to go over the feedback and work out a plan for testnet_STAGING
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments in-line -- in brief, let's totally remove testnet_STAGING
for now and eliminate any fuzzy fallbacks :) Saw a couple of spots that we should be unpacking env vars that I also mentioned in-line.
packages/frontend/src/config/environmentDefaults/mainnet_STAGING.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one thing re: always removing whitespace in the parse comma helper function
Also, Andy's comment re: https://github.com/near/near-wallet/blob/master/packages/frontend/ci/ParcelBundler.js#L13 is accurate -- please remove the coercion there :). Then we can get this sucker landed! I'm keen to get this merged today (Jan 11th) if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 legit -- nice work folks! We're really making some progress on our snarled and confusing environments at this point!
NEAR_WALLET_ENV
in module scope and throw if invalid*NEAR_WALLET_ENV
NEAR_WALLET_ENV
REACT_APP_IS_MAINNET
and replace withNEAR_WALLET_ENV
conditionalprocess.env
outside of config files*This is a breaking change in all environments until
NEAR_WALLET_ENV
is correctly set to one of these values.Closes #2291