-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4954 from nymtech/feature/contract-state-tools
Feature/contract state tools
- Loading branch information
Showing
19 changed files
with
782 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
common/commands/src/validator/cosmwasm/raw_contract_state.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2024 - Nym Technologies SA <[email protected]> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::context::QueryClient; | ||
use clap::Parser; | ||
use cosmrs::AccountId; | ||
use log::trace; | ||
use nym_validator_client::nyxd::CosmWasmClient; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct Args { | ||
#[clap(long, value_parser)] | ||
#[clap(help = "The address of contract to get the state of")] | ||
pub contract: AccountId, | ||
|
||
#[clap(short, long)] | ||
#[clap(help = "Output file for the retrieved contract state")] | ||
pub output: PathBuf, | ||
} | ||
|
||
pub async fn execute(args: Args, client: QueryClient) -> anyhow::Result<()> { | ||
trace!("args: {args:?}"); | ||
|
||
let output = File::create(&args.output)?; | ||
let raw = client.query_all_contract_state(&args.contract).await?; | ||
|
||
serde_json::to_writer(output, &raw)?; | ||
println!( | ||
"wrote {} key-value from {} pairs into '{}'", | ||
raw.len(), | ||
args.contract, | ||
fs::canonicalize(args.output)?.display() | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build-importer-contract: | ||
$(MAKE) -C importer-contract build |
26 changes: 26 additions & 0 deletions
26
tools/internal/contract-state-importer/importer-cli/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "importer-cli" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
documentation.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
rust-version.workspace = true | ||
readme.workspace = true | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
bip39 = { workspace = true } | ||
clap = { workspace = true, features = ["derive"] } | ||
dirs = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json = { workspace = true } | ||
tokio = { workspace = true, features = ["rt-multi-thread", "net", "signal"] } | ||
tracing = { workspace = true } | ||
|
||
importer-contract = { path = "../importer-contract" } | ||
nym-validator-client = { path = "../../../../common/client-libs/validator-client" } | ||
nym-bin-common = { path = "../../../../common/bin-common", features = ["basic_tracing"] } | ||
nym-network-defaults = { path = "../../../../common/network-defaults" } |
Oops, something went wrong.