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 summary-path to make-upgrade-canister-proposal #164

Merged
merged 4 commits into from
Feb 27, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Added `--summary-path` to `quill sns make-upgrade-canister-proposal`. (#164)

## [0.4.0] - 2023-02-14

## Changed
Expand Down
25 changes: 18 additions & 7 deletions src/commands/sns/make_upgrade_canister_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ pub struct MakeUpgradeCanisterProposalOpts {
#[clap(long, default_value_t = String::new())]
url: String,

/// Summary of the proposal. If empty, a somewhat generic summary will be
/// Summary of the proposal.
/// If neither summary nor summary-path is provided, a somewhat generic summary will be
/// constructed dynamically.
#[clap(long, default_value_t = String::new())]
summary: String,
#[clap(long)]
summary: Option<String>,

/// Path to a file containing the summary of the proposal.
/// If neither summary nor summary-path is provided, a somewhat generic summary will be
/// constructed dynamically.
#[clap(long, conflicts_with("summary"))]
summary_path: Option<PathBuf>,

/// Canister to be upgraded.
#[clap(long)]
Expand Down Expand Up @@ -66,6 +73,7 @@ pub fn exec(
title,
url,
summary,
summary_path,
target_canister_id,
wasm_path,
canister_upgrade_arg,
Expand All @@ -85,10 +93,13 @@ pub fn exec(
};

// (Dynamically) come up with a summary if one wasn't provided.
let summary = if !summary.is_empty() {
summary
} else {
summarize(target_canister_id, &wasm)
let summary = match (summary, summary_path) {
(Some(arg), _) => arg,
(_, Some(path)) => {
String::from_utf8(std::fs::read(path).context("Unable to read --summary-path.")?)
.context("Summary must be valid UTF-8.")?
}
(None, None) => summarize(target_canister_id, &wasm),
};

let proposal = Proposal {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PROPOSER_NEURON_ID=83a7d2b12f654ff58335e5a2512ccae0d7839c744b1807a47c96f5b9f3969069

"$QUILL" sns \
make-upgrade-canister-proposal \
--wasm-path=outputs/sns_canister.wasm \
--target-canister-id=pycv5-3jbbb-ccccc-ddddd-cai \
--canister-ids-file=./sns_canister_ids.json \
--summary-path=./upgrade-summary.txt \
--pem-file=- \
$PROPOSER_NEURON_ID \
| "$QUILL" send --dry-run -

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Sending message with

Call type: update
Sender: fdsgv-62ihb-nbiqv-xgic5-iefsv-3cscz-tmbzv-63qd5-vh43v-dqfrt-pae
Canister id: rrkah-fqaaa-aaaaa-aaaaq-cai
Method name: manage_neuron
Arguments: (
record {
subaccount = blob "\83\a7\d2\b1/eO\f5\835\e5\a2Q,\ca\e0\d7\83\9ctK\18\07\a4|\96\f5\b9\f3\96\90i";
command = opt variant {
MakeProposal = record {
url = "";
title = "Upgrade Canister";
action = opt variant {
UpgradeSnsControlledCanister = record {
new_canister_wasm = blob "\00asm\01\00\00\00";
canister_id = opt principal "pycv5-3jbbb-ccccc-ddddd-cai";
canister_upgrade_arg = null;
}
};
summary = "--This proposal upgrades the SNS-controlled canister.";
}
};
},
)
1 change: 1 addition & 0 deletions tests/upgrade-summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--This proposal upgrades the SNS-controlled canister.