@@ -46,17 +48,16 @@ function chain33_GetExecAddr() {
function CreateGameTx(){
local amount=$1
local hash_value=$2
local exector=$3
local addr=$4
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${exector}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]'
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
echo_rst "CreateGame createRawTx" 1
fi
signRawTx "${rawTx}""${ACCOUNT_A}"
signRawTx "${rawTx}""${ACCOUNT_A}"
echo_rst "CreateGame signRawTx""$?"
sendSignedTx
echo_rst "CreateGame sendSignedTx""$?"
...
...
@@ -68,16 +69,15 @@ function CreateGameTx() {
function MatchGameTx(){
local gameId=$1
local exector=$2
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${exector}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]'
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
echo_rst "MatchGame createRawTx" 1
fi
signRawTx "${rawTx}""${ACCOUNT_B}"
signRawTx "${rawTx}""${ACCOUNT_B}"
echo_rst "MatchGame signRawTx""$?"
sendSignedTx
echo_rst "MatchGame sendSignedTx""$?"
...
...
@@ -87,71 +87,69 @@ function MatchGameTx() {
}
function CloseGameTx(){
local gameId=$1
local secret=$2
local exector=$3
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""$?"
close_txHash="${txHash}"
query_tx "${txHash}"
echo_rst "CloseGame query_tx""$?"
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""$?"
close_txHash="${txHash}"
query_tx "${txHash}"
echo_rst "CloseGame query_tx""$?"
}
function CancleGameTx(){
local gameId=$1
local exector=$2
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""$?"
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 exector=$1
local req='"method":"Chain33.Query","params":[{"execer":"'"${exector}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":1,"address":""}}]'
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
GAMES=$(echo"${resp}" | jq -r".result.games")
echo_rst "$FUNCNAME""$?"
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 exector=$2
local status=$3
local req='"method":"Chain33.Query","params":[{"execer":"'"${exector}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]'