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

Tracking Issue: Keeeeeeks #2

Open
MariusVanDerWijden opened this issue Mar 19, 2021 · 3 comments
Open

Tracking Issue: Keeeeeeks #2

MariusVanDerWijden opened this issue Mar 19, 2021 · 3 comments

Comments

@MariusVanDerWijden
Copy link

Q:

Here's the repo, this file is the one giving me trouble
https://github.com/Keeeeeeeks/scaffold-eth/blob/master/packages/react-app/src/components/Vorple2.jsx
GitHub
Keeeeeeeks/scaffold-eth
🏗 forkable Ethereum dev stack focused on fast product iterations - Keeeeeeeks/scaffold-eth

Basically i want to make it so that:
- If user logs in through MM/WC AND logs in with the right address, they're able to load the page
else
- The Vorple component doesn't load

At the moment, this seems to load the stuff for failing, and the stuff for it succeeding

Proposed solution: Only initializing the vorple if the userAddress was correct

diff --git a/packages/react-app/src/components/Vorple2.jsx b/packages/react-app/src/components/Vorple2.jsx
index 3beb7ed..7004d98 100644
--- a/packages/react-app/src/components/Vorple2.jsx
+++ b/packages/react-app/src/components/Vorple2.jsx
@@ -22,13 +22,13 @@ export default function Vorple2( address, vorpAddress, userProvider, mainnetProv
                 // Container for the interpreter
                 container: containerRef.current
             };
-            vorple.init();
+            //vorple.init();
         } 
     }, [ containerRef ]);
 
-
     if (userAddress == vorpAddress) {
         isRightAddress = true;
+        vorple.init();
         return (
             <Row align="middle">
                     <vorple-section>
@MariusVanDerWijden
Copy link
Author

MariusVanDerWijden commented Mar 19, 2021

Hmm, this doesn't seem to work for him.
Seems the vorple now reinits whenever the backend refreshes.
I proposed to implement something like this:

initialized = false // has to be global
...
if !initialized {
    vorple.init()
    initialized = true
} 

@tenthirtyone
Copy link

Taking a look

@tenthirtyone
Copy link

tenthirtyone commented Mar 19, 2021

@MariusVanDerWijden I got the same result as you moving the init and could not replicate the reinit experienced by the user, either.

They can do the check in App.jsx L313:

       <Route path="/vorple2">
{address === vorpAddress ?
            <Vorple2
            address={address}
            VorpAddress={vorpAddress}
            userProvider={userProvider}
            mainnetProvider={mainnetProvider}
            localProvider={localProvider}
            tx={tx}
            writeContracts={writeContracts}
            />
:
null
}
          </Route>

And leave the Vorple2 component unchanged. That way React won't put the Vorple 2 component on the dom. They'll have to clean up the component code because only the userAddress ==[sic] vorpAddress branch will ever run. But this is the quickest way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants