Skip to content
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
3,298 changes: 1,883 additions & 1,415 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ic-cdk = "0.12"
ic-cdk-macros = "0.8"
ic-cdk-timers = "0.6"
ic-stable-structures = "0.6"
ic-nns-governance = { git = "https://github.com/dfinity/ic", tag = "release-2024-02-21_23-01", version = "0.9.0" }
ic-nns-common = { git = "https://github.com/dfinity/ic", tag = "release-2024-02-21_23-01", version = "0.9.0" }
ic-nns-governance = { git = "https://github.com/dfinity/ic", tag = "release-2025-01-09_03-19-base" }
ic-nns-common = { git = "https://github.com/dfinity/ic", tag = "release-2025-01-09_03-19-base" }

candid = "0.10"
candid_parser = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.75.0"
channel = "1.84.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
profile = "minimal"
7 changes: 2 additions & 5 deletions src/backend/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ ic-cdk-timers.workspace = true
ic-stable-structures.workspace = true
ic-nns-governance.workspace = true
ic-nns-common.workspace = true
ic-http-certification = { git = "https://github.com/dfinity/response-verification", features = [
"serde",
] }
ic-http-certification = "3"

candid.workspace = true
candid_parser.workspace = true
Expand All @@ -35,8 +33,7 @@ hex = "0.4"
lazy_static = "1.4"
base64.workspace = true

rand = { version = "0.8", default-features = false }
rand_chacha = { version = "0.3", default-features = false }
fastrand = "2"

[dev-dependencies]
mockall.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion src/backend/impl/src/controllers/http_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<I: ImageService, H: HttpService> HttpController<I, H> {
}
}

fn handle_http_request(&self, req: HttpRequest) -> HttpResponse {
fn handle_http_request(&self, req: HttpRequest) -> HttpResponse<'static> {
let req_path = req.get_path().expect("Missing path in request");

if req_path.starts_with(IMAGES_BASE_PATH) {
Expand Down
12 changes: 6 additions & 6 deletions src/backend/impl/src/controllers/init_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn init() {
let calling_principal = caller();

set_timer(Duration::from_secs(0), move || {
spawn(init_admin(calling_principal))
init_admin(calling_principal)
});

InitController::default().init_http_certification();
Expand All @@ -28,16 +28,16 @@ fn post_upgrade() {
let calling_principal = caller();

set_timer(Duration::from_secs(0), move || {
spawn(init_admin(calling_principal))
init_admin(calling_principal)
});

InitController::default().init_http_certification();

jobs::start_jobs();
}

async fn init_admin(calling_principal: Principal) {
if let Err(err) = InitController::default().init(calling_principal).await {
fn init_admin(calling_principal: Principal) {
if let Err(err) = InitController::default().init(calling_principal) {
ic_cdk::trap(&format!("Failed to initialize canister: {:?}", err));
}
}
Expand Down Expand Up @@ -73,8 +73,8 @@ impl<T: InitService, I: ImageService, H: HttpService> InitController<T, I, H> {
}
}

async fn init(&self, calling_principal: Principal) -> Result<(), ApiError> {
self.init_service.init(calling_principal).await
fn init(&self, calling_principal: Principal) -> Result<(), ApiError> {
self.init_service.init(calling_principal)
}

fn init_http_certification(&self) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ use crate::{

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn create_proposal_review_commit(
fn create_proposal_review_commit(
request: CreateProposalReviewCommitRequest,
) -> ApiResult<CreateProposalReviewCommitResponse> {
let calling_principal = caller();

ProposalReviewCommitController::default()
.create_proposal_review_commit(calling_principal, request)
.await
.into()
}

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn update_proposal_review_commit(
request: UpdateProposalReviewCommitRequest,
) -> ApiResult<()> {
fn update_proposal_review_commit(request: UpdateProposalReviewCommitRequest) -> ApiResult<()> {
let calling_principal = caller();

ProposalReviewCommitController::default()
Expand All @@ -44,9 +41,7 @@ async fn update_proposal_review_commit(

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn delete_proposal_review_commit(
request: DeleteProposalReviewCommitRequest,
) -> ApiResult<()> {
fn delete_proposal_review_commit(request: DeleteProposalReviewCommitRequest) -> ApiResult<()> {
let calling_principal = caller();

ProposalReviewCommitController::default()
Expand Down Expand Up @@ -89,7 +84,7 @@ impl<A: AccessControlService, P: ProposalReviewCommitService> ProposalReviewComm
}
}

async fn create_proposal_review_commit(
fn create_proposal_review_commit(
&self,
calling_principal: Principal,
request: CreateProposalReviewCommitRequest,
Expand All @@ -99,7 +94,6 @@ impl<A: AccessControlService, P: ProposalReviewCommitService> ProposalReviewComm

self.proposal_review_commit_service
.create_proposal_review_commit(calling_principal, request)
.await
}

fn update_proposal_review_commit(
Expand Down Expand Up @@ -138,7 +132,7 @@ mod tests {
use rstest::*;

#[rstest]
async fn create_proposal_review_commit() {
fn create_proposal_review_commit() {
let calling_principal = fixtures::principal_a();
let request = CreateProposalReviewCommitRequest {
proposal_review_id: "proposal_review_id".to_string(),
Expand Down Expand Up @@ -172,14 +166,13 @@ mod tests {

let result = controller
.create_proposal_review_commit(calling_principal, request)
.await
.unwrap();

assert_eq!(result, response);
}

#[rstest]
async fn create_proposal_review_commit_unauthorized() {
fn create_proposal_review_commit_unauthorized() {
let calling_principal = fixtures::principal_a();
let request = CreateProposalReviewCommitRequest {
proposal_review_id: "proposal_review_id".to_string(),
Expand Down Expand Up @@ -209,7 +202,6 @@ mod tests {

let result = controller
.create_proposal_review_commit(calling_principal, request)
.await
.unwrap_err();

assert_eq!(result, error);
Expand Down
30 changes: 11 additions & 19 deletions src/backend/impl/src/controllers/proposal_review_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ use ic_cdk::*;

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn create_proposal_review(
fn create_proposal_review(
request: CreateProposalReviewRequest,
) -> ApiResult<CreateProposalReviewResponse> {
let calling_principal = caller();

ProposalReviewController::default()
.create_proposal_review(calling_principal, request)
.await
.into()
}

Expand Down Expand Up @@ -65,14 +64,13 @@ fn get_proposal_review(request: GetProposalReviewRequest) -> ApiResult<GetPropos

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn create_proposal_review_image(
fn create_proposal_review_image(
request: CreateProposalReviewImageRequest,
) -> ApiResult<CreateProposalReviewImageResponse> {
let calling_principal = caller();

ProposalReviewController::default()
.create_proposal_review_image(calling_principal, request)
.await
.into()
}

Expand Down Expand Up @@ -142,7 +140,7 @@ impl<A: AccessControlService, P: ProposalReviewService> ProposalReviewController
}
}

async fn create_proposal_review(
fn create_proposal_review(
&self,
calling_principal: Principal,
request: CreateProposalReviewRequest,
Expand All @@ -152,8 +150,7 @@ impl<A: AccessControlService, P: ProposalReviewService> ProposalReviewController

let proposal_review = self
.proposal_review_service
.create_proposal_review(calling_principal, request)
.await?;
.create_proposal_review(calling_principal, request)?;

Ok(proposal_review)
}
Expand Down Expand Up @@ -188,7 +185,7 @@ impl<A: AccessControlService, P: ProposalReviewService> ProposalReviewController
.get_proposal_review(calling_principal, request)
}

async fn create_proposal_review_image(
fn create_proposal_review_image(
&self,
calling_principal: Principal,
request: CreateProposalReviewImageRequest,
Expand All @@ -198,7 +195,6 @@ impl<A: AccessControlService, P: ProposalReviewService> ProposalReviewController

self.proposal_review_service
.create_proposal_review_image(calling_principal, request)
.await
}

fn get_my_proposal_review(
Expand Down Expand Up @@ -254,7 +250,7 @@ mod tests {
use rstest::*;

#[rstest]
async fn create_proposal_review() {
fn create_proposal_review() {
let calling_principal = fixtures::principal_a();
let request = CreateProposalReviewRequest {
proposal_id: "proposal_id".to_string(),
Expand Down Expand Up @@ -289,14 +285,13 @@ mod tests {

let result = controller
.create_proposal_review(calling_principal, request)
.await
.unwrap();

assert_eq!(result, response);
}

#[rstest]
async fn create_proposal_review_unauthorized() {
fn create_proposal_review_unauthorized() {
let calling_principal = fixtures::principal_a();
let request = CreateProposalReviewRequest {
proposal_id: "proposal_id".to_string(),
Expand Down Expand Up @@ -328,7 +323,6 @@ mod tests {

let result = controller
.create_proposal_review(calling_principal, request)
.await
.unwrap_err();

assert_eq!(result, error);
Expand Down Expand Up @@ -409,7 +403,7 @@ mod tests {
}

#[rstest]
async fn create_proposal_review_image() {
fn create_proposal_review_image() {
let calling_principal = fixtures::principal_a();
let request = CreateProposalReviewImageRequest {
proposal_id: fixtures::proposal_id().to_string(),
Expand Down Expand Up @@ -441,14 +435,13 @@ mod tests {

let result = controller
.create_proposal_review_image(calling_principal, request)
.await
.unwrap();

assert_eq!(result, response);
}

#[rstest]
async fn create_proposal_review_image_unauthorized() {
fn create_proposal_review_image_unauthorized() {
let calling_principal = fixtures::principal_a();
let request = CreateProposalReviewImageRequest {
proposal_id: fixtures::proposal_id().to_string(),
Expand Down Expand Up @@ -479,14 +472,13 @@ mod tests {

let result = controller
.create_proposal_review_image(calling_principal, request)
.await
.unwrap_err();

assert_eq!(result, error);
}

#[rstest]
async fn delete_proposal_review_image() {
fn delete_proposal_review_image() {
let calling_principal = fixtures::principal_a();
let request = DeleteProposalReviewImageRequest {
proposal_id: fixtures::proposal_id().to_string(),
Expand Down Expand Up @@ -518,7 +510,7 @@ mod tests {
}

#[rstest]
async fn delete_proposal_review_image_unauthorized() {
fn delete_proposal_review_image_unauthorized() {
let calling_principal = fixtures::principal_a();
let request = DeleteProposalReviewImageRequest {
proposal_id: fixtures::proposal_id().to_string(),
Expand Down
16 changes: 6 additions & 10 deletions src/backend/impl/src/controllers/user_profile_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ fn get_my_user_profile_history() -> ApiResult<GetMyUserProfileHistoryResponse> {

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn create_my_user_profile() -> ApiResult<CreateMyUserProfileResponse> {
fn create_my_user_profile() -> ApiResult<CreateMyUserProfileResponse> {
let calling_principal = caller();

UserProfileController::default()
.create_my_user_profile(calling_principal)
.await
.into()
}

Expand All @@ -61,7 +60,7 @@ fn update_my_user_profile(request: UpdateMyUserProfileRequest) -> ApiResult<()>

#[update]
#[log_errors(crate::services::log_update_call_error)]
async fn update_user_profile(request: UpdateUserProfileRequest) -> ApiResult<()> {
fn update_user_profile(request: UpdateUserProfileRequest) -> ApiResult<()> {
let calling_principal = caller();

UserProfileController::default()
Expand Down Expand Up @@ -130,7 +129,7 @@ impl<A: AccessControlService, U: UserProfileService> UserProfileController<A, U>
Ok(profile_history)
}

async fn create_my_user_profile(
fn create_my_user_profile(
&self,
calling_principal: Principal,
) -> Result<CreateMyUserProfileResponse, ApiError> {
Expand All @@ -139,8 +138,7 @@ impl<A: AccessControlService, U: UserProfileService> UserProfileController<A, U>

let profile = self
.user_profile_service
.create_my_user_profile(calling_principal)
.await?;
.create_my_user_profile(calling_principal)?;

Ok(profile)
}
Expand Down Expand Up @@ -369,7 +367,7 @@ mod tests {
}

#[rstest]
async fn create_my_user_profile() {
fn create_my_user_profile() {
let calling_principal = fixtures::principal_a();
let profile = CreateMyUserProfileResponse {
id: "id".to_string(),
Expand All @@ -396,14 +394,13 @@ mod tests {

let result = controller
.create_my_user_profile(calling_principal)
.await
.unwrap();

assert_eq!(result, profile);
}

#[rstest]
async fn create_my_user_profile_anonymous_principal() {
fn create_my_user_profile_anonymous_principal() {
let calling_principal = Principal::anonymous();

let mut access_control_service_mock = MockAccessControlService::new();
Expand All @@ -420,7 +417,6 @@ mod tests {

let result = controller
.create_my_user_profile(calling_principal)
.await
.unwrap_err();

assert_eq!(result, ApiError::unauthenticated());
Expand Down
Loading
Loading