Skip to content

Commit

Permalink
Prepare test CLI for use in Programs repo (#856)
Browse files Browse the repository at this point in the history
* turn cli into lib

* add changes to store program

* add licence header

* remove testing utils from cargo toml

* update menmoic handling

* update readme

* fix reademe mnemonic

* add changelog
  • Loading branch information
JesseAbram authored May 29, 2024
1 parent 73a5762 commit 52d1723
Show file tree
Hide file tree
Showing 7 changed files with 562 additions and 523 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ At the moment this project **does not** adhere to
### Added
- Add a way to change program modification account ([#843](https://github.com/entropyxyz/entropy-core/pull/843))

### Changed
- Prepare test CLI for use in Programs repo ([#856](https://github.com/entropyxyz/entropy-core/pull/856))

## [0.1.0](https://github.com/entropyxyz/entropy-core/compare/release/v0.0.12...release/v0.1.0) - 2024-05-20

This is the first publicly available version of Entropy 🥳
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions crates/test-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ repository ='https://github.com/entropyxyz/entropy-core'
edition ='2021'

[dependencies]
entropy-testing-utils={ version="0.1.0", path="../testing-utils" }
entropy-client ={ version="0.1.0", path="../client" }
clap ={ version="4.4.6", features=["derive"] }
colored ="2.0.4"
subxt ="0.35.3"
sp-core ="31.0.0"
anyhow ="1.0.86"
tokio ={ version="1.16", features=["macros", "rt-multi-thread", "io-util", "process"] }
hex ="0.4.3"
bincode ="1.3.3"
x25519-dalek ="2.0.1"
sp-runtime ={ version="32.0.0", default-features=false }
entropy-client={ version="0.1.0", path="../client" }
clap ={ version="4.4.6", features=["derive"] }
colored ="2.0.4"
subxt ="0.35.3"
sp-core ="31.0.0"
anyhow ="1.0.86"
tokio ={ version="1.16", features=["macros", "rt-multi-thread", "io-util", "process"] }
hex ="0.4.3"
bincode ="1.3.3"
x25519-dalek ="2.0.1"
sp-runtime ={ version="32.0.0", default-features=false }
29 changes: 8 additions & 21 deletions crates/test-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,9 @@ When using the local docker compose setup, be aware you need to set the TSS host

## Usage

### Account names
### Mnemonic

As this is a test client, there is no private key storage. Instead we use 'account names'. An 'account
name' is a string from which to derive a substrate sr25519 keypair. They are the same as
the account names the command line tool [`subkey`](https://docs.substrate.io/reference/command-line-tools/subkey) uses.

For example the name `Alice` will give you the same keypair as `subkey inspect //Alice` will give you.

You can use `subkey inspect` to find the seed, private key and account ID associated with a name you choose.

With this `test-cli`, giving the `//` prefix is optional. That is, `Alice` and `//Alice` are identical. Note
however that account names are case sensitive, so `//Alice` and `//alice` are different accounts.
As this is a test client, there is no private key storage. Instead we pass in a mnemonic that can be stored as an enviroment variable or passed in on the command line

### Help

Expand Down Expand Up @@ -88,18 +79,14 @@ You also need to decide which ['access mode' or 'key visibility'](https://docs.e
you want to register with: private or public. If you are not sure, 'public' is the simplest 'vanilla'
access mode.

For example, to register with `//Alice` as the signature request account and `//Bob` as the program
modification account, in permissioned access mode, using the `template_barebones` program:
For example, to register with `//Alice` as the signature request account in public access mode, using the `template_barebones` program:

`entropy-test-cli register Alice public template_barebones.wasm`
`entropy-test-cli register public template_barebones.wasm template_barebones_config_data template_barebones_aux_data -m //Alice`

Example of registering in private access mode, with two programs, one given as a binary file and one
Example of registering in public access mode, with two programs, one given as a binary file and one
given as a hash of an existing program:

`entropy-test-cli register Alice private my-program.wasm 3b3993c957ed9342cbb011eb9029c53fb253345114eff7da5951e98a41ba5ad5`

When registering with private access mode, a keyshare file will be written to the directory where you
run the command. You must make subsequent `sign` commands in the same directory.
`entropy-test-cli register public my-program.wasm 3b3993c957ed9342cbb011eb9029c53fb253345114eff7da5951e98a41ba5ad5 -m //Alice`

If registration was successful you will see the verifying key of your account, which is the public
secp256k1 key of your distributed keypair. You will need this in order to specify the account when
Expand Down Expand Up @@ -129,7 +116,7 @@ a program you can use the `store-program` command.
You need to give the account which will store the program, and the path to a program binary file you
wish to store, for example:

`entropy-test-cli store-program Alice ./crates/testing-utils/example_barebones_with_auxilary.wasm`
`entropy-test-cli store-program ./crates/testing-utils/example_barebones_with_auxilary.wasm //Alice`

### Update programs

Expand All @@ -138,6 +125,6 @@ account. It takes the signature verifying key, and the program modification acco
programs to evaluate when signing. Programs may be given as either the path to a .wasm binary file
or hashes of existing programs.

`entropy-test-cli update-programs 039fa2a16982fa6176e3fa9ae8dc408386ff040bf91196d3ec0aa981e5ba3fc1bb Alice my-new-program.wasm`
`entropy-test-cli update-programs 039fa2a16982fa6176e3fa9ae8dc408386ff040bf91196d3ec0aa981e5ba3fc1bb my-new-program.wasm -m //Alice`

Note that the program modification account must be funded for this to work.
Loading

0 comments on commit 52d1723

Please sign in to comment.