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

refactor: environment config for social wallet #2728

Merged
merged 6 commits into from
Nov 3, 2023

Conversation

schmanu
Copy link
Member

@schmanu schmanu commented Nov 1, 2023

What it solves

Uses JSON in config for Social wallet to avoid having too many variables.

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

Copy link

github-actions bot commented Nov 1, 2023

Branch preview

⏳ Deploying a preview site...

Copy link

github-actions bot commented Nov 1, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link

github-actions bot commented Nov 1, 2023

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
75.25% (+0.01% 🔼)
10044/13347
🔴 Branches
49.72% (+0.04% 🔼)
2051/4125
🔴 Functions
57.87% (+0.03% 🔼)
1497/2587
🟡 Lines
76.77% (-0% 🔻)
9080/11828
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟡
... / config.ts
63.16% 53.85% 50% 62.5%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / SocialWalletService.ts
58.9% (+0.93% 🔼)
46.15% (-3.85% 🔻)
46.15%
60% (+0.91% 🔼)

Test suite run success

1100 tests passing in 153 suites.

Report generated by 🧪jest coverage report action from 5b92d4b

}

/** env variables */
const SOCIAL_WALLET_IS_PRODUCTION = process.env.NEXT_PUBLIC_IS_PRODUCTION === 'true'
Copy link
Member

@katspaugh katspaugh Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is IS_PRODUCTION in the constants.ts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this const and use IS_PRODUCTION directly now.


const hasRequiredKeys =
keys.length === 4 &&
keys.includes(SocialWalletOptionsKeys.web3AuthClientId) &&
Copy link
Member

@katspaugh katspaugh Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This validation is a bit excessive/boilerplatey.
Surely there’s a more elegant way to check that an object has certain properties other than getting the array of keys and checking it against each of the required ones.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to use the in operator to check if all keys exist in the object.

try {
return JSON.parse(IS_PRODUCTION ? SOCIAL_WALLET_OPTIONS_PRODUCTION : SOCIAL_WALLET_OPTIONS_STAGING)
} catch (error) {
console.error(error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error(error)
console.error('Error parsing SOCIAL_WALLET_OPTIONS', error)

@@ -18,9 +18,10 @@ export const useInitMPC = () => {
useInitSocialWallet()

useEffect(() => {
if (!chain || !onboard) {
if (!chain || !onboard || !isSocialWalletOptions(SOCIAL_WALLET_OPTIONS)) {
Copy link
Member

@katspaugh katspaugh Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this check at the entry point to this flow instead?
I.e. not even show the Google button if these env vars aren't set. This is important for forks.

Although, never mind. This feature needs to be explicitely toggled on in the config service anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the config service toggle only changes if the button is enabled or not. We could use the env vars to decide if the feature should be enabled or not though.

@usame-algan usame-algan merged commit 53d95cd into web3authcoresdk Nov 3, 2023
3 of 6 checks passed
@usame-algan usame-algan deleted the seedless-new-config branch November 3, 2023 10:45
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants