{"version":3,"sources":["components/App.js","serviceWorker.js","index.js","pages/Home.js","components/Navbar.js","components/Main.js","photo.png"],"names":["App","Home","Boolean","window","location","hostname","match","ReactDOM","render","document","getElementById","navigator","serviceWorker","ready","then","registration","unregister","ipfs","require","ipfsClient","host","port","protocol","Component","componentWillMount","loadWeb3","loadBlockchainData","ethereum","web3","Web3","enable","currentProvider","alert","eth","getAccounts","accounts","setState","account","net","getId","networkId","networkData","Decentragram","networks","decentragram","Contract","abi","address","methods","imageCount","call","imagesCount","i","images","image","state","sort","a","b","tipAmount","loading","tipImageOwner","id","this","send","from","value","on","hash","constructor","props","super","captureFile","event","preventDefault","file","target","files","reader","FileReader","readAsArrayBuffer","onloadend","buffer","Buffer","result","console","log","uploadImage","description","add","error","bind","className","Navbar","style","backgroundColor","rel","src","width","height","alt","color","position","top","left","fontFamily","fontSize","Identicon","toString","Main","role","maxWidth","onSubmit","imageDescription","type","accept","onChange","ref","input","placeholder","required","class","marginTop","marginLeft","marginRight","map","key","author","utils","fromWei","name","onClick","toWei","module","exports"],"mappings":"oNAUeA,MARf,WACE,OACE,6BACE,kBAACC,EAAA,EAAD,QCOcC,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCZNC,IAASC,OAAO,kBAAC,EAAD,MAASC,SAASC,eAAe,SD2H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAMC,KAAKC,IACjCA,EAAaC,gB,6zvHEzHbC,EADaC,EAAQ,IACdC,CAAW,CAAEC,KAAM,iBAAkBC,KAAM,KAAMC,SAAU,UAExE,MAAMrB,UAAasB,YAEXC,qBAAsB,IAAD,kIACnB,EAAKC,WADc,uBAEnB,EAAKC,qBAFc,6CAKrBD,WAAY,OAAD,wGACXtB,OAAOwB,SADI,uBAEbxB,OAAOyB,KAAO,IAAIC,IAAK1B,OAAOwB,UAFjB,SAGPxB,OAAOwB,SAASG,SAHT,6BAKN3B,OAAOy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MAAM,KACNC,OAAO,KACPF,IAAG,gCAA2B,IAAIU,IAAUrD,EAAMyE,OAAQ,IAAInB,cAEhE,2BAAOhB,UAAU,cAActC,EAAMyE,SAEvC,wBAAIjE,GAAG,YAAY8B,UAAU,+BAC3B,wBAAIA,UAAU,mBACZ,uBAAG6B,MAAM,eAAc,yBAAKxB,IAAG,sCAAiC3C,EAAMc,MAAQ0B,MAAO,CAAEiB,SAAU,YACjG,uBAAGjB,MAAO,CAACO,MAAM,UAAW/C,EAAMkC,cAEpC,wBAAIsC,IAAKA,EAAKlC,UAAU,wBACtB,2BAAOA,UAAU,8BAAjB,SACSzF,OAAOyB,KAAKoG,MAAMC,QAAQ3E,EAAMK,UAAUiD,WAAY,SAD/D,QAGA,4BACEhB,UAAU,uCACVsC,KAAM5E,EAAMQ,GACZqE,QAAU1D,IACR,IAAId,EAAYxD,OAAOyB,KAAKoG,MAAMI,MAAM,QAAS,SACjD/C,QAAQC,IAAIb,EAAMG,OAAOsD,KAAMvE,GAC/BI,KAAKO,MAAMT,cAAcY,EAAMG,OAAOsD,KAAMvE,KANhD,oBAuBTkD,O,2DCpFfwB,EAAOC,QAAU,IAA0B,mC","file":"static/js/main.1923fb21.chunk.js","sourcesContent":["import React from 'react'\nimport Home from '../pages/Home';\nfunction App() {\n return (\n
\n \n
\n )\n}\n\nexport default App","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport 'bootstrap/dist/css/bootstrap.css'\nimport App from './components/App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n","import Decentragram from '../abis/Decentragram.json'\nimport React, { Component } from 'react';\nimport Identicon from 'identicon.js';\nimport Navbar from '../components/Navbar'\nimport Main from '../components/Main'\nimport Web3 from 'web3';\n// import '../../src/App.css';\n\n//Declare IPFS\nconst ipfsClient = require('ipfs-http-client')\nconst ipfs = ipfsClient({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' }) // leaving out the arguments will default to these values\n\nclass Home extends Component {\n\n async componentWillMount() {\n await this.loadWeb3()\n await this.loadBlockchainData()\n }\n\n async loadWeb3() {\n if (window.ethereum) {\n window.web3 = new Web3(window.ethereum)\n await window.ethereum.enable()\n }\n else if (window.web3) {\n window.web3 = new Web3(window.web3.currentProvider)\n }\n else {\n window.alert('Non-Ethereum browser detected. You should consider trying MetaMask!')\n }\n }\n\n async loadBlockchainData() {\n const web3 = window.web3\n // Load account\n const accounts = await web3.eth.getAccounts()\n this.setState({ account: accounts[0] })\n // Network ID\n const networkId = await web3.eth.net.getId()\n const networkData = Decentragram.networks[networkId]\n if(networkData) {\n const decentragram = new web3.eth.Contract(Decentragram.abi, networkData.address)\n this.setState({ decentragram })\n const imagesCount = await decentragram.methods.imageCount().call()\n this.setState({ imagesCount })\n // Load images\n for (var i = 1; i <= imagesCount; i++) {\n const image = await decentragram.methods.images(i).call()\n this.setState({\n images: [...this.state.images, image]\n })\n }\n // Sort images. Show highest tipped images first\n this.setState({\n images: this.state.images.sort((a,b) => b.tipAmount - a.tipAmount )\n })\n this.setState({ loading: false})\n } else {\n window.alert('Decentragram contract not deployed to detected network.')\n }\n }\n\n captureFile = event => {\n\n event.preventDefault()\n const file = event.target.files[0]\n const reader = new window.FileReader()\n reader.readAsArrayBuffer(file)\n\n reader.onloadend = () => {\n this.setState({ buffer: Buffer(reader.result) })\n console.log('buffer', this.state.buffer)\n }\n }\n\n uploadImage = description => {\n console.log(\"Submitting file to ipfs...\")\n\n //adding file to the IPFS\n ipfs.add(this.state.buffer, (error, result) => {\n console.log('Ipfs result', result)\n if(error) {\n console.error(error)\n return\n }\n\n this.setState({ loading: true })\n this.state.decentragram.methods.uploadImage(result[0].hash, description).send({ from: this.state.account }).on('transactionHash', (hash) => {\n this.setState({ loading: false })\n })\n })\n }\n\n tipImageOwner(id, tipAmount) {\n this.setState({ loading: true })\n this.state.decentragram.methods.tipImageOwner(id).send({ from: this.state.account, value: tipAmount }).on('transactionHash', (hash) => {\n this.setState({ loading: false })\n })\n }\n\n constructor(props) {\n super(props)\n this.state = {\n account: '',\n decentragram: null,\n images: [],\n loading: true\n }\n\n this.uploadImage = this.uploadImage.bind(this)\n this.tipImageOwner = this.tipImageOwner.bind(this)\n this.captureFile = this.captureFile.bind(this)\n }\n\n render() {\n return (\n
\n \n { this.state.loading\n ?

Loading...

\n : \n }\n
\n );\n }\n}\n\nexport default Home;","import React, { Component } from 'react';\nimport Identicon from 'identicon.js';\nimport photo from '../photo.png'\nimport './main.css';\nclass Navbar extends Component {\n\n render() {\n return (\n \n );\n }\n}\n\nexport default Navbar;","import React, { Component } from 'react';\nimport Identicon from 'identicon.js';\nimport './main.css';\nclass Main extends Component {\n\n render() {\n return (\n <>\n
\n
\n
\n
\n

 

\n

Share Image

\n
{\n event.preventDefault()\n const description = this.imageDescription.value\n this.props.uploadImage(description)\n }} >\n \n
\n

\n { this.imageDescription = input }}\n className=\"form-control\"\n placeholder=\"Image description...\"\n required />\n
\n \n
\n

 

\n
\n
\n
\n
\n\n
\n { this.props.images.map((image, key) => {\n return(\n
\n
\n
\n \n {image.author}\n
\n
    \n
  • \n

    \n

    {image.description}

    \n
  • \n
  • \n \n TIPS: {window.web3.utils.fromWei(image.tipAmount.toString(), 'Ether')} ETH\n \n {\n let tipAmount = window.web3.utils.toWei('0.001', 'Ether')\n console.log(event.target.name, tipAmount)\n this.props.tipImageOwner(event.target.name, tipAmount)\n }}\n >\n TIP ETHS\n \n
  • \n
\n
\n
\n )\n })}\n
\n \n );\n }\n}\n\nexport default Main;","module.exports = __webpack_public_path__ + \"static/media/photo.d6cbd8e6.png\";"],"sourceRoot":""}