Skip to content

Commit b88a0d7

Browse files
committed
updates README and comments
1 parent f6ab4cd commit b88a0d7

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,13 @@ The app uses `IPFS` as a decentralized file storage and `webpack` to facilitate
88

99
And, of course, this cannot be a Dapp without using `web3`, find out more <a href="https://web3js.readthedocs.io/en/v1.2.0/index.html"> here </a>.
1010

11-
Run this app by installing aforementioned dependencies and `npm run dev`
11+
Run this app by installing aforementioned dependencies
12+
```
13+
npm i
14+
```
15+
16+
Then:
17+
18+
```
19+
npm run dev
20+
```

src/App.svelte

+7
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
pages[key] = true;
2828
};
2929
30+
// the conversion function used to intepret the response from the contract
3031
const hashToBytes32 = (hash) => {
3132
return "0x" + bs58.decode(hash).slice(2).toString('hex');
3233
}
3334
35+
// Upload an image hash from IPFS to the SC
3436
const uploadToSC = async (e) => {
3537
const ipfsHash = e.detail.path;
3638
//convert ipfsHash to bytes32 to fit the SC
@@ -39,18 +41,21 @@
3941
getPostsFromSC(e);
4042
}
4143
44+
// This is call to add claps (likes) to a post on SC
4245
const clap = (e) => {
4346
e.preventDefault()
4447
const imageHash = hashToBytes32(e.detail);
4548
etherGram.methods.clap(imageHash).send({from: callerAddress})
4649
}
4750
51+
// This is call to add comments to a post on SC
4852
const comment = (e) => {
4953
const commentHash = web3.utils.asciiToHex(e.detail.elements[0].value);
5054
const imageHash = hashToBytes32(e.detail.name);
5155
etherGram.methods.comment(imageHash, commentHash).send({from: callerAddress});
5256
}
5357
58+
// This is call to get all posts uploaded on SC
5459
const getPostsFromSC = async (e) => {
5560
e.preventDefault()
5661
setPage("uploading");
@@ -75,10 +80,12 @@
7580
setPage("viewImage");
7681
}
7782
83+
// Get the number of claps (likes) from the SC
7884
const getClapCountFromSC = async (imageHash) => {
7985
return etherGram.methods.getClapCount(imageHash).call({from: callerAddress})
8086
}
8187
88+
// Get all comments from the SC
8289
const getComment = async (imageHash) => {
8390
const result = await etherGram.methods.getComments(imageHash).call({from: callerAddress})
8491
var processedComments=[];

0 commit comments

Comments
 (0)