mm-eth 0.4.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mm_eth-0.4.0 → mm_eth-0.4.1}/PKG-INFO +1 -1
- {mm_eth-0.4.0 → mm_eth-0.4.1}/pyproject.toml +1 -1
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/account.py +11 -11
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cli.py +8 -5
- {mm_eth-0.4.0/src/mm_eth/cli/cmd → mm_eth-0.4.1/src/mm_eth/cli/cmd/wallet}/mnemonic_cmd.py +4 -4
- mm_eth-0.4.1/tests/cli/cmd/__init__.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_account.py +9 -1
- {mm_eth-0.4.0 → mm_eth-0.4.1}/uv.lock +1 -1
- {mm_eth-0.4.0 → mm_eth-0.4.1}/.gitignore +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/README.txt +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/dict.dic +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/justfile +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/__init__.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/abi.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/anvil.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/__init__.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/calcs.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cli_utils.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/__init__.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/balance_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/balances_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/call_contract_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/deploy_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/encode_input_data_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/example_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/node_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/rpc_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/send_contract_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/solc_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/token_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/transfer_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/tx_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/vault_cmd.py +0 -0
- {mm_eth-0.4.0/tests → mm_eth-0.4.1/src/mm_eth/cli/cmd/wallet}/__init__.py +0 -0
- {mm_eth-0.4.0/src/mm_eth/cli/cmd → mm_eth-0.4.1/src/mm_eth/cli/cmd/wallet}/private_key_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/examples/balances.toml +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/examples/call_contract.toml +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/examples/transfer.toml +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/print_helpers.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/rpc_helpers.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/validators.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/constants.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/deploy.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/ens.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/erc20.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/ethernodes.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/json_encoder.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/py.typed +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/rpc.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/solc.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/tx.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/utils.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/vault.py +0 -0
- {mm_eth-0.4.0/tests/cli → mm_eth-0.4.1/tests}/__init__.py +0 -0
- {mm_eth-0.4.0/tests/cli/cmd → mm_eth-0.4.1/tests/cli}/__init__.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_balance_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_mnemonic_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_node_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_private_key_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_solc_cmd.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/test_calcs.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/conftest.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/contracts/ERC20.sol +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/contracts/abi/ERC20.json +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_abi.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_ethernodes.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_rpc.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_tx.py +0 -0
- {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_utils.py +0 -0
|
@@ -13,9 +13,12 @@ Account.enable_unaudited_hdwallet_features()
|
|
|
13
13
|
|
|
14
14
|
key_api = KeyAPI()
|
|
15
15
|
|
|
16
|
+
DEFAULT_DERIVATION_PATH = "m/44'/60'/0'/0/{i}"
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
@dataclass
|
|
18
|
-
class
|
|
20
|
+
class DerivedAccount:
|
|
21
|
+
index: int
|
|
19
22
|
path: str
|
|
20
23
|
address: str
|
|
21
24
|
private_key: str
|
|
@@ -30,18 +33,15 @@ def generate_mnemonic(num_words: int = 24) -> str:
|
|
|
30
33
|
return mnemonic.generate(num_words=num_words)
|
|
31
34
|
|
|
32
35
|
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
limit: int = 12,
|
|
38
|
-
) -> list[NewAccount]:
|
|
39
|
-
result: list[NewAccount] = []
|
|
36
|
+
def derive_accounts(mnemonic: str, passphrase: str, derivation_path: str, limit: int) -> list[DerivedAccount]:
|
|
37
|
+
if "{i}" not in derivation_path:
|
|
38
|
+
raise ValueError("derivation_path must contain {i}, for example: " + DEFAULT_DERIVATION_PATH)
|
|
39
|
+
result: list[DerivedAccount] = []
|
|
40
40
|
for i in range(limit):
|
|
41
|
-
path =
|
|
42
|
-
acc = Account.from_mnemonic(mnemonic
|
|
41
|
+
path = derivation_path.replace("{i}", str(i))
|
|
42
|
+
acc = Account.from_mnemonic(mnemonic, passphrase, path)
|
|
43
43
|
private_key = acc.key.to_0x_hex().lower()
|
|
44
|
-
result.append(
|
|
44
|
+
result.append(DerivedAccount(i, path, acc.address, private_key))
|
|
45
45
|
return result
|
|
46
46
|
|
|
47
47
|
|
|
@@ -5,6 +5,8 @@ from typing import Annotated
|
|
|
5
5
|
import typer
|
|
6
6
|
from mm_std import PrintFormat, print_plain
|
|
7
7
|
|
|
8
|
+
from mm_eth.account import DEFAULT_DERIVATION_PATH
|
|
9
|
+
|
|
8
10
|
from . import cli_utils
|
|
9
11
|
from .cmd import (
|
|
10
12
|
balance_cmd,
|
|
@@ -13,9 +15,7 @@ from .cmd import (
|
|
|
13
15
|
deploy_cmd,
|
|
14
16
|
encode_input_data_cmd,
|
|
15
17
|
example_cmd,
|
|
16
|
-
mnemonic_cmd,
|
|
17
18
|
node_cmd,
|
|
18
|
-
private_key_cmd,
|
|
19
19
|
rpc_cmd,
|
|
20
20
|
send_contract_cmd,
|
|
21
21
|
solc_cmd,
|
|
@@ -29,6 +29,7 @@ from .cmd.call_contract_cmd import CallContractCmdParams
|
|
|
29
29
|
from .cmd.deploy_cmd import DeployCmdParams
|
|
30
30
|
from .cmd.send_contract_cmd import SendContractCmdParams
|
|
31
31
|
from .cmd.transfer_cmd import TransferCmdParams
|
|
32
|
+
from .cmd.wallet import mnemonic_cmd, private_key_cmd
|
|
32
33
|
|
|
33
34
|
app = typer.Typer(no_args_is_help=True, pretty_exceptions_enable=False, add_completion=False)
|
|
34
35
|
|
|
@@ -74,9 +75,10 @@ def node_command(
|
|
|
74
75
|
@wallet_app.command(name="mnemonic", help="Generate eth accounts based on a mnemonic")
|
|
75
76
|
def mnemonic_command( # nosec
|
|
76
77
|
mnemonic: Annotated[str, typer.Option("--mnemonic", "-m")] = "",
|
|
77
|
-
passphrase: Annotated[str, typer.Option("--passphrase", "-
|
|
78
|
+
passphrase: Annotated[str, typer.Option("--passphrase", "-p")] = "",
|
|
78
79
|
print_path: bool = typer.Option(False, "--print_path"),
|
|
79
|
-
|
|
80
|
+
derivation_path: Annotated[str, typer.Option("--path")] = DEFAULT_DERIVATION_PATH,
|
|
81
|
+
words: int = typer.Option(12, "--words", "-w", help="Number of mnemonic words"),
|
|
80
82
|
limit: int = typer.Option(10, "--limit", "-l"),
|
|
81
83
|
save_file: str = typer.Option("", "--save", "-s", help="Save private keys to a file"),
|
|
82
84
|
) -> None:
|
|
@@ -85,7 +87,8 @@ def mnemonic_command( # nosec
|
|
|
85
87
|
passphrase=passphrase,
|
|
86
88
|
print_path=print_path,
|
|
87
89
|
limit=limit,
|
|
88
|
-
|
|
90
|
+
words=words,
|
|
91
|
+
derivation_path=derivation_path,
|
|
89
92
|
save_file=save_file,
|
|
90
93
|
)
|
|
91
94
|
|
|
@@ -3,18 +3,18 @@ from typing import Any
|
|
|
3
3
|
|
|
4
4
|
from mm_std import print_json
|
|
5
5
|
|
|
6
|
-
from mm_eth.account import
|
|
6
|
+
from mm_eth.account import derive_accounts, generate_mnemonic
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def run(mnemonic: str, passphrase: str,
|
|
9
|
+
def run(mnemonic: str, passphrase: str, words: int, derivation_path: str, limit: int, print_path: bool, save_file: str) -> None: # nosec
|
|
10
10
|
result: dict[str, Any] = {}
|
|
11
11
|
if not mnemonic:
|
|
12
|
-
mnemonic = generate_mnemonic()
|
|
12
|
+
mnemonic = generate_mnemonic(num_words=words)
|
|
13
13
|
result["mnemonic"] = mnemonic
|
|
14
14
|
if passphrase:
|
|
15
15
|
result["passphrase"] = passphrase
|
|
16
16
|
result["accounts"] = []
|
|
17
|
-
for acc in
|
|
17
|
+
for acc in derive_accounts(mnemonic=mnemonic, passphrase=passphrase, limit=limit, derivation_path=derivation_path):
|
|
18
18
|
new_account = {"address": acc.address, "private": acc.private_key}
|
|
19
19
|
if print_path:
|
|
20
20
|
new_account["path"] = acc.path
|
|
File without changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from mm_eth import account
|
|
2
|
+
from mm_eth.account import DEFAULT_DERIVATION_PATH
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
def test_generate_mnemonic():
|
|
@@ -8,7 +9,14 @@ def test_generate_mnemonic():
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def test_generate_accounts():
|
|
11
|
-
|
|
12
|
+
mnemonic = "tuition skin amateur sail oak bone panel concert horse need panel balance"
|
|
13
|
+
passphrase = "pass-secret"
|
|
14
|
+
res = account.derive_accounts(mnemonic, passphrase, DEFAULT_DERIVATION_PATH, 7)
|
|
15
|
+
assert len(res) == 7
|
|
16
|
+
assert res[3].index == 3
|
|
17
|
+
assert res[3].path == "m/44'/60'/0'/0/3"
|
|
18
|
+
assert res[3].address == "0x2F9e1b9f4D11756E84d4b6D2f6B107FA37feB701"
|
|
19
|
+
assert res[3].private_key == "0x7b222a59ac8496b4f1f623bc86d15e889af8406f796037888ddee1290b933183"
|
|
12
20
|
|
|
13
21
|
|
|
14
22
|
def test_to_checksum_address():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mm_eth-0.4.0/src/mm_eth/cli/cmd → mm_eth-0.4.1/src/mm_eth/cli/cmd/wallet}/private_key_cmd.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|