-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathjob_alarmclock_test.sh
85 lines (81 loc) · 2.44 KB
/
job_alarmclock_test.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
#!/bin/bash
GREEN='\033[0;32m'
NC='\033[0m' # No Color
JOB_TITLE="Alarm Clock Sample"
JOB_FNAME="plinode_job_alarmclock.json"
#clear
echo -e "${GREEN}#"
echo -e "# This script generates the necessary json blob for the Oracle Job-Setup section in the docs"
echo -e "# source: https://docs.goplugin.co/oracle/job-setup"
echo -e "#"
echo -e "# The script uses the 'name' & 'endpoint' variables from your local VARS file & prompts"
echo -e "# you to enter the newly generated Oracle contract address (which was generated by the Oracle Deployment section)"
echo -e "#"
echo -e "# The script checks for leading / trailing white spaces and removes as necessary"
echo -e "# & converts the 'xdc' prefix to '0x' as necessary"
echo -e "#"
echo -e "#${NC}"
sleep 0.5s
source ~/"plinode_$(hostname -f)".vars
read -p 'Enter your Oracle Contract Address : ' _INPUT
ORACLE_ADDR="$(echo $_INPUT | sed '/^$/d;/^\\s*$/d;s/^xdc/0x/g')"
#echo "$_INPUT"
#echo "$ORACLE_ADDR"
diff -u <(echo "$_INPUT") <(echo "$ORACLE_ADDR")
sleep 2s
cat <<EOF > ~/$JOB_FNAME
{
"initiators":[
{
"type":"external",
"params":{
"name": "$PLI_L_INIT_NAME",
"body": {
"endpoint": "$PLI_E_INIT_NAME",
"addresses": ["$ORACLE_ADDR"]
}
}
}
],
"tasks":[
{
"type":"sleep",
"confirmations":null,
"params":{
}
},
{
"type":"ethbool",
"confirmations":null,
"params":{
}
},
{
"type":"ethtx",
"confirmations":null,
"params":{
}
}
],
"startAt":null,
"endAt":null
}
EOF
#sleep 1s
#echo
#echo " Local node json blob for AlarmClockSample job - Reference only"
#echo
#cat ~/$JOB_FNAME
plugin admin login -f ~/plugin-deployment/.env.apicred
plugin job_specs create ~/$JOB_FNAME > /tmp/plinode_job_id.raw
sed 's/ ║ /,/g;s/╬//g;s/═//g;s/║//g;s/╔//g;s/[[:space:]]//g' /tmp/plinode_job_id.raw > /tmp/plinode_job_id.raw1
jobid=(); jobid=($(cat /tmp/plinode_job_id.raw1))
alarmclock_jobid="$(echo ${jobid[2]} | sed 's/,,.*$//')"
echo -e "${GREEN}#"
echo -e "Local node $JOB_TITLE job id - Copy to your Solidity script"
echo -e "================================================================="
echo -e
echo -e "Your Oracle Contract Address is : $ORACLE_ADDR"
echo -e "Your $JOB_TITLE Job ID is : $alarmclock_jobid ${NC}"
echo
echo