Conversation
| // Binary flag applied | ||
| (_, true) => { | ||
| let wasm_code = | ||
| fetch_wasm_code(*info_to_json.code_hash(), &client).await?; |
There was a problem hiding this comment.
nit: using ok_or may simplify code below by removing match.
SkymanOne
left a comment
There was a problem hiding this comment.
Looks good. Just a few nitpicks and changes mainly to do with the coding style
| // All flag applied | ||
| if self.all { | ||
| // 1000 is max allowed value | ||
| const COUNT: u32 = 1000; |
There was a problem hiding this comment.
Nit:
| const COUNT: u32 = 1000; | |
| const MAX_COUNT: u32 = 1000; |
| ); | ||
| pub async fn run(&self) -> Result<(), ErrorVariant> { | ||
| let url = self.url.clone(); | ||
| let client = OnlineClient::<DefaultConfig>::from_url(url).await?; |
There was a problem hiding this comment.
| let client = OnlineClient::<DefaultConfig>::from_url(url).await?; | |
| let client = OnlineClient::<DefaultConfig>::from_url(&self.url).await?; |
| self.contract | ||
| ); | ||
| pub async fn run(&self) -> Result<(), ErrorVariant> { | ||
| let url = self.url.clone(); |
There was a problem hiding this comment.
| let url = self.url.clone(); |
crates/extrinsics/src/lib.rs
Outdated
| Ok(pristine_bytes) | ||
| } | ||
|
|
||
| /// Fetch all contracts addresses from the storage using the provided client and count of |
There was a problem hiding this comment.
| /// Fetch all contracts addresses from the storage using the provided client and count of | |
| /// Fetch all contract addresses from the storage using the provided client and count of |
crates/extrinsics/src/lib.rs
Outdated
| pub async fn fetch_all_contracts( | ||
| client: &Client, | ||
| count: u32, | ||
| from: Option<&AccountId32>, |
There was a problem hiding this comment.
| from: Option<&AccountId32>, | |
| count_from: Option<&AccountId32>, |
| if self.all { | ||
| // 1000 is max allowed value | ||
| const COUNT: u32 = 1000; | ||
| let mut from = None; |
There was a problem hiding this comment.
| let mut from = None; | |
| let mut count_from = None; |
crates/extrinsics/src/lib.rs
Outdated
| .fetch_keys(key.as_ref(), count, start_key.as_deref()) | ||
| .await?; | ||
|
|
||
| // StorageKey is a concatention of contract_info_of root key and |
There was a problem hiding this comment.
| // StorageKey is a concatention of contract_info_of root key and | |
| // StorageKey is a concatenation of contract_info_of root key and |
crates/extrinsics/src/lib.rs
Outdated
| e.0.get(key.len() + 8..) | ||
| .ok_or(anyhow!("Unexpected storage key size"))?; | ||
| AccountId32::decode(&mut account) | ||
| .map_err(|err| anyhow!("AccountId deserialization error: {}", err)) |
There was a problem hiding this comment.
I would extract it into a separate function for better readability
| pub fn display_all_contracts(contracts: &[<DefaultConfig as Config>::AccountId]) { | ||
| contracts | ||
| .iter() | ||
| .for_each(|e: &<DefaultConfig as Config>::AccountId| { | ||
| name_value_println!("Contract", format!("{}", e), MAX_KEY_COL_WIDTH); | ||
| }) | ||
| } |
There was a problem hiding this comment.
I would rewrite it to display the result something like:
Found contracts:
* <Address>
* <Address>
* <Address>There was a problem hiding this comment.
I think that in case when we have more than 1000 contracts, it will be hard to see this line Found contracts at the log beginning. I would opt to keep it as is. What do you think?
There was a problem hiding this comment.
Then I would enumerate them at least. Useful when you want to pipe the output into another bash command:
Found contracts:
1. <Address>
2. <Address>
...
1000. <Address>It is up to you if you want to keep Found contracts: or not.
There was a problem hiding this comment.
Useful when you want to pipe the output into another bash command
In this case it is best then to have only the list of contract addresses so instead of
Contract 5DpyotvcUDkFxTtHzkwR7Rqe37bdjc6M5Rxeiy57Gv2RQzp8
Contract 5GsoMKLTgFEpzHQTi7c4ZKCLZC6VxtHZxwMydSi79uemABez
have
5DpyotvcUDkFxTtHzkwR7Rqe37bdjc6M5Rxeiy57Gv2RQzp8
5GsoMKLTgFEpzHQTi7c4ZKCLZC6VxtHZxwMydSi79uemABez
I like it this way, unix command compatible.
Closes #797
cargo info -allis:Flags combination --binary --all is forbidden
Current implementation does not support response paging