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

Add total contract deposit #1347

Merged
merged 22 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 18 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bump `subxt` to `0.32.0` - [#1352](https://github.com/paritytech/cargo-contract/pull/1352)
- Remove check for compatible `scale` and `scale-info` versions - [#1370](https://github.com/paritytech/cargo-contract/pull/1370)
- Add workspace support -[#1358](https://github.com/paritytech/cargo-contract/pull/1358)
- Add `Storage Total Deposit` to `info` command output - [#1347](https://github.com/paritytech/cargo-contract/pull/1347)

## [4.0.0-alpha]

Expand Down
13 changes: 5 additions & 8 deletions crates/cargo-contract/src/cmd/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ impl InfoCommand {
.as_ref()
.expect("Contract argument was not provided");

let info_to_json = fetch_contract_info(contract, &rpc, &client)
.await?
.ok_or(anyhow!(
"No contract information was found for account id {}",
contract
))?;
let info_to_json = fetch_contract_info(contract, &rpc, &client).await?;

let wasm_code = fetch_wasm_code(&client, &rpc, info_to_json.code_hash())
.await?
Expand Down Expand Up @@ -154,7 +149,8 @@ pub struct ExtendedContractInfo {
pub trie_id: String,
pub code_hash: CodeHash,
pub storage_items: u32,
pub storage_item_deposit: Balance,
pub storage_items_deposit: Balance,
pub storage_total_deposit: Balance,
pub source_language: String,
}

Expand All @@ -168,7 +164,8 @@ impl ExtendedContractInfo {
trie_id: contract_info.trie_id().to_string(),
code_hash: *contract_info.code_hash(),
storage_items: contract_info.storage_items(),
storage_item_deposit: contract_info.storage_item_deposit(),
storage_items_deposit: contract_info.storage_items_deposit(),
storage_total_deposit: contract_info.storage_total_deposit(),
source_language: language,
}
}
Expand Down
11 changes: 8 additions & 3 deletions crates/cargo-contract/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl CLIExtrinsicOpts {
}
}

const STORAGE_DEPOSIT_KEY: &str = "Storage Deposit";
const STORAGE_DEPOSIT_KEY: &str = "Storage Total Deposit";
pub const MAX_KEY_COL_WIDTH: usize = STORAGE_DEPOSIT_KEY.len() + 1;

/// Print to stdout the fields of the result of a `instantiate` or `call` dry-run via RPC.
Expand Down Expand Up @@ -230,8 +230,13 @@ pub fn basic_display_format_extended_contract_info(info: &ExtendedContractInfo)
MAX_KEY_COL_WIDTH
);
name_value_println!(
"Storage Deposit",
format!("{:?}", info.storage_item_deposit),
"Storage Items Deposit",
format!("{:?}", info.storage_items_deposit),
MAX_KEY_COL_WIDTH
);
name_value_println!(
STORAGE_DEPOSIT_KEY,
format!("{:?}", info.storage_total_deposit),
MAX_KEY_COL_WIDTH
);
name_value_println!(
Expand Down
Loading