{"version":3,"sources":["assets/twitter-logo.svg","App.js","index.js"],"names":["SystemProgram","web3","arr","Keypair","Object","values","kp","_keypair","secretKey","secret","Uint8Array","baseAccount","fromSecretKey","programID","PublicKey","idl","metadata","address","network","clusterApiUrl","opts","TWITTER_HANDLE","TWITTER_LINK","App","useState","walletAddress","setWalletAddress","inputValue","setInputValue","gifList","setGifList","checkIfWalletIsConnected","a","window","solana","isPhantom","console","log","connect","onlyIfTrusted","response","publicKey","toString","alert","error","connectWallet","sendGif","length","provider","getProvider","program","Program","rpc","addGif","accounts","user","wallet","getGifList","onInputChange","event","value","target","connection","Connection","Provider","createGifAccount","startStuffOff","systemProgram","programId","signers","useEffect","onLoad","addEventListener","removeEventListener","account","fetch","className","onClick","onSubmit","preventDefault","type","placeholder","onChange","map","item","index","src","gifLink","alt","twitterLogo","href","rel","ReactDOM","render","StrictMode","document","getElementById"],"mappings":"8UAAe,MAA0B,yC,gDCSjCA,EAA2BC,IAA3BD,cAGFE,GAH6BD,IAAZE,QAGXC,OAAOC,OAAOC,EAAGC,SAASC,YAChCC,EAAS,IAAIC,WAAWR,GACxBS,EAAcV,IAAKE,QAAQS,cAAcH,GAGzCI,EAAY,IAAIC,YAAUC,EAAIC,SAASC,SAGvCC,EAAUC,wBAAc,UAGxBC,EACiB,YAgBjBC,EAAiB,YACjBC,EAAY,8BAA0BD,GAmM7BE,EAjMH,WACV,MAA0CC,mBAAS,MAAnD,mBAAOC,EAAP,KAAsBC,EAAtB,KACA,EAAoCF,mBAAS,IAA7C,mBAAOG,EAAP,KAAmBC,EAAnB,KACA,EAA8BJ,mBAAS,IAAvC,mBAAOK,EAAP,KAAgBC,EAAhB,KACMC,EAAwB,uCAAG,gCAAAC,EAAA,oEAEVC,SAAXC,EAFqB,EAErBA,QAFqB,qBAKvBA,EAAOC,UALgB,wBAMzBC,QAAQC,IAAI,yBANa,SAOFH,EAAOI,QAAQ,CAAEC,eAAe,IAP9B,OAOnBC,EAPmB,OAQzBJ,QAAQC,IAC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AgDvC,sBAAKT,UAAU,mBAAf,UACE,qBAAKY,IAAI,eAAeZ,UAAU,eAAeU,IAAKG,IACtD,mBACEb,UAAU,cACVc,KAAMpE,EACNuC,OAAO,SACP8B,IAAI,aAJN,6BAKetE,cChOzBuE,IAASC,OACP,cAAC,IAAMC,WAAP,UACE,cAAC,EAAD,MAEFC,SAASC,eAAe,U","file":"static/js/main.fdbc2cb0.chunk.js","sourcesContent":["export default __webpack_public_path__ + \"static/media/twitter-logo.d89d9a86.svg\";","import React, { useEffect, useState } from 'react';\nimport twitterLogo from './assets/twitter-logo.svg';\nimport './App.css';\nimport kp from './keypair.json'\nimport idl from \"./idl.json\";\nimport { Connection, PublicKey, clusterApiUrl } from '@solana/web3.js';\nimport { Program, Provider, web3 } from '@project-serum/anchor';\n\n\nconst { SystemProgram, Keypair } = web3;\n\n// Create a keypair for the account that will hold the GIF data.\nconst arr = Object.values(kp._keypair.secretKey)\nconst secret = new Uint8Array(arr)\nconst baseAccount = web3.Keypair.fromSecretKey(secret)\n\n// Get our program's id from the IDL file.\nconst programID = new PublicKey(idl.metadata.address);\n\n// Set our network to devnet.\nconst network = clusterApiUrl('devnet');\n\n// Controls how we want to acknowledge when a transaction is \"done\".\nconst opts = {\n preflightCommitment: \"processed\"\n}\n\n// Constants\nconst TEST_GIFS = [\n \"https://c.tenor.com/wMm7OOHf0KYAAAAd/hello-friends-chai-peelo.gif\",\n \"https://c.tenor.com/0YTbbLG-4uIAAAAC/gazab-bezzati-hai-yaar-panchayat.gif\",\n \"https://c.tenor.com/xZkG53lLlkMAAAAC/saale-ka-khopdi-tod-babu-bhaiya.gif\",\n \"https://c.tenor.com/ZAdD49K2-QkAAAAC/icc-cricket.gif\",\n \"https://c.tenor.com/gcB9oM_fwX4AAAAC/sabbir31x-waqt-badal-diye.gif\",\n \"https://c.tenor.com/H6sjheSkU1wAAAAC/noice-nice.gif\",\n \"https://c.tenor.com/VvSd6W6bm24AAAAM/nikal-lwde-get-out-of-here.gif\",\n \"https://c.tenor.com/lYx8DiK-dioAAAAM/waah-amir.gif\",\n \"https://c.tenor.com/8GdrrGPe4FcAAAAC/ok-approve.gif\",\n \"https://c.tenor.com/7HUogy7rXs4AAAAC/feel-me-think-about-it.gif\"\n]\nconst TWITTER_HANDLE = 'chidam333';\nconst TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`;\n\nconst App = () => {\n const [walletAddress, setWalletAddress] = useState(null);\n const [inputValue, setInputValue] = useState('');\n const [gifList, setGifList] = useState([]);\n const checkIfWalletIsConnected = async () => {\n try {\n const { solana } = window;\n\n if (solana) {\n if (solana.isPhantom) {\n console.log('Phantom wallet found!');\n const response = await solana.connect({ onlyIfTrusted: true });\n console.log(\n 'Connected with Public Key:',\n response.publicKey.toString()\n );\n setWalletAddress(response.publicKey.toString());\n }\n } else {\n alert('Solana object not found! Get a Phantom Wallet 👻');\n }\n } catch (error) {\n console.error(error);\n }\n };\n const connectWallet = async () => {\n const { solana } = window;\n \n if (solana) {\n const response = await solana.connect();\n console.log('Connected with Public Key:', response.publicKey.toString());\n setWalletAddress(response.publicKey.toString());\n }\n };\n const sendGif = async () => {\n if (inputValue.length === 0) {\n console.log(\"No gif link given!\")\n return\n }\n setInputValue('');\n console.log('Gif link:', inputValue);\n try {\n const provider = getProvider();\n const program = new Program(idl, programID, provider);\n \n await program.rpc.addGif(inputValue, {\n accounts: {\n baseAccount: baseAccount.publicKey,\n user: provider.wallet.publicKey,\n },\n });\n console.log(\"GIF successfully sent to program\", inputValue)\n \n await getGifList();\n } catch (error) {\n console.log(\"Error sending GIF:\", error)\n }\n };\n const onInputChange = (event) => {\n const { value } = event.target;\n setInputValue(value);\n };\n const getProvider = () => {\n const connection = new Connection(network, opts.preflightCommitment);\n const provider = new Provider(\n connection, window.solana, opts.preflightCommitment,\n );\n return provider;\n }\n const createGifAccount = async () => {\n try {\n const provider = getProvider();\n const program = new Program(idl, programID, provider);\n console.log(\"ping\")\n await program.rpc.startStuffOff({\n accounts: {\n baseAccount: baseAccount.publicKey,\n user: provider.wallet.publicKey,\n systemProgram: SystemProgram.programId,\n },\n signers: [baseAccount]\n });\n console.log(\"Created a new BaseAccount w/ address:\", baseAccount.publicKey.toString())\n await getGifList();\n \n } catch(error) {\n console.log(\"Error creating BaseAccount account:\", error)\n }\n }\n const renderNotConnectedContainer = () => (\n \n Connect to Wallet\n \n );\n const renderConnectedContainer = () => {\n // If we hit this, it means the program account hasn't been initialized.\n if (gifList === null) {\n return (\n
\n \n
\n )\n } \n // Otherwise, we're good! Account exists. User can submit GIFs.\n else {\n return(\n
\n {\n event.preventDefault();\n sendGif();\n }}\n >\n \n \n \n
\n {/* We use index as the key instead, also, the src is now item.gifLink */}\n {gifList.map((item, index) => (\n
\n \n
\n ))}\n
\n
\n )\n }\n }\n useEffect(() => {\n const onLoad = async () => {\n await checkIfWalletIsConnected();\n };\n window.addEventListener('load', onLoad);\n return () => window.removeEventListener('load', onLoad);\n }, []);\n const getGifList = async() => {\n try {\n const provider = getProvider();\n const program = new Program(idl, programID, provider);\n const account = await program.account.baseAccount.fetch(baseAccount.publicKey);\n \n console.log(\"Got the account\", account)\n setGifList(account.gifList)\n \n } catch (error) {\n console.log(\"Error in getGifList: \", error)\n setGifList(null);\n }\n }\n \nuseEffect(() => {\n if (walletAddress) {\n console.log('Fetching GIF list...');\n getGifList()\n }\n}, [walletAddress]);\n return (\n
\n\t\t\t
\n
\n

🇮🇳 GIFS

\n

\n Bharat ke apne gifs\n

\n {!walletAddress && renderNotConnectedContainer()}\n {walletAddress && renderConnectedContainer()}\n
\n
\n \"Twitter\n {`built by @${TWITTER_HANDLE}`}\n
\n
\n
\n );\n};\n\nexport default App;\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n"],"sourceRoot":""}