local req='"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${exector}"'"}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
# GAME_ADDR=$(echo "${res}" | jq -r ".result")
echo_rst "$FUNCNAME""$?"
}
function CreateGameTx(){
local amount=$1
local hash_value=$2
local addr=$3
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
rawTx=$(echo"${resp}" | jq -r".result")
if["$rawTx"=="null"];then
echo_rst "CreateGame createRawTx" 1
fi
signRawTx "${rawTx}""${ACCOUNT_A}"
echo_rst "CreateGame signRawTx""$?"
sendSignedTx
echo_rst "CreateGame sendSignedTx""$?"
GAME_ID="${txHash}"
# create_txHash="${txHash}"
query_tx "${txHash}"
echo_rst "CreateGame query_tx""$?"
}
function MatchGameTx(){
local gameId=$1
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
rawTx=$(echo"${resp}" | jq -r".result")
if["$rawTx"=="null"];then
echo_rst "MatchGame createRawTx" 1
fi
signRawTx "${rawTx}""${ACCOUNT_B}"
echo_rst "MatchGame signRawTx""$?"
sendSignedTx
echo_rst "MatchGame sendSignedTx""$?"
# match_txHash="${txHash}"
query_tx "${txHash}"
echo_rst "MatchGame query_tx""$?"
}
function CloseGameTx(){
local gameId=$1
local secret=$2
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
rawTx=$(echo"${resp}" | jq -r".result")
if["$rawTx"=="null"];then
echo_rst "CloseGame createRawTx" 1
fi
signRawTx "${rawTx}""${ACCOUNT_A}"
echo_rst "CloseGame signRawTx""$?"
sendSignedTx
echo_rst "CloseGame sendSignedTx""$?"
query_tx "${txHash}"
echo_rst "CloseGame query_tx""$?"
}
function CancleGameTx(){
local gameId=$1
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
rawTx=$(echo"${resp}" | jq -r".result")
if["$rawTx"=="null"];then
echo_rst "CancleGame createRawTx" 1
fi
signRawTx "${rawTx}""${ACCOUNT_A}"
echo_rst "CancleGame signRawTx""$?"
sendSignedTx
echo_rst "CancleGame sendSignedTx""$?"
# close_txHash="${txHash}"
query_tx "${txHash}"
echo_rst "CancleGame query_tx""$?"
}
function QueryGameByStatus(){
local status=$1
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
GAMES=$(echo"${resp}" | jq -r".result.games")
echo"${GAMES}"
echo_rst "$FUNCNAME""$?"
}
function QueryGameByGameId(){
local gameId=$1
local status=$2
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]'