-
Notifications
You must be signed in to change notification settings - Fork 31
Skeleton Single Page Application #18
Conversation
To recap: from the tBTC planning today, we summarised the desired qualities as something like:
With an obvious tradeoff between 1/2 and 3/4. 😆 let the games begin! 🔥 |
Some questions for @taggartbg :
Early reviews :) |
Quick answers (running to an appointment, will update further + review #7 afterwards) CSS scoping: Yeah, definitely the major downfall of a stylesheet vs inline, but I think component-level class names is usually enough to tackle the majority of naming collisions Hot reloading: Very good call. I haven't done hot reloading in 2019, but it looks like the tooling has gotten stronger ( Web Manifest: Create-react-app makes it and I guess its good to have for browsers that want to use it (usually mobile) Global contract context: Absolutely true, now that I'm thinking about it, it is probably useless, as we'll definitely want sagas controlling that flow. In theory we could connect the action literals to the contract context wrapper and pass them down that way, but I don't see that being stronger than using module imports + connecting where needed. Web3 Context: I threw an example in |
Let's undraft this PR and work on merging it today. All the items from @taggartbg Before we do anything else, you need to set up commit signing and rebase this branch to sign all the commits. |
Assigned @liamzebedee as feature buddy. |
Commits are signed, just attributed to an email that needs to be added to @taggartbg’s GitHub profile. |
- Add initial packages for building styles and running React
I used the saga + reducer workflow from PR #7 and adapted for it to here as @liamzebedee had already completed that work. This should be ready to be merged + built on. |
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.
<Web3Wrapper> | ||
<Route path="/" exact component={Home} /> | ||
<App> | ||
<Route path="/start" component={Start} /> |
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.
I like the names - pay, confirm, prove -- really simple to get
src/actions/index.js
Outdated
|
||
export function submitProof({ history }) { | ||
return { | ||
history, |
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.
Let's not pass around the history object in actions. I'm sure there's a redux helper pkg here somewhere? (since React Router is ubiquitous)
🙏
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.
Yeah, I definitely hear you.
A couple immediate thoughts:
- pass the history to a custom middleware that injects it into sagas when initializing (also pass to
<Router>
) - Create a singleton module and import both when creating routes and whenever a saga is called
I'll also google around, let me know if either of those sound better or worse to you!
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.
Middleware is an interesting idea! I think it's probably best to stick away from the Not Invented Here -style solutions, because routing+redux is such a common combo, it's bound to have been solved.
How does https://github.com/supasate/connected-react-router look to you?
class Web3Wrapper extends Component { | ||
state = {} | ||
|
||
componentDidMount() { |
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 pattern, TIL!
package.json
Outdated
"subPackages": [ | ||
"client", | ||
"lib/tbtc-helpers" | ||
], |
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.
trailing ,
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.
Unresolving because it wasn't removed and it's the reason why npm install
is failing on my machine:
➜ tbtc-dapp git:(skeleton) ✗ npm install
npm ERR! file /Users/piotr/go/src/github.com/keep-network/tbtc-dapp/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token } in JSON at position 1365 while parsing near '.../tbtc-helpers"
npm ERR! JSON.parse ],
npm ERR! JSON.parse }
npm ERR! JSON.parse '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/piotr/.npm/_logs/2019-08-02T08_46_19_368Z-debug.log
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.
@taggartbg did you resolve this perhaps?
(it's possible this was an accidental button mash from me, due to my stupid Mac keyboard)
RE: Ropsten - I meant to subscribe to network changes, oops! Will add now |
src/wrappers/web3.js
Outdated
} | ||
|
||
getAccountInfo = async () => { | ||
console.log("CHANGE!") |
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.
Was it intentionally committed?
Does not seem to be working: ^ I was already logged in to metamask when opening the page. If I log out, open the app and log in again I am running into the same problem. Also, does not seem to work when I switch the network: Not sure if this is related but the
|
package.json
Outdated
"subPackages": [ | ||
"client", | ||
"lib/tbtc-helpers" | ||
], |
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.
Unresolving because it wasn't removed and it's the reason why npm install
is failing on my machine:
➜ tbtc-dapp git:(skeleton) ✗ npm install
npm ERR! file /Users/piotr/go/src/github.com/keep-network/tbtc-dapp/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token } in JSON at position 1365 while parsing near '.../tbtc-helpers"
npm ERR! JSON.parse ],
npm ERR! JSON.parse }
npm ERR! JSON.parse '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/piotr/.npm/_logs/2019-08-02T08_46_19_368Z-debug.log
Probably a good idea to move this to a separate/future issue, as it won't be necessary for the demo, right? |
Created an issue for localStorage. |
@pdyraga seems to be working for me when loading when already logged in, tested on Ropsten/Kovan. Ran
However when Metamask is not logged in, and then I log in, it does not respond to the change. |
- Remove trailing comma - Add sleep to avoid race condition between CRA and less compiler
|
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.
Code seems fine, history works. But the page still doesn't refresh automatically after you unlock Metamask.
From what I can gather from MakerDAO's dapp, the only way you can detect the change is to poll the window.xyz
. Also found an answer here which should prove useful https://ethereum.stackexchange.com/questions/43572/how-to-auto-reload-dapp-when-metamask-is-unlocked-or-locked-by-user
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.
I do not want to block merging. If it works for you both we can go ahead and debug the problem later. Just need to make sure at least one other person checks it later.
If it is some more time-consuming work, we may want to do it in a separate PR fwiw. |
<Route path="/" exact component={Home} /> | ||
<App> | ||
<Route path="/start" component={Start} /> | ||
<Route path="/pay" exact component={Pay} /> |
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.
This feels like it could be “deposit”?
@liamzebedee If you have the We could make a new Issue, but it seems like two issue:
Seems worth fixing ASAP |
I think it probably makes sense to circle back to the Metamask issues next week. Basic reasoning: if we can't get Metamask working, we can mock out the calls to it and have a good demo. If, on the other hand, we fall short on the app flow/design, having Metamask working doesn't get us much from the demo's perspective. |
Yeah, I was thinking about contingency plan today and absolutely agree. We can also show the process from UI with mocks and then "hey, see how it works under the hood" and show (even a video) of how we do it with 4 consoles and clients using demo scripts we already have working. Worth discussing elsewhere but there is an alternative so we are safe. |
This is a very basic SPA skeleton to get started. It mimics the Random Beacon dApps (staker dashboard + emitter/requester) in packages and structure.
Includes:
TODO:
Add localstorage support?See Add localstorage support to Redux store #26Closes #5
Implementer: @taggartbg
Feature buddy: @liamzebedee