Compare commits
No commits in common. "3eee2576694d005478d50e8fafbb52ffda16f781" and "819b7180ed9bd126a6485ef544e34051e409219b" have entirely different histories.
3eee257669
...
819b7180ed
|
@ -35,6 +35,7 @@ const getContract = (name) => new ethers.Contract(
|
|||
|
||||
const fetchPaperInfo = async (paperId, retryDelay = 5000) => {
|
||||
const url = `https://api.semanticscholar.org/graph/v1/paper/${paperId}?fields=title,url,authors,references`;
|
||||
console.log('url:', url);
|
||||
let retry = false;
|
||||
let paper;
|
||||
const response = await axios.get(url, {
|
||||
|
@ -119,6 +120,9 @@ HREF ${paper.url}`;
|
|||
contentToSign += `\n\n${JSON.stringify(embeddedData, null, 2)}`;
|
||||
}
|
||||
const signature = firstAuthorWallet.signMessageSync(contentToSign);
|
||||
console.log({
|
||||
authors, content, signature, embeddedData,
|
||||
});
|
||||
const verified = verifySignature({
|
||||
authors, content, signature, embeddedData,
|
||||
});
|
||||
|
@ -145,10 +149,6 @@ module.exports = async (req, res) => {
|
|||
|
||||
// Read the paper info from SS
|
||||
const paper = await fetchPaperInfo(paperId);
|
||||
|
||||
// Send HTTP code 202 - Accepted
|
||||
res.status(202).end();
|
||||
|
||||
console.log('references count:', paper.references.length);
|
||||
|
||||
const eachCitationWeightPercent = Math.floor(30 / paper.references.length);
|
||||
|
@ -176,21 +176,19 @@ module.exports = async (req, res) => {
|
|||
hash, authors, content, signature, embeddedData,
|
||||
} = await generatePost(paper);
|
||||
|
||||
console.log({
|
||||
hash, authors, content, signature, embeddedData, citations,
|
||||
});
|
||||
|
||||
// Write the new post to our database
|
||||
await forum.put(hash, {
|
||||
authors, content, signature, embeddedData, citations,
|
||||
});
|
||||
|
||||
// Add the post to the form (on-chain)
|
||||
try {
|
||||
await dao.addPost(authors, hash, citations);
|
||||
} catch (e) {
|
||||
if (e.reason === 'A post with this contentId already exists') {
|
||||
console.log(`Post already added for paper ${paperId}`);
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
await dao.addPost(authors, hash, citations);
|
||||
|
||||
console.log(`Added post to blockchain for paper ${paperId}`);
|
||||
|
||||
res.end();
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ const verifySignature = ({
|
|||
}
|
||||
try {
|
||||
const account = recoverPersonalSignature({ data: contentToVerify, signature });
|
||||
console.log(`recovered account: ${account}`);
|
||||
const authorAddresses = authors.map((author) => author.authorAddress.toLowerCase());
|
||||
if (!authorAddresses.includes(account.toLowerCase())) {
|
||||
console.log('error: signer is not among the authors');
|
||||
|
|
|
@ -417,7 +417,6 @@ function App() {
|
|||
<th>ID</th>
|
||||
<th>Authors</th>
|
||||
<th>Sender</th>
|
||||
<th>Reputation</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -438,7 +437,6 @@ function App() {
|
|||
</Stack>
|
||||
</td>
|
||||
<td>{getAddressName(chainId, post.sender)}</td>
|
||||
<td>{post.reputation.toString()}</td>
|
||||
<td>
|
||||
<Button onClick={() => handleShowViewPost(post)}>
|
||||
View Post
|
||||
|
|
Loading…
Reference in New Issue