github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/creative/scripts/func_production.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  # addProduction $USER_TOKEN_01 "hanmeimei" "book" "00000001" "《李雷和韩梅梅》" "青春偶像" "INK" "100" "10000" "1000"
    20  # addProduction $USER_TOKEN_02 "lilei" "code" "00000001" "《PHP从出门到放弃》" "抓狂日志" "INK" "1" "10000" "5000"
    21  addProduction(){
    22      tag="add production"
    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":["AddProduction","'$2'","'$3'","'$4'","'$5'","'$6'","'$7'","'$8'","'$9'","'${10}'"]}' -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  # deleteProduction $USER_TOKEN_01 "hanmeimei" "book" "00000001"
    34  # deleteProduction $USER_TOKEN_02 "lilei" "code" "00000001"
    35  deleteProduction(){
    36      tag="delete production"
    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":["DeleteProduction","'$2'","'$3'","'$4'"]}' -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  # Name、Desc、CopyrightPriceType、CopyrightPrice、CopyrightNum、CopyrightTransferPart
    48  # modifyProduction $USER_TOKEN_01 "hanmeimei" "book" "00000001" "Name" "《老王和韩梅梅》"
    49  # modifyProduction $USER_TOKEN_02 "lilei" "code" "00000001" "Name" "《再见!coding》"
    50  modifyProduction(){
    51      tag="modify production"
    52      echo_b "Attempting to $tag"
    53      sleep 3
    54      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["ModifyProduction","'$2'","'$3'","'$4'","'$5'","'$6'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    55      res=$?
    56      cat log.txt
    57      verifyResult $res "$tag: Dainel Failed."
    58      echo_g "===================== creative  $tag successfully======================= "
    59      echo
    60  }
    61  
    62  # queryProduction "hanmeimei" "book" "00000001"
    63  # queryProduction "lilei" "code" "00000001"
    64  queryProduction () {
    65      tag="query production"
    66      echo_b "Attempting to $tag"
    67      sleep 3
    68      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["QueryProduction","'$1'","'$2'","'$3'"]}' >log.txt
    69      res=$?
    70      cat log.txt
    71      verifyResult $res "$tag: Dainel Failed."
    72      echo_g "===================== creative  $tag successfully======================= "
    73      echo
    74  }
    75  
    76  # listOfProduction username product_type
    77  # listOfProduction "hanmeimei" "book"
    78  # listOfProduction "lilei" "code"
    79  listOfProduction () {
    80      tag="list of production"
    81      echo_b "Attempting to $tag"
    82      sleep 3
    83      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["ListOfProduction","'$1'","'$2'"]}' >log.txt
    84      res=$?
    85      cat log.txt
    86      verifyResult $res "$tag: Dainel Failed."
    87      echo_g "===================== creative  $tag successfully======================= "
    88      echo
    89  }
    90  
    91  # addSupporter $USER_TOKEN_01 "lilei" "code" "00000001" "INK" "99" "hanmeimei"
    92  # addSupporter $USER_TOKEN_02 "hanmeimei" "book" "00000001" "INK" "199" "lilei"
    93  addSupporter(){
    94      tag="add supporter"
    95      echo_b "Attempting to $tag"
    96      sleep 3
    97      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["AddSupporter","'$2'","'$3'","'$4'","'$5'","'$6'","'$7'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    98      res=$?
    99      cat log.txt
   100      verifyResult $res "$tag: Dainel Failed."
   101      echo_g "===================== creative  $tag successfully======================= "
   102      echo
   103  }
   104  
   105  # listOfSupporter username product_type  product_serial
   106  # listOfSupporter "hanmeimei" "book" "00000001"
   107  # listOfSupporter "lilei" "code" "00000001"
   108  listOfSupporter(){
   109      tag="list of supporter"
   110      echo_b "Attempting to $tag"
   111      sleep 3
   112      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["ListOfSupporter","'$1'","'$2'","'$3'"]}' >log.txt
   113      res=$?
   114      cat log.txt
   115      verifyResult $res "$tag: Dainel Failed."
   116      echo_g "===================== creative  $tag successfully======================= "
   117      echo
   118  }
   119  
   120  # addBuyer $USER_TOKEN_01 "lilei" "code" "00000001" "INK" "5" "hanmeimei"
   121  # addBuyer $USER_TOKEN_01 "lilei" "code" "00000001" "INK" "5" "hanmeimei"
   122  addBuyer(){
   123      tag="add buyer"
   124      echo_b "Attempting to $tag"
   125      sleep 3
   126      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["AddBuyer","'$2'","'$3'","'$4'","'$5'","'$6'","'$7'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
   127      res=$?
   128      cat log.txt
   129      verifyResult $res "$tag: Dainel Failed."
   130      echo_g "===================== creative  $tag successfully======================= "
   131      echo
   132  }
   133  
   134  # modifyBuyer
   135  modifyBuyer(){
   136      tag="modify buyer"
   137      echo_b "Attempting to $tag"
   138  #    sleep 3
   139  #    peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["ModifyBuyer","'$2'","'$3'","'$4'","'$5'","'$6'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
   140  #    res=$?
   141  #    cat log.txt
   142  #    verifyResult $res "$tag: Dainel Failed."
   143      echo_g "===================== creative  $tag successfully======================= "
   144      echo
   145  }
   146  
   147  # deleteBuyer
   148  deleteBuyer(){
   149      tag="delete buyer"
   150      echo_b "Attempting to $tag"
   151  #    sleep 3
   152  #    peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["DeleteBuyer","'$2'","'$3'","'$4'","'$5'","'$6'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
   153  #    res=$?
   154  #    cat log.txt
   155  #    verifyResult $res "$tag: Dainel Failed."
   156      echo_g "===================== creative  $tag successfully======================= "
   157      echo
   158  }
   159  
   160  # listOfBuyer username product_type  product_serial
   161  # listOfBuyer "hanmeimei" "book" "00000001"
   162  # listOfBuyer "lilei" "code" "00000001"
   163  listOfBuyer(){
   164      tag="list of buyer"
   165      echo_b "Attempting to $tag"
   166      sleep 3
   167      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["ListOfBuyer","'$1'","'$2'","'$3'"]}' >log.txt
   168      res=$?
   169      cat log.txt
   170      verifyResult $res "$tag: Dainel Failed."
   171      echo_g "===================== creative  $tag successfully======================= "
   172      echo
   173  }