-
Notifications
You must be signed in to change notification settings - Fork 13
/
ContractExporterLight.sh
49 lines (34 loc) · 1.12 KB
/
ContractExporterLight.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
#!/bin/bash
################################################################################
#
# Script Created by Bohdan Kossak 2019
# http://CryptoLions.io
#
# Smart Contracts Data exporter For EOSIO Blockchains
#
# usage: ./ContractExporterLight.sh <ContractName> [<scope>]
# if scope is not mentioned by default is contract name
#
# https://github.com/CryptoLions/
#
################################################################################
if [ "$1" = "" ]; then
echo -ne "\n\nUSAGE:\n\n$0 <contractName> [<scope> - def contract name]\n\n"
exit;
fi
CONTRACTNAME=$1
scope=$CONTRACTNAME
if [ "$2" != "" ]; then
scope=$2
fi
echo "Extracting Contract: $1"
if [[ ! -d $CONTRACTNAME ]]; then
mkdir $CONTRACTNAME
fi
./cleos.sh get code $1 -c $CONTRACTNAME/$CONTRACTNAME.wasm --wasm -a $CONTRACTNAME/$CONTRACTNAME.abi
echo "Exporting Tables [Scope: $scope]:"
tables=( $(cat $CONTRACTNAME/$CONTRACTNAME.abi | jq -r '.tables[] | .name') )
for tbl in ${tables[@]}; do
echo -ne "Table: $tbl \r"
./cleos.sh get table $CONTRACTNAME $scope $tbl -l 10000000 > $CONTRACTNAME/table_"$tbl"_"$scope".json
done