Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cli for metadata cell data #1640

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 119 additions & 12 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ members = [
"core/storage",
"devtools/abi-generator",
"devtools/axon-tools",
"devtools/metadata-cli",
"protocol",
]

Expand Down
20 changes: 20 additions & 0 deletions devtools/metadata-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "metadata-cli"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]
name = "axon-metadata"
path = "src/main.rs"

[dependencies]
anyhow = "1.0.75"
axon-types = { git = "https://github.com/axonweb3/axon-contract.git", rev = "b82a843" }
clap = { version = "4.4.6", features = ["derive"] }
hex = "0.4.3"
molecule = "0.7.5"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
serde_with = "3.4.0"
toml = "0.8.2"
25 changes: 25 additions & 0 deletions devtools/metadata-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Metadata Cli

Cli for working with axon metadata cell.

## Get Data

Generate `MetadataCellData` from validators.

Usage:

From a chain spec file or input file:

```command
$ axon-metadata get-data -i input.example.toml
```

```command
$ axon-metadata get-data -i chain-spec.toml
```

From JSONRPC metadata result:

```command
$ curl 'https://rpc-alphanet-axon.ckbapp.dev/' --header 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"axon_getCurrentMetadata","id":3}' | jq '.result' | axon-metadata get-data -i /dev/stdin
```
66 changes: 66 additions & 0 deletions devtools/metadata-cli/input.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"version": {
"start": "0x1",
"end": "0x5f5e100"
},
"epoch": "0x0",
"verifier_list": [
{
"bls_pub_key": "0x95a16ed1f4c43a7470917771bf820741dbd040c51967122de66dc5bc9f6eff5953a36be6c0fdf8c202a26d6f2b0f8885",
"pub_key": "0x035e184329714d7e3f7e39e5d96ac3be4835897adbaab85bae2558473391fa8fcf",
"address": "0x81fb11017e520fda13df35d1fd1a3903e384020f",
"propose_weight": "0x1",
"vote_weight": "0x1"
},
{
"bls_pub_key": "0xa8d1c7c4152ce4ad8eff7ee90406b6cdf27eee97f0e520b8098a88ff3873c83aa8b74d9aab3a1c15361b5d3bc9224e9a",
"pub_key": "0x02f0018382fef706e37faf9770c14a58d35a457c7a2fa0ec84240d50b6d74f4adb",
"address": "0x7249d82017b77a5006808fe020e779af0d95e12e",
"propose_weight": "0x1",
"vote_weight": "0x1"
},
{
"bls_pub_key": "0x8d999a5c29604f32950bfedf289f6b8e7e2f1a19f86b208d370024e709f77d1208f5e000dc4232a63064530613aa4b26",
"pub_key": "0x03ea501a5600c260b62ff0cdb0c227e9374643395243f026f9c73fe9aa8ebcfebd",
"address": "0x387f3253e85c320b5e881656447eedccf5230f22",
"propose_weight": "0x1",
"vote_weight": "0x1"
},
{
"bls_pub_key": "0xafefcad3f6289c0bc0a9fd0015f533dcfcc1d7ba5161ff518702fee7aec33374a08d4fa45baeef85836c1e604e8f221d",
"pub_key": "0x02b2daf6d950f25735f2faa129cfe2a65c70bcbd4a050c9d18a06ed0e63a91f2a9",
"address": "0xc384b679bbc0de6e471fdb7735c0ff2d9508ece0",
"propose_weight": "0x1",
"vote_weight": "0x1"
}
],
"propose_counter": [
{
"address": "0x387f3253e85c320b5e881656447eedccf5230f22",
"count": "0xe605"
},
{
"address": "0x7249d82017b77a5006808fe020e779af0d95e12e",
"count": "0xe605"
},
{
"address": "0x81fb11017e520fda13df35d1fd1a3903e384020f",
"count": "0xe5f3"
},
{
"address": "0xc384b679bbc0de6e471fdb7735c0ff2d9508ece0",
"count": "0xe5ff"
}
],
"consensus_config": {
"gas_limit": "0x3e7fffffc18",
"interval": "0xbb8",
"propose_ratio": "0xf",
"prevote_ratio": "0xa",
"precommit_ratio": "0xa",
"brake_ratio": "0xa",
"tx_num_limit": "0x4e20",
"max_tx_size": "0x186a0000",
"max_contract_limit": "0xc000"
}
}
Loading
Loading