-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
141 additions
and
192 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn pre-commit |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 120, | ||
"trailingComma": "all", | ||
"singleQuote": false, | ||
"semi": false | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,58 @@ | ||
import { BigInt, Bytes, crypto, ipfs } from "@graphprotocol/graph-ts"; | ||
import { Poster, NewPost } from "../generated/Poster/Poster"; | ||
import { Post } from "../generated/schema"; | ||
import { json, JSONValueKind } from "@graphprotocol/graph-ts"; | ||
import { jsonToString, jsonToArrayString } from "./utils"; | ||
import { BigInt, Bytes, crypto, ipfs } from "@graphprotocol/graph-ts" | ||
import { Poster, NewPost } from "../generated/Poster/Poster" | ||
import { Post } from "../generated/schema" | ||
import { json, JSONValueKind } from "@graphprotocol/graph-ts" | ||
import { jsonToString, jsonToArrayString } from "./utils" | ||
|
||
export function handleNewPost(event: NewPost): void { | ||
// decode json content, fail gracefully. | ||
let contentData = json.try_fromString(event.params.content); | ||
let contentData = json.try_fromString(event.params.content) | ||
if (contentData.isError) { | ||
return; | ||
return | ||
} | ||
let content = contentData.value.toObject(); | ||
let content = contentData.value.toObject() | ||
|
||
// Load post entity | ||
let post = Post.load( | ||
event.transaction.hash.toHex() + "-" + event.logIndex.toString() | ||
); | ||
let post = Post.load(event.transaction.hash.toHex() + "-" + event.logIndex.toString()) | ||
// create new entity if it doesn't already exist | ||
if (!post) { | ||
post = new Post( | ||
event.transaction.hash.toHex() + "-" + event.logIndex.toString() | ||
); | ||
post = new Post(event.transaction.hash.toHex() + "-" + event.logIndex.toString()) | ||
} | ||
// Set user | ||
post.publisher = event.params.user; | ||
post.publisher = event.params.user | ||
|
||
// Fetch article article from IPFS, fail gracefully. | ||
let article = ipfs.cat(jsonToString(content.get("article"))); | ||
let article = ipfs.cat(jsonToString(content.get("article"))) | ||
if (!article) { | ||
post.article = jsonToString(content.get("article")); | ||
post.article = jsonToString(content.get("article")) | ||
} else { | ||
post.article = article.toString(); | ||
post.article = article.toString() | ||
} | ||
|
||
// Set article | ||
// post.article = jsonToString(content.get("article")); | ||
|
||
// Set authors | ||
post.authors = jsonToArrayString(content.get("authors")); | ||
post.authors = jsonToArrayString(content.get("authors")) | ||
|
||
// Set postedOn timestamp | ||
post.postedOn = event.block.timestamp; | ||
post.postedOn = event.block.timestamp | ||
|
||
// Set lastUpdated timestamp | ||
post.lastUpdated = event.block.timestamp; | ||
post.lastUpdated = event.block.timestamp | ||
|
||
// Set tags | ||
post.tags = jsonToArrayString(content.get("tags")); | ||
post.tags = jsonToArrayString(content.get("tags")) | ||
|
||
// Set title | ||
post.title = jsonToString(content.get("title")); | ||
post.title = jsonToString(content.get("title")) | ||
|
||
// Set description | ||
post.description = jsonToString(content.get("description")); | ||
post.description = jsonToString(content.get("description")) | ||
|
||
// Set image | ||
post.image = jsonToString(content.get("image")); | ||
post.image = jsonToString(content.get("image")) | ||
|
||
// Safe updates to store | ||
post.save(); | ||
post.save() | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,6 +244,13 @@ | |
dependencies: | ||
assemblyscript "0.19.10" | ||
|
||
"@graphprotocol/graph-ts@^0.24.1": | ||
version "0.24.1" | ||
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.24.1.tgz#50961b52b5383f9c5cf5e6e23fa039f24e729ddf" | ||
integrity sha512-2vU4m5ZPQIqMlMce/z5vmOtGHRlRmcRhMfemS3NIwxCSxSBGVnX2zb7QBTzzdQKGwsAZdbz6V0okkOtvohELfQ== | ||
dependencies: | ||
assemblyscript "0.19.10" | ||
|
||
"@types/bn.js@^5.1.0": | ||
version "5.1.0" | ||
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.0.tgz#32c5d271503a12653c62cf4d2b45e6eab8cebc68" | ||
|
@@ -460,6 +467,15 @@ [email protected]: | |
binaryen "101.0.0-nightly.20210723" | ||
long "^4.0.0" | ||
|
||
assemblyscript@^0.19.20: | ||
version "0.19.23" | ||
resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.19.23.tgz#16ece69f7f302161e2e736a0f6a474e6db72134c" | ||
integrity sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA== | ||
dependencies: | ||
binaryen "102.0.0-nightly.20211028" | ||
long "^5.2.0" | ||
source-map-support "^0.5.20" | ||
|
||
[email protected], assert-plus@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" | ||
|
@@ -547,6 +563,11 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz#b6bb7f3501341727681a03866c0856500eec3740" | ||
integrity sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA== | ||
|
||
[email protected]: | ||
version "102.0.0-nightly.20211028" | ||
resolved "https://registry.yarnpkg.com/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz#8f1efb0920afd34509e342e37f84313ec936afb2" | ||
integrity sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w== | ||
|
||
bindings@^1.5.0: | ||
version "1.5.0" | ||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" | ||
|
@@ -1390,9 +1411,9 @@ glob@^7.1.3: | |
once "^1.3.0" | ||
path-is-absolute "^1.0.0" | ||
|
||
"gluegun@git+https://github.com/edgeandnode/gluegun.git#v4.3.1-pin-colors-dep": | ||
"gluegun@https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep": | ||
version "4.3.1" | ||
resolved "git+https://github.com/edgeandnode/gluegun.git#b34b9003d7bf556836da41b57ef36eb21570620a" | ||
resolved "https://github.com/edgeandnode/gluegun#b34b9003d7bf556836da41b57ef36eb21570620a" | ||
dependencies: | ||
apisauce "^1.0.1" | ||
app-module-path "^2.2.0" | ||
|
@@ -2108,6 +2129,11 @@ long@^4.0.0: | |
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" | ||
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== | ||
|
||
long@^5.2.0: | ||
version "5.2.0" | ||
resolved "https://registry.yarnpkg.com/long/-/long-5.2.0.tgz#2696dadf4b4da2ce3f6f6b89186085d94d52fd61" | ||
integrity sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w== | ||
|
||
looper@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/looper/-/looper-3.0.0.tgz#2efa54c3b1cbaba9b94aee2e5914b0be57fbb749" | ||
|
@@ -2141,6 +2167,15 @@ mafmt@^7.0.0: | |
dependencies: | ||
multiaddr "^7.3.0" | ||
|
||
matchstick-as@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/matchstick-as/-/matchstick-as-0.4.0.tgz#7456c2f20abee6d12366b65f4216385a9ef62a50" | ||
integrity sha512-XkWoXQWUg1ms8DaDMkl2M95woGPB89f7aysjwDNst/x+G9FV48dxcAKSwilJ1BVGV3MqU7HfuKGHxegSsuxQxQ== | ||
dependencies: | ||
"@graphprotocol/graph-ts" "^0.24.1" | ||
assemblyscript "^0.19.20" | ||
wabt "1.0.24" | ||
|
||
md5.js@^1.3.4: | ||
version "1.3.5" | ||
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" | ||
|
@@ -2602,6 +2637,11 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" | ||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== | ||
|
||
prettier@^2.5.1: | ||
version "2.5.1" | ||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a" | ||
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg== | ||
|
||
process-nextick-args@~2.0.0: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" | ||
|
@@ -2948,6 +2988,19 @@ signed-varint@^2.0.1: | |
dependencies: | ||
varint "~5.0.0" | ||
|
||
source-map-support@^0.5.20: | ||
version "0.5.21" | ||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" | ||
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== | ||
dependencies: | ||
buffer-from "^1.0.0" | ||
source-map "^0.6.0" | ||
|
||
source-map@^0.6.0: | ||
version "0.6.1" | ||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" | ||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== | ||
|
||
split-ca@^1.0.0: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/split-ca/-/split-ca-1.0.1.tgz#6c83aff3692fa61256e0cd197e05e9de157691a6" | ||
|
@@ -3272,6 +3325,11 @@ [email protected]: | |
core-util-is "1.0.2" | ||
extsprintf "^1.2.0" | ||
|
||
[email protected]: | ||
version "1.0.24" | ||
resolved "https://registry.yarnpkg.com/wabt/-/wabt-1.0.24.tgz#c02e0b5b4503b94feaf4a30a426ef01c1bea7c6c" | ||
integrity sha512-8l7sIOd3i5GWfTWciPL0+ff/FK/deVK2Q6FN+MPz4vfUcD78i2M/49XJTwF6aml91uIiuXJEsLKWMB2cw/mtKg== | ||
|
||
wcwidth@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,6 +244,11 @@ history@^5.2.0: | |
dependencies: | ||
"@babel/runtime" "^7.7.6" | ||
|
||
[email protected]: | ||
version "5.1.3" | ||
resolved "https://registry.yarnpkg.com/husky/-/husky-5.1.3.tgz#1a0645a4fe3ffc006c4d0d8bd0bcb4c98787cc9d" | ||
integrity sha512-fbNJ+Gz5wx2LIBtMweJNY1D7Uc8p1XERi5KNRMccwfQA+rXlxWNSdUxswo0gT8XqxywTIw7Ywm/F4v/O35RdMg== | ||
|
||
inflight@^1.0.4: | ||
version "1.0.6" | ||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" | ||
|