Skip to content

Commit 52413dc

Browse files
Merge pull request #55 from ElrondNetwork/vmtools-and-contracts
Contract additions and `vmtools`
2 parents 8a54a0c + b214dd3 commit 52413dc

16 files changed

Lines changed: 455 additions & 410 deletions

File tree

erdpy/CLI.md

Lines changed: 344 additions & 324 deletions
Large diffs are not rendered by default.

erdpy/CLI.md.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ generate() {
6767
group "Account" "account"
6868
command "Account.Get" "account get"
6969
command "Account.GetTransactions" "account get-transactions"
70-
70+
7171
group "Wallet" "wallet"
72+
command "Wallet.New" "wallet new"
7273
command "Wallet.Derive" "wallet derive"
7374
command "Wallet.Bech32" "wallet bech32"
7475

erdpy/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ def get_defaults() -> Dict[str, Any]:
148148
"proxy": "https://testnet-gateway.elrond.com",
149149
"chainID": "T",
150150
"txVersion": "1",
151-
"dependencies.arwentools.tag": "latest",
151+
"dependencies.vmtools.tag": "latest",
152152
"dependencies.elrond_wasm_rs.tag": "latest",
153-
"dependencies.arwentools.urlTemplate.linux": "https://github.com/ElrondNetwork/arwen-wasm-vm/archive/{TAG}.tar.gz",
154-
"dependencies.arwentools.urlTemplate.osx": "https://github.com/ElrondNetwork/arwen-wasm-vm/archive/{TAG}.tar.gz",
153+
"dependencies.vmtools.urlTemplate.linux": "https://github.com/ElrondNetwork/wasm-vm/archive/{TAG}.tar.gz",
154+
"dependencies.vmtools.urlTemplate.osx": "https://github.com/ElrondNetwork/wasm-vm/archive/{TAG}.tar.gz",
155155
"dependencies.llvm.tag": "v9-19feb",
156156
"dependencies.llvm.urlTemplate.linux": "https://ide.elrond.com/vendor-llvm/{TAG}/linux-amd64.tar.gz?t=19feb",
157157
"dependencies.llvm.urlTemplate.osx": "https://ide.elrond.com/vendor-llvm/{TAG}/darwin-amd64.tar.gz?t=19feb",

erdpy/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VM_TYPE_SYSTEM = "0001"
2-
VM_TYPE_ARWEN = "0500"
2+
VM_TYPE_WASM_VM = "0500"
33
SC_HEX_PUBKEY_PREFIX = "0" * 16
44
SC_HEX_PUBKEY_PREFIX_SYSTEM = SC_HEX_PUBKEY_PREFIX + VM_TYPE_SYSTEM + "0" * 30
5-
SC_HEX_PUBKEY_PREFIX_ARWEN = SC_HEX_PUBKEY_PREFIX + VM_TYPE_ARWEN
5+
SC_HEX_PUBKEY_PREFIX_WASM_VM = SC_HEX_PUBKEY_PREFIX + VM_TYPE_WASM_VM

erdpy/contracts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def deploy(self, owner: Account, arguments: List[Any], gas_price: int, gas_limit
5252
return tx
5353

5454
def prepare_deploy_transaction_data(self, arguments: List[Any]):
55-
tx_data = f"{self.bytecode}@{constants.VM_TYPE_ARWEN}@{self.metadata.to_hex()}"
55+
tx_data = f"{self.bytecode}@{constants.VM_TYPE_WASM_VM}@{self.metadata.to_hex()}"
5656

5757
for arg in arguments:
5858
tx_data += f"@{_prepare_argument(arg)}"

erdpy/dependencies/install.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Dict, List
44

55
from erdpy import config, errors
6-
from erdpy.dependencies.modules import (ArwenToolsModule, DependencyModule,
6+
from erdpy.dependencies.modules import (VMToolsModule, DependencyModule,
77
GolangModule, MclSignerModule,
88
NodejsModule, Rust, StandaloneModule)
99

@@ -12,7 +12,7 @@
1212

1313
def install_module(key: str, tag: str = "", overwrite: bool = False):
1414
if key == 'all':
15-
modules = get_all_deps()
15+
modules = get_all_deps_installable_via_cli()
1616
else:
1717
modules = [get_module_by_key(key)]
1818

@@ -47,7 +47,7 @@ def get_deps_dict() -> Dict[str, DependencyModule]:
4747
def get_all_deps() -> List[DependencyModule]:
4848
return [
4949
StandaloneModule(key="llvm", aliases=["clang", "cpp"]),
50-
ArwenToolsModule(key="arwentools"),
50+
VMToolsModule(key="vmtools"),
5151
Rust(key="rust"),
5252
NodejsModule(key="nodejs", aliases=[]),
5353
StandaloneModule(key="elrond_go", repo_name="elrond-go", organisation="ElrondNetwork"),
@@ -57,6 +57,16 @@ def get_all_deps() -> List[DependencyModule]:
5757
]
5858

5959

60+
def get_all_deps_installable_via_cli() -> List[DependencyModule]:
61+
return [
62+
VMToolsModule(key="vmtools"),
63+
StandaloneModule(key="elrond_go", repo_name="elrond-go", organisation="ElrondNetwork"),
64+
StandaloneModule(key="elrond_proxy_go", repo_name="elrond-proxy-go", organisation="ElrondNetwork"),
65+
MclSignerModule(key="mcl_signer")
66+
]
67+
68+
69+
6070
def get_golang() -> GolangModule:
6171
golang = get_module_by_key('golang')
6272
assert isinstance(golang, GolangModule)

erdpy/dependencies/modules.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,19 @@ def _get_archive_path(self, tag: str) -> Path:
143143
return archive
144144

145145

146-
class ArwenToolsModule(StandaloneModule):
146+
class VMToolsModule(StandaloneModule):
147147
def __init__(self, key: str, aliases: List[str] = None):
148148
if aliases is None:
149149
aliases = list()
150150

151151
super().__init__(key, aliases)
152-
self.repo_name = 'arwen-wasm-vm'
152+
self.repo_name = 'wasm-vm'
153153
self.organisation = 'ElrondNetwork'
154154

155155
def _post_install(self, tag: str):
156156
dependencies.install_module('golang')
157157

158-
self.build_binary(tag, 'arwendebug')
159158
self.build_binary(tag, 'test')
160-
161-
self.make_binary_symlink_in_parent_folder(tag, 'arwendebug', 'arwendebug')
162159
self.make_binary_symlink_in_parent_folder(tag, 'test', 'mandos-test')
163160
self.copy_libwasmer_in_parent_directory(tag)
164161

erdpy/projects/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def run_tests(args: Any):
5858

5959
logger.info("run_tests.project: %s", project)
6060

61-
dependencies.install_module("arwentools")
61+
dependencies.install_module("vmtools")
6262

6363
guards.is_directory(project)
6464
project = load_project(project)

erdpy/projects/project_base.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def build(self, options: Union[Dict[str, Any], None] = None) -> Path:
2626
return self._do_after_build()
2727

2828
def clean(self):
29-
utils.remove_folder(self._get_output_folder())
29+
utils.remove_folder(self.get_output_folder())
3030

3131
def _ensure_dependencies_installed(self):
3232
module_keys = self.get_dependencies()
@@ -42,36 +42,35 @@ def perform_build(self) -> None:
4242
def get_file_wasm(self):
4343
return self.find_file_in_output("*.wasm")
4444

45-
def find_file_globally(self, pattern):
46-
folder = self.directory
47-
return self.find_file_in_folder(folder, pattern)
45+
def find_file_globally(self, pattern: str) -> Path:
46+
return self.find_file_in_folder(self.path, pattern)
4847

49-
def find_file_in_output(self, pattern):
50-
folder = path.join(self.directory, "output")
48+
def find_file_in_output(self, pattern: str) -> Path:
49+
folder = self.path / 'output'
5150
return self.find_file_in_folder(folder, pattern)
5251

53-
def find_file_in_folder(self, folder, pattern):
54-
files = list(Path(folder).rglob(pattern))
52+
def find_file_in_folder(self, folder: Path, pattern: str) -> Path:
53+
files = list(folder.rglob(pattern))
5554

5655
if len(files) == 0:
5756
raise errors.KnownError(f"No file matches pattern [{pattern}].")
5857
if len(files) > 1:
5958
logger.warning(f"More files match pattern [{pattern}]. Will pick first:\n{files}")
6059

61-
file = path.join(folder, files[0])
60+
file = folder / files[0]
6261
return Path(file).resolve()
6362

6463
def _do_after_build(self) -> Path:
6564
raise NotImplementedError()
6665

67-
def _copy_to_output(self, source: str, destination: str = None) -> Path:
68-
output_folder = self._get_output_folder()
66+
def _copy_to_output(self, source: Path, destination: str = None) -> Path:
67+
output_folder = self.get_output_folder()
6968
utils.ensure_folder(output_folder)
7069
destination = path.join(output_folder, destination) if destination else output_folder
71-
output_wasm_file = shutil.copy(source, destination)
70+
output_wasm_file = shutil.copy(str(source), destination)
7271
return Path(output_wasm_file)
7372

74-
def _get_output_folder(self):
73+
def get_output_folder(self):
7574
return path.join(self.directory, "output")
7675

7776
def get_bytecode(self):
@@ -97,9 +96,9 @@ def default_config(self):
9796
return dict()
9897

9998
def run_tests(self, tests_directory: str, wildcard: str = ""):
100-
arwentools = cast(StandaloneModule, dependencies.get_module_by_key("arwentools"))
101-
tool_env = arwentools.get_env()
102-
tool = path.join(arwentools.get_parent_directory(), "mandos-test")
99+
vmtools = cast(StandaloneModule, dependencies.get_module_by_key("vmtools"))
100+
tool_env = vmtools.get_env()
101+
tool = path.join(vmtools.get_parent_directory(), "mandos-test")
103102
test_folder = path.join(self.directory, tests_directory)
104103

105104
if not wildcard:

erdpy/projects/project_clang.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import logging
2-
import os
32
import subprocess
43
from os import path
54
from pathlib import Path
65

6+
from typing import List
7+
78
from erdpy import dependencies, errors, myprocess, utils
89
from erdpy.projects.project_base import Project
910

@@ -135,9 +136,9 @@ def ensure_source_files(self):
135136

136137
self.config['source_files'] = source_files
137138

138-
def get_exported_functions(self):
139+
def get_exported_functions(self) -> List[str]:
139140
file_export = self.find_file_globally('*.export')
140-
lines = utils.read_lines(file_export)
141+
lines = utils.read_lines(str(file_export))
141142
return lines
142143

143144
def default_config(self):

0 commit comments

Comments
 (0)