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.
Files changed (69) hide show
  1. {mm_eth-0.4.0 → mm_eth-0.4.1}/PKG-INFO +1 -1
  2. {mm_eth-0.4.0 → mm_eth-0.4.1}/pyproject.toml +1 -1
  3. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/account.py +11 -11
  4. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cli.py +8 -5
  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
  6. mm_eth-0.4.1/tests/cli/cmd/__init__.py +0 -0
  7. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_account.py +9 -1
  8. {mm_eth-0.4.0 → mm_eth-0.4.1}/uv.lock +1 -1
  9. {mm_eth-0.4.0 → mm_eth-0.4.1}/.gitignore +0 -0
  10. {mm_eth-0.4.0 → mm_eth-0.4.1}/README.txt +0 -0
  11. {mm_eth-0.4.0 → mm_eth-0.4.1}/dict.dic +0 -0
  12. {mm_eth-0.4.0 → mm_eth-0.4.1}/justfile +0 -0
  13. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/__init__.py +0 -0
  14. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/abi.py +0 -0
  15. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/anvil.py +0 -0
  16. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/__init__.py +0 -0
  17. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/calcs.py +0 -0
  18. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cli_utils.py +0 -0
  19. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/__init__.py +0 -0
  20. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/balance_cmd.py +0 -0
  21. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/balances_cmd.py +0 -0
  22. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/call_contract_cmd.py +0 -0
  23. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/deploy_cmd.py +0 -0
  24. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/encode_input_data_cmd.py +0 -0
  25. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/example_cmd.py +0 -0
  26. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/node_cmd.py +0 -0
  27. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/rpc_cmd.py +0 -0
  28. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/send_contract_cmd.py +0 -0
  29. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/solc_cmd.py +0 -0
  30. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/token_cmd.py +0 -0
  31. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/transfer_cmd.py +0 -0
  32. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/tx_cmd.py +0 -0
  33. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/cmd/vault_cmd.py +0 -0
  34. {mm_eth-0.4.0/tests → mm_eth-0.4.1/src/mm_eth/cli/cmd/wallet}/__init__.py +0 -0
  35. {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
  36. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/examples/balances.toml +0 -0
  37. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/examples/call_contract.toml +0 -0
  38. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/examples/transfer.toml +0 -0
  39. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/print_helpers.py +0 -0
  40. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/rpc_helpers.py +0 -0
  41. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/cli/validators.py +0 -0
  42. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/constants.py +0 -0
  43. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/deploy.py +0 -0
  44. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/ens.py +0 -0
  45. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/erc20.py +0 -0
  46. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/ethernodes.py +0 -0
  47. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/json_encoder.py +0 -0
  48. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/py.typed +0 -0
  49. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/rpc.py +0 -0
  50. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/solc.py +0 -0
  51. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/tx.py +0 -0
  52. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/utils.py +0 -0
  53. {mm_eth-0.4.0 → mm_eth-0.4.1}/src/mm_eth/vault.py +0 -0
  54. {mm_eth-0.4.0/tests/cli → mm_eth-0.4.1/tests}/__init__.py +0 -0
  55. {mm_eth-0.4.0/tests/cli/cmd → mm_eth-0.4.1/tests/cli}/__init__.py +0 -0
  56. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_balance_cmd.py +0 -0
  57. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_mnemonic_cmd.py +0 -0
  58. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_node_cmd.py +0 -0
  59. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_private_key_cmd.py +0 -0
  60. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/cmd/test_solc_cmd.py +0 -0
  61. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/cli/test_calcs.py +0 -0
  62. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/conftest.py +0 -0
  63. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/contracts/ERC20.sol +0 -0
  64. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/contracts/abi/ERC20.json +0 -0
  65. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_abi.py +0 -0
  66. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_ethernodes.py +0 -0
  67. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_rpc.py +0 -0
  68. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_tx.py +0 -0
  69. {mm_eth-0.4.0 → mm_eth-0.4.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-eth
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: mm-crypto-utils>=0.1.5
6
6
  Requires-Dist: typer>=0.15.1
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mm-eth"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  description = ""
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
@@ -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 NewAccount:
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 generate_accounts( # nosec
34
- mnemonic: str,
35
- passphrase: str = "",
36
- path_prefix: str = "m/44'/60'/0'/0",
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 = f"{path_prefix}/{i}"
42
- acc = Account.from_mnemonic(mnemonic=mnemonic, account_path=path, passphrase=passphrase)
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(NewAccount(path, acc.address, private_key))
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", "-pass")] = "",
78
+ passphrase: Annotated[str, typer.Option("--passphrase", "-p")] = "",
78
79
  print_path: bool = typer.Option(False, "--print_path"),
79
- path_prefix: Annotated[str, typer.Option("--path")] = "m/44'/60'/0'/0",
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
- path_prefix=path_prefix,
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 generate_accounts, generate_mnemonic
6
+ from mm_eth.account import derive_accounts, generate_mnemonic
7
7
 
8
8
 
9
- def run(mnemonic: str, passphrase: str, limit: int, print_path: bool, path_prefix: str, save_file: str) -> None: # nosec
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 generate_accounts(mnemonic=mnemonic, passphrase=passphrase, limit=limit, path_prefix=path_prefix):
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
- assert len(account.generate_accounts(account.generate_mnemonic(), limit=17)) == 17
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():
@@ -738,7 +738,7 @@ wheels = [
738
738
 
739
739
  [[package]]
740
740
  name = "mm-eth"
741
- version = "0.4.0"
741
+ version = "0.4.1"
742
742
  source = { editable = "." }
743
743
  dependencies = [
744
744
  { name = "mm-crypto-utils" },
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