Skip to content

Commit 47453d0

Browse files
committed
Submodules added for async contract
1 parent a66a396 commit 47453d0

File tree

8 files changed

+206
-1
lines changed

8 files changed

+206
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
node_modules
22
build
33
generated
4+
contracts
5+
data
6+
ganache-data

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "async-contracts"]
2+
path = async-contracts
3+
url = https://github.com/asyncart/async-contracts

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.PHONY: clear-data
2+
clear-data:
3+
sudo rm -rf data ganache-data
4+
5+
.PHONY: graph-test
6+
graph-test:
7+
./start-graph.sh
8+
9+
.PHONY: stop
10+
stop:
11+
docker-compose down -v
12+
13+
.PHONY: restart-graph-test
14+
restart-graph-test:
15+
make stop
16+
make graph-test

async-contracts

Submodule async-contracts added at 43df594

docker-compose.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: "3"
2+
services:
3+
ganache:
4+
image: trufflesuite/ganache-cli
5+
container_name: ganache
6+
volumes:
7+
- ./ganache-data:/ganache-data
8+
ports:
9+
- "8545:8545"
10+
entrypoint:
11+
- "node"
12+
- "/app/ganache-core.docker.cli.js"
13+
- "-s"
14+
- "async-art"
15+
# - "-m"
16+
# - "path local suggest utility axis mandate ten digital quality fee pull van"
17+
- "--db"
18+
- "/ganache-data"
19+
- "--networkId"
20+
- "321"
21+
- "--time"
22+
- "2020-07-25T08:24:37+00:00"
23+
- "--gasLimit"
24+
- "10000000"
25+
26+
graph-node:
27+
image: graphprotocol/graph-node:18b6183
28+
# image: graphprotocol/graph-node:dc82611
29+
ports:
30+
- "8000:8000"
31+
- "8001:8001"
32+
- "8020:8020"
33+
- "8030:8030"
34+
- "8040:8040"
35+
depends_on:
36+
- ipfs
37+
- postgres
38+
- ganache
39+
environment:
40+
postgres_host: postgres:5432
41+
postgres_user: graph-node
42+
postgres_pass: let-me-in
43+
postgres_db: graph-node
44+
ipfs: "ipfs:5001"
45+
ethereum: "ganache:http://ganache:8545"
46+
RUST_LOG: info
47+
48+
ipfs:
49+
image: ipfs/go-ipfs:v0.4.23
50+
ports:
51+
- "5001:5001"
52+
volumes:
53+
- ./data/ipfs:/data/ipfs
54+
55+
postgres:
56+
image: postgres
57+
ports:
58+
- "5432:5432"
59+
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
60+
environment:
61+
POSTGRES_USER: graph-node
62+
POSTGRES_PASSWORD: let-me-in
63+
POSTGRES_DB: graph-node
64+
volumes:
65+
- ./data/postgres:/var/lib/postgresql/data

schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type EventParam @entity {
1212
paramName: String!
1313
paramType: String!
1414
}
15+
1516
type EventParams @entity {
1617
id: ID!
1718
index: Int!

src/mapping.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from "./util";
2222

2323
export function handleApproval(event: Approval): void {
24-
24+
2525
let owner = event.params.owner;
2626
let ownerString = owner.toHex();
2727
let txTimestamp = event.block.timestamp;

start-graph.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
3+
######################
4+
####### CONFIG #######
5+
######################
6+
RPC_ENDPOINT="http://localhost:8545"
7+
TOTAL_WAITING_TIME=45 # seconds
8+
WAIT_FOR_INPUT=true
9+
ROOT_DIR=$(pwd)
10+
######################
11+
12+
function killCompose {
13+
cd $ROOT_DIR
14+
docker-compose down -v
15+
}
16+
17+
function killAndExit {
18+
echo "####### EXITING... #######"
19+
killCompose
20+
exit 0
21+
}
22+
23+
function graphCreate {
24+
echo '####### DEPLOYING GRAPH #######'
25+
yarn codegen
26+
echo '####### GRAPH CODE GENERATED #######'
27+
yarn create-local
28+
echo '####### GRAPH LOCAL CREATED #######'
29+
yarn deploy-local
30+
echo '####### GRAPH LOCAL DEPLOYED #######'
31+
if [ "$?" -ne 0 ];
32+
then
33+
echo "ERROR: Could not deploy graph successfully - try fix error and redeploy"
34+
fi
35+
}
36+
37+
function graphRedeploy {
38+
echo '####### REDEPLOYING GRAPH #######'
39+
yarn codegen && yarn deploy-local
40+
if [ "$?" -ne 0 ];
41+
then
42+
echo "ERROR: Could not redeploy graph successfully"
43+
fi
44+
}
45+
46+
function doneLoop {
47+
echo "######################"
48+
echo "######## DONE ########"
49+
if [ $WAIT_FOR_INPUT = true ]; then
50+
echo "####### PRESS R to RESTART ######"
51+
echo "# PRESS G to REDEPLOY the graph #"
52+
echo "######## PRESS Q to QUIT ########"
53+
fi
54+
echo "######################"
55+
if [ $WAIT_FOR_INPUT = true ]; then
56+
waitForInput
57+
fi
58+
}
59+
60+
function start {
61+
echo "####### CLEANUP #######"
62+
sudo rm -rf data ganache-data
63+
sudo rm -f ./contracts/.openzeppelin/dev-321.json
64+
65+
echo "####### DOCKER-COMPOSE #######"
66+
docker-compose up 2>&1 > /dev/null &
67+
DOCKER_COMPOSE_UP_PID=$!
68+
69+
echo "####### WAITING FOR DOCKERS #######"
70+
WAITING_TIME=0
71+
until $(curl --output /dev/null -X POST --silent --fail -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' $RPC_ENDPOINT); do
72+
SLEEP_AMOUNT=3
73+
sleep $SLEEP_AMOUNT
74+
WAITING_TIME=$(($WAITING_TIME+$SLEEP_AMOUNT))
75+
if [ "$WAITING_TIME" -gt "$TOTAL_WAITING_TIME" ];
76+
then
77+
echo "ERROR: Could not reach ETH chain"
78+
killAndExit
79+
fi;
80+
done
81+
82+
echo "####### DEPLOYING CONTRACTS #######"
83+
cd ./contracts && truffle migrate --reset --network graphTesting
84+
if [ "$?" -ne 0 ];
85+
then
86+
echo "ERROR: Could not deploy contracts successfully"
87+
killAndExit
88+
fi
89+
cd ../graph
90+
91+
sleep 5 ## Sometimes it takes a bit longer for the graph to be ready.
92+
graphCreate
93+
doneLoop
94+
}
95+
96+
function waitForInput {
97+
while [ true ] ; do
98+
read -n 1 k <&1
99+
if [[ $k == "q" || $k == "Q" ]]; then
100+
echo ""
101+
killAndExit
102+
elif [[ $k == "r" || $k == "R" ]]; then
103+
echo ""
104+
echo "######## RESTARTING ALL ########"
105+
killCompose
106+
sleep 3
107+
start
108+
elif [[ $k == "g" || $k == "G" ]]; then
109+
echo ""
110+
graphRedeploy
111+
doneLoop
112+
fi
113+
done
114+
}
115+
116+
start

0 commit comments

Comments
 (0)