-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.sh
executable file
·115 lines (95 loc) · 2.68 KB
/
demo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
set -e
command -v pipenv >/dev/null 2>&1 ||
{ echo >&2 "Pipenv is not installed!";
exit 1
}
command -v docker >/dev/null 2>&1 ||
{ echo >&2 "Docker is not installed!";
exit 1
}
command -v docker-compose >/dev/null 2>&1 ||
{ echo >&2 "docker-compose is not available!";
exit 1
}
# setup
pipenv install
pipenv run autonomy init --remote --ipfs --reset --author=prediction_markets_demo
# Load market creator env vars
set -o allexport && source .creator.env && set +o allexport
# Re-assign confusing overrides
export ETHEREUM_LEDGER_RPC=$RPC
export ETHEREUM_LEDGER_CHAIN_ID=$CHAIN_ID
# Set all participants
export ALL_PARTICIPANTS='["'$CREATOR_AGENT_ADDRESS'"]'
# Run the market creator service
directory="creator_service"
if [ -d $directory ]
then
echo "Detected an existing service in $directory. Using this one..."
else
echo "Fetching the market creator service..."
service_version=":$CREATOR_SERVICE_VERSION:$CREATOR_SERVICE_HASH"
pipenv run autonomy fetch --service valory/market_maker$service_version --alias $directory
fi
cd $directory
directory="abci_build"
if [ -d $directory ]
then
echo "Detected an existing build in the current folder. Using this one..."
else
echo "Building the market creator service..."
# Build the image
pipenv run autonomy build-image
cat > keys.json << EOF
[
{
"address": "$TRADER_AGENT_ADDRESS",
"private_key": "$CREATOR_P_KEY"
}
]
EOF
# Build the deployment with a single agent
pipenv run autonomy deploy build --n 1 -ltm
fi
# Run the deployment
pipenv run autonomy deploy run --build-dir abci_build/ &
cd ..
# Load trader env vars
set -o allexport && source .trader.env && set +o allexport
# Re-assign confusing overrides
export RPC_0=$RPC
# Set all participants
export ALL_PARTICIPANTS='["'$TRADER_AGENT_ADDRESS'"]'
# Run the trader service
directory="trader_service"
if [ -d $directory ]
then
echo "Detected an existing service in $directory. Using this one..."
else
echo "Fetching the trader service..."
service_version=":$TRADER_SERVICE_VERSION:$TRADER_SERVICE_HASH"
pipenv run autonomy fetch --service valory/trader$service_version --alias $directory
fi
cd $directory
directory="abci_build"
if [ -d $directory ]
then
echo "Detected an existing build in the current folder. Using this one..."
else
echo "Building the trader service..."
# Build the image
pipenv run autonomy build-image
cat > keys.json << EOF
[
{
"address": "$CREATOR_AGENT_ADDRESS",
"private_key": "$TRADER_P_KEY"
}
]
EOF
# Build the deployment with a single agent
pipenv run autonomy deploy build --n 1 -ltm
fi
# Run the deployment
pipenv run autonomy deploy run --build-dir abci_build/ &