Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Refactor prompt commands to be plugin based #623

Closed
@ixje

Description

@ixje

Rationale:
Currently prompt.py over time evolved into a beast of if/else branches for command handling with several issues such as:

  • Commands present but missing from the help output
  • Commands present but not part of the auto completer
  • Some commands have been extracted to live under /neo/Prompt/Commands/ yet still are dependent on proper integration in prompt.py
  • Most commands are suboptimally covered in automated testing and/or poorly testable
  • Custom commands require patching after every update

Goal:
Turn console commands into a plugin based system that's easily testable without having to run the actual prompt. They can live under /neo/Prompt/Commands/. They should be reusable with another front-end (see the related issue Create more interactive and clean CLI)

Command TODO list

  • quit

  • help

  • show

    • block
    • header {index/hash}
    • tx {hash}
    • mem # returns memory in use and number of buffers
    • nodes # returns connected peers
    • state
    • notifications {block_number or address}
    • account {address} # returns account state
    • asset
      • {assetId} # returns asset state
    • contract
      • {contract hash} # returns contract state
  • config

    • debug-notify {on/off}
    • sc-events {on/off}
    • maxpeers {num_peers}
    • node-requests {reqsize} {queuesize}
    • output
    • vm_log
    • compiler-nep8 {on/off}
  • wallet

    • create
    • open
    • close
    • {verbose}
    • claim (max_coins_to_claim)
    • rebuild {start block}
    • create_addr {number of addresses <= 3}
    • delete_addr {addr}
    • alias {addr} {title}
    • token
      • delete {token_contract_hash}
      • send {token symbol} etc
      • send_from {token symbol} etc
      • approve {token symbol} etc
      • allowance {token symbol} etc
      • mint {token symbol} {mint_to_addr} etc
      • register {addr} etc
      • history {token symbol}
    • unspent (neo/gas)
    • split {addr} {asset} etc
    • send {assetId or name} etc
    • sendmany {number of outgoing tx} etc
    • sign {transaction in JSON format}
    • import
      • nep2
      • wif
      • multisig_addr
      • token
      • contract_addr
      • watch_addr
    • export
      • wif
      • nep2
  • search

    • asset {query}
    • contract {query}

#need a good group command name for development related activities>

  • to be named group
    • build {path/to/file.py} etc
    • load_run {path/to/file.avm} etc
    • testinvoke {contract hash} etc
    • debugstorage {on/off/reset}
    • import contract {path/to/file.avm} etc

TODO various

  • separate presentation from implementation (move execute() implementations to separate functions such that others can call them without having to go through WalletCommand X)
  • after the previous item, make sure console themes still work. This requires "Format Tokens" from the prompt_toolkit package, but it should only be applied when used in the CLI. Meaning; the business logic should not be coupled to a PromptInterface() instance because that's the one who creates the theme tokens. solution idea: supply print function as param.
  • Move wallet commands related to address in its own address group ( alias, create, delete, split)
  • Wallet is becoming huge. Split file into multiple (e.g. based on subgroup)
  • check all command help output and validate consistent use of argument vs parameter.
  • Update readthedocs documentation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions