Skip to content

Commit 58eb413

Browse files
committed
Fix docker usage in contract deploy
1 parent 2911e22 commit 58eb413

File tree

5 files changed

+54
-33
lines changed

5 files changed

+54
-33
lines changed

.github/scripts/run_e2e_test.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fi
113113

114114
if [[ -n "${ADDER:-}" ]]; then
115115
ARGS+=(-e "ADDER=${ADDER}")
116-
ARGS+=(-e "ADDER_METADATA=/contracts/adder/target/ink/metadata.json")
116+
ARGS+=(-e "ADDER_METADATA=/contracts/adder/target/ink/adder.json")
117117
fi
118118

119119
if [[ -n "${BUTTON_GAME_METADATA:-}" ]]; then
@@ -123,12 +123,12 @@ if [[ -n "${BUTTON_GAME_METADATA:-}" ]]; then
123123
ARGS+=(-e "SIMPLE_DEX=${SIMPLE_DEX}")
124124
ARGS+=(-e "WRAPPED_AZERO=${WRAPPED_AZERO}")
125125
ARGS+=(-e "RUST_LOG=${RUST_LOG}")
126-
ARGS+=(-e "BUTTON_GAME_METADATA=/contracts/button/target/ink/metadata.json")
127-
ARGS+=(-e "TICKET_TOKEN_METADATA=/contracts/ticket_token/target/ink/metadata.json")
128-
ARGS+=(-e "REWARD_TOKEN_METADATA=/contracts/game_token/target/ink/metadata.json")
129-
ARGS+=(-e "MARKETPLACE_METADATA=/contracts/marketplace/target/ink/metadata.json")
130-
ARGS+=(-e "SIMPLE_DEX_METADATA=/contracts/simple_dex/target/ink/metadata.json")
131-
ARGS+=(-e "WRAPPED_AZERO_METADATA=/contracts/wrapped_azero/target/ink/metadata.json")
126+
ARGS+=(-e "BUTTON_GAME_METADATA=/contracts/button/target/ink/button.json")
127+
ARGS+=(-e "TICKET_TOKEN_METADATA=/contracts/ticket_token/target/ink/ticket_token.json")
128+
ARGS+=(-e "REWARD_TOKEN_METADATA=/contracts/game_token/target/ink/game_token.json")
129+
ARGS+=(-e "MARKETPLACE_METADATA=/contracts/marketplace/target/ink/marketplace.json")
130+
ARGS+=(-e "SIMPLE_DEX_METADATA=/contracts/simple_dex/target/ink/simple_dex.json")
131+
ARGS+=(-e "WRAPPED_AZERO_METADATA=/contracts/wrapped_azero/target/ink/wrapped_azero.json")
132132
fi
133133

134134
if [[ -n "${OUT_LATENCY:-}" ]]; then

.github/workflows/e2e-tests-main-devnet.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,6 @@ jobs:
533533
- name: Checkout source code
534534
uses: actions/checkout@v2
535535

536-
- name: Install rust-src
537-
working-directory: ./contracts
538-
run: rustup component add rust-src
539-
540536
- name: Run e2e test
541537
uses: ./.github/actions/run-e2e-test
542538
with:
@@ -552,13 +548,6 @@ jobs:
552548
- name: Checkout source code
553549
uses: actions/checkout@v2
554550

555-
- name: Install cargo-contract
556-
run: cargo install cargo-contract --version 2.0.1
557-
558-
- name: Install rust-src
559-
working-directory: ./contracts
560-
run: rustup component add rust-src
561-
562551
- name: Run e2e test
563552
uses: ./.github/actions/run-e2e-test
564553
with:

contracts/adder/deploy.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
#!/bin/bash
22

3-
set -euo pipefail
3+
set -euox pipefail
44

55
NODE_URL="${NODE_URL:-ws://localhost:9944}"
66
AUTHORITY="${AUTHORITY:-//Alice}"
77

8-
function ink-build() {
9-
docker run \
8+
function run_ink_builder() {
9+
docker start ink_builder 1>&2 || docker run \
1010
--network host \
11-
-v ${PWD}:/code \
11+
-v "${PWD}/../..:/code" \
12+
-u "$(id -u):$(id -g)" \
13+
--name ink_builder \
1214
--platform linux/amd64 \
13-
--rm public.ecr.aws/p6e8q1z1/ink-dev:0.1.0 "$@"
15+
--detach \
16+
--rm public.ecr.aws/p6e8q1z1/ink-dev:1.0.0 sleep 1d 1>&2
1417
}
1518

16-
ink-build cargo contract build --release --quiet 1>&2
19+
function ink_build() {
20+
docker exec \
21+
-u "$(id -u):$(id -g)" \
22+
-w "/code/contracts/adder" \
23+
ink_builder "$@"
24+
}
25+
26+
run_ink_builder
27+
ink_build rustup target add wasm32-unknown-unknown
28+
ink_build rustup component add rust-src
29+
ink_build cargo contract build --release --quiet 1>&2
1730

1831
export ADDER
1932

2033
ADDER=$(
21-
ink-build cargo contract instantiate --url "$NODE_URL" --suri "$AUTHORITY" --skip-confirm --output-json \
34+
ink_build cargo contract instantiate --url "$NODE_URL" --suri "$AUTHORITY" --skip-confirm --output-json \
2235
| jq -r ".contract"
2336
)
2437
echo "$ADDER"

contracts/scripts/deploy.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
#!/bin/bash
22

3-
set -euo pipefail
3+
set -euox pipefail
44

55
# --- FUNCTIONS
66

7+
function run_ink_builder() {
8+
docker start ink_builder || docker run \
9+
--network host \
10+
-v "${PWD}:/code" \
11+
-u "$(id -u):$(id -g)" \
12+
--name ink_builder \
13+
--platform linux/amd64 \
14+
--detach \
15+
--rm public.ecr.aws/p6e8q1z1/ink-dev:1.0.0 sleep 1d
16+
}
17+
18+
function ink_build() {
19+
contract_dir=$(basename "${PWD}")
20+
21+
docker exec \
22+
-u "$(id -u):$(id -g)" \
23+
-w "/code/contracts/$contract_dir" \
24+
ink_builder "$@"
25+
}
26+
727
function cargo_contract() {
8-
docker run \
9-
-v "${PWD}:/code" \
10-
--platform linux/amd64 \
11-
--rm -it cardinal-cryptography/ink-dev:latest \
12-
--network host \
13-
cargo contract "$@"
28+
ink_build cargo contract "$@"
1429
}
1530

1631
function upload_contract {
@@ -234,7 +249,11 @@ CONTRACTS_PATH=$(pwd)/contracts
234249

235250
# --- COMPILE CONTRACTS
236251

252+
run_ink_builder
253+
237254
cd "$CONTRACTS_PATH"/access_control
255+
ink_build rustup target add wasm32-unknown-unknown
256+
ink_build rustup component add rust-src
238257
cargo_contract build --release
239258

240259
cd "$CONTRACTS_PATH"/ticket_token

docker/common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
- CHAIN=/data/chainspec.json
88
- ALLOW_PRIVATE_IPV4=true
99
- DISCOVER_LOCAL=true
10-
- UNIT_CREATION_DELAY=50
10+
- UNIT_CREATION_DELAY=300
1111
volumes:
1212
- ./data/:/data/
1313

0 commit comments

Comments
 (0)