-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(nervous-system): Move Request implementations from canister …
…crates to rs/nervous_system/agent (#3657) This PR moves Request implementations from canister crates to rs/nervous_system/agent. This avoids the possibility of cyclic dependencies in case canister tests will need to use the agents. Additional changes entailed by this refactoring: 1. rs/nervous_system/agent now depends on SNS Gov API crate, not the internal one. 2. Similar for rs/sns/cli/ --------- Co-authored-by: Andre Popovitch <andre@popovit.ch>
- Loading branch information
Showing
53 changed files
with
922 additions
and
438 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
rs/nervous_system/agent/src/management_canister/requests.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use crate::Request; | ||
use candid::{CandidType, Principal}; | ||
use serde::Deserialize; | ||
|
||
// ```candid | ||
// type upload_chunk_args = record { | ||
// canister_id : principal; | ||
// chunk : blob; | ||
// }; | ||
// ``` | ||
#[derive(CandidType, Deserialize, Debug, Clone)] | ||
pub struct UploadChunkArgs { | ||
pub canister_id: Principal, | ||
pub chunk: Vec<u8>, | ||
} | ||
|
||
// ```candid | ||
// type chunk_hash = record { | ||
// hash : blob; | ||
// }; | ||
// ``` | ||
#[derive(CandidType, Deserialize, Debug, Clone)] | ||
pub struct ChunkHash { | ||
pub hash: Vec<u8>, | ||
} | ||
|
||
// ```candid | ||
// type upload_chunk_result = chunk_hash; | ||
// ``` | ||
pub type UploadChunksResult = ChunkHash; | ||
|
||
impl Request for UploadChunkArgs { | ||
fn method(&self) -> &'static str { | ||
"upload_chunk" | ||
} | ||
|
||
fn update(&self) -> bool { | ||
true | ||
} | ||
|
||
fn payload(&self) -> Result<Vec<u8>, candid::Error> { | ||
candid::encode_one(self) | ||
} | ||
|
||
type Response = UploadChunksResult; | ||
} | ||
|
||
// ```candid | ||
// type stored_chunks_args = record { | ||
// canister_id : canister_id; | ||
// }; | ||
// ``` | ||
#[derive(CandidType, Deserialize, Debug, Clone)] | ||
pub struct StoredChunksArgs { | ||
pub canister_id: Principal, | ||
} | ||
|
||
// ``` | ||
// type chunk_hash = record { | ||
// hash : blob; | ||
// }; | ||
// type stored_chunks_result = vec chunk_hash; | ||
// ``` | ||
pub type StoredChunksResult = Vec<ChunkHash>; | ||
|
||
impl Request for StoredChunksArgs { | ||
fn method(&self) -> &'static str { | ||
"stored_chunks" | ||
} | ||
|
||
fn update(&self) -> bool { | ||
true | ||
} | ||
|
||
fn payload(&self) -> Result<Vec<u8>, candid::Error> { | ||
candid::encode_one(self) | ||
} | ||
|
||
type Response = StoredChunksResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use crate::Request; | ||
use cycles_minting_canister::{CreateCanister, CreateCanisterResult}; | ||
|
||
impl Request for CreateCanister { | ||
fn method(&self) -> &'static str { | ||
"create_canister" | ||
} | ||
|
||
fn update(&self) -> bool { | ||
true | ||
} | ||
|
||
fn payload(&self) -> Result<Vec<u8>, candid::Error> { | ||
candid::encode_one(self) | ||
} | ||
|
||
type Response = CreateCanisterResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::Request; | ||
use ic_nns_governance_api::pb::v1::{ | ||
GetNeuronsFundAuditInfoRequest, GetNeuronsFundAuditInfoResponse, | ||
}; | ||
|
||
impl Request for GetNeuronsFundAuditInfoRequest { | ||
fn method(&self) -> &'static str { | ||
"get_neurons_fund_audit_info" | ||
} | ||
|
||
fn update(&self) -> bool { | ||
false | ||
} | ||
|
||
fn payload(&self) -> Result<Vec<u8>, candid::Error> { | ||
candid::encode_one(self) | ||
} | ||
|
||
type Response = GetNeuronsFundAuditInfoResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use crate::Request; | ||
use registry_canister::pb::v1::{GetSubnetForCanisterRequest, SubnetForCanister}; | ||
|
||
impl Request for GetSubnetForCanisterRequest { | ||
fn method(&self) -> &'static str { | ||
"get_subnet_for_canister" | ||
} | ||
|
||
fn update(&self) -> bool { | ||
false | ||
} | ||
|
||
fn payload(&self) -> Result<Vec<u8>, candid::Error> { | ||
candid::encode_one(self) | ||
} | ||
|
||
type Response = Result<SubnetForCanister, String>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.