@@ -36,14 +36,21 @@ check_fpc_path() {
3636
3737# Source environment variables
3838source_env () {
39+ local env_file=" ${1:- } "
40+
3941 # Get the directory where the script is located
4042 SCRIPT_DIR=" $FPC_PATH /samples/chaincode/confidential-escrow/"
4143
42- if [ -f " $SCRIPT_DIR /.env" ]; then
43- source " $SCRIPT_DIR /.env"
44- log_info " Environment variables loaded from .env"
44+ # If no argument provided, use default .env
45+ if [ -z " $env_file " ]; then
46+ env_file=" $SCRIPT_DIR /.env"
47+ fi
48+
49+ if [ -f " $env_file " ]; then
50+ source " $env_file "
51+ log_info " Environment variables loaded from $( basename $env_file ) "
4552 else
46- log_error " .env file not found. Make sure it exists in script directory : $SCRIPT_DIR "
53+ log_error " Environment file not found: $env_file "
4754 exit 1
4855 fi
4956}
@@ -114,8 +121,16 @@ start_ercc() {
114121
115122# Setup docker environment
116123setup_docker () {
124+ local env_file=" ${1:- } "
125+
117126 log_info " === SETTING UP DOCKER ENVIRONMENT ==="
118- source_env
127+
128+ # Source the appropriate environment file
129+ if [ -n " $env_file " ]; then
130+ source_env " $env_file "
131+ else
132+ source_env # Use default .env
133+ fi
119134
120135 cd $FPC_PATH /samples/deployment/test-network
121136 run_cmd " ./update-connection.sh" " Updating connections"
@@ -187,6 +202,7 @@ test_create_wallet() {
187202 \" digitalAssetTypes\" : [$DIGITAL_ASSET_JSON ]
188203 }" 2>&1 )
189204 echo " $output "
205+ echo " DIGITIAL ASSET JSON:> $DIGITAL_ASSET_JSON "
190206 store_wallet_data " $output "
191207}
192208
@@ -201,6 +217,7 @@ test_create_wallet2() {
201217 \" digitalAssetTypes\" : [$DIGITAL_ASSET_JSON ]
202218 }" 2>&1 )
203219 echo " $output "
220+ echo " DIGITIAL ASSET JSON:> $DIGITAL_ASSET_JSON "
204221 WALLET2_UUID=$( echo " $output " | grep ' ^>' | sed ' s/^> //' | grep -o ' "@key":"wallet:[^"]*"' | cut -d' :' -f3 | tr -d ' "' )
205222}
206223
@@ -502,4 +519,7 @@ main() {
502519 esac
503520}
504521
505- main " $@ "
522+ # Only run main if script is executed directly, not sourced
523+ if [ " ${BASH_SOURCE[0]} " = " ${0} " ]; then
524+ main " $@ "
525+ fi
0 commit comments