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
| onSubmit = async () => { | |
| const { inputKey, inputValue, dappSpace } = this.state; | |
| // set private key / value pair from input form | |
| try { | |
| await dappSpace.private.set(inputKey, inputValue); | |
| } catch(err) { | |
| console.log(err); | |
| } |
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
| getSecret = async () => { | |
| const { displayValueKey, dappSpace } = this.state; | |
| //returns string || object.. undefined if no such key | |
| const displayValue = await dappSpace.private.get(displayValueKey) | |
| if (displayValue) { | |
| await this.setState({ displayValue, displayValueKey: '' }); | |
| } | |
| } |
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, {}); | |
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
| This post links my 3Box profile to my Github account! Web3 social profiles by 3Box. | |
| ✅ did:muport:QmbqWA5ArkWjCApMaYtusVaMT7gbRfh6ToJMfAVEtK3RGm ✅ | |
| Create your profile today to start building social connection and trust online at https://3Box.io/ |
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)); |
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
| //log user out | |
| handleLogout = async () => { | |
| const { box } = this.state; | |
| await box.logout(); | |
| } |
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
| // delete selected secret | |
| deleteSecret = async () => { | |
| const { inputKey, dappStorage } = this.state; | |
| await dappStorage.private.remove(inputKey); | |
| } |
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
| getSecret = async () => { | |
| const { inputKey, dappStorage } = this.state; | |
| const displayValue = await dappStorage.private.get(inputKey) | |
| await this.setState({ displayValue }) | |
| } |
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
| // submit new key / value pair from input-form | |
| onSubmit = async () => { | |
| const { inputKey, inputValue, dappStorage } = this.state; | |
| // set private key / value pair from input form | |
| try { | |
| await dappStorage.private.set(inputKey, inputValue); | |
| } catch(err) { | |
| console.log(err); | |
| } |
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
| // create new space | |
| createNewSpace = async () => { | |
| const { inputKey, box } = this.state; | |
| await box.openSpace(inputKey); | |
| } |