Last active
September 5, 2019 01:26
-
-
Save ryanpedersen42/5d97f7ec4a40bf9e0e478efbb171c919 to your computer and use it in GitHub Desktop.
simple auth flow
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 () => { | |
| //web3 actions to authenticate with metamask or other provider | |
| const ethAddresses = await window.ethereum.enable(); | |
| const ethAddress = ethAddresses[0]; | |
| //Authenticate into 3Box | |
| const box = await Box.openBox(ethAddress, window.ethereum, {}); | |
| //Promise resolution- waiting for 3Box onSyncDone confirmation | |
| await new Promise((resolve, reject) => box.onSyncDone(resolve)); | |
| //Authenticate into your space | |
| const dappSpace = await box.openSpace(<'your-space-name'>); | |
| //Set all to state and continue | |
| await this.setState({ box, dappSpace, ethAddress }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment