-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
executable file
·65 lines (51 loc) · 3.62 KB
/
deploy.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
--platform linux/amd64 \
cosmwasm/workspace-optimizer:0.12.6
NODE="--node https://rpc.uni.juno.deuslabs.fi:443"
TXFLAG="--node https://rpc.uni.juno.deuslabs.fi:443 --chain-id uni-3 --gas-prices 0.025ujunox --gas auto --gas-adjustment 1.3 --broadcast-mode block"
if [ -z "$1"]
then
OWNER=cross-contract-example-owner
junod keys show $OWNER 2> /dev/null || junod keys add $OWNER
JSON=$(jq -n --arg addr $(junod keys show -a $OWNER) '{ denom:"ujunox","address":$addr}') && \
curl -X POST --header "Content-Type: application/json" --data "$JSON" https://faucet.uni.juno.deuslabs.fi/credit && echo
else
OWNER=$1
fi
ALICE=alice
BOB=bob
junod keys show $ALICE 2> /dev/null || junod keys add $ALICE
JSON=$(jq -n --arg addr $(junod keys show -a $ALICE) '{ denom:"ujunox","address":$addr}') && \
curl -X POST --header "Content-Type: application/json" --data "$JSON" https://faucet.uni.juno.deuslabs.fi/credit && echo
junod keys show $BOB 2> /dev/null || junod keys add $BOB
JSON=$(jq -n --arg addr $(junod keys show -a $BOB) '{ denom:"ujunox","address":$addr}') && \
curl -X POST --header "Content-Type: application/json" --data "$JSON" https://faucet.uni.juno.deuslabs.fi/credit && echo
# Store code
RES_DEMO_TOTAL=$(junod tx wasm store artifacts/cross_contract_demo_totals.wasm --from $OWNER $TXFLAG -y --output json -b block)
CODE_DEMO_TOTAL=$(echo $RES_DEMO_TOTAL | jq -r '.logs[0].events[-1].attributes[0].value')
RES_DINNER=$(junod tx wasm store artifacts/cross_contract_dinner.wasm --from $OWNER $TXFLAG -y --output json -b block)
CODE_DINNER=$(echo $RES_DINNER | jq -r '.logs[0].events[-1].attributes[0].value')
RES_WHITELIST=$(junod tx wasm store contracts/whitelist-binary/cw1_whitelist.wasm --from $OWNER $TXFLAG -y --output json -b block)
CODE_WHITELIST=$(echo $RES_WHITELIST | jq -r '.logs[0].events[-1].attributes[0].value')
# Instantiate
INIT_WHITELIST='{"admins":["'$(junod keys show -a $ALICE)'"], "mutable": true}'
junod tx wasm instantiate $CODE_WHITELIST "$INIT_WHITELIST" --from $OWNER --label "scholarship-list" $TXFLAG -y --no-admin
CONTRACT_WHITELIST=$(junod query wasm list-contract-by-code $CODE_WHITELIST $NODE --output json | jq -r '.contracts[-1]')
INIT_DEMO_TOTAL='{"denom":"ujunox"}'
junod tx wasm instantiate $CODE_DEMO_TOTAL "$INIT_DEMO_TOTAL" --from $OWNER --label "demo-total" $TXFLAG -y --no-admin
CONTRACT_DEMO_TOTAL=$(junod query wasm list-contract-by-code $CODE_DEMO_TOTAL $NODE --output json | jq -r '.contracts[-1]')
INIT_DINNER='{"denom":"ujunox", "scholarship_address":"'$CONTRACT_WHITELIST'"}'
junod tx wasm instantiate $CODE_DINNER "$INIT_DINNER" --from $OWNER --label "dinner" $TXFLAG -y --no-admin
CONTRACT_DINNER=$(junod query wasm list-contract-by-code $CODE_DINNER $NODE --output json | jq -r '.contracts[-1]')
# ALICE and BOB call CONTRACT_DEMO_TOTAL
REGISTER_WITH_PAYMENT='{"register_with_payment":{"dinner_contract":"'$CONTRACT_DINNER'"}}'
junod tx wasm execute $CONTRACT_DEMO_TOTAL "$REGISTER_WITH_PAYMENT" --amount 10000ujunox --from $BOB $TXFLAG -y
REGISTER_WITH_SCHOLARSHIP='{"register_with_scholarship":{"dinner_contract":"'$CONTRACT_DINNER'"}}'
junod tx wasm execute $CONTRACT_DEMO_TOTAL "$REGISTER_WITH_SCHOLARSHIP" --from $ALICE $TXFLAG -y
# BOB shouldn't be able to register with scholarship
# REGISTER_WITH_SCHOLARSHIP='{"register_with_scholarship":{"dinner_contract":"'$CONTRACT_DINNER'"}}'
# junod tx wasm execute $CONTRACT_DEMO_TOTAL "$REGISTER_WITH_SCHOLARSHIP" --from $BOB $TXFLAG -y