Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rinkeby deploy #169

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dharmaprotocol/contracts",
"version": "0.1.11",
"version": "0.1.13",
"main": "dist/artifacts/index.js",
"typings": "dist/types/artifacts/index.d.ts",
"files": [
Expand Down
52 changes: 52 additions & 0 deletions scripts/deploy_rinkeby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# We use the build/ directory as a day-to-day development
# environment, and use the artifacts/ directory to store production
# artifacts (i.e. artifacts where our contracts are deployed
# on non-local blockchains).
#
# Truffle will by default use the build folder to fetch the most recent
# artifacts and update them with the newly deployed contract
# addresses, saving the newest artifacts in build.dev
#
# Thus, when pushing a new build to Rinkeby, we want to replace build
# folder with most recent saved production artifacts/ directory contents
# so that our new artifacts include the addresses of contracts deployed in production
# on networks *other* than Rinkeby.
rm build/contracts/*
cp artifacts/json/* build/contracts/

# Setup SSH tunneling with port forwarding into hosted Rinkeby node
ssh -f -o 'ServerAliveInterval 10' -o 'ServerAliveCountMax 3' \
-N -L 8546:localhost:8545 ubuntu@rinkeby.dharma.io

# Grab PID of ssh connection process
SSH_PID=$(ps aux | grep "ssh" | grep -v 'grep' | awk '{print $2}')

# Re-compile all contrac
truffle compile --all

# Deploy contracts onto Rinkeby network
truffle migrate --network rinkeby

# Replace production artifacts with newly generated json artifacts
rm artifacts/json/*
cp build/contracts/* artifacts/json/

# Remove old transpiled artifacts from the artifacts/ directory
rm artifacts/ts/*

# Transform raw JSON artifacts into Typescript modules. This makes
# interacting with the artifacts significantly easier when exporting
# them as modules.
for filename in build/contracts/*.json; do
filename_base=$(basename $filename .json)
echo -e "export const $filename_base = " > "artifacts/ts/$filename_base.ts"
cat "build/contracts/$filename_base.json" >> "artifacts/ts/$filename_base.ts"

echo -e "Transpiled $filename_base.json into $filename_base.ts"
done

# Kill ssh connection process
kill -9 $SSH_PID

echo -e "Successfully deployed contracts onto Rinkeby Testnet!"