feat: add interactive deployment and switch to poetry #2

Merged
williamluke merged 19 commits from lum/easy-token-deployment into master 2022-03-16 06:37:49 +01:00
4 changed files with 35 additions and 5 deletions
Showing only changes of commit 556366a933 - Show all commits

View File

@ -60,6 +60,9 @@ below are limited to the context of the EVM.
poetry run cic -h
```
```bash
poetry run cic wizard ./somewhere -c ./config/dev-docker
```
### Tests
```

View File

@ -109,19 +109,32 @@ def generate_contract(
CIC_REGISTRY_ADDRESS: {config.get("CIC_REGISTRY_ADDRESS")}
CHAIN_SPEC: {config.get("CHAIN_SPEC")}
RPC_PROVIDER: {config.get("RPC_PROVIDER")}
AUTH_KEY: {config.get("AUTH_KEY")}
"""
)
for target in targets:
# TODO Clean this up
modname = f"cic.ext.{target}"
cmd_mod = importlib.import_module(modname)
signer_hint = config.get("WALLET_KEY_FILE")
keys = cmd_mod.list_keys(config, signer_hint)
for idx, key in enumerate(keys):
print(f"{idx} - {key} ")
selecting_key = True
while selecting_key:
idx = int(input("Select key: "))
if keys[idx] is not None:
key_account_address = keys[idx]
selecting_key = False
else:
print("Invalid key, try again")
m = importlib.import_module(f"cic.ext.{target}.start")
m.extension_start(
network,
registry_address=config.get("CIC_REGISTRY_ADDRESS"),
chain_spec=ChainSpec.from_chain_str(config.get("CHAIN_SPEC")),
rpc_provider=config.get("RPC_PROVIDER"),
key_account_address=config.get(
"AUTH_KEY"
), # TODO this should come from the wallet keystore
key_account_address=key_account_address
)
network.load()

View File

@ -18,7 +18,7 @@ from giftable_erc20_token import GiftableToken
from hexathon import add_0x, strip_0x
# local imports
from cic.ext.eth.rpc import parse_adapter
from cic.ext.eth.rpc import parse_adapter, list_keys
from cic.extension import Extension

View File

@ -52,3 +52,17 @@ def parse_adapter(config, signer_hint):
rpc.connect_by_config(config)
return (rpc.conn, signer)
# TODO Find a better place for this
def list_keys(config, signer_hint):
keystore = None
if signer_hint is None:
logg.info("signer hint missing")
return None
st = os.stat(signer_hint)
if stat.S_ISDIR(st.st_mode):
logg.debug("signer hint is directory")
keystore = EthKeystoreDirectory()
keystore.process_dir(signer_hint, default_password=config.get('WALLET_PASSPHRASE', ''))
return keystore.list()