Skip to content

Commit 73c745e

Browse files
Update MultiversX SDK: 0.47 => 0.50 (stable Rust) (#269)
* mx-sdk-rs => v0.50.1 * update cargo files * allow reading contract code from mxsc.json files * update test sets * update Dockerfile: install stable Rust * format * Set Version: 0.1.62 --------- Co-authored-by: devops <[email protected]>
1 parent ec47f8a commit 73c745e

File tree

69 files changed

+1273
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1273
-459
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ RUN python3 -m pip install --upgrade pip
3636

3737
RUN wget -O rustup.sh https://sh.rustup.rs && \
3838
chmod +x rustup.sh && \
39-
./rustup.sh --verbose --default-toolchain nightly-2023-12-11 --target wasm32-unknown-unknown -y
39+
./rustup.sh --verbose --target wasm32-unknown-unknown -y
4040

4141
ENV PATH="/home/${USER}/.cargo/bin:${PATH}"
4242

43-
RUN cargo install multiversx-sc-meta --version ~0.47 --locked
43+
RUN cargo install multiversx-sc-meta --version ~0.50 --locked

deps/mx-sdk-rs

Submodule mx-sdk-rs updated 2020 files

kmultiversx/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "kmultiversx"
7-
version = "0.1.61"
7+
version = "0.1.62"
88
description = "Python tools for Elrond semantics"
99
authors = [
1010
"Runtime Verification, Inc. <[email protected]>",

kmultiversx/src/kmultiversx/scenario.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
from pyk.prelude.collections import set_of
1919
from pykwasm.kwasm_ast import KBytes, KInt, KString
2020

21-
from kmultiversx.utils import flatten, kast_to_json_str, krun_config, load_wasm, read_mandos_runtime
21+
from kmultiversx.utils import (
22+
flatten,
23+
kast_to_json_str,
24+
krun_config,
25+
load_wasm,
26+
load_wasm_from_mxsc,
27+
read_mandos_runtime,
28+
)
2229

2330
if TYPE_CHECKING:
2431
from pyk.kast.inner import KInner
@@ -445,7 +452,7 @@ def mandos_to_deploy_tx(tx: dict, filename: str, output_dir: str) -> KInner:
445452
value = mandos_int_to_kint(get_egld_value(tx))
446453
arguments = mandos_arguments_to_klist(tx['arguments'])
447454
gas_limit = mandos_int_to_kint(tx['gasLimit'])
448-
gas_price = mandos_int_to_kint(tx['gasPrice'], default_when_empty=0)
455+
gas_price = mandos_int_to_kint(tx.get('gasPrice', '0'), default_when_empty=0)
449456

450457
code = get_contract_code(tx['contractCode'], filename)
451458
assert isinstance(code, str)
@@ -462,7 +469,7 @@ def mandos_to_call_tx(tx: dict) -> KInner:
462469
function = KWasmString(tx['function'])
463470
arguments = mandos_arguments_to_klist(tx.get('arguments', []))
464471
gas_limit = mandos_int_to_kint(tx['gasLimit'])
465-
gas_price = mandos_int_to_kint(tx['gasPrice'], default_when_empty=0)
472+
gas_price = mandos_int_to_kint(tx.get('gasPrice', '0'), default_when_empty=0)
466473

467474
return KApply('callTx', [sender, to, value, esdt_value, function, arguments, gas_limit, gas_price])
468475

@@ -574,6 +581,9 @@ def file_to_module_decl(filename: str, output_dir: str) -> KInner:
574581
return load_wasm(filename)
575582
if filename[-5:] == '.wast' or filename[-4:] == '.wat':
576583
return wat_file_to_module_decl(filename, output_dir)
584+
if filename[-10:] == '.mxsc.json':
585+
return load_wasm_from_mxsc(filename)
586+
577587
raise ValueError(f'Filetype not yet supported: {filename}')
578588

579589

@@ -602,7 +612,7 @@ def get_external_file_path(test_file: str, rel_path_to_new_file: str) -> str:
602612

603613

604614
def get_contract_code(code: str, filename: str) -> Optional[str]:
605-
if code[0:5] == 'file:':
615+
if code[0:5] in ('file:', 'mxsc:'):
606616
return get_external_file_path(filename, code[5:])
607617
if code == '':
608618
return None

kmultiversx/src/kmultiversx/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
from io import BytesIO
45
from pathlib import Path
56
from typing import TYPE_CHECKING, TypeVar
67

@@ -51,6 +52,14 @@ def load_wasm(filename: str) -> KInner:
5152
return wasm2kast.wasm2kast(f, filename)
5253

5354

55+
def load_wasm_from_mxsc(filename: str) -> KInner:
56+
with open(filename, 'r') as f:
57+
contract_json = json.load(f)
58+
code_hex = contract_json['code']
59+
code_bytes = bytes.fromhex(code_hex)
60+
return wasm2kast.wasm2kast(BytesIO(code_bytes), filename)
61+
62+
5463
def krun_config(krun: KRun, conf: KInner, pipe_stderr: bool = False) -> KInner:
5564
conf_kore = krun.kast_to_kore(conf, sort=GENERATED_TOP_CELL)
5665
res_conf_kore = krun.run_pattern(conf_kore, pipe_stderr=pipe_stderr)

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.61
1+
0.1.62

src/esdt-system-sc/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ publish = false
99
path = "src/esdt_system_sc.rs"
1010

1111
[dependencies.multiversx-sc]
12-
version = "0.43.4"
13-
path = "../../deps/mx-sdk-rs/framework/base"
12+
version = "0.50.1"
1413

1514
[dev-dependencies.multiversx-sc-scenario]
1615
version = "0.43.4"

src/esdt-system-sc/meta/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ publish = false
99
path = ".."
1010

1111
[dependencies.multiversx-sc-meta]
12-
version = "0.43.4"
13-
path = "../../../deps/mx-sdk-rs/framework/meta"
12+
version = "0.50.1"

src/esdt-system-sc/wasm/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ panic = "abort"
1919
path = ".."
2020

2121
[dependencies.multiversx-sc-wasm-adapter]
22-
version = "0.43.4"
23-
path = "../../../deps/mx-sdk-rs/framework/wasm-adapter"
22+
version = "0.50.1"
2423

2524
[workspace]
2625
members = ["."]

src/testapi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
num-bigint = "0.4.2"
1010

1111
[dependencies.multiversx-sc]
12-
version = "0.48.0"
12+
version = "0.50.1"
1313

1414
[lib]
1515
path = "src/testapi.rs"

0 commit comments

Comments
 (0)