forked from RostislavLitovkin/PlutoFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.sh
58 lines (44 loc) · 1.46 KB
/
generator.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
#!/bin/bash
echo "Starting Substrate.Net.Toolchain code generation :)"
SELECTED_NAME=""
# Check if a name was passed as an argument
if [ $# -gt 0 ]; then
SELECTED_NAME="$1"
fi
# Load chains data from the chains.json file
CHAINS=$(jq -c '.chains[]' "chains.json")
cd Generated
# Loop through all chains
echo "$CHAINS" | while read -r chain; do
# Extract the name and websocket values from the current chain object
NAME=$(echo "$chain" | jq -r '.name')
# skip other chains, generate only the selected name chain
if [ "$SELECTED_NAME" != "" ]; then
if [ "$SELECTED_NAME" != $NAME ]; then
continue
fi
fi
echo "Generating: "$NAME
# Prepare each chain project/solution
mkdir $NAME
cd $NAME
dotnet new sln
# Prepare data to be used as parameter
PROJECTNAME=$NAME".NetApi"
WEBSOCKET=$(echo "$chain" | jq -r '.websocket')
# Use Substrate.Net.Toolchain to generate the correct c# represenation of the chain
dotnet new substrate --sdk_version 0.6.8 --metadata_websocket $WEBSOCKET --net_api $PROJECTNAME --force --allow-scripts yes --generate_openapi_documentation false
# Remove unused folders (Few of them are causing unwanted compile-time errors)
cd $PROJECTNAME
rm Client -r
rm Helper -r
# Remove unused projects
cd ..
rm Substrate.Integration -r
rm Substrate.RestClient -r
rm Substrate.RestClient.Mockup -r
rm Substrate.RestClient.Test -r
rm Substrate.RestService -r
# Go back to Generated folder
cd ..
done