Skip to content

Commit ac7b78e

Browse files
Merge pull request #14 from multiversx/update-2024-01-31
Update Rust, mxpy etc.
2 parents 25d3e77 + fdaaeae commit ac7b78e

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Run the container and do a quick inspection:
3535
```
3636
${RUN} ${IMAGE} whoami
3737
${RUN} ${IMAGE} mxpy --version
38-
${RUN} ${IMAGE} mxpy deps check rust
38+
${RUN} ${IMAGE} cargo --version
39+
${RUN} ${IMAGE} rustc --version
3940
${RUN} ${IMAGE} sc-meta --version
4041
```
4142

@@ -44,10 +45,10 @@ Clone `mx-contracts-rs` locally, then build a few contracts within the container
4445
```
4546
git clone https://github.com/multiversx/mx-contracts-rs.git --single-branch --depth=1
4647
47-
${RUN} ${IMAGE} mxpy contract build --path /data/mx-contracts-rs/contracts/adder
48+
${RUN} ${IMAGE} sc-meta all build --path /data/mx-contracts-rs/contracts/adder
4849
stat ./mx-contracts-rs/contracts/adder/output/adder.wasm
4950
50-
${RUN} ${IMAGE} mxpy contract build --path /data/mx-contracts-rs/contracts/ping-pong-egld
51+
${RUN} ${IMAGE} sc-meta all build --path /data/mx-contracts-rs/contracts/ping-pong-egld
5152
stat ./mx-contracts-rs/contracts/ping-pong-egld/output/ping-pong-egld.wasm
5253
```
5354

@@ -61,32 +62,32 @@ ${RUN} ${IMAGE} mxpy contract deploy \
6162
--recall-nonce \
6263
--gas-limit 5000000 \
6364
--chain D \
64-
--proxy https://devnet2-gateway.multiversx.com \
65+
--proxy https://devnet-gateway.multiversx.com \
6566
--send
6667
```
6768

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

7071
```
7172
${RUN} ${IMAGE} mxpy contract call \
72-
erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts \
73+
erd1qqqqqqqqqqqqqpgqr3clh6ghpww5fc4uhwh2amsseuvecswzd8ssxu68s3 \
7374
--function "add" \
7475
--arguments 42 \
7576
--pem /home/developer/multiversx-sdk/testwallets/latest/users/alice.pem \
7677
--recall-nonce \
7778
--gas-limit 5000000 \
7879
--chain D \
79-
--proxy https://devnet2-gateway.multiversx.com \
80+
--proxy https://devnet-gateway.multiversx.com \
8081
--send
8182
```
8283

8384
Query a smart contract:
8485

8586
```
8687
${RUN} ${IMAGE} mxpy contract query \
87-
erd1qqqqqqqqqqqqqpgqfzydqmdw7m2vazsp6u5p95yxz76t2p9rd8ss0zp9ts \
88+
erd1qqqqqqqqqqqqqpgqr3clh6ghpww5fc4uhwh2amsseuvecswzd8ssxu68s3 \
8889
--function "getSum" \
89-
--proxy https://devnet2-gateway.multiversx.com
90+
--proxy https://devnet-gateway.multiversx.com
9091
```
9192

9293
Setup a localnet (make sure to set the `--workdir`, as well), then inspect the generated files (on the mapped volume):

resources/smart-contracts-rust/Dockerfile

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

7-
ARG VERSION_MXPY="v8.1.0"
8-
ARG VERSION_RUST="nightly-2023-05-26"
9-
ARG VERSION_WASM_OPT="version_112"
10-
ARG VERSION_VMTOOLS="v1.4.60"
7+
ARG VERSION_MXPY="v9.4.1"
8+
ARG VERSION_RUST="nightly-2023-12-11"
9+
ARG VERSION_SC_META="0.47.1"
10+
ARG VERSION_WASM_OPT="0.112.0"
11+
ARG VERSION_VMTOOLS="v1.5.24"
1112

1213
# Create the user
1314
RUN groupadd --gid $USER_GID $USERNAME \
@@ -23,7 +24,7 @@ RUN groupadd --gid $USER_GID $USERNAME \
2324
RUN apt-get update && apt-get install -y \
2425
wget \
2526
build-essential \
26-
python3.10 python3-pip \
27+
python3.10 python3-pip python3.10-venv \
2728
git \
2829
pkg-config \
2930
libssl-dev && \
@@ -33,28 +34,29 @@ RUN apt-get update && apt-get install -y \
3334
USER $USERNAME
3435
WORKDIR /home/${USERNAME}
3536

36-
# Create "~/multiversx-sdk"
37-
ENV MULTIVERSX=/home/${USERNAME}/multiversx-sdk
38-
RUN mkdir ${MULTIVERSX}
37+
ENV MULTIVERSX="/home/${USERNAME}/multiversx-sdk"
38+
ENV PATH="/home/${USERNAME}/.local/bin:${PATH}"
39+
ENV PATH="/home/${USERNAME}/.cargo/bin:${PATH}"
40+
ENV PATH="${MULTIVERSX}/vmtools:${PATH}"
41+
42+
# Install pipx
43+
RUN python3 -m pip install --no-cache-dir --user pipx
3944

4045
# Install mxpy
41-
RUN pip3 install --no-cache-dir https://github.com/multiversx/mx-sdk-py-cli/archive/refs/tags/${VERSION_MXPY}.zip
42-
ENV PATH="${MULTIVERSX}:${PATH}"
43-
COPY "mxpy" "${MULTIVERSX}/mxpy"
46+
RUN pipx install multiversx-sdk-cli==${VERSION_MXPY}
4447

4548
# Install rust and other tools
46-
RUN mxpy deps install rust --tag=${VERSION_RUST} && rm -rf ${MULTIVERSX}/vendor-rust/registry/*
47-
RUN mxpy deps install wasm-opt --tag=${VERSION_WASM_OPT} && rm ${MULTIVERSX}/*.tar.gz
48-
RUN mxpy deps install vmtools --tag=${VERSION_VMTOOLS} && rm ${MULTIVERSX}/*.tar.gz && sudo rm -rf ${MULTIVERSX}/golang
49+
RUN mxpy config set "dependencies.rust.tag" ${VERSION_RUST} && \
50+
mxpy config set "dependencies.sc-meta.tag" ${VERSION_SC_META} && \
51+
mxpy config set "dependencies.wasm-opt.tag" ${VERSION_WASM_OPT} && \
52+
mxpy config set "dependencies.vmtools.tag" ${VERSION_VMTOOLS}
53+
RUN mxpy deps install rust && rm -rf /home/${USERNAME}/.cargo/registry/* && rm -rf /home/${USERNAME}/.cargo/git/*
54+
RUN mxpy deps install vmtools && rm ${MULTIVERSX}/*.tar.gz && sudo rm -rf ${MULTIVERSX}/golang
4955

5056
# Install test wallets
5157
RUN mxpy deps install testwallets && rm ${MULTIVERSX}/*.tar.gz
5258

53-
ENV PATH="${MULTIVERSX}/vendor-rust/bin:${MULTIVERSX}/vmtools:${PATH}"
54-
ENV CARGO_HOME="${MULTIVERSX}/vendor-rust"
55-
ENV RUSTUP_HOME="${MULTIVERSX}/vendor-rust"
56-
57-
RUN rustup component add rustfmt && rm -rf ${MULTIVERSX}/vendor-rust/registry/*
59+
RUN rustup component add rustfmt && rm -rf /home/${USERNAME}/.cargo/registry/* && rm -rf /home/${USERNAME}/.cargo/git/*
5860

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

resources/smart-contracts-rust/mxpy

Lines changed: 0 additions & 2 deletions
This file was deleted.

resources/smart-contracts-rust/post_create_command.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
prepare_vscode_settings()
1010
prepare_gitignore()
1111
add_samples()
12-
12+
1313

1414
def prepare_vscode_settings():
1515
vscode_path = Path(".vscode")
@@ -49,8 +49,6 @@ def prepare_gitignore():
4949
**/target/**
5050
**/output/**
5151
**/trace*.scen.json
52-
Cargo.lock
53-
!**/wasm*/Cargo.lock
5452
""")
5553

5654

@@ -63,7 +61,7 @@ def add_samples():
6361

6462
if samples_folder.exists():
6563
return
66-
64+
6765
urllib.request.urlretrieve(archive_url, download_path)
6866
shutil.unpack_archive(download_path, extract_path)
6967
shutil.move(str(extract_path / contracts_in_extract_path), str(samples_folder))

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.6",
3+
"version": "0.2.0",
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)