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
| require('babel-register'); | |
| require('babel-polyfill'); | |
| const HDWalletProvider = require("@truffle/hdwallet-provider"); | |
| const mnemonic='<your mnemonic>'; | |
| module.exports = { | |
| networks: { | |
| ropsten: { | |
| provider: 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
| //imports to add images to IPFS | |
| const ipfsClient = require('ipfs-http-client') | |
| const ipfs = ipfsClient({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' }) |
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 = (event) => { | |
| const { toggleAddImage, startLoading, endLoading } = this.props; | |
| event.preventDefault() | |
| startLoading() | |
| //add to IPFS | |
| ipfs.add(this.state.buffer, (error, result) => { | |
| const petHash = result[0].hash | |
| this.setState({ petHash }) | |
| if(error) { |
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
| fetchPosts = async () => { | |
| //fetch users posts | |
| const { user, setUserPosts } = this.props; | |
| const dappSpace = user.dappSpace; | |
| try { | |
| const dappSpaceData = await dappSpace.public.all() | |
| let ipfsKeyArray = [] | |
| Object.keys(dappSpaceData).forEach((values) => { | |
| if (values.length === 46) { | |
| ipfsKeyArray.push(values) |
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
| handleLogout = async () => { | |
| const { history, user } = this.props; | |
| const box = user.box; | |
| await box.logout(); | |
| history.push('/'); | |
| } |
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
| auth3Box = async () => { | |
| const { user, logUserIn, history, setUserProfile, setBox, setDappSpace } = this.props; | |
| const box = await Box.openBox(user.ethAddress, window.ethereum, {}); | |
| await new Promise((resolve, reject) => box.onSyncDone(resolve)); | |
| const dappSpace = await box.openSpace('catRoulette'); | |
| const userProfile = await Box.getProfile(user.ethAddress) | |
| await setBox(box) |
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
| loadWeb3 = async () => { | |
| const { setEthAddress } = this.props; | |
| if (window.ethereum) { | |
| window.web3 = new Web3(window.ethereum) | |
| const ethAddresses = await window.ethereum.enable() | |
| const ethAddress = ethAddresses[0] | |
| await setEthAddress(ethAddress) | |
| } | |
| else if (window.web3) { |
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
| function doRequest(options) { | |
| return new Promise((resolve, reject) => { | |
| request(options, function(error, body) { | |
| if (error) { | |
| reject(error); | |
| return; | |
| } | |
| resolve(JSON.parse(body.body)); | |
| }); | |
| }); |
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
| const decryptEntry = async encObj => JSON.parse(await threeId.decrypt(encObj, spaceName)) | |
| return { | |
| //some code | |
| if (!entry) { | |
| return null //returns null with no entry | |
| } |
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
| const userProfile = await Box.getProfile(ethAddress); | |
| await console.log(userProfile) |