2021-09-21 14:56:19 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Source env settings
|
|
|
|
. .env
|
2022-06-10 08:32:20 +00:00
|
|
|
source bin/helper.sh
|
2021-09-21 14:56:19 +00:00
|
|
|
|
|
|
|
# NeoGo binary path.
|
|
|
|
NEOGO="${NEOGO:-docker exec -it morph_chain neo-go}"
|
|
|
|
# NNS contract script hash
|
2022-06-10 08:32:20 +00:00
|
|
|
output=$(curl -s --data '{ "id": 1, "jsonrpc": "2.0", "method": "getcontractstate", "params": [1] }' \
|
|
|
|
"http://morph-chain.${LOCAL_DOMAIN}:30333/") \
|
|
|
|
|| die "Cannot fetch NNS contract state"
|
|
|
|
|
|
|
|
NNS_ADDR=$(jq -r '.result.hash' <<< "$output") \
|
|
|
|
|| die "Cannot parse NNS contract hash: $NNS_ADDR"
|
2021-09-21 14:56:19 +00:00
|
|
|
|
|
|
|
${NEOGO} contract testinvokefunction \
|
2022-06-10 08:32:20 +00:00
|
|
|
-r "http://morph-chain.${LOCAL_DOMAIN}:30333" \
|
|
|
|
"${NNS_ADDR}" resolve string:"${1}" int:16 \
|
|
|
|
| jq -r '.stack[0].value | if type=="array" then .[0].value else . end' \
|
|
|
|
| base64 -d \
|
|
|
|
|| die "Cannot invoke 'NNS.resolve' $output"
|