-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from RetricSu/hot-bump-version
bump godwoken version and improve start command
- Loading branch information
Showing
4 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule godwoken
updated
from b811a1 to 26d15d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
|
||
# how to use: | ||
# parese_toml_with_section file_path section_name key_name | ||
parse_toml_with_section(){ | ||
[[ -f $1 ]] || { echo "$1 is not a file." >&2;return 1;} | ||
local -n config_array=config | ||
[[ -n $2 ]] || { echo "pleas pass your interested section name as second variable!";} | ||
if [[ -n $3 ]]; then | ||
key_name="$3" | ||
else | ||
echo "pleas pass your interested key name as third variable!"; | ||
fi | ||
declare -Ag ${!config_array} || return 1 | ||
local line key value section_regex entry_regex interested_section_array | ||
section_regex="^[[:blank:]]*\[([[:alpha:]_][[:alnum:]/._-]*)\][[:blank:]]*(#.*)?$" | ||
entry_regex="^[[:blank:]]*([[:alpha:]_][[:alnum:]_]*)[[:blank:]]*=[[:blank:]]*('[^']+'|\"[^\"]+\"|[^#[:blank:]]+)[[:blank:]]*(#.*)*$" | ||
while read -r line | ||
do | ||
[[ -n $line ]] || continue | ||
[[ $line =~ $section_regex ]] && { | ||
local -n config_array=${BASH_REMATCH[1]//\./\_} # if section name contains ".", replace it with "_" for naming. | ||
if [[ ${BASH_REMATCH[1]} =~ $2 ]]; then | ||
interested_section_array="$BASH_REMATCH" | ||
else | ||
continue | ||
fi | ||
declare -Ag ${!config_array} || return 1 | ||
continue | ||
} | ||
[[ $line =~ $entry_regex ]] || continue | ||
key=${BASH_REMATCH[1]} | ||
value=${BASH_REMATCH[2]#[\'\"]} # strip quotes | ||
value=${value%[\'\"]} | ||
config_array["${key}"]="${value}" | ||
done < "$1" | ||
declare -n array="${interested_section_array//\./\_}" | ||
echo ${array[$key_name]} | ||
} | ||
|
||
isRollupCellExits(){ | ||
echo $1 | ||
if [[ -n $1 ]]; | ||
then | ||
local tomlconfigfile="$1" | ||
else | ||
local tomlconfigfile="/code/godwoken/config.toml" | ||
fi | ||
|
||
rollup_code_hash=$( parse_toml_with_section "$tomlconfigfile" "chain.rollup_type_script" "code_hash" ) | ||
rollup_hash_type=$( parse_toml_with_section "$tomlconfigfile" "chain.rollup_type_script" "hash_type" ) | ||
rollup_args=$( parse_toml_with_section "$tomlconfigfile" "chain.rollup_type_script" "args" ) | ||
|
||
result=$( echo '{ | ||
"id": 2, | ||
"jsonrpc": "2.0", | ||
"method": "get_cells", | ||
"params": [ | ||
{ | ||
"script": { | ||
"code_hash": "'${rollup_code_hash}'", | ||
"hash_type": "'${rollup_hash_type}'", | ||
"args": "'${rollup_args}'" | ||
}, | ||
"script_type": "type" | ||
}, | ||
"asc", | ||
"0x64" | ||
] | ||
}' \ | ||
| tr -d '\n' \ | ||
| curl -H 'content-type: application/json' -d @- \ | ||
http://localhost:8116 ) | ||
|
||
if [[ $result =~ "block_number" ]]; then | ||
echo "Rollup cell exits!" | ||
# 0 equals true | ||
return 0 | ||
else | ||
echo "can not found Rollup cell!" | ||
# 1 equals false | ||
return 1 | ||
fi | ||
} | ||
|