@@ -46,9 +48,8 @@ function chain33_GetExecAddr() {
...
@@ -46,9 +48,8 @@ function chain33_GetExecAddr() {
function CreateGameTx(){
function CreateGameTx(){
local amount=$1
local amount=$1
local hash_value=$2
local hash_value=$2
local exector=$3
local addr=$3
local addr=$4
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]'
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${exector}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]'
echo"#request: $req"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
echo"#response: $resp"
...
@@ -68,8 +69,7 @@ function CreateGameTx() {
...
@@ -68,8 +69,7 @@ function CreateGameTx() {
function MatchGameTx(){
function MatchGameTx(){
local gameId=$1
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"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
echo"#response: $resp"
...
@@ -89,8 +89,7 @@ function MatchGameTx() {
...
@@ -89,8 +89,7 @@ function MatchGameTx() {
function CloseGameTx(){
function CloseGameTx(){
local gameId=$1
local gameId=$1
local secret=$2
local secret=$2
local exector=$3
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]'
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${exector}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]'
echo"#request: $req"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
echo"#response: $resp"
...
@@ -109,8 +108,7 @@ function CloseGameTx() {
...
@@ -109,8 +108,7 @@ function CloseGameTx() {
function CancleGameTx(){
function CancleGameTx(){
local gameId=$1
local gameId=$1
local exector=$2
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]'
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${exector}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]'
echo"#request: $req"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
echo"#response: $resp"
...
@@ -128,20 +126,20 @@ function CancleGameTx() {
...
@@ -128,20 +126,20 @@ function CancleGameTx() {
}
}
function QueryGameByStatus(){
function QueryGameByStatus(){
local exector=$1
local status=$1
local req='"method":"Chain33.Query","params":[{"execer":"'"${exector}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":1,"address":""}}]'
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":"${status}","address":""}}]'
echo"#request: $req"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
echo"#response: $resp"
GAMES=$(echo"${resp}" | jq -r".result.games")
GAMES=$(echo"${resp}" | jq -r".result.games")
echo"${GAMES}"
echo_rst "$FUNCNAME""$?"
echo_rst "$FUNCNAME""$?"
}
}
function QueryGameByGameId(){
function QueryGameByGameId(){
local gameId=$1
local gameId=$1
local exector=$2
local status=$2
local status=$3
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]'
local req='"method":"Chain33.Query","params":[{"execer":"'"${exector}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]'
echo"#request: $req"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
echo"#response: $resp"
...
@@ -161,25 +159,22 @@ function chain33_ImportPrivkey() {
...
@@ -161,25 +159,22 @@ function chain33_ImportPrivkey() {
echo"#request: $req"
echo"#request: $req"
resp=$(curl -ksd"{$req}""$1")
resp=$(curl -ksd"{$req}""$1")
echo"#response: $resp"
echo"#response: $resp"
ok=$(jq '(.error|not) and (.result.label=="gameB") and (.result.acc.addr == "'"$acc"'")'<<<"$resp")
# ok=$(jq '(.error|not) and (.result.label=="gameB") and (.result.acc.addr == "'"$acc"'")' <<<"$resp")
["$ok"==true]
# [ "$ok" == true ]
# echo_rst "$FUNCNAME" "$?"
# echo_rst "$FUNCNAME" "$?"
}
}
function Chain33_SendToAddress(){
function Chain33_SendToAddress(){
local from="$1"
from=$1
local to="$2"
to=$2
local amount=$3
amount=$3
local req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]'