l00k/devphase

Implement auto-updates to devphase.config.json

HashWarlock opened this issue ยท 10 comments

Description

Add additional properties to the devphase.config.json and add functions to retrieve and edit the config based on different commands executed. This can help with creating/retrieving accounts, contract directory paths, networks to connect to RPCs, etc.

Swanky suite keeps track of the following in the swanky.config.json https://github.com/AstarNetwork/swanky-cli/blob/master/packages/core/src/types/index.ts#L41-L54

  • node: polkadot pallet version, local path, supported Ink
  • accounts array
  • contract records
  • network map

Swanky suite command-utils can be helpful to check as well. https://github.com/AstarNetwork/swanky-cli/blob/master/packages/core/src/lib/command-utils.ts

Devphase does have some similar functions & if we can add the missing capabilities then this enables a cleaner way to manage a Phat Contracts dev environment with commands for:

  • Contract
    • Call
    • New
    • Deploy
  • Account
    • Create
    • List
  • Check
    • Checks the package dependencies, binaries & devphase.config.json file is present
l00k commented

Awesome idea. Todo

l00k commented

First part:

  • node: polkadot pallet version, local path, supported Ink
    It's already implemented in devPhaseOptions.nodeUrl and devPhaseOptions.nodeApiOptions.
    https://github.com/l00k/devphase/blob/master/src/def.ts#L79
    Used: https://github.com/l00k/devphase/blob/master/src/service/api/DevPhase.ts#L60
  • accounts array
    It's already implemented in devPhaseOptions.accountsMnemonic and devPhaseOptions.accountsPaths.
    https://github.com/l00k/devphase/blob/master/src/def.ts#L78
    Used: https://github.com/l00k/devphase/blob/master/src/service/api/DevPhase.ts#L60
  • contract records
    It is auto loaded based on directories.
  • network map
    I don't know what you mean. Please describe ;)
l00k commented

Account management implemented in 0.0.32

First part:

  • node: polkadot pallet version, local path, supported Ink
    It's already implemented in devPhaseOptions.nodeUrl and devPhaseOptions.nodeApiOptions.
    https://github.com/l00k/devphase/blob/master/src/def.ts#L79
    Used: https://github.com/l00k/devphase/blob/master/src/service/api/DevPhase.ts#L60
  • accounts array
    It's already implemented in devPhaseOptions.accountsMnemonic and devPhaseOptions.accountsPaths.
    https://github.com/l00k/devphase/blob/master/src/def.ts#L78
    Used: https://github.com/l00k/devphase/blob/master/src/service/api/DevPhase.ts#L60
  • network map
    I don't know what you mean. Please describe ;)
  • Network Map would be having a mapping of networks and the RPC URL. For instance, Phala Network, Khala Network, Phala PoC5 Testnet. Though this could be not needed.
  • contract records
    It is auto loaded based on directories.
  • What does this mean? How would I need to retrieve the contract to make a call to it? I was thinking that we can be in the base directory of the project and be able to use a command like swanky has & use a command like swanky phala contract call --address <value> -m <value> [-a <value>] [-d] [-g <value>] [-n <value>]
FLAGS
  -a, --args=<value>
  -d, --dry
  -g, --gas=<value>
  -m, --message=<value>  (required)
  -n, --network=<value>  Network name to connect to
  --address=<value>      (required)

Ultimately, the idea is to be able to have a function like getSwankyConfig, so I can access all the current configuration & have functions to retrieve certain information. Here is an example https://github.com/AstarNetwork/swanky-cli/blob/26a19363938d44633e4f1e4b4fff5a363eb3984b/packages/cli/src/commands/contract/call.ts#L42

In the example, the config can retrieve contract deployment info & account info to be able to execute the contract call. There are also commands that can update the Swanky Config like the swanky contract deploy call. An example of this is here https://github.com/AstarNetwork/swanky-cli/blob/26a19363938d44633e4f1e4b4fff5a363eb3984b/packages/cli/src/commands/contract/deploy.ts#L54

l00k commented

0.0.33
Configuration updated.
Network map feature implemented.
Contract commands (except call) implemented

I'm waiting for feedback at current stage

Can there be an option to install the binaries and system contracts without starting the local testnet?
Commands like:

  • yarn devphase stack install
  • yarn devphase stack start
  • yarn devphase stack stop

Update dependencies for @polkadot packages

    "@polkadot/api": "9.9.1",
    "@polkadot/api-contract": "9.9.1",
    "@polkadot/keyring": "10.2.1",
    "@polkadot/util": "10.2.1",
    "@polkadot/util-crypto": "10.2.1",

My other comment would be allow for create accounts and deploy contract to accept arguments or flags instead of interactive CLI. I can make this change if needed.

l00k commented

Migration to oclif finalized in 0.1.1. The rest of commands implemented in 0.1.2.
I'm waiting for your feedback.

l00k commented

About dependencies check (rustup / cargo contract) - I was able to verify list of required dependencies here:
https://wiki.phala.network/en-us/build/developer/run-a-local-development-network/#environment
but now this page is not available so I don't know real dependencies.
Could you provide list?

l00k commented

Done, released in version v0.1.4