Created
September 9, 2019 01:19
-
-
Save ryanpedersen42/b770122ea138cdce205a351d8b78a661 to your computer and use it in GitHub Desktop.
handleAuth function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| handleAuth = async () => { | |
| const { history } = this.props | |
| // web3 actions to authenticate with metamask or other provider | |
| const ethAddresses = await window.ethereum.enable(); | |
| const ethAddress = ethAddresses[0]; | |
| // authenticate and get profile data | |
| const box = await Box.openBox(ethAddress, window.ethereum, {}); | |
| // promise resolution.. waiting from 3Box onSyncDone confirmation | |
| await new Promise((resolve, reject) => box.onSyncDone(resolve)); | |
| //open s3cretkeep3r space | |
| const dappSpace = await box.openSpace('s3cretkeep3r'); | |
| // set all to state and continue | |
| await this.setState({ box, ethAddress, dappSpace }); | |
| history.push('/main'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment