|
@@ -0,0 +1,55 @@
|
|
|
+#!/usr/bin/env bash
|
|
|
+
|
|
|
+set -e
|
|
|
+
|
|
|
+DATA_PATH=$PWD/../data
|
|
|
+
|
|
|
+cd ../joystream
|
|
|
+
|
|
|
+# The docker image tag to use for joystream/node
|
|
|
+RUNTIME=${RUNTIME:=$(scripts/runtime-code-shasum.sh)}
|
|
|
+
|
|
|
+# Source of funds for all new accounts that are created in the tests.
|
|
|
+TREASURY_INITIAL_BALANCE=${TREASURY_INITIAL_BALANCE:="100000000"}
|
|
|
+TREASURY_ACCOUNT_URI=${TREASURY_ACCOUNT_URI:="//Bob"}
|
|
|
+TREASURY_ACCOUNT=$(docker run --rm joystream/node:${RUNTIME} key inspect ${TREASURY_ACCOUNT_URI} --output-type json | jq .ss58Address -r)
|
|
|
+
|
|
|
+>&2 echo "treasury account from suri: ${TREASURY_ACCOUNT}"
|
|
|
+
|
|
|
+# Default initial balances
|
|
|
+echo "{
|
|
|
+ \"balances\":[
|
|
|
+ [\"$TREASURY_ACCOUNT\", $TREASURY_INITIAL_BALANCE]
|
|
|
+ ],
|
|
|
+ \"vesting\":[]
|
|
|
+}" > ${DATA_PATH}/initial-balances.json
|
|
|
+
|
|
|
+# Override initial balances from external source
|
|
|
+if [[ $INITIAL_BALANCES == http* ]];
|
|
|
+then
|
|
|
+ >&2 echo "fetching ${INITIAL_BALANCES}"
|
|
|
+ wget -O ${DATA_PATH}/initial-balances.json ${INITIAL_BALANCES}
|
|
|
+else
|
|
|
+ if [ ! -z "$INITIAL_BALANCES" ]; then
|
|
|
+ if jq -e . >/dev/null 2>&1 <<<"$INITIAL_BALANCES"; then
|
|
|
+ >&2 echo "Detected some valid JSON in INITIAL_BALANCES"
|
|
|
+ echo $INITIAL_BALANCES > ${DATA_PATH}/initial-balances.json
|
|
|
+ else
|
|
|
+ >&2 echo "Failed to parse INITIAL_BALANCES as JSON, or got false/null"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+fi
|
|
|
+
|
|
|
+# Create a chain spec file
|
|
|
+docker run --rm -v ${DATA_PATH}:/spec --entrypoint ./chain-spec-builder joystream/node:${RUNTIME} \
|
|
|
+ new \
|
|
|
+ --fund-accounts \
|
|
|
+ --authorities //Alice \
|
|
|
+ --deployment dev \
|
|
|
+ --chain-spec-path /spec/chain-spec.json \
|
|
|
+ --initial-balances-path /spec/initial-balances.json
|
|
|
+
|
|
|
+# Convert the chain spec file to a raw chainspec file
|
|
|
+docker run --rm -v ${DATA_PATH}:/spec joystream/node:${RUNTIME} build-spec \
|
|
|
+ --raw --disable-default-bootnode \
|
|
|
+ --chain /spec/chain-spec.json > ${DATA_PATH}/chain-spec-raw.json
|