Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop committed Jan 24, 2024
1 parent 9a48f92 commit ed5dbaf
Show file tree
Hide file tree
Showing 13 changed files with 2,138 additions and 1,574 deletions.
3,583 changes: 2,060 additions & 1,523 deletions Cargo.lock

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ name = "quill"
path = "src/main.rs"

[dependencies]
ic-base-types = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-ckbtc-minter = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-nervous-system-common = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-nns-common = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-nns-constants = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-sns-governance = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-sns-root = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-sns-swap = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-sns-wasm = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
icp-ledger = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
icrc-ledger-types = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ledger-canister = { git = "https://github.com/dfinity/ic", rev = "5e56d9e6f7da97bbad0ef0269a198e189c6d7120" }
ic-base-types = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-ckbtc-minter = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-nervous-system-common = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-nns-common = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-nns-constants = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-nns-governance = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-sns-governance = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-sns-root = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-sns-swap = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ic-sns-wasm = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
icp-ledger = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
icrc-ledger-types = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }
ledger-canister = { git = "https://github.com/dfinity/ic", rev = "a044296844c8c82b4c6642a6bda290f3ff22bfbb" }

candid = "0.8.2"
ic-agent = { git = "https://github.com/dfinity/agent-rs", rev = "b9c57f8bab23cc9936dca4560293ffe485471c6d" }
ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs", rev = "b9c57f8bab23cc9936dca4560293ffe485471c6d", optional = true }
candid = "0.10.2"
candid_parser = "0.1.2"
ic-agent = { git = "https://github.com/dfinity/agent-rs", rev = "73da09c1c553193c46d7edef73c8c20beaa8498c" }
ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs", rev = "73da09c1c553193c46d7edef73c8c20beaa8498c", optional = true }

anyhow = "1.0.34"
atty = "0.2.14"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.66.1"
channel = "1.75"
components = ["rustfmt", "clippy"]
2 changes: 2 additions & 0 deletions src/commands/list_proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub async fn exec(opts: ListProposalsOpts, fetch_root_key: bool) -> AnyhowResult
exclude_topic: vec![2 /*TOPIC_EXCHANGE_RATE*/, 9 /*TOPIC_KYC*/],
include_reward_status: Vec::new(),
include_status: Vec::new(),
include_all_manage_neuron_proposals: Some(false),
omit_large_fields: Some(false),
})?;
submit_unsigned_ingress(
governance_canister_id(),
Expand Down
30 changes: 15 additions & 15 deletions src/commands/neuron_manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo
});
if opts.add_hot_key.is_some() {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::AddHotKey(AddHotKey {
new_hot_key: opts.add_hot_key.map(PrincipalId)
Expand All @@ -160,7 +160,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.remove_hot_key.is_some() {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::RemoveHotKey(RemoveHotKey {
hot_key_to_remove: opts.remove_hot_key.map(PrincipalId)
Expand All @@ -173,7 +173,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.stop_dissolving {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::StopDissolving(StopDissolving {}))
})),
Expand All @@ -184,7 +184,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.start_dissolving {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::StartDissolving(StartDissolving {}))
})),
Expand All @@ -195,7 +195,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if let Some(additional_dissolve_delay_seconds) = opts.additional_dissolve_delay_seconds {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::IncreaseDissolveDelay(IncreaseDissolveDelay {
additional_dissolve_delay_seconds: match additional_dissolve_delay_seconds
Expand Down Expand Up @@ -242,7 +242,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.disburse || opts.disburse_amount.is_some() || opts.disburse_to.is_some() {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Disburse(Disburse {
to_account: opts.disburse_to.map(|to| to.into_identifier().into()),
amount: opts.disburse_amount.map(|amount| Amount {
Expand All @@ -256,7 +256,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.spawn {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Spawn(Default::default())),
neuron_id_or_subaccount: None,
})?;
Expand All @@ -265,7 +265,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if let Some(amount) = opts.split {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Split(Split {
amount_e8s: amount * 100_000_000
})),
Expand All @@ -276,7 +276,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.clear_manage_neuron_followees {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Follow(Follow {
topic: 1, // Topic::NeuronManagement as i32,
followees: Vec::new()
Expand All @@ -288,7 +288,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if let Some(neuron_id) = opts.merge_from_neuron {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Merge(Merge {
source_neuron_id: Some(NeuronId {
id: parse_neuron_id(neuron_id)?
Expand All @@ -308,7 +308,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo
bail!("Percentage to merge must be a number from 1 to 100");
}
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::StakeMaturity(StakeMaturity {
percentage_to_stake: Some(percentage),
})),
Expand All @@ -319,7 +319,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.join_community_fund {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::JoinCommunityFund(JoinCommunityFund {}))
})),
Expand All @@ -330,7 +330,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo

if opts.leave_community_fund {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Configure(Configure {
operation: Some(Operation::LeaveCommunityFund(LeaveCommunityFund {}))
})),
Expand All @@ -342,7 +342,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo
if let Some(proposals) = opts.register_vote {
for proposal in proposals {
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::RegisterVote(RegisterVote {
vote: if opts.reject { 2 } else { 1 },
proposal: Some(ProposalId { id: proposal }),
Expand All @@ -356,7 +356,7 @@ Cannot use --ledger with these flags. This version of quill only supports the fo
if let (Some(topic), Some(neuron_ids)) = (opts.follow_topic, opts.follow_neurons) {
let followees = neuron_ids.into_iter().map(|x| NeuronId { id: x }).collect();
let args = Encode!(&ManageNeuron {
id: id.clone(),
id,
command: Some(Command::Follow(Follow {
topic, // Topic::NeuronManagement as i32,
followees,
Expand Down
16 changes: 12 additions & 4 deletions src/commands/request_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::lib::get_ic_url;
use crate::lib::{get_agent, get_idl_string, signing::RequestStatus, AnyhowResult, AuthInfo};
use anyhow::{anyhow, Context};
use candid::Principal;
use ic_agent::agent::{Replied, RequestStatusResponse, Transport};
use ic_agent::agent::{ReplyResponse, RequestStatusResponse, Transport};
use ic_agent::AgentError::MessageError;
use ic_agent::{AgentError, RequestId};
use std::future::Future;
Expand All @@ -27,14 +27,14 @@ pub async fn submit(
agent.set_transport(ProxySignTransport {
req: req.clone(),
http_transport: Arc::new(
ic_agent::agent::http_transport::ReqwestHttpReplicaV2Transport::create(get_ic_url())
ic_agent::agent::http_transport::reqwest_transport::ReqwestHttpReplicaV2Transport::create(get_ic_url())
.context("Failed to create an agent")?,
),
});
let Replied::CallReplied(blob) = async {
let ReplyResponse { arg: blob } = async {
loop {
match agent.request_status_raw(&request_id, canister_id).await? {
RequestStatusResponse::Replied { reply } => return Ok(reply),
RequestStatusResponse::Replied(reply) => return Ok(reply),
RequestStatusResponse::Rejected(response) => {
return Err(anyhow!(AgentError::ReplicaError(response)))
}
Expand Down Expand Up @@ -93,6 +93,14 @@ impl Transport for ProxySignTransport {
Box::pin(run(self))
}

fn read_subnet_state(
&self,
subnet_id: Principal,
envelope: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AgentError>> + Send + '_>> {
self.http_transport.read_subnet_state(subnet_id, envelope)
}

fn call<'a>(
&'a self,
_effective_canister_id: Principal,
Expand Down
4 changes: 3 additions & 1 deletion src/commands/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use atty::Stream;
use candid::{CandidType, Principal};
use clap::Parser;
use ic_agent::agent::Transport;
use ic_agent::{agent::http_transport::ReqwestHttpReplicaV2Transport, RequestId};
use ic_agent::{
agent::http_transport::reqwest_transport::ReqwestHttpReplicaV2Transport, RequestId,
};
use icp_ledger::{Subaccount, Tokens};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
Expand Down
1 change: 1 addition & 0 deletions src/commands/sns/follow_neuron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum Type {
TransferSnsTreasuryFunds = 9,
RegisterDappCanisters = 10,
DeregisterDappCanisters = 11,
MintSnsTokens = 12,
}

pub fn exec(
Expand Down
5 changes: 3 additions & 2 deletions src/commands/sns/make_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use crate::{
AnyhowResult,
};
use anyhow::Error;
use candid::{Decode, Encode, IDLArgs};
use candid::{Decode, Encode};
use candid_parser::parse_idl_args;
use clap::Parser;
use ic_sns_governance::pb::v1::{manage_neuron, ManageNeuron, Proposal};

Expand Down Expand Up @@ -83,7 +84,7 @@ pub fn exec(
}

fn parse_proposal_from_candid_string(proposal_candid: String) -> AnyhowResult<Proposal> {
let args: IDLArgs = proposal_candid.parse()?;
let args = parse_idl_args(&proposal_candid)?;
let args: Vec<u8> = args.to_bytes()?;
Decode!(args.as_slice(), Proposal).map_err(Error::msg)
}
3 changes: 2 additions & 1 deletion src/commands/sns/make_upgrade_canister_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
use anyhow::{Context, Error};
use candid::Principal;
use candid::{Encode, IDLArgs};
use candid_parser::parse_idl_args;
use clap::Parser;
use ic_sns_governance::pb::v1::{
manage_neuron, proposal, ManageNeuron, Proposal, UpgradeSnsControlledCanister,
Expand Down Expand Up @@ -83,7 +84,7 @@ pub fn exec(
let wasm = std::fs::read(wasm_path).context("Unable to read --wasm-path.")?;
let canister_upgrade_arg = match (canister_upgrade_arg, canister_upgrade_arg_path) {
(Some(arg), _) => {
let parsed_arg: IDLArgs = arg.parse()?;
let parsed_arg: IDLArgs = parse_idl_args(&arg)?;
Some(parsed_arg.to_bytes()?)
}
(_, Some(path)) => {
Expand Down
8 changes: 8 additions & 0 deletions src/lib/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,16 @@ impl Identity for LedgerIdentity {
Ok(Signature {
public_key: Some(pk),
signature: Some(sig),
delegations: None,
})
}

fn public_key(&self) -> Option<Vec<u8>> {
let (_, pk) = get_identity(&self.inner.transport.lock().unwrap(), &derivation_path())
.map_err(|e| e.to_string())
.ok()?;
Some(pk)
}
}

fn serialize_path(path: &DerivationPath) -> Vec<u8> {
Expand Down
21 changes: 11 additions & 10 deletions src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
use anyhow::{anyhow, bail, ensure, Context};
use bip32::DerivationPath;
use bip39::{Mnemonic, Seed};
use candid::{
parser::typing::{check_prog, TypeEnv},
types::Function,
IDLProg, Principal,
};
use candid::{types::Function, Principal, TypeEnv};
use candid_parser::{typing::check_prog, IDLProg};
use crc32fast::Hasher;
use data_encoding::BASE32_NOPAD;
use ic_agent::{
Expand Down Expand Up @@ -237,7 +234,7 @@ pub fn get_idl_string(
/// Returns the candid type of a specifed method and correspondig idl
/// description.
pub fn get_candid_type(idl: &str, method_name: &str) -> Option<(TypeEnv, Function)> {
let ast = candid::pretty_parse::<IDLProg>("/dev/null", idl).ok()?;
let ast = candid_parser::pretty_parse::<IDLProg>("/dev/null", idl).ok()?;
let mut env = TypeEnv::new();
let actor = check_prog(&mut env, &ast).ok()?;
let method = env.get_method(&actor?, method_name).ok()?.clone();
Expand Down Expand Up @@ -265,7 +262,7 @@ pub fn get_agent(auth: &AuthInfo) -> AnyhowResult<Agent> {
let timeout = Duration::from_secs(60 * 5);
let builder = Agent::builder()
.with_transport(
ic_agent::agent::http_transport::ReqwestHttpReplicaV2Transport::create({
ic_agent::agent::http_transport::reqwest_transport::ReqwestHttpReplicaV2Transport::create({
get_ic_url()
})?,
)
Expand Down Expand Up @@ -465,7 +462,7 @@ impl FromStr for ParsedAccount {
return Ok(Self(Account {
owner: Principal::from_str(s)
.map_err(|e| anyhow!("Invalid ICRC-1 account: missing subaccount, or: {e}"))?,
subaccount: None
subaccount: None,
}));
};
let (principal, crc) = rest
Expand Down Expand Up @@ -513,8 +510,12 @@ impl Display for ParsedAccount {

fn fmt_account(account: &Account, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", account.owner)?;
let Some(subaccount) = account.subaccount else { return Ok(()) };
let Some(first_digit) = subaccount.iter().position(|x| *x != 0) else { return Ok(()) };
let Some(subaccount) = account.subaccount else {
return Ok(());
};
let Some(first_digit) = subaccount.iter().position(|x| *x != 0) else {
return Ok(());
};
let mut crc = Hasher::new();
crc.update(account.owner.as_slice());
crc.update(&subaccount);
Expand Down
4 changes: 3 additions & 1 deletion tests/output/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ fn output_eq(a: &[u8], b: &[u8]) -> bool {
}

fn trim(s: &[u8]) -> &[u8] {
let Some(start) = s.iter().position(|x| !b" \r\n\t".contains(x)) else { return &[] };
let Some(start) = s.iter().position(|x| !b" \r\n\t".contains(x)) else {
return &[];
};
let end = s.iter().rposition(|x| !b" \r\n\t".contains(x)).unwrap();
&s[start..=end]
}

0 comments on commit ed5dbaf

Please sign in to comment.