github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/creative/scripts/func_user.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  #Copyright Ziggurat Corp. 2017 All Rights Reserved.
     4  #
     5  #SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  # Detecting whether can import the header file to render colorful cli output
     9  if [ -f ./func_init.sh ]; then
    10   source ./func_init.sh
    11  elif [ -f scripts/func_init.sh ]; then
    12   source scripts/func_init.sh
    13  else
    14   alias echo_r="echo"
    15   alias echo_g="echo"
    16   alias echo_b="echo"
    17  fi
    18  
    19  # addUser $USER_TOKEN_01 hanmeimei hanmeimei@qq.com
    20  # addUser $USER_TOKEN_02 lilei lilei@qq.com
    21  addUser(){
    22      tag="add user"
    23      echo_b "Attempting to $tag"
    24      sleep 3
    25      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["AddUser","'$2'","'$3'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    26      res=$?
    27      cat log.txt
    28      verifyResult $res "$tag: Dainel Failed."
    29      echo_g "===================== creative $tag successfully======================= "
    30      echo
    31  }
    32  
    33  # deleteUser $USER_TOKEN_01 hanmeimei
    34  # deleteUser $USER_TOKEN_02 lilei
    35  deleteUser () {
    36      tag="delete user"
    37      echo_b "Attempting to $tag"
    38      sleep 3
    39      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["DeleteUser","'$2'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    40      res=$?
    41      cat log.txt
    42      verifyResult $res "$tag: Dainel Failed."
    43      echo_g "===================== creative $tag successfully======================= "
    44      echo
    45  }
    46  
    47  # modifyUser $USER_TOKEN_01 hanmeimei Email meimei@qq.com
    48  # modifyUser $USER_TOKEN_02 lilei Email leilei@qq.com
    49  modifyUser () {
    50      tag="modify user"
    51      echo_b "Attempting to $tag"
    52      sleep 3
    53      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["ModifyUser","'$2'","'$3'","'$4'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    54      res=$?
    55      cat log.txt
    56      verifyResult $res "$tag: Dainel Failed."
    57      echo_g "===================== creative $tag successfully======================= "
    58      echo
    59  }
    60  
    61  # queryUser hanmeimei
    62  # queryUser lilei
    63  queryUser () {
    64      tag="query user"
    65      echo_b "Attempting to $tag"
    66      sleep 3
    67      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["QueryUser","'$1'"]}' >log.txt
    68      res=$?
    69      cat log.txt
    70      verifyResult $res "$tag: Dainel Failed."
    71      echo_g "===================== creative $tag successfully======================= "
    72      echo
    73  }
    74  
    75  # listOfUser
    76  listOfUser () {
    77      tag="list of user"
    78      echo_b "Attempting to $tag"
    79      sleep 3
    80      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["ListOfUser"]}' >log.txt
    81      res=$?
    82      cat log.txt
    83      verifyResult $res "$tag: Dainel Failed."
    84      echo_g "===================== creative  $tag successfully======================= "
    85      echo
    86  }