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

chore+fix: update dids #116

Merged
merged 1 commit into from
Mar 14, 2024
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
45 changes: 35 additions & 10 deletions did/individual_user_template.did
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ type HotOrNotOutcomePayoutEvent = variant {
post_canister_id : principal;
};
};
type HttpRequest = record {
url : text;
method : text;
body : vec nat8;
headers : vec record { text; text };
};
type HttpResponse = record {
body : vec nat8;
headers : vec record { text; text };
status_code : nat16;
};
type IndividualUserTemplateInitArgs = record {
known_principal_ids : opt vec record { KnownPrincipalType; principal };
version : text;
Expand Down Expand Up @@ -197,22 +208,25 @@ type Result_1 = variant {
Ok : BettingStatus;
Err : BetOnCurrentlyViewingPostError;
};
type Result_10 = variant { Ok; Err : text };
type Result_11 = variant { Ok; Err : UpdateProfileSetUniqueUsernameError };
type Result_2 = variant { Ok : bool; Err : FollowAnotherUserProfileError };
type Result_3 = variant { Ok : Post; Err };
type Result_4 = variant {
type Result_4 = variant { Ok : SystemTime; Err : text };
type Result_5 = variant {
Ok : vec PostDetailsForFrontend;
Err : GetPostsOfUserProfileError;
};
type Result_5 = variant {
type Result_6 = variant { Ok : SessionType; Err : text };
type Result_7 = variant {
Ok : vec record { nat64; TokenEvent };
Err : GetPostsOfUserProfileError;
};
type Result_6 = variant {
type Result_8 = variant { Ok : text; Err : text };
type Result_9 = variant {
Ok : UserProfileDetailsForFrontend;
Err : UpdateProfileDetailsError;
};
type Result_7 = variant { Ok; Err : text };
type Result_8 = variant { Ok; Err : UpdateProfileSetUniqueUsernameError };
type RoomBetPossibleOutcomes = variant { HotWon; BetOngoing; Draw; NotWon };
type RoomDetails = record {
total_hot_bets : nat64;
Expand All @@ -221,6 +235,7 @@ type RoomDetails = record {
room_bets_total_pot : nat64;
bet_outcome : RoomBetPossibleOutcomes;
};
type SessionType = variant { AnonymousSession; RegisteredSession };
type SlotDetails = record { room_details : vec record { nat64; RoomDetails } };
type StakeEvent = variant { BetOnHotOrNotPost : PlaceBetArg };
type SystemTime = record {
Expand Down Expand Up @@ -282,7 +297,9 @@ service : (IndividualUserTemplateInitArgs) -> {
check_and_update_scores_and_share_with_post_cache_if_difference_beyond_threshold : (
vec nat64,
) -> ();
clear_snapshot : () -> ();
do_i_follow_this_user : (FolloweeArg) -> (Result_2) query;
download_snapshot : (nat64, nat64) -> (vec nat8) query;
get_entire_individual_post_detail_by_id : (nat64) -> (Result_3) query;
get_hot_or_not_bet_details_for_this_post : (nat64) -> (BettingStatus) query;
get_hot_or_not_bets_placed_by_this_profile_with_pagination : (nat64) -> (
Expand All @@ -292,8 +309,9 @@ service : (IndividualUserTemplateInitArgs) -> {
opt PlacedBetDetail,
) query;
get_individual_post_details_by_id : (nat64) -> (PostDetailsForFrontend) query;
get_last_access_time : () -> (Result_4) query;
get_posts_of_this_user_profile_with_pagination : (nat64, nat64) -> (
Result_4,
Result_5,
) query;
get_principals_that_follow_this_profile_paginated : (opt nat64) -> (
vec record { nat64; FollowEntryDetail },
Expand All @@ -304,18 +322,22 @@ service : (IndividualUserTemplateInitArgs) -> {
get_profile_details : () -> (UserProfileDetailsForFrontend) query;
get_rewarded_for_referral : (principal, principal) -> ();
get_rewarded_for_signing_up : () -> ();
get_session_type : () -> (Result_6) query;
get_stable_memory_size : () -> (nat32) query;
get_user_caniser_cycle_balance : () -> (nat) query;
get_user_utility_token_transaction_history_with_pagination : (
nat64,
nat64,
) -> (Result_5) query;
) -> (Result_7) query;
get_utility_token_balance : () -> (nat64) query;
get_version : () -> (text) query;
get_version_number : () -> (nat64) query;
get_well_known_principal_value : (KnownPrincipalType) -> (
opt principal,
) query;
http_request : (HttpRequest) -> (HttpResponse) query;
load_snapshot : (nat64) -> ();
receive_and_save_snaphot : (nat64, vec nat8) -> ();
receive_bet_from_bet_makers_canister : (PlaceBetArg, principal) -> (Result_1);
receive_bet_winnings_when_distributed : (nat64, BetOutcomeForBetMaker) -> ();
receive_my_created_posts_from_data_backup_canister : (vec Post) -> ();
Expand All @@ -329,19 +351,22 @@ service : (IndividualUserTemplateInitArgs) -> {
vec principal,
) -> ();
return_cycles_to_user_index_canister : (opt nat) -> ();
save_snapshot_json : () -> (nat32);
update_last_access_time : () -> (Result_8);
update_post_add_view_details : (nat64, PostViewDetailsFromFrontend) -> ();
update_post_as_ready_to_view : (nat64) -> ();
update_post_increment_share_count : (nat64) -> (nat64);
update_post_toggle_like_status_by_caller : (nat64) -> (bool);
update_profile_display_details : (UserProfileUpdateDetailsFromFrontend) -> (
Result_6,
Result_9,
);
update_profile_owner : (opt principal) -> (Result_7);
update_profile_set_unique_username_once : (text) -> (Result_8);
update_profile_owner : (opt principal) -> (Result_10);
update_profile_set_unique_username_once : (text) -> (Result_11);
update_profiles_i_follow_toggle_list_with_specified_profile : (
FolloweeArg,
) -> (Result_2);
update_profiles_that_follow_me_toggle_list_with_specified_profile : (
FollowerArg,
) -> (Result_2);
update_session_type : (opt SessionType) -> (text);
}
28 changes: 23 additions & 5 deletions did/platform_orchestrator.did
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ type CanisterUpgradeStatus = record {
count : nat64;
upgrade_arg : UpgradeCanisterArg;
};
type HttpRequest = record {
url : text;
method : text;
body : vec nat8;
headers : vec record { text; text };
};
type HttpResponse = record {
body : vec nat8;
headers : vec record { text; text };
status_code : nat16;
};
type PlatformOrchestratorInitArgs = record { version : text };
type Result = variant { Ok : principal; Err : text };
type Result_1 = variant { Ok : text; Err : text };
type Result = variant { Ok : text; Err : text };
type Result_1 = variant { Ok : principal; Err : text };
type UpgradeCanisterArg = record {
version : text;
canister : WasmType;
Expand All @@ -17,12 +28,19 @@ type WasmType = variant {
SubnetOrchestratorWasm;
};
service : (PlatformOrchestratorInitArgs) -> {
deposit_cycles_to_canister : (principal, nat) -> (Result);
get_all_available_subnet_orchestrators : () -> (vec principal) query;
get_all_subnet_orchestrators : () -> (vec principal) query;
get_subnet_last_upgrade_status : () -> (CanisterUpgradeStatus) query;
get_version : () -> (text) query;
provision_subnet_orchestrator_canister : (principal) -> (Result);
http_request : (HttpRequest) -> (HttpResponse) query;
provision_subnet_orchestrator_canister : (principal) -> (Result_1);
start_reclaiming_cycles_from_individual_canisters : () -> (Result);
start_reclaiming_cycles_from_subnet_orchestrator_canister : () -> (text);
stop_upgrades_for_individual_user_canisters : () -> (Result);
subnet_orchestrator_maxed_out : () -> ();
upgrade_canister : (UpgradeCanisterArg) -> (Result_1);
upload_wasms : (WasmType, vec nat8) -> (Result_1);
update_profile_owner_for_individual_canisters : () -> ();
upgrade_canister : (UpgradeCanisterArg) -> (Result);
upgrade_specific_individual_canister : (principal) -> ();
upload_wasms : (WasmType, vec nat8) -> (Result);
}
35 changes: 18 additions & 17 deletions did/post_cache.did
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
type HttpRequest = record {
url : text;
method : text;
body : vec nat8;
headers : vec record { text; text };
};
type HttpResponse = record {
body : vec nat8;
headers : vec record { text; text };
status_code : nat16;
};
type KnownPrincipalType = variant {
CanisterIdUserIndex;
CanisterIdPlatformOrchestrator;
Expand All @@ -11,16 +22,12 @@ type KnownPrincipalType = variant {
CanisterIdSnsGovernance;
UserIdGlobalSuperAdmin;
};
type NsfwFilter = variant { IncludeNsfw; OnlyNsfw; ExcludeNsfw };
type PostCacheInitArgs = record {
known_principal_ids : opt vec record { KnownPrincipalType; principal };
version : text;
upgrade_version_number : opt nat64;
};
type PostScoreIndexItem = record {
post_id : nat64;
score : nat64;
publisher_canister_id : principal;
};
type PostScoreIndexItemV1 = record {
is_nsfw : bool;
status : PostStatus;
Expand All @@ -38,8 +45,7 @@ type PostStatus = variant {
Transcoding;
Deleted;
};
type Result = variant { Ok : vec PostScoreIndexItem; Err : TopPostsFetchError };
type Result_1 = variant {
type Result = variant {
Ok : vec PostScoreIndexItemV1;
Err : TopPostsFetchError;
};
Expand All @@ -54,29 +60,24 @@ type TopPostsFetchError = variant {
};
service : (PostCacheInitArgs) -> {
get_cycle_balance : () -> (nat) query;
get_top_posts_aggregated_from_canisters_on_this_network_for_home_feed : (
nat64,
nat64,
) -> (Result) query;
get_top_posts_aggregated_from_canisters_on_this_network_for_home_feed_cursor : (
nat64,
nat64,
opt bool,
opt PostStatus,
) -> (Result_1) query;
get_top_posts_aggregated_from_canisters_on_this_network_for_hot_or_not_feed : (
nat64,
nat64,
opt NsfwFilter,
) -> (Result) query;
get_top_posts_aggregated_from_canisters_on_this_network_for_hot_or_not_feed_cursor : (
nat64,
nat64,
opt bool,
opt PostStatus,
) -> (Result_1) query;
opt NsfwFilter,
) -> (Result) query;
get_well_known_principal_value : (KnownPrincipalType) -> (
opt principal,
) query;
http_request : (HttpRequest) -> (HttpResponse) query;
receive_top_home_feed_posts_from_publishing_canister : (
vec PostScoreIndexItemV1,
) -> ();
Expand All @@ -86,4 +87,4 @@ service : (PostCacheInitArgs) -> {
remove_all_feed_entries : () -> ();
update_post_home_feed : (PostScoreIndexItemV1) -> ();
update_post_hot_or_not_feed : (PostScoreIndexItemV1) -> ();
}
}
22 changes: 20 additions & 2 deletions did/user_index.did
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ type DefiniteCanisterSettings = record {
memory_allocation : nat;
compute_allocation : nat;
};
type HttpRequest = record {
url : text;
method : text;
body : vec nat8;
headers : vec record { text; text };
};
type HttpResponse = record {
body : vec nat8;
headers : vec record { text; text };
status_code : nat16;
};
type KnownPrincipalType = variant {
CanisterIdUserIndex;
CanisterIdPlatformOrchestrator;
Expand Down Expand Up @@ -93,33 +104,40 @@ service : (UserIndexInitArgs) -> {
opt principal,
) -> (principal);
get_subnet_available_capacity : () -> (nat64) query;
get_subnet_backup_capacity : () -> (nat64) query;
get_user_canister_id_from_unique_user_name : (text) -> (opt principal) query;
get_user_canister_id_from_user_principal_id : (principal) -> (
opt principal,
) query;
get_user_canister_incl_avail_list : () -> (vec principal) query;
get_user_canister_list : () -> (vec principal) query;
get_user_canister_status : (principal) -> (Result_1);
get_user_index_canister_count : () -> (nat64) query;
get_user_index_canister_cycle_balance : () -> (nat) query;
get_well_known_principal_value : (KnownPrincipalType) -> (
opt principal,
) query;
http_request : (HttpRequest) -> (HttpResponse) query;
receive_data_from_backup_canister_and_restore_data_to_heap : (
principal,
principal,
text,
) -> ();
reclaim_cycles_from_individual_canisters : () -> ();
reset_user_individual_canisters : (vec principal) -> (Result);
return_cycles_to_platform_orchestrator_canister : () -> (Result);
set_permission_to_upgrade_individual_canisters : (bool) -> (text);
start_upgrades_for_individual_canisters : (text, vec nat8) -> (text);
toggle_signups_enabled : () -> (Result_2);
update_index_with_unique_user_name_corresponding_to_user_principal_id : (
text,
principal,
) -> (Result_3);
update_profile_owner_for_individual_canisters : () -> ();
upgrade_specific_individual_user_canister_with_latest_wasm : (
principal,
principal,
opt principal,
opt CanisterInstallMode,
) -> (text);
validate_reset_user_individual_canisters : (vec principal) -> (Result) query;
}
}
14 changes: 11 additions & 3 deletions src/page/post_view/video_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use futures::{stream::FuturesOrdered, Stream, StreamExt};
use serde::{Deserialize, Serialize};

use crate::{
canister::{individual_user_template::PostDetailsForFrontend, post_cache},
canister::{
individual_user_template::PostDetailsForFrontend,
post_cache::{self, NsfwFilter},
},
state::canisters::Canisters,
utils::profile::propic_from_principal,
};
Expand Down Expand Up @@ -145,11 +148,16 @@ impl<'a, const AUTH: bool> VideoFetchStream<'a, AUTH> {
.get_top_posts_aggregated_from_canisters_on_this_network_for_hot_or_not_feed_cursor(
self.cursor.start,
self.cursor.limit,
if allow_nsfw { None } else { Some(false) },
None,
None,
Some(if allow_nsfw {
NsfwFilter::IncludeNsfw
} else {
NsfwFilter::ExcludeNsfw
}),
);
// TODO: error handling
let post_cache::Result1::Ok(top_posts) = top_posts_fut.await? else {
let post_cache::Result_::Ok(top_posts) = top_posts_fut.await? else {
return Err(PostViewError::Canister(
"canister refused to send posts".into(),
));
Expand Down
6 changes: 3 additions & 3 deletions src/page/refer_earn/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod history_provider {
from: usize,
end: usize,
) -> Result<PageEntry<HistoryDetails>, AgentError> {
use crate::canister::individual_user_template::{MintEvent, Result5, TokenEvent};
use crate::canister::individual_user_template::{MintEvent, Result7, TokenEvent};
use crate::utils::route::failure_redirect;
let individual = self.0.authenticated_user();
let history = individual
Expand All @@ -138,8 +138,8 @@ mod history_provider {
)
.await?;
let history = match history {
Result5::Ok(history) => history,
Result5::Err(_) => {
Result7::Ok(history) => history,
Result7::Err(_) => {
failure_redirect("failed to get posts");
return Ok(PageEntry {
data: vec![],
Expand Down
8 changes: 7 additions & 1 deletion src/page/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ async fn get_top_post_id() -> Result<Option<(Principal, u64)>, ServerFnError> {
let post_cache = canisters.post_cache();

let top_items = match post_cache
.get_top_posts_aggregated_from_canisters_on_this_network_for_hot_or_not_feed(0, 1)
.get_top_posts_aggregated_from_canisters_on_this_network_for_home_feed_cursor(
0,
1,
None,
None,
Some(post_cache::NsfwFilter::ExcludeNsfw),
komal-sai-yral marked this conversation as resolved.
Show resolved Hide resolved
)
.await?
{
post_cache::Result_::Ok(items) => items,
Expand Down
Loading
Loading