mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-24 18:45:09 +00:00
73 lines
1.8 KiB
Bash
Executable file
73 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Copyright IBM Corp All Rights Reserved
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Exit on first error
|
|
set -e
|
|
|
|
# don't rewrite paths for Windows Git Bash users
|
|
export MSYS_NO_PATHCONV=1
|
|
starttime=$(date +%s)
|
|
CC_SRC_LANGUAGE=${1:-"typescript"}
|
|
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
|
|
|
|
if [ "$CC_SRC_LANGUAGE" = "go" -o "$CC_SRC_LANGUAGE" = "golang" ] ; then
|
|
CC_SRC_PATH="../chaincode/fabcar/go/"
|
|
elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then
|
|
CC_SRC_PATH="../chaincode/fabcar/javascript/"
|
|
elif [ "$CC_SRC_LANGUAGE" = "java" ]; then
|
|
CC_SRC_PATH="../chaincode/fabcar/java"
|
|
elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then
|
|
CC_SRC_PATH="../chaincode/fabcar/typescript/"
|
|
else
|
|
echo The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script
|
|
echo Supported chaincode languages are: go, java, javascript, and typescript
|
|
exit 1
|
|
fi
|
|
|
|
# clean out any old identites in the wallets
|
|
rm -rf javascript/wallet/*
|
|
rm -rf java/wallet/*
|
|
rm -rf typescript/wallet/*
|
|
rm -rf go/wallet/*
|
|
|
|
# launch network; create channel and join peer to channel
|
|
pushd ../test-network
|
|
./network.sh down
|
|
./network.sh up createChannel -ca -s couchdb
|
|
./network.sh deployCC -ccn djinn -ccv 1 -cci initLedger -ccl ${CC_SRC_LANGUAGE} -ccp ${CC_SRC_PATH}
|
|
popd
|
|
|
|
cat <<EOF
|
|
|
|
Total setup execution time : $(($(date +%s) - starttime)) secs ...
|
|
|
|
Next, use the Djinn applications to interact with the deployed Djinn contract.
|
|
|
|
TypeScript:
|
|
|
|
Start by changing into the "typescript" directory:
|
|
cd typescript
|
|
|
|
Next, install all required packages:
|
|
npm install
|
|
|
|
Next, compile the TypeScript code into JavaScript:
|
|
npm run build
|
|
|
|
Register user and admin:
|
|
node dist/enrollAdmin
|
|
node dist/registerUser
|
|
|
|
Add transaction:
|
|
node dist/invoke
|
|
|
|
Get specific transaction:
|
|
node dist/getValidationById
|
|
|
|
Get all transactions:
|
|
node dist/query
|
|
|
|
EOF
|