Skip to content

Commit

Permalink
update backend 795874 (#2045)
Browse files Browse the repository at this point in the history
* Update backend

* Update declarations

* Add null check

* Add symbol

* Update icon

* Exclude stuck canisters

* Update db name

* Make bet optional

* Add slow spin

* Add experiments popup

* Add control

* Update db

* Show experiments button on hot feed

* Add delay & chunking

* Bump

* Move to top left

* Move to top-left postiion

* load first

* Update pos
  • Loading branch information
harsh-mn-yral authored Dec 19, 2023
1 parent f3e4ecf commit 4763ab2
Show file tree
Hide file tree
Showing 23 changed files with 248 additions and 183 deletions.
2 changes: 1 addition & 1 deletion packages/experiments/src/lib/idb/idb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Log from '../utils/Log'

export type IDBStores = 'up-down-watch-history'

const dbPromise = openDB('keyval-store', 8, {
const dbPromise = openDB('hot-or-not-experiments', 8, {
upgrade(db) {
if (!db.objectStoreNames.contains('up-down-watch-history')) {
db.createObjectStore('up-down-watch-history')
Expand Down
2 changes: 1 addition & 1 deletion packages/hot-or-not-backend-canister
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import type { ActorMethod } from '@dfinity/agent';
export interface ConfigurationInitArgs {
'known_principal_ids' : [] | [Array<[KnownPrincipalType, Principal]>],
'signups_enabled' : [] | [boolean],
'access_control_map' : [] | [Array<[Principal, Array<UserAccessRole>]>],
}
export type ErrorUpdateListOfWellKnownPrincipals = { 'Unauthorized' : null };
export type KnownPrincipalType = { 'CanisterIdUserIndex' : null } |
{ 'CanisterIdConfiguration' : null } |
{ 'CanisterIdProjectMemberIndex' : null } |
Expand All @@ -17,30 +15,20 @@ export type KnownPrincipalType = { 'CanisterIdUserIndex' : null } |
{ 'CanisterIdSNSController' : null } |
{ 'UserIdGlobalSuperAdmin' : null };
export type Result = { 'Ok' : null } |
{ 'Err' : ErrorUpdateListOfWellKnownPrincipals };
export type UserAccessRole = { 'CanisterController' : null } |
{ 'ProfileOwner' : null } |
{ 'CanisterAdmin' : null } |
{ 'ProjectCanister' : null };
{ 'Err' : string };
export interface _SERVICE {
'are_signups_enabled' : ActorMethod<[], boolean>,
'get_current_list_of_all_well_known_principal_values' : ActorMethod<
[],
Array<[KnownPrincipalType, Principal]>
>,
'get_user_roles' : ActorMethod<[Principal], Array<UserAccessRole>>,
'get_well_known_principal_value' : ActorMethod<
[KnownPrincipalType],
[] | [Principal]
>,
'toggle_signups_enabled' : ActorMethod<[], undefined>,
'toggle_signups_enabled' : ActorMethod<[], Result>,
'update_list_of_well_known_principals' : ActorMethod<
[KnownPrincipalType, Principal],
Result
>,
'update_user_add_role' : ActorMethod<[UserAccessRole, Principal], undefined>,
'update_user_remove_role' : ActorMethod<
[UserAccessRole, Principal],
undefined
>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,31 @@ export const idlFactory = ({ IDL }) => {
'CanisterIdSNSController' : IDL.Null,
'UserIdGlobalSuperAdmin' : IDL.Null,
});
const UserAccessRole = IDL.Variant({
'CanisterController' : IDL.Null,
'ProfileOwner' : IDL.Null,
'CanisterAdmin' : IDL.Null,
'ProjectCanister' : IDL.Null,
});
const ConfigurationInitArgs = IDL.Record({
'known_principal_ids' : IDL.Opt(
IDL.Vec(IDL.Tuple(KnownPrincipalType, IDL.Principal))
),
'signups_enabled' : IDL.Opt(IDL.Bool),
'access_control_map' : IDL.Opt(
IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Vec(UserAccessRole)))
),
});
const ErrorUpdateListOfWellKnownPrincipals = IDL.Variant({
'Unauthorized' : IDL.Null,
});
const Result = IDL.Variant({
'Ok' : IDL.Null,
'Err' : ErrorUpdateListOfWellKnownPrincipals,
});
const Result = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : IDL.Text });
return IDL.Service({
'are_signups_enabled' : IDL.Func([], [IDL.Bool], ['query']),
'get_current_list_of_all_well_known_principal_values' : IDL.Func(
[],
[IDL.Vec(IDL.Tuple(KnownPrincipalType, IDL.Principal))],
['query'],
),
'get_user_roles' : IDL.Func(
[IDL.Principal],
[IDL.Vec(UserAccessRole)],
['query'],
),
'get_well_known_principal_value' : IDL.Func(
[KnownPrincipalType],
[IDL.Opt(IDL.Principal)],
['query'],
),
'toggle_signups_enabled' : IDL.Func([], [], []),
'toggle_signups_enabled' : IDL.Func([], [Result], []),
'update_list_of_well_known_principals' : IDL.Func(
[KnownPrincipalType, IDL.Principal],
[Result],
[],
),
'update_user_add_role' : IDL.Func([UserAccessRole, IDL.Principal], [], []),
'update_user_remove_role' : IDL.Func(
[UserAccessRole, IDL.Principal],
[],
[],
),
});
};
export const init = ({ IDL }) => {
Expand All @@ -75,20 +49,11 @@ export const init = ({ IDL }) => {
'CanisterIdSNSController' : IDL.Null,
'UserIdGlobalSuperAdmin' : IDL.Null,
});
const UserAccessRole = IDL.Variant({
'CanisterController' : IDL.Null,
'ProfileOwner' : IDL.Null,
'CanisterAdmin' : IDL.Null,
'ProjectCanister' : IDL.Null,
});
const ConfigurationInitArgs = IDL.Record({
'known_principal_ids' : IDL.Opt(
IDL.Vec(IDL.Tuple(KnownPrincipalType, IDL.Principal))
),
'signups_enabled' : IDL.Opt(IDL.Bool),
'access_control_map' : IDL.Opt(
IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Vec(UserAccessRole)))
),
});
return [ConfigurationInitArgs];
};
10 changes: 8 additions & 2 deletions packages/web-client/declarations/configuration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { Actor, HttpAgent } from "@dfinity/agent";
import { idlFactory } from "./configuration.did.js";
export { idlFactory } from "./configuration.did.js";

// CANISTER_ID is replaced by webpack based on node environment
export const canisterId = process.env.CONFIGURATION_CANISTER_ID;
/* CANISTER_ID is replaced by webpack based on node environment
* Note: canister environment variable will be standardized as
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
* beginning in dfx 0.15.0
*/
export const canisterId =
process.env.CANISTER_ID_CONFIGURATION ||
process.env.CONFIGURATION_CANISTER_ID;

export const createActor = (canisterId, options = {}) => {
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
Expand Down
10 changes: 8 additions & 2 deletions packages/web-client/declarations/data_backup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { Actor, HttpAgent } from "@dfinity/agent";
import { idlFactory } from "./data_backup.did.js";
export { idlFactory } from "./data_backup.did.js";

// CANISTER_ID is replaced by webpack based on node environment
export const canisterId = process.env.DATA_BACKUP_CANISTER_ID;
/* CANISTER_ID is replaced by webpack based on node environment
* Note: canister environment variable will be standardized as
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
* beginning in dfx 0.15.0
*/
export const canisterId =
process.env.CANISTER_ID_DATA_BACKUP ||
process.env.DATA_BACKUP_CANISTER_ID;

export const createActor = (canisterId, options = {}) => {
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { Actor, HttpAgent } from "@dfinity/agent";
import { idlFactory } from "./individual_user_template.did.js";
export { idlFactory } from "./individual_user_template.did.js";

// CANISTER_ID is replaced by webpack based on node environment
export const canisterId = process.env.INDIVIDUAL_USER_TEMPLATE_CANISTER_ID;
/* CANISTER_ID is replaced by webpack based on node environment
* Note: canister environment variable will be standardized as
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
* beginning in dfx 0.15.0
*/
export const canisterId =
process.env.CANISTER_ID_INDIVIDUAL_USER_TEMPLATE ||
process.env.INDIVIDUAL_USER_TEMPLATE_CANISTER_ID;

export const createActor = (canisterId, options = {}) => {
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export type HotOrNotOutcomePayoutEvent = {
};
export interface IndividualUserTemplateInitArgs {
'known_principal_ids' : [] | [Array<[KnownPrincipalType, Principal]>],
'url_to_send_canister_metrics_to' : [] | [string],
'profile_owner' : [] | [Principal],
'upgrade_version_number' : [] | [bigint],
}
Expand Down Expand Up @@ -313,6 +314,7 @@ export interface _SERVICE {
'get_profile_details' : ActorMethod<[], UserProfileDetailsForFrontend>,
'get_rewarded_for_referral' : ActorMethod<[Principal, Principal], undefined>,
'get_rewarded_for_signing_up' : ActorMethod<[], undefined>,
'get_user_caniser_cycle_balance' : ActorMethod<[], bigint>,
'get_user_utility_token_transaction_history_with_pagination' : ActorMethod<
[bigint, bigint],
Result_5
Expand Down Expand Up @@ -354,7 +356,10 @@ export interface _SERVICE {
[Array<Principal>],
undefined
>,
'return_cycles_to_user_index_canister' : ActorMethod<[], undefined>,
'return_cycles_to_user_index_canister' : ActorMethod<
[[] | [bigint]],
undefined
>,
'update_post_add_view_details' : ActorMethod<
[bigint, PostViewDetailsFromFrontend],
undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const idlFactory = ({ IDL }) => {
'known_principal_ids' : IDL.Opt(
IDL.Vec(IDL.Tuple(KnownPrincipalType, IDL.Principal))
),
'url_to_send_canister_metrics_to' : IDL.Opt(IDL.Text),
'profile_owner' : IDL.Opt(IDL.Principal),
'upgrade_version_number' : IDL.Opt(IDL.Nat64),
});
Expand Down Expand Up @@ -350,6 +351,7 @@ export const idlFactory = ({ IDL }) => {
[],
),
'get_rewarded_for_signing_up' : IDL.Func([], [], []),
'get_user_caniser_cycle_balance' : IDL.Func([], [IDL.Nat], ['query']),
'get_user_utility_token_transaction_history_with_pagination' : IDL.Func(
[IDL.Nat64, IDL.Nat64],
[Result_5],
Expand Down Expand Up @@ -401,7 +403,11 @@ export const idlFactory = ({ IDL }) => {
[],
[],
),
'return_cycles_to_user_index_canister' : IDL.Func([], [], []),
'return_cycles_to_user_index_canister' : IDL.Func(
[IDL.Opt(IDL.Nat)],
[],
[],
),
'update_post_add_view_details' : IDL.Func(
[IDL.Nat64, PostViewDetailsFromFrontend],
[],
Expand Down Expand Up @@ -456,6 +462,7 @@ export const init = ({ IDL }) => {
'known_principal_ids' : IDL.Opt(
IDL.Vec(IDL.Tuple(KnownPrincipalType, IDL.Principal))
),
'url_to_send_canister_metrics_to' : IDL.Opt(IDL.Text),
'profile_owner' : IDL.Opt(IDL.Principal),
'upgrade_version_number' : IDL.Opt(IDL.Nat64),
});
Expand Down
10 changes: 8 additions & 2 deletions packages/web-client/declarations/post_cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { Actor, HttpAgent } from "@dfinity/agent";
import { idlFactory } from "./post_cache.did.js";
export { idlFactory } from "./post_cache.did.js";

// CANISTER_ID is replaced by webpack based on node environment
export const canisterId = process.env.POST_CACHE_CANISTER_ID;
/* CANISTER_ID is replaced by webpack based on node environment
* Note: canister environment variable will be standardized as
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
* beginning in dfx 0.15.0
*/
export const canisterId =
process.env.CANISTER_ID_POST_CACHE ||
process.env.POST_CACHE_CANISTER_ID;

export const createActor = (canisterId, options = {}) => {
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
Expand Down
10 changes: 8 additions & 2 deletions packages/web-client/declarations/user_index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import { Actor, HttpAgent } from "@dfinity/agent";
import { idlFactory } from "./user_index.did.js";
export { idlFactory } from "./user_index.did.js";

// CANISTER_ID is replaced by webpack based on node environment
export const canisterId = process.env.USER_INDEX_CANISTER_ID;
/* CANISTER_ID is replaced by webpack based on node environment
* Note: canister environment variable will be standardized as
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
* beginning in dfx 0.15.0
*/
export const canisterId =
process.env.CANISTER_ID_USER_INDEX ||
process.env.USER_INDEX_CANISTER_ID;

export const createActor = (canisterId, options = {}) => {
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
Expand Down
40 changes: 5 additions & 35 deletions packages/web-client/declarations/user_index/user_index.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ import type { ActorMethod } from '@dfinity/agent';
export type CanisterInstallMode = { 'reinstall' : null } |
{ 'upgrade' : null } |
{ 'install' : null };
export interface CanisterStatusResponse {
'status' : CanisterStatusType,
'memory_size' : bigint,
'cycles' : bigint,
'settings' : DefiniteCanisterSettings,
'idle_cycles_burned_per_day' : bigint,
'module_hash' : [] | [Uint8Array | number[]],
}
export type CanisterStatusType = { 'stopped' : null } |
{ 'stopping' : null } |
{ 'running' : null };
export interface DefiniteCanisterSettings {
'freezing_threshold' : bigint,
'controllers' : Array<Principal>,
'memory_allocation' : bigint,
'compute_allocation' : bigint,
}
export type KnownPrincipalType = { 'CanisterIdUserIndex' : null } |
{ 'CanisterIdConfiguration' : null } |
{ 'CanisterIdProjectMemberIndex' : null } |
Expand All @@ -30,9 +13,7 @@ export type KnownPrincipalType = { 'CanisterIdUserIndex' : null } |
{ 'CanisterIdPostCache' : null } |
{ 'CanisterIdSNSController' : null } |
{ 'UserIdGlobalSuperAdmin' : null };
export type Result = { 'Ok' : CanisterStatusResponse } |
{ 'Err' : string };
export type Result_1 = { 'Ok' : null } |
export type Result = { 'Ok' : null } |
{ 'Err' : SetUniqueUsernameError };
export type SetUniqueUsernameError = { 'UsernameAlreadyTaken' : null } |
{ 'SendingCanisterDoesNotMatchUserCanisterId' : null } |
Expand All @@ -44,7 +25,7 @@ export interface SystemTime {
export interface UpgradeStatus {
'version_number' : bigint,
'last_run_on' : SystemTime,
'failed_canister_ids' : Array<[Principal, Principal]>,
'failed_canister_ids' : Array<[Principal, Principal, string]>,
'successful_upgrade_count' : number,
}
export type UserAccessRole = { 'CanisterController' : null } |
Expand All @@ -57,10 +38,6 @@ export interface UserIndexInitArgs {
}
export interface _SERVICE {
'backup_all_individual_user_canisters' : ActorMethod<[], undefined>,
'get_canister_status_from_management_canister' : ActorMethod<
[Principal],
Result
>,
'get_index_details_is_user_name_taken' : ActorMethod<[string], boolean>,
'get_index_details_last_upgrade_status' : ActorMethod<[], UpgradeStatus>,
'get_requester_principals_canister_id_create_if_not_exists_and_optionally_allow_referrer' : ActorMethod<
Expand All @@ -75,6 +52,8 @@ export interface _SERVICE {
[Principal],
[] | [Principal]
>,
'get_user_index_canister_count' : ActorMethod<[], bigint>,
'get_user_index_canister_cycle_balance' : ActorMethod<[], bigint>,
'get_well_known_principal_value' : ActorMethod<
[KnownPrincipalType],
[] | [Principal]
Expand All @@ -83,18 +62,9 @@ export interface _SERVICE {
[Principal, Principal, string],
undefined
>,
'retry_upgrade_for_canisters_that_failed_upgrade_with_the_latest_wasm' : ActorMethod<
[],
Array<[Principal, Principal, string]>
>,
'topup_canisters_that_need_it' : ActorMethod<[], undefined>,
'update_index_with_unique_user_name_corresponding_to_user_principal_id' : ActorMethod<
[string, Principal],
Result_1
>,
'update_user_index_upgrade_user_canisters_with_latest_wasm' : ActorMethod<
[],
string
Result
>,
'upgrade_specific_individual_user_canister_with_latest_wasm' : ActorMethod<
[Principal, Principal, [] | [CanisterInstallMode]],
Expand Down
Loading

0 comments on commit 4763ab2

Please sign in to comment.