Skip to content

Commit 0ba55cc

Browse files
Merge pull request #57 from ElrondNetwork/development
Prepare version 1.0.21
2 parents bf2e978 + eeb885b commit 0ba55cc

38 files changed

Lines changed: 2840 additions & 542 deletions

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include erdpy/projects/*.txt
22
include erdpy/projects/*.json
3+
include erdpy/wallet/*.txt
34

45
include erdpy/testnet/wallets/users/*.pem
56
include erdpy/testnet/wallets/users/*.json

erdpy/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes will be documented in this file.
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
## [1.0.21] - 01.11.2021
8+
- New command `erdpy wallet new`, which generates a new wallet mnemonic and optionally saves it to JSON or PEM
9+
- Add support for Rust contract `meta` crates
10+
- Update reference to the renamed VM repository (VM dependency is now named `vmtools`)
11+
- Change `erdpy deps install all` to avoid installing / overwriting non-repository dependencies, e.g. Rust, LLVM, Go
12+
- Update help strings and `CLI.md`
13+
714
## [1.0.20] - 26.10.2021
815
- Bugfix by [phanletrunghieu](https://github.com/phanletrunghieu): use $PATH in `erdpy-up`
916
- Bugfix by [x2ocoder](https://github.com/x2ocoder): add missing `enable_epochs` configurations

erdpy/CLI.md

Lines changed: 347 additions & 326 deletions
Large diffs are not rendered by default.

erdpy/CLI.md.sh

Lines changed: 4 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

@@ -117,3 +118,5 @@ generate() {
117118
command "Data.Store" "data store"
118119
command "Data.Load" "data load"
119120
}
121+
122+
generate

erdpy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.20"
1+
__version__ = "1.0.21"

erdpy/accounts.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def generate_accounts(self, count):
2727
self.generate_account(i)
2828

2929
def generate_account(self, name):
30-
seed, pubkey = generate_pair()
30+
secret_key, pubkey = generate_pair()
3131
address = Address(pubkey).bech32()
3232

3333
pem_file = f"{name}_{address}.pem"
3434
pem_file = path.join(self.folder, pem_file)
35-
pem.write(pem_file, seed, pubkey, name=f"{name}:{address}")
35+
pem.write(pem_file, secret_key, pubkey, name=f"{name}:{address}")
3636

3737
def get_all(self):
3838
accounts = []
@@ -59,24 +59,24 @@ def __init__(self,
5959
self.ledger = ledger
6060

6161
if self.pem_file:
62-
seed, pubkey = pem.parse(self.pem_file, self.pem_index)
63-
self.private_key_seed = seed.hex()
62+
secret_key, pubkey = pem.parse(self.pem_file, self.pem_index)
63+
self.secret_key = secret_key.hex()
6464
self.address = Address(pubkey)
6565
elif key_file and pass_file:
6666
password = get_password(pass_file)
67-
address_from_key_file, seed = load_from_key_file(key_file, password)
68-
self.private_key_seed = seed.hex()
67+
address_from_key_file, secret_key = load_from_key_file(key_file, password)
68+
self.secret_key = secret_key.hex()
6969
self.address = Address(address_from_key_file)
7070

7171
def sync_nonce(self, proxy: Any):
7272
logger.info("Account.sync_nonce()")
7373
self.nonce = proxy.get_account_nonce(self.address)
7474
logger.info(f"Account.sync_nonce() done: {self.nonce}")
7575

76-
def get_seed(self) -> bytes:
76+
def get_secret_key(self) -> bytes:
7777
if self.ledger:
7878
raise LedgerError("cannot get seed from a Ledger account")
79-
return unhexlify(self.private_key_seed)
79+
return unhexlify(self.secret_key)
8080

8181

8282
class Address(IAddress):

erdpy/cli_wallet.py

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from erdpy.wallet.keyfile import save_to_key_file
2+
from erdpy.wallet.core import generate_mnemonic
13
import logging
4+
import getpass
5+
from pathlib import Path
26
from typing import Any, List
37

4-
from erdpy import cli_shared, wallet
8+
from erdpy import cli_shared, wallet, utils
59
from erdpy.accounts import Account, Address
610
from erdpy.wallet import pem
711

@@ -12,10 +16,24 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
1216
parser = cli_shared.add_group_subparser(
1317
subparsers,
1418
"wallet",
15-
"Derive private key from mnemonic, bech32 address helpers etc."
19+
"Create wallet, derive secret key from mnemonic, bech32 address helpers etc."
1620
)
1721
subparsers = parser.add_subparsers()
1822

23+
sub = cli_shared.add_command_subparser(
24+
subparsers,
25+
"wallet",
26+
"new",
27+
"Create a new wallet and print its mnemonic; optionally save as password-protected JSON (recommended) or PEM (not recommended)"
28+
)
29+
sub.add_argument("--json",
30+
help="whether to create a json key file", action="store_true", default=False)
31+
sub.add_argument("--pem",
32+
help="whether to create a pem key file", action="store_true", default=False)
33+
sub.add_argument("--output-path",
34+
help="the output path and base file name for the generated wallet files (default: %(default)s)", type=str, default="./wallet")
35+
sub.set_defaults(func=new_wallet)
36+
1937
sub = cli_shared.add_command_subparser(
2038
subparsers,
2139
"wallet",
@@ -69,19 +87,42 @@ def setup_parser(args: List[str], subparsers: Any) -> Any:
6987
return subparsers
7088

7189

90+
def new_wallet(args: Any):
91+
mnemonic = generate_mnemonic()
92+
print(f"Mnemonic: {mnemonic}")
93+
secret_key, pubkey = wallet.derive_keys(mnemonic)
94+
if args.pem:
95+
pem_file = prepare_file(args.output_path, ".pem")
96+
address = Address(pubkey)
97+
pem.write(pem_file, secret_key, pubkey, name=address.bech32())
98+
logger.info(f"Pem wallet generated: {pem_file}")
99+
if args.json:
100+
json_file = prepare_file(args.output_path, ".json")
101+
password = getpass.getpass("Enter a new password:")
102+
save_to_key_file(json_file, secret_key, pubkey, password)
103+
logger.info(f"Json wallet generated: {json_file}")
104+
105+
106+
def prepare_file(output_path: str, suffix: str) -> Path:
107+
base_path = Path(output_path)
108+
utils.ensure_folder(base_path.parent)
109+
file_path = base_path.with_suffix(suffix)
110+
return utils.uniquify(file_path)
111+
112+
72113
def generate_pem(args: Any):
73114
pem_file = args.pem
74115
mnemonic = args.mnemonic
75116
index = args.index
76117

77-
seed, pubkey = wallet.generate_pair()
118+
secret_key, pubkey = wallet.generate_pair()
78119
if mnemonic:
79120
mnemonic = input("Enter mnemonic:\n")
80121
mnemonic = mnemonic.strip()
81-
seed, pubkey = wallet.derive_keys(mnemonic, index)
122+
secret_key, pubkey = wallet.derive_keys(mnemonic, index)
82123

83124
address = Address(pubkey)
84-
pem.write(pem_file, seed, pubkey, name=address.bech32())
125+
pem.write(pem_file, secret_key, pubkey, name=address.bech32())
85126
logger.info(f"Created PEM file [{pem_file}] for [{address.bech32()}]")
86127

87128

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)}"

0 commit comments

Comments
 (0)