forked from planetarium/NineChronicles.EthBridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare-development.sh
More file actions
executable file
·28 lines (23 loc) · 993 Bytes
/
prepare-development.sh
File metadata and controls
executable file
·28 lines (23 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -e
# Deploy WNCG contract.
pushd contracts > /dev/null
rm -rf build
yarn
yarn truffle migrate --network ropsten
contract_address=$(jq '.networks."3".address' ./build/contracts/WrappedNCG.json | tr -d '"')
popd > /dev/null
# Create KMS key.
key_id="16b2c06f-d1bb-4e8a-8c38-0cab0836e816"
public_key=$(aws kms get-public-key \
--region us-east-2 \
--key-id "$key_id" | jq ".PublicKey" | tr -d '"' | \
python3 -c "import base64; print(base64.b64encode(base64.b64decode(input())[23:]).decode('utf-8'))")
pushd contracts > /dev/null
address=$(node -e "console.log('0x' + require('web3').utils.keccak256('0x' + Buffer.from('$public_key', 'base64').toString('hex').slice(2)).slice(26))")
yarn truffle exec --network ropsten ./scripts/transfer-ownership.js "$address"
popd > /dev/null
echo "WNCG_CONTRACT_ADDRESS=$contract_address"
echo "KMS_PROVIDER_KEY_ID=$key_id"
echo "KMS_PROVIDER_PUBLIC_KEY=$public_key"
echo "KMS_PROVIDER_ADDRESS=$address"