ApeWorX / ape-ganache

Ganache network provider plugin for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
4 stars 6 forks source link

incorrect mnemonic and test_accounts has no initial balance #5

Closed Yaiba closed 1 year ago

Yaiba commented 2 years ago

Environment information

$ ape --version
0.4.5

$ ape plugins list
ganache     0.4.0a1

What went wrong?

$ cat ape-config.yaml
test:
  mnemonic: test test test test test test test test test test test junk
  number_of_accounts: 5

Using ape console by ape console --network ethereum:local:ganache --verbosity DEBUG.

  1. the mnemonic ganache used to generate test_account is not what's configured in ape-config.yaml, below is the debug info when console starts:
DEBUG: HD Wallet
DEBUG: ==================
DEBUG: Mnemonic:      night crater logic spread endless aim vehicle bulb draw humble require equal
DEBUG: Base HD Path:  m/44'/60'/0'/0/{account_index}
  1. accounts.test_accounts generate from ape-config.yaml has no balance
In [1]: accounts.test_accounts[0]
Out[1]: <TestAccount 0x1e59ce931B4CFea3fe4B875411e280e173cB7A9C>

In [2]: accounts.test_accounts[0].balance
Out[2]: 0

How can it be fixed?

These two problems could be fixed by changing the ganache command line args, now it uses --wallet.seed {MNEMONIC}, which is wrong. The correct args should be --wallet.mnemonic {MNEMONIC} --wallet.hdPath m/44'/60'/0' Set --wallet.hdPath m/44'/60'/0' is necessary, because ganache's default is m/44'/60'/0'/0, which is different from eth-tester and ape-foundry