mm-eth 0.4.0__py3-none-any.whl → 0.4.1__py3-none-any.whl

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/account.py CHANGED
@@ -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
 
mm_eth/cli/cli.py CHANGED
@@ -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
 
File without changes
@@ -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
@@ -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
  mm_eth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  mm_eth/abi.py,sha256=Qf-QOsR9QexyQM9XWKNeTMkRarIL3XQJbaDbJ8ifMrw,4856
3
- mm_eth/account.py,sha256=VjyWOYX5K9ZgdJsHp_I3m-lJ5g9FDo3OJ3knqUPs_TM,1924
3
+ mm_eth/account.py,sha256=k0MNMatBe0zo1iKZiB_Tq6zyEIo22IncD6ewNUJp3dY,2075
4
4
  mm_eth/anvil.py,sha256=98RCfI7dEpxFBTV6UErYvubWVP3n0ctUFn1--4kZ84U,1603
5
5
  mm_eth/constants.py,sha256=Cy_G-IleBH4gAZ4ok8AGHHlqmdW0ZM7ZldyVpzAfWLs,54
6
6
  mm_eth/deploy.py,sha256=SB3ruY808_5UnG8kHR34uVP66P3zOWZu0ImKD7UUv2s,691
@@ -16,7 +16,7 @@ mm_eth/utils.py,sha256=sSxt9GZEntZlT0RU8ht9Qon875HPhpd-1JjgqUBEfVo,7405
16
16
  mm_eth/vault.py,sha256=h8NyiOQh5YFskh1lZA3KyvnJUnxl9769ME2ChplG0CM,1477
17
17
  mm_eth/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  mm_eth/cli/calcs.py,sha256=cLFTYNAN-I53tUiSg-zFfVr2afjIZPftDDjHj16FBz0,1068
19
- mm_eth/cli/cli.py,sha256=SdfOq4hSI2V8rgbSG0LTXqicE8dmIdLDBfSstSPhDfA,9019
19
+ mm_eth/cli/cli.py,sha256=0UYDtNrCXvJqs836tPxsQHs7yTKjvAGL3qgWiXVhnDU,9208
20
20
  mm_eth/cli/cli_utils.py,sha256=yBIS3dGid75zyxw8crPOQHA4p3Krk5BoA2g01turKmQ,1712
21
21
  mm_eth/cli/print_helpers.py,sha256=yOiOFjTKloumwf07AqNIHQswUo8t0yuT9bpeGBGl60Q,1470
22
22
  mm_eth/cli/rpc_helpers.py,sha256=FMV-QVNM3v9X8H_-DP0hjNRqmm7KOnfzkw9bP17Qbz0,4499
@@ -28,9 +28,7 @@ mm_eth/cli/cmd/call_contract_cmd.py,sha256=RbBPvyUEQ45hQINYDKkx1yWhPygdymVKlRL26
28
28
  mm_eth/cli/cmd/deploy_cmd.py,sha256=0oBp_RZw_DIEtBFRc6QKdAw5oouwwpDIdeXvuyP9xdU,1272
29
29
  mm_eth/cli/cmd/encode_input_data_cmd.py,sha256=9UQ1MKPEFQJ8j_COsP3KGKhwOf9tT3feBezI8vvxTlw,267
30
30
  mm_eth/cli/cmd/example_cmd.py,sha256=o4NTll3fjmspbKjZ0sHGDRHTZ1RcFNHZDi9Ka0VNoDQ,264
31
- mm_eth/cli/cmd/mnemonic_cmd.py,sha256=Mb0H0inSNCa93GEPxGYQi7BnPe11mnLjnspfe7h54I4,972
32
31
  mm_eth/cli/cmd/node_cmd.py,sha256=Ae5yPxxnNiHw3tZcojS7KwNLM4gEfLhsTfhZp_86rqU,1956
33
- mm_eth/cli/cmd/private_key_cmd.py,sha256=Fv_2OLog1h32pIP7PJITwl_pHdy3BXvaDRcXZsxY1xo,241
34
32
  mm_eth/cli/cmd/rpc_cmd.py,sha256=02q82YqgbPezfEBmV_QBCIeNReE7ktkPych8Xr9ann8,2186
35
33
  mm_eth/cli/cmd/send_contract_cmd.py,sha256=JX3L1Dz4CBySfa2Pf87E8grauPu0U6xIyyOus81285Y,7316
36
34
  mm_eth/cli/cmd/solc_cmd.py,sha256=tBpeMdPfGs2iQIMaIJAAhMh1a3KyXHwyninfXPVpsgs,677
@@ -38,10 +36,13 @@ mm_eth/cli/cmd/token_cmd.py,sha256=4y6ZQpLOJ33_iNuKpm9tZXh4RntWhmPUcizgaNNBzaw,1
38
36
  mm_eth/cli/cmd/transfer_cmd.py,sha256=nC1Jiqe6zDJQvK9xVhB8mCbkEB1ZgMZmA393tDnZ1Dw,12176
39
37
  mm_eth/cli/cmd/tx_cmd.py,sha256=PIenXYTT60Z2fqsivpzybCLI2Z_tlcz-asm3B0JLHgI,517
40
38
  mm_eth/cli/cmd/vault_cmd.py,sha256=MOM1CILIaaqown1I-Fgo22ckqIMLtFt8t2D3fWNp798,606
39
+ mm_eth/cli/cmd/wallet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ mm_eth/cli/cmd/wallet/mnemonic_cmd.py,sha256=xE-5Ux9BdYsTZYBy0dMn9jupGhW4ced-AgYscy_wU_4,1007
41
+ mm_eth/cli/cmd/wallet/private_key_cmd.py,sha256=Fv_2OLog1h32pIP7PJITwl_pHdy3BXvaDRcXZsxY1xo,241
41
42
  mm_eth/cli/examples/balances.toml,sha256=i_ALpiEcf8-0TFiUg1cgJhxxfHYeBl9x0b3tnUWjswU,421
42
43
  mm_eth/cli/examples/call_contract.toml,sha256=ZQWK-409V_vLIZ2bsRD5RCWPPzShPz2KJTTRQY4YaGw,248
43
44
  mm_eth/cli/examples/transfer.toml,sha256=HLVpkCNakZFE8qdFdDUoBPk7ZBdfEmk9TLZtooRsGAc,1198
44
- mm_eth-0.4.0.dist-info/METADATA,sha256=WjvTV6bG2379Zk0cJkuMX6xhAlVSi_YeqVhS4IyBFfI,207
45
- mm_eth-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
46
- mm_eth-0.4.0.dist-info/entry_points.txt,sha256=aGhpsozl8NIrkuUcX5fSgURCcDhr3ShUdeTSIrJq4oc,46
47
- mm_eth-0.4.0.dist-info/RECORD,,
45
+ mm_eth-0.4.1.dist-info/METADATA,sha256=aMEeaP5awNBZ0ZhRIxmhTl1jennR_TAdETFamw4F9HU,207
46
+ mm_eth-0.4.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
+ mm_eth-0.4.1.dist-info/entry_points.txt,sha256=aGhpsozl8NIrkuUcX5fSgURCcDhr3ShUdeTSIrJq4oc,46
48
+ mm_eth-0.4.1.dist-info/RECORD,,
File without changes