From 1629645b84d8ff658011b0ffdd97fcdf8ba1faaa Mon Sep 17 00:00:00 2001 From: 0xZensh Date: Fri, 11 Oct 2024 21:09:54 +0800 Subject: [PATCH] chore: add proposals to upgrade massaging app to v2.5 --- proposals/proposal-148.sh | 10 + proposals/proposal-149.sh | 29 ++ proposals/proposal-150.sh | 22 + proposals/proposal-151.sh | 10 + proposals/proposal-152.sh | 22 + proposals/proposal-153.sh | 22 + proposals/proposal-154.sh | 25 ++ proposals/proposal-155.sh | 25 ++ sns_functions.md | 11 + src/ic_message_frontend/package.json | 2 +- .../ic_oss_bucket/ic_oss_bucket.did | 194 +++++++++ .../ic_oss_bucket/ic_oss_bucket.did.d.ts | 276 +++++++++++++ .../ic_oss_bucket/ic_oss_bucket.did.js | 389 ++++++++++++++++++ .../src/declarations/ic_oss_bucket/index.d.ts | 50 +++ .../src/declarations/ic_oss_bucket/index.js | 42 ++ .../ic_oss_cluster/ic_oss_cluster.did | 102 +++++ .../ic_oss_cluster/ic_oss_cluster.did.d.ts | 160 +++++++ .../ic_oss_cluster/ic_oss_cluster.did.js | 216 ++++++++++ .../declarations/ic_oss_cluster/index.d.ts | 50 +++ .../src/declarations/ic_oss_cluster/index.js | 42 ++ src/ic_message_frontend/src/lib/constants.ts | 2 +- .../static/.ic-assets.json | 2 +- 22 files changed, 1700 insertions(+), 3 deletions(-) create mode 100755 proposals/proposal-148.sh create mode 100755 proposals/proposal-149.sh create mode 100755 proposals/proposal-150.sh create mode 100755 proposals/proposal-151.sh create mode 100755 proposals/proposal-152.sh create mode 100755 proposals/proposal-153.sh create mode 100755 proposals/proposal-154.sh create mode 100755 proposals/proposal-155.sh create mode 100644 sns_functions.md create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.d.ts create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.js create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_bucket/index.d.ts create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_bucket/index.js create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.d.ts create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.js create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_cluster/index.d.ts create mode 100644 src/ic_message_frontend/src/declarations/ic_oss_cluster/index.js diff --git a/proposals/proposal-148.sh b/proposals/proposal-148.sh new file mode 100755 index 0000000..bbd4971 --- /dev/null +++ b/proposals/proposal-148.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +export CANISTERS_PATH="$(pwd)/.dfx/ic/github" + +quill sns make-upgrade-canister-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE --target-canister-id "ijyxz-wyaaa-aaaaj-qa4qa-cai" --wasm-path "$CANISTERS_PATH/ic_message_profile.wasm.gz" $PROPOSAL_NEURON_ID > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-149.sh b/proposals/proposal-149.sh new file mode 100755 index 0000000..5f41fef --- /dev/null +++ b/proposals/proposal-149.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal '( + record { + title = "Add a generic function \"admin_add_canister\" to ic_message_profile service"; + url = "https://internetcomputer.org/docs/current/developer-docs/daos/sns/managing/sns-asset-canister#sns-genericnervoussystemfunctions"; + summary = "The `admin_add_canister` function is used to add more IC-OSS canisters to the messaging cluster."; + action = opt variant { + AddGenericNervousSystemFunction = record { + id = 1_105 : nat64; + name = "`admin_add_canister` function"; + description = opt "It is used to add more IC-OSS canisters to ic_message_profile service."; + function_type = opt variant { + GenericNervousSystemFunction = record { + validator_canister_id = opt principal "ijyxz-wyaaa-aaaaj-qa4qa-cai"; + target_canister_id = opt principal "ijyxz-wyaaa-aaaaj-qa4qa-cai"; + validator_method_name = opt "validate_admin_add_canister"; + target_method_name = opt "admin_add_canister"; + } + }; + } + }; + } +)' > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-150.sh b/proposals/proposal-150.sh new file mode 100755 index 0000000..5b07083 --- /dev/null +++ b/proposals/proposal-150.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +export BLOB="$(didc encode --format blob '(variant { OssCluster }, principal "5szpn-tiaaa-aaaaj-qncoq-cai")')" + +quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "( + record { + title = \"Try again: execute admin_add_canister() to add ic_oss_cluster canister to ic_message_profile service\"; + url = \"https://panda.fans/_/messages\"; + summary = \"This proposal executes admin_add_canister() on ijyxz-wyaaa-aaaaj-qa4qa-cai to add ic_oss_cluster canister to ic_message_profile service.\"; + action = opt variant { + ExecuteGenericNervousSystemFunction = record { + function_id = 1_105 : nat64; + payload = ${BLOB}; + } + }; + } +)" > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-151.sh b/proposals/proposal-151.sh new file mode 100755 index 0000000..bbd4971 --- /dev/null +++ b/proposals/proposal-151.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +export CANISTERS_PATH="$(pwd)/.dfx/ic/github" + +quill sns make-upgrade-canister-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE --target-canister-id "ijyxz-wyaaa-aaaaj-qa4qa-cai" --wasm-path "$CANISTERS_PATH/ic_message_profile.wasm.gz" $PROPOSAL_NEURON_ID > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-152.sh b/proposals/proposal-152.sh new file mode 100755 index 0000000..5b07083 --- /dev/null +++ b/proposals/proposal-152.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +export BLOB="$(didc encode --format blob '(variant { OssCluster }, principal "5szpn-tiaaa-aaaaj-qncoq-cai")')" + +quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "( + record { + title = \"Try again: execute admin_add_canister() to add ic_oss_cluster canister to ic_message_profile service\"; + url = \"https://panda.fans/_/messages\"; + summary = \"This proposal executes admin_add_canister() on ijyxz-wyaaa-aaaaj-qa4qa-cai to add ic_oss_cluster canister to ic_message_profile service.\"; + action = opt variant { + ExecuteGenericNervousSystemFunction = record { + function_id = 1_105 : nat64; + payload = ${BLOB}; + } + }; + } +)" > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-153.sh b/proposals/proposal-153.sh new file mode 100755 index 0000000..e6d0785 --- /dev/null +++ b/proposals/proposal-153.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +export BLOB="$(didc encode --format blob '(variant { OssBucket }, principal "532er-faaaa-aaaaj-qncpa-cai")')" + +quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "( + record { + title = \"Execute admin_add_canister() to add ic_oss_bucket canister to ic_message_profile service\"; + url = \"https://panda.fans/_/messages\"; + summary = \"This proposal executes admin_add_canister() on ijyxz-wyaaa-aaaaj-qa4qa-cai to add ic_oss_bucket canister to ic_message_profile service.\"; + action = opt variant { + ExecuteGenericNervousSystemFunction = record { + function_id = 1_105 : nat64; + payload = ${BLOB}; + } + }; + } +)" > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-154.sh b/proposals/proposal-154.sh new file mode 100755 index 0000000..9b00634 --- /dev/null +++ b/proposals/proposal-154.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +# build and get batch_id, evidence: +# dfx deploy ic_message_frontend --ic --by-proposal + +export BLOB="$(didc encode --format blob '(record {batch_id=15:nat; evidence=blob "\e0\a5\44\45\18\ec\f3\bd\c2\dc\0d\79\5d\f1\be\f9\94\16\72\38\6f\bf\d9\6e\26\73\b3\aa\69\f2\fe\29"})')" + +quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "( + record { + title = \"Execute commit_proposed_batch() to release ic_message_frontend v2.5.0\"; + url = \"https://panda.fans/\"; + summary = \"This proposal executes commit_proposed_batch() on 2fvu6-tqaaa-aaaap-akksa-cai to release ic_message_frontend v2.5.0.\n\n1. feat: Add profile image.\n2. feat: Add profile links.\"; + action = opt variant { + ExecuteGenericNervousSystemFunction = record { + function_id = 1100 : nat64; + payload = ${BLOB}; + } + }; + } +)" > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/proposals/proposal-155.sh b/proposals/proposal-155.sh new file mode 100755 index 0000000..cbb3259 --- /dev/null +++ b/proposals/proposal-155.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Load the environment variables +source "$(pwd)"/proposals/env.sh + +# build and get batch_id, evidence: +# dfx deploy ic_message_frontend --ic --by-proposal + +export BLOB="$(didc encode --format blob '(record {batch_id=16:nat; evidence=blob "\f8\33\a3\48\19\f6\46\67\b7\29\0a\84\0d\f0\b7\85\55\54\af\ff\bc\bb\d0\a8\dd\7c\fc\31\63\32\b1\af"})')" + +quill sns make-proposal --canister-ids-file ./sns_canister_ids.json --pem-file $PROPOSAL_PEM_FILE $PROPOSAL_NEURON_ID --proposal "( + record { + title = \"Execute commit_proposed_batch() to release ic_message_frontend v2.5.1\"; + url = \"https://panda.fans/\"; + summary = \"This proposal executes commit_proposed_batch() on 2fvu6-tqaaa-aaaap-akksa-cai to release ic_message_frontend v2.5.1.\n\n1. fix: Fix CSP header for images.\"; + action = opt variant { + ExecuteGenericNervousSystemFunction = record { + function_id = 1100 : nat64; + payload = ${BLOB}; + } + }; + } +)" > proposal-message.json + +# quill send proposal-message.json \ No newline at end of file diff --git a/sns_functions.md b/sns_functions.md new file mode 100644 index 0000000..a485ab8 --- /dev/null +++ b/sns_functions.md @@ -0,0 +1,11 @@ +1_000 c63a7-6yaaa-aaaap-ab3gq-cai commit_proposed_batch +1_001 a7cug-2qaaa-aaaap-ab3la-cai admin_set_managers +1_002 a7cug-2qaaa-aaaap-ab3la-cai admin_collect_icp +1_003 c63a7-6yaaa-aaaap-ab3gq-cai grant_permission +1_004 6sul7-xqaaa-aaaap-ahdsq-cai withdraw +1_100 2fvu6-tqaaa-aaaap-akksa-cai commit_proposed_batch +1_101 nscli-qiaaa-aaaaj-qa4pa-cai admin_add_canister +1_102 nscli-qiaaa-aaaaj-qa4pa-cai admin_update_price +1_103 nscli-qiaaa-aaaaj-qa4pa-cai admin_collect_token +1_104 nscli-qiaaa-aaaaj-qa4pa-cai admin_update_price +1_105 ijyxz-wyaaa-aaaaj-qa4qa-cai admin_add_canister \ No newline at end of file diff --git a/src/ic_message_frontend/package.json b/src/ic_message_frontend/package.json index 83f4825..9bbb813 100644 --- a/src/ic_message_frontend/package.json +++ b/src/ic_message_frontend/package.json @@ -81,5 +81,5 @@ "test": "vitest run" }, "type": "module", - "version": "2.5.0" + "version": "2.5.1" } \ No newline at end of file diff --git a/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did b/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did new file mode 100644 index 0000000..50deea0 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did @@ -0,0 +1,194 @@ +type BucketInfo = record { + status : int8; + total_chunks : nat64; + trusted_eddsa_pub_keys : vec blob; + managers : vec principal; + name : text; + max_custom_data_size : nat16; + auditors : vec principal; + total_files : nat64; + max_children : nat16; + enable_hash_index : bool; + max_file_size : nat64; + folder_id : nat32; + visibility : nat8; + max_folder_depth : nat8; + trusted_ecdsa_pub_keys : vec blob; + total_folders : nat64; + file_id : nat32; +}; +type CanisterArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs }; +type CanisterStatusResponse = record { + status : CanisterStatusType; + memory_size : nat; + cycles : nat; + settings : DefiniteCanisterSettings; + query_stats : QueryStats; + idle_cycles_burned_per_day : nat; + module_hash : opt blob; + reserved_cycles : nat; +}; +type CanisterStatusType = variant { stopped; stopping; running }; +type CreateFileInput = record { + dek : opt blob; + status : opt int8; + content : opt blob; + custom : opt vec record { text; MetadataValue }; + hash : opt blob; + name : text; + size : opt nat64; + content_type : text; + parent : nat32; +}; +type CreateFileOutput = record { id : nat32; created_at : nat64 }; +type CreateFolderInput = record { name : text; parent : nat32 }; +type DefiniteCanisterSettings = record { + freezing_threshold : nat; + controllers : vec principal; + reserved_cycles_limit : nat; + log_visibility : LogVisibility; + wasm_memory_limit : nat; + memory_allocation : nat; + compute_allocation : nat; +}; +type FileInfo = record { + ex : opt vec record { text; MetadataValue }; + id : nat32; + dek : opt blob; + status : int8; + updated_at : nat64; + custom : opt vec record { text; MetadataValue }; + hash : opt blob; + name : text; + size : nat64; + content_type : text; + created_at : nat64; + filled : nat64; + chunks : nat32; + parent : nat32; +}; +type FolderInfo = record { + id : nat32; + files : vec nat32; + status : int8; + updated_at : nat64; + name : text; + folders : vec nat32; + created_at : nat64; + parent : nat32; +}; +type FolderName = record { id : nat32; name : text }; +type InitArgs = record { + name : text; + max_custom_data_size : nat16; + max_children : nat16; + enable_hash_index : bool; + max_file_size : nat64; + visibility : nat8; + max_folder_depth : nat8; + file_id : nat32; +}; +type LogVisibility = variant { controllers; public }; +type MetadataValue = variant { Int : int; Nat : nat; Blob : blob; Text : text }; +type MoveInput = record { id : nat32; to : nat32; from : nat32 }; +type QueryStats = record { + response_payload_bytes_total : nat; + num_instructions_total : nat; + num_calls_total : nat; + request_payload_bytes_total : nat; +}; +type Result = variant { Ok; Err : text }; +type Result_1 = variant { Ok : vec nat32; Err : text }; +type Result_10 = variant { Ok : vec FileInfo; Err : text }; +type Result_11 = variant { Ok : vec FolderInfo; Err : text }; +type Result_12 = variant { Ok : UpdateFileOutput; Err : text }; +type Result_13 = variant { Ok : UpdateFileChunkOutput; Err : text }; +type Result_14 = variant { Ok : text; Err : text }; +type Result_2 = variant { Ok : CreateFileOutput; Err : text }; +type Result_3 = variant { Ok : bool; Err : text }; +type Result_4 = variant { Ok : BucketInfo; Err : text }; +type Result_5 = variant { Ok : CanisterStatusResponse; Err : text }; +type Result_6 = variant { Ok : vec FolderName; Err : text }; +type Result_7 = variant { Ok : vec record { nat32; blob }; Err : text }; +type Result_8 = variant { Ok : FileInfo; Err : text }; +type Result_9 = variant { Ok : FolderInfo; Err : text }; +type UpdateBucketInput = record { + status : opt int8; + trusted_eddsa_pub_keys : opt vec blob; + name : opt text; + max_custom_data_size : opt nat16; + max_children : opt nat16; + enable_hash_index : opt bool; + max_file_size : opt nat64; + visibility : opt nat8; + max_folder_depth : opt nat8; + trusted_ecdsa_pub_keys : opt vec blob; +}; +type UpdateFileChunkInput = record { + id : nat32; + chunk_index : nat32; + content : blob; +}; +type UpdateFileChunkOutput = record { updated_at : nat64; filled : nat64 }; +type UpdateFileInput = record { + id : nat32; + status : opt int8; + custom : opt vec record { text; MetadataValue }; + hash : opt blob; + name : opt text; + size : opt nat64; + content_type : opt text; +}; +type UpdateFileOutput = record { updated_at : nat64 }; +type UpdateFolderInput = record { + id : nat32; + status : opt int8; + name : opt text; +}; +type UpgradeArgs = record { + max_custom_data_size : opt nat16; + max_children : opt nat16; + enable_hash_index : opt bool; + max_file_size : opt nat64; + max_folder_depth : opt nat8; +}; +service : (opt CanisterArgs) -> { + admin_add_auditors : (vec principal) -> (Result); + admin_add_managers : (vec principal) -> (Result); + admin_remove_auditors : (vec principal) -> (Result); + admin_remove_managers : (vec principal) -> (Result); + admin_set_auditors : (vec principal) -> (Result); + admin_set_managers : (vec principal) -> (Result); + admin_update_bucket : (UpdateBucketInput) -> (Result); + api_version : () -> (nat16) query; + batch_delete_subfiles : (nat32, vec nat32, opt blob) -> (Result_1); + create_file : (CreateFileInput, opt blob) -> (Result_2); + create_folder : (CreateFolderInput, opt blob) -> (Result_2); + delete_file : (nat32, opt blob) -> (Result_3); + delete_folder : (nat32, opt blob) -> (Result_3); + get_bucket_info : (opt blob) -> (Result_4) query; + get_canister_status : () -> (Result_5); + get_file_ancestors : (nat32, opt blob) -> (Result_6) query; + get_file_chunks : (nat32, nat32, opt nat32, opt blob) -> (Result_7) query; + get_file_info : (nat32, opt blob) -> (Result_8) query; + get_file_info_by_hash : (blob, opt blob) -> (Result_8) query; + get_folder_ancestors : (nat32, opt blob) -> (Result_6) query; + get_folder_info : (nat32, opt blob) -> (Result_9) query; + list_files : (nat32, opt nat32, opt nat32, opt blob) -> (Result_10) query; + list_folders : (nat32, opt nat32, opt nat32, opt blob) -> (Result_11) query; + move_file : (MoveInput, opt blob) -> (Result_12); + move_folder : (MoveInput, opt blob) -> (Result_12); + update_file_chunk : (UpdateFileChunkInput, opt blob) -> (Result_13); + update_file_info : (UpdateFileInput, opt blob) -> (Result_12); + update_folder_info : (UpdateFolderInput, opt blob) -> (Result_12); + validate2_admin_set_auditors : (vec principal) -> (Result_14); + validate2_admin_set_managers : (vec principal) -> (Result_14); + validate2_admin_update_bucket : (UpdateBucketInput) -> (Result_14); + validate_admin_add_auditors : (vec principal) -> (Result_14); + validate_admin_add_managers : (vec principal) -> (Result_14); + validate_admin_remove_auditors : (vec principal) -> (Result_14); + validate_admin_remove_managers : (vec principal) -> (Result_14); + validate_admin_set_auditors : (vec principal) -> (Result); + validate_admin_set_managers : (vec principal) -> (Result); + validate_admin_update_bucket : (UpdateBucketInput) -> (Result); +} diff --git a/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.d.ts b/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.d.ts new file mode 100644 index 0000000..c9724ae --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.d.ts @@ -0,0 +1,276 @@ +import type { Principal } from '@dfinity/principal'; +import type { ActorMethod } from '@dfinity/agent'; +import type { IDL } from '@dfinity/candid'; + +export interface BucketInfo { + 'status' : number, + 'total_chunks' : bigint, + 'trusted_eddsa_pub_keys' : Array, + 'managers' : Array, + 'name' : string, + 'max_custom_data_size' : number, + 'auditors' : Array, + 'total_files' : bigint, + 'max_children' : number, + 'enable_hash_index' : boolean, + 'max_file_size' : bigint, + 'folder_id' : number, + 'visibility' : number, + 'max_folder_depth' : number, + 'trusted_ecdsa_pub_keys' : Array, + 'total_folders' : bigint, + 'file_id' : number, +} +export type CanisterArgs = { 'Upgrade' : UpgradeArgs } | + { 'Init' : InitArgs }; +export interface CanisterStatusResponse { + 'status' : CanisterStatusType, + 'memory_size' : bigint, + 'cycles' : bigint, + 'settings' : DefiniteCanisterSettings, + 'query_stats' : QueryStats, + 'idle_cycles_burned_per_day' : bigint, + 'module_hash' : [] | [Uint8Array | number[]], + 'reserved_cycles' : bigint, +} +export type CanisterStatusType = { 'stopped' : null } | + { 'stopping' : null } | + { 'running' : null }; +export interface CreateFileInput { + 'dek' : [] | [Uint8Array | number[]], + 'status' : [] | [number], + 'content' : [] | [Uint8Array | number[]], + 'custom' : [] | [Array<[string, MetadataValue]>], + 'hash' : [] | [Uint8Array | number[]], + 'name' : string, + 'size' : [] | [bigint], + 'content_type' : string, + 'parent' : number, +} +export interface CreateFileOutput { 'id' : number, 'created_at' : bigint } +export interface CreateFolderInput { 'name' : string, 'parent' : number } +export interface DefiniteCanisterSettings { + 'freezing_threshold' : bigint, + 'controllers' : Array, + 'reserved_cycles_limit' : bigint, + 'log_visibility' : LogVisibility, + 'wasm_memory_limit' : bigint, + 'memory_allocation' : bigint, + 'compute_allocation' : bigint, +} +export interface FileInfo { + 'ex' : [] | [Array<[string, MetadataValue]>], + 'id' : number, + 'dek' : [] | [Uint8Array | number[]], + 'status' : number, + 'updated_at' : bigint, + 'custom' : [] | [Array<[string, MetadataValue]>], + 'hash' : [] | [Uint8Array | number[]], + 'name' : string, + 'size' : bigint, + 'content_type' : string, + 'created_at' : bigint, + 'filled' : bigint, + 'chunks' : number, + 'parent' : number, +} +export interface FolderInfo { + 'id' : number, + 'files' : Uint32Array | number[], + 'status' : number, + 'updated_at' : bigint, + 'name' : string, + 'folders' : Uint32Array | number[], + 'created_at' : bigint, + 'parent' : number, +} +export interface FolderName { 'id' : number, 'name' : string } +export interface InitArgs { + 'name' : string, + 'max_custom_data_size' : number, + 'max_children' : number, + 'enable_hash_index' : boolean, + 'max_file_size' : bigint, + 'visibility' : number, + 'max_folder_depth' : number, + 'file_id' : number, +} +export type LogVisibility = { 'controllers' : null } | + { 'public' : null }; +export type MetadataValue = { 'Int' : bigint } | + { 'Nat' : bigint } | + { 'Blob' : Uint8Array | number[] } | + { 'Text' : string }; +export interface MoveInput { 'id' : number, 'to' : number, 'from' : number } +export interface QueryStats { + 'response_payload_bytes_total' : bigint, + 'num_instructions_total' : bigint, + 'num_calls_total' : bigint, + 'request_payload_bytes_total' : bigint, +} +export type Result = { 'Ok' : null } | + { 'Err' : string }; +export type Result_1 = { 'Ok' : Uint32Array | number[] } | + { 'Err' : string }; +export type Result_10 = { 'Ok' : Array } | + { 'Err' : string }; +export type Result_11 = { 'Ok' : Array } | + { 'Err' : string }; +export type Result_12 = { 'Ok' : UpdateFileOutput } | + { 'Err' : string }; +export type Result_13 = { 'Ok' : UpdateFileChunkOutput } | + { 'Err' : string }; +export type Result_14 = { 'Ok' : string } | + { 'Err' : string }; +export type Result_2 = { 'Ok' : CreateFileOutput } | + { 'Err' : string }; +export type Result_3 = { 'Ok' : boolean } | + { 'Err' : string }; +export type Result_4 = { 'Ok' : BucketInfo } | + { 'Err' : string }; +export type Result_5 = { 'Ok' : CanisterStatusResponse } | + { 'Err' : string }; +export type Result_6 = { 'Ok' : Array } | + { 'Err' : string }; +export type Result_7 = { 'Ok' : Array<[number, Uint8Array | number[]]> } | + { 'Err' : string }; +export type Result_8 = { 'Ok' : FileInfo } | + { 'Err' : string }; +export type Result_9 = { 'Ok' : FolderInfo } | + { 'Err' : string }; +export interface UpdateBucketInput { + 'status' : [] | [number], + 'trusted_eddsa_pub_keys' : [] | [Array], + 'name' : [] | [string], + 'max_custom_data_size' : [] | [number], + 'max_children' : [] | [number], + 'enable_hash_index' : [] | [boolean], + 'max_file_size' : [] | [bigint], + 'visibility' : [] | [number], + 'max_folder_depth' : [] | [number], + 'trusted_ecdsa_pub_keys' : [] | [Array], +} +export interface UpdateFileChunkInput { + 'id' : number, + 'chunk_index' : number, + 'content' : Uint8Array | number[], +} +export interface UpdateFileChunkOutput { + 'updated_at' : bigint, + 'filled' : bigint, +} +export interface UpdateFileInput { + 'id' : number, + 'status' : [] | [number], + 'custom' : [] | [Array<[string, MetadataValue]>], + 'hash' : [] | [Uint8Array | number[]], + 'name' : [] | [string], + 'size' : [] | [bigint], + 'content_type' : [] | [string], +} +export interface UpdateFileOutput { 'updated_at' : bigint } +export interface UpdateFolderInput { + 'id' : number, + 'status' : [] | [number], + 'name' : [] | [string], +} +export interface UpgradeArgs { + 'max_custom_data_size' : [] | [number], + 'max_children' : [] | [number], + 'enable_hash_index' : [] | [boolean], + 'max_file_size' : [] | [bigint], + 'max_folder_depth' : [] | [number], +} +export interface _SERVICE { + 'admin_add_auditors' : ActorMethod<[Array], Result>, + 'admin_add_managers' : ActorMethod<[Array], Result>, + 'admin_remove_auditors' : ActorMethod<[Array], Result>, + 'admin_remove_managers' : ActorMethod<[Array], Result>, + 'admin_set_auditors' : ActorMethod<[Array], Result>, + 'admin_set_managers' : ActorMethod<[Array], Result>, + 'admin_update_bucket' : ActorMethod<[UpdateBucketInput], Result>, + 'api_version' : ActorMethod<[], number>, + 'batch_delete_subfiles' : ActorMethod< + [number, Uint32Array | number[], [] | [Uint8Array | number[]]], + Result_1 + >, + 'create_file' : ActorMethod< + [CreateFileInput, [] | [Uint8Array | number[]]], + Result_2 + >, + 'create_folder' : ActorMethod< + [CreateFolderInput, [] | [Uint8Array | number[]]], + Result_2 + >, + 'delete_file' : ActorMethod<[number, [] | [Uint8Array | number[]]], Result_3>, + 'delete_folder' : ActorMethod< + [number, [] | [Uint8Array | number[]]], + Result_3 + >, + 'get_bucket_info' : ActorMethod<[[] | [Uint8Array | number[]]], Result_4>, + 'get_canister_status' : ActorMethod<[], Result_5>, + 'get_file_ancestors' : ActorMethod< + [number, [] | [Uint8Array | number[]]], + Result_6 + >, + 'get_file_chunks' : ActorMethod< + [number, number, [] | [number], [] | [Uint8Array | number[]]], + Result_7 + >, + 'get_file_info' : ActorMethod< + [number, [] | [Uint8Array | number[]]], + Result_8 + >, + 'get_file_info_by_hash' : ActorMethod< + [Uint8Array | number[], [] | [Uint8Array | number[]]], + Result_8 + >, + 'get_folder_ancestors' : ActorMethod< + [number, [] | [Uint8Array | number[]]], + Result_6 + >, + 'get_folder_info' : ActorMethod< + [number, [] | [Uint8Array | number[]]], + Result_9 + >, + 'list_files' : ActorMethod< + [number, [] | [number], [] | [number], [] | [Uint8Array | number[]]], + Result_10 + >, + 'list_folders' : ActorMethod< + [number, [] | [number], [] | [number], [] | [Uint8Array | number[]]], + Result_11 + >, + 'move_file' : ActorMethod< + [MoveInput, [] | [Uint8Array | number[]]], + Result_12 + >, + 'move_folder' : ActorMethod< + [MoveInput, [] | [Uint8Array | number[]]], + Result_12 + >, + 'update_file_chunk' : ActorMethod< + [UpdateFileChunkInput, [] | [Uint8Array | number[]]], + Result_13 + >, + 'update_file_info' : ActorMethod< + [UpdateFileInput, [] | [Uint8Array | number[]]], + Result_12 + >, + 'update_folder_info' : ActorMethod< + [UpdateFolderInput, [] | [Uint8Array | number[]]], + Result_12 + >, + 'validate2_admin_set_auditors' : ActorMethod<[Array], Result_14>, + 'validate2_admin_set_managers' : ActorMethod<[Array], Result_14>, + 'validate2_admin_update_bucket' : ActorMethod<[UpdateBucketInput], Result_14>, + 'validate_admin_add_auditors' : ActorMethod<[Array], Result_14>, + 'validate_admin_add_managers' : ActorMethod<[Array], Result_14>, + 'validate_admin_remove_auditors' : ActorMethod<[Array], Result_14>, + 'validate_admin_remove_managers' : ActorMethod<[Array], Result_14>, + 'validate_admin_set_auditors' : ActorMethod<[Array], Result>, + 'validate_admin_set_managers' : ActorMethod<[Array], Result>, + 'validate_admin_update_bucket' : ActorMethod<[UpdateBucketInput], Result>, +} +export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.js b/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.js new file mode 100644 index 0000000..34f2ad3 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_bucket/ic_oss_bucket.did.js @@ -0,0 +1,389 @@ +export const idlFactory = ({ IDL }) => { + const UpgradeArgs = IDL.Record({ + 'max_custom_data_size' : IDL.Opt(IDL.Nat16), + 'max_children' : IDL.Opt(IDL.Nat16), + 'enable_hash_index' : IDL.Opt(IDL.Bool), + 'max_file_size' : IDL.Opt(IDL.Nat64), + 'max_folder_depth' : IDL.Opt(IDL.Nat8), + }); + const InitArgs = IDL.Record({ + 'name' : IDL.Text, + 'max_custom_data_size' : IDL.Nat16, + 'max_children' : IDL.Nat16, + 'enable_hash_index' : IDL.Bool, + 'max_file_size' : IDL.Nat64, + 'visibility' : IDL.Nat8, + 'max_folder_depth' : IDL.Nat8, + 'file_id' : IDL.Nat32, + }); + const CanisterArgs = IDL.Variant({ + 'Upgrade' : UpgradeArgs, + 'Init' : InitArgs, + }); + const Result = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : IDL.Text }); + const UpdateBucketInput = IDL.Record({ + 'status' : IDL.Opt(IDL.Int8), + 'trusted_eddsa_pub_keys' : IDL.Opt(IDL.Vec(IDL.Vec(IDL.Nat8))), + 'name' : IDL.Opt(IDL.Text), + 'max_custom_data_size' : IDL.Opt(IDL.Nat16), + 'max_children' : IDL.Opt(IDL.Nat16), + 'enable_hash_index' : IDL.Opt(IDL.Bool), + 'max_file_size' : IDL.Opt(IDL.Nat64), + 'visibility' : IDL.Opt(IDL.Nat8), + 'max_folder_depth' : IDL.Opt(IDL.Nat8), + 'trusted_ecdsa_pub_keys' : IDL.Opt(IDL.Vec(IDL.Vec(IDL.Nat8))), + }); + const Result_1 = IDL.Variant({ 'Ok' : IDL.Vec(IDL.Nat32), 'Err' : IDL.Text }); + const MetadataValue = IDL.Variant({ + 'Int' : IDL.Int, + 'Nat' : IDL.Nat, + 'Blob' : IDL.Vec(IDL.Nat8), + 'Text' : IDL.Text, + }); + const CreateFileInput = IDL.Record({ + 'dek' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'status' : IDL.Opt(IDL.Int8), + 'content' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'custom' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))), + 'hash' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'name' : IDL.Text, + 'size' : IDL.Opt(IDL.Nat64), + 'content_type' : IDL.Text, + 'parent' : IDL.Nat32, + }); + const CreateFileOutput = IDL.Record({ + 'id' : IDL.Nat32, + 'created_at' : IDL.Nat64, + }); + const Result_2 = IDL.Variant({ 'Ok' : CreateFileOutput, 'Err' : IDL.Text }); + const CreateFolderInput = IDL.Record({ + 'name' : IDL.Text, + 'parent' : IDL.Nat32, + }); + const Result_3 = IDL.Variant({ 'Ok' : IDL.Bool, 'Err' : IDL.Text }); + const BucketInfo = IDL.Record({ + 'status' : IDL.Int8, + 'total_chunks' : IDL.Nat64, + 'trusted_eddsa_pub_keys' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'managers' : IDL.Vec(IDL.Principal), + 'name' : IDL.Text, + 'max_custom_data_size' : IDL.Nat16, + 'auditors' : IDL.Vec(IDL.Principal), + 'total_files' : IDL.Nat64, + 'max_children' : IDL.Nat16, + 'enable_hash_index' : IDL.Bool, + 'max_file_size' : IDL.Nat64, + 'folder_id' : IDL.Nat32, + 'visibility' : IDL.Nat8, + 'max_folder_depth' : IDL.Nat8, + 'trusted_ecdsa_pub_keys' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'total_folders' : IDL.Nat64, + 'file_id' : IDL.Nat32, + }); + const Result_4 = IDL.Variant({ 'Ok' : BucketInfo, 'Err' : IDL.Text }); + const CanisterStatusType = IDL.Variant({ + 'stopped' : IDL.Null, + 'stopping' : IDL.Null, + 'running' : IDL.Null, + }); + const LogVisibility = IDL.Variant({ + 'controllers' : IDL.Null, + 'public' : IDL.Null, + }); + const DefiniteCanisterSettings = IDL.Record({ + 'freezing_threshold' : IDL.Nat, + 'controllers' : IDL.Vec(IDL.Principal), + 'reserved_cycles_limit' : IDL.Nat, + 'log_visibility' : LogVisibility, + 'wasm_memory_limit' : IDL.Nat, + 'memory_allocation' : IDL.Nat, + 'compute_allocation' : IDL.Nat, + }); + const QueryStats = IDL.Record({ + 'response_payload_bytes_total' : IDL.Nat, + 'num_instructions_total' : IDL.Nat, + 'num_calls_total' : IDL.Nat, + 'request_payload_bytes_total' : IDL.Nat, + }); + const CanisterStatusResponse = IDL.Record({ + 'status' : CanisterStatusType, + 'memory_size' : IDL.Nat, + 'cycles' : IDL.Nat, + 'settings' : DefiniteCanisterSettings, + 'query_stats' : QueryStats, + 'idle_cycles_burned_per_day' : IDL.Nat, + 'module_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'reserved_cycles' : IDL.Nat, + }); + const Result_5 = IDL.Variant({ + 'Ok' : CanisterStatusResponse, + 'Err' : IDL.Text, + }); + const FolderName = IDL.Record({ 'id' : IDL.Nat32, 'name' : IDL.Text }); + const Result_6 = IDL.Variant({ + 'Ok' : IDL.Vec(FolderName), + 'Err' : IDL.Text, + }); + const Result_7 = IDL.Variant({ + 'Ok' : IDL.Vec(IDL.Tuple(IDL.Nat32, IDL.Vec(IDL.Nat8))), + 'Err' : IDL.Text, + }); + const FileInfo = IDL.Record({ + 'ex' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))), + 'id' : IDL.Nat32, + 'dek' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'status' : IDL.Int8, + 'updated_at' : IDL.Nat64, + 'custom' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))), + 'hash' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'name' : IDL.Text, + 'size' : IDL.Nat64, + 'content_type' : IDL.Text, + 'created_at' : IDL.Nat64, + 'filled' : IDL.Nat64, + 'chunks' : IDL.Nat32, + 'parent' : IDL.Nat32, + }); + const Result_8 = IDL.Variant({ 'Ok' : FileInfo, 'Err' : IDL.Text }); + const FolderInfo = IDL.Record({ + 'id' : IDL.Nat32, + 'files' : IDL.Vec(IDL.Nat32), + 'status' : IDL.Int8, + 'updated_at' : IDL.Nat64, + 'name' : IDL.Text, + 'folders' : IDL.Vec(IDL.Nat32), + 'created_at' : IDL.Nat64, + 'parent' : IDL.Nat32, + }); + const Result_9 = IDL.Variant({ 'Ok' : FolderInfo, 'Err' : IDL.Text }); + const Result_10 = IDL.Variant({ 'Ok' : IDL.Vec(FileInfo), 'Err' : IDL.Text }); + const Result_11 = IDL.Variant({ + 'Ok' : IDL.Vec(FolderInfo), + 'Err' : IDL.Text, + }); + const MoveInput = IDL.Record({ + 'id' : IDL.Nat32, + 'to' : IDL.Nat32, + 'from' : IDL.Nat32, + }); + const UpdateFileOutput = IDL.Record({ 'updated_at' : IDL.Nat64 }); + const Result_12 = IDL.Variant({ 'Ok' : UpdateFileOutput, 'Err' : IDL.Text }); + const UpdateFileChunkInput = IDL.Record({ + 'id' : IDL.Nat32, + 'chunk_index' : IDL.Nat32, + 'content' : IDL.Vec(IDL.Nat8), + }); + const UpdateFileChunkOutput = IDL.Record({ + 'updated_at' : IDL.Nat64, + 'filled' : IDL.Nat64, + }); + const Result_13 = IDL.Variant({ + 'Ok' : UpdateFileChunkOutput, + 'Err' : IDL.Text, + }); + const UpdateFileInput = IDL.Record({ + 'id' : IDL.Nat32, + 'status' : IDL.Opt(IDL.Int8), + 'custom' : IDL.Opt(IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))), + 'hash' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'name' : IDL.Opt(IDL.Text), + 'size' : IDL.Opt(IDL.Nat64), + 'content_type' : IDL.Opt(IDL.Text), + }); + const UpdateFolderInput = IDL.Record({ + 'id' : IDL.Nat32, + 'status' : IDL.Opt(IDL.Int8), + 'name' : IDL.Opt(IDL.Text), + }); + const Result_14 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : IDL.Text }); + return IDL.Service({ + 'admin_add_auditors' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), + 'admin_add_managers' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), + 'admin_remove_auditors' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), + 'admin_remove_managers' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), + 'admin_set_auditors' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), + 'admin_set_managers' : IDL.Func([IDL.Vec(IDL.Principal)], [Result], []), + 'admin_update_bucket' : IDL.Func([UpdateBucketInput], [Result], []), + 'api_version' : IDL.Func([], [IDL.Nat16], ['query']), + 'batch_delete_subfiles' : IDL.Func( + [IDL.Nat32, IDL.Vec(IDL.Nat32), IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'create_file' : IDL.Func( + [CreateFileInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_2], + [], + ), + 'create_folder' : IDL.Func( + [CreateFolderInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_2], + [], + ), + 'delete_file' : IDL.Func( + [IDL.Nat32, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_3], + [], + ), + 'delete_folder' : IDL.Func( + [IDL.Nat32, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_3], + [], + ), + 'get_bucket_info' : IDL.Func( + [IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_4], + ['query'], + ), + 'get_canister_status' : IDL.Func([], [Result_5], []), + 'get_file_ancestors' : IDL.Func( + [IDL.Nat32, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_6], + ['query'], + ), + 'get_file_chunks' : IDL.Func( + [IDL.Nat32, IDL.Nat32, IDL.Opt(IDL.Nat32), IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_7], + ['query'], + ), + 'get_file_info' : IDL.Func( + [IDL.Nat32, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_8], + ['query'], + ), + 'get_file_info_by_hash' : IDL.Func( + [IDL.Vec(IDL.Nat8), IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_8], + ['query'], + ), + 'get_folder_ancestors' : IDL.Func( + [IDL.Nat32, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_6], + ['query'], + ), + 'get_folder_info' : IDL.Func( + [IDL.Nat32, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_9], + ['query'], + ), + 'list_files' : IDL.Func( + [ + IDL.Nat32, + IDL.Opt(IDL.Nat32), + IDL.Opt(IDL.Nat32), + IDL.Opt(IDL.Vec(IDL.Nat8)), + ], + [Result_10], + ['query'], + ), + 'list_folders' : IDL.Func( + [ + IDL.Nat32, + IDL.Opt(IDL.Nat32), + IDL.Opt(IDL.Nat32), + IDL.Opt(IDL.Vec(IDL.Nat8)), + ], + [Result_11], + ['query'], + ), + 'move_file' : IDL.Func( + [MoveInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_12], + [], + ), + 'move_folder' : IDL.Func( + [MoveInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_12], + [], + ), + 'update_file_chunk' : IDL.Func( + [UpdateFileChunkInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_13], + [], + ), + 'update_file_info' : IDL.Func( + [UpdateFileInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_12], + [], + ), + 'update_folder_info' : IDL.Func( + [UpdateFolderInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_12], + [], + ), + 'validate2_admin_set_auditors' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_14], + [], + ), + 'validate2_admin_set_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_14], + [], + ), + 'validate2_admin_update_bucket' : IDL.Func( + [UpdateBucketInput], + [Result_14], + [], + ), + 'validate_admin_add_auditors' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_14], + [], + ), + 'validate_admin_add_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_14], + [], + ), + 'validate_admin_remove_auditors' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_14], + [], + ), + 'validate_admin_remove_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_14], + [], + ), + 'validate_admin_set_auditors' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result], + [], + ), + 'validate_admin_set_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result], + [], + ), + 'validate_admin_update_bucket' : IDL.Func( + [UpdateBucketInput], + [Result], + [], + ), + }); +}; +export const init = ({ IDL }) => { + const UpgradeArgs = IDL.Record({ + 'max_custom_data_size' : IDL.Opt(IDL.Nat16), + 'max_children' : IDL.Opt(IDL.Nat16), + 'enable_hash_index' : IDL.Opt(IDL.Bool), + 'max_file_size' : IDL.Opt(IDL.Nat64), + 'max_folder_depth' : IDL.Opt(IDL.Nat8), + }); + const InitArgs = IDL.Record({ + 'name' : IDL.Text, + 'max_custom_data_size' : IDL.Nat16, + 'max_children' : IDL.Nat16, + 'enable_hash_index' : IDL.Bool, + 'max_file_size' : IDL.Nat64, + 'visibility' : IDL.Nat8, + 'max_folder_depth' : IDL.Nat8, + 'file_id' : IDL.Nat32, + }); + const CanisterArgs = IDL.Variant({ + 'Upgrade' : UpgradeArgs, + 'Init' : InitArgs, + }); + return [IDL.Opt(CanisterArgs)]; +}; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_bucket/index.d.ts b/src/ic_message_frontend/src/declarations/ic_oss_bucket/index.d.ts new file mode 100644 index 0000000..bd1fa71 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_bucket/index.d.ts @@ -0,0 +1,50 @@ +import type { + ActorSubclass, + HttpAgentOptions, + ActorConfig, + Agent, +} from "@dfinity/agent"; +import type { Principal } from "@dfinity/principal"; +import type { IDL } from "@dfinity/candid"; + +import { _SERVICE } from './ic_oss_bucket.did'; + +export declare const idlFactory: IDL.InterfaceFactory; +export declare const canisterId: string; + +export declare interface CreateActorOptions { + /** + * @see {@link Agent} + */ + agent?: Agent; + /** + * @see {@link HttpAgentOptions} + */ + agentOptions?: HttpAgentOptions; + /** + * @see {@link ActorConfig} + */ + actorOptions?: ActorConfig; +} + +/** + * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. + * @constructs {@link ActorSubClass} + * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to + * @param {CreateActorOptions} options - see {@link CreateActorOptions} + * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions + * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent + * @see {@link HttpAgentOptions} + * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor + * @see {@link ActorConfig} + */ +export declare const createActor: ( + canisterId: string | Principal, + options?: CreateActorOptions +) => ActorSubclass<_SERVICE>; + +/** + * Intialized Actor using default settings, ready to talk to a canister using its candid interface + * @constructs {@link ActorSubClass} + */ +export declare const ic_oss_bucket: ActorSubclass<_SERVICE>; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_bucket/index.js b/src/ic_message_frontend/src/declarations/ic_oss_bucket/index.js new file mode 100644 index 0000000..1ba9e62 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_bucket/index.js @@ -0,0 +1,42 @@ +import { Actor, HttpAgent } from "@dfinity/agent"; + +// Imports and re-exports candid interface +import { idlFactory } from "./ic_oss_bucket.did.js"; +export { idlFactory } from "./ic_oss_bucket.did.js"; + +/* CANISTER_ID is replaced by webpack based on node environment + * Note: canister environment variable will be standardized as + * process.env.CANISTER_ID_ + * beginning in dfx 0.15.0 + */ +export const canisterId = + process.env.CANISTER_ID_IC_OSS_BUCKET; + +export const createActor = (canisterId, options = {}) => { + const agent = options.agent || new HttpAgent({ ...options.agentOptions }); + + if (options.agent && options.agentOptions) { + console.warn( + "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." + ); + } + + // Fetch root key for certificate validation during development + if (process.env.DFX_NETWORK !== "ic") { + agent.fetchRootKey().catch((err) => { + console.warn( + "Unable to fetch root key. Check to ensure that your local replica is running" + ); + console.error(err); + }); + } + + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options.actorOptions, + }); +}; + +export const ic_oss_bucket = canisterId ? createActor(canisterId) : undefined; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did b/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did new file mode 100644 index 0000000..3df08a0 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did @@ -0,0 +1,102 @@ +type AddWasmInput = record { wasm : blob; description : text }; +type BucketDeploymentInfo = record { + args : opt blob; + prev_hash : blob; + error : opt text; + deploy_at : nat64; + canister : principal; + wasm_hash : blob; +}; +type ChainArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs }; +type ClusterInfo = record { + ecdsa_token_public_key : text; + schnorr_ed25519_token_public_key : text; + bucket_wasm_total : nat64; + ecdsa_key_name : text; + managers : vec principal; + name : text; + bucket_deployed_total : nat64; + token_expiration : nat64; + weak_ed25519_token_public_key : text; + bucket_latest_version : blob; + schnorr_key_name : text; + bucket_deployment_logs : nat64; + subject_authz_total : nat64; +}; +type DeployWasmInput = record { args : opt blob; canister : principal }; +type InitArgs = record { + ecdsa_key_name : text; + name : text; + token_expiration : nat64; + bucket_topup_threshold : nat; + bucket_topup_amount : nat; + schnorr_key_name : text; +}; +type Result = variant { Ok : blob; Err : text }; +type Result_1 = variant { Ok; Err : text }; +type Result_2 = variant { Ok : vec blob; Err : text }; +type Result_3 = variant { Ok : nat; Err : text }; +type Result_4 = variant { Ok : vec BucketDeploymentInfo; Err : text }; +type Result_5 = variant { Ok : WasmInfo; Err : text }; +type Result_6 = variant { Ok : vec principal; Err : text }; +type Result_7 = variant { Ok : ClusterInfo; Err : text }; +type Result_8 = variant { Ok : vec record { principal; text }; Err : text }; +type Result_9 = variant { Ok : text; Err : text }; +type Token = record { + subject : principal; + audience : principal; + policies : text; +}; +type UpgradeArgs = record { + name : opt text; + token_expiration : opt nat64; + bucket_topup_threshold : opt nat; + bucket_topup_amount : opt nat; +}; +type WasmInfo = record { + hash : blob; + wasm : blob; + description : text; + created_at : nat64; + created_by : principal; +}; +service : (opt ChainArgs) -> { + access_token : (principal) -> (Result); + admin_add_managers : (vec principal) -> (Result_1); + admin_add_wasm : (AddWasmInput, opt blob) -> (Result_1); + admin_attach_policies : (Token) -> (Result_1); + admin_batch_call_buckets : (vec principal, text, opt blob) -> (Result_2); + admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_1); + admin_detach_policies : (Token) -> (Result_1); + admin_ed25519_access_token : (Token) -> (Result); + admin_remove_managers : (vec principal) -> (Result_1); + admin_set_managers : (vec principal) -> (Result_1); + admin_sign_access_token : (Token) -> (Result); + admin_topup_all_buckets : () -> (Result_3); + admin_upgrade_all_buckets : (opt blob) -> (Result_1); + admin_weak_access_token : (Token, nat64, nat64) -> (Result) query; + bucket_deployment_logs : (opt nat, opt nat) -> (Result_4) query; + ed25519_access_token : (principal) -> (Result); + get_bucket_wasm : (blob) -> (Result_5) query; + get_buckets : () -> (Result_6) query; + get_cluster_info : () -> (Result_7) query; + get_deployed_buckets : () -> (Result_4) query; + get_subject_policies : (principal) -> (Result_8) query; + get_subject_policies_for : (principal, principal) -> (Result_9) query; + validate2_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_9); + validate2_admin_batch_call_buckets : (vec principal, text, opt blob) -> ( + Result_9, + ); + validate2_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_9); + validate2_admin_set_managers : (vec principal) -> (Result_9); + validate2_admin_upgrade_all_buckets : (opt blob) -> (Result_9); + validate_admin_add_managers : (vec principal) -> (Result_9); + validate_admin_add_wasm : (AddWasmInput, opt blob) -> (Result_1); + validate_admin_batch_call_buckets : (vec principal, text, opt blob) -> ( + Result_2, + ); + validate_admin_deploy_bucket : (DeployWasmInput, opt blob) -> (Result_1); + validate_admin_remove_managers : (vec principal) -> (Result_9); + validate_admin_set_managers : (vec principal) -> (Result_1); + validate_admin_upgrade_all_buckets : (opt blob) -> (Result_1); +} diff --git a/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.d.ts b/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.d.ts new file mode 100644 index 0000000..39e7030 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.d.ts @@ -0,0 +1,160 @@ +import type { Principal } from '@dfinity/principal'; +import type { ActorMethod } from '@dfinity/agent'; +import type { IDL } from '@dfinity/candid'; + +export interface AddWasmInput { + 'wasm' : Uint8Array | number[], + 'description' : string, +} +export interface BucketDeploymentInfo { + 'args' : [] | [Uint8Array | number[]], + 'prev_hash' : Uint8Array | number[], + 'error' : [] | [string], + 'deploy_at' : bigint, + 'canister' : Principal, + 'wasm_hash' : Uint8Array | number[], +} +export type ChainArgs = { 'Upgrade' : UpgradeArgs } | + { 'Init' : InitArgs }; +export interface ClusterInfo { + 'ecdsa_token_public_key' : string, + 'schnorr_ed25519_token_public_key' : string, + 'bucket_wasm_total' : bigint, + 'ecdsa_key_name' : string, + 'managers' : Array, + 'name' : string, + 'bucket_deployed_total' : bigint, + 'token_expiration' : bigint, + 'weak_ed25519_token_public_key' : string, + 'bucket_latest_version' : Uint8Array | number[], + 'schnorr_key_name' : string, + 'bucket_deployment_logs' : bigint, + 'subject_authz_total' : bigint, +} +export interface DeployWasmInput { + 'args' : [] | [Uint8Array | number[]], + 'canister' : Principal, +} +export interface InitArgs { + 'ecdsa_key_name' : string, + 'name' : string, + 'token_expiration' : bigint, + 'bucket_topup_threshold' : bigint, + 'bucket_topup_amount' : bigint, + 'schnorr_key_name' : string, +} +export type Result = { 'Ok' : Uint8Array | number[] } | + { 'Err' : string }; +export type Result_1 = { 'Ok' : null } | + { 'Err' : string }; +export type Result_2 = { 'Ok' : Array } | + { 'Err' : string }; +export type Result_3 = { 'Ok' : bigint } | + { 'Err' : string }; +export type Result_4 = { 'Ok' : Array } | + { 'Err' : string }; +export type Result_5 = { 'Ok' : WasmInfo } | + { 'Err' : string }; +export type Result_6 = { 'Ok' : Array } | + { 'Err' : string }; +export type Result_7 = { 'Ok' : ClusterInfo } | + { 'Err' : string }; +export type Result_8 = { 'Ok' : Array<[Principal, string]> } | + { 'Err' : string }; +export type Result_9 = { 'Ok' : string } | + { 'Err' : string }; +export interface Token { + 'subject' : Principal, + 'audience' : Principal, + 'policies' : string, +} +export interface UpgradeArgs { + 'name' : [] | [string], + 'token_expiration' : [] | [bigint], + 'bucket_topup_threshold' : [] | [bigint], + 'bucket_topup_amount' : [] | [bigint], +} +export interface WasmInfo { + 'hash' : Uint8Array | number[], + 'wasm' : Uint8Array | number[], + 'description' : string, + 'created_at' : bigint, + 'created_by' : Principal, +} +export interface _SERVICE { + 'access_token' : ActorMethod<[Principal], Result>, + 'admin_add_managers' : ActorMethod<[Array], Result_1>, + 'admin_add_wasm' : ActorMethod< + [AddWasmInput, [] | [Uint8Array | number[]]], + Result_1 + >, + 'admin_attach_policies' : ActorMethod<[Token], Result_1>, + 'admin_batch_call_buckets' : ActorMethod< + [Array, string, [] | [Uint8Array | number[]]], + Result_2 + >, + 'admin_deploy_bucket' : ActorMethod< + [DeployWasmInput, [] | [Uint8Array | number[]]], + Result_1 + >, + 'admin_detach_policies' : ActorMethod<[Token], Result_1>, + 'admin_ed25519_access_token' : ActorMethod<[Token], Result>, + 'admin_remove_managers' : ActorMethod<[Array], Result_1>, + 'admin_set_managers' : ActorMethod<[Array], Result_1>, + 'admin_sign_access_token' : ActorMethod<[Token], Result>, + 'admin_topup_all_buckets' : ActorMethod<[], Result_3>, + 'admin_upgrade_all_buckets' : ActorMethod< + [[] | [Uint8Array | number[]]], + Result_1 + >, + 'admin_weak_access_token' : ActorMethod<[Token, bigint, bigint], Result>, + 'bucket_deployment_logs' : ActorMethod< + [[] | [bigint], [] | [bigint]], + Result_4 + >, + 'ed25519_access_token' : ActorMethod<[Principal], Result>, + 'get_bucket_wasm' : ActorMethod<[Uint8Array | number[]], Result_5>, + 'get_buckets' : ActorMethod<[], Result_6>, + 'get_cluster_info' : ActorMethod<[], Result_7>, + 'get_deployed_buckets' : ActorMethod<[], Result_4>, + 'get_subject_policies' : ActorMethod<[Principal], Result_8>, + 'get_subject_policies_for' : ActorMethod<[Principal, Principal], Result_9>, + 'validate2_admin_add_wasm' : ActorMethod< + [AddWasmInput, [] | [Uint8Array | number[]]], + Result_9 + >, + 'validate2_admin_batch_call_buckets' : ActorMethod< + [Array, string, [] | [Uint8Array | number[]]], + Result_9 + >, + 'validate2_admin_deploy_bucket' : ActorMethod< + [DeployWasmInput, [] | [Uint8Array | number[]]], + Result_9 + >, + 'validate2_admin_set_managers' : ActorMethod<[Array], Result_9>, + 'validate2_admin_upgrade_all_buckets' : ActorMethod< + [[] | [Uint8Array | number[]]], + Result_9 + >, + 'validate_admin_add_managers' : ActorMethod<[Array], Result_9>, + 'validate_admin_add_wasm' : ActorMethod< + [AddWasmInput, [] | [Uint8Array | number[]]], + Result_1 + >, + 'validate_admin_batch_call_buckets' : ActorMethod< + [Array, string, [] | [Uint8Array | number[]]], + Result_2 + >, + 'validate_admin_deploy_bucket' : ActorMethod< + [DeployWasmInput, [] | [Uint8Array | number[]]], + Result_1 + >, + 'validate_admin_remove_managers' : ActorMethod<[Array], Result_9>, + 'validate_admin_set_managers' : ActorMethod<[Array], Result_1>, + 'validate_admin_upgrade_all_buckets' : ActorMethod< + [[] | [Uint8Array | number[]]], + Result_1 + >, +} +export declare const idlFactory: IDL.InterfaceFactory; +export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.js b/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.js new file mode 100644 index 0000000..0e183cd --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_cluster/ic_oss_cluster.did.js @@ -0,0 +1,216 @@ +export const idlFactory = ({ IDL }) => { + const UpgradeArgs = IDL.Record({ + 'name' : IDL.Opt(IDL.Text), + 'token_expiration' : IDL.Opt(IDL.Nat64), + 'bucket_topup_threshold' : IDL.Opt(IDL.Nat), + 'bucket_topup_amount' : IDL.Opt(IDL.Nat), + }); + const InitArgs = IDL.Record({ + 'ecdsa_key_name' : IDL.Text, + 'name' : IDL.Text, + 'token_expiration' : IDL.Nat64, + 'bucket_topup_threshold' : IDL.Nat, + 'bucket_topup_amount' : IDL.Nat, + 'schnorr_key_name' : IDL.Text, + }); + const ChainArgs = IDL.Variant({ 'Upgrade' : UpgradeArgs, 'Init' : InitArgs }); + const Result = IDL.Variant({ 'Ok' : IDL.Vec(IDL.Nat8), 'Err' : IDL.Text }); + const Result_1 = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : IDL.Text }); + const AddWasmInput = IDL.Record({ + 'wasm' : IDL.Vec(IDL.Nat8), + 'description' : IDL.Text, + }); + const Token = IDL.Record({ + 'subject' : IDL.Principal, + 'audience' : IDL.Principal, + 'policies' : IDL.Text, + }); + const Result_2 = IDL.Variant({ + 'Ok' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'Err' : IDL.Text, + }); + const DeployWasmInput = IDL.Record({ + 'args' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'canister' : IDL.Principal, + }); + const Result_3 = IDL.Variant({ 'Ok' : IDL.Nat, 'Err' : IDL.Text }); + const BucketDeploymentInfo = IDL.Record({ + 'args' : IDL.Opt(IDL.Vec(IDL.Nat8)), + 'prev_hash' : IDL.Vec(IDL.Nat8), + 'error' : IDL.Opt(IDL.Text), + 'deploy_at' : IDL.Nat64, + 'canister' : IDL.Principal, + 'wasm_hash' : IDL.Vec(IDL.Nat8), + }); + const Result_4 = IDL.Variant({ + 'Ok' : IDL.Vec(BucketDeploymentInfo), + 'Err' : IDL.Text, + }); + const WasmInfo = IDL.Record({ + 'hash' : IDL.Vec(IDL.Nat8), + 'wasm' : IDL.Vec(IDL.Nat8), + 'description' : IDL.Text, + 'created_at' : IDL.Nat64, + 'created_by' : IDL.Principal, + }); + const Result_5 = IDL.Variant({ 'Ok' : WasmInfo, 'Err' : IDL.Text }); + const Result_6 = IDL.Variant({ + 'Ok' : IDL.Vec(IDL.Principal), + 'Err' : IDL.Text, + }); + const ClusterInfo = IDL.Record({ + 'ecdsa_token_public_key' : IDL.Text, + 'schnorr_ed25519_token_public_key' : IDL.Text, + 'bucket_wasm_total' : IDL.Nat64, + 'ecdsa_key_name' : IDL.Text, + 'managers' : IDL.Vec(IDL.Principal), + 'name' : IDL.Text, + 'bucket_deployed_total' : IDL.Nat64, + 'token_expiration' : IDL.Nat64, + 'weak_ed25519_token_public_key' : IDL.Text, + 'bucket_latest_version' : IDL.Vec(IDL.Nat8), + 'schnorr_key_name' : IDL.Text, + 'bucket_deployment_logs' : IDL.Nat64, + 'subject_authz_total' : IDL.Nat64, + }); + const Result_7 = IDL.Variant({ 'Ok' : ClusterInfo, 'Err' : IDL.Text }); + const Result_8 = IDL.Variant({ + 'Ok' : IDL.Vec(IDL.Tuple(IDL.Principal, IDL.Text)), + 'Err' : IDL.Text, + }); + const Result_9 = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : IDL.Text }); + return IDL.Service({ + 'access_token' : IDL.Func([IDL.Principal], [Result], []), + 'admin_add_managers' : IDL.Func([IDL.Vec(IDL.Principal)], [Result_1], []), + 'admin_add_wasm' : IDL.Func( + [AddWasmInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'admin_attach_policies' : IDL.Func([Token], [Result_1], []), + 'admin_batch_call_buckets' : IDL.Func( + [IDL.Vec(IDL.Principal), IDL.Text, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_2], + [], + ), + 'admin_deploy_bucket' : IDL.Func( + [DeployWasmInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'admin_detach_policies' : IDL.Func([Token], [Result_1], []), + 'admin_ed25519_access_token' : IDL.Func([Token], [Result], []), + 'admin_remove_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_1], + [], + ), + 'admin_set_managers' : IDL.Func([IDL.Vec(IDL.Principal)], [Result_1], []), + 'admin_sign_access_token' : IDL.Func([Token], [Result], []), + 'admin_topup_all_buckets' : IDL.Func([], [Result_3], []), + 'admin_upgrade_all_buckets' : IDL.Func( + [IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'admin_weak_access_token' : IDL.Func( + [Token, IDL.Nat64, IDL.Nat64], + [Result], + ['query'], + ), + 'bucket_deployment_logs' : IDL.Func( + [IDL.Opt(IDL.Nat), IDL.Opt(IDL.Nat)], + [Result_4], + ['query'], + ), + 'ed25519_access_token' : IDL.Func([IDL.Principal], [Result], []), + 'get_bucket_wasm' : IDL.Func([IDL.Vec(IDL.Nat8)], [Result_5], ['query']), + 'get_buckets' : IDL.Func([], [Result_6], ['query']), + 'get_cluster_info' : IDL.Func([], [Result_7], ['query']), + 'get_deployed_buckets' : IDL.Func([], [Result_4], ['query']), + 'get_subject_policies' : IDL.Func([IDL.Principal], [Result_8], ['query']), + 'get_subject_policies_for' : IDL.Func( + [IDL.Principal, IDL.Principal], + [Result_9], + ['query'], + ), + 'validate2_admin_add_wasm' : IDL.Func( + [AddWasmInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_9], + [], + ), + 'validate2_admin_batch_call_buckets' : IDL.Func( + [IDL.Vec(IDL.Principal), IDL.Text, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_9], + [], + ), + 'validate2_admin_deploy_bucket' : IDL.Func( + [DeployWasmInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_9], + [], + ), + 'validate2_admin_set_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_9], + [], + ), + 'validate2_admin_upgrade_all_buckets' : IDL.Func( + [IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_9], + [], + ), + 'validate_admin_add_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_9], + [], + ), + 'validate_admin_add_wasm' : IDL.Func( + [AddWasmInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'validate_admin_batch_call_buckets' : IDL.Func( + [IDL.Vec(IDL.Principal), IDL.Text, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_2], + [], + ), + 'validate_admin_deploy_bucket' : IDL.Func( + [DeployWasmInput, IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + 'validate_admin_remove_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_9], + [], + ), + 'validate_admin_set_managers' : IDL.Func( + [IDL.Vec(IDL.Principal)], + [Result_1], + [], + ), + 'validate_admin_upgrade_all_buckets' : IDL.Func( + [IDL.Opt(IDL.Vec(IDL.Nat8))], + [Result_1], + [], + ), + }); +}; +export const init = ({ IDL }) => { + const UpgradeArgs = IDL.Record({ + 'name' : IDL.Opt(IDL.Text), + 'token_expiration' : IDL.Opt(IDL.Nat64), + 'bucket_topup_threshold' : IDL.Opt(IDL.Nat), + 'bucket_topup_amount' : IDL.Opt(IDL.Nat), + }); + const InitArgs = IDL.Record({ + 'ecdsa_key_name' : IDL.Text, + 'name' : IDL.Text, + 'token_expiration' : IDL.Nat64, + 'bucket_topup_threshold' : IDL.Nat, + 'bucket_topup_amount' : IDL.Nat, + 'schnorr_key_name' : IDL.Text, + }); + const ChainArgs = IDL.Variant({ 'Upgrade' : UpgradeArgs, 'Init' : InitArgs }); + return [IDL.Opt(ChainArgs)]; +}; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_cluster/index.d.ts b/src/ic_message_frontend/src/declarations/ic_oss_cluster/index.d.ts new file mode 100644 index 0000000..e144d11 --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_cluster/index.d.ts @@ -0,0 +1,50 @@ +import type { + ActorSubclass, + HttpAgentOptions, + ActorConfig, + Agent, +} from "@dfinity/agent"; +import type { Principal } from "@dfinity/principal"; +import type { IDL } from "@dfinity/candid"; + +import { _SERVICE } from './ic_oss_cluster.did'; + +export declare const idlFactory: IDL.InterfaceFactory; +export declare const canisterId: string; + +export declare interface CreateActorOptions { + /** + * @see {@link Agent} + */ + agent?: Agent; + /** + * @see {@link HttpAgentOptions} + */ + agentOptions?: HttpAgentOptions; + /** + * @see {@link ActorConfig} + */ + actorOptions?: ActorConfig; +} + +/** + * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. + * @constructs {@link ActorSubClass} + * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to + * @param {CreateActorOptions} options - see {@link CreateActorOptions} + * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions + * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent + * @see {@link HttpAgentOptions} + * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor + * @see {@link ActorConfig} + */ +export declare const createActor: ( + canisterId: string | Principal, + options?: CreateActorOptions +) => ActorSubclass<_SERVICE>; + +/** + * Intialized Actor using default settings, ready to talk to a canister using its candid interface + * @constructs {@link ActorSubClass} + */ +export declare const ic_oss_cluster: ActorSubclass<_SERVICE>; diff --git a/src/ic_message_frontend/src/declarations/ic_oss_cluster/index.js b/src/ic_message_frontend/src/declarations/ic_oss_cluster/index.js new file mode 100644 index 0000000..d10eb8b --- /dev/null +++ b/src/ic_message_frontend/src/declarations/ic_oss_cluster/index.js @@ -0,0 +1,42 @@ +import { Actor, HttpAgent } from "@dfinity/agent"; + +// Imports and re-exports candid interface +import { idlFactory } from "./ic_oss_cluster.did.js"; +export { idlFactory } from "./ic_oss_cluster.did.js"; + +/* CANISTER_ID is replaced by webpack based on node environment + * Note: canister environment variable will be standardized as + * process.env.CANISTER_ID_ + * beginning in dfx 0.15.0 + */ +export const canisterId = + process.env.CANISTER_ID_IC_OSS_CLUSTER; + +export const createActor = (canisterId, options = {}) => { + const agent = options.agent || new HttpAgent({ ...options.agentOptions }); + + if (options.agent && options.agentOptions) { + console.warn( + "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." + ); + } + + // Fetch root key for certificate validation during development + if (process.env.DFX_NETWORK !== "ic") { + agent.fetchRootKey().catch((err) => { + console.warn( + "Unable to fetch root key. Check to ensure that your local replica is running" + ); + console.error(err); + }); + } + + // Creates an actor with using the candid interface and the HttpAgent + return Actor.createActor(idlFactory, { + agent, + canisterId, + ...options.actorOptions, + }); +}; + +export const ic_oss_cluster = canisterId ? createActor(canisterId) : undefined; diff --git a/src/ic_message_frontend/src/lib/constants.ts b/src/ic_message_frontend/src/lib/constants.ts index 7a8860f..483581a 100644 --- a/src/ic_message_frontend/src/lib/constants.ts +++ b/src/ic_message_frontend/src/lib/constants.ts @@ -1,6 +1,6 @@ const src = globalThis.location?.href || '' -export const APP_VERSION = '2.5.0' +export const APP_VERSION = '2.5.1' export const IS_LOCAL = src.includes('localhost') || src.includes('127.0.0.1') export const ENV = IS_LOCAL ? 'local' : 'ic' export const APP_ORIGIN = IS_LOCAL diff --git a/src/ic_message_frontend/static/.ic-assets.json b/src/ic_message_frontend/static/.ic-assets.json index 33df57c..6373b52 100644 --- a/src/ic_message_frontend/static/.ic-assets.json +++ b/src/ic_message_frontend/static/.ic-assets.json @@ -15,7 +15,7 @@ "match": "**/*", "security_policy": "standard", "headers": { - "Content-Security-Policy": "default-src 'self';script-src 'self' 'unsafe-eval' 'unsafe-inline';connect-src 'self' http://localhost:* https://icp0.io https://*.icp0.io https://icp-api.io;img-src 'self' https://pbs.twimg.com data:;style-src * 'unsafe-inline';style-src-elem * 'unsafe-inline';font-src *;object-src 'none';base-uri 'self';frame-ancestors 'none';form-action 'self';upgrade-insecure-requests;", + "Content-Security-Policy": "default-src 'self';script-src 'self' 'unsafe-eval' 'unsafe-inline';connect-src 'self' http://localhost:* https://icp0.io https://*.icp0.io https://icp-api.io;img-src 'self' https://pbs.twimg.com https://*.icp0.io data: blob:;style-src * 'unsafe-inline';style-src-elem * 'unsafe-inline';font-src *;object-src 'none';base-uri 'self';frame-ancestors 'none';form-action 'self';upgrade-insecure-requests;", "Permissions-Policy": "autoplay=*, camera=*, cross-origin-isolated=*, display-capture=*, encrypted-media=*, fullscreen=*, keyboard-map=*, microphone=*, payment=*, picture-in-picture=*, clipboard-read=*, clipboard-write=*", "X-Frame-Options": "DENY", "Referrer-Policy": "same-origin",