Skip to content

Instantly share code, notes, and snippets.

@ryanpedersen42
Created September 9, 2019 01:19
Show Gist options
  • Select an option

  • Save ryanpedersen42/b770122ea138cdce205a351d8b78a661 to your computer and use it in GitHub Desktop.

Select an option

Save ryanpedersen42/b770122ea138cdce205a351d8b78a661 to your computer and use it in GitHub Desktop.
handleAuth function
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