Skip to content
Open
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
82 changes: 49 additions & 33 deletions rs/sns_aggregator/src/types/ic_sns_governance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Rust code created from candid by: `scripts/did2rs.sh --canister sns_governance --out ic_sns_governance.rs --header did2rs.header --traits Serialize\,\ Clone\,\ Debug`
//! Candid for canister `sns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/f54e1f82c3cf8ae0b4be6b0fc3a940cdcd70dd97/rs/sns/governance/canister/governance.did>
#![allow(clippy::all)]
#![allow(clippy::pedantic)]
#![allow(deprecated)]
#![allow(unused_imports)]
#![allow(missing_docs)]
Expand Down Expand Up @@ -76,24 +77,32 @@ pub struct NervousSystemFunction {
pub struct Subaccount {
pub subaccount: serde_bytes::ByteBuf,
}
/// ! Candid for canister `sns_governance` obtained by `scripts/update_ic_commit` from: <https://raw.githubusercontent.com/dfinity/ic/f54e1f82c3cf8ae0b4be6b0fc3a940cdcd70dd97/rs/sns/governance/canister/governance.did>
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct Account {
pub owner: Option<Principal>,
pub subaccount: Option<Subaccount>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct TreasuryMetrics {
/// A human-readable identified for this treasury, e.g., "ICP".
pub name: Option<String>,
/// The amount of tokens in this treasury at the end of swap finalization.
pub original_amount_e8s: Option<u64>,
/// The regularly updated amount of tokens in this treasury.
pub amount_e8s: Option<u64>,
pub account: Option<Account>,
/// The source of truth for the treasury balance is this ledger canister / account.
pub ledger_canister_id: Option<Principal>,
/// Same as, e.g., `TransferSnsTreasuryFunds.from_treasury`.
pub treasury: i32,
/// When the metrics were last updated.
pub timestamp_seconds: Option<u64>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct VotingPowerMetrics {
pub governance_total_potential_voting_power: Option<u64>,
/// When the metrics were last updated.
pub timestamp_seconds: Option<u64>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
Expand Down Expand Up @@ -334,6 +343,20 @@ pub struct ManageDappCanisterSettings {
pub memory_allocation: Option<u64>,
pub compute_allocation: Option<u64>,
}
/// This type is equivalant to `ICRC3Value`, but we give it another name since it is used here not
/// in the context of the ICRC-3 ledger standard. The justification is the same: The candid format
/// supports sharing information even when the client and the server involved do not have the same
/// schema (see the Upgrading and subtyping section of the candid spec). While this mechanism allows
/// to evolve services and clients independently without breaking them, it also means that a client
/// may not receive all the information that the server is sending, e.g. in case the client schema
/// lacks some fields that the server schema has.
///
/// This loss of information is not an option for SNS voters deciding if an extension with particular
/// init args should be installed or if an extension function with particular arguments should be
/// called. The client must receive the same exact data the server sent in order to verify it.
///
/// Verification of a priorly installed extension is done by hashing the extension's init arg data
/// and checking that the result is consistent with what has been certified by the SNS.
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub enum PreciseValue {
Int(i64),
Expand Down Expand Up @@ -739,11 +762,7 @@ pub struct SwapNeuron {
pub struct ClaimedSwapNeurons {
pub swap_neurons: Vec<SwapNeuron>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub enum ClaimSwapNeuronsResult {
Ok(ClaimedSwapNeurons),
Err(i32),
}
pub type ClaimSwapNeuronsResult = std::result::Result<ClaimedSwapNeurons, i32>;
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct ClaimSwapNeuronsResponse {
pub claim_swap_neurons_result: Option<ClaimSwapNeuronsResult>,
Expand Down Expand Up @@ -773,18 +792,15 @@ pub struct GetMetricsRequest {
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct Metrics {
/// The metrics below are cached (albeit this is an implementation detail).
pub treasury_metrics: Option<Vec<TreasuryMetrics>>,
pub voting_power_metrics: Option<VotingPowerMetrics>,
pub last_ledger_block_timestamp: Option<u64>,
pub num_recently_executed_proposals: Option<u64>,
pub num_recently_submitted_proposals: Option<u64>,
pub genesis_timestamp_seconds: Option<u64>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub enum GetMetricsResult {
Ok(Metrics),
Err(GovernanceError),
}
pub type GetMetricsResult = std::result::Result<Metrics, GovernanceError>;
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct GetMetricsResponse {
pub get_metrics_result: Option<GetMetricsResult>,
Expand All @@ -800,13 +816,13 @@ pub struct GetNeuron {
pub neuron_id: Option<NeuronId>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub enum Result_ {
pub enum Result {
Error(GovernanceError),
Neuron(Neuron),
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct GetNeuronResponse {
pub result: Option<Result_>,
pub result: Option<Result>,
}
#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
pub struct GetProposal {
Expand Down Expand Up @@ -1066,12 +1082,12 @@ pub struct SetModeRet {}

pub struct Service(pub Principal);
impl Service {
pub async fn claim_swap_neurons(&self, arg0: ClaimSwapNeuronsRequest) -> CallResult<(ClaimSwapNeuronsResponse,)> {
pub async fn claim_swap_neurons(&self, arg0: &ClaimSwapNeuronsRequest) -> CallResult<(ClaimSwapNeuronsResponse,)> {
ic_cdk::call(self.0, "claim_swap_neurons", (arg0,)).await
}
pub async fn fail_stuck_upgrade_in_progress(
&self,
arg0: FailStuckUpgradeInProgressArg,
arg0: &FailStuckUpgradeInProgressArg,
) -> CallResult<(FailStuckUpgradeInProgressRet,)> {
ic_cdk::call(self.0, "fail_stuck_upgrade_in_progress", (arg0,)).await
}
Expand All @@ -1083,74 +1099,74 @@ impl Service {
}
pub async fn get_maturity_modulation(
&self,
arg0: GetMaturityModulationArg,
arg0: &GetMaturityModulationArg,
) -> CallResult<(GetMaturityModulationResponse,)> {
ic_cdk::call(self.0, "get_maturity_modulation", (arg0,)).await
}
pub async fn get_metadata(&self, arg0: GetMetadataArg) -> CallResult<(GetMetadataResponse,)> {
pub async fn get_metadata(&self, arg0: &GetMetadataArg) -> CallResult<(GetMetadataResponse,)> {
ic_cdk::call(self.0, "get_metadata", (arg0,)).await
}
pub async fn get_metrics(&self, arg0: GetMetricsRequest) -> CallResult<(GetMetricsResponse,)> {
pub async fn get_metrics(&self, arg0: &GetMetricsRequest) -> CallResult<(GetMetricsResponse,)> {
ic_cdk::call(self.0, "get_metrics", (arg0,)).await
}
pub async fn get_metrics_replicated(&self, arg0: GetMetricsRequest) -> CallResult<(GetMetricsResponse,)> {
pub async fn get_metrics_replicated(&self, arg0: &GetMetricsRequest) -> CallResult<(GetMetricsResponse,)> {
ic_cdk::call(self.0, "get_metrics_replicated", (arg0,)).await
}
pub async fn get_mode(&self, arg0: GetModeArg) -> CallResult<(GetModeResponse,)> {
pub async fn get_mode(&self, arg0: &GetModeArg) -> CallResult<(GetModeResponse,)> {
ic_cdk::call(self.0, "get_mode", (arg0,)).await
}
pub async fn get_nervous_system_parameters(&self, arg0: ()) -> CallResult<(NervousSystemParameters,)> {
pub async fn get_nervous_system_parameters(&self, arg0: &()) -> CallResult<(NervousSystemParameters,)> {
ic_cdk::call(self.0, "get_nervous_system_parameters", (arg0,)).await
}
pub async fn get_neuron(&self, arg0: GetNeuron) -> CallResult<(GetNeuronResponse,)> {
pub async fn get_neuron(&self, arg0: &GetNeuron) -> CallResult<(GetNeuronResponse,)> {
ic_cdk::call(self.0, "get_neuron", (arg0,)).await
}
pub async fn get_proposal(&self, arg0: GetProposal) -> CallResult<(GetProposalResponse,)> {
pub async fn get_proposal(&self, arg0: &GetProposal) -> CallResult<(GetProposalResponse,)> {
ic_cdk::call(self.0, "get_proposal", (arg0,)).await
}
pub async fn get_root_canister_status(&self, arg0: ()) -> CallResult<(CanisterStatusResultV2,)> {
pub async fn get_root_canister_status(&self, arg0: &()) -> CallResult<(CanisterStatusResultV2,)> {
ic_cdk::call(self.0, "get_root_canister_status", (arg0,)).await
}
pub async fn get_running_sns_version(
&self,
arg0: GetRunningSnsVersionArg,
arg0: &GetRunningSnsVersionArg,
) -> CallResult<(GetRunningSnsVersionResponse,)> {
ic_cdk::call(self.0, "get_running_sns_version", (arg0,)).await
}
pub async fn get_sns_initialization_parameters(
&self,
arg0: GetSnsInitializationParametersArg,
arg0: &GetSnsInitializationParametersArg,
) -> CallResult<(GetSnsInitializationParametersResponse,)> {
ic_cdk::call(self.0, "get_sns_initialization_parameters", (arg0,)).await
}
pub async fn get_timers(&self, arg0: GetTimersArg) -> CallResult<(GetTimersResponse,)> {
pub async fn get_timers(&self, arg0: &GetTimersArg) -> CallResult<(GetTimersResponse,)> {
ic_cdk::call(self.0, "get_timers", (arg0,)).await
}
pub async fn get_upgrade_journal(
&self,
arg0: GetUpgradeJournalRequest,
arg0: &GetUpgradeJournalRequest,
) -> CallResult<(GetUpgradeJournalResponse,)> {
ic_cdk::call(self.0, "get_upgrade_journal", (arg0,)).await
}
pub async fn list_nervous_system_functions(&self) -> CallResult<(ListNervousSystemFunctionsResponse,)> {
ic_cdk::call(self.0, "list_nervous_system_functions", ()).await
}
pub async fn list_neurons(&self, arg0: ListNeurons) -> CallResult<(ListNeuronsResponse,)> {
pub async fn list_neurons(&self, arg0: &ListNeurons) -> CallResult<(ListNeuronsResponse,)> {
ic_cdk::call(self.0, "list_neurons", (arg0,)).await
}
pub async fn list_proposals(&self, arg0: ListProposals) -> CallResult<(ListProposalsResponse,)> {
pub async fn list_proposals(&self, arg0: &ListProposals) -> CallResult<(ListProposalsResponse,)> {
ic_cdk::call(self.0, "list_proposals", (arg0,)).await
}
pub async fn list_topics(&self, arg0: ListTopicsRequest) -> CallResult<(ListTopicsResponse,)> {
pub async fn list_topics(&self, arg0: &ListTopicsRequest) -> CallResult<(ListTopicsResponse,)> {
ic_cdk::call(self.0, "list_topics", (arg0,)).await
}
pub async fn manage_neuron(&self, arg0: ManageNeuron) -> CallResult<(ManageNeuronResponse,)> {
pub async fn manage_neuron(&self, arg0: &ManageNeuron) -> CallResult<(ManageNeuronResponse,)> {
ic_cdk::call(self.0, "manage_neuron", (arg0,)).await
}
pub async fn reset_timers(&self, arg0: ResetTimersArg) -> CallResult<(ResetTimersRet,)> {
pub async fn reset_timers(&self, arg0: &ResetTimersArg) -> CallResult<(ResetTimersRet,)> {
ic_cdk::call(self.0, "reset_timers", (arg0,)).await
}
pub async fn set_mode(&self, arg0: SetMode) -> CallResult<(SetModeRet,)> {
pub async fn set_mode(&self, arg0: &SetMode) -> CallResult<(SetModeRet,)> {
ic_cdk::call(self.0, "set_mode", (arg0,)).await
}
}
24 changes: 11 additions & 13 deletions rs/sns_aggregator/src/types/ic_sns_ledger.patch
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
diff --git b/rs/sns_aggregator/src/types/ic_sns_ledger.rs a/rs/sns_aggregator/src/types/ic_sns_ledger.rs
index 7566582df..00c91ff35 100644
--- b/rs/sns_aggregator/src/types/ic_sns_ledger.rs
+++ a/rs/sns_aggregator/src/types/ic_sns_ledger.rs
@@ -129,7 +129,7 @@ pub struct GetBlocksResponseArchivedBlocksItem {
pub start: BlockIndex,
@@ -154,7 +154,7 @@
pub length: candid::Nat,
}
/// The result of a "get_blocks" call.
-#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
+#[derive(CandidType, Deserialize)]
pub struct GetBlocksResponse {
pub certificate: Option<serde_bytes::ByteBuf>,
pub first_index: BlockIndex,
@@ -205,7 +205,7 @@ pub struct GetTransactionsResponseArchivedTransactionsItem {
pub start: TxIndex,
/// System certificate for the hash of the latest block in the chain.
/// Only present if `get_blocks` is called in a non-replicated query context.
@@ -299,7 +299,7 @@
/// The number of transactions you can fetch using the callback.
pub length: candid::Nat,
}
-#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
+#[derive(CandidType, Deserialize)]
pub struct GetTransactionsResponse {
pub first_index: TxIndex,
pub log_length: candid::Nat,
@@ -339,7 +339,7 @@ pub struct GetBlocksResultArchivedBlocksItem {
/// The index of the first transaction in [transactions].
/// If the transaction vector is empty, the exact value of this field is not specified.
@@ -567,7 +567,7 @@
pub args: Vec<GetBlocksArgs>,
pub callback: GetBlocksResultArchivedBlocksItemCallback,
}
-#[derive(Serialize, Clone, Debug, CandidType, Deserialize)]
+#[derive(CandidType, Deserialize)]
pub struct GetBlocksResult {
pub log_length: candid::Nat,
pub blocks: Vec<GetBlocksResultBlocksItem>,
/// Total number of blocks in the
/// block log
Loading
Loading