Skip to content

Commit 25d3e77

Browse files
Merge pull request #13 from multiversx/update-15
Reference newer tools, update documentation
2 parents 2c8d828 + c36ba71 commit 25d3e77

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

.github/workflows/publish-image-rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
password: ${{ secrets.DOCKER_PASSWORD }}
3535

3636
- name: Build and push
37-
uses: docker/build-push-action@v3
37+
uses: docker/build-push-action@v4
3838
with:
3939
context: ./resources/smart-contracts-rust
4040
push: true
@@ -43,7 +43,7 @@ jobs:
4343
tags: multiversx/devcontainer-smart-contracts-rust:${{ env.VERSION }}
4444

4545
- name: Push to "latest"
46-
uses: docker/build-push-action@v3
46+
uses: docker/build-push-action@v4
4747
with:
4848
context: ./resources/smart-contracts-rust
4949
push: ${{ inputs.latest }}

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export DOCKER_USER=$(id -u):$(id -g)
2727
# Mandatory: run the container as the current user (should be 1000:1000), not as root.
2828
# Suggestion: use a stateless container; remove it after use (--rm).
2929
# Suggestion: map the current directory to "/data" in the container.
30-
export RUN="docker run --user=${DOCKER_USER} --rm -it --volume $(pwd):/data"
30+
export RUN="docker run --network=host --user=${DOCKER_USER} --rm -it --volume $(pwd):/data"
3131
```
3232

3333
Run the container and do a quick inspection:
@@ -36,56 +36,57 @@ Run the container and do a quick inspection:
3636
${RUN} ${IMAGE} whoami
3737
${RUN} ${IMAGE} mxpy --version
3838
${RUN} ${IMAGE} mxpy deps check rust
39+
${RUN} ${IMAGE} sc-meta --version
3940
```
4041

4142
Clone `mx-contracts-rs` locally, then build a few contracts within the container:
4243

4344
```
4445
git clone https://github.com/multiversx/mx-contracts-rs.git --single-branch --depth=1
4546
46-
${RUN} ${IMAGE} mxpy contract build /data/mx-contracts-rs/contracts/adder
47+
${RUN} ${IMAGE} mxpy contract build --path /data/mx-contracts-rs/contracts/adder
4748
stat ./mx-contracts-rs/contracts/adder/output/adder.wasm
4849
49-
${RUN} ${IMAGE} mxpy contract build /data/mx-contracts-rs/contracts/ping-pong-egld
50+
${RUN} ${IMAGE} mxpy contract build --path /data/mx-contracts-rs/contracts/ping-pong-egld
5051
stat ./mx-contracts-rs/contracts/ping-pong-egld/output/ping-pong-egld.wasm
5152
```
5253

53-
Deploy a previously-built smart contract on Testnet:
54+
Deploy a previously-built smart contract on Devnet:
5455

5556
```
5657
${RUN} ${IMAGE} mxpy contract deploy \
5758
--bytecode /data/mx-contracts-rs/contracts/adder/output/adder.wasm \
5859
--arguments 0 \
59-
--pem /home/developer/multiversx-sdk/testwallets/latest/users/frank.pem \
60+
--pem /home/developer/multiversx-sdk/testwallets/latest/users/alice.pem \
6061
--recall-nonce \
6162
--gas-limit 5000000 \
62-
--chain T \
63-
--proxy https://testnet-gateway.multiversx.com \
63+
--chain D \
64+
--proxy https://devnet2-gateway.multiversx.com \
6465
--send
6566
```
6667

6768
Call a function of a previously-deployed smart contract:
6869

6970
```
7071
${RUN} ${IMAGE} mxpy contract call \
71-
erd1qqqqqqqqqqqqqpgq5v3ra8mxjkv6g2pues9tdkkzwmtm9fdht7asp8wtnr \
72+
erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts \
7273
--function "add" \
7374
--arguments 42 \
74-
--pem /home/developer/multiversx-sdk/testwallets/latest/users/frank.pem \
75+
--pem /home/developer/multiversx-sdk/testwallets/latest/users/alice.pem \
7576
--recall-nonce \
7677
--gas-limit 5000000 \
77-
--chain T \
78-
--proxy https://testnet-gateway.multiversx.com \
78+
--chain D \
79+
--proxy https://devnet2-gateway.multiversx.com \
7980
--send
8081
```
8182

8283
Query a smart contract:
8384

8485
```
8586
${RUN} ${IMAGE} mxpy contract query \
86-
erd1qqqqqqqqqqqqqpgq5v3ra8mxjkv6g2pues9tdkkzwmtm9fdht7asp8wtnr \
87+
erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts \
8788
--function "getSum" \
88-
--proxy https://testnet-gateway.multiversx.com
89+
--proxy https://devnet2-gateway.multiversx.com
8990
```
9091

9192
Setup a localnet (make sure to set the `--workdir`, as well), then inspect the generated files (on the mapped volume):
@@ -126,7 +127,7 @@ Resources:
126127
Build the Docker images for local testing:
127128

128129
```
129-
docker build ./resources/smart-contracts-rust -t multiversx/devcontainer-smart-contracts-rust:latest -f ./resources/smart-contracts-rust/Dockerfile
130+
docker build --network=host ./resources/smart-contracts-rust -t multiversx/devcontainer-smart-contracts-rust:latest -f ./resources/smart-contracts-rust/Dockerfile
130131
```
131132

132133
### Test the templates
@@ -137,14 +138,14 @@ cp -R "src/smart-contracts-rust/.devcontainer" "/tmp/test-workspace" && \
137138
code "/tmp/test-workspace/"
138139
```
139140

140-
Then, in VSCode, launch the command `Dev Containers: Rebuild and Reopen in Container`, wait, then inspect the environment (e.g. check version of `mxpy`, `rust`, build the sample smart contracts, verify output of rust-analyzer).
141+
Then, in VSCode, launch the command `Dev Containers: Rebuild and Reopen in Container`, wait, then inspect the environment. For example, check version of `mxpy`, `rust`, `sc-meta`, build the sample smart contracts, verify output of `rust-analyzer`.
141142

142143
### Publish images
143144

144145
Locally:
145146

146147
```
147-
docker build ./resources/smart-contracts-rust -t multiversx/devcontainer-smart-contracts-rust:latest -f ./resources/smart-contracts-rust/Dockerfile
148+
docker build --network=host ./resources/smart-contracts-rust -t multiversx/devcontainer-smart-contracts-rust:latest -f ./resources/smart-contracts-rust/Dockerfile
148149
docker push multiversx/devcontainer-smart-contracts-rust:latest
149150
```
150151

resources/smart-contracts-rust/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ARG USERNAME=developer
44
ARG USER_UID=1000
55
ARG USER_GID=$USER_UID
66

7-
ARG VERSION_MXPY="v7.2.1"
8-
ARG VERSION_RUST="nightly-2023-04-24"
7+
ARG VERSION_MXPY="v8.1.0"
8+
ARG VERSION_RUST="nightly-2023-05-26"
99
ARG VERSION_WASM_OPT="version_112"
1010
ARG VERSION_VMTOOLS="v1.4.60"
1111

@@ -24,7 +24,9 @@ RUN apt-get update && apt-get install -y \
2424
wget \
2525
build-essential \
2626
python3.10 python3-pip \
27-
git && \
27+
git \
28+
pkg-config \
29+
libssl-dev && \
2830
rm -rf /var/lib/apt/lists/*
2931

3032
# Switch to regular user
@@ -53,7 +55,6 @@ ENV CARGO_HOME="${MULTIVERSX}/vendor-rust"
5355
ENV RUSTUP_HOME="${MULTIVERSX}/vendor-rust"
5456

5557
RUN rustup component add rustfmt && rm -rf ${MULTIVERSX}/vendor-rust/registry/*
56-
RUN cargo install multiversx-sc-meta && rm -rf ${MULTIVERSX}/vendor-rust/registry/*
5758

5859
# This command will be executed once the devcontainer is created
5960
COPY "post_create_command.py" "${MULTIVERSX}/devcontainer-resources/"

src/smart-contracts-rust/devcontainer-template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "smart-contracts-rust",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"name": "MultiversX: Smart Contracts Development (Rust)",
55
"description": "Develop smart contracts for MultiversX. Includes Rust, mxpy, VSCode extensions etc.",
66
"documentationURL": "https://github.com/multiversx/mx-template-devcontainers/blob/main/src/smart-contracts-rust",

0 commit comments

Comments
 (0)