fix: add getpass
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
William Luke 2022-03-14 15:48:36 +03:00
parent 67f947a9af
commit 47a9b259ae
7 changed files with 78 additions and 14 deletions

1
.gitignore vendored
View File

@ -8,4 +8,5 @@ build/
contracts contracts
*.egg *.egg
.coverage .coverage
deployments/
dist/ dist/

View File

@ -8,15 +8,20 @@ token deployments.
```shell ```shell
pip install --extra-index-url https://pip.grassrootseconomics.net cic[eth] pip install --extra-index-url https://pip.grassrootseconomics.net cic[eth]
``` ```
## Setup
### Importing a wallet from metamask
- Export the accounts private key [Instructions](https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-Export-an-Account-Private-Key)
- Save the private key to a file
- Run `eth-keyfile -k <file> > ~/.config/cic/keystore/keyfile.json`
## Usage ## Usage
### Using the wizard ### Using the wizard
``` ```
# Local # Local
cic wizard ./somewhere -c ./config/dev-docker cic wizard ./somewhere -c ./config/docker
# Test Net # Test Net
cic wizard ./somewhere -c ./config/test-net cic wizard ./somewhere -c ./config/testnet
``` ```
### Modular ### Modular
@ -61,8 +66,9 @@ below are limited to the context of the EVM.
``` ```
```bash ```bash
poetry run cic wizard ./somewhere -c ./config/dev-docker poetry run cic wizard ./somewhere -c ./config/docker
``` ```
### Tests ### Tests
``` ```

View File

@ -1,17 +1,19 @@
# standard imports # standard imports
import stat from getpass import getpass
import os
import logging import logging
import os
import stat
# external imports # external imports
from funga.eth.keystore.dict import DictKeystore from funga.eth.keystore.dict import DictKeystore
from funga.eth.signer import EIP155Signer from funga.eth.signer import EIP155Signer
from chainlib.eth.cli import Rpc
from chainlib.cli import Wallet from chainlib.cli import Wallet
from chainlib.eth.cli import Rpc
# local imports # local imports
from cic.keystore import KeystoreDirectory from cic.keystore import KeystoreDirectory
logg = logging.getLogger(__name__) logg = logging.getLogger(__name__)
@ -22,7 +24,8 @@ class EthKeystoreDirectory(DictKeystore, KeystoreDirectory):
""" """
def get_passphrase():
return getpass('Enter passphrase: ')
def parse_adapter(config, signer_hint): def parse_adapter(config, signer_hint):
"""Determine and instantiate signer and rpc from configuration. """Determine and instantiate signer and rpc from configuration.
@ -44,7 +47,7 @@ def parse_adapter(config, signer_hint):
if stat.S_ISDIR(st.st_mode): if stat.S_ISDIR(st.st_mode):
logg.debug("signer hint is directory") logg.debug("signer hint is directory")
keystore = EthKeystoreDirectory() keystore = EthKeystoreDirectory()
keystore.process_dir(signer_hint) keystore.process_dir(signer_hint, password_retriever=get_passphrase)
w = Wallet(EIP155Signer, keystore=keystore) w = Wallet(EIP155Signer, keystore=keystore)
signer = EIP155Signer(keystore) signer = EIP155Signer(keystore)
@ -63,6 +66,6 @@ def list_keys(config, signer_hint):
if stat.S_ISDIR(st.st_mode): if stat.S_ISDIR(st.st_mode):
logg.debug("signer hint is directory") logg.debug("signer hint is directory")
keystore = EthKeystoreDirectory() keystore = EthKeystoreDirectory()
keystore.process_dir(signer_hint, default_password=config.get('WALLET_PASSPHRASE', '')) keystore.process_dir(signer_hint, default_password=config.get('WALLET_PASSPHRASE', ''), password_retriever=get_passphrase)
return keystore.list() return keystore.list()

27
config/docker/config.ini Normal file
View File

@ -0,0 +1,27 @@
[cic_core]
meta_writer = cic.writers.KVWriter
attachment_writer = cic.writers.KVWriter
proof_writer = cic.writers.KVWriter
ext_writer = cic.writers.KVWriter
[cic]
registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299
[meta]
url = http://localhost:63380
http_origin =
[rpc]
provider = http://localhost:63545
[auth]
type = gnupg
keyfile_path = /home/will/grassroots/cic-internal-integration/apps/cic-ussd/tests/data/pgp/privatekeys_meta.asc
passphrase = merman
[wallet]
key_file = /home/will/.config/cic/keystore
passphrase =
[chain]
spec = evm:byzantium:8996:bloxberg

View File

@ -8,11 +8,11 @@ ext_writer = cic.writers.KVWriter
registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299 registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299
[meta] [meta]
url = http://localhost:63380 url = http://localhost:8000
http_origin = http_origin =
[rpc] [rpc]
provider = http://localhost:63545 provider = http://localhost:8545
[auth] [auth]
type = gnupg type = gnupg

View File

@ -5,14 +5,14 @@ proof_writer = cic.writers.KVWriter
ext_writer = cic.writers.KVWriter ext_writer = cic.writers.KVWriter
[cic] [cic]
registry_address = 0x86c616fd2f020289d6fd7a98f3bd7539b335c995 registry_address = 0x999487d8B1EC2b2ac9F4a9D1A6D35a24D75D7EF4
[meta] [meta]
url = https://meta.grassecon.net url = https://meta.grassecon.net
http_origin = http_origin =
[rpc] [rpc]
provider = https://rpc.grassecon.net provider = https://rpc.kitabu.grassecon.net
[auth] [auth]
type = gnupg type = gnupg

27
config/testnet/config.ini Normal file
View File

@ -0,0 +1,27 @@
[cic_core]
meta_writer = cic.writers.KVWriter
attachment_writer = cic.writers.KVWriter
proof_writer = cic.writers.KVWriter
ext_writer = cic.writers.KVWriter
[cic]
registry_address = 0xcf60ebc445b636a5ab787f9e8bc465a2a3ef8299
[meta]
url = http://localhost:6700
http_origin =
[rpc]
provider = https://rpc.grassecon.net
[auth]
type = gnupg
keyfile_path = /home/will/grassroots/cic-internal-integration/apps/cic-ussd/tests/data/pgp/privatekeys_meta.asc
passphrase = merman
[wallet]
key_file = /home/will/grassroots/cic-internal-integration/apps/contract-migration/keystore
passphrase =
[chain]
spec = evm:byzantium:5050:bloxberg