diff --git a/.dfx/local/canister_ids.json b/.dfx/local/canister_ids.json deleted file mode 100644 index cc50ca98..00000000 --- a/.dfx/local/canister_ids.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "__Candid_UI": { - "local": "be2us-64aaa-aaaaa-qaabq-cai" - }, - "assets": { - "local": "bw4dl-smaaa-aaaaa-qaacq-cai" - }, - "backend": { - "local": "bd3sg-teaaa-aaaaa-qaaba-cai" - }, - "ckbtc_ledger": { - "local": "bkyz2-fmaaa-aaaaa-qaaaq-cai" - }, - "icrc1_index": { - "local": "br5f7-7uaaa-aaaaa-qaaca-cai" - }, - "internet_identity": { - "local": "b77ix-eeaaa-aaaaa-qaada-cai" - } -} \ No newline at end of file diff --git a/.dfx/local/canisters/assets/assets.wasm.gz b/.dfx/local/canisters/assets/assets.wasm.gz deleted file mode 100644 index 2796c34f..00000000 Binary files a/.dfx/local/canisters/assets/assets.wasm.gz and /dev/null differ diff --git a/.dfx/local/canisters/assets/assetstorage.did b/.dfx/local/canisters/assets/assetstorage.did deleted file mode 100644 index 51bb1a23..00000000 --- a/.dfx/local/canisters/assets/assetstorage.did +++ /dev/null @@ -1,262 +0,0 @@ -type BatchId = nat; -type ChunkId = nat; -type Key = text; -type Time = int; - -type CreateAssetArguments = record { - key: Key; - content_type: text; - max_age: opt nat64; - headers: opt vec HeaderField; - enable_aliasing: opt bool; - allow_raw_access: opt bool; -}; - -// Add or change content for an asset, by content encoding -type SetAssetContentArguments = record { - key: Key; - content_encoding: text; - chunk_ids: vec ChunkId; - sha256: opt blob; -}; - -// Remove content for an asset, by content encoding -type UnsetAssetContentArguments = record { - key: Key; - content_encoding: text; -}; - -// Delete an asset -type DeleteAssetArguments = record { - key: Key; -}; - -// Reset everything -type ClearArguments = record {}; - -type BatchOperationKind = variant { - CreateAsset: CreateAssetArguments; - SetAssetContent: SetAssetContentArguments; - - SetAssetProperties: SetAssetPropertiesArguments; - - UnsetAssetContent: UnsetAssetContentArguments; - DeleteAsset: DeleteAssetArguments; - - Clear: ClearArguments; -}; - -type CommitBatchArguments = record { - batch_id: BatchId; - operations: vec BatchOperationKind -}; - -type CommitProposedBatchArguments = record { - batch_id: BatchId; - evidence: blob; -}; - -type ComputeEvidenceArguments = record { - batch_id: BatchId; - max_iterations: opt nat16 -}; - -type DeleteBatchArguments = record { - batch_id: BatchId; -}; - -type HeaderField = record { text; text; }; - -type HttpRequest = record { - method: text; - url: text; - headers: vec HeaderField; - body: blob; - certificate_version: opt nat16; -}; - -type HttpResponse = record { - status_code: nat16; - headers: vec HeaderField; - body: blob; - streaming_strategy: opt StreamingStrategy; -}; - -type StreamingCallbackHttpResponse = record { - body: blob; - token: opt StreamingCallbackToken; -}; - -type StreamingCallbackToken = record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; -}; - -type StreamingStrategy = variant { - Callback: record { - callback: func (StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - token: StreamingCallbackToken; - }; -}; - -type SetAssetPropertiesArguments = record { - key: Key; - max_age: opt opt nat64; - headers: opt opt vec HeaderField; - allow_raw_access: opt opt bool; - is_aliased: opt opt bool; -}; - -type ConfigurationResponse = record { - max_batches: opt nat64; - max_chunks: opt nat64; - max_bytes: opt nat64; -}; - -type ConfigureArguments = record { - max_batches: opt opt nat64; - max_chunks: opt opt nat64; - max_bytes: opt opt nat64; -}; - -type Permission = variant { - Commit; - ManagePermissions; - Prepare; -}; - -type GrantPermission = record { - to_principal: principal; - permission: Permission; -}; -type RevokePermission = record { - of_principal: principal; - permission: Permission; -}; -type ListPermitted = record { permission: Permission }; - -type ValidationResult = variant { Ok : text; Err : text }; - -type AssetCanisterArgs = variant { - Init: InitArgs; - Upgrade: UpgradeArgs; -}; - -type InitArgs = record {}; - -type UpgradeArgs = record { - set_permissions: opt SetPermissions; -}; - -/// Sets the list of principals granted each permission. -type SetPermissions = record { - prepare: vec principal; - commit: vec principal; - manage_permissions: vec principal; -}; - -service: (asset_canister_args: opt AssetCanisterArgs) -> { - api_version: () -> (nat16) query; - - get: (record { - key: Key; - accept_encodings: vec text; - }) -> (record { - content: blob; // may be the entirety of the content, or just chunk index 0 - content_type: text; - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - total_length: nat; // all chunks except last have size == content.size() - }) query; - - // if get() returned chunks > 1, call this to retrieve them. - // chunks may or may not be split up at the same boundaries as presented to create_chunk(). - get_chunk: (record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - }) -> (record { content: blob }) query; - - list : (record {}) -> (vec record { - key: Key; - content_type: text; - encodings: vec record { - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - length: nat; // Size of this encoding's blob. Calculated when uploading assets. - modified: Time; - }; - }) query; - - certified_tree : (record {}) -> (record { - certificate: blob; - tree: blob; - }) query; - - create_batch : (record {}) -> (record { batch_id: BatchId }); - - create_chunk: (record { batch_id: BatchId; content: blob }) -> (record { chunk_id: ChunkId }); - - // Perform all operations successfully, or reject - commit_batch: (CommitBatchArguments) -> (); - - // Save the batch operations for later commit - propose_commit_batch: (CommitBatchArguments) -> (); - - // Given a batch already proposed, perform all operations successfully, or reject - commit_proposed_batch: (CommitProposedBatchArguments) -> (); - - // Compute a hash over the CommitBatchArguments. Call until it returns Some(evidence). - compute_evidence: (ComputeEvidenceArguments) -> (opt blob); - - // Delete a batch that has been created, or proposed for commit, but not yet committed - delete_batch: (DeleteBatchArguments) -> (); - - create_asset: (CreateAssetArguments) -> (); - set_asset_content: (SetAssetContentArguments) -> (); - unset_asset_content: (UnsetAssetContentArguments) -> (); - - delete_asset: (DeleteAssetArguments) -> (); - - clear: (ClearArguments) -> (); - - // Single call to create an asset with content for a single content encoding that - // fits within the message ingress limit. - store: (record { - key: Key; - content_type: text; - content_encoding: text; - content: blob; - sha256: opt blob - }) -> (); - - http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_streaming_callback: (token: StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - - authorize: (principal) -> (); - deauthorize: (principal) -> (); - list_authorized: () -> (vec principal); - grant_permission: (GrantPermission) -> (); - revoke_permission: (RevokePermission) -> (); - list_permitted: (ListPermitted) -> (vec principal); - take_ownership: () -> (); - - get_asset_properties : (key: Key) -> (record { - max_age: opt nat64; - headers: opt vec HeaderField; - allow_raw_access: opt bool; - is_aliased: opt bool; } ) query; - set_asset_properties: (SetAssetPropertiesArguments) -> (); - - get_configuration: () -> (ConfigurationResponse); - configure: (ConfigureArguments) -> (); - - validate_grant_permission: (GrantPermission) -> (ValidationResult); - validate_revoke_permission: (RevokePermission) -> (ValidationResult); - validate_take_ownership: () -> (ValidationResult); - validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); - validate_configure: (ConfigureArguments) -> (ValidationResult); -} diff --git a/.dfx/local/canisters/assets/assetstorage.wasm.gz b/.dfx/local/canisters/assets/assetstorage.wasm.gz deleted file mode 100644 index 2796c34f..00000000 Binary files a/.dfx/local/canisters/assets/assetstorage.wasm.gz and /dev/null differ diff --git a/.dfx/local/canisters/assets/constructor.did b/.dfx/local/canisters/assets/constructor.did deleted file mode 100644 index 51bb1a23..00000000 --- a/.dfx/local/canisters/assets/constructor.did +++ /dev/null @@ -1,262 +0,0 @@ -type BatchId = nat; -type ChunkId = nat; -type Key = text; -type Time = int; - -type CreateAssetArguments = record { - key: Key; - content_type: text; - max_age: opt nat64; - headers: opt vec HeaderField; - enable_aliasing: opt bool; - allow_raw_access: opt bool; -}; - -// Add or change content for an asset, by content encoding -type SetAssetContentArguments = record { - key: Key; - content_encoding: text; - chunk_ids: vec ChunkId; - sha256: opt blob; -}; - -// Remove content for an asset, by content encoding -type UnsetAssetContentArguments = record { - key: Key; - content_encoding: text; -}; - -// Delete an asset -type DeleteAssetArguments = record { - key: Key; -}; - -// Reset everything -type ClearArguments = record {}; - -type BatchOperationKind = variant { - CreateAsset: CreateAssetArguments; - SetAssetContent: SetAssetContentArguments; - - SetAssetProperties: SetAssetPropertiesArguments; - - UnsetAssetContent: UnsetAssetContentArguments; - DeleteAsset: DeleteAssetArguments; - - Clear: ClearArguments; -}; - -type CommitBatchArguments = record { - batch_id: BatchId; - operations: vec BatchOperationKind -}; - -type CommitProposedBatchArguments = record { - batch_id: BatchId; - evidence: blob; -}; - -type ComputeEvidenceArguments = record { - batch_id: BatchId; - max_iterations: opt nat16 -}; - -type DeleteBatchArguments = record { - batch_id: BatchId; -}; - -type HeaderField = record { text; text; }; - -type HttpRequest = record { - method: text; - url: text; - headers: vec HeaderField; - body: blob; - certificate_version: opt nat16; -}; - -type HttpResponse = record { - status_code: nat16; - headers: vec HeaderField; - body: blob; - streaming_strategy: opt StreamingStrategy; -}; - -type StreamingCallbackHttpResponse = record { - body: blob; - token: opt StreamingCallbackToken; -}; - -type StreamingCallbackToken = record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; -}; - -type StreamingStrategy = variant { - Callback: record { - callback: func (StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - token: StreamingCallbackToken; - }; -}; - -type SetAssetPropertiesArguments = record { - key: Key; - max_age: opt opt nat64; - headers: opt opt vec HeaderField; - allow_raw_access: opt opt bool; - is_aliased: opt opt bool; -}; - -type ConfigurationResponse = record { - max_batches: opt nat64; - max_chunks: opt nat64; - max_bytes: opt nat64; -}; - -type ConfigureArguments = record { - max_batches: opt opt nat64; - max_chunks: opt opt nat64; - max_bytes: opt opt nat64; -}; - -type Permission = variant { - Commit; - ManagePermissions; - Prepare; -}; - -type GrantPermission = record { - to_principal: principal; - permission: Permission; -}; -type RevokePermission = record { - of_principal: principal; - permission: Permission; -}; -type ListPermitted = record { permission: Permission }; - -type ValidationResult = variant { Ok : text; Err : text }; - -type AssetCanisterArgs = variant { - Init: InitArgs; - Upgrade: UpgradeArgs; -}; - -type InitArgs = record {}; - -type UpgradeArgs = record { - set_permissions: opt SetPermissions; -}; - -/// Sets the list of principals granted each permission. -type SetPermissions = record { - prepare: vec principal; - commit: vec principal; - manage_permissions: vec principal; -}; - -service: (asset_canister_args: opt AssetCanisterArgs) -> { - api_version: () -> (nat16) query; - - get: (record { - key: Key; - accept_encodings: vec text; - }) -> (record { - content: blob; // may be the entirety of the content, or just chunk index 0 - content_type: text; - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - total_length: nat; // all chunks except last have size == content.size() - }) query; - - // if get() returned chunks > 1, call this to retrieve them. - // chunks may or may not be split up at the same boundaries as presented to create_chunk(). - get_chunk: (record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - }) -> (record { content: blob }) query; - - list : (record {}) -> (vec record { - key: Key; - content_type: text; - encodings: vec record { - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - length: nat; // Size of this encoding's blob. Calculated when uploading assets. - modified: Time; - }; - }) query; - - certified_tree : (record {}) -> (record { - certificate: blob; - tree: blob; - }) query; - - create_batch : (record {}) -> (record { batch_id: BatchId }); - - create_chunk: (record { batch_id: BatchId; content: blob }) -> (record { chunk_id: ChunkId }); - - // Perform all operations successfully, or reject - commit_batch: (CommitBatchArguments) -> (); - - // Save the batch operations for later commit - propose_commit_batch: (CommitBatchArguments) -> (); - - // Given a batch already proposed, perform all operations successfully, or reject - commit_proposed_batch: (CommitProposedBatchArguments) -> (); - - // Compute a hash over the CommitBatchArguments. Call until it returns Some(evidence). - compute_evidence: (ComputeEvidenceArguments) -> (opt blob); - - // Delete a batch that has been created, or proposed for commit, but not yet committed - delete_batch: (DeleteBatchArguments) -> (); - - create_asset: (CreateAssetArguments) -> (); - set_asset_content: (SetAssetContentArguments) -> (); - unset_asset_content: (UnsetAssetContentArguments) -> (); - - delete_asset: (DeleteAssetArguments) -> (); - - clear: (ClearArguments) -> (); - - // Single call to create an asset with content for a single content encoding that - // fits within the message ingress limit. - store: (record { - key: Key; - content_type: text; - content_encoding: text; - content: blob; - sha256: opt blob - }) -> (); - - http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_streaming_callback: (token: StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - - authorize: (principal) -> (); - deauthorize: (principal) -> (); - list_authorized: () -> (vec principal); - grant_permission: (GrantPermission) -> (); - revoke_permission: (RevokePermission) -> (); - list_permitted: (ListPermitted) -> (vec principal); - take_ownership: () -> (); - - get_asset_properties : (key: Key) -> (record { - max_age: opt nat64; - headers: opt vec HeaderField; - allow_raw_access: opt bool; - is_aliased: opt bool; } ) query; - set_asset_properties: (SetAssetPropertiesArguments) -> (); - - get_configuration: () -> (ConfigurationResponse); - configure: (ConfigureArguments) -> (); - - validate_grant_permission: (GrantPermission) -> (ValidationResult); - validate_revoke_permission: (RevokePermission) -> (ValidationResult); - validate_take_ownership: () -> (ValidationResult); - validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); - validate_configure: (ConfigureArguments) -> (ValidationResult); -} diff --git a/.dfx/local/canisters/assets/index.js b/.dfx/local/canisters/assets/index.js deleted file mode 100644 index 6b8be335..00000000 --- a/.dfx/local/canisters/assets/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from './assets.did.js'; -export { idlFactory } from './assets.did.js'; -// CANISTER_ID is replaced by webpack based on node environment -export const canisterId = process.env.ASSETS_CANISTER_ID; - -/** - * @deprecated since dfx 0.11.1 - * Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface. - * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent - * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options] - * @return {import("@dfinity/agent").ActorSubclass} - */ -export const createActor = (canisterId, options = {}) => { - console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings. - -See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`); - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - // 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 ? options.actorOptions : {}), - }); -}; - -/** - * A ready-to-use agent for the assets canister - * @type {import("@dfinity/agent").ActorSubclass} - */ -export const assets = createActor(canisterId); diff --git a/.dfx/local/canisters/assets/init_args.txt b/.dfx/local/canisters/assets/init_args.txt deleted file mode 100644 index 660e31f7..00000000 --- a/.dfx/local/canisters/assets/init_args.txt +++ /dev/null @@ -1 +0,0 @@ -(opt AssetCanisterArgs) \ No newline at end of file diff --git a/.dfx/local/canisters/assets/service.did b/.dfx/local/canisters/assets/service.did deleted file mode 100644 index 4d9ea8be..00000000 --- a/.dfx/local/canisters/assets/service.did +++ /dev/null @@ -1,197 +0,0 @@ -type AssetCanisterArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs }; -type BatchId = nat; -type BatchOperationKind = variant { - SetAssetProperties : SetAssetPropertiesArguments; - CreateAsset : CreateAssetArguments; - UnsetAssetContent : UnsetAssetContentArguments; - DeleteAsset : DeleteAssetArguments; - SetAssetContent : SetAssetContentArguments; - Clear : ClearArguments; -}; -type ChunkId = nat; -type ClearArguments = record {}; -type CommitBatchArguments = record { - batch_id : BatchId; - operations : vec BatchOperationKind; -}; -type CommitProposedBatchArguments = record { - batch_id : BatchId; - evidence : vec nat8; -}; -type ComputeEvidenceArguments = record { - batch_id : BatchId; - max_iterations : opt nat16; -}; -type ConfigurationResponse = record { - max_batches : opt nat64; - max_bytes : opt nat64; - max_chunks : opt nat64; -}; -type ConfigureArguments = record { - max_batches : opt opt nat64; - max_bytes : opt opt nat64; - max_chunks : opt opt nat64; -}; -type CreateAssetArguments = record { - key : Key; - content_type : text; - headers : opt vec HeaderField; - allow_raw_access : opt bool; - max_age : opt nat64; - enable_aliasing : opt bool; -}; -type DeleteAssetArguments = record { key : Key }; -type DeleteBatchArguments = record { batch_id : BatchId }; -type GrantPermission = record { - permission : Permission; - to_principal : principal; -}; -type HeaderField = record { text; text }; -type HttpRequest = record { - url : text; - method : text; - body : vec nat8; - headers : vec HeaderField; - certificate_version : opt nat16; -}; -type HttpResponse = record { - body : vec nat8; - headers : vec HeaderField; - streaming_strategy : opt StreamingStrategy; - status_code : nat16; -}; -type InitArgs = record {}; -type Key = text; -type ListPermitted = record { permission : Permission }; -type Permission = variant { Prepare; ManagePermissions; Commit }; -type RevokePermission = record { - permission : Permission; - of_principal : principal; -}; -type SetAssetContentArguments = record { - key : Key; - sha256 : opt vec nat8; - chunk_ids : vec ChunkId; - content_encoding : text; -}; -type SetAssetPropertiesArguments = record { - key : Key; - headers : opt opt vec HeaderField; - is_aliased : opt opt bool; - allow_raw_access : opt opt bool; - max_age : opt opt nat64; -}; -type SetPermissions = record { - prepare : vec principal; - commit : vec principal; - manage_permissions : vec principal; -}; -type StreamingCallbackHttpResponse = record { - token : opt StreamingCallbackToken; - body : vec nat8; -}; -type StreamingCallbackToken = record { - key : Key; - sha256 : opt vec nat8; - index : nat; - content_encoding : text; -}; -type StreamingStrategy = variant { - Callback : record { - token : StreamingCallbackToken; - callback : func (StreamingCallbackToken) -> ( - opt StreamingCallbackHttpResponse, - ) query; - }; -}; -type Time = int; -type UnsetAssetContentArguments = record { key : Key; content_encoding : text }; -type UpgradeArgs = record { set_permissions : opt SetPermissions }; -type ValidationResult = variant { Ok : text; Err : text }; -service : { - api_version : () -> (nat16) query; - authorize : (principal) -> (); - certified_tree : (record {}) -> ( - record { certificate : vec nat8; tree : vec nat8 }, - ) query; - clear : (ClearArguments) -> (); - commit_batch : (CommitBatchArguments) -> (); - commit_proposed_batch : (CommitProposedBatchArguments) -> (); - compute_evidence : (ComputeEvidenceArguments) -> (opt vec nat8); - configure : (ConfigureArguments) -> (); - create_asset : (CreateAssetArguments) -> (); - create_batch : (record {}) -> (record { batch_id : BatchId }); - create_chunk : (record { content : vec nat8; batch_id : BatchId }) -> ( - record { chunk_id : ChunkId }, - ); - deauthorize : (principal) -> (); - delete_asset : (DeleteAssetArguments) -> (); - delete_batch : (DeleteBatchArguments) -> (); - get : (record { key : Key; accept_encodings : vec text }) -> ( - record { - content : vec nat8; - sha256 : opt vec nat8; - content_type : text; - content_encoding : text; - total_length : nat; - }, - ) query; - get_asset_properties : (Key) -> ( - record { - headers : opt vec HeaderField; - is_aliased : opt bool; - allow_raw_access : opt bool; - max_age : opt nat64; - }, - ) query; - get_chunk : ( - record { - key : Key; - sha256 : opt vec nat8; - index : nat; - content_encoding : text; - }, - ) -> (record { content : vec nat8 }) query; - get_configuration : () -> (ConfigurationResponse); - grant_permission : (GrantPermission) -> (); - http_request : (HttpRequest) -> (HttpResponse) query; - http_request_streaming_callback : (StreamingCallbackToken) -> ( - opt StreamingCallbackHttpResponse, - ) query; - list : (record {}) -> ( - vec record { - key : Key; - encodings : vec record { - modified : Time; - sha256 : opt vec nat8; - length : nat; - content_encoding : text; - }; - content_type : text; - }, - ) query; - list_authorized : () -> (vec principal); - list_permitted : (ListPermitted) -> (vec principal); - propose_commit_batch : (CommitBatchArguments) -> (); - revoke_permission : (RevokePermission) -> (); - set_asset_content : (SetAssetContentArguments) -> (); - set_asset_properties : (SetAssetPropertiesArguments) -> (); - store : ( - record { - key : Key; - content : vec nat8; - sha256 : opt vec nat8; - content_type : text; - content_encoding : text; - }, - ) -> (); - take_ownership : () -> (); - unset_asset_content : (UnsetAssetContentArguments) -> (); - validate_commit_proposed_batch : (CommitProposedBatchArguments) -> ( - ValidationResult, - ); - validate_configure : (ConfigureArguments) -> (ValidationResult); - validate_grant_permission : (GrantPermission) -> (ValidationResult); - validate_revoke_permission : (RevokePermission) -> (ValidationResult); - validate_take_ownership : () -> (ValidationResult); -} \ No newline at end of file diff --git a/.dfx/local/canisters/assets/service.did.d.ts b/.dfx/local/canisters/assets/service.did.d.ts deleted file mode 100644 index 0b4168ef..00000000 --- a/.dfx/local/canisters/assets/service.did.d.ts +++ /dev/null @@ -1,240 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export type AssetCanisterArgs = { 'Upgrade' : UpgradeArgs } | - { 'Init' : InitArgs }; -export type BatchId = bigint; -export type BatchOperationKind = { - 'SetAssetProperties' : SetAssetPropertiesArguments - } | - { 'CreateAsset' : CreateAssetArguments } | - { 'UnsetAssetContent' : UnsetAssetContentArguments } | - { 'DeleteAsset' : DeleteAssetArguments } | - { 'SetAssetContent' : SetAssetContentArguments } | - { 'Clear' : ClearArguments }; -export type ChunkId = bigint; -export type ClearArguments = {}; -export interface CommitBatchArguments { - 'batch_id' : BatchId, - 'operations' : Array, -} -export interface CommitProposedBatchArguments { - 'batch_id' : BatchId, - 'evidence' : Uint8Array | number[], -} -export interface ComputeEvidenceArguments { - 'batch_id' : BatchId, - 'max_iterations' : [] | [number], -} -export interface ConfigurationResponse { - 'max_batches' : [] | [bigint], - 'max_bytes' : [] | [bigint], - 'max_chunks' : [] | [bigint], -} -export interface ConfigureArguments { - 'max_batches' : [] | [[] | [bigint]], - 'max_bytes' : [] | [[] | [bigint]], - 'max_chunks' : [] | [[] | [bigint]], -} -export interface CreateAssetArguments { - 'key' : Key, - 'content_type' : string, - 'headers' : [] | [Array], - 'allow_raw_access' : [] | [boolean], - 'max_age' : [] | [bigint], - 'enable_aliasing' : [] | [boolean], -} -export interface DeleteAssetArguments { 'key' : Key } -export interface DeleteBatchArguments { 'batch_id' : BatchId } -export interface GrantPermission { - 'permission' : Permission, - 'to_principal' : Principal, -} -export type HeaderField = [string, string]; -export interface HttpRequest { - 'url' : string, - 'method' : string, - 'body' : Uint8Array | number[], - 'headers' : Array, - 'certificate_version' : [] | [number], -} -export interface HttpResponse { - 'body' : Uint8Array | number[], - 'headers' : Array, - 'streaming_strategy' : [] | [StreamingStrategy], - 'status_code' : number, -} -export type InitArgs = {}; -export type Key = string; -export interface ListPermitted { 'permission' : Permission } -export type Permission = { 'Prepare' : null } | - { 'ManagePermissions' : null } | - { 'Commit' : null }; -export interface RevokePermission { - 'permission' : Permission, - 'of_principal' : Principal, -} -export interface SetAssetContentArguments { - 'key' : Key, - 'sha256' : [] | [Uint8Array | number[]], - 'chunk_ids' : Array, - 'content_encoding' : string, -} -export interface SetAssetPropertiesArguments { - 'key' : Key, - 'headers' : [] | [[] | [Array]], - 'is_aliased' : [] | [[] | [boolean]], - 'allow_raw_access' : [] | [[] | [boolean]], - 'max_age' : [] | [[] | [bigint]], -} -export interface SetPermissions { - 'prepare' : Array, - 'commit' : Array, - 'manage_permissions' : Array, -} -export interface StreamingCallbackHttpResponse { - 'token' : [] | [StreamingCallbackToken], - 'body' : Uint8Array | number[], -} -export interface StreamingCallbackToken { - 'key' : Key, - 'sha256' : [] | [Uint8Array | number[]], - 'index' : bigint, - 'content_encoding' : string, -} -export type StreamingStrategy = { - 'Callback' : { - 'token' : StreamingCallbackToken, - 'callback' : [Principal, string], - } - }; -export type Time = bigint; -export interface UnsetAssetContentArguments { - 'key' : Key, - 'content_encoding' : string, -} -export interface UpgradeArgs { 'set_permissions' : [] | [SetPermissions] } -export type ValidationResult = { 'Ok' : string } | - { 'Err' : string }; -export interface _SERVICE { - 'api_version' : ActorMethod<[], number>, - 'authorize' : ActorMethod<[Principal], undefined>, - 'certified_tree' : ActorMethod< - [{}], - { 'certificate' : Uint8Array | number[], 'tree' : Uint8Array | number[] } - >, - 'clear' : ActorMethod<[ClearArguments], undefined>, - 'commit_batch' : ActorMethod<[CommitBatchArguments], undefined>, - 'commit_proposed_batch' : ActorMethod< - [CommitProposedBatchArguments], - undefined - >, - 'compute_evidence' : ActorMethod< - [ComputeEvidenceArguments], - [] | [Uint8Array | number[]] - >, - 'configure' : ActorMethod<[ConfigureArguments], undefined>, - 'create_asset' : ActorMethod<[CreateAssetArguments], undefined>, - 'create_batch' : ActorMethod<[{}], { 'batch_id' : BatchId }>, - 'create_chunk' : ActorMethod< - [{ 'content' : Uint8Array | number[], 'batch_id' : BatchId }], - { 'chunk_id' : ChunkId } - >, - 'deauthorize' : ActorMethod<[Principal], undefined>, - 'delete_asset' : ActorMethod<[DeleteAssetArguments], undefined>, - 'delete_batch' : ActorMethod<[DeleteBatchArguments], undefined>, - 'get' : ActorMethod< - [{ 'key' : Key, 'accept_encodings' : Array }], - { - 'content' : Uint8Array | number[], - 'sha256' : [] | [Uint8Array | number[]], - 'content_type' : string, - 'content_encoding' : string, - 'total_length' : bigint, - } - >, - 'get_asset_properties' : ActorMethod< - [Key], - { - 'headers' : [] | [Array], - 'is_aliased' : [] | [boolean], - 'allow_raw_access' : [] | [boolean], - 'max_age' : [] | [bigint], - } - >, - 'get_chunk' : ActorMethod< - [ - { - 'key' : Key, - 'sha256' : [] | [Uint8Array | number[]], - 'index' : bigint, - 'content_encoding' : string, - }, - ], - { 'content' : Uint8Array | number[] } - >, - 'get_configuration' : ActorMethod<[], ConfigurationResponse>, - 'grant_permission' : ActorMethod<[GrantPermission], undefined>, - 'http_request' : ActorMethod<[HttpRequest], HttpResponse>, - 'http_request_streaming_callback' : ActorMethod< - [StreamingCallbackToken], - [] | [StreamingCallbackHttpResponse] - >, - 'list' : ActorMethod< - [{}], - Array< - { - 'key' : Key, - 'encodings' : Array< - { - 'modified' : Time, - 'sha256' : [] | [Uint8Array | number[]], - 'length' : bigint, - 'content_encoding' : string, - } - >, - 'content_type' : string, - } - > - >, - 'list_authorized' : ActorMethod<[], Array>, - 'list_permitted' : ActorMethod<[ListPermitted], Array>, - 'propose_commit_batch' : ActorMethod<[CommitBatchArguments], undefined>, - 'revoke_permission' : ActorMethod<[RevokePermission], undefined>, - 'set_asset_content' : ActorMethod<[SetAssetContentArguments], undefined>, - 'set_asset_properties' : ActorMethod< - [SetAssetPropertiesArguments], - undefined - >, - 'store' : ActorMethod< - [ - { - 'key' : Key, - 'content' : Uint8Array | number[], - 'sha256' : [] | [Uint8Array | number[]], - 'content_type' : string, - 'content_encoding' : string, - }, - ], - undefined - >, - 'take_ownership' : ActorMethod<[], undefined>, - 'unset_asset_content' : ActorMethod<[UnsetAssetContentArguments], undefined>, - 'validate_commit_proposed_batch' : ActorMethod< - [CommitProposedBatchArguments], - ValidationResult - >, - 'validate_configure' : ActorMethod<[ConfigureArguments], ValidationResult>, - 'validate_grant_permission' : ActorMethod< - [GrantPermission], - ValidationResult - >, - 'validate_revoke_permission' : ActorMethod< - [RevokePermission], - ValidationResult - >, - 'validate_take_ownership' : ActorMethod<[], ValidationResult>, -} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/.dfx/local/canisters/assets/service.did.js b/.dfx/local/canisters/assets/service.did.js deleted file mode 100644 index 1cc196eb..00000000 --- a/.dfx/local/canisters/assets/service.did.js +++ /dev/null @@ -1,258 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const ClearArguments = IDL.Record({}); - const BatchId = IDL.Nat; - const Key = IDL.Text; - const HeaderField = IDL.Tuple(IDL.Text, IDL.Text); - const SetAssetPropertiesArguments = IDL.Record({ - 'key' : Key, - 'headers' : IDL.Opt(IDL.Opt(IDL.Vec(HeaderField))), - 'is_aliased' : IDL.Opt(IDL.Opt(IDL.Bool)), - 'allow_raw_access' : IDL.Opt(IDL.Opt(IDL.Bool)), - 'max_age' : IDL.Opt(IDL.Opt(IDL.Nat64)), - }); - const CreateAssetArguments = IDL.Record({ - 'key' : Key, - 'content_type' : IDL.Text, - 'headers' : IDL.Opt(IDL.Vec(HeaderField)), - 'allow_raw_access' : IDL.Opt(IDL.Bool), - 'max_age' : IDL.Opt(IDL.Nat64), - 'enable_aliasing' : IDL.Opt(IDL.Bool), - }); - const UnsetAssetContentArguments = IDL.Record({ - 'key' : Key, - 'content_encoding' : IDL.Text, - }); - const DeleteAssetArguments = IDL.Record({ 'key' : Key }); - const ChunkId = IDL.Nat; - const SetAssetContentArguments = IDL.Record({ - 'key' : Key, - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'chunk_ids' : IDL.Vec(ChunkId), - 'content_encoding' : IDL.Text, - }); - const BatchOperationKind = IDL.Variant({ - 'SetAssetProperties' : SetAssetPropertiesArguments, - 'CreateAsset' : CreateAssetArguments, - 'UnsetAssetContent' : UnsetAssetContentArguments, - 'DeleteAsset' : DeleteAssetArguments, - 'SetAssetContent' : SetAssetContentArguments, - 'Clear' : ClearArguments, - }); - const CommitBatchArguments = IDL.Record({ - 'batch_id' : BatchId, - 'operations' : IDL.Vec(BatchOperationKind), - }); - const CommitProposedBatchArguments = IDL.Record({ - 'batch_id' : BatchId, - 'evidence' : IDL.Vec(IDL.Nat8), - }); - const ComputeEvidenceArguments = IDL.Record({ - 'batch_id' : BatchId, - 'max_iterations' : IDL.Opt(IDL.Nat16), - }); - const ConfigureArguments = IDL.Record({ - 'max_batches' : IDL.Opt(IDL.Opt(IDL.Nat64)), - 'max_bytes' : IDL.Opt(IDL.Opt(IDL.Nat64)), - 'max_chunks' : IDL.Opt(IDL.Opt(IDL.Nat64)), - }); - const DeleteBatchArguments = IDL.Record({ 'batch_id' : BatchId }); - const ConfigurationResponse = IDL.Record({ - 'max_batches' : IDL.Opt(IDL.Nat64), - 'max_bytes' : IDL.Opt(IDL.Nat64), - 'max_chunks' : IDL.Opt(IDL.Nat64), - }); - const Permission = IDL.Variant({ - 'Prepare' : IDL.Null, - 'ManagePermissions' : IDL.Null, - 'Commit' : IDL.Null, - }); - const GrantPermission = IDL.Record({ - 'permission' : Permission, - 'to_principal' : IDL.Principal, - }); - const HttpRequest = IDL.Record({ - 'url' : IDL.Text, - 'method' : IDL.Text, - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(HeaderField), - 'certificate_version' : IDL.Opt(IDL.Nat16), - }); - const StreamingCallbackToken = IDL.Record({ - 'key' : Key, - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'index' : IDL.Nat, - 'content_encoding' : IDL.Text, - }); - const StreamingCallbackHttpResponse = IDL.Record({ - 'token' : IDL.Opt(StreamingCallbackToken), - 'body' : IDL.Vec(IDL.Nat8), - }); - const StreamingStrategy = IDL.Variant({ - 'Callback' : IDL.Record({ - 'token' : StreamingCallbackToken, - 'callback' : IDL.Func( - [StreamingCallbackToken], - [IDL.Opt(StreamingCallbackHttpResponse)], - ['query'], - ), - }), - }); - const HttpResponse = IDL.Record({ - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(HeaderField), - 'streaming_strategy' : IDL.Opt(StreamingStrategy), - 'status_code' : IDL.Nat16, - }); - const Time = IDL.Int; - const ListPermitted = IDL.Record({ 'permission' : Permission }); - const RevokePermission = IDL.Record({ - 'permission' : Permission, - 'of_principal' : IDL.Principal, - }); - const ValidationResult = IDL.Variant({ 'Ok' : IDL.Text, 'Err' : IDL.Text }); - return IDL.Service({ - 'api_version' : IDL.Func([], [IDL.Nat16], ['query']), - 'authorize' : IDL.Func([IDL.Principal], [], []), - 'certified_tree' : IDL.Func( - [IDL.Record({})], - [ - IDL.Record({ - 'certificate' : IDL.Vec(IDL.Nat8), - 'tree' : IDL.Vec(IDL.Nat8), - }), - ], - ['query'], - ), - 'clear' : IDL.Func([ClearArguments], [], []), - 'commit_batch' : IDL.Func([CommitBatchArguments], [], []), - 'commit_proposed_batch' : IDL.Func([CommitProposedBatchArguments], [], []), - 'compute_evidence' : IDL.Func( - [ComputeEvidenceArguments], - [IDL.Opt(IDL.Vec(IDL.Nat8))], - [], - ), - 'configure' : IDL.Func([ConfigureArguments], [], []), - 'create_asset' : IDL.Func([CreateAssetArguments], [], []), - 'create_batch' : IDL.Func( - [IDL.Record({})], - [IDL.Record({ 'batch_id' : BatchId })], - [], - ), - 'create_chunk' : IDL.Func( - [IDL.Record({ 'content' : IDL.Vec(IDL.Nat8), 'batch_id' : BatchId })], - [IDL.Record({ 'chunk_id' : ChunkId })], - [], - ), - 'deauthorize' : IDL.Func([IDL.Principal], [], []), - 'delete_asset' : IDL.Func([DeleteAssetArguments], [], []), - 'delete_batch' : IDL.Func([DeleteBatchArguments], [], []), - 'get' : IDL.Func( - [IDL.Record({ 'key' : Key, 'accept_encodings' : IDL.Vec(IDL.Text) })], - [ - IDL.Record({ - 'content' : IDL.Vec(IDL.Nat8), - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'content_type' : IDL.Text, - 'content_encoding' : IDL.Text, - 'total_length' : IDL.Nat, - }), - ], - ['query'], - ), - 'get_asset_properties' : IDL.Func( - [Key], - [ - IDL.Record({ - 'headers' : IDL.Opt(IDL.Vec(HeaderField)), - 'is_aliased' : IDL.Opt(IDL.Bool), - 'allow_raw_access' : IDL.Opt(IDL.Bool), - 'max_age' : IDL.Opt(IDL.Nat64), - }), - ], - ['query'], - ), - 'get_chunk' : IDL.Func( - [ - IDL.Record({ - 'key' : Key, - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'index' : IDL.Nat, - 'content_encoding' : IDL.Text, - }), - ], - [IDL.Record({ 'content' : IDL.Vec(IDL.Nat8) })], - ['query'], - ), - 'get_configuration' : IDL.Func([], [ConfigurationResponse], []), - 'grant_permission' : IDL.Func([GrantPermission], [], []), - 'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']), - 'http_request_streaming_callback' : IDL.Func( - [StreamingCallbackToken], - [IDL.Opt(StreamingCallbackHttpResponse)], - ['query'], - ), - 'list' : IDL.Func( - [IDL.Record({})], - [ - IDL.Vec( - IDL.Record({ - 'key' : Key, - 'encodings' : IDL.Vec( - IDL.Record({ - 'modified' : Time, - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'length' : IDL.Nat, - 'content_encoding' : IDL.Text, - }) - ), - 'content_type' : IDL.Text, - }) - ), - ], - ['query'], - ), - 'list_authorized' : IDL.Func([], [IDL.Vec(IDL.Principal)], []), - 'list_permitted' : IDL.Func([ListPermitted], [IDL.Vec(IDL.Principal)], []), - 'propose_commit_batch' : IDL.Func([CommitBatchArguments], [], []), - 'revoke_permission' : IDL.Func([RevokePermission], [], []), - 'set_asset_content' : IDL.Func([SetAssetContentArguments], [], []), - 'set_asset_properties' : IDL.Func([SetAssetPropertiesArguments], [], []), - 'store' : IDL.Func( - [ - IDL.Record({ - 'key' : Key, - 'content' : IDL.Vec(IDL.Nat8), - 'sha256' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'content_type' : IDL.Text, - 'content_encoding' : IDL.Text, - }), - ], - [], - [], - ), - 'take_ownership' : IDL.Func([], [], []), - 'unset_asset_content' : IDL.Func([UnsetAssetContentArguments], [], []), - 'validate_commit_proposed_batch' : IDL.Func( - [CommitProposedBatchArguments], - [ValidationResult], - [], - ), - 'validate_configure' : IDL.Func( - [ConfigureArguments], - [ValidationResult], - [], - ), - 'validate_grant_permission' : IDL.Func( - [GrantPermission], - [ValidationResult], - [], - ), - 'validate_revoke_permission' : IDL.Func( - [RevokePermission], - [ValidationResult], - [], - ), - 'validate_take_ownership' : IDL.Func([], [ValidationResult], []), - }); -}; -export const init = ({ IDL }) => { return []; }; diff --git a/.dfx/local/canisters/backend/backend.did b/.dfx/local/canisters/backend/backend.did deleted file mode 100644 index 7e72b04a..00000000 --- a/.dfx/local/canisters/backend/backend.did +++ /dev/null @@ -1,334 +0,0 @@ -type User = - record { - email_address: text; - email_notifications: bool; - name: text; - phone_notifications: bool; - phone_number: text; - }; -type TransformArgs = - record { - context: blob; - response: HttpResponsePayload; - }; -type Transaction__1 = - record { - amount: nat; - created_at: int; - creator: principal; - destination: principal; - id: nat; - successful: bool; - }; -type Transaction = - record { - amount: nat; - created_at: int; - creator: principal; - destination: principal; - id: nat; - successful: bool; - }; -type Subaccount = blob; -type SchedulePaymentsSuccess = record {receivers: vec PayrollType;}; -type SchedulePaymentsResult = - variant { - err: SchedulePaymentsErr; - ok: SchedulePaymentsSuccess; - }; -type SchedulePaymentsErr = - record { - kind: - variant { - InsufficientBalance; - InvalidAmount; - InvalidDestination; - InvalidDetails; - InvalidSender; - MaxTransactionsReached; - Other; - }; - message: opt text; - }; -type SchedulePaymentsArgs = - record { - created_at: int; - payment_at: int; - receivers: vec PayrollType; - status: variant { - Accepted; - Paid; - Rejected; - Unpaid; - }; - }; -type Result = - variant { - err: text; - ok: text; - }; -type Response_4 = - record { - data: opt Employee; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_3 = - record { - data: opt vec PayrollType__1; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_2 = - record { - data: opt text; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_1 = - record { - data: opt Transaction; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response = - record { - data: opt User; - error_text: opt text; - status: nat16; - status_text: text; - }; -type PayrollType__1 = - record { - amount: nat; - created_at: int; - creator: text; - destination: text; - id: nat; - successful: bool; - }; -type PayrollType = - record { - amount: nat; - created_at: int; - creator: text; - destination: text; - id: nat; - successful: bool; - }; -type Notification__1 = - record { - amount: nat; - id: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type Notification = - record { - amount: nat; - id: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type HttpResponsePayload = - record { - body: vec nat8; - headers: vec HttpHeader; - status: nat; - }; -type HttpHeader = - record { - name: text; - value: text; - }; -type GetTransactionSuccess = record {transaction: Transaction__1;}; -type GetTransactionResult = - variant { - err: GetTransactionErr; - ok: GetTransactionSuccess; - }; -type GetTransactionErr = - record { - kind: variant { - InvalidTransactionId; - NotAuthorized; - NotFound; - Other; - }; - message: opt text; - }; -type GetTransactionArgs = record {id: nat;}; -type GetAccountIdentifierSuccess = record { - accountIdentifier: AccountIdentifier;}; -type GetAccountIdentifierResult = - variant { - err: GetAccountIdentifierErr; - ok: GetAccountIdentifierSuccess; - }; -type GetAccountIdentifierErr = record {message: opt text;}; -type GetAccountIdentifierArgs = record {"principal": principal;}; -type Employee = - record { - access_type: text; - created_at: int; - creator: principal; - email_address: text; - emp_type: text; - id: nat; - modified_at: int; - name: text; - phone_number: text; - wallet: text; - }; -type CreateTransactionSuccess = record {transaction: Transaction__1;}; -type CreateTransactionResult = - variant { - err: CreateTransactionErr; - ok: CreateTransactionSuccess; - }; -type CreateTransactionErr = - record { - kind: - variant { - InsufficientBalance; - InvalidAmount; - InvalidDestination; - InvalidDetails; - InvalidSender; - MaxTransactionsReached; - Other; - }; - message: opt text; - }; -type CreateTransactionArgs = - record { - amount: nat; - creator: principal; - destination: principal; - successful: bool; - }; -type CreateNotificationSuccess = record {notification: Notification;}; -type CreateNotificationResult = - variant { - err: CreateNotificationErr; - ok: CreateNotificationSuccess; - }; -type CreateNotificationErr = - record { - kind: variant { - InvalidNotification; - Other; - }; - message: opt text; - }; -type CreateNotificationArgs = - record { - amount: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type CreateEmployeeArgs = - record { - access_type: text; - emp_type: text; - wallet: text; - }; -type CanisterHttpResponsePayload = - record { - body: vec nat8; - headers: vec HttpHeader; - status: nat; - }; -type Backend = - service { - accountIdentifierToBlob: (AccountIdentifier) -> - (AccountIdentifierToBlobResult); - cancelRecurringTimer: (nat) -> (); - checkPayroll: () -> (); - create_employee: (CreateEmployeeArgs) -> (Response_4); - emailExists: (text) -> (bool) query; - getAddress: () -> (text); - getCanisterAddress: () -> (text); - getCanisterBalance: () -> (text); - getEmployeeByPrincipal: (principal) -> (Response_4); - getFundingAddress: () -> (text); - getFundingBalance: () -> (text); - getInvoice: () -> (Account); - /// * Get latest log items. Log output is capped at 100 items. - getLogs: () -> (vec text) query; - getMyContacts: () -> (vec Employee); - getMyContactsLength: () -> (text); - getMyTransactionLength: () -> (text); - getNotifications: () -> (vec Notification__1); - getTradingAddress: () -> (text); - getTradingBalance: () -> (text); - getTransactionLength: () -> (text) query; - getUnreadNotifications: () -> (vec Notification__1); - getUnreadNotificationsLength: () -> (text); - /// * Get the merchant's information - getUser: () -> (Response) query; - /// * Get user data by principal - getUserByPrincipal: (principal) -> (Response) query; - getUsersList: () -> (vec record { - text; - User; - }) query; - /// * Check for new transactions and notify the merchant if a new transaction is found. - /// * This function is called by the global timer. - get_account_identifier: (GetAccountIdentifierArgs) -> - (GetAccountIdentifierResult) query; - get_transaction: (GetTransactionArgs) -> (GetTransactionResult) query; - get_transactions: () -> (vec Transaction) query; - /// * Check if user exists and return Bool - isRegistered: () -> (bool) query; - remove_employee: (text) -> (Response_4); - runpayroll: (vec PayrollType__1) -> (Response_3); - save_notification: (CreateNotificationArgs) -> (CreateNotificationResult); - save_payroll: (SchedulePaymentsArgs) -> (SchedulePaymentsResult); - save_transaction: (CreateTransactionArgs) -> (CreateTransactionResult); - sendToOwner: (nat, text) -> (Result); - send_notifications: (text, text, text, text, text) -> (); - /// * Set the courier API key. Only the owner can set the courier API key. - setCourierApiKey: (text) -> (Response_2); - setRecurringTimer: (nat) -> (nat); - transferFromCanistertoSubAccount: () -> (Result); - transferFromSubAccountToSubAccount: (text, nat) -> (Response_1); - transform: (TransformArgs) -> (CanisterHttpResponsePayload) query; - /// * Update the merchant's information - updateUser: (User) -> (Response); - userLength: () -> (text) query; - whoami: () -> (principal); - }; -type AccountIdentifierToBlobSuccess = blob; -type AccountIdentifierToBlobResult = - variant { - err: AccountIdentifierToBlobErr; - ok: AccountIdentifierToBlobSuccess; - }; -type AccountIdentifierToBlobErr = - record { - kind: variant { - InvalidAccountIdentifier; - Other; - }; - message: opt text; - }; -type AccountIdentifier = - variant { - "blob": blob; - "principal": principal; - "text": text; - }; -type Account = - record { - owner: principal; - subaccount: opt Subaccount; - }; -service : (nat) -> Backend diff --git a/.dfx/local/canisters/backend/backend.most b/.dfx/local/canisters/backend/backend.most deleted file mode 100644 index c5a2ea83..00000000 --- a/.dfx/local/canisters/backend/backend.most +++ /dev/null @@ -1,85 +0,0 @@ -// Version: 1.0.0 -type AssocList = List<(K, V)>; -type AssocList__1 = AssocList; -type Branch = {left : Trie; right : Trie; size : Nat}; -type Employee = - { - access_type : Text; - created_at : Int; - creator : Principal; - email_address : Text; - emp_type : Text; - id : Nat; - modified_at : Int; - name : Text; - phone_number : Text; - wallet : Text - }; -type Employee__1 = Employee; -type Hash = Nat32; -type Invoice = - { - amount : Text; - client : Text; - created_at : Int; - creator : Text; - id : Nat; - isApproved : Bool; - isPaid : Bool; - memo : ?Text; - modified_at : Int; - receiver : Text - }; -type Invoice__1 = Invoice; -type Key__1 = {hash : Hash; key : K}; -type Leaf = {keyvals : AssocList__1, V>; size : Nat}; -type List = ?(T, List); -type Notification = - {amount : Nat; id : Nat; isRead : Bool; receiver : Text; sender : Text}; -type Notification__1 = Notification; -type PayrollType = - { - amount : Nat; - created_at : Int; - creator : Text; - destination : Text; - id : Nat; - successful : Bool - }; -type PayrollType__1 = PayrollType; -type Transaction = - { - amount : Nat; - created_at : Int; - creator : Principal; - destination : Principal; - id : Nat; - successful : Bool - }; -type Transaction__2 = Transaction; -type Trie = {#branch : Branch; #empty; #leaf : Leaf}; -type User = - { - email_address : Text; - email_notifications : Bool; - name : Text; - phone_notifications : Bool; - phone_number : Text - }; -type User__1 = User; -actor { - stable var contactsCounter : Nat; - stable var contactsStable : [(Nat, Employee__1)]; - stable var courierApiKey : Text; - stable var invoiceCounter : Nat; - stable var invoicesStable : [(Nat, Invoice__1)]; - stable var latestTransactionIndex : Nat; - stable var notificationsCounter : Nat; - stable var notificationsStable : [(Nat, Notification__1)]; - stable var payrollCounter : Nat; - stable var stablePayroll : [(Nat, [PayrollType__1])]; - stable var transactionCounter : Nat; - stable var transactionsStable : [(Nat, Transaction__2)]; - stable var userStore : - {#branch : Branch; #empty; #leaf : Leaf} -}; diff --git a/.dfx/local/canisters/backend/backend.old.most b/.dfx/local/canisters/backend/backend.old.most deleted file mode 100644 index c5a2ea83..00000000 --- a/.dfx/local/canisters/backend/backend.old.most +++ /dev/null @@ -1,85 +0,0 @@ -// Version: 1.0.0 -type AssocList = List<(K, V)>; -type AssocList__1 = AssocList; -type Branch = {left : Trie; right : Trie; size : Nat}; -type Employee = - { - access_type : Text; - created_at : Int; - creator : Principal; - email_address : Text; - emp_type : Text; - id : Nat; - modified_at : Int; - name : Text; - phone_number : Text; - wallet : Text - }; -type Employee__1 = Employee; -type Hash = Nat32; -type Invoice = - { - amount : Text; - client : Text; - created_at : Int; - creator : Text; - id : Nat; - isApproved : Bool; - isPaid : Bool; - memo : ?Text; - modified_at : Int; - receiver : Text - }; -type Invoice__1 = Invoice; -type Key__1 = {hash : Hash; key : K}; -type Leaf = {keyvals : AssocList__1, V>; size : Nat}; -type List = ?(T, List); -type Notification = - {amount : Nat; id : Nat; isRead : Bool; receiver : Text; sender : Text}; -type Notification__1 = Notification; -type PayrollType = - { - amount : Nat; - created_at : Int; - creator : Text; - destination : Text; - id : Nat; - successful : Bool - }; -type PayrollType__1 = PayrollType; -type Transaction = - { - amount : Nat; - created_at : Int; - creator : Principal; - destination : Principal; - id : Nat; - successful : Bool - }; -type Transaction__2 = Transaction; -type Trie = {#branch : Branch; #empty; #leaf : Leaf}; -type User = - { - email_address : Text; - email_notifications : Bool; - name : Text; - phone_notifications : Bool; - phone_number : Text - }; -type User__1 = User; -actor { - stable var contactsCounter : Nat; - stable var contactsStable : [(Nat, Employee__1)]; - stable var courierApiKey : Text; - stable var invoiceCounter : Nat; - stable var invoicesStable : [(Nat, Invoice__1)]; - stable var latestTransactionIndex : Nat; - stable var notificationsCounter : Nat; - stable var notificationsStable : [(Nat, Notification__1)]; - stable var payrollCounter : Nat; - stable var stablePayroll : [(Nat, [PayrollType__1])]; - stable var transactionCounter : Nat; - stable var transactionsStable : [(Nat, Transaction__2)]; - stable var userStore : - {#branch : Branch; #empty; #leaf : Leaf} -}; diff --git a/.dfx/local/canisters/backend/backend.wasm b/.dfx/local/canisters/backend/backend.wasm deleted file mode 100644 index 60071004..00000000 Binary files a/.dfx/local/canisters/backend/backend.wasm and /dev/null differ diff --git a/.dfx/local/canisters/backend/constructor.did b/.dfx/local/canisters/backend/constructor.did deleted file mode 100644 index 7e72b04a..00000000 --- a/.dfx/local/canisters/backend/constructor.did +++ /dev/null @@ -1,334 +0,0 @@ -type User = - record { - email_address: text; - email_notifications: bool; - name: text; - phone_notifications: bool; - phone_number: text; - }; -type TransformArgs = - record { - context: blob; - response: HttpResponsePayload; - }; -type Transaction__1 = - record { - amount: nat; - created_at: int; - creator: principal; - destination: principal; - id: nat; - successful: bool; - }; -type Transaction = - record { - amount: nat; - created_at: int; - creator: principal; - destination: principal; - id: nat; - successful: bool; - }; -type Subaccount = blob; -type SchedulePaymentsSuccess = record {receivers: vec PayrollType;}; -type SchedulePaymentsResult = - variant { - err: SchedulePaymentsErr; - ok: SchedulePaymentsSuccess; - }; -type SchedulePaymentsErr = - record { - kind: - variant { - InsufficientBalance; - InvalidAmount; - InvalidDestination; - InvalidDetails; - InvalidSender; - MaxTransactionsReached; - Other; - }; - message: opt text; - }; -type SchedulePaymentsArgs = - record { - created_at: int; - payment_at: int; - receivers: vec PayrollType; - status: variant { - Accepted; - Paid; - Rejected; - Unpaid; - }; - }; -type Result = - variant { - err: text; - ok: text; - }; -type Response_4 = - record { - data: opt Employee; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_3 = - record { - data: opt vec PayrollType__1; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_2 = - record { - data: opt text; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_1 = - record { - data: opt Transaction; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response = - record { - data: opt User; - error_text: opt text; - status: nat16; - status_text: text; - }; -type PayrollType__1 = - record { - amount: nat; - created_at: int; - creator: text; - destination: text; - id: nat; - successful: bool; - }; -type PayrollType = - record { - amount: nat; - created_at: int; - creator: text; - destination: text; - id: nat; - successful: bool; - }; -type Notification__1 = - record { - amount: nat; - id: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type Notification = - record { - amount: nat; - id: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type HttpResponsePayload = - record { - body: vec nat8; - headers: vec HttpHeader; - status: nat; - }; -type HttpHeader = - record { - name: text; - value: text; - }; -type GetTransactionSuccess = record {transaction: Transaction__1;}; -type GetTransactionResult = - variant { - err: GetTransactionErr; - ok: GetTransactionSuccess; - }; -type GetTransactionErr = - record { - kind: variant { - InvalidTransactionId; - NotAuthorized; - NotFound; - Other; - }; - message: opt text; - }; -type GetTransactionArgs = record {id: nat;}; -type GetAccountIdentifierSuccess = record { - accountIdentifier: AccountIdentifier;}; -type GetAccountIdentifierResult = - variant { - err: GetAccountIdentifierErr; - ok: GetAccountIdentifierSuccess; - }; -type GetAccountIdentifierErr = record {message: opt text;}; -type GetAccountIdentifierArgs = record {"principal": principal;}; -type Employee = - record { - access_type: text; - created_at: int; - creator: principal; - email_address: text; - emp_type: text; - id: nat; - modified_at: int; - name: text; - phone_number: text; - wallet: text; - }; -type CreateTransactionSuccess = record {transaction: Transaction__1;}; -type CreateTransactionResult = - variant { - err: CreateTransactionErr; - ok: CreateTransactionSuccess; - }; -type CreateTransactionErr = - record { - kind: - variant { - InsufficientBalance; - InvalidAmount; - InvalidDestination; - InvalidDetails; - InvalidSender; - MaxTransactionsReached; - Other; - }; - message: opt text; - }; -type CreateTransactionArgs = - record { - amount: nat; - creator: principal; - destination: principal; - successful: bool; - }; -type CreateNotificationSuccess = record {notification: Notification;}; -type CreateNotificationResult = - variant { - err: CreateNotificationErr; - ok: CreateNotificationSuccess; - }; -type CreateNotificationErr = - record { - kind: variant { - InvalidNotification; - Other; - }; - message: opt text; - }; -type CreateNotificationArgs = - record { - amount: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type CreateEmployeeArgs = - record { - access_type: text; - emp_type: text; - wallet: text; - }; -type CanisterHttpResponsePayload = - record { - body: vec nat8; - headers: vec HttpHeader; - status: nat; - }; -type Backend = - service { - accountIdentifierToBlob: (AccountIdentifier) -> - (AccountIdentifierToBlobResult); - cancelRecurringTimer: (nat) -> (); - checkPayroll: () -> (); - create_employee: (CreateEmployeeArgs) -> (Response_4); - emailExists: (text) -> (bool) query; - getAddress: () -> (text); - getCanisterAddress: () -> (text); - getCanisterBalance: () -> (text); - getEmployeeByPrincipal: (principal) -> (Response_4); - getFundingAddress: () -> (text); - getFundingBalance: () -> (text); - getInvoice: () -> (Account); - /// * Get latest log items. Log output is capped at 100 items. - getLogs: () -> (vec text) query; - getMyContacts: () -> (vec Employee); - getMyContactsLength: () -> (text); - getMyTransactionLength: () -> (text); - getNotifications: () -> (vec Notification__1); - getTradingAddress: () -> (text); - getTradingBalance: () -> (text); - getTransactionLength: () -> (text) query; - getUnreadNotifications: () -> (vec Notification__1); - getUnreadNotificationsLength: () -> (text); - /// * Get the merchant's information - getUser: () -> (Response) query; - /// * Get user data by principal - getUserByPrincipal: (principal) -> (Response) query; - getUsersList: () -> (vec record { - text; - User; - }) query; - /// * Check for new transactions and notify the merchant if a new transaction is found. - /// * This function is called by the global timer. - get_account_identifier: (GetAccountIdentifierArgs) -> - (GetAccountIdentifierResult) query; - get_transaction: (GetTransactionArgs) -> (GetTransactionResult) query; - get_transactions: () -> (vec Transaction) query; - /// * Check if user exists and return Bool - isRegistered: () -> (bool) query; - remove_employee: (text) -> (Response_4); - runpayroll: (vec PayrollType__1) -> (Response_3); - save_notification: (CreateNotificationArgs) -> (CreateNotificationResult); - save_payroll: (SchedulePaymentsArgs) -> (SchedulePaymentsResult); - save_transaction: (CreateTransactionArgs) -> (CreateTransactionResult); - sendToOwner: (nat, text) -> (Result); - send_notifications: (text, text, text, text, text) -> (); - /// * Set the courier API key. Only the owner can set the courier API key. - setCourierApiKey: (text) -> (Response_2); - setRecurringTimer: (nat) -> (nat); - transferFromCanistertoSubAccount: () -> (Result); - transferFromSubAccountToSubAccount: (text, nat) -> (Response_1); - transform: (TransformArgs) -> (CanisterHttpResponsePayload) query; - /// * Update the merchant's information - updateUser: (User) -> (Response); - userLength: () -> (text) query; - whoami: () -> (principal); - }; -type AccountIdentifierToBlobSuccess = blob; -type AccountIdentifierToBlobResult = - variant { - err: AccountIdentifierToBlobErr; - ok: AccountIdentifierToBlobSuccess; - }; -type AccountIdentifierToBlobErr = - record { - kind: variant { - InvalidAccountIdentifier; - Other; - }; - message: opt text; - }; -type AccountIdentifier = - variant { - "blob": blob; - "principal": principal; - "text": text; - }; -type Account = - record { - owner: principal; - subaccount: opt Subaccount; - }; -service : (nat) -> Backend diff --git a/.dfx/local/canisters/backend/constructor.old.did b/.dfx/local/canisters/backend/constructor.old.did deleted file mode 100644 index 773b6cbf..00000000 --- a/.dfx/local/canisters/backend/constructor.old.did +++ /dev/null @@ -1,324 +0,0 @@ -type User = - record { - email_address: text; - email_notifications: bool; - name: text; - phone_notifications: bool; - phone_number: text; - }; -type TransformArgs = - record { - context: blob; - response: HttpResponsePayload; - }; -type Transaction__1 = - record { - amount: nat; - created_at: int; - creator: principal; - destination: principal; - id: nat; - successful: bool; - }; -type Transaction = - record { - amount: nat; - created_at: int; - creator: principal; - destination: principal; - id: nat; - successful: bool; - }; -type Subaccount = blob; -type SchedulePaymentsSuccess = record {receivers: vec PayrollType;}; -type SchedulePaymentsResult = - variant { - err: SchedulePaymentsErr; - ok: SchedulePaymentsSuccess; - }; -type SchedulePaymentsErr = - record { - kind: - variant { - InsufficientBalance; - InvalidAmount; - InvalidDestination; - InvalidDetails; - InvalidSender; - MaxTransactionsReached; - Other; - }; - message: opt text; - }; -type SchedulePaymentsArgs = - record { - created_at: int; - payment_at: int; - receivers: vec PayrollType; - status: variant { - Accepted; - Paid; - Rejected; - Unpaid; - }; - }; -type Result = - variant { - err: text; - ok: text; - }; -type Response_4 = - record { - data: opt Employee; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_3 = - record { - data: opt vec PayrollType__1; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_2 = - record { - data: opt text; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response_1 = - record { - data: opt Transaction; - error_text: opt text; - status: nat16; - status_text: text; - }; -type Response = - record { - data: opt User; - error_text: opt text; - status: nat16; - status_text: text; - }; -type PayrollType__1 = - record { - amount: nat; - created_at: int; - creator: text; - destination: text; - id: nat; - successful: bool; - }; -type PayrollType = - record { - amount: nat; - created_at: int; - creator: text; - destination: text; - id: nat; - successful: bool; - }; -type Notification__1 = - record { - amount: nat; - id: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type Notification = - record { - amount: nat; - id: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type HttpResponsePayload = - record { - body: vec nat8; - headers: vec HttpHeader; - status: nat; - }; -type HttpHeader = - record { - name: text; - value: text; - }; -type GetTransactionSuccess = record {transaction: Transaction__1;}; -type GetTransactionResult = - variant { - err: GetTransactionErr; - ok: GetTransactionSuccess; - }; -type GetTransactionErr = - record { - kind: variant { - InvalidTransactionId; - NotAuthorized; - NotFound; - Other; - }; - message: opt text; - }; -type GetTransactionArgs = record {id: nat;}; -type GetAccountIdentifierSuccess = record { - accountIdentifier: AccountIdentifier;}; -type GetAccountIdentifierResult = - variant { - err: GetAccountIdentifierErr; - ok: GetAccountIdentifierSuccess; - }; -type GetAccountIdentifierErr = record {message: opt text;}; -type GetAccountIdentifierArgs = record {"principal": principal;}; -type Employee = - record { - access_type: text; - created_at: int; - creator: principal; - email_address: text; - emp_type: text; - id: nat; - modified_at: int; - name: text; - phone_number: text; - wallet: text; - }; -type CreateTransactionSuccess = record {transaction: Transaction__1;}; -type CreateTransactionResult = - variant { - err: CreateTransactionErr; - ok: CreateTransactionSuccess; - }; -type CreateTransactionErr = - record { - kind: - variant { - InsufficientBalance; - InvalidAmount; - InvalidDestination; - InvalidDetails; - InvalidSender; - MaxTransactionsReached; - Other; - }; - message: opt text; - }; -type CreateTransactionArgs = - record { - amount: nat; - creator: principal; - destination: principal; - successful: bool; - }; -type CreateNotificationSuccess = record {notification: Notification;}; -type CreateNotificationResult = - variant { - err: CreateNotificationErr; - ok: CreateNotificationSuccess; - }; -type CreateNotificationErr = - record { - kind: variant { - InvalidNotification; - Other; - }; - message: opt text; - }; -type CreateNotificationArgs = - record { - amount: nat; - isRead: bool; - receiver: text; - sender: text; - }; -type CreateEmployeeArgs = - record { - access_type: text; - emp_type: text; - wallet: text; - }; -type CanisterHttpResponsePayload = - record { - body: vec nat8; - headers: vec HttpHeader; - status: nat; - }; -type AccountIdentifierToBlobSuccess = blob; -type AccountIdentifierToBlobResult = - variant { - err: AccountIdentifierToBlobErr; - ok: AccountIdentifierToBlobSuccess; - }; -type AccountIdentifierToBlobErr = - record { - kind: variant { - InvalidAccountIdentifier; - Other; - }; - message: opt text; - }; -type AccountIdentifier = - variant { - "blob": blob; - "principal": principal; - "text": text; - }; -type Account = - record { - owner: principal; - subaccount: opt Subaccount; - }; -service : { - accountIdentifierToBlob: (AccountIdentifier) -> - (AccountIdentifierToBlobResult); - cancelRecurringTimer: (nat) -> (); - checkPayroll: () -> (); - create_employee: (CreateEmployeeArgs) -> (Response_4); - emailExists: (text) -> (bool) query; - getAddress: () -> (text); - getCanisterAddress: () -> (text); - getCanisterBalance: () -> (text); - getEmployeeByPrincipal: (principal) -> (Response_4); - getFundingAddress: () -> (text); - getFundingBalance: () -> (text); - getInvoice: () -> (Account); - getLogs: () -> (vec text) query; - getMyContacts: () -> (vec Employee); - getMyContactsLength: () -> (text); - getMyTransactionLength: () -> (text); - getNotifications: () -> (vec Notification__1); - getTradingAddress: () -> (text); - getTradingBalance: () -> (text); - getTransactionLength: () -> (text) query; - getUnreadNotifications: () -> (vec Notification__1); - getUnreadNotificationsLength: () -> (text); - getUser: () -> (Response) query; - getUserByPrincipal: (principal) -> (Response) query; - getUsersList: () -> (vec record { - text; - User; - }) query; - get_account_identifier: (GetAccountIdentifierArgs) -> - (GetAccountIdentifierResult) query; - get_transaction: (GetTransactionArgs) -> (GetTransactionResult) query; - get_transactions: () -> (vec Transaction) query; - isRegistered: () -> (bool) query; - remove_employee: (text) -> (Response_4); - runpayroll: (vec PayrollType__1) -> (Response_3); - save_notification: (CreateNotificationArgs) -> (CreateNotificationResult); - save_payroll: (SchedulePaymentsArgs) -> (SchedulePaymentsResult); - save_transaction: (CreateTransactionArgs) -> (CreateTransactionResult); - sendToOwner: (nat, text) -> (Result); - send_notifications: (text, text, text, text, text) -> (); - setCourierApiKey: (text) -> (Response_2); - setRecurringTimer: (nat) -> (nat); - transferFromCanistertoSubAccount: () -> (Result); - transferFromSubAccountToSubAccount: (text, nat) -> (Response_1); - transform: (TransformArgs) -> (CanisterHttpResponsePayload) query; - updateUser: (User) -> (Response); - userLength: () -> (text) query; - whoami: () -> (principal); -} diff --git a/.dfx/local/canisters/backend/index.js b/.dfx/local/canisters/backend/index.js deleted file mode 100644 index 17776d38..00000000 --- a/.dfx/local/canisters/backend/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from './backend.did.js'; -export { idlFactory } from './backend.did.js'; -// CANISTER_ID is replaced by webpack based on node environment -export const canisterId = process.env.BACKEND_CANISTER_ID; - -/** - * @deprecated since dfx 0.11.1 - * Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface. - * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent - * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options] - * @return {import("@dfinity/agent").ActorSubclass} - */ -export const createActor = (canisterId, options = {}) => { - console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings. - -See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`); - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - // 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 ? options.actorOptions : {}), - }); -}; - -/** - * A ready-to-use agent for the backend canister - * @type {import("@dfinity/agent").ActorSubclass} - */ -export const backend = createActor(canisterId); diff --git a/.dfx/local/canisters/backend/init_args.txt b/.dfx/local/canisters/backend/init_args.txt deleted file mode 100644 index a2147eb9..00000000 --- a/.dfx/local/canisters/backend/init_args.txt +++ /dev/null @@ -1 +0,0 @@ -(nat) \ No newline at end of file diff --git a/.dfx/local/canisters/backend/service.did b/.dfx/local/canisters/backend/service.did deleted file mode 100644 index 013ecd85..00000000 --- a/.dfx/local/canisters/backend/service.did +++ /dev/null @@ -1,263 +0,0 @@ -type Account = record { owner : principal; subaccount : opt Subaccount }; -type AccountIdentifier = variant { - "principal" : principal; - "blob" : vec nat8; - "text" : text; -}; -type AccountIdentifierToBlobErr = record { - kind : variant { InvalidAccountIdentifier; Other }; - message : opt text; -}; -type AccountIdentifierToBlobResult = variant { - ok : AccountIdentifierToBlobSuccess; - err : AccountIdentifierToBlobErr; -}; -type AccountIdentifierToBlobSuccess = vec nat8; -type Backend = service { - accountIdentifierToBlob : (AccountIdentifier) -> ( - AccountIdentifierToBlobResult, - ); - cancelRecurringTimer : (nat) -> (); - checkPayroll : () -> (); - create_employee : (CreateEmployeeArgs) -> (Response_4); - emailExists : (text) -> (bool) query; - getAddress : () -> (text); - getCanisterAddress : () -> (text); - getCanisterBalance : () -> (text); - getEmployeeByPrincipal : (principal) -> (Response_4); - getFundingAddress : () -> (text); - getFundingBalance : () -> (text); - getInvoice : () -> (Account); - getLogs : () -> (vec text) query; - getMyContacts : () -> (vec Employee); - getMyContactsLength : () -> (text); - getMyTransactionLength : () -> (text); - getNotifications : () -> (vec Notification__1); - getTradingAddress : () -> (text); - getTradingBalance : () -> (text); - getTransactionLength : () -> (text) query; - getUnreadNotifications : () -> (vec Notification__1); - getUnreadNotificationsLength : () -> (text); - getUser : () -> (Response) query; - getUserByPrincipal : (principal) -> (Response) query; - getUsersList : () -> (vec record { text; User }) query; - get_account_identifier : (GetAccountIdentifierArgs) -> ( - GetAccountIdentifierResult, - ) query; - get_transaction : (GetTransactionArgs) -> (GetTransactionResult) query; - get_transactions : () -> (vec Transaction) query; - isRegistered : () -> (bool) query; - remove_employee : (text) -> (Response_4); - runpayroll : (vec PayrollType__1) -> (Response_3); - save_notification : (CreateNotificationArgs) -> (CreateNotificationResult); - save_payroll : (SchedulePaymentsArgs) -> (SchedulePaymentsResult); - save_transaction : (CreateTransactionArgs) -> (CreateTransactionResult); - sendToOwner : (nat, text) -> (Result); - send_notifications : (text, text, text, text, text) -> (); - setCourierApiKey : (text) -> (Response_2); - setRecurringTimer : (nat) -> (nat); - transferFromCanistertoSubAccount : () -> (Result); - transferFromSubAccountToSubAccount : (text, nat) -> (Response_1); - transform : (TransformArgs) -> (CanisterHttpResponsePayload) query; - updateUser : (User) -> (Response); - userLength : () -> (text) query; - whoami : () -> (principal); -}; -type CanisterHttpResponsePayload = record { - status : nat; - body : vec nat8; - headers : vec HttpHeader; -}; -type CreateEmployeeArgs = record { - emp_type : text; - wallet : text; - access_type : text; -}; -type CreateNotificationArgs = record { - isRead : bool; - sender : text; - amount : nat; - receiver : text; -}; -type CreateNotificationErr = record { - kind : variant { InvalidNotification; Other }; - message : opt text; -}; -type CreateNotificationResult = variant { - ok : CreateNotificationSuccess; - err : CreateNotificationErr; -}; -type CreateNotificationSuccess = record { notification : Notification }; -type CreateTransactionArgs = record { - creator : principal; - destination : principal; - amount : nat; - successful : bool; -}; -type CreateTransactionErr = record { - kind : variant { - InvalidDetails; - InvalidAmount; - InvalidDestination; - MaxTransactionsReached; - InsufficientBalance; - InvalidSender; - Other; - }; - message : opt text; -}; -type CreateTransactionResult = variant { - ok : CreateTransactionSuccess; - err : CreateTransactionErr; -}; -type CreateTransactionSuccess = record { transaction : Transaction__1 }; -type Employee = record { - id : nat; - email_address : text; - emp_type : text; - creator : principal; - modified_at : int; - name : text; - created_at : int; - wallet : text; - phone_number : text; - access_type : text; -}; -type GetAccountIdentifierArgs = record { "principal" : principal }; -type GetAccountIdentifierErr = record { message : opt text }; -type GetAccountIdentifierResult = variant { - ok : GetAccountIdentifierSuccess; - err : GetAccountIdentifierErr; -}; -type GetAccountIdentifierSuccess = record { - accountIdentifier : AccountIdentifier; -}; -type GetTransactionArgs = record { id : nat }; -type GetTransactionErr = record { - kind : variant { NotFound; NotAuthorized; Other; InvalidTransactionId }; - message : opt text; -}; -type GetTransactionResult = variant { - ok : GetTransactionSuccess; - err : GetTransactionErr; -}; -type GetTransactionSuccess = record { transaction : Transaction__1 }; -type HttpHeader = record { value : text; name : text }; -type HttpResponsePayload = record { - status : nat; - body : vec nat8; - headers : vec HttpHeader; -}; -type Notification = record { - id : nat; - isRead : bool; - sender : text; - amount : nat; - receiver : text; -}; -type Notification__1 = record { - id : nat; - isRead : bool; - sender : text; - amount : nat; - receiver : text; -}; -type PayrollType = record { - id : nat; - creator : text; - destination : text; - created_at : int; - amount : nat; - successful : bool; -}; -type PayrollType__1 = record { - id : nat; - creator : text; - destination : text; - created_at : int; - amount : nat; - successful : bool; -}; -type Response = record { - status : nat16; - data : opt User; - status_text : text; - error_text : opt text; -}; -type Response_1 = record { - status : nat16; - data : opt Transaction; - status_text : text; - error_text : opt text; -}; -type Response_2 = record { - status : nat16; - data : opt text; - status_text : text; - error_text : opt text; -}; -type Response_3 = record { - status : nat16; - data : opt vec PayrollType__1; - status_text : text; - error_text : opt text; -}; -type Response_4 = record { - status : nat16; - data : opt Employee; - status_text : text; - error_text : opt text; -}; -type Result = variant { ok : text; err : text }; -type SchedulePaymentsArgs = record { - status : variant { Paid; Rejected; Unpaid; Accepted }; - created_at : int; - receivers : vec PayrollType; - payment_at : int; -}; -type SchedulePaymentsErr = record { - kind : variant { - InvalidDetails; - InvalidAmount; - InvalidDestination; - MaxTransactionsReached; - InsufficientBalance; - InvalidSender; - Other; - }; - message : opt text; -}; -type SchedulePaymentsResult = variant { - ok : SchedulePaymentsSuccess; - err : SchedulePaymentsErr; -}; -type SchedulePaymentsSuccess = record { receivers : vec PayrollType }; -type Subaccount = vec nat8; -type Transaction = record { - id : nat; - creator : principal; - destination : principal; - created_at : int; - amount : nat; - successful : bool; -}; -type Transaction__1 = record { - id : nat; - creator : principal; - destination : principal; - created_at : int; - amount : nat; - successful : bool; -}; -type TransformArgs = record { - context : vec nat8; - response : HttpResponsePayload; -}; -type User = record { - email_address : text; - phone_notifications : bool; - name : text; - email_notifications : bool; - phone_number : text; -}; -service : Backend \ No newline at end of file diff --git a/.dfx/local/canisters/backend/service.did.d.ts b/.dfx/local/canisters/backend/service.did.d.ts deleted file mode 100644 index b549d5c3..00000000 --- a/.dfx/local/canisters/backend/service.did.d.ts +++ /dev/null @@ -1,281 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export interface Account { - 'owner' : Principal, - 'subaccount' : [] | [Subaccount], -} -export type AccountIdentifier = { 'principal' : Principal } | - { 'blob' : Uint8Array | number[] } | - { 'text' : string }; -export interface AccountIdentifierToBlobErr { - 'kind' : { 'InvalidAccountIdentifier' : null } | - { 'Other' : null }, - 'message' : [] | [string], -} -export type AccountIdentifierToBlobResult = { - 'ok' : AccountIdentifierToBlobSuccess - } | - { 'err' : AccountIdentifierToBlobErr }; -export type AccountIdentifierToBlobSuccess = Uint8Array | number[]; -export interface Backend { - 'accountIdentifierToBlob' : ActorMethod< - [AccountIdentifier], - AccountIdentifierToBlobResult - >, - 'cancelRecurringTimer' : ActorMethod<[bigint], undefined>, - 'checkPayroll' : ActorMethod<[], undefined>, - 'create_employee' : ActorMethod<[CreateEmployeeArgs], Response_4>, - 'emailExists' : ActorMethod<[string], boolean>, - 'getAddress' : ActorMethod<[], string>, - 'getCanisterAddress' : ActorMethod<[], string>, - 'getCanisterBalance' : ActorMethod<[], string>, - 'getEmployeeByPrincipal' : ActorMethod<[Principal], Response_4>, - 'getFundingAddress' : ActorMethod<[], string>, - 'getFundingBalance' : ActorMethod<[], string>, - 'getInvoice' : ActorMethod<[], Account>, - 'getLogs' : ActorMethod<[], Array>, - 'getMyContacts' : ActorMethod<[], Array>, - 'getMyContactsLength' : ActorMethod<[], string>, - 'getMyTransactionLength' : ActorMethod<[], string>, - 'getNotifications' : ActorMethod<[], Array>, - 'getTradingAddress' : ActorMethod<[], string>, - 'getTradingBalance' : ActorMethod<[], string>, - 'getTransactionLength' : ActorMethod<[], string>, - 'getUnreadNotifications' : ActorMethod<[], Array>, - 'getUnreadNotificationsLength' : ActorMethod<[], string>, - 'getUser' : ActorMethod<[], Response>, - 'getUserByPrincipal' : ActorMethod<[Principal], Response>, - 'getUsersList' : ActorMethod<[], Array<[string, User]>>, - 'get_account_identifier' : ActorMethod< - [GetAccountIdentifierArgs], - GetAccountIdentifierResult - >, - 'get_transaction' : ActorMethod<[GetTransactionArgs], GetTransactionResult>, - 'get_transactions' : ActorMethod<[], Array>, - 'isRegistered' : ActorMethod<[], boolean>, - 'remove_employee' : ActorMethod<[string], Response_4>, - 'runpayroll' : ActorMethod<[Array], Response_3>, - 'save_notification' : ActorMethod< - [CreateNotificationArgs], - CreateNotificationResult - >, - 'save_payroll' : ActorMethod<[SchedulePaymentsArgs], SchedulePaymentsResult>, - 'save_transaction' : ActorMethod< - [CreateTransactionArgs], - CreateTransactionResult - >, - 'sendToOwner' : ActorMethod<[bigint, string], Result>, - 'send_notifications' : ActorMethod< - [string, string, string, string, string], - undefined - >, - 'setCourierApiKey' : ActorMethod<[string], Response_2>, - 'setRecurringTimer' : ActorMethod<[bigint], bigint>, - 'transferFromCanistertoSubAccount' : ActorMethod<[], Result>, - 'transferFromSubAccountToSubAccount' : ActorMethod< - [string, bigint], - Response_1 - >, - 'transform' : ActorMethod<[TransformArgs], CanisterHttpResponsePayload>, - 'updateUser' : ActorMethod<[User], Response>, - 'userLength' : ActorMethod<[], string>, - 'whoami' : ActorMethod<[], Principal>, -} -export interface CanisterHttpResponsePayload { - 'status' : bigint, - 'body' : Uint8Array | number[], - 'headers' : Array, -} -export interface CreateEmployeeArgs { - 'emp_type' : string, - 'wallet' : string, - 'access_type' : string, -} -export interface CreateNotificationArgs { - 'isRead' : boolean, - 'sender' : string, - 'amount' : bigint, - 'receiver' : string, -} -export interface CreateNotificationErr { - 'kind' : { 'InvalidNotification' : null } | - { 'Other' : null }, - 'message' : [] | [string], -} -export type CreateNotificationResult = { 'ok' : CreateNotificationSuccess } | - { 'err' : CreateNotificationErr }; -export interface CreateNotificationSuccess { 'notification' : Notification } -export interface CreateTransactionArgs { - 'creator' : Principal, - 'destination' : Principal, - 'amount' : bigint, - 'successful' : boolean, -} -export interface CreateTransactionErr { - 'kind' : { 'InvalidDetails' : null } | - { 'InvalidAmount' : null } | - { 'InvalidDestination' : null } | - { 'MaxTransactionsReached' : null } | - { 'InsufficientBalance' : null } | - { 'InvalidSender' : null } | - { 'Other' : null }, - 'message' : [] | [string], -} -export type CreateTransactionResult = { 'ok' : CreateTransactionSuccess } | - { 'err' : CreateTransactionErr }; -export interface CreateTransactionSuccess { 'transaction' : Transaction__1 } -export interface Employee { - 'id' : bigint, - 'email_address' : string, - 'emp_type' : string, - 'creator' : Principal, - 'modified_at' : bigint, - 'name' : string, - 'created_at' : bigint, - 'wallet' : string, - 'phone_number' : string, - 'access_type' : string, -} -export interface GetAccountIdentifierArgs { 'principal' : Principal } -export interface GetAccountIdentifierErr { 'message' : [] | [string] } -export type GetAccountIdentifierResult = { - 'ok' : GetAccountIdentifierSuccess - } | - { 'err' : GetAccountIdentifierErr }; -export interface GetAccountIdentifierSuccess { - 'accountIdentifier' : AccountIdentifier, -} -export interface GetTransactionArgs { 'id' : bigint } -export interface GetTransactionErr { - 'kind' : { 'NotFound' : null } | - { 'NotAuthorized' : null } | - { 'Other' : null } | - { 'InvalidTransactionId' : null }, - 'message' : [] | [string], -} -export type GetTransactionResult = { 'ok' : GetTransactionSuccess } | - { 'err' : GetTransactionErr }; -export interface GetTransactionSuccess { 'transaction' : Transaction__1 } -export interface HttpHeader { 'value' : string, 'name' : string } -export interface HttpResponsePayload { - 'status' : bigint, - 'body' : Uint8Array | number[], - 'headers' : Array, -} -export interface Notification { - 'id' : bigint, - 'isRead' : boolean, - 'sender' : string, - 'amount' : bigint, - 'receiver' : string, -} -export interface Notification__1 { - 'id' : bigint, - 'isRead' : boolean, - 'sender' : string, - 'amount' : bigint, - 'receiver' : string, -} -export interface PayrollType { - 'id' : bigint, - 'creator' : string, - 'destination' : string, - 'created_at' : bigint, - 'amount' : bigint, - 'successful' : boolean, -} -export interface PayrollType__1 { - 'id' : bigint, - 'creator' : string, - 'destination' : string, - 'created_at' : bigint, - 'amount' : bigint, - 'successful' : boolean, -} -export interface Response { - 'status' : number, - 'data' : [] | [User], - 'status_text' : string, - 'error_text' : [] | [string], -} -export interface Response_1 { - 'status' : number, - 'data' : [] | [Transaction], - 'status_text' : string, - 'error_text' : [] | [string], -} -export interface Response_2 { - 'status' : number, - 'data' : [] | [string], - 'status_text' : string, - 'error_text' : [] | [string], -} -export interface Response_3 { - 'status' : number, - 'data' : [] | [Array], - 'status_text' : string, - 'error_text' : [] | [string], -} -export interface Response_4 { - 'status' : number, - 'data' : [] | [Employee], - 'status_text' : string, - 'error_text' : [] | [string], -} -export type Result = { 'ok' : string } | - { 'err' : string }; -export interface SchedulePaymentsArgs { - 'status' : { 'Paid' : null } | - { 'Rejected' : null } | - { 'Unpaid' : null } | - { 'Accepted' : null }, - 'created_at' : bigint, - 'receivers' : Array, - 'payment_at' : bigint, -} -export interface SchedulePaymentsErr { - 'kind' : { 'InvalidDetails' : null } | - { 'InvalidAmount' : null } | - { 'InvalidDestination' : null } | - { 'MaxTransactionsReached' : null } | - { 'InsufficientBalance' : null } | - { 'InvalidSender' : null } | - { 'Other' : null }, - 'message' : [] | [string], -} -export type SchedulePaymentsResult = { 'ok' : SchedulePaymentsSuccess } | - { 'err' : SchedulePaymentsErr }; -export interface SchedulePaymentsSuccess { 'receivers' : Array } -export type Subaccount = Uint8Array | number[]; -export interface Transaction { - 'id' : bigint, - 'creator' : Principal, - 'destination' : Principal, - 'created_at' : bigint, - 'amount' : bigint, - 'successful' : boolean, -} -export interface Transaction__1 { - 'id' : bigint, - 'creator' : Principal, - 'destination' : Principal, - 'created_at' : bigint, - 'amount' : bigint, - 'successful' : boolean, -} -export interface TransformArgs { - 'context' : Uint8Array | number[], - 'response' : HttpResponsePayload, -} -export interface User { - 'email_address' : string, - 'phone_notifications' : boolean, - 'name' : string, - 'email_notifications' : boolean, - 'phone_number' : string, -} -export interface _SERVICE extends Backend {} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/.dfx/local/canisters/backend/service.did.js b/.dfx/local/canisters/backend/service.did.js deleted file mode 100644 index 91f2a5a3..00000000 --- a/.dfx/local/canisters/backend/service.did.js +++ /dev/null @@ -1,327 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const AccountIdentifier = IDL.Variant({ - 'principal' : IDL.Principal, - 'blob' : IDL.Vec(IDL.Nat8), - 'text' : IDL.Text, - }); - const AccountIdentifierToBlobSuccess = IDL.Vec(IDL.Nat8); - const AccountIdentifierToBlobErr = IDL.Record({ - 'kind' : IDL.Variant({ - 'InvalidAccountIdentifier' : IDL.Null, - 'Other' : IDL.Null, - }), - 'message' : IDL.Opt(IDL.Text), - }); - const AccountIdentifierToBlobResult = IDL.Variant({ - 'ok' : AccountIdentifierToBlobSuccess, - 'err' : AccountIdentifierToBlobErr, - }); - const CreateEmployeeArgs = IDL.Record({ - 'emp_type' : IDL.Text, - 'wallet' : IDL.Text, - 'access_type' : IDL.Text, - }); - const Employee = IDL.Record({ - 'id' : IDL.Nat, - 'email_address' : IDL.Text, - 'emp_type' : IDL.Text, - 'creator' : IDL.Principal, - 'modified_at' : IDL.Int, - 'name' : IDL.Text, - 'created_at' : IDL.Int, - 'wallet' : IDL.Text, - 'phone_number' : IDL.Text, - 'access_type' : IDL.Text, - }); - const Response_4 = IDL.Record({ - 'status' : IDL.Nat16, - 'data' : IDL.Opt(Employee), - 'status_text' : IDL.Text, - 'error_text' : IDL.Opt(IDL.Text), - }); - const Subaccount = IDL.Vec(IDL.Nat8); - const Account = IDL.Record({ - 'owner' : IDL.Principal, - 'subaccount' : IDL.Opt(Subaccount), - }); - const Notification__1 = IDL.Record({ - 'id' : IDL.Nat, - 'isRead' : IDL.Bool, - 'sender' : IDL.Text, - 'amount' : IDL.Nat, - 'receiver' : IDL.Text, - }); - const User = IDL.Record({ - 'email_address' : IDL.Text, - 'phone_notifications' : IDL.Bool, - 'name' : IDL.Text, - 'email_notifications' : IDL.Bool, - 'phone_number' : IDL.Text, - }); - const Response = IDL.Record({ - 'status' : IDL.Nat16, - 'data' : IDL.Opt(User), - 'status_text' : IDL.Text, - 'error_text' : IDL.Opt(IDL.Text), - }); - const GetAccountIdentifierArgs = IDL.Record({ 'principal' : IDL.Principal }); - const GetAccountIdentifierSuccess = IDL.Record({ - 'accountIdentifier' : AccountIdentifier, - }); - const GetAccountIdentifierErr = IDL.Record({ 'message' : IDL.Opt(IDL.Text) }); - const GetAccountIdentifierResult = IDL.Variant({ - 'ok' : GetAccountIdentifierSuccess, - 'err' : GetAccountIdentifierErr, - }); - const GetTransactionArgs = IDL.Record({ 'id' : IDL.Nat }); - const Transaction__1 = IDL.Record({ - 'id' : IDL.Nat, - 'creator' : IDL.Principal, - 'destination' : IDL.Principal, - 'created_at' : IDL.Int, - 'amount' : IDL.Nat, - 'successful' : IDL.Bool, - }); - const GetTransactionSuccess = IDL.Record({ 'transaction' : Transaction__1 }); - const GetTransactionErr = IDL.Record({ - 'kind' : IDL.Variant({ - 'NotFound' : IDL.Null, - 'NotAuthorized' : IDL.Null, - 'Other' : IDL.Null, - 'InvalidTransactionId' : IDL.Null, - }), - 'message' : IDL.Opt(IDL.Text), - }); - const GetTransactionResult = IDL.Variant({ - 'ok' : GetTransactionSuccess, - 'err' : GetTransactionErr, - }); - const Transaction = IDL.Record({ - 'id' : IDL.Nat, - 'creator' : IDL.Principal, - 'destination' : IDL.Principal, - 'created_at' : IDL.Int, - 'amount' : IDL.Nat, - 'successful' : IDL.Bool, - }); - const PayrollType__1 = IDL.Record({ - 'id' : IDL.Nat, - 'creator' : IDL.Text, - 'destination' : IDL.Text, - 'created_at' : IDL.Int, - 'amount' : IDL.Nat, - 'successful' : IDL.Bool, - }); - const Response_3 = IDL.Record({ - 'status' : IDL.Nat16, - 'data' : IDL.Opt(IDL.Vec(PayrollType__1)), - 'status_text' : IDL.Text, - 'error_text' : IDL.Opt(IDL.Text), - }); - const CreateNotificationArgs = IDL.Record({ - 'isRead' : IDL.Bool, - 'sender' : IDL.Text, - 'amount' : IDL.Nat, - 'receiver' : IDL.Text, - }); - const Notification = IDL.Record({ - 'id' : IDL.Nat, - 'isRead' : IDL.Bool, - 'sender' : IDL.Text, - 'amount' : IDL.Nat, - 'receiver' : IDL.Text, - }); - const CreateNotificationSuccess = IDL.Record({ - 'notification' : Notification, - }); - const CreateNotificationErr = IDL.Record({ - 'kind' : IDL.Variant({ - 'InvalidNotification' : IDL.Null, - 'Other' : IDL.Null, - }), - 'message' : IDL.Opt(IDL.Text), - }); - const CreateNotificationResult = IDL.Variant({ - 'ok' : CreateNotificationSuccess, - 'err' : CreateNotificationErr, - }); - const PayrollType = IDL.Record({ - 'id' : IDL.Nat, - 'creator' : IDL.Text, - 'destination' : IDL.Text, - 'created_at' : IDL.Int, - 'amount' : IDL.Nat, - 'successful' : IDL.Bool, - }); - const SchedulePaymentsArgs = IDL.Record({ - 'status' : IDL.Variant({ - 'Paid' : IDL.Null, - 'Rejected' : IDL.Null, - 'Unpaid' : IDL.Null, - 'Accepted' : IDL.Null, - }), - 'created_at' : IDL.Int, - 'receivers' : IDL.Vec(PayrollType), - 'payment_at' : IDL.Int, - }); - const SchedulePaymentsSuccess = IDL.Record({ - 'receivers' : IDL.Vec(PayrollType), - }); - const SchedulePaymentsErr = IDL.Record({ - 'kind' : IDL.Variant({ - 'InvalidDetails' : IDL.Null, - 'InvalidAmount' : IDL.Null, - 'InvalidDestination' : IDL.Null, - 'MaxTransactionsReached' : IDL.Null, - 'InsufficientBalance' : IDL.Null, - 'InvalidSender' : IDL.Null, - 'Other' : IDL.Null, - }), - 'message' : IDL.Opt(IDL.Text), - }); - const SchedulePaymentsResult = IDL.Variant({ - 'ok' : SchedulePaymentsSuccess, - 'err' : SchedulePaymentsErr, - }); - const CreateTransactionArgs = IDL.Record({ - 'creator' : IDL.Principal, - 'destination' : IDL.Principal, - 'amount' : IDL.Nat, - 'successful' : IDL.Bool, - }); - const CreateTransactionSuccess = IDL.Record({ - 'transaction' : Transaction__1, - }); - const CreateTransactionErr = IDL.Record({ - 'kind' : IDL.Variant({ - 'InvalidDetails' : IDL.Null, - 'InvalidAmount' : IDL.Null, - 'InvalidDestination' : IDL.Null, - 'MaxTransactionsReached' : IDL.Null, - 'InsufficientBalance' : IDL.Null, - 'InvalidSender' : IDL.Null, - 'Other' : IDL.Null, - }), - 'message' : IDL.Opt(IDL.Text), - }); - const CreateTransactionResult = IDL.Variant({ - 'ok' : CreateTransactionSuccess, - 'err' : CreateTransactionErr, - }); - const Result = IDL.Variant({ 'ok' : IDL.Text, 'err' : IDL.Text }); - const Response_2 = IDL.Record({ - 'status' : IDL.Nat16, - 'data' : IDL.Opt(IDL.Text), - 'status_text' : IDL.Text, - 'error_text' : IDL.Opt(IDL.Text), - }); - const Response_1 = IDL.Record({ - 'status' : IDL.Nat16, - 'data' : IDL.Opt(Transaction), - 'status_text' : IDL.Text, - 'error_text' : IDL.Opt(IDL.Text), - }); - const HttpHeader = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text }); - const HttpResponsePayload = IDL.Record({ - 'status' : IDL.Nat, - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(HttpHeader), - }); - const TransformArgs = IDL.Record({ - 'context' : IDL.Vec(IDL.Nat8), - 'response' : HttpResponsePayload, - }); - const CanisterHttpResponsePayload = IDL.Record({ - 'status' : IDL.Nat, - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(HttpHeader), - }); - const Backend = IDL.Service({ - 'accountIdentifierToBlob' : IDL.Func( - [AccountIdentifier], - [AccountIdentifierToBlobResult], - [], - ), - 'cancelRecurringTimer' : IDL.Func([IDL.Nat], [], []), - 'checkPayroll' : IDL.Func([], [], []), - 'create_employee' : IDL.Func([CreateEmployeeArgs], [Response_4], []), - 'emailExists' : IDL.Func([IDL.Text], [IDL.Bool], ['query']), - 'getAddress' : IDL.Func([], [IDL.Text], []), - 'getCanisterAddress' : IDL.Func([], [IDL.Text], []), - 'getCanisterBalance' : IDL.Func([], [IDL.Text], []), - 'getEmployeeByPrincipal' : IDL.Func([IDL.Principal], [Response_4], []), - 'getFundingAddress' : IDL.Func([], [IDL.Text], []), - 'getFundingBalance' : IDL.Func([], [IDL.Text], []), - 'getInvoice' : IDL.Func([], [Account], []), - 'getLogs' : IDL.Func([], [IDL.Vec(IDL.Text)], ['query']), - 'getMyContacts' : IDL.Func([], [IDL.Vec(Employee)], []), - 'getMyContactsLength' : IDL.Func([], [IDL.Text], []), - 'getMyTransactionLength' : IDL.Func([], [IDL.Text], []), - 'getNotifications' : IDL.Func([], [IDL.Vec(Notification__1)], []), - 'getTradingAddress' : IDL.Func([], [IDL.Text], []), - 'getTradingBalance' : IDL.Func([], [IDL.Text], []), - 'getTransactionLength' : IDL.Func([], [IDL.Text], ['query']), - 'getUnreadNotifications' : IDL.Func([], [IDL.Vec(Notification__1)], []), - 'getUnreadNotificationsLength' : IDL.Func([], [IDL.Text], []), - 'getUser' : IDL.Func([], [Response], ['query']), - 'getUserByPrincipal' : IDL.Func([IDL.Principal], [Response], ['query']), - 'getUsersList' : IDL.Func( - [], - [IDL.Vec(IDL.Tuple(IDL.Text, User))], - ['query'], - ), - 'get_account_identifier' : IDL.Func( - [GetAccountIdentifierArgs], - [GetAccountIdentifierResult], - ['query'], - ), - 'get_transaction' : IDL.Func( - [GetTransactionArgs], - [GetTransactionResult], - ['query'], - ), - 'get_transactions' : IDL.Func([], [IDL.Vec(Transaction)], ['query']), - 'isRegistered' : IDL.Func([], [IDL.Bool], ['query']), - 'remove_employee' : IDL.Func([IDL.Text], [Response_4], []), - 'runpayroll' : IDL.Func([IDL.Vec(PayrollType__1)], [Response_3], []), - 'save_notification' : IDL.Func( - [CreateNotificationArgs], - [CreateNotificationResult], - [], - ), - 'save_payroll' : IDL.Func( - [SchedulePaymentsArgs], - [SchedulePaymentsResult], - [], - ), - 'save_transaction' : IDL.Func( - [CreateTransactionArgs], - [CreateTransactionResult], - [], - ), - 'sendToOwner' : IDL.Func([IDL.Nat, IDL.Text], [Result], []), - 'send_notifications' : IDL.Func( - [IDL.Text, IDL.Text, IDL.Text, IDL.Text, IDL.Text], - [], - [], - ), - 'setCourierApiKey' : IDL.Func([IDL.Text], [Response_2], []), - 'setRecurringTimer' : IDL.Func([IDL.Nat], [IDL.Nat], []), - 'transferFromCanistertoSubAccount' : IDL.Func([], [Result], []), - 'transferFromSubAccountToSubAccount' : IDL.Func( - [IDL.Text, IDL.Nat], - [Response_1], - [], - ), - 'transform' : IDL.Func( - [TransformArgs], - [CanisterHttpResponsePayload], - ['query'], - ), - 'updateUser' : IDL.Func([User], [Response], []), - 'userLength' : IDL.Func([], [IDL.Text], ['query']), - 'whoami' : IDL.Func([], [IDL.Principal], []), - }); - return Backend; -}; -export const init = ({ IDL }) => { return []; }; diff --git a/.dfx/local/canisters/ckbtc_ledger/ckbtc_ledger.wasm b/.dfx/local/canisters/ckbtc_ledger/ckbtc_ledger.wasm deleted file mode 100644 index 70ea396f..00000000 Binary files a/.dfx/local/canisters/ckbtc_ledger/ckbtc_ledger.wasm and /dev/null differ diff --git a/.dfx/local/canisters/ckbtc_ledger/constructor.did b/.dfx/local/canisters/ckbtc_ledger/constructor.did deleted file mode 100644 index ed129e46..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/constructor.did +++ /dev/null @@ -1,276 +0,0 @@ -type BlockIndex = nat; -type Subaccount = blob; -// Number of nanoseconds since the UNIX epoch in UTC timezone. -type Timestamp = nat64; -// Number of nanoseconds between two [Timestamp]s. -type Duration = nat64; -type Tokens = nat; -type TxIndex = nat; - -type Account = record { - owner : principal; - subaccount : opt Subaccount; -}; - -type TransferArg = record { - from_subaccount : opt Subaccount; - to : Account; - amount : Tokens; - fee : opt Tokens; - memo : opt blob; - created_at_time: opt Timestamp; -}; - -type TransferError = variant { - BadFee : record { expected_fee : Tokens }; - BadBurn : record { min_burn_amount : Tokens }; - InsufficientFunds : record { balance : Tokens }; - TooOld; - CreatedInFuture : record { ledger_time : nat64 }; - TemporarilyUnavailable; - Duplicate : record { duplicate_of : BlockIndex }; - GenericError : record { error_code : nat; message : text }; -}; - -type TransferResult = variant { - Ok : BlockIndex; - Err : TransferError; -}; - -// The value returned from the [icrc1_metadata] endpoint. -type MetadataValue = variant { - Nat : nat; - Int : int; - Text : text; - Blob : blob; -}; - -// The initialization parameters of the Ledger -type InitArgs = record { - minting_account : Account; - fee_collector_account : opt Account; - transfer_fee : nat64; - token_symbol : text; - token_name : text; - metadata : vec record { text; MetadataValue }; - initial_balances : vec record { Account; nat64 }; - archive_options : record { - num_blocks_to_archive : nat64; - trigger_threshold : nat64; - max_message_size_bytes : opt nat64; - cycles_for_archive_creation : opt nat64; - node_max_memory_size_bytes : opt nat64; - controller_id : principal; - }; -}; - -type ChangeFeeCollector = variant { - Unset; SetTo: Account; -}; - -type UpgradeArgs = record { - metadata : opt vec record { text; MetadataValue }; - token_symbol : opt text; - token_name : opt text; - transfer_fee : opt nat64; - change_fee_collector : opt ChangeFeeCollector; -}; - -type LedgerArg = variant { - Init: InitArgs; - Upgrade: opt UpgradeArgs; -}; - -type GetTransactionsRequest = record { - // The index of the first tx to fetch. - start : TxIndex; - // The number of transactions to fetch. - length : nat; -}; - -type GetTransactionsResponse = record { - // The total number of transactions in the log. - log_length : nat; - - // List of transaction that were available in the ledger when it processed the call. - // - // The transactions form a contiguous range, with the first transaction having index - // [first_index] (see below), and the last transaction having index - // [first_index] + len(transactions) - 1. - // - // The transaction range can be an arbitrary sub-range of the originally requested range. - transactions : vec Transaction; - - // The index of the first transaction in [transactions]. - // If the transaction vector is empty, the exact value of this field is not specified. - first_index : TxIndex; - - // Encoding of instructions for fetching archived transactions whose indices fall into the - // requested range. - // - // For each entry `e` in [archived_transactions], `[e.from, e.from + len)` is a sub-range - // of the originally requested transaction range. - archived_transactions : vec record { - // The index of the first archived transaction you can fetch using the [callback]. - start : TxIndex; - - // The number of transactions you can fetch using the callback. - length : nat; - - // The function you should call to fetch the archived transactions. - // The range of the transaction accessible using this function is given by [from] - // and [len] fields above. - callback : QueryArchiveFn; - }; -}; - - -// A prefix of the transaction range specified in the [GetTransactionsRequest] request. -type TransactionRange = record { - // A prefix of the requested transaction range. - // The index of the first transaction is equal to [GetTransactionsRequest.from]. - // - // Note that the number of transactions might be less than the requested - // [GetTransactionsRequest.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of transactions can be empty if: - // - // 1. [GetTransactionsRequest.length] was zero. - // 2. [GetTransactionsRequest.from] was larger than the last transaction known to - // the canister. - transactions : vec Transaction; -}; - -// A function for fetching archived transaction. -type QueryArchiveFn = func (GetTransactionsRequest) -> (TransactionRange) query; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type Value = variant { - Blob : blob; - Text : text; - Nat : nat; - Nat64: nat64; - Int : int; - Array : vec Value; - Map : Map; -}; - -type Map = vec record { text; Value }; - -type Block = Value; - -type GetBlocksArgs = record { - // The index of the first block to fetch. - start : BlockIndex; - // Max number of blocks to fetch. - length : nat; -}; - -// A prefix of the block range specified in the [GetBlocksArgs] request. -type BlockRange = record { - // A prefix of the requested block range. - // The index of the first block is equal to [GetBlocksArgs.start]. - // - // Note that the number of blocks might be less than the requested - // [GetBlocksArgs.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of blocks can be empty if: - // - // 1. [GetBlocksArgs.length] was zero. - // 2. [GetBlocksArgs.start] was larger than the last block known to - // the canister. - blocks : vec Block; -}; - -// A function for fetching archived blocks. -type QueryBlockArchiveFn = func (GetBlocksArgs) -> (BlockRange) query; - -// The result of a "get_blocks" call. -type GetBlocksResponse = record { - // The index of the first block in "blocks". - // If the blocks vector is empty, the exact value of this field is not specified. - first_index : BlockIndex; - - // The total number of blocks in the chain. - // If the chain length is positive, the index of the last block is `chain_len - 1`. - chain_length : nat64; - - // System certificate for the hash of the latest block in the chain. - // Only present if `get_blocks` is called in a non-replicated query context. - certificate : opt blob; - - // List of blocks that were available in the ledger when it processed the call. - // - // The blocks form a contiguous range, with the first block having index - // [first_block_index] (see below), and the last block having index - // [first_block_index] + len(blocks) - 1. - // - // The block range can be an arbitrary sub-range of the originally requested range. - blocks : vec Block; - - // Encoding of instructions for fetching archived blocks. - archived_blocks : vec record { - // The index of the first archived block. - start : BlockIndex; - - // The number of blocks that can be fetched. - length : nat; - - // Callback to fetch the archived blocks. - callback : QueryBlockArchiveFn; - }; -}; - -// Certificate for the block at `block_index`. -type DataCertificate = record { - certificate : opt blob; - hash_tree : blob; -}; - -service : { - icrc1_name : () -> (text) query; - icrc1_symbol : () -> (text) query; - icrc1_decimals : () -> (nat8) query; - icrc1_metadata : () -> (vec record { text; MetadataValue }) query; - icrc1_total_supply : () -> (Tokens) query; - icrc1_fee : () -> (Tokens) query; - icrc1_minting_account : () -> (opt Account) query; - icrc1_balance_of : (Account) -> (Tokens) query; - icrc1_transfer : (TransferArg) -> (TransferResult); - icrc1_supported_standards : () -> (vec record { name : text; url : text }) query; - get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query; - get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query; - get_data_certificate : () -> (DataCertificate) query; -} \ No newline at end of file diff --git a/.dfx/local/canisters/ckbtc_ledger/constructor.old.did b/.dfx/local/canisters/ckbtc_ledger/constructor.old.did deleted file mode 100644 index b615ed21..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/constructor.old.did +++ /dev/null @@ -1,276 +0,0 @@ -type BlockIndex = nat; -type Subaccount = blob; -// Number of nanoseconds since the UNIX epoch in UTC timezone. -type Timestamp = nat64; -// Number of nanoseconds between two [Timestamp]s. -type Duration = nat64; -type Tokens = nat; -type TxIndex = nat; - -type Account = record { - owner : principal; - subaccount : opt Subaccount; -}; - -type TransferArg = record { - from_subaccount : opt Subaccount; - to : Account; - amount : Tokens; - fee : opt Tokens; - memo : opt blob; - created_at_time: opt Timestamp; -}; - -type TransferError = variant { - BadFee : record { expected_fee : Tokens }; - BadBurn : record { min_burn_amount : Tokens }; - InsufficientFunds : record { balance : Tokens }; - TooOld; - CreatedInFuture : record { ledger_time : nat64 }; - TemporarilyUnavailable; - Duplicate : record { duplicate_of : BlockIndex }; - GenericError : record { error_code : nat; message : text }; -}; - -type TransferResult = variant { - Ok : BlockIndex; - Err : TransferError; -}; - -// The value returned from the [icrc1_metadata] endpoint. -type MetadataValue = variant { - Nat : nat; - Int : int; - Text : text; - Blob : blob; -}; - -// The initialization parameters of the Ledger -type InitArgs = record { - minting_account : Account; - fee_collector_account : opt Account; - transfer_fee : nat64; - token_symbol : text; - token_name : text; - metadata : vec record { text; MetadataValue }; - initial_balances : vec record { Account; nat64 }; - archive_options : record { - num_blocks_to_archive : nat64; - trigger_threshold : nat64; - max_message_size_bytes : opt nat64; - cycles_for_archive_creation : opt nat64; - node_max_memory_size_bytes : opt nat64; - controller_id : principal; - }; -}; - -type ChangeFeeCollector = variant { - Unset; SetTo: Account; -}; - -type UpgradeArgs = record { - metadata : opt vec record { text; MetadataValue }; - token_symbol : opt text; - token_name : opt text; - transfer_fee : opt nat64; - change_fee_collector : opt ChangeFeeCollector; -}; - -type LedgerArg = variant { - Init: InitArgs; - Upgrade: opt UpgradeArgs; -}; - -type GetTransactionsRequest = record { - // The index of the first tx to fetch. - start : TxIndex; - // The number of transactions to fetch. - length : nat; -}; - -type GetTransactionsResponse = record { - // The total number of transactions in the log. - log_length : nat; - - // List of transaction that were available in the ledger when it processed the call. - // - // The transactions form a contiguous range, with the first transaction having index - // [first_index] (see below), and the last transaction having index - // [first_index] + len(transactions) - 1. - // - // The transaction range can be an arbitrary sub-range of the originally requested range. - transactions : vec Transaction; - - // The index of the first transaction in [transactions]. - // If the transaction vector is empty, the exact value of this field is not specified. - first_index : TxIndex; - - // Encoding of instructions for fetching archived transactions whose indices fall into the - // requested range. - // - // For each entry `e` in [archived_transactions], `[e.from, e.from + len)` is a sub-range - // of the originally requested transaction range. - archived_transactions : vec record { - // The index of the first archived transaction you can fetch using the [callback]. - start : TxIndex; - - // The number of transactions you can fetch using the callback. - length : nat; - - // The function you should call to fetch the archived transactions. - // The range of the transaction accessible using this function is given by [from] - // and [len] fields above. - callback : QueryArchiveFn; - }; -}; - - -// A prefix of the transaction range specified in the [GetTransactionsRequest] request. -type TransactionRange = record { - // A prefix of the requested transaction range. - // The index of the first transaction is equal to [GetTransactionsRequest.from]. - // - // Note that the number of transactions might be less than the requested - // [GetTransactionsRequest.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of transactions can be empty if: - // - // 1. [GetTransactionsRequest.length] was zero. - // 2. [GetTransactionsRequest.from] was larger than the last transaction known to - // the canister. - transactions : vec Transaction; -}; - -// A function for fetching archived transaction. -type QueryArchiveFn = func (GetTransactionsRequest) -> (TransactionRange) query; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type Value = variant { - Blob : blob; - Text : text; - Nat : nat; - Nat64: nat64; - Int : int; - Array : vec Value; - Map : Map; -}; - -type Map = vec record { text; Value }; - -type Block = Value; - -type GetBlocksArgs = record { - // The index of the first block to fetch. - start : BlockIndex; - // Max number of blocks to fetch. - length : nat; -}; - -// A prefix of the block range specified in the [GetBlocksArgs] request. -type BlockRange = record { - // A prefix of the requested block range. - // The index of the first block is equal to [GetBlocksArgs.start]. - // - // Note that the number of blocks might be less than the requested - // [GetBlocksArgs.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of blocks can be empty if: - // - // 1. [GetBlocksArgs.length] was zero. - // 2. [GetBlocksArgs.start] was larger than the last block known to - // the canister. - blocks : vec Block; -}; - -// A function for fetching archived blocks. -type QueryBlockArchiveFn = func (GetBlocksArgs) -> (BlockRange) query; - -// The result of a "get_blocks" call. -type GetBlocksResponse = record { - // The index of the first block in "blocks". - // If the blocks vector is empty, the exact value of this field is not specified. - first_index : BlockIndex; - - // The total number of blocks in the chain. - // If the chain length is positive, the index of the last block is `chain_len - 1`. - chain_length : nat64; - - // System certificate for the hash of the latest block in the chain. - // Only present if `get_blocks` is called in a non-replicated query context. - certificate : opt blob; - - // List of blocks that were available in the ledger when it processed the call. - // - // The blocks form a contiguous range, with the first block having index - // [first_block_index] (see below), and the last block having index - // [first_block_index] + len(blocks) - 1. - // - // The block range can be an arbitrary sub-range of the originally requested range. - blocks : vec Block; - - // Encoding of instructions for fetching archived blocks. - archived_blocks : vec record { - // The index of the first archived block. - start : BlockIndex; - - // The number of blocks that can be fetched. - length : nat; - - // Callback to fetch the archived blocks. - callback : QueryBlockArchiveFn; - }; -}; - -// Certificate for the block at `block_index`. -type DataCertificate = record { - certificate : opt blob; - hash_tree : blob; -}; - -service : (ledger_arg : LedgerArg) -> { - icrc1_name : () -> (text) query; - icrc1_symbol : () -> (text) query; - icrc1_decimals : () -> (nat8) query; - icrc1_metadata : () -> (vec record { text; MetadataValue }) query; - icrc1_total_supply : () -> (Tokens) query; - icrc1_fee : () -> (Tokens) query; - icrc1_minting_account : () -> (opt Account) query; - icrc1_balance_of : (Account) -> (Tokens) query; - icrc1_transfer : (TransferArg) -> (TransferResult); - icrc1_supported_standards : () -> (vec record { name : text; url : text }) query; - get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query; - get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query; - get_data_certificate : () -> (DataCertificate) query; -} diff --git a/.dfx/local/canisters/ckbtc_ledger/index.js b/.dfx/local/canisters/ckbtc_ledger/index.js deleted file mode 100644 index 90183316..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from './ckbtc_ledger.did.js'; -export { idlFactory } from './ckbtc_ledger.did.js'; -// CANISTER_ID is replaced by webpack based on node environment -export const canisterId = process.env.CKBTC_LEDGER_CANISTER_ID; - -/** - * @deprecated since dfx 0.11.1 - * Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface. - * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent - * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options] - * @return {import("@dfinity/agent").ActorSubclass} - */ -export const createActor = (canisterId, options = {}) => { - console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings. - -See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`); - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - // 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 ? options.actorOptions : {}), - }); -}; - -/** - * A ready-to-use agent for the ckbtc_ledger canister - * @type {import("@dfinity/agent").ActorSubclass} - */ -export const ckbtc_ledger = createActor(canisterId); diff --git a/.dfx/local/canisters/ckbtc_ledger/init_args.txt b/.dfx/local/canisters/ckbtc_ledger/init_args.txt deleted file mode 100644 index dd626a0f..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/init_args.txt +++ /dev/null @@ -1 +0,0 @@ -() \ No newline at end of file diff --git a/.dfx/local/canisters/ckbtc_ledger/service.did b/.dfx/local/canisters/ckbtc_ledger/service.did deleted file mode 100644 index ed129e46..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/service.did +++ /dev/null @@ -1,276 +0,0 @@ -type BlockIndex = nat; -type Subaccount = blob; -// Number of nanoseconds since the UNIX epoch in UTC timezone. -type Timestamp = nat64; -// Number of nanoseconds between two [Timestamp]s. -type Duration = nat64; -type Tokens = nat; -type TxIndex = nat; - -type Account = record { - owner : principal; - subaccount : opt Subaccount; -}; - -type TransferArg = record { - from_subaccount : opt Subaccount; - to : Account; - amount : Tokens; - fee : opt Tokens; - memo : opt blob; - created_at_time: opt Timestamp; -}; - -type TransferError = variant { - BadFee : record { expected_fee : Tokens }; - BadBurn : record { min_burn_amount : Tokens }; - InsufficientFunds : record { balance : Tokens }; - TooOld; - CreatedInFuture : record { ledger_time : nat64 }; - TemporarilyUnavailable; - Duplicate : record { duplicate_of : BlockIndex }; - GenericError : record { error_code : nat; message : text }; -}; - -type TransferResult = variant { - Ok : BlockIndex; - Err : TransferError; -}; - -// The value returned from the [icrc1_metadata] endpoint. -type MetadataValue = variant { - Nat : nat; - Int : int; - Text : text; - Blob : blob; -}; - -// The initialization parameters of the Ledger -type InitArgs = record { - minting_account : Account; - fee_collector_account : opt Account; - transfer_fee : nat64; - token_symbol : text; - token_name : text; - metadata : vec record { text; MetadataValue }; - initial_balances : vec record { Account; nat64 }; - archive_options : record { - num_blocks_to_archive : nat64; - trigger_threshold : nat64; - max_message_size_bytes : opt nat64; - cycles_for_archive_creation : opt nat64; - node_max_memory_size_bytes : opt nat64; - controller_id : principal; - }; -}; - -type ChangeFeeCollector = variant { - Unset; SetTo: Account; -}; - -type UpgradeArgs = record { - metadata : opt vec record { text; MetadataValue }; - token_symbol : opt text; - token_name : opt text; - transfer_fee : opt nat64; - change_fee_collector : opt ChangeFeeCollector; -}; - -type LedgerArg = variant { - Init: InitArgs; - Upgrade: opt UpgradeArgs; -}; - -type GetTransactionsRequest = record { - // The index of the first tx to fetch. - start : TxIndex; - // The number of transactions to fetch. - length : nat; -}; - -type GetTransactionsResponse = record { - // The total number of transactions in the log. - log_length : nat; - - // List of transaction that were available in the ledger when it processed the call. - // - // The transactions form a contiguous range, with the first transaction having index - // [first_index] (see below), and the last transaction having index - // [first_index] + len(transactions) - 1. - // - // The transaction range can be an arbitrary sub-range of the originally requested range. - transactions : vec Transaction; - - // The index of the first transaction in [transactions]. - // If the transaction vector is empty, the exact value of this field is not specified. - first_index : TxIndex; - - // Encoding of instructions for fetching archived transactions whose indices fall into the - // requested range. - // - // For each entry `e` in [archived_transactions], `[e.from, e.from + len)` is a sub-range - // of the originally requested transaction range. - archived_transactions : vec record { - // The index of the first archived transaction you can fetch using the [callback]. - start : TxIndex; - - // The number of transactions you can fetch using the callback. - length : nat; - - // The function you should call to fetch the archived transactions. - // The range of the transaction accessible using this function is given by [from] - // and [len] fields above. - callback : QueryArchiveFn; - }; -}; - - -// A prefix of the transaction range specified in the [GetTransactionsRequest] request. -type TransactionRange = record { - // A prefix of the requested transaction range. - // The index of the first transaction is equal to [GetTransactionsRequest.from]. - // - // Note that the number of transactions might be less than the requested - // [GetTransactionsRequest.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of transactions can be empty if: - // - // 1. [GetTransactionsRequest.length] was zero. - // 2. [GetTransactionsRequest.from] was larger than the last transaction known to - // the canister. - transactions : vec Transaction; -}; - -// A function for fetching archived transaction. -type QueryArchiveFn = func (GetTransactionsRequest) -> (TransactionRange) query; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type Value = variant { - Blob : blob; - Text : text; - Nat : nat; - Nat64: nat64; - Int : int; - Array : vec Value; - Map : Map; -}; - -type Map = vec record { text; Value }; - -type Block = Value; - -type GetBlocksArgs = record { - // The index of the first block to fetch. - start : BlockIndex; - // Max number of blocks to fetch. - length : nat; -}; - -// A prefix of the block range specified in the [GetBlocksArgs] request. -type BlockRange = record { - // A prefix of the requested block range. - // The index of the first block is equal to [GetBlocksArgs.start]. - // - // Note that the number of blocks might be less than the requested - // [GetBlocksArgs.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of blocks can be empty if: - // - // 1. [GetBlocksArgs.length] was zero. - // 2. [GetBlocksArgs.start] was larger than the last block known to - // the canister. - blocks : vec Block; -}; - -// A function for fetching archived blocks. -type QueryBlockArchiveFn = func (GetBlocksArgs) -> (BlockRange) query; - -// The result of a "get_blocks" call. -type GetBlocksResponse = record { - // The index of the first block in "blocks". - // If the blocks vector is empty, the exact value of this field is not specified. - first_index : BlockIndex; - - // The total number of blocks in the chain. - // If the chain length is positive, the index of the last block is `chain_len - 1`. - chain_length : nat64; - - // System certificate for the hash of the latest block in the chain. - // Only present if `get_blocks` is called in a non-replicated query context. - certificate : opt blob; - - // List of blocks that were available in the ledger when it processed the call. - // - // The blocks form a contiguous range, with the first block having index - // [first_block_index] (see below), and the last block having index - // [first_block_index] + len(blocks) - 1. - // - // The block range can be an arbitrary sub-range of the originally requested range. - blocks : vec Block; - - // Encoding of instructions for fetching archived blocks. - archived_blocks : vec record { - // The index of the first archived block. - start : BlockIndex; - - // The number of blocks that can be fetched. - length : nat; - - // Callback to fetch the archived blocks. - callback : QueryBlockArchiveFn; - }; -}; - -// Certificate for the block at `block_index`. -type DataCertificate = record { - certificate : opt blob; - hash_tree : blob; -}; - -service : { - icrc1_name : () -> (text) query; - icrc1_symbol : () -> (text) query; - icrc1_decimals : () -> (nat8) query; - icrc1_metadata : () -> (vec record { text; MetadataValue }) query; - icrc1_total_supply : () -> (Tokens) query; - icrc1_fee : () -> (Tokens) query; - icrc1_minting_account : () -> (opt Account) query; - icrc1_balance_of : (Account) -> (Tokens) query; - icrc1_transfer : (TransferArg) -> (TransferResult); - icrc1_supported_standards : () -> (vec record { name : text; url : text }) query; - get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query; - get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query; - get_data_certificate : () -> (DataCertificate) query; -} \ No newline at end of file diff --git a/.dfx/local/canisters/ckbtc_ledger/service.did.d.ts b/.dfx/local/canisters/ckbtc_ledger/service.did.d.ts deleted file mode 100644 index 78cadf80..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/service.did.d.ts +++ /dev/null @@ -1,162 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export interface Account { - 'owner' : Principal, - 'subaccount' : [] | [Subaccount], -} -export type Block = Value; -export type BlockIndex = bigint; -export interface BlockRange { 'blocks' : Array } -export type ChangeFeeCollector = { 'SetTo' : Account } | - { 'Unset' : null }; -export interface DataCertificate { - 'certificate' : [] | [Uint8Array | number[]], - 'hash_tree' : Uint8Array | number[], -} -export type Duration = bigint; -export interface GetBlocksArgs { 'start' : BlockIndex, 'length' : bigint } -export interface GetBlocksResponse { - 'certificate' : [] | [Uint8Array | number[]], - 'first_index' : BlockIndex, - 'blocks' : Array, - 'chain_length' : bigint, - 'archived_blocks' : Array< - { - 'callback' : QueryBlockArchiveFn, - 'start' : BlockIndex, - 'length' : bigint, - } - >, -} -export interface GetTransactionsRequest { 'start' : TxIndex, 'length' : bigint } -export interface GetTransactionsResponse { - 'first_index' : TxIndex, - 'log_length' : bigint, - 'transactions' : Array, - 'archived_transactions' : Array< - { 'callback' : QueryArchiveFn, 'start' : TxIndex, 'length' : bigint } - >, -} -export interface InitArgs { - 'token_symbol' : string, - 'transfer_fee' : bigint, - 'metadata' : Array<[string, MetadataValue]>, - 'minting_account' : Account, - 'initial_balances' : Array<[Account, bigint]>, - 'fee_collector_account' : [] | [Account], - 'archive_options' : { - 'num_blocks_to_archive' : bigint, - 'trigger_threshold' : bigint, - 'max_message_size_bytes' : [] | [bigint], - 'cycles_for_archive_creation' : [] | [bigint], - 'node_max_memory_size_bytes' : [] | [bigint], - 'controller_id' : Principal, - }, - 'token_name' : string, -} -export type LedgerArg = { 'Upgrade' : [] | [UpgradeArgs] } | - { 'Init' : InitArgs }; -export type Map = Array<[string, Value]>; -export type MetadataValue = { 'Int' : bigint } | - { 'Nat' : bigint } | - { 'Blob' : Uint8Array | number[] } | - { 'Text' : string }; -export type QueryArchiveFn = ActorMethod< - [GetTransactionsRequest], - TransactionRange ->; -export type QueryBlockArchiveFn = ActorMethod<[GetBlocksArgs], BlockRange>; -export type Subaccount = Uint8Array | number[]; -export type Timestamp = bigint; -export type Tokens = bigint; -export interface Transaction { - 'burn' : [] | [ - { - 'from' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - } - ], - 'kind' : string, - 'mint' : [] | [ - { - 'to' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - } - ], - 'timestamp' : bigint, - 'transfer' : [] | [ - { - 'to' : Account, - 'fee' : [] | [bigint], - 'from' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - } - ], -} -export interface TransactionRange { 'transactions' : Array } -export interface TransferArg { - 'to' : Account, - 'fee' : [] | [Tokens], - 'memo' : [] | [Uint8Array | number[]], - 'from_subaccount' : [] | [Subaccount], - 'created_at_time' : [] | [Timestamp], - 'amount' : Tokens, -} -export type TransferError = { - 'GenericError' : { 'message' : string, 'error_code' : bigint } - } | - { 'TemporarilyUnavailable' : null } | - { 'BadBurn' : { 'min_burn_amount' : Tokens } } | - { 'Duplicate' : { 'duplicate_of' : BlockIndex } } | - { 'BadFee' : { 'expected_fee' : Tokens } } | - { 'CreatedInFuture' : { 'ledger_time' : bigint } } | - { 'TooOld' : null } | - { 'InsufficientFunds' : { 'balance' : Tokens } }; -export type TransferResult = { 'Ok' : BlockIndex } | - { 'Err' : TransferError }; -export type TxIndex = bigint; -export interface UpgradeArgs { - 'token_symbol' : [] | [string], - 'transfer_fee' : [] | [bigint], - 'metadata' : [] | [Array<[string, MetadataValue]>], - 'change_fee_collector' : [] | [ChangeFeeCollector], - 'token_name' : [] | [string], -} -export type Value = { 'Int' : bigint } | - { 'Map' : Map } | - { 'Nat' : bigint } | - { 'Nat64' : bigint } | - { 'Blob' : Uint8Array | number[] } | - { 'Text' : string } | - { 'Array' : Array }; -export interface _SERVICE { - 'get_blocks' : ActorMethod<[GetBlocksArgs], GetBlocksResponse>, - 'get_data_certificate' : ActorMethod<[], DataCertificate>, - 'get_transactions' : ActorMethod< - [GetTransactionsRequest], - GetTransactionsResponse - >, - 'icrc1_balance_of' : ActorMethod<[Account], Tokens>, - 'icrc1_decimals' : ActorMethod<[], number>, - 'icrc1_fee' : ActorMethod<[], Tokens>, - 'icrc1_metadata' : ActorMethod<[], Array<[string, MetadataValue]>>, - 'icrc1_minting_account' : ActorMethod<[], [] | [Account]>, - 'icrc1_name' : ActorMethod<[], string>, - 'icrc1_supported_standards' : ActorMethod< - [], - Array<{ 'url' : string, 'name' : string }> - >, - 'icrc1_symbol' : ActorMethod<[], string>, - 'icrc1_total_supply' : ActorMethod<[], Tokens>, - 'icrc1_transfer' : ActorMethod<[TransferArg], TransferResult>, -} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/.dfx/local/canisters/ckbtc_ledger/service.did.js b/.dfx/local/canisters/ckbtc_ledger/service.did.js deleted file mode 100644 index 2f333ed2..00000000 --- a/.dfx/local/canisters/ckbtc_ledger/service.did.js +++ /dev/null @@ -1,165 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const Value = IDL.Rec(); - const BlockIndex = IDL.Nat; - const GetBlocksArgs = IDL.Record({ - 'start' : BlockIndex, - 'length' : IDL.Nat, - }); - const Map = IDL.Vec(IDL.Tuple(IDL.Text, Value)); - Value.fill( - IDL.Variant({ - 'Int' : IDL.Int, - 'Map' : Map, - 'Nat' : IDL.Nat, - 'Nat64' : IDL.Nat64, - 'Blob' : IDL.Vec(IDL.Nat8), - 'Text' : IDL.Text, - 'Array' : IDL.Vec(Value), - }) - ); - const Block = Value; - const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) }); - const QueryBlockArchiveFn = IDL.Func( - [GetBlocksArgs], - [BlockRange], - ['query'], - ); - const GetBlocksResponse = IDL.Record({ - 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'first_index' : BlockIndex, - 'blocks' : IDL.Vec(Block), - 'chain_length' : IDL.Nat64, - 'archived_blocks' : IDL.Vec( - IDL.Record({ - 'callback' : QueryBlockArchiveFn, - 'start' : BlockIndex, - 'length' : IDL.Nat, - }) - ), - }); - const DataCertificate = IDL.Record({ - 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'hash_tree' : IDL.Vec(IDL.Nat8), - }); - const TxIndex = IDL.Nat; - const GetTransactionsRequest = IDL.Record({ - 'start' : TxIndex, - 'length' : IDL.Nat, - }); - const Subaccount = IDL.Vec(IDL.Nat8); - const Account = IDL.Record({ - 'owner' : IDL.Principal, - 'subaccount' : IDL.Opt(Subaccount), - }); - const Transaction = IDL.Record({ - 'burn' : IDL.Opt( - IDL.Record({ - 'from' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - }) - ), - 'kind' : IDL.Text, - 'mint' : IDL.Opt( - IDL.Record({ - 'to' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - }) - ), - 'timestamp' : IDL.Nat64, - 'transfer' : IDL.Opt( - IDL.Record({ - 'to' : Account, - 'fee' : IDL.Opt(IDL.Nat), - 'from' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - }) - ), - }); - const TransactionRange = IDL.Record({ - 'transactions' : IDL.Vec(Transaction), - }); - const QueryArchiveFn = IDL.Func( - [GetTransactionsRequest], - [TransactionRange], - ['query'], - ); - const GetTransactionsResponse = IDL.Record({ - 'first_index' : TxIndex, - 'log_length' : IDL.Nat, - 'transactions' : IDL.Vec(Transaction), - 'archived_transactions' : IDL.Vec( - IDL.Record({ - 'callback' : QueryArchiveFn, - 'start' : TxIndex, - 'length' : IDL.Nat, - }) - ), - }); - const Tokens = IDL.Nat; - const MetadataValue = IDL.Variant({ - 'Int' : IDL.Int, - 'Nat' : IDL.Nat, - 'Blob' : IDL.Vec(IDL.Nat8), - 'Text' : IDL.Text, - }); - const Timestamp = IDL.Nat64; - const TransferArg = IDL.Record({ - 'to' : Account, - 'fee' : IDL.Opt(Tokens), - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'from_subaccount' : IDL.Opt(Subaccount), - 'created_at_time' : IDL.Opt(Timestamp), - 'amount' : Tokens, - }); - const TransferError = IDL.Variant({ - 'GenericError' : IDL.Record({ - 'message' : IDL.Text, - 'error_code' : IDL.Nat, - }), - 'TemporarilyUnavailable' : IDL.Null, - 'BadBurn' : IDL.Record({ 'min_burn_amount' : Tokens }), - 'Duplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }), - 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }), - 'CreatedInFuture' : IDL.Record({ 'ledger_time' : IDL.Nat64 }), - 'TooOld' : IDL.Null, - 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }), - }); - const TransferResult = IDL.Variant({ - 'Ok' : BlockIndex, - 'Err' : TransferError, - }); - return IDL.Service({ - 'get_blocks' : IDL.Func([GetBlocksArgs], [GetBlocksResponse], ['query']), - 'get_data_certificate' : IDL.Func([], [DataCertificate], ['query']), - 'get_transactions' : IDL.Func( - [GetTransactionsRequest], - [GetTransactionsResponse], - ['query'], - ), - 'icrc1_balance_of' : IDL.Func([Account], [Tokens], ['query']), - 'icrc1_decimals' : IDL.Func([], [IDL.Nat8], ['query']), - 'icrc1_fee' : IDL.Func([], [Tokens], ['query']), - 'icrc1_metadata' : IDL.Func( - [], - [IDL.Vec(IDL.Tuple(IDL.Text, MetadataValue))], - ['query'], - ), - 'icrc1_minting_account' : IDL.Func([], [IDL.Opt(Account)], ['query']), - 'icrc1_name' : IDL.Func([], [IDL.Text], ['query']), - 'icrc1_supported_standards' : IDL.Func( - [], - [IDL.Vec(IDL.Record({ 'url' : IDL.Text, 'name' : IDL.Text }))], - ['query'], - ), - 'icrc1_symbol' : IDL.Func([], [IDL.Text], ['query']), - 'icrc1_total_supply' : IDL.Func([], [Tokens], ['query']), - 'icrc1_transfer' : IDL.Func([TransferArg], [TransferResult], []), - }); -}; -export const init = ({ IDL }) => { return []; }; diff --git a/.dfx/local/canisters/icrc1_index/constructor.did b/.dfx/local/canisters/icrc1_index/constructor.did deleted file mode 100644 index 5df93c6c..00000000 --- a/.dfx/local/canisters/icrc1_index/constructor.did +++ /dev/null @@ -1,88 +0,0 @@ -type TxId = nat; - -type Account = record { owner : principal; subaccount : opt blob }; - -type SubAccount = blob; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - spender : opt Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - spender : opt Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - approve : opt record { - amount : nat; - from : Account; - spender : opt Account; - expected_allowance : opt nat; - expires_at : opt nat64; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type GetAccountTransactionsArgs = record { - account : Account; - // The txid of the last transaction seen by the client. - // If None then the results will start from the most recent - // txid. - start : opt TxId; - // Maximum number of transactions to fetch. - max_results : nat; -}; - -type TransactionWithId = record { - id : TxId; - transaction : Transaction; -}; - -type GetTransactions = record { - transactions : vec TransactionWithId; - // The txid of the oldest transaction the account has - oldest_tx_id : opt TxId; -}; - -type GetTransactionsErr = record { - message : text; -}; - -type GetTransactionsResult = variant { - Ok : GetTransactions; - Err : GetTransactionsErr; -}; - -type ListSubaccountsArgs = record { - owner: principal; - start: opt SubAccount; -}; - -// The initialization parameters of the Index canister. -type InitArgs = record { - ledger_id : principal; -}; - -service : (InitArgs) -> { - get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult); - ledger_id : () -> (principal) query; - list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query; -} diff --git a/.dfx/local/canisters/icrc1_index/download-ic-icrc1-index.wasm.gz b/.dfx/local/canisters/icrc1_index/download-ic-icrc1-index.wasm.gz deleted file mode 100644 index 4a5ce2fe..00000000 Binary files a/.dfx/local/canisters/icrc1_index/download-ic-icrc1-index.wasm.gz and /dev/null differ diff --git a/.dfx/local/canisters/icrc1_index/icrc1_index.did b/.dfx/local/canisters/icrc1_index/icrc1_index.did deleted file mode 100644 index 5df93c6c..00000000 --- a/.dfx/local/canisters/icrc1_index/icrc1_index.did +++ /dev/null @@ -1,88 +0,0 @@ -type TxId = nat; - -type Account = record { owner : principal; subaccount : opt blob }; - -type SubAccount = blob; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - spender : opt Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - spender : opt Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - approve : opt record { - amount : nat; - from : Account; - spender : opt Account; - expected_allowance : opt nat; - expires_at : opt nat64; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type GetAccountTransactionsArgs = record { - account : Account; - // The txid of the last transaction seen by the client. - // If None then the results will start from the most recent - // txid. - start : opt TxId; - // Maximum number of transactions to fetch. - max_results : nat; -}; - -type TransactionWithId = record { - id : TxId; - transaction : Transaction; -}; - -type GetTransactions = record { - transactions : vec TransactionWithId; - // The txid of the oldest transaction the account has - oldest_tx_id : opt TxId; -}; - -type GetTransactionsErr = record { - message : text; -}; - -type GetTransactionsResult = variant { - Ok : GetTransactions; - Err : GetTransactionsErr; -}; - -type ListSubaccountsArgs = record { - owner: principal; - start: opt SubAccount; -}; - -// The initialization parameters of the Index canister. -type InitArgs = record { - ledger_id : principal; -}; - -service : (InitArgs) -> { - get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult); - ledger_id : () -> (principal) query; - list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query; -} diff --git a/.dfx/local/canisters/icrc1_index/icrc1_index.wasm.gz b/.dfx/local/canisters/icrc1_index/icrc1_index.wasm.gz deleted file mode 100644 index 4a5ce2fe..00000000 Binary files a/.dfx/local/canisters/icrc1_index/icrc1_index.wasm.gz and /dev/null differ diff --git a/.dfx/local/canisters/icrc1_index/index.js b/.dfx/local/canisters/icrc1_index/index.js deleted file mode 100644 index dd5ee128..00000000 --- a/.dfx/local/canisters/icrc1_index/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from './icrc1_index.did.js'; -export { idlFactory } from './icrc1_index.did.js'; -// CANISTER_ID is replaced by webpack based on node environment -export const canisterId = process.env.ICRC1_INDEX_CANISTER_ID; - -/** - * @deprecated since dfx 0.11.1 - * Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface. - * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent - * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options] - * @return {import("@dfinity/agent").ActorSubclass} - */ -export const createActor = (canisterId, options = {}) => { - console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings. - -See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`); - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - // 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 ? options.actorOptions : {}), - }); -}; - -/** - * A ready-to-use agent for the icrc1_index canister - * @type {import("@dfinity/agent").ActorSubclass} - */ -export const icrc1_index = createActor(canisterId); diff --git a/.dfx/local/canisters/icrc1_index/init_args.txt b/.dfx/local/canisters/icrc1_index/init_args.txt deleted file mode 100644 index 7ab5312c..00000000 --- a/.dfx/local/canisters/icrc1_index/init_args.txt +++ /dev/null @@ -1 +0,0 @@ -(InitArgs) \ No newline at end of file diff --git a/.dfx/local/canisters/icrc1_index/service.did b/.dfx/local/canisters/icrc1_index/service.did deleted file mode 100644 index 629e178b..00000000 --- a/.dfx/local/canisters/icrc1_index/service.did +++ /dev/null @@ -1,63 +0,0 @@ -type Account = record { owner : principal; subaccount : opt vec nat8 }; -type GetAccountTransactionsArgs = record { - max_results : nat; - start : opt TxId; - account : Account; -}; -type GetTransactions = record { - transactions : vec TransactionWithId; - oldest_tx_id : opt TxId; -}; -type GetTransactionsErr = record { message : text }; -type GetTransactionsResult = variant { - Ok : GetTransactions; - Err : GetTransactionsErr; -}; -type InitArgs = record { ledger_id : principal }; -type ListSubaccountsArgs = record { owner : principal; start : opt SubAccount }; -type SubAccount = vec nat8; -type Transaction = record { - burn : opt record { - from : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - spender : opt Account; - }; - kind : text; - mint : opt record { - to : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - }; - approve : opt record { - fee : opt nat; - from : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - expected_allowance : opt nat; - expires_at : opt nat64; - spender : opt Account; - }; - timestamp : nat64; - transfer : opt record { - to : Account; - fee : opt nat; - from : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - spender : opt Account; - }; -}; -type TransactionWithId = record { id : TxId; transaction : Transaction }; -type TxId = nat; -service : { - get_account_transactions : (GetAccountTransactionsArgs) -> ( - GetTransactionsResult, - ); - ledger_id : () -> (principal) query; - list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query; -} \ No newline at end of file diff --git a/.dfx/local/canisters/icrc1_index/service.did.d.ts b/.dfx/local/canisters/icrc1_index/service.did.d.ts deleted file mode 100644 index 09569f40..00000000 --- a/.dfx/local/canisters/icrc1_index/service.did.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export interface Account { - 'owner' : Principal, - 'subaccount' : [] | [Uint8Array | number[]], -} -export interface GetAccountTransactionsArgs { - 'max_results' : bigint, - 'start' : [] | [TxId], - 'account' : Account, -} -export interface GetTransactions { - 'transactions' : Array, - 'oldest_tx_id' : [] | [TxId], -} -export interface GetTransactionsErr { 'message' : string } -export type GetTransactionsResult = { 'Ok' : GetTransactions } | - { 'Err' : GetTransactionsErr }; -export interface InitArgs { 'ledger_id' : Principal } -export interface ListSubaccountsArgs { - 'owner' : Principal, - 'start' : [] | [SubAccount], -} -export type SubAccount = Uint8Array | number[]; -export interface Transaction { - 'burn' : [] | [ - { - 'from' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - 'spender' : [] | [Account], - } - ], - 'kind' : string, - 'mint' : [] | [ - { - 'to' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - } - ], - 'approve' : [] | [ - { - 'fee' : [] | [bigint], - 'from' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - 'expected_allowance' : [] | [bigint], - 'expires_at' : [] | [bigint], - 'spender' : [] | [Account], - } - ], - 'timestamp' : bigint, - 'transfer' : [] | [ - { - 'to' : Account, - 'fee' : [] | [bigint], - 'from' : Account, - 'memo' : [] | [Uint8Array | number[]], - 'created_at_time' : [] | [bigint], - 'amount' : bigint, - 'spender' : [] | [Account], - } - ], -} -export interface TransactionWithId { 'id' : TxId, 'transaction' : Transaction } -export type TxId = bigint; -export interface _SERVICE { - 'get_account_transactions' : ActorMethod< - [GetAccountTransactionsArgs], - GetTransactionsResult - >, - 'ledger_id' : ActorMethod<[], Principal>, - 'list_subaccounts' : ActorMethod<[ListSubaccountsArgs], Array>, -} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/.dfx/local/canisters/icrc1_index/service.did.js b/.dfx/local/canisters/icrc1_index/service.did.js deleted file mode 100644 index 5c569361..00000000 --- a/.dfx/local/canisters/icrc1_index/service.did.js +++ /dev/null @@ -1,88 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const TxId = IDL.Nat; - const Account = IDL.Record({ - 'owner' : IDL.Principal, - 'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)), - }); - const GetAccountTransactionsArgs = IDL.Record({ - 'max_results' : IDL.Nat, - 'start' : IDL.Opt(TxId), - 'account' : Account, - }); - const Transaction = IDL.Record({ - 'burn' : IDL.Opt( - IDL.Record({ - 'from' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - 'spender' : IDL.Opt(Account), - }) - ), - 'kind' : IDL.Text, - 'mint' : IDL.Opt( - IDL.Record({ - 'to' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - }) - ), - 'approve' : IDL.Opt( - IDL.Record({ - 'fee' : IDL.Opt(IDL.Nat), - 'from' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - 'expected_allowance' : IDL.Opt(IDL.Nat), - 'expires_at' : IDL.Opt(IDL.Nat64), - 'spender' : IDL.Opt(Account), - }) - ), - 'timestamp' : IDL.Nat64, - 'transfer' : IDL.Opt( - IDL.Record({ - 'to' : Account, - 'fee' : IDL.Opt(IDL.Nat), - 'from' : Account, - 'memo' : IDL.Opt(IDL.Vec(IDL.Nat8)), - 'created_at_time' : IDL.Opt(IDL.Nat64), - 'amount' : IDL.Nat, - 'spender' : IDL.Opt(Account), - }) - ), - }); - const TransactionWithId = IDL.Record({ - 'id' : TxId, - 'transaction' : Transaction, - }); - const GetTransactions = IDL.Record({ - 'transactions' : IDL.Vec(TransactionWithId), - 'oldest_tx_id' : IDL.Opt(TxId), - }); - const GetTransactionsErr = IDL.Record({ 'message' : IDL.Text }); - const GetTransactionsResult = IDL.Variant({ - 'Ok' : GetTransactions, - 'Err' : GetTransactionsErr, - }); - const SubAccount = IDL.Vec(IDL.Nat8); - const ListSubaccountsArgs = IDL.Record({ - 'owner' : IDL.Principal, - 'start' : IDL.Opt(SubAccount), - }); - return IDL.Service({ - 'get_account_transactions' : IDL.Func( - [GetAccountTransactionsArgs], - [GetTransactionsResult], - [], - ), - 'ledger_id' : IDL.Func([], [IDL.Principal], ['query']), - 'list_subaccounts' : IDL.Func( - [ListSubaccountsArgs], - [IDL.Vec(SubAccount)], - ['query'], - ), - }); -}; -export const init = ({ IDL }) => { return []; }; diff --git a/.dfx/local/canisters/internet_identity/constructor.did b/.dfx/local/canisters/internet_identity/constructor.did deleted file mode 100644 index dd464712..00000000 --- a/.dfx/local/canisters/internet_identity/constructor.did +++ /dev/null @@ -1,620 +0,0 @@ -type UserNumber = nat64; -type PublicKey = blob; -type CredentialId = blob; -type DeviceKey = PublicKey; -type UserKey = PublicKey; -type SessionKey = PublicKey; -type FrontendHostname = text; -type Timestamp = nat64; - -type HeaderField = record { - text; - text; -}; - -type HttpRequest = record { - method: text; - url: text; - headers: vec HeaderField; - body: blob; - certificate_version: opt nat16; -}; - -type HttpResponse = record { - status_code: nat16; - headers: vec HeaderField; - body: blob; - upgrade : opt bool; - streaming_strategy: opt StreamingStrategy; -}; - -type StreamingCallbackHttpResponse = record { - body: blob; - token: opt Token; -}; - -type Token = record {}; - -type StreamingStrategy = variant { - Callback: record { - callback: func (Token) -> (StreamingCallbackHttpResponse) query; - token: Token; - }; -}; - -type Purpose = variant { - recovery; - authentication; -}; - -type KeyType = variant { - unknown; - platform; - cross_platform; - seed_phrase; - browser_storage_key; -}; - -// This describes whether a device is "protected" or not. -// When protected, a device can only be updated or removed if the -// user is authenticated with that very device. -type DeviceProtection = variant { - protected; - unprotected; -}; - -type Challenge = record { - png_base64: text; - challenge_key: ChallengeKey; -}; - -type DeviceData = record { - pubkey : DeviceKey; - alias : text; - credential_id : opt CredentialId; - purpose: Purpose; - key_type: KeyType; - protection: DeviceProtection; - origin: opt text; - // Metadata map for additional device information. - // - // Note: some fields above will be moved to the metadata map in the future. - // All field names of `DeviceData` (such as 'alias', 'origin, etc.) are - // reserved and cannot be written. - // In addition, the keys "usage" and "authenticator_attachment" are reserved as well. - metadata: opt MetadataMap; -}; - -// The same as `DeviceData` but with the `last_usage` field. -// This field cannot be written, hence the separate type. -type DeviceWithUsage = record { - pubkey : DeviceKey; - alias : text; - credential_id : opt CredentialId; - purpose: Purpose; - key_type: KeyType; - protection: DeviceProtection; - origin: opt text; - last_usage: opt Timestamp; - metadata: opt MetadataMap; -}; - -// Map with some variants for the value type. -// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. -type MetadataMap = vec record { - text; - variant { map : MetadataMap; string : text; bytes : vec nat8 }; -}; - -type RegisterResponse = variant { - // A new user was successfully registered. - registered: record { - user_number: UserNumber; - }; - // No more registrations are possible in this instance of the II service canister. - canister_full; - // The challenge was not successful. - bad_challenge; -}; - -type AddTentativeDeviceResponse = variant { - // The device was tentatively added. - added_tentatively: record { - verification_code: text; - // Expiration date, in nanos since the epoch - device_registration_timeout: Timestamp; - }; - // Device registration mode is off, either due to timeout or because it was never enabled. - device_registration_mode_off; - // There is another device already added tentatively - another_device_tentatively_added; -}; - -type VerifyTentativeDeviceResponse = variant { - // The device was successfully verified. - verified; - // Wrong verification code entered. Retry with correct code. - wrong_code: record { - retries_left: nat8 - }; - // Device registration mode is off, either due to timeout or because it was never enabled. - device_registration_mode_off; - // There is no tentative device to be verified. - no_device_to_verify; -}; - -type Delegation = record { - pubkey: PublicKey; - expiration: Timestamp; - targets: opt vec principal; -}; - -type SignedDelegation = record { - delegation: Delegation; - signature: blob; -}; - -type GetDelegationResponse = variant { - // The signed delegation was successfully retrieved. - signed_delegation: SignedDelegation; - - // The signature is not ready. Maybe retry by calling `prepare_delegation` - no_such_delegation -}; - -type InternetIdentityStats = record { - users_registered: nat64; - storage_layout_version: nat8; - assigned_user_number_range: record { - nat64; - nat64; - }; - archive_info: ArchiveInfo; - canister_creation_cycles_cost: nat64; - max_num_latest_delegation_origins: nat64; - latest_delegation_origins: vec FrontendHostname -}; - -// Configuration parameters related to the archive. -type ArchiveConfig = record { - // The allowed module hash of the archive canister. - // Changing this parameter does _not_ deploy the archive, but enable archive deployments with the - // corresponding wasm module. - module_hash : blob; - // Buffered archive entries limit. If reached, II will stop accepting new anchor operations - // until the buffered operations are acknowledged by the archive. - entries_buffer_limit: nat64; - // The maximum number of entries to be transferred to the archive per call. - entries_fetch_limit: nat16; - // Polling interval to fetch new entries from II (in nanoseconds). - // Changes to this parameter will only take effect after an archive deployment. - polling_interval_ns: nat64; -}; - -// Information about the archive. -type ArchiveInfo = record { - // Canister id of the archive or empty if no archive has been deployed yet. - archive_canister : opt principal; - // Configuration parameters related to the II archive. - archive_config: opt ArchiveConfig; -}; - -// Rate limit configuration. -// Currently only used for `register`. -type RateLimitConfig = record { - // Time it takes (in ns) for a rate limiting token to be replenished. - time_per_token_ns : nat64; - // How many tokens are at most generated (to accommodate peaks). - max_tokens: nat64; -}; - -// Init arguments of II which can be supplied on install and upgrade. -// Setting a value to null keeps the previous value. -type InternetIdentityInit = record { - // Set lowest and highest anchor - assigned_user_number_range : opt record { - nat64; - nat64; - }; - // Configuration parameters related to the II archive. - // Note: some parameters changes (like the polling interval) will only take effect after an archive deployment. - // See ArchiveConfig for details. - archive_config: opt ArchiveConfig; - // Set the amounts of cycles sent with the create canister message. - // This is configurable because in the staging environment cycles are required. - // The canister creation cost on mainnet is currently 100'000'000'000 cycles. If this value is higher thant the - // canister creation cost, the newly created canister will keep extra cycles. - canister_creation_cycles_cost : opt nat64; - // Rate limit for the `register` call. - register_rate_limit : opt RateLimitConfig; - // Maximum number of latest delegation origins to track. - // Default: 1000 - max_num_latest_delegation_origins : opt nat64; - // Maximum number of inflight captchas. - // Default: 500 - max_inflight_captchas: opt nat64; -}; - -type ChallengeKey = text; - -type ChallengeResult = record { - key : ChallengeKey; - chars : text; -}; -type CaptchaResult = ChallengeResult; - -// Extra information about registration status for new devices -type DeviceRegistrationInfo = record { - // If present, the user has tentatively added a new device. This - // new device needs to be verified (see relevant endpoint) before - // 'expiration'. - tentative_device : opt DeviceData; - // The timestamp at which the anchor will turn off registration mode - // (and the tentative device will be forgotten, if any, and if not verified) - expiration: Timestamp; -}; - -// Information about the anchor -type IdentityAnchorInfo = record { - // All devices that can authenticate to this anchor - devices : vec DeviceWithUsage; - // Device registration status used when adding devices, see DeviceRegistrationInfo - device_registration: opt DeviceRegistrationInfo; -}; - -type AnchorCredentials = record { - credentials : vec WebAuthnCredential; - recovery_credentials : vec WebAuthnCredential; - recovery_phrases: vec PublicKey; -}; - -type WebAuthnCredential = record { - credential_id : CredentialId; - pubkey: PublicKey; -}; - -type DeployArchiveResult = variant { - // The archive was deployed successfully and the supplied wasm module has been installed. The principal of the archive - // canister is returned. - success: principal; - // Initial archive creation is already in progress. - creation_in_progress; - // Archive deployment failed. An error description is returned. - failed: text; -}; - -type BufferedArchiveEntry = record { - anchor_number: UserNumber; - timestamp: Timestamp; - sequence_number: nat64; - entry: blob; -}; - -// API V2 specific types -// WARNING: These type are experimental and may change in the future. - -type IdentityNumber = nat64; - -// Map with some variants for the value type. -// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. -type MetadataMapV2 = vec record { - text; - variant { Map : MetadataMapV2; String : text; Bytes : vec nat8 }; -}; - -// Authentication method using WebAuthn signatures -// See https://www.w3.org/TR/webauthn-2/ -// This is a separate type because WebAuthn requires to also store -// the credential id (in addition to the public key). -type WebAuthn = record { - credential_id: CredentialId; - pubkey: PublicKey; -}; - -// Authentication method using generic signatures -// See https://internetcomputer.org/docs/current/references/ic-interface-spec/#signatures for -// supported signature schemes. -type PublicKeyAuthn = record { - pubkey: PublicKey; -}; - -// The authentication methods currently supported by II. -type AuthnMethod = variant { - WebAuthn: WebAuthn; - PubKey: PublicKeyAuthn; -}; - -// This describes whether an authentication method is "protected" or not. -// When protected, a authentication method can only be updated or removed if the -// user is authenticated with that very authentication method. -type AuthnMethodProtection = variant { - Protected; - Unprotected; -}; - -type AuthnMethodPurpose = variant { - Recovery; - Authentication; -}; - -type AuthnMethodSecuritySettings = record { - protection: AuthnMethodProtection; - purpose: AuthnMethodPurpose; -}; - -type AuthnMethodData = record { - authn_method: AuthnMethod; - security_settings: AuthnMethodSecuritySettings; - // contains the following fields of the DeviceWithUsage type: - // - alias - // - origin - // - authenticator_attachment: data taken from key_type and reduced to "platform", "cross_platform" or absent on migration - // - usage: data taken from key_type and reduced to "recovery_phrase", "browser_storage_key" or absent on migration - // Note: for compatibility reasons with the v1 API, the entries above (if present) - // must be of the `String` variant. This restriction may be lifted in the future. - metadata: MetadataMapV2; - last_authentication: opt Timestamp; -}; - -// Extra information about registration status for new authentication methods -type AuthnMethodRegistrationInfo = record { - // If present, the user has registered a new authentication method. This - // new authentication needs to be verified before 'expiration' in order to - // be added to the identity. - authn_method : opt AuthnMethodData; - // The timestamp at which the identity will turn off registration mode - // (and the authentication method will be forgotten, if any, and if not verified) - expiration: Timestamp; -}; - -type AuthnMethodConfirmationCode = record { - confirmation_code: text; - expiration: Timestamp; -}; - -type AuthnMethodRegisterError = variant { - // Authentication method registration mode is off, either due to timeout or because it was never enabled. - RegistrationModeOff; - // There is another authentication method already registered that needs to be confirmed first. - RegistrationAlreadyInProgress; - // The metadata of the provided authentication method contains invalid entries. - InvalidMetadata: text; -}; - -type AuthnMethodConfirmationError = variant { - // Wrong confirmation code entered. Retry with correct code. - WrongCode: record { - retries_left: nat8 - }; - // Authentication method registration mode is off, either due to timeout or because it was never enabled. - RegistrationModeOff; - // There is no registered authentication method to be confirmed. - NoAuthnMethodToConfirm; -}; - -type IdentityAuthnInfo = record { - authn_methods: vec AuthnMethod; - recovery_authn_methods: vec AuthnMethod; -}; - -type IdentityInfo = record { - authn_methods: vec AuthnMethodData; - authn_method_registration: opt AuthnMethodRegistrationInfo; - // Authentication method independent metadata - metadata: MetadataMapV2; -}; - -type IdentityInfoError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - - - -type IdentityRegisterError = variant { - // No more registrations are possible in this instance of the II service canister. - CanisterFull; - // The captcha check was not successful. - BadCaptcha; - // The metadata of the provided authentication method contains invalid entries. - InvalidMetadata: text; -}; - -type AuthnMethodAddError = variant { - InvalidMetadata: text; -}; - -type AuthnMethodReplaceError = variant { - InvalidMetadata: text; - // No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type AuthnMethodMetadataReplaceError = variant { - InvalidMetadata: text; - /// No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type AuthnMethodSecuritySettingsReplaceError = variant { - /// No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type IdentityMetadataReplaceError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// The identity including the new metadata exceeds the maximum allowed size. - StorageSpaceExceeded: record {space_available: nat64; space_required: nat64}; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -type PrepareIdAliasRequest = record { - /// Origin of the issuer in the attribute sharing flow. - issuer : FrontendHostname; - /// Origin of the relying party in the attribute sharing flow. - relying_party : FrontendHostname; - /// Identity for which the IdAlias should be generated. - identity_number : IdentityNumber; -}; - -type PrepareIdAliasError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -/// The prepared id alias contains two (still unsigned) credentials in JWT format, -/// certifying the id alias for the issuer resp. the relying party. -type PreparedIdAlias = record { - rp_id_alias_jwt : text; - issuer_id_alias_jwt : text; - canister_sig_pk_der : PublicKey; -}; - -/// The request to retrieve the actual signed id alias credentials. -/// The field values should be equal to the values of corresponding -/// fields from the preceding `PrepareIdAliasRequest` and `PrepareIdAliasResponse`. -type GetIdAliasRequest = record { - rp_id_alias_jwt : text; - issuer : FrontendHostname; - issuer_id_alias_jwt : text; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; - -type GetIdAliasError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// The credential(s) are not available: may be expired or not prepared yet (call prepare_id_alias to prepare). - NoSuchCredentials : text; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -/// The signed id alias credentials for each involved party. -type IdAliasCredentials = record { - rp_id_alias_credential : SignedIdAlias; - issuer_id_alias_credential : SignedIdAlias; -}; - -type SignedIdAlias = record { - credential_jws : text; - id_alias : principal; - id_dapp : principal; -}; - -service : (opt InternetIdentityInit) -> { - init_salt: () -> (); - create_challenge : () -> (Challenge); - register : (DeviceData, ChallengeResult, opt principal) -> (RegisterResponse); - add : (UserNumber, DeviceData) -> (); - update : (UserNumber, DeviceKey, DeviceData) -> (); - // Atomically replace device matching the device key with the new device data - replace : (UserNumber, DeviceKey, DeviceData) -> (); - remove : (UserNumber, DeviceKey) -> (); - // Returns all devices of the user (authentication and recovery) but no information about device registrations. - // Note: Clears out the 'alias' fields on the devices. Use 'get_anchor_info' to obtain the full information. - // Deprecated: Use 'get_anchor_credentials' instead. - lookup : (UserNumber) -> (vec DeviceData) query; - get_anchor_credentials : (UserNumber) -> (AnchorCredentials) query; - get_anchor_info : (UserNumber) -> (IdentityAnchorInfo); - get_principal : (UserNumber, FrontendHostname) -> (principal) query; - stats : () -> (InternetIdentityStats) query; - - enter_device_registration_mode : (UserNumber) -> (Timestamp); - exit_device_registration_mode : (UserNumber) -> (); - add_tentative_device : (UserNumber, DeviceData) -> (AddTentativeDeviceResponse); - verify_tentative_device : (UserNumber, verification_code: text) -> (VerifyTentativeDeviceResponse); - - prepare_delegation : (UserNumber, FrontendHostname, SessionKey, maxTimeToLive : opt nat64) -> (UserKey, Timestamp); - get_delegation: (UserNumber, FrontendHostname, SessionKey, Timestamp) -> (GetDelegationResponse) query; - - http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_update: (request: HttpRequest) -> (HttpResponse); - - deploy_archive: (wasm: blob) -> (DeployArchiveResult); - /// Returns a batch of entries _sorted by sequence number_ to be archived. - /// This is an update call because the archive information _must_ be certified. - /// Only callable by this IIs archive canister. - fetch_entries: () -> (vec BufferedArchiveEntry); - acknowledge_entries: (sequence_number: nat64) -> (); - - // V2 API - // WARNING: The following methods are experimental and may change in the future. - - // Creates a new captcha. The solution needs to be submitted using the - // `identity_register` call. - captcha_create: () -> (variant {Ok: Challenge; Err;}); - - // Registers a new identity with the given authn_method. - // A valid captcha solution to a previously generated captcha (using create_captcha) must be provided. - // The sender needs to match the supplied authn_method. - identity_register: (AuthnMethodData, CaptchaResult, opt principal) -> (variant {Ok: IdentityNumber; Err: IdentityRegisterError;}); - - // Returns information about the authentication methods of the identity with the given number. - // Only returns the minimal information required for authentication without exposing any metadata such as aliases. - identity_authn_info: (IdentityNumber) -> (variant {Ok: IdentityAuthnInfo; Err;}) query; - - // Returns information about the identity with the given number. - // Requires authentication. - identity_info: (IdentityNumber) -> (variant {Ok: IdentityInfo; Err: IdentityInfoError;}); - - // Replaces the authentication method independent metadata map. - // The existing metadata map will be overwritten. - // Requires authentication. - identity_metadata_replace: (IdentityNumber, MetadataMapV2) -> (variant {Ok; Err: IdentityMetadataReplaceError;}); - - // Adds a new authentication method to the identity. - // Requires authentication. - authn_method_add: (IdentityNumber, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodAddError;}); - - // Atomically replaces the authentication method matching the supplied public key with the new authentication method - // provided. - // Requires authentication. - authn_method_replace: (IdentityNumber, PublicKey, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodReplaceError;}); - - // Replaces the authentication method metadata map. - // The existing metadata map will be overwritten. - // Requires authentication. - authn_method_metadata_replace: (IdentityNumber, PublicKey, MetadataMapV2) -> (variant {Ok; Err: AuthnMethodMetadataReplaceError;}); - - // Replaces the authentication method security settings. - // The existing security settings will be overwritten. - // Requires authentication. - authn_method_security_settings_replace: (IdentityNumber, PublicKey, AuthnMethodSecuritySettings) -> (variant {Ok; Err: AuthnMethodSecuritySettingsReplaceError;}); - - // Removes the authentication method associated with the public key from the identity. - // Requires authentication. - authn_method_remove: (IdentityNumber, PublicKey) -> (variant {Ok; Err;}); - - // Enters the authentication method registration mode for the identity. - // In this mode, a new authentication method can be registered, which then needs to be - // confirmed before it can be used for authentication on this identity. - // The registration mode is automatically exited after the returned expiration timestamp. - // Requires authentication. - authn_method_registration_mode_enter : (IdentityNumber) -> (variant {Ok: record { expiration: Timestamp; }; Err;}); - - // Exits the authentication method registration mode for the identity. - // Requires authentication. - authn_method_registration_mode_exit : (IdentityNumber) -> (variant {Ok; Err;}); - - // Registers a new authentication method to the identity. - // This authentication method needs to be confirmed before it can be used for authentication on this identity. - authn_method_register: (IdentityNumber, AuthnMethodData) -> (variant {Ok: AuthnMethodConfirmationCode; Err: AuthnMethodRegisterError;}); - - // Confirms a previously registered authentication method. - // On successful confirmation, the authentication method is permanently added to the identity and can - // subsequently be used for authentication for that identity. - // Requires authentication. - authn_method_confirm: (IdentityNumber, confirmation_code: text) -> (variant {Ok; Err: AuthnMethodConfirmationError;}); - - // Attribute Sharing MVP API - // The methods below are used to generate ID-alias credentials during attribute sharing flow. - prepare_id_alias : (PrepareIdAliasRequest) -> (variant {Ok: PreparedIdAlias; Err: PrepareIdAliasError;}); - get_id_alias : (GetIdAliasRequest) -> (variant {Ok: IdAliasCredentials; Err: GetIdAliasError;}) query; -} diff --git a/.dfx/local/canisters/internet_identity/download-internet_identity_dev.wasm.gz b/.dfx/local/canisters/internet_identity/download-internet_identity_dev.wasm.gz deleted file mode 100644 index 17c96103..00000000 Binary files a/.dfx/local/canisters/internet_identity/download-internet_identity_dev.wasm.gz and /dev/null differ diff --git a/.dfx/local/canisters/internet_identity/index.js b/.dfx/local/canisters/internet_identity/index.js deleted file mode 100644 index aa61fde5..00000000 --- a/.dfx/local/canisters/internet_identity/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from './internet_identity.did.js'; -export { idlFactory } from './internet_identity.did.js'; -// CANISTER_ID is replaced by webpack based on node environment -export const canisterId = process.env.INTERNET_IDENTITY_CANISTER_ID; - -/** - * @deprecated since dfx 0.11.1 - * Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface. - * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent - * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options] - * @return {import("@dfinity/agent").ActorSubclass} - */ -export const createActor = (canisterId, options = {}) => { - console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings. - -See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`); - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - // 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 ? options.actorOptions : {}), - }); -}; - -/** - * A ready-to-use agent for the internet_identity canister - * @type {import("@dfinity/agent").ActorSubclass} - */ -export const internet_identity = createActor(canisterId); diff --git a/.dfx/local/canisters/internet_identity/init_args.txt b/.dfx/local/canisters/internet_identity/init_args.txt deleted file mode 100644 index ff08b423..00000000 --- a/.dfx/local/canisters/internet_identity/init_args.txt +++ /dev/null @@ -1 +0,0 @@ -(opt InternetIdentityInit) \ No newline at end of file diff --git a/.dfx/local/canisters/internet_identity/internet_identity.did b/.dfx/local/canisters/internet_identity/internet_identity.did deleted file mode 100644 index dd464712..00000000 --- a/.dfx/local/canisters/internet_identity/internet_identity.did +++ /dev/null @@ -1,620 +0,0 @@ -type UserNumber = nat64; -type PublicKey = blob; -type CredentialId = blob; -type DeviceKey = PublicKey; -type UserKey = PublicKey; -type SessionKey = PublicKey; -type FrontendHostname = text; -type Timestamp = nat64; - -type HeaderField = record { - text; - text; -}; - -type HttpRequest = record { - method: text; - url: text; - headers: vec HeaderField; - body: blob; - certificate_version: opt nat16; -}; - -type HttpResponse = record { - status_code: nat16; - headers: vec HeaderField; - body: blob; - upgrade : opt bool; - streaming_strategy: opt StreamingStrategy; -}; - -type StreamingCallbackHttpResponse = record { - body: blob; - token: opt Token; -}; - -type Token = record {}; - -type StreamingStrategy = variant { - Callback: record { - callback: func (Token) -> (StreamingCallbackHttpResponse) query; - token: Token; - }; -}; - -type Purpose = variant { - recovery; - authentication; -}; - -type KeyType = variant { - unknown; - platform; - cross_platform; - seed_phrase; - browser_storage_key; -}; - -// This describes whether a device is "protected" or not. -// When protected, a device can only be updated or removed if the -// user is authenticated with that very device. -type DeviceProtection = variant { - protected; - unprotected; -}; - -type Challenge = record { - png_base64: text; - challenge_key: ChallengeKey; -}; - -type DeviceData = record { - pubkey : DeviceKey; - alias : text; - credential_id : opt CredentialId; - purpose: Purpose; - key_type: KeyType; - protection: DeviceProtection; - origin: opt text; - // Metadata map for additional device information. - // - // Note: some fields above will be moved to the metadata map in the future. - // All field names of `DeviceData` (such as 'alias', 'origin, etc.) are - // reserved and cannot be written. - // In addition, the keys "usage" and "authenticator_attachment" are reserved as well. - metadata: opt MetadataMap; -}; - -// The same as `DeviceData` but with the `last_usage` field. -// This field cannot be written, hence the separate type. -type DeviceWithUsage = record { - pubkey : DeviceKey; - alias : text; - credential_id : opt CredentialId; - purpose: Purpose; - key_type: KeyType; - protection: DeviceProtection; - origin: opt text; - last_usage: opt Timestamp; - metadata: opt MetadataMap; -}; - -// Map with some variants for the value type. -// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. -type MetadataMap = vec record { - text; - variant { map : MetadataMap; string : text; bytes : vec nat8 }; -}; - -type RegisterResponse = variant { - // A new user was successfully registered. - registered: record { - user_number: UserNumber; - }; - // No more registrations are possible in this instance of the II service canister. - canister_full; - // The challenge was not successful. - bad_challenge; -}; - -type AddTentativeDeviceResponse = variant { - // The device was tentatively added. - added_tentatively: record { - verification_code: text; - // Expiration date, in nanos since the epoch - device_registration_timeout: Timestamp; - }; - // Device registration mode is off, either due to timeout or because it was never enabled. - device_registration_mode_off; - // There is another device already added tentatively - another_device_tentatively_added; -}; - -type VerifyTentativeDeviceResponse = variant { - // The device was successfully verified. - verified; - // Wrong verification code entered. Retry with correct code. - wrong_code: record { - retries_left: nat8 - }; - // Device registration mode is off, either due to timeout or because it was never enabled. - device_registration_mode_off; - // There is no tentative device to be verified. - no_device_to_verify; -}; - -type Delegation = record { - pubkey: PublicKey; - expiration: Timestamp; - targets: opt vec principal; -}; - -type SignedDelegation = record { - delegation: Delegation; - signature: blob; -}; - -type GetDelegationResponse = variant { - // The signed delegation was successfully retrieved. - signed_delegation: SignedDelegation; - - // The signature is not ready. Maybe retry by calling `prepare_delegation` - no_such_delegation -}; - -type InternetIdentityStats = record { - users_registered: nat64; - storage_layout_version: nat8; - assigned_user_number_range: record { - nat64; - nat64; - }; - archive_info: ArchiveInfo; - canister_creation_cycles_cost: nat64; - max_num_latest_delegation_origins: nat64; - latest_delegation_origins: vec FrontendHostname -}; - -// Configuration parameters related to the archive. -type ArchiveConfig = record { - // The allowed module hash of the archive canister. - // Changing this parameter does _not_ deploy the archive, but enable archive deployments with the - // corresponding wasm module. - module_hash : blob; - // Buffered archive entries limit. If reached, II will stop accepting new anchor operations - // until the buffered operations are acknowledged by the archive. - entries_buffer_limit: nat64; - // The maximum number of entries to be transferred to the archive per call. - entries_fetch_limit: nat16; - // Polling interval to fetch new entries from II (in nanoseconds). - // Changes to this parameter will only take effect after an archive deployment. - polling_interval_ns: nat64; -}; - -// Information about the archive. -type ArchiveInfo = record { - // Canister id of the archive or empty if no archive has been deployed yet. - archive_canister : opt principal; - // Configuration parameters related to the II archive. - archive_config: opt ArchiveConfig; -}; - -// Rate limit configuration. -// Currently only used for `register`. -type RateLimitConfig = record { - // Time it takes (in ns) for a rate limiting token to be replenished. - time_per_token_ns : nat64; - // How many tokens are at most generated (to accommodate peaks). - max_tokens: nat64; -}; - -// Init arguments of II which can be supplied on install and upgrade. -// Setting a value to null keeps the previous value. -type InternetIdentityInit = record { - // Set lowest and highest anchor - assigned_user_number_range : opt record { - nat64; - nat64; - }; - // Configuration parameters related to the II archive. - // Note: some parameters changes (like the polling interval) will only take effect after an archive deployment. - // See ArchiveConfig for details. - archive_config: opt ArchiveConfig; - // Set the amounts of cycles sent with the create canister message. - // This is configurable because in the staging environment cycles are required. - // The canister creation cost on mainnet is currently 100'000'000'000 cycles. If this value is higher thant the - // canister creation cost, the newly created canister will keep extra cycles. - canister_creation_cycles_cost : opt nat64; - // Rate limit for the `register` call. - register_rate_limit : opt RateLimitConfig; - // Maximum number of latest delegation origins to track. - // Default: 1000 - max_num_latest_delegation_origins : opt nat64; - // Maximum number of inflight captchas. - // Default: 500 - max_inflight_captchas: opt nat64; -}; - -type ChallengeKey = text; - -type ChallengeResult = record { - key : ChallengeKey; - chars : text; -}; -type CaptchaResult = ChallengeResult; - -// Extra information about registration status for new devices -type DeviceRegistrationInfo = record { - // If present, the user has tentatively added a new device. This - // new device needs to be verified (see relevant endpoint) before - // 'expiration'. - tentative_device : opt DeviceData; - // The timestamp at which the anchor will turn off registration mode - // (and the tentative device will be forgotten, if any, and if not verified) - expiration: Timestamp; -}; - -// Information about the anchor -type IdentityAnchorInfo = record { - // All devices that can authenticate to this anchor - devices : vec DeviceWithUsage; - // Device registration status used when adding devices, see DeviceRegistrationInfo - device_registration: opt DeviceRegistrationInfo; -}; - -type AnchorCredentials = record { - credentials : vec WebAuthnCredential; - recovery_credentials : vec WebAuthnCredential; - recovery_phrases: vec PublicKey; -}; - -type WebAuthnCredential = record { - credential_id : CredentialId; - pubkey: PublicKey; -}; - -type DeployArchiveResult = variant { - // The archive was deployed successfully and the supplied wasm module has been installed. The principal of the archive - // canister is returned. - success: principal; - // Initial archive creation is already in progress. - creation_in_progress; - // Archive deployment failed. An error description is returned. - failed: text; -}; - -type BufferedArchiveEntry = record { - anchor_number: UserNumber; - timestamp: Timestamp; - sequence_number: nat64; - entry: blob; -}; - -// API V2 specific types -// WARNING: These type are experimental and may change in the future. - -type IdentityNumber = nat64; - -// Map with some variants for the value type. -// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. -type MetadataMapV2 = vec record { - text; - variant { Map : MetadataMapV2; String : text; Bytes : vec nat8 }; -}; - -// Authentication method using WebAuthn signatures -// See https://www.w3.org/TR/webauthn-2/ -// This is a separate type because WebAuthn requires to also store -// the credential id (in addition to the public key). -type WebAuthn = record { - credential_id: CredentialId; - pubkey: PublicKey; -}; - -// Authentication method using generic signatures -// See https://internetcomputer.org/docs/current/references/ic-interface-spec/#signatures for -// supported signature schemes. -type PublicKeyAuthn = record { - pubkey: PublicKey; -}; - -// The authentication methods currently supported by II. -type AuthnMethod = variant { - WebAuthn: WebAuthn; - PubKey: PublicKeyAuthn; -}; - -// This describes whether an authentication method is "protected" or not. -// When protected, a authentication method can only be updated or removed if the -// user is authenticated with that very authentication method. -type AuthnMethodProtection = variant { - Protected; - Unprotected; -}; - -type AuthnMethodPurpose = variant { - Recovery; - Authentication; -}; - -type AuthnMethodSecuritySettings = record { - protection: AuthnMethodProtection; - purpose: AuthnMethodPurpose; -}; - -type AuthnMethodData = record { - authn_method: AuthnMethod; - security_settings: AuthnMethodSecuritySettings; - // contains the following fields of the DeviceWithUsage type: - // - alias - // - origin - // - authenticator_attachment: data taken from key_type and reduced to "platform", "cross_platform" or absent on migration - // - usage: data taken from key_type and reduced to "recovery_phrase", "browser_storage_key" or absent on migration - // Note: for compatibility reasons with the v1 API, the entries above (if present) - // must be of the `String` variant. This restriction may be lifted in the future. - metadata: MetadataMapV2; - last_authentication: opt Timestamp; -}; - -// Extra information about registration status for new authentication methods -type AuthnMethodRegistrationInfo = record { - // If present, the user has registered a new authentication method. This - // new authentication needs to be verified before 'expiration' in order to - // be added to the identity. - authn_method : opt AuthnMethodData; - // The timestamp at which the identity will turn off registration mode - // (and the authentication method will be forgotten, if any, and if not verified) - expiration: Timestamp; -}; - -type AuthnMethodConfirmationCode = record { - confirmation_code: text; - expiration: Timestamp; -}; - -type AuthnMethodRegisterError = variant { - // Authentication method registration mode is off, either due to timeout or because it was never enabled. - RegistrationModeOff; - // There is another authentication method already registered that needs to be confirmed first. - RegistrationAlreadyInProgress; - // The metadata of the provided authentication method contains invalid entries. - InvalidMetadata: text; -}; - -type AuthnMethodConfirmationError = variant { - // Wrong confirmation code entered. Retry with correct code. - WrongCode: record { - retries_left: nat8 - }; - // Authentication method registration mode is off, either due to timeout or because it was never enabled. - RegistrationModeOff; - // There is no registered authentication method to be confirmed. - NoAuthnMethodToConfirm; -}; - -type IdentityAuthnInfo = record { - authn_methods: vec AuthnMethod; - recovery_authn_methods: vec AuthnMethod; -}; - -type IdentityInfo = record { - authn_methods: vec AuthnMethodData; - authn_method_registration: opt AuthnMethodRegistrationInfo; - // Authentication method independent metadata - metadata: MetadataMapV2; -}; - -type IdentityInfoError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - - - -type IdentityRegisterError = variant { - // No more registrations are possible in this instance of the II service canister. - CanisterFull; - // The captcha check was not successful. - BadCaptcha; - // The metadata of the provided authentication method contains invalid entries. - InvalidMetadata: text; -}; - -type AuthnMethodAddError = variant { - InvalidMetadata: text; -}; - -type AuthnMethodReplaceError = variant { - InvalidMetadata: text; - // No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type AuthnMethodMetadataReplaceError = variant { - InvalidMetadata: text; - /// No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type AuthnMethodSecuritySettingsReplaceError = variant { - /// No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type IdentityMetadataReplaceError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// The identity including the new metadata exceeds the maximum allowed size. - StorageSpaceExceeded: record {space_available: nat64; space_required: nat64}; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -type PrepareIdAliasRequest = record { - /// Origin of the issuer in the attribute sharing flow. - issuer : FrontendHostname; - /// Origin of the relying party in the attribute sharing flow. - relying_party : FrontendHostname; - /// Identity for which the IdAlias should be generated. - identity_number : IdentityNumber; -}; - -type PrepareIdAliasError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -/// The prepared id alias contains two (still unsigned) credentials in JWT format, -/// certifying the id alias for the issuer resp. the relying party. -type PreparedIdAlias = record { - rp_id_alias_jwt : text; - issuer_id_alias_jwt : text; - canister_sig_pk_der : PublicKey; -}; - -/// The request to retrieve the actual signed id alias credentials. -/// The field values should be equal to the values of corresponding -/// fields from the preceding `PrepareIdAliasRequest` and `PrepareIdAliasResponse`. -type GetIdAliasRequest = record { - rp_id_alias_jwt : text; - issuer : FrontendHostname; - issuer_id_alias_jwt : text; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; - -type GetIdAliasError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// The credential(s) are not available: may be expired or not prepared yet (call prepare_id_alias to prepare). - NoSuchCredentials : text; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -/// The signed id alias credentials for each involved party. -type IdAliasCredentials = record { - rp_id_alias_credential : SignedIdAlias; - issuer_id_alias_credential : SignedIdAlias; -}; - -type SignedIdAlias = record { - credential_jws : text; - id_alias : principal; - id_dapp : principal; -}; - -service : (opt InternetIdentityInit) -> { - init_salt: () -> (); - create_challenge : () -> (Challenge); - register : (DeviceData, ChallengeResult, opt principal) -> (RegisterResponse); - add : (UserNumber, DeviceData) -> (); - update : (UserNumber, DeviceKey, DeviceData) -> (); - // Atomically replace device matching the device key with the new device data - replace : (UserNumber, DeviceKey, DeviceData) -> (); - remove : (UserNumber, DeviceKey) -> (); - // Returns all devices of the user (authentication and recovery) but no information about device registrations. - // Note: Clears out the 'alias' fields on the devices. Use 'get_anchor_info' to obtain the full information. - // Deprecated: Use 'get_anchor_credentials' instead. - lookup : (UserNumber) -> (vec DeviceData) query; - get_anchor_credentials : (UserNumber) -> (AnchorCredentials) query; - get_anchor_info : (UserNumber) -> (IdentityAnchorInfo); - get_principal : (UserNumber, FrontendHostname) -> (principal) query; - stats : () -> (InternetIdentityStats) query; - - enter_device_registration_mode : (UserNumber) -> (Timestamp); - exit_device_registration_mode : (UserNumber) -> (); - add_tentative_device : (UserNumber, DeviceData) -> (AddTentativeDeviceResponse); - verify_tentative_device : (UserNumber, verification_code: text) -> (VerifyTentativeDeviceResponse); - - prepare_delegation : (UserNumber, FrontendHostname, SessionKey, maxTimeToLive : opt nat64) -> (UserKey, Timestamp); - get_delegation: (UserNumber, FrontendHostname, SessionKey, Timestamp) -> (GetDelegationResponse) query; - - http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_update: (request: HttpRequest) -> (HttpResponse); - - deploy_archive: (wasm: blob) -> (DeployArchiveResult); - /// Returns a batch of entries _sorted by sequence number_ to be archived. - /// This is an update call because the archive information _must_ be certified. - /// Only callable by this IIs archive canister. - fetch_entries: () -> (vec BufferedArchiveEntry); - acknowledge_entries: (sequence_number: nat64) -> (); - - // V2 API - // WARNING: The following methods are experimental and may change in the future. - - // Creates a new captcha. The solution needs to be submitted using the - // `identity_register` call. - captcha_create: () -> (variant {Ok: Challenge; Err;}); - - // Registers a new identity with the given authn_method. - // A valid captcha solution to a previously generated captcha (using create_captcha) must be provided. - // The sender needs to match the supplied authn_method. - identity_register: (AuthnMethodData, CaptchaResult, opt principal) -> (variant {Ok: IdentityNumber; Err: IdentityRegisterError;}); - - // Returns information about the authentication methods of the identity with the given number. - // Only returns the minimal information required for authentication without exposing any metadata such as aliases. - identity_authn_info: (IdentityNumber) -> (variant {Ok: IdentityAuthnInfo; Err;}) query; - - // Returns information about the identity with the given number. - // Requires authentication. - identity_info: (IdentityNumber) -> (variant {Ok: IdentityInfo; Err: IdentityInfoError;}); - - // Replaces the authentication method independent metadata map. - // The existing metadata map will be overwritten. - // Requires authentication. - identity_metadata_replace: (IdentityNumber, MetadataMapV2) -> (variant {Ok; Err: IdentityMetadataReplaceError;}); - - // Adds a new authentication method to the identity. - // Requires authentication. - authn_method_add: (IdentityNumber, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodAddError;}); - - // Atomically replaces the authentication method matching the supplied public key with the new authentication method - // provided. - // Requires authentication. - authn_method_replace: (IdentityNumber, PublicKey, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodReplaceError;}); - - // Replaces the authentication method metadata map. - // The existing metadata map will be overwritten. - // Requires authentication. - authn_method_metadata_replace: (IdentityNumber, PublicKey, MetadataMapV2) -> (variant {Ok; Err: AuthnMethodMetadataReplaceError;}); - - // Replaces the authentication method security settings. - // The existing security settings will be overwritten. - // Requires authentication. - authn_method_security_settings_replace: (IdentityNumber, PublicKey, AuthnMethodSecuritySettings) -> (variant {Ok; Err: AuthnMethodSecuritySettingsReplaceError;}); - - // Removes the authentication method associated with the public key from the identity. - // Requires authentication. - authn_method_remove: (IdentityNumber, PublicKey) -> (variant {Ok; Err;}); - - // Enters the authentication method registration mode for the identity. - // In this mode, a new authentication method can be registered, which then needs to be - // confirmed before it can be used for authentication on this identity. - // The registration mode is automatically exited after the returned expiration timestamp. - // Requires authentication. - authn_method_registration_mode_enter : (IdentityNumber) -> (variant {Ok: record { expiration: Timestamp; }; Err;}); - - // Exits the authentication method registration mode for the identity. - // Requires authentication. - authn_method_registration_mode_exit : (IdentityNumber) -> (variant {Ok; Err;}); - - // Registers a new authentication method to the identity. - // This authentication method needs to be confirmed before it can be used for authentication on this identity. - authn_method_register: (IdentityNumber, AuthnMethodData) -> (variant {Ok: AuthnMethodConfirmationCode; Err: AuthnMethodRegisterError;}); - - // Confirms a previously registered authentication method. - // On successful confirmation, the authentication method is permanently added to the identity and can - // subsequently be used for authentication for that identity. - // Requires authentication. - authn_method_confirm: (IdentityNumber, confirmation_code: text) -> (variant {Ok; Err: AuthnMethodConfirmationError;}); - - // Attribute Sharing MVP API - // The methods below are used to generate ID-alias credentials during attribute sharing flow. - prepare_id_alias : (PrepareIdAliasRequest) -> (variant {Ok: PreparedIdAlias; Err: PrepareIdAliasError;}); - get_id_alias : (GetIdAliasRequest) -> (variant {Ok: IdAliasCredentials; Err: GetIdAliasError;}) query; -} diff --git a/.dfx/local/canisters/internet_identity/internet_identity.wasm.gz b/.dfx/local/canisters/internet_identity/internet_identity.wasm.gz deleted file mode 100644 index 17c96103..00000000 Binary files a/.dfx/local/canisters/internet_identity/internet_identity.wasm.gz and /dev/null differ diff --git a/.dfx/local/canisters/internet_identity/service.did b/.dfx/local/canisters/internet_identity/service.did deleted file mode 100644 index fd53d49c..00000000 --- a/.dfx/local/canisters/internet_identity/service.did +++ /dev/null @@ -1,356 +0,0 @@ -type AddTentativeDeviceResponse = variant { - device_registration_mode_off; - another_device_tentatively_added; - added_tentatively : record { - verification_code : text; - device_registration_timeout : Timestamp; - }; -}; -type AnchorCredentials = record { - recovery_phrases : vec PublicKey; - credentials : vec WebAuthnCredential; - recovery_credentials : vec WebAuthnCredential; -}; -type ArchiveConfig = record { - polling_interval_ns : nat64; - entries_buffer_limit : nat64; - module_hash : vec nat8; - entries_fetch_limit : nat16; -}; -type ArchiveInfo = record { - archive_config : opt ArchiveConfig; - archive_canister : opt principal; -}; -type AuthnMethod = variant { PubKey : PublicKeyAuthn; WebAuthn : WebAuthn }; -type AuthnMethodAddError = variant { InvalidMetadata : text }; -type AuthnMethodConfirmationCode = record { - confirmation_code : text; - expiration : Timestamp; -}; -type AuthnMethodConfirmationError = variant { - RegistrationModeOff; - NoAuthnMethodToConfirm; - WrongCode : record { retries_left : nat8 }; -}; -type AuthnMethodData = record { - security_settings : AuthnMethodSecuritySettings; - metadata : MetadataMapV2; - last_authentication : opt Timestamp; - authn_method : AuthnMethod; -}; -type AuthnMethodMetadataReplaceError = variant { - AuthnMethodNotFound; - InvalidMetadata : text; -}; -type AuthnMethodProtection = variant { Protected; Unprotected }; -type AuthnMethodPurpose = variant { Recovery; Authentication }; -type AuthnMethodRegisterError = variant { - RegistrationModeOff; - RegistrationAlreadyInProgress; - InvalidMetadata : text; -}; -type AuthnMethodRegistrationInfo = record { - expiration : Timestamp; - authn_method : opt AuthnMethodData; -}; -type AuthnMethodReplaceError = variant { - AuthnMethodNotFound; - InvalidMetadata : text; -}; -type AuthnMethodSecuritySettings = record { - protection : AuthnMethodProtection; - purpose : AuthnMethodPurpose; -}; -type AuthnMethodSecuritySettingsReplaceError = variant { AuthnMethodNotFound }; -type BufferedArchiveEntry = record { - sequence_number : nat64; - entry : vec nat8; - anchor_number : UserNumber; - timestamp : Timestamp; -}; -type CaptchaResult = ChallengeResult; -type Challenge = record { png_base64 : text; challenge_key : ChallengeKey }; -type ChallengeKey = text; -type ChallengeResult = record { key : ChallengeKey; chars : text }; -type CredentialId = vec nat8; -type Delegation = record { - pubkey : PublicKey; - targets : opt vec principal; - expiration : Timestamp; -}; -type DeployArchiveResult = variant { - creation_in_progress; - success : principal; - failed : text; -}; -type DeviceData = record { - alias : text; - metadata : opt MetadataMap; - origin : opt text; - protection : DeviceProtection; - pubkey : DeviceKey; - key_type : KeyType; - purpose : Purpose; - credential_id : opt CredentialId; -}; -type DeviceKey = PublicKey; -type DeviceProtection = variant { unprotected; protected }; -type DeviceRegistrationInfo = record { - tentative_device : opt DeviceData; - expiration : Timestamp; -}; -type DeviceWithUsage = record { - alias : text; - last_usage : opt Timestamp; - metadata : opt MetadataMap; - origin : opt text; - protection : DeviceProtection; - pubkey : DeviceKey; - key_type : KeyType; - purpose : Purpose; - credential_id : opt CredentialId; -}; -type FrontendHostname = text; -type GetDelegationResponse = variant { - no_such_delegation; - signed_delegation : SignedDelegation; -}; -type GetIdAliasError = variant { - InternalCanisterError : text; - Unauthorized : principal; - NoSuchCredentials : text; -}; -type GetIdAliasRequest = record { - rp_id_alias_jwt : text; - issuer : FrontendHostname; - issuer_id_alias_jwt : text; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; -type HeaderField = record { text; text }; -type HttpRequest = record { - url : text; - method : text; - body : vec nat8; - headers : vec HeaderField; - certificate_version : opt nat16; -}; -type HttpResponse = record { - body : vec nat8; - headers : vec HeaderField; - upgrade : opt bool; - streaming_strategy : opt StreamingStrategy; - status_code : nat16; -}; -type IdAliasCredentials = record { - rp_id_alias_credential : SignedIdAlias; - issuer_id_alias_credential : SignedIdAlias; -}; -type IdentityAnchorInfo = record { - devices : vec DeviceWithUsage; - device_registration : opt DeviceRegistrationInfo; -}; -type IdentityAuthnInfo = record { - authn_methods : vec AuthnMethod; - recovery_authn_methods : vec AuthnMethod; -}; -type IdentityInfo = record { - authn_methods : vec AuthnMethodData; - metadata : MetadataMapV2; - authn_method_registration : opt AuthnMethodRegistrationInfo; -}; -type IdentityInfoError = variant { - InternalCanisterError : text; - Unauthorized : principal; -}; -type IdentityMetadataReplaceError = variant { - InternalCanisterError : text; - Unauthorized : principal; - StorageSpaceExceeded : record { - space_required : nat64; - space_available : nat64; - }; -}; -type IdentityNumber = nat64; -type IdentityRegisterError = variant { - BadCaptcha; - CanisterFull; - InvalidMetadata : text; -}; -type InternetIdentityInit = record { - max_num_latest_delegation_origins : opt nat64; - assigned_user_number_range : opt record { nat64; nat64 }; - max_inflight_captchas : opt nat64; - archive_config : opt ArchiveConfig; - canister_creation_cycles_cost : opt nat64; - register_rate_limit : opt RateLimitConfig; -}; -type InternetIdentityStats = record { - storage_layout_version : nat8; - users_registered : nat64; - max_num_latest_delegation_origins : nat64; - assigned_user_number_range : record { nat64; nat64 }; - latest_delegation_origins : vec FrontendHostname; - archive_info : ArchiveInfo; - canister_creation_cycles_cost : nat64; -}; -type KeyType = variant { - platform; - seed_phrase; - cross_platform; - unknown; - browser_storage_key; -}; -type MetadataMap = vec record { - text; - variant { map : MetadataMap; string : text; bytes : vec nat8 }; -}; -type MetadataMapV2 = vec record { - text; - variant { Map : MetadataMapV2; String : text; Bytes : vec nat8 }; -}; -type PrepareIdAliasError = variant { - InternalCanisterError : text; - Unauthorized : principal; -}; -type PrepareIdAliasRequest = record { - issuer : FrontendHostname; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; -type PreparedIdAlias = record { - rp_id_alias_jwt : text; - issuer_id_alias_jwt : text; - canister_sig_pk_der : PublicKey; -}; -type PublicKey = vec nat8; -type PublicKeyAuthn = record { pubkey : PublicKey }; -type Purpose = variant { authentication; recovery }; -type RateLimitConfig = record { max_tokens : nat64; time_per_token_ns : nat64 }; -type RegisterResponse = variant { - bad_challenge; - canister_full; - registered : record { user_number : UserNumber }; -}; -type SessionKey = PublicKey; -type SignedDelegation = record { - signature : vec nat8; - delegation : Delegation; -}; -type SignedIdAlias = record { - credential_jws : text; - id_alias : principal; - id_dapp : principal; -}; -type StreamingCallbackHttpResponse = record { - token : opt Token; - body : vec nat8; -}; -type StreamingStrategy = variant { - Callback : record { - token : Token; - callback : func (Token) -> (StreamingCallbackHttpResponse) query; - }; -}; -type Timestamp = nat64; -type Token = record {}; -type UserKey = PublicKey; -type UserNumber = nat64; -type VerifyTentativeDeviceResponse = variant { - device_registration_mode_off; - verified; - wrong_code : record { retries_left : nat8 }; - no_device_to_verify; -}; -type WebAuthn = record { pubkey : PublicKey; credential_id : CredentialId }; -type WebAuthnCredential = record { - pubkey : PublicKey; - credential_id : CredentialId; -}; -service : { - acknowledge_entries : (nat64) -> (); - add : (UserNumber, DeviceData) -> (); - add_tentative_device : (UserNumber, DeviceData) -> ( - AddTentativeDeviceResponse, - ); - authn_method_add : (IdentityNumber, AuthnMethodData) -> ( - variant { Ok; Err : AuthnMethodAddError }, - ); - authn_method_confirm : (IdentityNumber, text) -> ( - variant { Ok; Err : AuthnMethodConfirmationError }, - ); - authn_method_metadata_replace : ( - IdentityNumber, - PublicKey, - MetadataMapV2, - ) -> (variant { Ok; Err : AuthnMethodMetadataReplaceError }); - authn_method_register : (IdentityNumber, AuthnMethodData) -> ( - variant { - Ok : AuthnMethodConfirmationCode; - Err : AuthnMethodRegisterError; - }, - ); - authn_method_registration_mode_enter : (IdentityNumber) -> ( - variant { Ok : record { expiration : Timestamp }; Err }, - ); - authn_method_registration_mode_exit : (IdentityNumber) -> ( - variant { Ok; Err }, - ); - authn_method_remove : (IdentityNumber, PublicKey) -> (variant { Ok; Err }); - authn_method_replace : (IdentityNumber, PublicKey, AuthnMethodData) -> ( - variant { Ok; Err : AuthnMethodReplaceError }, - ); - authn_method_security_settings_replace : ( - IdentityNumber, - PublicKey, - AuthnMethodSecuritySettings, - ) -> (variant { Ok; Err : AuthnMethodSecuritySettingsReplaceError }); - captcha_create : () -> (variant { Ok : Challenge; Err }); - create_challenge : () -> (Challenge); - deploy_archive : (vec nat8) -> (DeployArchiveResult); - enter_device_registration_mode : (UserNumber) -> (Timestamp); - exit_device_registration_mode : (UserNumber) -> (); - fetch_entries : () -> (vec BufferedArchiveEntry); - get_anchor_credentials : (UserNumber) -> (AnchorCredentials) query; - get_anchor_info : (UserNumber) -> (IdentityAnchorInfo); - get_delegation : (UserNumber, FrontendHostname, SessionKey, Timestamp) -> ( - GetDelegationResponse, - ) query; - get_id_alias : (GetIdAliasRequest) -> ( - variant { Ok : IdAliasCredentials; Err : GetIdAliasError }, - ) query; - get_principal : (UserNumber, FrontendHostname) -> (principal) query; - http_request : (HttpRequest) -> (HttpResponse) query; - http_request_update : (HttpRequest) -> (HttpResponse); - identity_authn_info : (IdentityNumber) -> ( - variant { Ok : IdentityAuthnInfo; Err }, - ) query; - identity_info : (IdentityNumber) -> ( - variant { Ok : IdentityInfo; Err : IdentityInfoError }, - ); - identity_metadata_replace : (IdentityNumber, MetadataMapV2) -> ( - variant { Ok; Err : IdentityMetadataReplaceError }, - ); - identity_register : (AuthnMethodData, CaptchaResult, opt principal) -> ( - variant { Ok : IdentityNumber; Err : IdentityRegisterError }, - ); - init_salt : () -> (); - lookup : (UserNumber) -> (vec DeviceData) query; - prepare_delegation : ( - UserNumber, - FrontendHostname, - SessionKey, - opt nat64, - ) -> (UserKey, Timestamp); - prepare_id_alias : (PrepareIdAliasRequest) -> ( - variant { Ok : PreparedIdAlias; Err : PrepareIdAliasError }, - ); - register : (DeviceData, ChallengeResult, opt principal) -> (RegisterResponse); - remove : (UserNumber, DeviceKey) -> (); - replace : (UserNumber, DeviceKey, DeviceData) -> (); - stats : () -> (InternetIdentityStats) query; - update : (UserNumber, DeviceKey, DeviceData) -> (); - verify_tentative_device : (UserNumber, text) -> ( - VerifyTentativeDeviceResponse, - ); -} \ No newline at end of file diff --git a/.dfx/local/canisters/internet_identity/service.did.d.ts b/.dfx/local/canisters/internet_identity/service.did.d.ts deleted file mode 100644 index 1eac5713..00000000 --- a/.dfx/local/canisters/internet_identity/service.did.d.ts +++ /dev/null @@ -1,392 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export type AddTentativeDeviceResponse = { - 'device_registration_mode_off' : null - } | - { 'another_device_tentatively_added' : null } | - { - 'added_tentatively' : { - 'verification_code' : string, - 'device_registration_timeout' : Timestamp, - } - }; -export interface AnchorCredentials { - 'recovery_phrases' : Array, - 'credentials' : Array, - 'recovery_credentials' : Array, -} -export interface ArchiveConfig { - 'polling_interval_ns' : bigint, - 'entries_buffer_limit' : bigint, - 'module_hash' : Uint8Array | number[], - 'entries_fetch_limit' : number, -} -export interface ArchiveInfo { - 'archive_config' : [] | [ArchiveConfig], - 'archive_canister' : [] | [Principal], -} -export type AuthnMethod = { 'PubKey' : PublicKeyAuthn } | - { 'WebAuthn' : WebAuthn }; -export type AuthnMethodAddError = { 'InvalidMetadata' : string }; -export interface AuthnMethodConfirmationCode { - 'confirmation_code' : string, - 'expiration' : Timestamp, -} -export type AuthnMethodConfirmationError = { 'RegistrationModeOff' : null } | - { 'NoAuthnMethodToConfirm' : null } | - { 'WrongCode' : { 'retries_left' : number } }; -export interface AuthnMethodData { - 'security_settings' : AuthnMethodSecuritySettings, - 'metadata' : MetadataMapV2, - 'last_authentication' : [] | [Timestamp], - 'authn_method' : AuthnMethod, -} -export type AuthnMethodMetadataReplaceError = { 'AuthnMethodNotFound' : null } | - { 'InvalidMetadata' : string }; -export type AuthnMethodProtection = { 'Protected' : null } | - { 'Unprotected' : null }; -export type AuthnMethodPurpose = { 'Recovery' : null } | - { 'Authentication' : null }; -export type AuthnMethodRegisterError = { 'RegistrationModeOff' : null } | - { 'RegistrationAlreadyInProgress' : null } | - { 'InvalidMetadata' : string }; -export interface AuthnMethodRegistrationInfo { - 'expiration' : Timestamp, - 'authn_method' : [] | [AuthnMethodData], -} -export type AuthnMethodReplaceError = { 'AuthnMethodNotFound' : null } | - { 'InvalidMetadata' : string }; -export interface AuthnMethodSecuritySettings { - 'protection' : AuthnMethodProtection, - 'purpose' : AuthnMethodPurpose, -} -export type AuthnMethodSecuritySettingsReplaceError = { - 'AuthnMethodNotFound' : null - }; -export interface BufferedArchiveEntry { - 'sequence_number' : bigint, - 'entry' : Uint8Array | number[], - 'anchor_number' : UserNumber, - 'timestamp' : Timestamp, -} -export type CaptchaResult = ChallengeResult; -export interface Challenge { - 'png_base64' : string, - 'challenge_key' : ChallengeKey, -} -export type ChallengeKey = string; -export interface ChallengeResult { 'key' : ChallengeKey, 'chars' : string } -export type CredentialId = Uint8Array | number[]; -export interface Delegation { - 'pubkey' : PublicKey, - 'targets' : [] | [Array], - 'expiration' : Timestamp, -} -export type DeployArchiveResult = { 'creation_in_progress' : null } | - { 'success' : Principal } | - { 'failed' : string }; -export interface DeviceData { - 'alias' : string, - 'metadata' : [] | [MetadataMap], - 'origin' : [] | [string], - 'protection' : DeviceProtection, - 'pubkey' : DeviceKey, - 'key_type' : KeyType, - 'purpose' : Purpose, - 'credential_id' : [] | [CredentialId], -} -export type DeviceKey = PublicKey; -export type DeviceProtection = { 'unprotected' : null } | - { 'protected' : null }; -export interface DeviceRegistrationInfo { - 'tentative_device' : [] | [DeviceData], - 'expiration' : Timestamp, -} -export interface DeviceWithUsage { - 'alias' : string, - 'last_usage' : [] | [Timestamp], - 'metadata' : [] | [MetadataMap], - 'origin' : [] | [string], - 'protection' : DeviceProtection, - 'pubkey' : DeviceKey, - 'key_type' : KeyType, - 'purpose' : Purpose, - 'credential_id' : [] | [CredentialId], -} -export type FrontendHostname = string; -export type GetDelegationResponse = { 'no_such_delegation' : null } | - { 'signed_delegation' : SignedDelegation }; -export type GetIdAliasError = { 'InternalCanisterError' : string } | - { 'Unauthorized' : Principal } | - { 'NoSuchCredentials' : string }; -export interface GetIdAliasRequest { - 'rp_id_alias_jwt' : string, - 'issuer' : FrontendHostname, - 'issuer_id_alias_jwt' : string, - 'relying_party' : FrontendHostname, - 'identity_number' : IdentityNumber, -} -export type HeaderField = [string, string]; -export interface HttpRequest { - 'url' : string, - 'method' : string, - 'body' : Uint8Array | number[], - 'headers' : Array, - 'certificate_version' : [] | [number], -} -export interface HttpResponse { - 'body' : Uint8Array | number[], - 'headers' : Array, - 'upgrade' : [] | [boolean], - 'streaming_strategy' : [] | [StreamingStrategy], - 'status_code' : number, -} -export interface IdAliasCredentials { - 'rp_id_alias_credential' : SignedIdAlias, - 'issuer_id_alias_credential' : SignedIdAlias, -} -export interface IdentityAnchorInfo { - 'devices' : Array, - 'device_registration' : [] | [DeviceRegistrationInfo], -} -export interface IdentityAuthnInfo { - 'authn_methods' : Array, - 'recovery_authn_methods' : Array, -} -export interface IdentityInfo { - 'authn_methods' : Array, - 'metadata' : MetadataMapV2, - 'authn_method_registration' : [] | [AuthnMethodRegistrationInfo], -} -export type IdentityInfoError = { 'InternalCanisterError' : string } | - { 'Unauthorized' : Principal }; -export type IdentityMetadataReplaceError = { - 'InternalCanisterError' : string - } | - { 'Unauthorized' : Principal } | - { - 'StorageSpaceExceeded' : { - 'space_required' : bigint, - 'space_available' : bigint, - } - }; -export type IdentityNumber = bigint; -export type IdentityRegisterError = { 'BadCaptcha' : null } | - { 'CanisterFull' : null } | - { 'InvalidMetadata' : string }; -export interface InternetIdentityInit { - 'max_num_latest_delegation_origins' : [] | [bigint], - 'assigned_user_number_range' : [] | [[bigint, bigint]], - 'max_inflight_captchas' : [] | [bigint], - 'archive_config' : [] | [ArchiveConfig], - 'canister_creation_cycles_cost' : [] | [bigint], - 'register_rate_limit' : [] | [RateLimitConfig], -} -export interface InternetIdentityStats { - 'storage_layout_version' : number, - 'users_registered' : bigint, - 'max_num_latest_delegation_origins' : bigint, - 'assigned_user_number_range' : [bigint, bigint], - 'latest_delegation_origins' : Array, - 'archive_info' : ArchiveInfo, - 'canister_creation_cycles_cost' : bigint, -} -export type KeyType = { 'platform' : null } | - { 'seed_phrase' : null } | - { 'cross_platform' : null } | - { 'unknown' : null } | - { 'browser_storage_key' : null }; -export type MetadataMap = Array< - [ - string, - { 'map' : MetadataMap } | - { 'string' : string } | - { 'bytes' : Uint8Array | number[] }, - ] ->; -export type MetadataMapV2 = Array< - [ - string, - { 'Map' : MetadataMapV2 } | - { 'String' : string } | - { 'Bytes' : Uint8Array | number[] }, - ] ->; -export type PrepareIdAliasError = { 'InternalCanisterError' : string } | - { 'Unauthorized' : Principal }; -export interface PrepareIdAliasRequest { - 'issuer' : FrontendHostname, - 'relying_party' : FrontendHostname, - 'identity_number' : IdentityNumber, -} -export interface PreparedIdAlias { - 'rp_id_alias_jwt' : string, - 'issuer_id_alias_jwt' : string, - 'canister_sig_pk_der' : PublicKey, -} -export type PublicKey = Uint8Array | number[]; -export interface PublicKeyAuthn { 'pubkey' : PublicKey } -export type Purpose = { 'authentication' : null } | - { 'recovery' : null }; -export interface RateLimitConfig { - 'max_tokens' : bigint, - 'time_per_token_ns' : bigint, -} -export type RegisterResponse = { 'bad_challenge' : null } | - { 'canister_full' : null } | - { 'registered' : { 'user_number' : UserNumber } }; -export type SessionKey = PublicKey; -export interface SignedDelegation { - 'signature' : Uint8Array | number[], - 'delegation' : Delegation, -} -export interface SignedIdAlias { - 'credential_jws' : string, - 'id_alias' : Principal, - 'id_dapp' : Principal, -} -export interface StreamingCallbackHttpResponse { - 'token' : [] | [Token], - 'body' : Uint8Array | number[], -} -export type StreamingStrategy = { - 'Callback' : { 'token' : Token, 'callback' : [Principal, string] } - }; -export type Timestamp = bigint; -export type Token = {}; -export type UserKey = PublicKey; -export type UserNumber = bigint; -export type VerifyTentativeDeviceResponse = { - 'device_registration_mode_off' : null - } | - { 'verified' : null } | - { 'wrong_code' : { 'retries_left' : number } } | - { 'no_device_to_verify' : null }; -export interface WebAuthn { - 'pubkey' : PublicKey, - 'credential_id' : CredentialId, -} -export interface WebAuthnCredential { - 'pubkey' : PublicKey, - 'credential_id' : CredentialId, -} -export interface _SERVICE { - 'acknowledge_entries' : ActorMethod<[bigint], undefined>, - 'add' : ActorMethod<[UserNumber, DeviceData], undefined>, - 'add_tentative_device' : ActorMethod< - [UserNumber, DeviceData], - AddTentativeDeviceResponse - >, - 'authn_method_add' : ActorMethod< - [IdentityNumber, AuthnMethodData], - { 'Ok' : null } | - { 'Err' : AuthnMethodAddError } - >, - 'authn_method_confirm' : ActorMethod< - [IdentityNumber, string], - { 'Ok' : null } | - { 'Err' : AuthnMethodConfirmationError } - >, - 'authn_method_metadata_replace' : ActorMethod< - [IdentityNumber, PublicKey, MetadataMapV2], - { 'Ok' : null } | - { 'Err' : AuthnMethodMetadataReplaceError } - >, - 'authn_method_register' : ActorMethod< - [IdentityNumber, AuthnMethodData], - { 'Ok' : AuthnMethodConfirmationCode } | - { 'Err' : AuthnMethodRegisterError } - >, - 'authn_method_registration_mode_enter' : ActorMethod< - [IdentityNumber], - { 'Ok' : { 'expiration' : Timestamp } } | - { 'Err' : null } - >, - 'authn_method_registration_mode_exit' : ActorMethod< - [IdentityNumber], - { 'Ok' : null } | - { 'Err' : null } - >, - 'authn_method_remove' : ActorMethod< - [IdentityNumber, PublicKey], - { 'Ok' : null } | - { 'Err' : null } - >, - 'authn_method_replace' : ActorMethod< - [IdentityNumber, PublicKey, AuthnMethodData], - { 'Ok' : null } | - { 'Err' : AuthnMethodReplaceError } - >, - 'authn_method_security_settings_replace' : ActorMethod< - [IdentityNumber, PublicKey, AuthnMethodSecuritySettings], - { 'Ok' : null } | - { 'Err' : AuthnMethodSecuritySettingsReplaceError } - >, - 'captcha_create' : ActorMethod<[], { 'Ok' : Challenge } | { 'Err' : null }>, - 'create_challenge' : ActorMethod<[], Challenge>, - 'deploy_archive' : ActorMethod<[Uint8Array | number[]], DeployArchiveResult>, - 'enter_device_registration_mode' : ActorMethod<[UserNumber], Timestamp>, - 'exit_device_registration_mode' : ActorMethod<[UserNumber], undefined>, - 'fetch_entries' : ActorMethod<[], Array>, - 'get_anchor_credentials' : ActorMethod<[UserNumber], AnchorCredentials>, - 'get_anchor_info' : ActorMethod<[UserNumber], IdentityAnchorInfo>, - 'get_delegation' : ActorMethod< - [UserNumber, FrontendHostname, SessionKey, Timestamp], - GetDelegationResponse - >, - 'get_id_alias' : ActorMethod< - [GetIdAliasRequest], - { 'Ok' : IdAliasCredentials } | - { 'Err' : GetIdAliasError } - >, - 'get_principal' : ActorMethod<[UserNumber, FrontendHostname], Principal>, - 'http_request' : ActorMethod<[HttpRequest], HttpResponse>, - 'http_request_update' : ActorMethod<[HttpRequest], HttpResponse>, - 'identity_authn_info' : ActorMethod< - [IdentityNumber], - { 'Ok' : IdentityAuthnInfo } | - { 'Err' : null } - >, - 'identity_info' : ActorMethod< - [IdentityNumber], - { 'Ok' : IdentityInfo } | - { 'Err' : IdentityInfoError } - >, - 'identity_metadata_replace' : ActorMethod< - [IdentityNumber, MetadataMapV2], - { 'Ok' : null } | - { 'Err' : IdentityMetadataReplaceError } - >, - 'identity_register' : ActorMethod< - [AuthnMethodData, CaptchaResult, [] | [Principal]], - { 'Ok' : IdentityNumber } | - { 'Err' : IdentityRegisterError } - >, - 'init_salt' : ActorMethod<[], undefined>, - 'lookup' : ActorMethod<[UserNumber], Array>, - 'prepare_delegation' : ActorMethod< - [UserNumber, FrontendHostname, SessionKey, [] | [bigint]], - [UserKey, Timestamp] - >, - 'prepare_id_alias' : ActorMethod< - [PrepareIdAliasRequest], - { 'Ok' : PreparedIdAlias } | - { 'Err' : PrepareIdAliasError } - >, - 'register' : ActorMethod< - [DeviceData, ChallengeResult, [] | [Principal]], - RegisterResponse - >, - 'remove' : ActorMethod<[UserNumber, DeviceKey], undefined>, - 'replace' : ActorMethod<[UserNumber, DeviceKey, DeviceData], undefined>, - 'stats' : ActorMethod<[], InternetIdentityStats>, - 'update' : ActorMethod<[UserNumber, DeviceKey, DeviceData], undefined>, - 'verify_tentative_device' : ActorMethod< - [UserNumber, string], - VerifyTentativeDeviceResponse - >, -} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; diff --git a/.dfx/local/canisters/internet_identity/service.did.js b/.dfx/local/canisters/internet_identity/service.did.js deleted file mode 100644 index e92c6719..00000000 --- a/.dfx/local/canisters/internet_identity/service.did.js +++ /dev/null @@ -1,474 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const MetadataMap = IDL.Rec(); - const MetadataMapV2 = IDL.Rec(); - const UserNumber = IDL.Nat64; - MetadataMap.fill( - IDL.Vec( - IDL.Tuple( - IDL.Text, - IDL.Variant({ - 'map' : MetadataMap, - 'string' : IDL.Text, - 'bytes' : IDL.Vec(IDL.Nat8), - }), - ) - ) - ); - const DeviceProtection = IDL.Variant({ - 'unprotected' : IDL.Null, - 'protected' : IDL.Null, - }); - const PublicKey = IDL.Vec(IDL.Nat8); - const DeviceKey = PublicKey; - const KeyType = IDL.Variant({ - 'platform' : IDL.Null, - 'seed_phrase' : IDL.Null, - 'cross_platform' : IDL.Null, - 'unknown' : IDL.Null, - 'browser_storage_key' : IDL.Null, - }); - const Purpose = IDL.Variant({ - 'authentication' : IDL.Null, - 'recovery' : IDL.Null, - }); - const CredentialId = IDL.Vec(IDL.Nat8); - const DeviceData = IDL.Record({ - 'alias' : IDL.Text, - 'metadata' : IDL.Opt(MetadataMap), - 'origin' : IDL.Opt(IDL.Text), - 'protection' : DeviceProtection, - 'pubkey' : DeviceKey, - 'key_type' : KeyType, - 'purpose' : Purpose, - 'credential_id' : IDL.Opt(CredentialId), - }); - const Timestamp = IDL.Nat64; - const AddTentativeDeviceResponse = IDL.Variant({ - 'device_registration_mode_off' : IDL.Null, - 'another_device_tentatively_added' : IDL.Null, - 'added_tentatively' : IDL.Record({ - 'verification_code' : IDL.Text, - 'device_registration_timeout' : Timestamp, - }), - }); - const IdentityNumber = IDL.Nat64; - const AuthnMethodProtection = IDL.Variant({ - 'Protected' : IDL.Null, - 'Unprotected' : IDL.Null, - }); - const AuthnMethodPurpose = IDL.Variant({ - 'Recovery' : IDL.Null, - 'Authentication' : IDL.Null, - }); - const AuthnMethodSecuritySettings = IDL.Record({ - 'protection' : AuthnMethodProtection, - 'purpose' : AuthnMethodPurpose, - }); - MetadataMapV2.fill( - IDL.Vec( - IDL.Tuple( - IDL.Text, - IDL.Variant({ - 'Map' : MetadataMapV2, - 'String' : IDL.Text, - 'Bytes' : IDL.Vec(IDL.Nat8), - }), - ) - ) - ); - const PublicKeyAuthn = IDL.Record({ 'pubkey' : PublicKey }); - const WebAuthn = IDL.Record({ - 'pubkey' : PublicKey, - 'credential_id' : CredentialId, - }); - const AuthnMethod = IDL.Variant({ - 'PubKey' : PublicKeyAuthn, - 'WebAuthn' : WebAuthn, - }); - const AuthnMethodData = IDL.Record({ - 'security_settings' : AuthnMethodSecuritySettings, - 'metadata' : MetadataMapV2, - 'last_authentication' : IDL.Opt(Timestamp), - 'authn_method' : AuthnMethod, - }); - const AuthnMethodAddError = IDL.Variant({ 'InvalidMetadata' : IDL.Text }); - const AuthnMethodConfirmationError = IDL.Variant({ - 'RegistrationModeOff' : IDL.Null, - 'NoAuthnMethodToConfirm' : IDL.Null, - 'WrongCode' : IDL.Record({ 'retries_left' : IDL.Nat8 }), - }); - const AuthnMethodMetadataReplaceError = IDL.Variant({ - 'AuthnMethodNotFound' : IDL.Null, - 'InvalidMetadata' : IDL.Text, - }); - const AuthnMethodConfirmationCode = IDL.Record({ - 'confirmation_code' : IDL.Text, - 'expiration' : Timestamp, - }); - const AuthnMethodRegisterError = IDL.Variant({ - 'RegistrationModeOff' : IDL.Null, - 'RegistrationAlreadyInProgress' : IDL.Null, - 'InvalidMetadata' : IDL.Text, - }); - const AuthnMethodReplaceError = IDL.Variant({ - 'AuthnMethodNotFound' : IDL.Null, - 'InvalidMetadata' : IDL.Text, - }); - const AuthnMethodSecuritySettingsReplaceError = IDL.Variant({ - 'AuthnMethodNotFound' : IDL.Null, - }); - const ChallengeKey = IDL.Text; - const Challenge = IDL.Record({ - 'png_base64' : IDL.Text, - 'challenge_key' : ChallengeKey, - }); - const DeployArchiveResult = IDL.Variant({ - 'creation_in_progress' : IDL.Null, - 'success' : IDL.Principal, - 'failed' : IDL.Text, - }); - const BufferedArchiveEntry = IDL.Record({ - 'sequence_number' : IDL.Nat64, - 'entry' : IDL.Vec(IDL.Nat8), - 'anchor_number' : UserNumber, - 'timestamp' : Timestamp, - }); - const WebAuthnCredential = IDL.Record({ - 'pubkey' : PublicKey, - 'credential_id' : CredentialId, - }); - const AnchorCredentials = IDL.Record({ - 'recovery_phrases' : IDL.Vec(PublicKey), - 'credentials' : IDL.Vec(WebAuthnCredential), - 'recovery_credentials' : IDL.Vec(WebAuthnCredential), - }); - const DeviceWithUsage = IDL.Record({ - 'alias' : IDL.Text, - 'last_usage' : IDL.Opt(Timestamp), - 'metadata' : IDL.Opt(MetadataMap), - 'origin' : IDL.Opt(IDL.Text), - 'protection' : DeviceProtection, - 'pubkey' : DeviceKey, - 'key_type' : KeyType, - 'purpose' : Purpose, - 'credential_id' : IDL.Opt(CredentialId), - }); - const DeviceRegistrationInfo = IDL.Record({ - 'tentative_device' : IDL.Opt(DeviceData), - 'expiration' : Timestamp, - }); - const IdentityAnchorInfo = IDL.Record({ - 'devices' : IDL.Vec(DeviceWithUsage), - 'device_registration' : IDL.Opt(DeviceRegistrationInfo), - }); - const FrontendHostname = IDL.Text; - const SessionKey = PublicKey; - const Delegation = IDL.Record({ - 'pubkey' : PublicKey, - 'targets' : IDL.Opt(IDL.Vec(IDL.Principal)), - 'expiration' : Timestamp, - }); - const SignedDelegation = IDL.Record({ - 'signature' : IDL.Vec(IDL.Nat8), - 'delegation' : Delegation, - }); - const GetDelegationResponse = IDL.Variant({ - 'no_such_delegation' : IDL.Null, - 'signed_delegation' : SignedDelegation, - }); - const GetIdAliasRequest = IDL.Record({ - 'rp_id_alias_jwt' : IDL.Text, - 'issuer' : FrontendHostname, - 'issuer_id_alias_jwt' : IDL.Text, - 'relying_party' : FrontendHostname, - 'identity_number' : IdentityNumber, - }); - const SignedIdAlias = IDL.Record({ - 'credential_jws' : IDL.Text, - 'id_alias' : IDL.Principal, - 'id_dapp' : IDL.Principal, - }); - const IdAliasCredentials = IDL.Record({ - 'rp_id_alias_credential' : SignedIdAlias, - 'issuer_id_alias_credential' : SignedIdAlias, - }); - const GetIdAliasError = IDL.Variant({ - 'InternalCanisterError' : IDL.Text, - 'Unauthorized' : IDL.Principal, - 'NoSuchCredentials' : IDL.Text, - }); - const HeaderField = IDL.Tuple(IDL.Text, IDL.Text); - const HttpRequest = IDL.Record({ - 'url' : IDL.Text, - 'method' : IDL.Text, - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(HeaderField), - 'certificate_version' : IDL.Opt(IDL.Nat16), - }); - const Token = IDL.Record({}); - const StreamingCallbackHttpResponse = IDL.Record({ - 'token' : IDL.Opt(Token), - 'body' : IDL.Vec(IDL.Nat8), - }); - const StreamingStrategy = IDL.Variant({ - 'Callback' : IDL.Record({ - 'token' : Token, - 'callback' : IDL.Func( - [Token], - [StreamingCallbackHttpResponse], - ['query'], - ), - }), - }); - const HttpResponse = IDL.Record({ - 'body' : IDL.Vec(IDL.Nat8), - 'headers' : IDL.Vec(HeaderField), - 'upgrade' : IDL.Opt(IDL.Bool), - 'streaming_strategy' : IDL.Opt(StreamingStrategy), - 'status_code' : IDL.Nat16, - }); - const IdentityAuthnInfo = IDL.Record({ - 'authn_methods' : IDL.Vec(AuthnMethod), - 'recovery_authn_methods' : IDL.Vec(AuthnMethod), - }); - const AuthnMethodRegistrationInfo = IDL.Record({ - 'expiration' : Timestamp, - 'authn_method' : IDL.Opt(AuthnMethodData), - }); - const IdentityInfo = IDL.Record({ - 'authn_methods' : IDL.Vec(AuthnMethodData), - 'metadata' : MetadataMapV2, - 'authn_method_registration' : IDL.Opt(AuthnMethodRegistrationInfo), - }); - const IdentityInfoError = IDL.Variant({ - 'InternalCanisterError' : IDL.Text, - 'Unauthorized' : IDL.Principal, - }); - const IdentityMetadataReplaceError = IDL.Variant({ - 'InternalCanisterError' : IDL.Text, - 'Unauthorized' : IDL.Principal, - 'StorageSpaceExceeded' : IDL.Record({ - 'space_required' : IDL.Nat64, - 'space_available' : IDL.Nat64, - }), - }); - const ChallengeResult = IDL.Record({ - 'key' : ChallengeKey, - 'chars' : IDL.Text, - }); - const CaptchaResult = ChallengeResult; - const IdentityRegisterError = IDL.Variant({ - 'BadCaptcha' : IDL.Null, - 'CanisterFull' : IDL.Null, - 'InvalidMetadata' : IDL.Text, - }); - const UserKey = PublicKey; - const PrepareIdAliasRequest = IDL.Record({ - 'issuer' : FrontendHostname, - 'relying_party' : FrontendHostname, - 'identity_number' : IdentityNumber, - }); - const PreparedIdAlias = IDL.Record({ - 'rp_id_alias_jwt' : IDL.Text, - 'issuer_id_alias_jwt' : IDL.Text, - 'canister_sig_pk_der' : PublicKey, - }); - const PrepareIdAliasError = IDL.Variant({ - 'InternalCanisterError' : IDL.Text, - 'Unauthorized' : IDL.Principal, - }); - const RegisterResponse = IDL.Variant({ - 'bad_challenge' : IDL.Null, - 'canister_full' : IDL.Null, - 'registered' : IDL.Record({ 'user_number' : UserNumber }), - }); - const ArchiveConfig = IDL.Record({ - 'polling_interval_ns' : IDL.Nat64, - 'entries_buffer_limit' : IDL.Nat64, - 'module_hash' : IDL.Vec(IDL.Nat8), - 'entries_fetch_limit' : IDL.Nat16, - }); - const ArchiveInfo = IDL.Record({ - 'archive_config' : IDL.Opt(ArchiveConfig), - 'archive_canister' : IDL.Opt(IDL.Principal), - }); - const InternetIdentityStats = IDL.Record({ - 'storage_layout_version' : IDL.Nat8, - 'users_registered' : IDL.Nat64, - 'max_num_latest_delegation_origins' : IDL.Nat64, - 'assigned_user_number_range' : IDL.Tuple(IDL.Nat64, IDL.Nat64), - 'latest_delegation_origins' : IDL.Vec(FrontendHostname), - 'archive_info' : ArchiveInfo, - 'canister_creation_cycles_cost' : IDL.Nat64, - }); - const VerifyTentativeDeviceResponse = IDL.Variant({ - 'device_registration_mode_off' : IDL.Null, - 'verified' : IDL.Null, - 'wrong_code' : IDL.Record({ 'retries_left' : IDL.Nat8 }), - 'no_device_to_verify' : IDL.Null, - }); - return IDL.Service({ - 'acknowledge_entries' : IDL.Func([IDL.Nat64], [], []), - 'add' : IDL.Func([UserNumber, DeviceData], [], []), - 'add_tentative_device' : IDL.Func( - [UserNumber, DeviceData], - [AddTentativeDeviceResponse], - [], - ), - 'authn_method_add' : IDL.Func( - [IdentityNumber, AuthnMethodData], - [IDL.Variant({ 'Ok' : IDL.Null, 'Err' : AuthnMethodAddError })], - [], - ), - 'authn_method_confirm' : IDL.Func( - [IdentityNumber, IDL.Text], - [ - IDL.Variant({ - 'Ok' : IDL.Null, - 'Err' : AuthnMethodConfirmationError, - }), - ], - [], - ), - 'authn_method_metadata_replace' : IDL.Func( - [IdentityNumber, PublicKey, MetadataMapV2], - [ - IDL.Variant({ - 'Ok' : IDL.Null, - 'Err' : AuthnMethodMetadataReplaceError, - }), - ], - [], - ), - 'authn_method_register' : IDL.Func( - [IdentityNumber, AuthnMethodData], - [ - IDL.Variant({ - 'Ok' : AuthnMethodConfirmationCode, - 'Err' : AuthnMethodRegisterError, - }), - ], - [], - ), - 'authn_method_registration_mode_enter' : IDL.Func( - [IdentityNumber], - [ - IDL.Variant({ - 'Ok' : IDL.Record({ 'expiration' : Timestamp }), - 'Err' : IDL.Null, - }), - ], - [], - ), - 'authn_method_registration_mode_exit' : IDL.Func( - [IdentityNumber], - [IDL.Variant({ 'Ok' : IDL.Null, 'Err' : IDL.Null })], - [], - ), - 'authn_method_remove' : IDL.Func( - [IdentityNumber, PublicKey], - [IDL.Variant({ 'Ok' : IDL.Null, 'Err' : IDL.Null })], - [], - ), - 'authn_method_replace' : IDL.Func( - [IdentityNumber, PublicKey, AuthnMethodData], - [IDL.Variant({ 'Ok' : IDL.Null, 'Err' : AuthnMethodReplaceError })], - [], - ), - 'authn_method_security_settings_replace' : IDL.Func( - [IdentityNumber, PublicKey, AuthnMethodSecuritySettings], - [ - IDL.Variant({ - 'Ok' : IDL.Null, - 'Err' : AuthnMethodSecuritySettingsReplaceError, - }), - ], - [], - ), - 'captcha_create' : IDL.Func( - [], - [IDL.Variant({ 'Ok' : Challenge, 'Err' : IDL.Null })], - [], - ), - 'create_challenge' : IDL.Func([], [Challenge], []), - 'deploy_archive' : IDL.Func([IDL.Vec(IDL.Nat8)], [DeployArchiveResult], []), - 'enter_device_registration_mode' : IDL.Func([UserNumber], [Timestamp], []), - 'exit_device_registration_mode' : IDL.Func([UserNumber], [], []), - 'fetch_entries' : IDL.Func([], [IDL.Vec(BufferedArchiveEntry)], []), - 'get_anchor_credentials' : IDL.Func( - [UserNumber], - [AnchorCredentials], - ['query'], - ), - 'get_anchor_info' : IDL.Func([UserNumber], [IdentityAnchorInfo], []), - 'get_delegation' : IDL.Func( - [UserNumber, FrontendHostname, SessionKey, Timestamp], - [GetDelegationResponse], - ['query'], - ), - 'get_id_alias' : IDL.Func( - [GetIdAliasRequest], - [IDL.Variant({ 'Ok' : IdAliasCredentials, 'Err' : GetIdAliasError })], - ['query'], - ), - 'get_principal' : IDL.Func( - [UserNumber, FrontendHostname], - [IDL.Principal], - ['query'], - ), - 'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']), - 'http_request_update' : IDL.Func([HttpRequest], [HttpResponse], []), - 'identity_authn_info' : IDL.Func( - [IdentityNumber], - [IDL.Variant({ 'Ok' : IdentityAuthnInfo, 'Err' : IDL.Null })], - ['query'], - ), - 'identity_info' : IDL.Func( - [IdentityNumber], - [IDL.Variant({ 'Ok' : IdentityInfo, 'Err' : IdentityInfoError })], - [], - ), - 'identity_metadata_replace' : IDL.Func( - [IdentityNumber, MetadataMapV2], - [ - IDL.Variant({ - 'Ok' : IDL.Null, - 'Err' : IdentityMetadataReplaceError, - }), - ], - [], - ), - 'identity_register' : IDL.Func( - [AuthnMethodData, CaptchaResult, IDL.Opt(IDL.Principal)], - [IDL.Variant({ 'Ok' : IdentityNumber, 'Err' : IdentityRegisterError })], - [], - ), - 'init_salt' : IDL.Func([], [], []), - 'lookup' : IDL.Func([UserNumber], [IDL.Vec(DeviceData)], ['query']), - 'prepare_delegation' : IDL.Func( - [UserNumber, FrontendHostname, SessionKey, IDL.Opt(IDL.Nat64)], - [UserKey, Timestamp], - [], - ), - 'prepare_id_alias' : IDL.Func( - [PrepareIdAliasRequest], - [IDL.Variant({ 'Ok' : PreparedIdAlias, 'Err' : PrepareIdAliasError })], - [], - ), - 'register' : IDL.Func( - [DeviceData, ChallengeResult, IDL.Opt(IDL.Principal)], - [RegisterResponse], - [], - ), - 'remove' : IDL.Func([UserNumber, DeviceKey], [], []), - 'replace' : IDL.Func([UserNumber, DeviceKey, DeviceData], [], []), - 'stats' : IDL.Func([], [InternetIdentityStats], ['query']), - 'update' : IDL.Func([UserNumber, DeviceKey, DeviceData], [], []), - 'verify_tentative_device' : IDL.Func( - [UserNumber, IDL.Text], - [VerifyTentativeDeviceResponse], - [], - ), - }); -}; -export const init = ({ IDL }) => { return []; }; diff --git a/.dfx/local/lsp/b77ix-eeaaa-aaaaa-qaada-cai.did b/.dfx/local/lsp/b77ix-eeaaa-aaaaa-qaada-cai.did deleted file mode 100644 index fd53d49c..00000000 --- a/.dfx/local/lsp/b77ix-eeaaa-aaaaa-qaada-cai.did +++ /dev/null @@ -1,356 +0,0 @@ -type AddTentativeDeviceResponse = variant { - device_registration_mode_off; - another_device_tentatively_added; - added_tentatively : record { - verification_code : text; - device_registration_timeout : Timestamp; - }; -}; -type AnchorCredentials = record { - recovery_phrases : vec PublicKey; - credentials : vec WebAuthnCredential; - recovery_credentials : vec WebAuthnCredential; -}; -type ArchiveConfig = record { - polling_interval_ns : nat64; - entries_buffer_limit : nat64; - module_hash : vec nat8; - entries_fetch_limit : nat16; -}; -type ArchiveInfo = record { - archive_config : opt ArchiveConfig; - archive_canister : opt principal; -}; -type AuthnMethod = variant { PubKey : PublicKeyAuthn; WebAuthn : WebAuthn }; -type AuthnMethodAddError = variant { InvalidMetadata : text }; -type AuthnMethodConfirmationCode = record { - confirmation_code : text; - expiration : Timestamp; -}; -type AuthnMethodConfirmationError = variant { - RegistrationModeOff; - NoAuthnMethodToConfirm; - WrongCode : record { retries_left : nat8 }; -}; -type AuthnMethodData = record { - security_settings : AuthnMethodSecuritySettings; - metadata : MetadataMapV2; - last_authentication : opt Timestamp; - authn_method : AuthnMethod; -}; -type AuthnMethodMetadataReplaceError = variant { - AuthnMethodNotFound; - InvalidMetadata : text; -}; -type AuthnMethodProtection = variant { Protected; Unprotected }; -type AuthnMethodPurpose = variant { Recovery; Authentication }; -type AuthnMethodRegisterError = variant { - RegistrationModeOff; - RegistrationAlreadyInProgress; - InvalidMetadata : text; -}; -type AuthnMethodRegistrationInfo = record { - expiration : Timestamp; - authn_method : opt AuthnMethodData; -}; -type AuthnMethodReplaceError = variant { - AuthnMethodNotFound; - InvalidMetadata : text; -}; -type AuthnMethodSecuritySettings = record { - protection : AuthnMethodProtection; - purpose : AuthnMethodPurpose; -}; -type AuthnMethodSecuritySettingsReplaceError = variant { AuthnMethodNotFound }; -type BufferedArchiveEntry = record { - sequence_number : nat64; - entry : vec nat8; - anchor_number : UserNumber; - timestamp : Timestamp; -}; -type CaptchaResult = ChallengeResult; -type Challenge = record { png_base64 : text; challenge_key : ChallengeKey }; -type ChallengeKey = text; -type ChallengeResult = record { key : ChallengeKey; chars : text }; -type CredentialId = vec nat8; -type Delegation = record { - pubkey : PublicKey; - targets : opt vec principal; - expiration : Timestamp; -}; -type DeployArchiveResult = variant { - creation_in_progress; - success : principal; - failed : text; -}; -type DeviceData = record { - alias : text; - metadata : opt MetadataMap; - origin : opt text; - protection : DeviceProtection; - pubkey : DeviceKey; - key_type : KeyType; - purpose : Purpose; - credential_id : opt CredentialId; -}; -type DeviceKey = PublicKey; -type DeviceProtection = variant { unprotected; protected }; -type DeviceRegistrationInfo = record { - tentative_device : opt DeviceData; - expiration : Timestamp; -}; -type DeviceWithUsage = record { - alias : text; - last_usage : opt Timestamp; - metadata : opt MetadataMap; - origin : opt text; - protection : DeviceProtection; - pubkey : DeviceKey; - key_type : KeyType; - purpose : Purpose; - credential_id : opt CredentialId; -}; -type FrontendHostname = text; -type GetDelegationResponse = variant { - no_such_delegation; - signed_delegation : SignedDelegation; -}; -type GetIdAliasError = variant { - InternalCanisterError : text; - Unauthorized : principal; - NoSuchCredentials : text; -}; -type GetIdAliasRequest = record { - rp_id_alias_jwt : text; - issuer : FrontendHostname; - issuer_id_alias_jwt : text; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; -type HeaderField = record { text; text }; -type HttpRequest = record { - url : text; - method : text; - body : vec nat8; - headers : vec HeaderField; - certificate_version : opt nat16; -}; -type HttpResponse = record { - body : vec nat8; - headers : vec HeaderField; - upgrade : opt bool; - streaming_strategy : opt StreamingStrategy; - status_code : nat16; -}; -type IdAliasCredentials = record { - rp_id_alias_credential : SignedIdAlias; - issuer_id_alias_credential : SignedIdAlias; -}; -type IdentityAnchorInfo = record { - devices : vec DeviceWithUsage; - device_registration : opt DeviceRegistrationInfo; -}; -type IdentityAuthnInfo = record { - authn_methods : vec AuthnMethod; - recovery_authn_methods : vec AuthnMethod; -}; -type IdentityInfo = record { - authn_methods : vec AuthnMethodData; - metadata : MetadataMapV2; - authn_method_registration : opt AuthnMethodRegistrationInfo; -}; -type IdentityInfoError = variant { - InternalCanisterError : text; - Unauthorized : principal; -}; -type IdentityMetadataReplaceError = variant { - InternalCanisterError : text; - Unauthorized : principal; - StorageSpaceExceeded : record { - space_required : nat64; - space_available : nat64; - }; -}; -type IdentityNumber = nat64; -type IdentityRegisterError = variant { - BadCaptcha; - CanisterFull; - InvalidMetadata : text; -}; -type InternetIdentityInit = record { - max_num_latest_delegation_origins : opt nat64; - assigned_user_number_range : opt record { nat64; nat64 }; - max_inflight_captchas : opt nat64; - archive_config : opt ArchiveConfig; - canister_creation_cycles_cost : opt nat64; - register_rate_limit : opt RateLimitConfig; -}; -type InternetIdentityStats = record { - storage_layout_version : nat8; - users_registered : nat64; - max_num_latest_delegation_origins : nat64; - assigned_user_number_range : record { nat64; nat64 }; - latest_delegation_origins : vec FrontendHostname; - archive_info : ArchiveInfo; - canister_creation_cycles_cost : nat64; -}; -type KeyType = variant { - platform; - seed_phrase; - cross_platform; - unknown; - browser_storage_key; -}; -type MetadataMap = vec record { - text; - variant { map : MetadataMap; string : text; bytes : vec nat8 }; -}; -type MetadataMapV2 = vec record { - text; - variant { Map : MetadataMapV2; String : text; Bytes : vec nat8 }; -}; -type PrepareIdAliasError = variant { - InternalCanisterError : text; - Unauthorized : principal; -}; -type PrepareIdAliasRequest = record { - issuer : FrontendHostname; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; -type PreparedIdAlias = record { - rp_id_alias_jwt : text; - issuer_id_alias_jwt : text; - canister_sig_pk_der : PublicKey; -}; -type PublicKey = vec nat8; -type PublicKeyAuthn = record { pubkey : PublicKey }; -type Purpose = variant { authentication; recovery }; -type RateLimitConfig = record { max_tokens : nat64; time_per_token_ns : nat64 }; -type RegisterResponse = variant { - bad_challenge; - canister_full; - registered : record { user_number : UserNumber }; -}; -type SessionKey = PublicKey; -type SignedDelegation = record { - signature : vec nat8; - delegation : Delegation; -}; -type SignedIdAlias = record { - credential_jws : text; - id_alias : principal; - id_dapp : principal; -}; -type StreamingCallbackHttpResponse = record { - token : opt Token; - body : vec nat8; -}; -type StreamingStrategy = variant { - Callback : record { - token : Token; - callback : func (Token) -> (StreamingCallbackHttpResponse) query; - }; -}; -type Timestamp = nat64; -type Token = record {}; -type UserKey = PublicKey; -type UserNumber = nat64; -type VerifyTentativeDeviceResponse = variant { - device_registration_mode_off; - verified; - wrong_code : record { retries_left : nat8 }; - no_device_to_verify; -}; -type WebAuthn = record { pubkey : PublicKey; credential_id : CredentialId }; -type WebAuthnCredential = record { - pubkey : PublicKey; - credential_id : CredentialId; -}; -service : { - acknowledge_entries : (nat64) -> (); - add : (UserNumber, DeviceData) -> (); - add_tentative_device : (UserNumber, DeviceData) -> ( - AddTentativeDeviceResponse, - ); - authn_method_add : (IdentityNumber, AuthnMethodData) -> ( - variant { Ok; Err : AuthnMethodAddError }, - ); - authn_method_confirm : (IdentityNumber, text) -> ( - variant { Ok; Err : AuthnMethodConfirmationError }, - ); - authn_method_metadata_replace : ( - IdentityNumber, - PublicKey, - MetadataMapV2, - ) -> (variant { Ok; Err : AuthnMethodMetadataReplaceError }); - authn_method_register : (IdentityNumber, AuthnMethodData) -> ( - variant { - Ok : AuthnMethodConfirmationCode; - Err : AuthnMethodRegisterError; - }, - ); - authn_method_registration_mode_enter : (IdentityNumber) -> ( - variant { Ok : record { expiration : Timestamp }; Err }, - ); - authn_method_registration_mode_exit : (IdentityNumber) -> ( - variant { Ok; Err }, - ); - authn_method_remove : (IdentityNumber, PublicKey) -> (variant { Ok; Err }); - authn_method_replace : (IdentityNumber, PublicKey, AuthnMethodData) -> ( - variant { Ok; Err : AuthnMethodReplaceError }, - ); - authn_method_security_settings_replace : ( - IdentityNumber, - PublicKey, - AuthnMethodSecuritySettings, - ) -> (variant { Ok; Err : AuthnMethodSecuritySettingsReplaceError }); - captcha_create : () -> (variant { Ok : Challenge; Err }); - create_challenge : () -> (Challenge); - deploy_archive : (vec nat8) -> (DeployArchiveResult); - enter_device_registration_mode : (UserNumber) -> (Timestamp); - exit_device_registration_mode : (UserNumber) -> (); - fetch_entries : () -> (vec BufferedArchiveEntry); - get_anchor_credentials : (UserNumber) -> (AnchorCredentials) query; - get_anchor_info : (UserNumber) -> (IdentityAnchorInfo); - get_delegation : (UserNumber, FrontendHostname, SessionKey, Timestamp) -> ( - GetDelegationResponse, - ) query; - get_id_alias : (GetIdAliasRequest) -> ( - variant { Ok : IdAliasCredentials; Err : GetIdAliasError }, - ) query; - get_principal : (UserNumber, FrontendHostname) -> (principal) query; - http_request : (HttpRequest) -> (HttpResponse) query; - http_request_update : (HttpRequest) -> (HttpResponse); - identity_authn_info : (IdentityNumber) -> ( - variant { Ok : IdentityAuthnInfo; Err }, - ) query; - identity_info : (IdentityNumber) -> ( - variant { Ok : IdentityInfo; Err : IdentityInfoError }, - ); - identity_metadata_replace : (IdentityNumber, MetadataMapV2) -> ( - variant { Ok; Err : IdentityMetadataReplaceError }, - ); - identity_register : (AuthnMethodData, CaptchaResult, opt principal) -> ( - variant { Ok : IdentityNumber; Err : IdentityRegisterError }, - ); - init_salt : () -> (); - lookup : (UserNumber) -> (vec DeviceData) query; - prepare_delegation : ( - UserNumber, - FrontendHostname, - SessionKey, - opt nat64, - ) -> (UserKey, Timestamp); - prepare_id_alias : (PrepareIdAliasRequest) -> ( - variant { Ok : PreparedIdAlias; Err : PrepareIdAliasError }, - ); - register : (DeviceData, ChallengeResult, opt principal) -> (RegisterResponse); - remove : (UserNumber, DeviceKey) -> (); - replace : (UserNumber, DeviceKey, DeviceData) -> (); - stats : () -> (InternetIdentityStats) query; - update : (UserNumber, DeviceKey, DeviceData) -> (); - verify_tentative_device : (UserNumber, text) -> ( - VerifyTentativeDeviceResponse, - ); -} \ No newline at end of file diff --git a/.dfx/local/lsp/bd3sg-teaaa-aaaaa-qaaba-cai.did b/.dfx/local/lsp/bd3sg-teaaa-aaaaa-qaaba-cai.did deleted file mode 100644 index 013ecd85..00000000 --- a/.dfx/local/lsp/bd3sg-teaaa-aaaaa-qaaba-cai.did +++ /dev/null @@ -1,263 +0,0 @@ -type Account = record { owner : principal; subaccount : opt Subaccount }; -type AccountIdentifier = variant { - "principal" : principal; - "blob" : vec nat8; - "text" : text; -}; -type AccountIdentifierToBlobErr = record { - kind : variant { InvalidAccountIdentifier; Other }; - message : opt text; -}; -type AccountIdentifierToBlobResult = variant { - ok : AccountIdentifierToBlobSuccess; - err : AccountIdentifierToBlobErr; -}; -type AccountIdentifierToBlobSuccess = vec nat8; -type Backend = service { - accountIdentifierToBlob : (AccountIdentifier) -> ( - AccountIdentifierToBlobResult, - ); - cancelRecurringTimer : (nat) -> (); - checkPayroll : () -> (); - create_employee : (CreateEmployeeArgs) -> (Response_4); - emailExists : (text) -> (bool) query; - getAddress : () -> (text); - getCanisterAddress : () -> (text); - getCanisterBalance : () -> (text); - getEmployeeByPrincipal : (principal) -> (Response_4); - getFundingAddress : () -> (text); - getFundingBalance : () -> (text); - getInvoice : () -> (Account); - getLogs : () -> (vec text) query; - getMyContacts : () -> (vec Employee); - getMyContactsLength : () -> (text); - getMyTransactionLength : () -> (text); - getNotifications : () -> (vec Notification__1); - getTradingAddress : () -> (text); - getTradingBalance : () -> (text); - getTransactionLength : () -> (text) query; - getUnreadNotifications : () -> (vec Notification__1); - getUnreadNotificationsLength : () -> (text); - getUser : () -> (Response) query; - getUserByPrincipal : (principal) -> (Response) query; - getUsersList : () -> (vec record { text; User }) query; - get_account_identifier : (GetAccountIdentifierArgs) -> ( - GetAccountIdentifierResult, - ) query; - get_transaction : (GetTransactionArgs) -> (GetTransactionResult) query; - get_transactions : () -> (vec Transaction) query; - isRegistered : () -> (bool) query; - remove_employee : (text) -> (Response_4); - runpayroll : (vec PayrollType__1) -> (Response_3); - save_notification : (CreateNotificationArgs) -> (CreateNotificationResult); - save_payroll : (SchedulePaymentsArgs) -> (SchedulePaymentsResult); - save_transaction : (CreateTransactionArgs) -> (CreateTransactionResult); - sendToOwner : (nat, text) -> (Result); - send_notifications : (text, text, text, text, text) -> (); - setCourierApiKey : (text) -> (Response_2); - setRecurringTimer : (nat) -> (nat); - transferFromCanistertoSubAccount : () -> (Result); - transferFromSubAccountToSubAccount : (text, nat) -> (Response_1); - transform : (TransformArgs) -> (CanisterHttpResponsePayload) query; - updateUser : (User) -> (Response); - userLength : () -> (text) query; - whoami : () -> (principal); -}; -type CanisterHttpResponsePayload = record { - status : nat; - body : vec nat8; - headers : vec HttpHeader; -}; -type CreateEmployeeArgs = record { - emp_type : text; - wallet : text; - access_type : text; -}; -type CreateNotificationArgs = record { - isRead : bool; - sender : text; - amount : nat; - receiver : text; -}; -type CreateNotificationErr = record { - kind : variant { InvalidNotification; Other }; - message : opt text; -}; -type CreateNotificationResult = variant { - ok : CreateNotificationSuccess; - err : CreateNotificationErr; -}; -type CreateNotificationSuccess = record { notification : Notification }; -type CreateTransactionArgs = record { - creator : principal; - destination : principal; - amount : nat; - successful : bool; -}; -type CreateTransactionErr = record { - kind : variant { - InvalidDetails; - InvalidAmount; - InvalidDestination; - MaxTransactionsReached; - InsufficientBalance; - InvalidSender; - Other; - }; - message : opt text; -}; -type CreateTransactionResult = variant { - ok : CreateTransactionSuccess; - err : CreateTransactionErr; -}; -type CreateTransactionSuccess = record { transaction : Transaction__1 }; -type Employee = record { - id : nat; - email_address : text; - emp_type : text; - creator : principal; - modified_at : int; - name : text; - created_at : int; - wallet : text; - phone_number : text; - access_type : text; -}; -type GetAccountIdentifierArgs = record { "principal" : principal }; -type GetAccountIdentifierErr = record { message : opt text }; -type GetAccountIdentifierResult = variant { - ok : GetAccountIdentifierSuccess; - err : GetAccountIdentifierErr; -}; -type GetAccountIdentifierSuccess = record { - accountIdentifier : AccountIdentifier; -}; -type GetTransactionArgs = record { id : nat }; -type GetTransactionErr = record { - kind : variant { NotFound; NotAuthorized; Other; InvalidTransactionId }; - message : opt text; -}; -type GetTransactionResult = variant { - ok : GetTransactionSuccess; - err : GetTransactionErr; -}; -type GetTransactionSuccess = record { transaction : Transaction__1 }; -type HttpHeader = record { value : text; name : text }; -type HttpResponsePayload = record { - status : nat; - body : vec nat8; - headers : vec HttpHeader; -}; -type Notification = record { - id : nat; - isRead : bool; - sender : text; - amount : nat; - receiver : text; -}; -type Notification__1 = record { - id : nat; - isRead : bool; - sender : text; - amount : nat; - receiver : text; -}; -type PayrollType = record { - id : nat; - creator : text; - destination : text; - created_at : int; - amount : nat; - successful : bool; -}; -type PayrollType__1 = record { - id : nat; - creator : text; - destination : text; - created_at : int; - amount : nat; - successful : bool; -}; -type Response = record { - status : nat16; - data : opt User; - status_text : text; - error_text : opt text; -}; -type Response_1 = record { - status : nat16; - data : opt Transaction; - status_text : text; - error_text : opt text; -}; -type Response_2 = record { - status : nat16; - data : opt text; - status_text : text; - error_text : opt text; -}; -type Response_3 = record { - status : nat16; - data : opt vec PayrollType__1; - status_text : text; - error_text : opt text; -}; -type Response_4 = record { - status : nat16; - data : opt Employee; - status_text : text; - error_text : opt text; -}; -type Result = variant { ok : text; err : text }; -type SchedulePaymentsArgs = record { - status : variant { Paid; Rejected; Unpaid; Accepted }; - created_at : int; - receivers : vec PayrollType; - payment_at : int; -}; -type SchedulePaymentsErr = record { - kind : variant { - InvalidDetails; - InvalidAmount; - InvalidDestination; - MaxTransactionsReached; - InsufficientBalance; - InvalidSender; - Other; - }; - message : opt text; -}; -type SchedulePaymentsResult = variant { - ok : SchedulePaymentsSuccess; - err : SchedulePaymentsErr; -}; -type SchedulePaymentsSuccess = record { receivers : vec PayrollType }; -type Subaccount = vec nat8; -type Transaction = record { - id : nat; - creator : principal; - destination : principal; - created_at : int; - amount : nat; - successful : bool; -}; -type Transaction__1 = record { - id : nat; - creator : principal; - destination : principal; - created_at : int; - amount : nat; - successful : bool; -}; -type TransformArgs = record { - context : vec nat8; - response : HttpResponsePayload; -}; -type User = record { - email_address : text; - phone_notifications : bool; - name : text; - email_notifications : bool; - phone_number : text; -}; -service : Backend \ No newline at end of file diff --git a/.dfx/local/lsp/bkyz2-fmaaa-aaaaa-qaaaq-cai.did b/.dfx/local/lsp/bkyz2-fmaaa-aaaaa-qaaaq-cai.did deleted file mode 100644 index ed129e46..00000000 --- a/.dfx/local/lsp/bkyz2-fmaaa-aaaaa-qaaaq-cai.did +++ /dev/null @@ -1,276 +0,0 @@ -type BlockIndex = nat; -type Subaccount = blob; -// Number of nanoseconds since the UNIX epoch in UTC timezone. -type Timestamp = nat64; -// Number of nanoseconds between two [Timestamp]s. -type Duration = nat64; -type Tokens = nat; -type TxIndex = nat; - -type Account = record { - owner : principal; - subaccount : opt Subaccount; -}; - -type TransferArg = record { - from_subaccount : opt Subaccount; - to : Account; - amount : Tokens; - fee : opt Tokens; - memo : opt blob; - created_at_time: opt Timestamp; -}; - -type TransferError = variant { - BadFee : record { expected_fee : Tokens }; - BadBurn : record { min_burn_amount : Tokens }; - InsufficientFunds : record { balance : Tokens }; - TooOld; - CreatedInFuture : record { ledger_time : nat64 }; - TemporarilyUnavailable; - Duplicate : record { duplicate_of : BlockIndex }; - GenericError : record { error_code : nat; message : text }; -}; - -type TransferResult = variant { - Ok : BlockIndex; - Err : TransferError; -}; - -// The value returned from the [icrc1_metadata] endpoint. -type MetadataValue = variant { - Nat : nat; - Int : int; - Text : text; - Blob : blob; -}; - -// The initialization parameters of the Ledger -type InitArgs = record { - minting_account : Account; - fee_collector_account : opt Account; - transfer_fee : nat64; - token_symbol : text; - token_name : text; - metadata : vec record { text; MetadataValue }; - initial_balances : vec record { Account; nat64 }; - archive_options : record { - num_blocks_to_archive : nat64; - trigger_threshold : nat64; - max_message_size_bytes : opt nat64; - cycles_for_archive_creation : opt nat64; - node_max_memory_size_bytes : opt nat64; - controller_id : principal; - }; -}; - -type ChangeFeeCollector = variant { - Unset; SetTo: Account; -}; - -type UpgradeArgs = record { - metadata : opt vec record { text; MetadataValue }; - token_symbol : opt text; - token_name : opt text; - transfer_fee : opt nat64; - change_fee_collector : opt ChangeFeeCollector; -}; - -type LedgerArg = variant { - Init: InitArgs; - Upgrade: opt UpgradeArgs; -}; - -type GetTransactionsRequest = record { - // The index of the first tx to fetch. - start : TxIndex; - // The number of transactions to fetch. - length : nat; -}; - -type GetTransactionsResponse = record { - // The total number of transactions in the log. - log_length : nat; - - // List of transaction that were available in the ledger when it processed the call. - // - // The transactions form a contiguous range, with the first transaction having index - // [first_index] (see below), and the last transaction having index - // [first_index] + len(transactions) - 1. - // - // The transaction range can be an arbitrary sub-range of the originally requested range. - transactions : vec Transaction; - - // The index of the first transaction in [transactions]. - // If the transaction vector is empty, the exact value of this field is not specified. - first_index : TxIndex; - - // Encoding of instructions for fetching archived transactions whose indices fall into the - // requested range. - // - // For each entry `e` in [archived_transactions], `[e.from, e.from + len)` is a sub-range - // of the originally requested transaction range. - archived_transactions : vec record { - // The index of the first archived transaction you can fetch using the [callback]. - start : TxIndex; - - // The number of transactions you can fetch using the callback. - length : nat; - - // The function you should call to fetch the archived transactions. - // The range of the transaction accessible using this function is given by [from] - // and [len] fields above. - callback : QueryArchiveFn; - }; -}; - - -// A prefix of the transaction range specified in the [GetTransactionsRequest] request. -type TransactionRange = record { - // A prefix of the requested transaction range. - // The index of the first transaction is equal to [GetTransactionsRequest.from]. - // - // Note that the number of transactions might be less than the requested - // [GetTransactionsRequest.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of transactions can be empty if: - // - // 1. [GetTransactionsRequest.length] was zero. - // 2. [GetTransactionsRequest.from] was larger than the last transaction known to - // the canister. - transactions : vec Transaction; -}; - -// A function for fetching archived transaction. -type QueryArchiveFn = func (GetTransactionsRequest) -> (TransactionRange) query; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type Value = variant { - Blob : blob; - Text : text; - Nat : nat; - Nat64: nat64; - Int : int; - Array : vec Value; - Map : Map; -}; - -type Map = vec record { text; Value }; - -type Block = Value; - -type GetBlocksArgs = record { - // The index of the first block to fetch. - start : BlockIndex; - // Max number of blocks to fetch. - length : nat; -}; - -// A prefix of the block range specified in the [GetBlocksArgs] request. -type BlockRange = record { - // A prefix of the requested block range. - // The index of the first block is equal to [GetBlocksArgs.start]. - // - // Note that the number of blocks might be less than the requested - // [GetBlocksArgs.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of blocks can be empty if: - // - // 1. [GetBlocksArgs.length] was zero. - // 2. [GetBlocksArgs.start] was larger than the last block known to - // the canister. - blocks : vec Block; -}; - -// A function for fetching archived blocks. -type QueryBlockArchiveFn = func (GetBlocksArgs) -> (BlockRange) query; - -// The result of a "get_blocks" call. -type GetBlocksResponse = record { - // The index of the first block in "blocks". - // If the blocks vector is empty, the exact value of this field is not specified. - first_index : BlockIndex; - - // The total number of blocks in the chain. - // If the chain length is positive, the index of the last block is `chain_len - 1`. - chain_length : nat64; - - // System certificate for the hash of the latest block in the chain. - // Only present if `get_blocks` is called in a non-replicated query context. - certificate : opt blob; - - // List of blocks that were available in the ledger when it processed the call. - // - // The blocks form a contiguous range, with the first block having index - // [first_block_index] (see below), and the last block having index - // [first_block_index] + len(blocks) - 1. - // - // The block range can be an arbitrary sub-range of the originally requested range. - blocks : vec Block; - - // Encoding of instructions for fetching archived blocks. - archived_blocks : vec record { - // The index of the first archived block. - start : BlockIndex; - - // The number of blocks that can be fetched. - length : nat; - - // Callback to fetch the archived blocks. - callback : QueryBlockArchiveFn; - }; -}; - -// Certificate for the block at `block_index`. -type DataCertificate = record { - certificate : opt blob; - hash_tree : blob; -}; - -service : { - icrc1_name : () -> (text) query; - icrc1_symbol : () -> (text) query; - icrc1_decimals : () -> (nat8) query; - icrc1_metadata : () -> (vec record { text; MetadataValue }) query; - icrc1_total_supply : () -> (Tokens) query; - icrc1_fee : () -> (Tokens) query; - icrc1_minting_account : () -> (opt Account) query; - icrc1_balance_of : (Account) -> (Tokens) query; - icrc1_transfer : (TransferArg) -> (TransferResult); - icrc1_supported_standards : () -> (vec record { name : text; url : text }) query; - get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query; - get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query; - get_data_certificate : () -> (DataCertificate) query; -} \ No newline at end of file diff --git a/.dfx/local/lsp/br5f7-7uaaa-aaaaa-qaaca-cai.did b/.dfx/local/lsp/br5f7-7uaaa-aaaaa-qaaca-cai.did deleted file mode 100644 index 629e178b..00000000 --- a/.dfx/local/lsp/br5f7-7uaaa-aaaaa-qaaca-cai.did +++ /dev/null @@ -1,63 +0,0 @@ -type Account = record { owner : principal; subaccount : opt vec nat8 }; -type GetAccountTransactionsArgs = record { - max_results : nat; - start : opt TxId; - account : Account; -}; -type GetTransactions = record { - transactions : vec TransactionWithId; - oldest_tx_id : opt TxId; -}; -type GetTransactionsErr = record { message : text }; -type GetTransactionsResult = variant { - Ok : GetTransactions; - Err : GetTransactionsErr; -}; -type InitArgs = record { ledger_id : principal }; -type ListSubaccountsArgs = record { owner : principal; start : opt SubAccount }; -type SubAccount = vec nat8; -type Transaction = record { - burn : opt record { - from : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - spender : opt Account; - }; - kind : text; - mint : opt record { - to : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - }; - approve : opt record { - fee : opt nat; - from : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - expected_allowance : opt nat; - expires_at : opt nat64; - spender : opt Account; - }; - timestamp : nat64; - transfer : opt record { - to : Account; - fee : opt nat; - from : Account; - memo : opt vec nat8; - created_at_time : opt nat64; - amount : nat; - spender : opt Account; - }; -}; -type TransactionWithId = record { id : TxId; transaction : Transaction }; -type TxId = nat; -service : { - get_account_transactions : (GetAccountTransactionsArgs) -> ( - GetTransactionsResult, - ); - ledger_id : () -> (principal) query; - list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query; -} \ No newline at end of file diff --git a/.dfx/local/lsp/bw4dl-smaaa-aaaaa-qaacq-cai.did b/.dfx/local/lsp/bw4dl-smaaa-aaaaa-qaacq-cai.did deleted file mode 100644 index 4d9ea8be..00000000 --- a/.dfx/local/lsp/bw4dl-smaaa-aaaaa-qaacq-cai.did +++ /dev/null @@ -1,197 +0,0 @@ -type AssetCanisterArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs }; -type BatchId = nat; -type BatchOperationKind = variant { - SetAssetProperties : SetAssetPropertiesArguments; - CreateAsset : CreateAssetArguments; - UnsetAssetContent : UnsetAssetContentArguments; - DeleteAsset : DeleteAssetArguments; - SetAssetContent : SetAssetContentArguments; - Clear : ClearArguments; -}; -type ChunkId = nat; -type ClearArguments = record {}; -type CommitBatchArguments = record { - batch_id : BatchId; - operations : vec BatchOperationKind; -}; -type CommitProposedBatchArguments = record { - batch_id : BatchId; - evidence : vec nat8; -}; -type ComputeEvidenceArguments = record { - batch_id : BatchId; - max_iterations : opt nat16; -}; -type ConfigurationResponse = record { - max_batches : opt nat64; - max_bytes : opt nat64; - max_chunks : opt nat64; -}; -type ConfigureArguments = record { - max_batches : opt opt nat64; - max_bytes : opt opt nat64; - max_chunks : opt opt nat64; -}; -type CreateAssetArguments = record { - key : Key; - content_type : text; - headers : opt vec HeaderField; - allow_raw_access : opt bool; - max_age : opt nat64; - enable_aliasing : opt bool; -}; -type DeleteAssetArguments = record { key : Key }; -type DeleteBatchArguments = record { batch_id : BatchId }; -type GrantPermission = record { - permission : Permission; - to_principal : principal; -}; -type HeaderField = record { text; text }; -type HttpRequest = record { - url : text; - method : text; - body : vec nat8; - headers : vec HeaderField; - certificate_version : opt nat16; -}; -type HttpResponse = record { - body : vec nat8; - headers : vec HeaderField; - streaming_strategy : opt StreamingStrategy; - status_code : nat16; -}; -type InitArgs = record {}; -type Key = text; -type ListPermitted = record { permission : Permission }; -type Permission = variant { Prepare; ManagePermissions; Commit }; -type RevokePermission = record { - permission : Permission; - of_principal : principal; -}; -type SetAssetContentArguments = record { - key : Key; - sha256 : opt vec nat8; - chunk_ids : vec ChunkId; - content_encoding : text; -}; -type SetAssetPropertiesArguments = record { - key : Key; - headers : opt opt vec HeaderField; - is_aliased : opt opt bool; - allow_raw_access : opt opt bool; - max_age : opt opt nat64; -}; -type SetPermissions = record { - prepare : vec principal; - commit : vec principal; - manage_permissions : vec principal; -}; -type StreamingCallbackHttpResponse = record { - token : opt StreamingCallbackToken; - body : vec nat8; -}; -type StreamingCallbackToken = record { - key : Key; - sha256 : opt vec nat8; - index : nat; - content_encoding : text; -}; -type StreamingStrategy = variant { - Callback : record { - token : StreamingCallbackToken; - callback : func (StreamingCallbackToken) -> ( - opt StreamingCallbackHttpResponse, - ) query; - }; -}; -type Time = int; -type UnsetAssetContentArguments = record { key : Key; content_encoding : text }; -type UpgradeArgs = record { set_permissions : opt SetPermissions }; -type ValidationResult = variant { Ok : text; Err : text }; -service : { - api_version : () -> (nat16) query; - authorize : (principal) -> (); - certified_tree : (record {}) -> ( - record { certificate : vec nat8; tree : vec nat8 }, - ) query; - clear : (ClearArguments) -> (); - commit_batch : (CommitBatchArguments) -> (); - commit_proposed_batch : (CommitProposedBatchArguments) -> (); - compute_evidence : (ComputeEvidenceArguments) -> (opt vec nat8); - configure : (ConfigureArguments) -> (); - create_asset : (CreateAssetArguments) -> (); - create_batch : (record {}) -> (record { batch_id : BatchId }); - create_chunk : (record { content : vec nat8; batch_id : BatchId }) -> ( - record { chunk_id : ChunkId }, - ); - deauthorize : (principal) -> (); - delete_asset : (DeleteAssetArguments) -> (); - delete_batch : (DeleteBatchArguments) -> (); - get : (record { key : Key; accept_encodings : vec text }) -> ( - record { - content : vec nat8; - sha256 : opt vec nat8; - content_type : text; - content_encoding : text; - total_length : nat; - }, - ) query; - get_asset_properties : (Key) -> ( - record { - headers : opt vec HeaderField; - is_aliased : opt bool; - allow_raw_access : opt bool; - max_age : opt nat64; - }, - ) query; - get_chunk : ( - record { - key : Key; - sha256 : opt vec nat8; - index : nat; - content_encoding : text; - }, - ) -> (record { content : vec nat8 }) query; - get_configuration : () -> (ConfigurationResponse); - grant_permission : (GrantPermission) -> (); - http_request : (HttpRequest) -> (HttpResponse) query; - http_request_streaming_callback : (StreamingCallbackToken) -> ( - opt StreamingCallbackHttpResponse, - ) query; - list : (record {}) -> ( - vec record { - key : Key; - encodings : vec record { - modified : Time; - sha256 : opt vec nat8; - length : nat; - content_encoding : text; - }; - content_type : text; - }, - ) query; - list_authorized : () -> (vec principal); - list_permitted : (ListPermitted) -> (vec principal); - propose_commit_batch : (CommitBatchArguments) -> (); - revoke_permission : (RevokePermission) -> (); - set_asset_content : (SetAssetContentArguments) -> (); - set_asset_properties : (SetAssetPropertiesArguments) -> (); - store : ( - record { - key : Key; - content : vec nat8; - sha256 : opt vec nat8; - content_type : text; - content_encoding : text; - }, - ) -> (); - take_ownership : () -> (); - unset_asset_content : (UnsetAssetContentArguments) -> (); - validate_commit_proposed_batch : (CommitProposedBatchArguments) -> ( - ValidationResult, - ); - validate_configure : (ConfigureArguments) -> (ValidationResult); - validate_grant_permission : (GrantPermission) -> (ValidationResult); - validate_revoke_permission : (RevokePermission) -> (ValidationResult); - validate_take_ownership : () -> (ValidationResult); -} \ No newline at end of file diff --git a/.dfx/local/wallets.json b/.dfx/local/wallets.json deleted file mode 100644 index 404c0f73..00000000 --- a/.dfx/local/wallets.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "identities": { - "developer": { - "local": "bnz7o-iuaaa-aaaaa-qaaaa-cai" - } - } -} \ No newline at end of file diff --git a/.dfx/network/local/ic-canister-http-config.json b/.dfx/network/local/ic-canister-http-config.json deleted file mode 100644 index 75232083..00000000 --- a/.dfx/network/local/ic-canister-http-config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "incoming_source": { - "Path": "/tmp/ic-https-outcalls-adapter-socket.5395.1712335096" - }, - "logger": { - "level": "error" - } -} \ No newline at end of file diff --git a/.dfx/network/local/ic-canister-http-socket-path b/.dfx/network/local/ic-canister-http-socket-path deleted file mode 100644 index f6c36aaa..00000000 --- a/.dfx/network/local/ic-canister-http-socket-path +++ /dev/null @@ -1 +0,0 @@ -/tmp/ic-https-outcalls-adapter-socket.5395.1712335096 \ No newline at end of file diff --git a/.dfx/network/local/ic-https-outcalls-adapter-pid b/.dfx/network/local/ic-https-outcalls-adapter-pid deleted file mode 100644 index b6359920..00000000 --- a/.dfx/network/local/ic-https-outcalls-adapter-pid +++ /dev/null @@ -1 +0,0 @@ -5405 \ No newline at end of file diff --git a/.dfx/network/local/icx-proxy-pid b/.dfx/network/local/icx-proxy-pid deleted file mode 100644 index 64eb5ed7..00000000 --- a/.dfx/network/local/icx-proxy-pid +++ /dev/null @@ -1 +0,0 @@ -5519 \ No newline at end of file diff --git a/.dfx/network/local/network-id b/.dfx/network/local/network-id deleted file mode 100644 index d710d6db..00000000 --- a/.dfx/network/local/network-id +++ /dev/null @@ -1,3 +0,0 @@ -{ - "created": "2024-04-05 16:38:16.942046839 +00:00:00" -} \ No newline at end of file diff --git a/.dfx/network/local/replica-configuration/replica-1.port b/.dfx/network/local/replica-configuration/replica-1.port deleted file mode 100644 index c45129e6..00000000 --- a/.dfx/network/local/replica-configuration/replica-1.port +++ /dev/null @@ -1 +0,0 @@ -41045 \ No newline at end of file diff --git a/.dfx/network/local/replica-configuration/replica-pid b/.dfx/network/local/replica-configuration/replica-pid deleted file mode 100644 index 9e7a4793..00000000 --- a/.dfx/network/local/replica-configuration/replica-pid +++ /dev/null @@ -1 +0,0 @@ -5412 \ No newline at end of file diff --git a/.dfx/network/local/replica-effective-config.json b/.dfx/network/local/replica-effective-config.json deleted file mode 100644 index b456fe55..00000000 --- a/.dfx/network/local/replica-effective-config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "replica_rev": "044cfd5147fc97d7e5a214966941b6580c325d72", - "type": "replica", - "config": { - "http_handler": { - "port": null, - "write_port_to": "/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/replica-configuration/replica-1.port" - }, - "state_manager": { - "state_root": "/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/replicated_state" - }, - "crypto": { - "crypto_root": "/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/crypto_store" - }, - "artifact_pool": { - "consensus_pool_path": "/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/consensus_pool" - }, - "subnet_type": "application", - "btc_adapter": { - "enabled": false, - "socket_path": null - }, - "canister_http_adapter": { - "enabled": true, - "socket_path": "/tmp/ic-https-outcalls-adapter-socket.5395.1712335096" - }, - "log_level": "error", - "artificial_delay": 600, - "use_old_metering": false - } -} \ No newline at end of file diff --git a/.dfx/network/local/state/replicated_state/ic.json5 b/.dfx/network/local/state/replicated_state/ic.json5 deleted file mode 100644 index 76c1d016..00000000 --- a/.dfx/network/local/state/replicated_state/ic.json5 +++ /dev/null @@ -1 +0,0 @@ -{"registry_client":{"local_store":"/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/replicated_state/ic_registry_local_store"},"transport":{"node_ip":"0.0.0.0","listening_port":0,"send_queue_size":1024,"max_streams":1},"state_manager":{"state_root":"/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/replicated_state/node-100/state","file_backed_memory_allocator":"Enabled","lsmt_storage":"Disabled"},"hypervisor":{"embedders_config":{"max_wasm_stack_size":5242880,"query_execution_threads_per_canister":2,"max_globals":1000,"max_functions":50000,"max_custom_sections":16,"max_custom_sections_size":1048576,"max_number_exported_functions":1000,"max_sum_exported_function_name_lengths":20000,"cost_to_compile_wasm_instruction":6000,"num_rayon_compilation_threads":10,"feature_flags":{"rate_limiting_of_debug_prints":"Disabled","write_barrier":"Disabled","wasm_native_stable_memory":"Enabled"},"metering_type":"New","stable_memory_dirty_page_limit":2097152,"stable_memory_accessed_page_limit":2097152,"min_sandbox_count":500,"max_sandbox_count":2000,"max_sandbox_idle_time":{"secs":1800,"nanos":0},"subnet_type":"application","dirty_page_overhead":0,"trace_execution":"Disabled","max_dirty_pages_without_optimization":262144,"dirty_page_copy_overhead":3000},"create_funds_whitelist":"","max_instructions_for_message_acceptance_calls":200000000,"subnet_memory_threshold":483183820800,"subnet_memory_capacity":751619276800,"subnet_message_memory_capacity":26843545600,"ingress_history_memory_capacity":4294967296,"subnet_wasm_custom_sections_memory_capacity":2147483648,"subnet_memory_reservation":10737418240,"max_canister_memory_size":433791696896,"default_provisional_cycles_balance":100000000000000,"default_freeze_threshold":2592000,"max_controllers":10,"canister_sandboxing_flag":"Enabled","query_execution_threads_total":4,"query_scheduling_time_slice_per_canister":{"secs":0,"nanos":20000000},"max_query_call_graph_depth":6,"max_query_call_graph_instructions":5000000000,"max_query_call_walltime":{"secs":10,"nanos":0},"instruction_overhead_per_query_call":50000000,"rate_limiting_of_heap_delta":"Disabled","rate_limiting_of_instructions":"Disabled","allocatable_compute_capacity_in_percent":50,"deterministic_time_slicing":"Enabled","bitcoin":{"privileged_access":["g4xu7-jiaaa-aaaan-aaaaq-cai","ghsi2-tqaaa-aaaan-aaaca-cai","gsvzx-syaaa-aaaan-aaabq-cai"],"testnet_canister_id":"g4xu7-jiaaa-aaaan-aaaaq-cai","mainnet_canister_id":"ghsi2-tqaaa-aaaan-aaaca-cai"},"composite_queries":"Enabled","query_caching":"Enabled","query_cache_capacity":209715200,"query_cache_max_expiry_time":{"secs":300,"nanos":0},"max_compilation_cache_size":10737418240,"query_stats_aggregation":"Disabled","query_stats_epoch_length":2000,"wasm_chunk_store":"Enabled","stop_canister_timeout_duration":{"secs":300,"nanos":0},"canister_snapshots":"Disabled"},"http_handler":{"listen_addr":"127.0.0.1:0","port_file_path":"/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/replica-configuration/replica-1.port","connection_read_timeout_seconds":1200,"request_timeout_seconds":300,"http_max_concurrent_streams":256,"max_request_size_bytes":5242880,"max_delegation_certificate_size_bytes":1048576,"max_request_receive_seconds":300,"max_read_state_concurrent_requests":100,"max_status_concurrent_requests":100,"max_catch_up_package_concurrent_requests":100,"max_dashboard_concurrent_requests":100,"max_call_concurrent_requests":50,"max_query_concurrent_requests":400,"max_pprof_concurrent_requests":5},"metrics":null,"artifact_pool":{"consensus_pool_path":"/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/replicated_state/node-100/ic_consensus_pool","ingress_pool_max_count":18446744073709551615,"ingress_pool_max_bytes":18446744073709551615},"crypto":{"crypto_root":"/home/cosmas/harambeeapps/ic-payroll/.dfx/network/local/state/replicated_state/node-100/crypto","csp_vault_type":"in_replica"},"logger":{"node_id":100,"dc_id":200,"level":"error","format":"text_full","debug_overrides":[],"sampling_rates":{},"enabled_tags":[],"target":"Stdout","block_on_overflow":true},"orchestrator_logger":null,"csp_vault_logger":null,"message_routing":null,"malicious_behaviour":null,"firewall":null,"registration":null,"nns_registry_replicator":null,"adapters_config":{"bitcoin_mainnet_uds_path":null,"bitcoin_mainnet_uds_metrics_path":null,"bitcoin_testnet_uds_path":null,"bitcoin_testnet_uds_metrics_path":null,"https_outcalls_uds_path":"/tmp/ic-https-outcalls-adapter-socket.5395.1712335096","https_outcalls_uds_metrics_path":null},"bitcoin_payload_builder_config":null,"ipv4_config":null,"domain":null} \ No newline at end of file diff --git a/.dfx/network/local/state/replicated_state/ic_registry_local_store/0000000000/00/00/01.pb b/.dfx/network/local/state/replicated_state/ic_registry_local_store/0000000000/00/00/01.pb deleted file mode 100644 index 3d713b6f..00000000 Binary files a/.dfx/network/local/state/replicated_state/ic_registry_local_store/0000000000/00/00/01.pb and /dev/null differ diff --git a/.dfx/network/local/state/replicated_state/ic_registry_local_store/time.local_store.v1.CertificationTime.pb b/.dfx/network/local/state/replicated_state/ic_registry_local_store/time.local_store.v1.CertificationTime.pb deleted file mode 100644 index 632a8853..00000000 --- a/.dfx/network/local/state/replicated_state/ic_registry_local_store/time.local_store.v1.CertificationTime.pb +++ /dev/null @@ -1 +0,0 @@ -ö’ˆÄöÛá \ No newline at end of file diff --git a/.dfx/network/local/state/replicated_state/nns_public_key.pem b/.dfx/network/local/state/replicated_state/nns_public_key.pem deleted file mode 100644 index 72be1670..00000000 --- a/.dfx/network/local/state/replicated_state/nns_public_key.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIGCMB0GDSsGAQQBgtx8BQMBAgEGDCsGAQQBgtx8BQMCAQNhAIqj4FnHtfsRRcSZ -fSupi60pjMDeK6o0yAGlbUcA1uMyUIwyquOjeyuJkfXrL7de8RRbeLKsEfuPtcYN -LbmrEh/EpsIil7QuTjR0X1Vh91ENKOEvTw9VWWMYhx2oJSNVjw== ------END PUBLIC KEY----- diff --git a/.dfx/network/local/state/replicated_state/node-100/committee_signing_key b/.dfx/network/local/state/replicated_state/node-100/committee_signing_key deleted file mode 100644 index a255521f..00000000 --- a/.dfx/network/local/state/replicated_state/node-100/committee_signing_key +++ /dev/null @@ -1,2 +0,0 @@ -`®ÒSÔe§µòÁ(! ãÅš)6œ¿¬»{“*\\àœŽå>Œ{(7ö¡*Y=t†ˆê`º/¿«/$Ácæ9ÆQ~–°Ê’^Ê Šoï­…VG]9F¥†š˜Â‰(ê<Ü"2 -0¬®óo¼—c% (4×d©•Pиx~w"vþ@A (TransactionRange) query; - -type Transaction = record { - kind : text; - mint : opt record { - amount : nat; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - burn : opt record { - amount : nat; - from : Account; - memo : opt blob; - created_at_time : opt nat64; - }; - transfer : opt record { - amount : nat; - from : Account; - to : Account; - memo : opt blob; - created_at_time : opt nat64; - fee : opt nat; - }; - timestamp : nat64; -}; - -type Value = variant { - Blob : blob; - Text : text; - Nat : nat; - Nat64: nat64; - Int : int; - Array : vec Value; - Map : Map; -}; - -type Map = vec record { text; Value }; - -type Block = Value; - -type GetBlocksArgs = record { - // The index of the first block to fetch. - start : BlockIndex; - // Max number of blocks to fetch. - length : nat; -}; - -// A prefix of the block range specified in the [GetBlocksArgs] request. -type BlockRange = record { - // A prefix of the requested block range. - // The index of the first block is equal to [GetBlocksArgs.start]. - // - // Note that the number of blocks might be less than the requested - // [GetBlocksArgs.length] for various reasons, for example: - // - // 1. The query might have hit the replica with an outdated state - // that doesn't have the whole range yet. - // 2. The requested range is too large to fit into a single reply. - // - // NOTE: the list of blocks can be empty if: - // - // 1. [GetBlocksArgs.length] was zero. - // 2. [GetBlocksArgs.start] was larger than the last block known to - // the canister. - blocks : vec Block; -}; - -// A function for fetching archived blocks. -type QueryBlockArchiveFn = func (GetBlocksArgs) -> (BlockRange) query; - -// The result of a "get_blocks" call. -type GetBlocksResponse = record { - // The index of the first block in "blocks". - // If the blocks vector is empty, the exact value of this field is not specified. - first_index : BlockIndex; - - // The total number of blocks in the chain. - // If the chain length is positive, the index of the last block is `chain_len - 1`. - chain_length : nat64; - - // System certificate for the hash of the latest block in the chain. - // Only present if `get_blocks` is called in a non-replicated query context. - certificate : opt blob; - - // List of blocks that were available in the ledger when it processed the call. - // - // The blocks form a contiguous range, with the first block having index - // [first_block_index] (see below), and the last block having index - // [first_block_index] + len(blocks) - 1. - // - // The block range can be an arbitrary sub-range of the originally requested range. - blocks : vec Block; - - // Encoding of instructions for fetching archived blocks. - archived_blocks : vec record { - // The index of the first archived block. - start : BlockIndex; - - // The number of blocks that can be fetched. - length : nat; - - // Callback to fetch the archived blocks. - callback : QueryBlockArchiveFn; - }; -}; - -// Certificate for the block at `block_index`. -type DataCertificate = record { - certificate : opt blob; - hash_tree : blob; -}; - -service : (ledger_arg : LedgerArg) -> { - icrc1_name : () -> (text) query; - icrc1_symbol : () -> (text) query; - icrc1_decimals : () -> (nat8) query; - icrc1_metadata : () -> (vec record { text; MetadataValue }) query; - icrc1_total_supply : () -> (Tokens) query; - icrc1_fee : () -> (Tokens) query; - icrc1_minting_account : () -> (opt Account) query; - icrc1_balance_of : (Account) -> (Tokens) query; - icrc1_transfer : (TransferArg) -> (TransferResult); - icrc1_supported_standards : () -> (vec record { name : text; url : text }) query; - get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query; - get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query; - get_data_certificate : () -> (DataCertificate) query; -} - )¾Ü+JN<ó(nèq!™£¼÷VH¹E4-kç$] -` - git_commit_idO)b3b00ba59c366384e3e0cd53a69457e9053ec987 - }Ÿoáù½>§#c,‹%´ ÇgNÔ]{íï Ç'øG\2 ×% äÍC.QÍÚföL4ìb("ɬS…é‰28Z -xˆ´¢ Ö8¹· -ø‘E -€’E -€€@ -𺮹M - authorize -clear - commit_batch -commit_proposed_batch -compute_evidence - configure - create_asset - create_batch - create_chunk - deauthorize - delete_asset - delete_batch -get_configuration -grant_permission -list_authorized -list_permitted -propose_commit_batch -revoke_permission -set_asset_content -set_asset_properties -store -take_ownership -unset_asset_content -validate_commit_proposed_batch -validate_configure -validate_grant_permission -validate_revoke_permission -validate_take_ownership  api_versioncertified_treegetget_asset_properties  get_chunk http_request!http_request_streaming_callbacklist -retrieve *¦8 -Ö7 -candid:serviceÃ7œ7type BatchId = nat; -type ChunkId = nat; -type Key = text; -type Time = int; - -type CreateAssetArguments = record { - key: Key; - content_type: text; - max_age: opt nat64; - headers: opt vec HeaderField; - enable_aliasing: opt bool; - allow_raw_access: opt bool; -}; - -// Add or change content for an asset, by content encoding -type SetAssetContentArguments = record { - key: Key; - content_encoding: text; - chunk_ids: vec ChunkId; - sha256: opt blob; -}; - -// Remove content for an asset, by content encoding -type UnsetAssetContentArguments = record { - key: Key; - content_encoding: text; -}; - -// Delete an asset -type DeleteAssetArguments = record { - key: Key; -}; - -// Reset everything -type ClearArguments = record {}; - -type BatchOperationKind = variant { - CreateAsset: CreateAssetArguments; - SetAssetContent: SetAssetContentArguments; - - SetAssetProperties: SetAssetPropertiesArguments; - - UnsetAssetContent: UnsetAssetContentArguments; - DeleteAsset: DeleteAssetArguments; - - Clear: ClearArguments; -}; - -type CommitBatchArguments = record { - batch_id: BatchId; - operations: vec BatchOperationKind -}; - -type CommitProposedBatchArguments = record { - batch_id: BatchId; - evidence: blob; -}; - -type ComputeEvidenceArguments = record { - batch_id: BatchId; - max_iterations: opt nat16 -}; - -type DeleteBatchArguments = record { - batch_id: BatchId; -}; - -type HeaderField = record { text; text; }; - -type HttpRequest = record { - method: text; - url: text; - headers: vec HeaderField; - body: blob; - certificate_version: opt nat16; -}; - -type HttpResponse = record { - status_code: nat16; - headers: vec HeaderField; - body: blob; - streaming_strategy: opt StreamingStrategy; -}; - -type StreamingCallbackHttpResponse = record { - body: blob; - token: opt StreamingCallbackToken; -}; - -type StreamingCallbackToken = record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; -}; - -type StreamingStrategy = variant { - Callback: record { - callback: func (StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - token: StreamingCallbackToken; - }; -}; - -type SetAssetPropertiesArguments = record { - key: Key; - max_age: opt opt nat64; - headers: opt opt vec HeaderField; - allow_raw_access: opt opt bool; - is_aliased: opt opt bool; -}; - -type ConfigurationResponse = record { - max_batches: opt nat64; - max_chunks: opt nat64; - max_bytes: opt nat64; -}; - -type ConfigureArguments = record { - max_batches: opt opt nat64; - max_chunks: opt opt nat64; - max_bytes: opt opt nat64; -}; - -type Permission = variant { - Commit; - ManagePermissions; - Prepare; -}; - -type GrantPermission = record { - to_principal: principal; - permission: Permission; -}; -type RevokePermission = record { - of_principal: principal; - permission: Permission; -}; -type ListPermitted = record { permission: Permission }; - -type ValidationResult = variant { Ok : text; Err : text }; - -type AssetCanisterArgs = variant { - Init: InitArgs; - Upgrade: UpgradeArgs; -}; - -type InitArgs = record {}; - -type UpgradeArgs = record { - set_permissions: opt SetPermissions; -}; - -/// Sets the list of principals granted each permission. -type SetPermissions = record { - prepare: vec principal; - commit: vec principal; - manage_permissions: vec principal; -}; - -service: (asset_canister_args: opt AssetCanisterArgs) -> { - api_version: () -> (nat16) query; - - get: (record { - key: Key; - accept_encodings: vec text; - }) -> (record { - content: blob; // may be the entirety of the content, or just chunk index 0 - content_type: text; - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - total_length: nat; // all chunks except last have size == content.size() - }) query; - - // if get() returned chunks > 1, call this to retrieve them. - // chunks may or may not be split up at the same boundaries as presented to create_chunk(). - get_chunk: (record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - }) -> (record { content: blob }) query; - - list : (record {}) -> (vec record { - key: Key; - content_type: text; - encodings: vec record { - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - length: nat; // Size of this encoding's blob. Calculated when uploading assets. - modified: Time; - }; - }) query; - - certified_tree : (record {}) -> (record { - certificate: blob; - tree: blob; - }) query; - - create_batch : (record {}) -> (record { batch_id: BatchId }); - - create_chunk: (record { batch_id: BatchId; content: blob }) -> (record { chunk_id: ChunkId }); - - // Perform all operations successfully, or reject - commit_batch: (CommitBatchArguments) -> (); - - // Save the batch operations for later commit - propose_commit_batch: (CommitBatchArguments) -> (); - - // Given a batch already proposed, perform all operations successfully, or reject - commit_proposed_batch: (CommitProposedBatchArguments) -> (); - - // Compute a hash over the CommitBatchArguments. Call until it returns Some(evidence). - compute_evidence: (ComputeEvidenceArguments) -> (opt blob); - - // Delete a batch that has been created, or proposed for commit, but not yet committed - delete_batch: (DeleteBatchArguments) -> (); - - create_asset: (CreateAssetArguments) -> (); - set_asset_content: (SetAssetContentArguments) -> (); - unset_asset_content: (UnsetAssetContentArguments) -> (); - - delete_asset: (DeleteAssetArguments) -> (); - - clear: (ClearArguments) -> (); - - // Single call to create an asset with content for a single content encoding that - // fits within the message ingress limit. - store: (record { - key: Key; - content_type: text; - content_encoding: text; - content: blob; - sha256: opt blob - }) -> (); - - http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_streaming_callback: (token: StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - - authorize: (principal) -> (); - deauthorize: (principal) -> (); - list_authorized: () -> (vec principal); - grant_permission: (GrantPermission) -> (); - revoke_permission: (RevokePermission) -> (); - list_permitted: (ListPermitted) -> (vec principal); - take_ownership: () -> (); - - get_asset_properties : (key: Key) -> (record { - max_age: opt nat64; - headers: opt vec HeaderField; - allow_raw_access: opt bool; - is_aliased: opt bool; } ) query; - set_asset_properties: (SetAssetPropertiesArguments) -> (); - - get_configuration: () -> (ConfigurationResponse); - configure: (ConfigureArguments) -> (); - - validate_grant_permission: (GrantPermission) -> (ValidationResult); - validate_revoke_permission: (RevokePermission) -> (ValidationResult); - validate_take_ownership: () -> (ValidationResult); - validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); - validate_configure: (ConfigureArguments) -> (ValidationResult); -} - €ˆî…f<8‚owžÕx6k©Ê4ÙbzX²ð[ú¬7 -K -supported_certificate_versions)1,2 ŽÔ»bØ—øÑŒ;ZâFATbà€'¨ø_¿M»'‡&û—2 <†ÙêÖÞq3¹÷‡ßL©þƒ]>Õ”´~èžl·08Z -Txˆå¢ rãD ^\zÌ5Ï#~°ë’¹Ø}ûó¢ç maè1½Ó²ÇØ­€¸€šžÊ - -€Ê -ˆVÆ Å1Kdzž³u²1³¾BÔƒÞXOLOÊÒ¹«ZÖÏú -îÎÉÇÓ±Ýá‚U¢Ï«¢ -Éœ£ñ¢ Ãöú:¢ -ì™ýÓª¦ -K¾šÛèïùÛá" - - -€*/ - - -€ - -ˆVÆ Å1Kdzž³u²1³¾BÔƒÞXOLOÊ -U鿬ŠûÛá! - -ˆVÆ Å1Kdzž³u²1³¾BÔƒÞXOLOÊ:$ <†ÙêÖÞq3¹÷‡ßL©þƒ]>Õ”´~èžl·0²ºP9'ŒÂÊP - - - -" -Ð \ No newline at end of file diff --git a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/software.wasm b/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/software.wasm deleted file mode 100644 index 2796c34f..00000000 Binary files a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/software.wasm and /dev/null differ diff --git a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/stable_memory.bin b/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/stable_memory.bin deleted file mode 100644 index e69de29b..00000000 diff --git a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/vmemory_0.bin b/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/vmemory_0.bin deleted file mode 100644 index fb064368..00000000 Binary files a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/vmemory_0.bin and /dev/null differ diff --git a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/wasm_chunk_store.bin b/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000050101/wasm_chunk_store.bin deleted file mode 100644 index e69de29b..00000000 diff --git a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000060101/canister.pbuf b/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000060101/canister.pbuf deleted file mode 100644 index f8ea90a5..00000000 --- a/.dfx/network/local/state/replicated_state/node-100/state/checkpoints/00000000000009c4/canister_states/80000000001000060101/canister.pbuf +++ /dev/null @@ -1,695 +0,0 @@ -˜ -(¬:‡Â -ì” -„Ž” -Ñæ  -àæ  -€€@ -øϽ¸F -acknowledge_entries -add -add_tentative_device -authn_method_add -authn_method_confirm -authn_method_metadata_replace -authn_method_register& -$authn_method_registration_mode_enter% -#authn_method_registration_mode_exit -authn_method_remove -authn_method_replace( -&authn_method_security_settings_replace -captcha_create -create_challenge -deploy_archive -enter_device_registration_mode -exit_device_registration_mode - fetch_entries -get_anchor_info -http_request_update - identity_info -identity_metadata_replace -identity_register - init_salt -prepare_delegation -prepare_id_alias - -register -remove -replace -update -verify_tentative_deviceget_anchor_credentialsget_delegation get_id_alias get_principal http_requestidentity_authn_infolookupstats ˜ -*㺠-O - candid:args@(opt InternetIdentityInit) ˆÂ‘ö¶Q&1ñå)…€ÿ¨˜”®pÐÂYž’á~ -‹¶ -candid:service÷µϵtype UserNumber = nat64; -type PublicKey = blob; -type CredentialId = blob; -type DeviceKey = PublicKey; -type UserKey = PublicKey; -type SessionKey = PublicKey; -type FrontendHostname = text; -type Timestamp = nat64; - -type HeaderField = record { - text; - text; -}; - -type HttpRequest = record { - method: text; - url: text; - headers: vec HeaderField; - body: blob; - certificate_version: opt nat16; -}; - -type HttpResponse = record { - status_code: nat16; - headers: vec HeaderField; - body: blob; - upgrade : opt bool; - streaming_strategy: opt StreamingStrategy; -}; - -type StreamingCallbackHttpResponse = record { - body: blob; - token: opt Token; -}; - -type Token = record {}; - -type StreamingStrategy = variant { - Callback: record { - callback: func (Token) -> (StreamingCallbackHttpResponse) query; - token: Token; - }; -}; - -type Purpose = variant { - recovery; - authentication; -}; - -type KeyType = variant { - unknown; - platform; - cross_platform; - seed_phrase; - browser_storage_key; -}; - -// This describes whether a device is "protected" or not. -// When protected, a device can only be updated or removed if the -// user is authenticated with that very device. -type DeviceProtection = variant { - protected; - unprotected; -}; - -type Challenge = record { - png_base64: text; - challenge_key: ChallengeKey; -}; - -type DeviceData = record { - pubkey : DeviceKey; - alias : text; - credential_id : opt CredentialId; - purpose: Purpose; - key_type: KeyType; - protection: DeviceProtection; - origin: opt text; - // Metadata map for additional device information. - // - // Note: some fields above will be moved to the metadata map in the future. - // All field names of `DeviceData` (such as 'alias', 'origin, etc.) are - // reserved and cannot be written. - // In addition, the keys "usage" and "authenticator_attachment" are reserved as well. - metadata: opt MetadataMap; -}; - -// The same as `DeviceData` but with the `last_usage` field. -// This field cannot be written, hence the separate type. -type DeviceWithUsage = record { - pubkey : DeviceKey; - alias : text; - credential_id : opt CredentialId; - purpose: Purpose; - key_type: KeyType; - protection: DeviceProtection; - origin: opt text; - last_usage: opt Timestamp; - metadata: opt MetadataMap; -}; - -// Map with some variants for the value type. -// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. -type MetadataMap = vec record { - text; - variant { map : MetadataMap; string : text; bytes : vec nat8 }; -}; - -type RegisterResponse = variant { - // A new user was successfully registered. - registered: record { - user_number: UserNumber; - }; - // No more registrations are possible in this instance of the II service canister. - canister_full; - // The challenge was not successful. - bad_challenge; -}; - -type AddTentativeDeviceResponse = variant { - // The device was tentatively added. - added_tentatively: record { - verification_code: text; - // Expiration date, in nanos since the epoch - device_registration_timeout: Timestamp; - }; - // Device registration mode is off, either due to timeout or because it was never enabled. - device_registration_mode_off; - // There is another device already added tentatively - another_device_tentatively_added; -}; - -type VerifyTentativeDeviceResponse = variant { - // The device was successfully verified. - verified; - // Wrong verification code entered. Retry with correct code. - wrong_code: record { - retries_left: nat8 - }; - // Device registration mode is off, either due to timeout or because it was never enabled. - device_registration_mode_off; - // There is no tentative device to be verified. - no_device_to_verify; -}; - -type Delegation = record { - pubkey: PublicKey; - expiration: Timestamp; - targets: opt vec principal; -}; - -type SignedDelegation = record { - delegation: Delegation; - signature: blob; -}; - -type GetDelegationResponse = variant { - // The signed delegation was successfully retrieved. - signed_delegation: SignedDelegation; - - // The signature is not ready. Maybe retry by calling `prepare_delegation` - no_such_delegation -}; - -type InternetIdentityStats = record { - users_registered: nat64; - storage_layout_version: nat8; - assigned_user_number_range: record { - nat64; - nat64; - }; - archive_info: ArchiveInfo; - canister_creation_cycles_cost: nat64; - max_num_latest_delegation_origins: nat64; - latest_delegation_origins: vec FrontendHostname -}; - -// Configuration parameters related to the archive. -type ArchiveConfig = record { - // The allowed module hash of the archive canister. - // Changing this parameter does _not_ deploy the archive, but enable archive deployments with the - // corresponding wasm module. - module_hash : blob; - // Buffered archive entries limit. If reached, II will stop accepting new anchor operations - // until the buffered operations are acknowledged by the archive. - entries_buffer_limit: nat64; - // The maximum number of entries to be transferred to the archive per call. - entries_fetch_limit: nat16; - // Polling interval to fetch new entries from II (in nanoseconds). - // Changes to this parameter will only take effect after an archive deployment. - polling_interval_ns: nat64; -}; - -// Information about the archive. -type ArchiveInfo = record { - // Canister id of the archive or empty if no archive has been deployed yet. - archive_canister : opt principal; - // Configuration parameters related to the II archive. - archive_config: opt ArchiveConfig; -}; - -// Rate limit configuration. -// Currently only used for `register`. -type RateLimitConfig = record { - // Time it takes (in ns) for a rate limiting token to be replenished. - time_per_token_ns : nat64; - // How many tokens are at most generated (to accommodate peaks). - max_tokens: nat64; -}; - -// Init arguments of II which can be supplied on install and upgrade. -// Setting a value to null keeps the previous value. -type InternetIdentityInit = record { - // Set lowest and highest anchor - assigned_user_number_range : opt record { - nat64; - nat64; - }; - // Configuration parameters related to the II archive. - // Note: some parameters changes (like the polling interval) will only take effect after an archive deployment. - // See ArchiveConfig for details. - archive_config: opt ArchiveConfig; - // Set the amounts of cycles sent with the create canister message. - // This is configurable because in the staging environment cycles are required. - // The canister creation cost on mainnet is currently 100'000'000'000 cycles. If this value is higher thant the - // canister creation cost, the newly created canister will keep extra cycles. - canister_creation_cycles_cost : opt nat64; - // Rate limit for the `register` call. - register_rate_limit : opt RateLimitConfig; - // Maximum number of latest delegation origins to track. - // Default: 1000 - max_num_latest_delegation_origins : opt nat64; - // Maximum number of inflight captchas. - // Default: 500 - max_inflight_captchas: opt nat64; -}; - -type ChallengeKey = text; - -type ChallengeResult = record { - key : ChallengeKey; - chars : text; -}; -type CaptchaResult = ChallengeResult; - -// Extra information about registration status for new devices -type DeviceRegistrationInfo = record { - // If present, the user has tentatively added a new device. This - // new device needs to be verified (see relevant endpoint) before - // 'expiration'. - tentative_device : opt DeviceData; - // The timestamp at which the anchor will turn off registration mode - // (and the tentative device will be forgotten, if any, and if not verified) - expiration: Timestamp; -}; - -// Information about the anchor -type IdentityAnchorInfo = record { - // All devices that can authenticate to this anchor - devices : vec DeviceWithUsage; - // Device registration status used when adding devices, see DeviceRegistrationInfo - device_registration: opt DeviceRegistrationInfo; -}; - -type AnchorCredentials = record { - credentials : vec WebAuthnCredential; - recovery_credentials : vec WebAuthnCredential; - recovery_phrases: vec PublicKey; -}; - -type WebAuthnCredential = record { - credential_id : CredentialId; - pubkey: PublicKey; -}; - -type DeployArchiveResult = variant { - // The archive was deployed successfully and the supplied wasm module has been installed. The principal of the archive - // canister is returned. - success: principal; - // Initial archive creation is already in progress. - creation_in_progress; - // Archive deployment failed. An error description is returned. - failed: text; -}; - -type BufferedArchiveEntry = record { - anchor_number: UserNumber; - timestamp: Timestamp; - sequence_number: nat64; - entry: blob; -}; - -// API V2 specific types -// WARNING: These type are experimental and may change in the future. - -type IdentityNumber = nat64; - -// Map with some variants for the value type. -// Note, due to the Candid mapping this must be a tuple type thus we cannot name the fields `key` and `value`. -type MetadataMapV2 = vec record { - text; - variant { Map : MetadataMapV2; String : text; Bytes : vec nat8 }; -}; - -// Authentication method using WebAuthn signatures -// See https://www.w3.org/TR/webauthn-2/ -// This is a separate type because WebAuthn requires to also store -// the credential id (in addition to the public key). -type WebAuthn = record { - credential_id: CredentialId; - pubkey: PublicKey; -}; - -// Authentication method using generic signatures -// See https://internetcomputer.org/docs/current/references/ic-interface-spec/#signatures for -// supported signature schemes. -type PublicKeyAuthn = record { - pubkey: PublicKey; -}; - -// The authentication methods currently supported by II. -type AuthnMethod = variant { - WebAuthn: WebAuthn; - PubKey: PublicKeyAuthn; -}; - -// This describes whether an authentication method is "protected" or not. -// When protected, a authentication method can only be updated or removed if the -// user is authenticated with that very authentication method. -type AuthnMethodProtection = variant { - Protected; - Unprotected; -}; - -type AuthnMethodPurpose = variant { - Recovery; - Authentication; -}; - -type AuthnMethodSecuritySettings = record { - protection: AuthnMethodProtection; - purpose: AuthnMethodPurpose; -}; - -type AuthnMethodData = record { - authn_method: AuthnMethod; - security_settings: AuthnMethodSecuritySettings; - // contains the following fields of the DeviceWithUsage type: - // - alias - // - origin - // - authenticator_attachment: data taken from key_type and reduced to "platform", "cross_platform" or absent on migration - // - usage: data taken from key_type and reduced to "recovery_phrase", "browser_storage_key" or absent on migration - // Note: for compatibility reasons with the v1 API, the entries above (if present) - // must be of the `String` variant. This restriction may be lifted in the future. - metadata: MetadataMapV2; - last_authentication: opt Timestamp; -}; - -// Extra information about registration status for new authentication methods -type AuthnMethodRegistrationInfo = record { - // If present, the user has registered a new authentication method. This - // new authentication needs to be verified before 'expiration' in order to - // be added to the identity. - authn_method : opt AuthnMethodData; - // The timestamp at which the identity will turn off registration mode - // (and the authentication method will be forgotten, if any, and if not verified) - expiration: Timestamp; -}; - -type AuthnMethodConfirmationCode = record { - confirmation_code: text; - expiration: Timestamp; -}; - -type AuthnMethodRegisterError = variant { - // Authentication method registration mode is off, either due to timeout or because it was never enabled. - RegistrationModeOff; - // There is another authentication method already registered that needs to be confirmed first. - RegistrationAlreadyInProgress; - // The metadata of the provided authentication method contains invalid entries. - InvalidMetadata: text; -}; - -type AuthnMethodConfirmationError = variant { - // Wrong confirmation code entered. Retry with correct code. - WrongCode: record { - retries_left: nat8 - }; - // Authentication method registration mode is off, either due to timeout or because it was never enabled. - RegistrationModeOff; - // There is no registered authentication method to be confirmed. - NoAuthnMethodToConfirm; -}; - -type IdentityAuthnInfo = record { - authn_methods: vec AuthnMethod; - recovery_authn_methods: vec AuthnMethod; -}; - -type IdentityInfo = record { - authn_methods: vec AuthnMethodData; - authn_method_registration: opt AuthnMethodRegistrationInfo; - // Authentication method independent metadata - metadata: MetadataMapV2; -}; - -type IdentityInfoError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - - - -type IdentityRegisterError = variant { - // No more registrations are possible in this instance of the II service canister. - CanisterFull; - // The captcha check was not successful. - BadCaptcha; - // The metadata of the provided authentication method contains invalid entries. - InvalidMetadata: text; -}; - -type AuthnMethodAddError = variant { - InvalidMetadata: text; -}; - -type AuthnMethodReplaceError = variant { - InvalidMetadata: text; - // No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type AuthnMethodMetadataReplaceError = variant { - InvalidMetadata: text; - /// No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type AuthnMethodSecuritySettingsReplaceError = variant { - /// No authentication method found with the given public key. - AuthnMethodNotFound; -}; - -type IdentityMetadataReplaceError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// The identity including the new metadata exceeds the maximum allowed size. - StorageSpaceExceeded: record {space_available: nat64; space_required: nat64}; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -type PrepareIdAliasRequest = record { - /// Origin of the issuer in the attribute sharing flow. - issuer : FrontendHostname; - /// Origin of the relying party in the attribute sharing flow. - relying_party : FrontendHostname; - /// Identity for which the IdAlias should be generated. - identity_number : IdentityNumber; -}; - -type PrepareIdAliasError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -/// The prepared id alias contains two (still unsigned) credentials in JWT format, -/// certifying the id alias for the issuer resp. the relying party. -type PreparedIdAlias = record { - rp_id_alias_jwt : text; - issuer_id_alias_jwt : text; - canister_sig_pk_der : PublicKey; -}; - -/// The request to retrieve the actual signed id alias credentials. -/// The field values should be equal to the values of corresponding -/// fields from the preceding `PrepareIdAliasRequest` and `PrepareIdAliasResponse`. -type GetIdAliasRequest = record { - rp_id_alias_jwt : text; - issuer : FrontendHostname; - issuer_id_alias_jwt : text; - relying_party : FrontendHostname; - identity_number : IdentityNumber; -}; - -type GetIdAliasError = variant { - /// The principal is not authorized to call this method with the given arguments. - Unauthorized: principal; - /// The credential(s) are not available: may be expired or not prepared yet (call prepare_id_alias to prepare). - NoSuchCredentials : text; - /// Internal canister error. See the error message for details. - InternalCanisterError: text; -}; - -/// The signed id alias credentials for each involved party. -type IdAliasCredentials = record { - rp_id_alias_credential : SignedIdAlias; - issuer_id_alias_credential : SignedIdAlias; -}; - -type SignedIdAlias = record { - credential_jws : text; - id_alias : principal; - id_dapp : principal; -}; - -service : (opt InternetIdentityInit) -> { - init_salt: () -> (); - create_challenge : () -> (Challenge); - register : (DeviceData, ChallengeResult, opt principal) -> (RegisterResponse); - add : (UserNumber, DeviceData) -> (); - update : (UserNumber, DeviceKey, DeviceData) -> (); - // Atomically replace device matching the device key with the new device data - replace : (UserNumber, DeviceKey, DeviceData) -> (); - remove : (UserNumber, DeviceKey) -> (); - // Returns all devices of the user (authentication and recovery) but no information about device registrations. - // Note: Clears out the 'alias' fields on the devices. Use 'get_anchor_info' to obtain the full information. - // Deprecated: Use 'get_anchor_credentials' instead. - lookup : (UserNumber) -> (vec DeviceData) query; - get_anchor_credentials : (UserNumber) -> (AnchorCredentials) query; - get_anchor_info : (UserNumber) -> (IdentityAnchorInfo); - get_principal : (UserNumber, FrontendHostname) -> (principal) query; - stats : () -> (InternetIdentityStats) query; - - enter_device_registration_mode : (UserNumber) -> (Timestamp); - exit_device_registration_mode : (UserNumber) -> (); - add_tentative_device : (UserNumber, DeviceData) -> (AddTentativeDeviceResponse); - verify_tentative_device : (UserNumber, verification_code: text) -> (VerifyTentativeDeviceResponse); - - prepare_delegation : (UserNumber, FrontendHostname, SessionKey, maxTimeToLive : opt nat64) -> (UserKey, Timestamp); - get_delegation: (UserNumber, FrontendHostname, SessionKey, Timestamp) -> (GetDelegationResponse) query; - - http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_update: (request: HttpRequest) -> (HttpResponse); - - deploy_archive: (wasm: blob) -> (DeployArchiveResult); - /// Returns a batch of entries _sorted by sequence number_ to be archived. - /// This is an update call because the archive information _must_ be certified. - /// Only callable by this IIs archive canister. - fetch_entries: () -> (vec BufferedArchiveEntry); - acknowledge_entries: (sequence_number: nat64) -> (); - - // V2 API - // WARNING: The following methods are experimental and may change in the future. - - // Creates a new captcha. The solution needs to be submitted using the - // `identity_register` call. - captcha_create: () -> (variant {Ok: Challenge; Err;}); - - // Registers a new identity with the given authn_method. - // A valid captcha solution to a previously generated captcha (using create_captcha) must be provided. - // The sender needs to match the supplied authn_method. - identity_register: (AuthnMethodData, CaptchaResult, opt principal) -> (variant {Ok: IdentityNumber; Err: IdentityRegisterError;}); - - // Returns information about the authentication methods of the identity with the given number. - // Only returns the minimal information required for authentication without exposing any metadata such as aliases. - identity_authn_info: (IdentityNumber) -> (variant {Ok: IdentityAuthnInfo; Err;}) query; - - // Returns information about the identity with the given number. - // Requires authentication. - identity_info: (IdentityNumber) -> (variant {Ok: IdentityInfo; Err: IdentityInfoError;}); - - // Replaces the authentication method independent metadata map. - // The existing metadata map will be overwritten. - // Requires authentication. - identity_metadata_replace: (IdentityNumber, MetadataMapV2) -> (variant {Ok; Err: IdentityMetadataReplaceError;}); - - // Adds a new authentication method to the identity. - // Requires authentication. - authn_method_add: (IdentityNumber, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodAddError;}); - - // Atomically replaces the authentication method matching the supplied public key with the new authentication method - // provided. - // Requires authentication. - authn_method_replace: (IdentityNumber, PublicKey, AuthnMethodData) -> (variant {Ok; Err: AuthnMethodReplaceError;}); - - // Replaces the authentication method metadata map. - // The existing metadata map will be overwritten. - // Requires authentication. - authn_method_metadata_replace: (IdentityNumber, PublicKey, MetadataMapV2) -> (variant {Ok; Err: AuthnMethodMetadataReplaceError;}); - - // Replaces the authentication method security settings. - // The existing security settings will be overwritten. - // Requires authentication. - authn_method_security_settings_replace: (IdentityNumber, PublicKey, AuthnMethodSecuritySettings) -> (variant {Ok; Err: AuthnMethodSecuritySettingsReplaceError;}); - - // Removes the authentication method associated with the public key from the identity. - // Requires authentication. - authn_method_remove: (IdentityNumber, PublicKey) -> (variant {Ok; Err;}); - - // Enters the authentication method registration mode for the identity. - // In this mode, a new authentication method can be registered, which then needs to be - // confirmed before it can be used for authentication on this identity. - // The registration mode is automatically exited after the returned expiration timestamp. - // Requires authentication. - authn_method_registration_mode_enter : (IdentityNumber) -> (variant {Ok: record { expiration: Timestamp; }; Err;}); - - // Exits the authentication method registration mode for the identity. - // Requires authentication. - authn_method_registration_mode_exit : (IdentityNumber) -> (variant {Ok; Err;}); - - // Registers a new authentication method to the identity. - // This authentication method needs to be confirmed before it can be used for authentication on this identity. - authn_method_register: (IdentityNumber, AuthnMethodData) -> (variant {Ok: AuthnMethodConfirmationCode; Err: AuthnMethodRegisterError;}); - - // Confirms a previously registered authentication method. - // On successful confirmation, the authentication method is permanently added to the identity and can - // subsequently be used for authentication for that identity. - // Requires authentication. - authn_method_confirm: (IdentityNumber, confirmation_code: text) -> (variant {Ok; Err: AuthnMethodConfirmationError;}); - - // Attribute Sharing MVP API - // The methods below are used to generate ID-alias credentials during attribute sharing flow. - prepare_id_alias : (PrepareIdAliasRequest) -> (variant {Ok: PreparedIdAlias; Err: PrepareIdAliasError;}); - get_id_alias : (GetIdAliasRequest) -> (variant {Ok: IdAliasCredentials; Err: GetIdAliasError;}) query; -} - ‰Ñúz‘Ⱥf¹Ù£ùð0Áz¦ôŸÚ`৛ -³ -dfx«„{"pullable":{"wasm_url":"https://github.com/dfinity/internet-identity/releases/download/release-2024-04-05/internet_identity_dev.wasm.gz","wasm_hash_url":"https://github.com/dfinity/internet-identity/releases/download/release-2024-04-05/internet_identity_dev.wasm.gz.sha256","dependencies":[],"init_guide":"Use '(null)' for sensible defaults. See the candid interface for more details."}} Ù](9äB¦‹øY͹æäÃüÍ2­&›!o¯z¢¥”W -K -supported_certificate_versions)1,2 ŽÔ»bØ—øÑŒ;ZâFATbà€'¨ø_¿M»'‡&û—2 81û<Ô<²é‘·÷:F—5Jêw6 u?T+ë·¼²ܑȬ¸€šžÊ - -€Ê -ˆVÆ Å1Kdzž³u²1³¾BÔƒÞXOLOÊÒ$ÔàÏØ‚ú -îÎÉÇÓ±Ýá‚ ¢ÈàX¢ -ó Ö¢ ß¼—V¢Ö¹¢ -ì™ýÓª¦ -KížîÍÊüÛá" - - -€*/ - - -€ - -ˆVÆ Å1Kdzž³u²1³¾BÔƒÞXOLOÊ -U‚šÌ‰…ýÛá! - -ˆVÆ Å1Kdzž³u²1³¾BÔƒÞXOLOÊ:$ 81û<Ô<> 24), byte(n >> 16), byte(n >> 8), byte(n)]; }; - public func defaultSubaccount() : Subaccount { - Blob.fromArrayMut(Array.init(32, 0 : Nat8)); + /// Parses account from its textual representation. + public func fromText(text : Text) : Result.Result { + let n = text.size(); + + if (n == 0) { + return #err(#malformed("empty")); + }; + + let charsIter = text.chars(); + let chars = Array.tabulate(n, func(_ : Nat) : Char { Option.get(charsIter.next(), ' ') }); + + var lastDash = n; + var dot = n; + + // Find the last dash and the dot. + label l for (i in Iter.range(0, n - 1)) { + if (chars[i] == '-') { lastDash := i }; + if (chars[i] == '.') { dot := i; break l }; + }; + + if (lastDash == n) { + return #err(#malformed("expected at least one dash ('-') character")); + }; + + if (dot == n) { + // No subaccount separator: the principal case. + return #ok({ owner = Principal.fromText(text); subaccount = null }); + }; + + let numSubaccountDigits = (n - dot - 1) : Nat; + + if (numSubaccountDigits > 64) { + return #err(#malformed("the subaccount is too long (expected at most 64 characters)")); + }; + + if (dot < lastDash) { + return #err(#malformed("the subaccount separator does not follow the checksum separator")); + }; + + if (dot - lastDash - 1 : Nat != 7) { + return #err(#bad_checksum); + }; + + // The encoding ends with a dot, the subaccount is empty. + if (dot == (n - 1 : Nat)) { + return #err(#not_canonical); + }; + + // The first digit after the dot must not be a zero. + if (chars[dot + 1] == '0') { + return #err(#not_canonical); + }; + + let principalText = Text.fromIter(iterSlice(chars, 0, lastDash - 1 : Nat)); + let owner = Principal.fromText(principalText); + + var subaccountMut = Array.init(32, 0); + + let subaccountDigits = iterChain( + iterReplicate('0', 64 - numSubaccountDigits : Nat), + iterSlice(chars, dot + 1, n - 1 : Nat), + ); + + // Decode hex backwards into the subaccount array. + for ((i, c) in iterEnumerate(subaccountDigits)) { + let value = switch (decodeHexDigit(c)) { + case (?v) { v }; + case (null) { + return #err(#malformed("invalid hex char: '" # Text.fromChar(c) # "'")); + }; + }; + subaccountMut[i / 2] += value << (4 * Nat8.fromNat(1 - i % 2)); + }; + + // Check that the subaccount is not the default. + if (iterAll(subaccountMut.vals(), func(x : Nat8) : Bool { x == 0 })) { + return #err(#not_canonical); + }; + + let subaccount = Blob.fromArrayMut(subaccountMut); + + if (not iterEqual(checkSum(owner, subaccount).chars(), iterSlice(chars, lastDash + 1, dot - 1 : Nat), Char.equal)) { + return #err(#bad_checksum); + }; + + #ok({ owner = owner; subaccount = ?subaccount }); }; - public func accountIdentifier(principal : Principal, subaccount : Subaccount) : AccountIdentifier { - let hash = SHA224.Digest(); - hash.write([0x0A]); - hash.write(Blob.toArray(Text.encodeUtf8("account-id"))); - hash.write(Blob.toArray(Principal.toBlob(principal))); - hash.write(Blob.toArray(subaccount)); - let hashSum = hash.sum(); - let crc32Bytes = beBytes(CRC32.ofArray(hashSum)); - let buf = Buffer.Buffer(32); - Blob.fromArray(Array.append(crc32Bytes, hashSum)); + // prettier-ignore + let hexDigits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; + + func hexDigit(n : Nat8) : Char { + hexDigits[Nat8.toNat(n)]; }; - public func validateAccountIdentifier(accountIdentifier : AccountIdentifier) : Bool { - if (accountIdentifier.size() != 32) { - return false; + func decodeHexDigit(c : Char) : ?Nat8 { + switch (c) { + case ('0') { ?0 }; + case ('1') { ?1 }; + case ('2') { ?2 }; + case ('3') { ?3 }; + case ('4') { ?4 }; + case ('5') { ?5 }; + case ('6') { ?6 }; + case ('7') { ?7 }; + case ('8') { ?8 }; + case ('9') { ?9 }; + case ('a') { ?10 }; + case ('b') { ?11 }; + case ('c') { ?12 }; + case ('d') { ?13 }; + case ('e') { ?14 }; + case ('f') { ?15 }; + case _ { null }; }; - let a = Blob.toArray(accountIdentifier); - let accIdPart = Array.tabulate(28, func(i : Nat) : Nat8 { a[i + 4] }); - let checksumPart = Array.tabulate(4, func(i : Nat) : Nat8 { a[i] }); - let crc32 = CRC32.ofArray(accIdPart); - Array.equal(beBytes(crc32), checksumPart, Nat8.equal); }; - public func principalToSubaccount(principal : Principal) : Blob { - let idHash = SHA224.Digest(); - idHash.write(Blob.toArray(Principal.toBlob(principal))); - let hashSum = idHash.sum(); - let crc32Bytes = beBytes(CRC32.ofArray(hashSum)); - let buf = Buffer.Buffer(32); - Blob.fromArray(Array.append(crc32Bytes, hashSum)); + // prettier-ignore + let crc32Table : [Nat32] = + [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f + , 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988 + , 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2 + , 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7 + , 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9 + , 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172 + , 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c + , 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59 + , 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423 + , 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924 + , 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106 + , 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433 + , 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d + , 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e + , 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950 + , 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65 + , 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7 + , 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0 + , 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa + , 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f + , 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81 + , 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a + , 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84 + , 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1 + , 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb + , 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc + , 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e + , 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b + , 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55 + , 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236 + , 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28 + , 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d + , 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f + , 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38 + , 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242 + , 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777 + , 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69 + , 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2 + , 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc + , 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9 + , 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693 + , 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94 + , 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + ]; + + let crc32Seed : Nat32 = 0xffffffff; + + // prettier-ignore + let base32Alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "2", "3", "4", "5", "6", "7"]; + + func updateCrc(crc : Nat32, byte : Nat8) : Nat32 { + crc32Table[Nat32.toNat(crc ^ Nat32.fromNat(Nat8.toNat(byte)) & 0xff)] ^ (crc >> 8); + }; + + public func checkSum(owner : Principal, subaccount : Blob) : Text { + let crc = crc32Seed ^ iterFold(iterChain(Principal.toBlob(owner).vals(), subaccount.vals()), updateCrc, crc32Seed); + + let d = func(shift : Nat) : Text { + base32Alphabet[Nat32.toNat((crc >> Nat32.fromNat(shift)) & 0x1f)]; + }; + + d(27) # d(22) # d(17) # d(12) # d(7) # d(2) # base32Alphabet[Nat32.toNat((crc & 0x03) << 3)]; + }; + + // Hex-encodes a subaccount, skipping the leading zeros. + func displaySubaccount(subaccount : Blob) : Text { + func nibbles(b : Nat8) : Iter.Iter { + iterChain(iterOnce(b / 16), iterOnce(b % 16)); + }; + + Text.fromIter( + Iter.map( + iterSkipWhile( + iterFlatMap(subaccount.vals(), nibbles), + func(b : Nat8) : Bool { b == 0 }, + ), + hexDigit, + ) + ); + }; + + // Helper functions to deal with iterators + + func iterSlice(a : [T], from : Nat, to : Nat) : Iter.Iter { + Iter.map(Iter.range(from, to), func(i : Nat) : T { a[i] }); + }; + + func iterEqual(xs : Iter.Iter, ys : Iter.Iter, eq : (T, T) -> Bool) : Bool { + loop { + switch ((xs.next(), ys.next())) { + case ((null, null)) { return true }; + case ((null, _)) { return false }; + case ((_, null)) { return false }; + case ((?x, ?y)) { if (not eq(x, y)) { return false } }; + }; + }; + }; + + func iterAll(xs : Iter.Iter, predicate : (T) -> Bool) : Bool { + loop { + switch (xs.next()) { + case (null) { return true }; + case (?x) { if (not predicate(x)) { return false } }; + }; + }; + }; + + func iterSkipWhile(xs : Iter.Iter, predicate : (T) -> Bool) : Iter.Iter { + loop { + switch (xs.next()) { + case (null) { return xs }; + case (?x) { + if (not predicate(x)) { + return iterChain(iterOnce(x), xs); + }; + }; + }; + }; + }; + + func iterEnumerate(xs : Iter.Iter) : Iter.Iter<(Nat, T)> = object { + var counter = 0; + + public func next() : ?(Nat, T) { + switch (xs.next()) { + case (?x) { + let count = counter; + counter += 1; + ?(count, x); + }; + case (null) { null }; + }; + }; + }; + + func iterFlatMap(xs : Iter.Iter, f : (T) -> Iter.Iter) : Iter.Iter = object { + var it = iterEmpty(); + + public func next() : ?S { + loop { + switch (it.next()) { + case (?s) { return ?s }; + case (null) { + switch (xs.next()) { + case (null) { return null }; + case (?x) { it := f(x) }; + }; + }; + }; + }; + }; + }; + + func iterReplicate(x : T, times : Nat) : Iter.Iter = object { + var left = times; + + public func next() : ?T { + if (left == 0) { null } else { left -= 1; ?x }; + }; + }; + + func iterEmpty() : Iter.Iter = object { + public func next() : ?T = null; + }; + + func iterOnce(x : T) : Iter.Iter = object { + var value = ?x; + + public func next() : ?T { + let old_value = value; + value := null; + old_value; + }; + }; + + func iterChain(xs : Iter.Iter, ys : Iter.Iter) : Iter.Iter = object { + public func next() : ?T { + switch (xs.next()) { + case (null) { ys.next() }; + case (?x) { ?x }; + }; + }; + }; + + func iterFold(xs : Iter.Iter, f : (A, T) -> A, seed : A) : A { + var acc = seed; + loop { + switch (xs.next()) { + case (null) { return acc }; + case (?x) { acc := f(acc, x) }; + }; + }; }; -}; +}; \ No newline at end of file diff --git a/canisters/backend/date/Base.mo b/canisters/backend/date/Base.mo index 41341ba0..6cba34a8 100644 --- a/canisters/backend/date/Base.mo +++ b/canisters/backend/date/Base.mo @@ -14,7 +14,7 @@ module Base { */ public func showYear(year : Year) : Text { let #Year n = year; - Int.toText(n) + Int.toText(n); }; /** @@ -52,7 +52,7 @@ module Base { case (#October) "October"; case (#November) "November"; case (#December) "December"; - } + }; }; /** @@ -72,7 +72,7 @@ module Base { case (#October) "Oct"; case (#November) "Nov"; case (#December) "Dec"; - } + }; }; /** @@ -87,7 +87,7 @@ module Base { */ public func showDay(day : Day) : Text { let #Day n = day; - Int.toText(n) + Int.toText(n); }; /** @@ -115,7 +115,7 @@ module Base { case (#Thursday) "Thursday"; case (#Friday) "Friday"; case (#Saturday) "Saturday"; - } + }; }; /** @@ -130,7 +130,7 @@ module Base { case (#Thursday) "Thu"; case (#Friday) "Fri"; case (#Saturday) "Sat"; - } + }; }; /** @@ -145,7 +145,7 @@ module Base { */ public func showHour(hour : Hour) : Text { let #Hour n = hour; - Int.toText(n) + Int.toText(n); }; /** @@ -160,7 +160,7 @@ module Base { */ public func showMinute(min : Minute) : Text { let #Minute n = min; - Int.toText(n) + Int.toText(n); }; /** @@ -175,7 +175,7 @@ module Base { */ public func showSecond(sec : Second) : Text { let #Second n = sec; - Int.toText(n) + Int.toText(n); }; /** @@ -190,7 +190,7 @@ module Base { */ public func showNanos(nanos : Nanos) : Text { let #Nanos n = nanos; - Int.toText(n) + Int.toText(n); }; /** @@ -215,7 +215,7 @@ module Base { accum #= showWithPad(2, showDay(parts.day)); accum #= " "; accum #= showWithPad(4, showYear(parts.year)); - accum + accum; }; /** @@ -241,6 +241,6 @@ module Base { accum := "0" # accum; i += 1; }; - accum + accum; }; -}; \ No newline at end of file +}; diff --git a/canisters/backend/date/Date.mo b/canisters/backend/date/Date.mo index 7d11dcbe..746fe4d3 100644 --- a/canisters/backend/date/Date.mo +++ b/canisters/backend/date/Date.mo @@ -22,20 +22,20 @@ module Date { * Show a date. */ public func show(date : Date) : Text { - Base.showDateParts(unpack(date)) + Base.showDateParts(unpack(date)); }; /** * Create a date. */ - public func create(year : Year, month : Month, day : Day) : ? Date { + public func create(year : Year, month : Month, day : Day) : ?Date { let days = epochToDate(year, month, day); if (0 <= days and days <= 2932896) { let base = Int32.fromInt(days); - ? #Date base + ? #Date base; } else { - null - } + null; + }; }; /** @@ -43,14 +43,14 @@ module Date { */ public func now() : Date { let base = Int32.fromInt(Nat64.toNat(Prim.time()) / 86400000000000); - #Date base + #Date base; }; /** * Pack a date from parts. */ - public func pack(parts : DateParts) : ? Date { - create(parts.year, parts.month, parts.day) + public func pack(parts : DateParts) : ?Date { + create(parts.year, parts.month, parts.day); }; /** @@ -70,66 +70,34 @@ module Date { let (month, day) = if (leap) { if (days > 181) { if (days > 273) { - if (days > 334) { - (#December, days - 334) - } else if (days > 304) { - (#November, days - 304) - } else { - (#October, days - 273) - } - } else if (days > 243) { - (#September, days - 243) - } else if (days > 212) { - (#August, days - 212) - } else { - (#July, days - 181) - } + if (days > 334) { (#December, days - 334) } else if (days > 304) { + (#November, days - 304); + } else { (#October, days - 273) }; + } else if (days > 243) { (#September, days - 243) } else if (days > 212) { + (#August, days - 212); + } else { (#July, days - 181) }; } else if (days > 90) { - if (days > 151) { - (#June, days - 151) - } else if (days > 120) { - (#May, days - 120) - } else { - (#April, days - 90) - } - } else if (days > 59) { - (#March, days - 59) - } else if (days > 30) { - (#February, days - 30) - } else { - (#January, days + 1) - } + if (days > 151) { (#June, days - 151) } else if (days > 120) { + (#May, days - 120); + } else { (#April, days - 90) }; + } else if (days > 59) { (#March, days - 59) } else if (days > 30) { + (#February, days - 30); + } else { (#January, days + 1) }; } else if (days > 180) { if (days > 272) { - if (days > 333) { - (#December, days - 333) - } else if (days > 303) { - (#November, days - 303) - } else { - (#October, days - 272) - } - } else if (days > 242) { - (#September, days - 242) - } else if (days > 211) { - (#August, days - 211) - } else { - (#July, days - 180) - } + if (days > 333) { (#December, days - 333) } else if (days > 303) { + (#November, days - 303); + } else { (#October, days - 272) }; + } else if (days > 242) { (#September, days - 242) } else if (days > 211) { + (#August, days - 211); + } else { (#July, days - 180) }; } else if (days > 89) { - if (days > 151) { - (#June, days - 150) - } else if (days > 119) { - (#May, days - 119) - } else { - (#April, days - 89) - } - } else if (days > 58) { - (#March, days - 58) - } else if (days > 30) { - (#February, days - 30) - } else { - (#January, days + 1) - }; + if (days > 151) { (#June, days - 150) } else if (days > 119) { + (#May, days - 119); + } else { (#April, days - 89) }; + } else if (days > 58) { (#March, days - 58) } else if (days > 30) { + (#February, days - 30); + } else { (#January, days + 1) }; let wday = switch (1 + (Int32.toInt(base) + 4) % 7) { case 1 #Sunday; case 2 #Monday; @@ -144,7 +112,7 @@ module Date { month = month; day = #Day day; wday = wday; - } + }; }; /** @@ -152,7 +120,7 @@ module Date { */ private func isLeapYear(year : Year) : Bool { let #Year y = year; - y % 400 == 0 or y % 100 != 0 and y % 4 == 0 + y % 400 == 0 or y % 100 != 0 and y % 4 == 0; }; /** @@ -161,7 +129,7 @@ module Date { */ private func epochToDate(year : Year, month : Month, day : Day) : Int { let leap = isLeapYear(year); - epochToYear(year) + yearToMonth(leap, month) + monthToDay(day) - 1 + epochToYear(year) + yearToMonth(leap, month) + monthToDay(day) - 1; }; /** @@ -170,7 +138,7 @@ module Date { */ private func epochToYear(year : Year) : Int { let #Year y = year; - 365 * (y - 1970) + (y - 1969) / 4 - (y - 1901) / 100 + (y - 1601) / 400 + 365 * (y - 1970) + (y - 1969) / 4 - (y - 1901) / 100 + (y - 1601) / 400; }; /** @@ -192,7 +160,7 @@ module Date { case (#October) 274; case (#November) 305; case (#December) 335; - } + }; } else { switch (month) { case (#January) 0; @@ -207,8 +175,8 @@ module Date { case (#October) 273; case (#November) 304; case (#December) 334; - } - } + }; + }; }; /** @@ -217,6 +185,6 @@ module Date { */ private func monthToDay(day : Day) : Int { let #Day d = day; - d + d; }; -}; \ No newline at end of file +}; diff --git a/canisters/backend/main.mo b/canisters/backend/main.mo index abf91cf7..9291797a 100644 --- a/canisters/backend/main.mo +++ b/canisters/backend/main.mo @@ -33,25 +33,34 @@ import Hex "./Hex"; import Timer "mo:base/Timer"; import { abs } = "mo:base/Int"; import { now } = "mo:base/Time"; -import { setTimer; recurringTimer; cancelTimer ; } = "mo:base/Timer"; +import { setTimer; recurringTimer; cancelTimer } = "mo:base/Timer"; +import Taxcalculator "taxcalculator"; +import MyAccount "./Account"; shared (actorContext) actor class Backend(_startBlock : Nat) = this { // #region Types type Account = Types.Account; + type Payslip = Types.Payslip; + type PayslipData = Types.PayslipData; type AccountIdentifier = Types.AccountIdentifier; type Transaction = Types.Transaction; + type Department = Types.Department; + type Organization = Types.Organization; + type Designation = Types.Designation; type User = Types.User; type Notification = Types.Notification; type PayrollType = Types.PayrollType; type Employee = Types.Employee; type Invoice = Types.Invoice; + type Emp = Types.Emp; public type TransactionId = Nat32; let r = Random.Finite("username"); // #endregion let addressConverter_ = Utils.addressConverter; + // The next available transaction identifier. private stable var latestTransactionIndex : Nat = 0; private stable var courierApiKey : Text = ""; @@ -59,20 +68,33 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { // The user data store. The key is the user's principal ID. private stable var userStore : Trie.Trie = Trie.empty(); stable var transactionsStable : [(Nat, Transaction)] = []; + stable var departmentsStable : [(Nat, Department)] = []; + stable var organizationsStable : [(Nat, Organization)] = []; + stable var designationsStable : [(Nat, Designation)] = []; stable var contactsStable : [(Nat, Employee)] = []; + stable var stableEmployees : [(Nat, Emp)] = []; stable var notificationsStable : [(Nat, Notification)] = []; stable var invoicesStable : [(Nat, Invoice)] = []; stable var stablePayroll : [(Nat, [PayrollType])] = []; stable var transactionCounter : Nat = 0; stable var contactsCounter : Nat = 0; + stable var noOfEmployees : Nat = 0; + stable var organizationsCounter : Nat = 0; + stable var departmentsCounter : Nat = 0; + stable var designationsCounter : Nat = 0; let oneMinute = 60; stable var notificationsCounter : Nat = 0; stable var invoiceCounter : Nat = 0; stable var payrollCounter : Nat = 0; var transactions : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(transactionsStable), transactionsStable.size(), Nat.equal, Hash.hash); var contacts : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(contactsStable), contactsStable.size(), Nat.equal, Hash.hash); + var employees : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(stableEmployees), stableEmployees.size(), Nat.equal, Hash.hash); var notifications : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(notificationsStable), notificationsStable.size(), Nat.equal, Hash.hash); - var payrolls : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(stablePayroll), stablePayroll.size(), Nat.equal, Hash.hash); + var payrolls : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(stablePayroll), stablePayroll.size(), Nat.equal, Hash.hash); + var organizations : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(organizationsStable), organizationsStable.size(), Nat.equal, Hash.hash); + var departments : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(departmentsStable), departmentsStable.size(), Nat.equal, Hash.hash); + var designations : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(designationsStable), designationsStable.size(), Nat.equal, Hash.hash); + var MAX_TRANSACTIONS = 30_000; let invoices : HashMap.HashMap = HashMap.fromIter(Iter.fromArray(invoicesStable), invoicesStable.size(), Nat.equal, Hash.hash); @@ -85,56 +107,152 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { return address; }; - /** - * High-Level API - */ - var count = 0; - let n = 120; - let nMonth = 2629800; - let oneMin: Int = 60_000_000_000; - let twoMins: Int = oneMin * 2; - let fourMins: Int = oneMin * 4; - let fiveMins: Int = oneMin * 5; - let oneHour:Int = oneMin * 60; - let oneDay: Int = 86_400_000_000_000; - let oneMonth: Int = 2_629_800_000_000_000; - let oneYear: Int = oneMonth * 12; + + +public func mapPrincipal(wallet:Text): async Principal{ +return Principal.fromText(wallet); + }; + - // system func timer(set : Nat64 -> ()) : async () { - // set(Nat64.fromIntWrap(Time.now()) + Nat64.fromIntWrap(oneDay)); + public shared ({ caller }) func generatePayslip(income : Text) : async Types.Response { + // let dt : Nat = Nat.fromText(income); + switch (Nat.fromText(income)) { + case (null) { + + let payslipInfo = await Taxcalculator.calculateTax(5000); + return payslipInfo; + /* handle error here, perhaps return an error response */ }; + case (?dt) { + let payslipInfo = await Taxcalculator.calculateTax(dt); + return payslipInfo; + }; + }; +}; - // count += 1; - // Debug.print("check for any transactions " # debug_show count); + public shared ({ caller }) func getUserPayslip(identity : Text) : async Types.Response { + let employee = await getEmpByPrincipal(Principal.fromText(identity)); + Debug.print("employee is " # debug_show (employee)); +//let employeedata = await employee.data; + // if (employee.status == 200) { + + // let payslip = await generatePayslip(employeedata.gross_salary); + + // let payslipData : PayslipData = { + // name = employeedata.first_name; + // organization = employeedata.organization; + // department = employeedata.department; + // designation = employeedata.designation; + // gross_salary = payslip.gross_salary; + // taxable_income = payslip.taxable_income; + // net_salary = payslip.net_salary; + // housing = payslip.housing; + // nhif_deductions = payslip.nhif_deductions; + // nssf_deductions = payslip.nssf_deductions; + // personal_relief = payslip.personal_relief; + // paye = payslip.paye; + // other_deductions = payslip.other_deductions; + // total_tax = payslip.total_tax; + // }; - // await checkPayroll(); - // }; + // { + // status = 200; + // status_text = "OK"; + // data = ?payslipData; + // error_text = null; + // }; + + // } else { + // let payslipData : PayslipData = { + // name = "N/A"; + // organization = "N/A"; + // department = "N/A"; + // designation = "N/A"; + // gross_salary = 0; + // taxable_income = 0; + // net_salary = 0; + // housing = 0; + // nhif_deductions = 0; + // nssf_deductions = 0; + // personal_relief = 0; + // paye = 0; + // other_deductions = 0; + // total_tax = 0; + // }; + // { + // status = 500; + // status_text = "FAILED"; + // data = ?payslipData; + // error_text = null; + // }; - public shared ({ caller }) func checkPayroll() : async() { + // }; + let payslipData : PayslipData = { + name = "N/A"; + organization = "N/A"; + department = "N/A"; + designation = "N/A"; + gross_salary = 0; + taxable_income = 0; + net_salary = 0; + housing = 0; + nhif_deductions = 0; + nssf_deductions = 0; + personal_relief = 0; + paye = 0; + other_deductions = 0; + total_tax = 0; + }; + { + status = 200; + status_text = "Yes"; + data = ?payslipData; + error_text = null; + }; - let allEntries = Iter.toArray(payrolls.entries()); + }; + + /** + * High-Level API + */ + + var count = 0; + let n = 120; + let nMonth = 2629800; + let oneMin : Int = 60_000_000_000; + let twoMins : Int = oneMin * 2; + let fourMins : Int = oneMin * 4; + let fiveMins : Int = oneMin * 5; + let oneHour : Int = oneMin * 60; + let oneDay : Int = 86_400_000_000_000; + let oneMonth : Int = 2_629_800_000_000_000; + let oneYear : Int = oneMonth * 12; + + public shared ({ caller }) func checkPayroll() : async () { + + let allEntries = Iter.toArray(payrolls.entries()); var size = 0; - // for ((_, [PayrollType]) in allEntries.vals()) { - // // if (contact.creator == caller) { - // // size += 1; - // // }; - // }; - Debug.print(debug_show(allEntries)); + Debug.print(debug_show (allEntries)); - }; + public shared ({caller}) func linkAccount(): async (){ - public func setRecurringTimer(N : Nat) : async Nat { - let timerId = recurringTimer(#seconds N, func() : async () { - Debug.print("Here are the items that are pending"); - await checkPayroll(); - }); - return timerId; }; - public func cancelRecurringTimer(id:Nat) : async () { + public func setRecurringTimer(N : Nat) : async Nat { + let timerId = recurringTimer( + #seconds N, + func() : async () { + Debug.print("Here are the items that are pending"); + await checkPayroll(); + }, + ); + return timerId; + }; + + public func cancelRecurringTimer(id : Nat) : async () { // switch (timerId) { // case (?id) { ignore cancelTimer(id); }; // case null {}; @@ -142,8 +260,6 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { ignore cancelTimer(id); }; - // public shared ({ caller }) func savePayroll(receivers : [PayrollType]) : async Types.Response<[PayrollType]> { - // }; public shared ({ caller }) func save_payroll(args : Types.SchedulePaymentsArgs) : async Types.SchedulePaymentsResult { let id : Nat = payrollCounter; @@ -158,15 +274,11 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { }); }; - payrolls.put(id, args.receivers); return #ok({ receivers }); }; - - - /** * Get the merchant's information */ @@ -234,7 +346,7 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { }; /** - * Update the merchant's information + * Update the user's information */ public shared (context) func updateUser(user : User) : async Types.Response { @@ -264,7 +376,7 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { return usersArray; }; - public shared ({ caller }) func whoami() : async Principal { + public shared query ({ caller }) func whoami() : async Principal { return caller; }; @@ -286,12 +398,10 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { }; public shared ({ caller }) func getTradingBalance() : async Text { - let balance = await CkBtcLedger.icrc1_balance_of( - { - owner = Principal.fromActor(this); - subaccount = ?toSubaccount(caller); - } - ); + let balance = await CkBtcLedger.icrc1_balance_of({ + owner = Principal.fromActor(this); + subaccount = ?toSubaccount(caller); + }); return Nat.toText(balance); }; @@ -315,15 +425,21 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { return address; }; + + public shared ({ caller }) func getTradingAddress() : async Text { let acc : Types.Account = { owner = Principal.fromActor(this); subaccount = ?toSubaccount(caller); }; let address = addressConverter_.toText(acc); + + let readable = MyAccount.toText(acc); return address; }; + + public shared ({ caller }) func getCanisterAddress() : async Text { let acc : Types.Account = { owner = Principal.fromActor(this); @@ -333,18 +449,15 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { return address; }; - //transfer funds from the default canister subaccount to the user subaccount //Works public shared ({ caller }) func transferFromCanistertoSubAccount() : async Result.Result { // check ckBTC balance of the callers dedicated account - let balance = await CkBtcLedger.icrc1_balance_of( - { - owner = Principal.fromActor(this); - subaccount = null; - } - ); + let balance = await CkBtcLedger.icrc1_balance_of({ + owner = Principal.fromActor(this); + subaccount = null; + }); if (balance < 100) { return #err("Not enough funds available in the Account. Make sure you send at least 100 ckSats."); @@ -354,19 +467,17 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { try { // if enough funds were sent, move them to the canisters default account - let transferResult = await CkBtcLedger.icrc1_transfer( - { - amount = 5000; - from_subaccount = null; - created_at_time = null; - fee = ?10; - memo = null; - to = { - owner = Principal.fromActor(this); - subaccount = ?toSubaccount(caller); - }; - } - ); + let transferResult = await CkBtcLedger.icrc1_transfer({ + amount = 5000; + from_subaccount = null; + created_at_time = null; + fee = ?10; + memo = null; + to = { + owner = Principal.fromActor(this); + subaccount = ?toSubaccount(caller); + }; + }); //Debug.print("transferresult: is " # debug_show (transferResult)); @@ -388,12 +499,10 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { public shared ({ caller }) func transferFromSubAccountToSubAccount(receiver : Text, amount : Nat) : async Types.Response { // check ckBTC balance of the callers dedicated account - let balance = await CkBtcLedger.icrc1_balance_of( - { - owner = Principal.fromActor(this); - subaccount = ?toSubaccount(caller); - } - ); + let balance = await CkBtcLedger.icrc1_balance_of({ + owner = Principal.fromActor(this); + subaccount = ?toSubaccount(caller); + }); let fee = 10; let total = amount + fee; @@ -409,19 +518,17 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { try { // if enough funds were sent, move them to the canisters default account - let transferResult = await CkBtcLedger.icrc1_transfer( - { - amount = amount; - from_subaccount = ?toSubaccount(caller); - created_at_time = null; - fee = ?10; - memo = null; - to = { - owner = Principal.fromActor(this); - subaccount = ?toSubaccount(Principal.fromText(receiver)); - }; - } - ); + let transferResult = await CkBtcLedger.icrc1_transfer({ + amount = amount; + from_subaccount = ?toSubaccount(caller); + created_at_time = null; + fee = ?10; + memo = null; + to = { + owner = Principal.fromActor(this); + subaccount = ?toSubaccount(Principal.fromText(receiver)); + }; + }); switch (transferResult) { case (#Err(transferError)) { @@ -458,7 +565,7 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { switch (Trie.get(userStore, userKey(receiver), Text.equal)) { case (?user) { - let notification = await send_notifications(user.name, user.email_address, user.phone_number, Nat.toText(amount), Principal.toText(caller)); + let notification = await send_notifications(user.first_name, user.email_address, user.phone_number, Nat.toText(amount), Principal.toText(caller)); Debug.print("notification sent to : " # debug_show (user.email_address)); }; case null { @@ -493,15 +600,13 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { //transfer from your account to other //works - public shared ({ caller }) func sendToOwner(amount : Nat,receiver :Text) : async Result.Result { + public shared ({ caller }) func sendToOwner(amount : Nat, receiver : Text) : async Result.Result { // check ckBTC balance of the callers dedicated account - let balance = await CkBtcLedger.icrc1_balance_of( - { - owner = caller; - subaccount = null; - } - ); + let balance = await CkBtcLedger.icrc1_balance_of({ + owner = caller; + subaccount = null; + }); Debug.print("balance of main account is " # debug_show (balance)); @@ -511,27 +616,25 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { try { // if enough funds were sent, move them to the canisters default account - let transferResult = await CkBtcLedger.icrc1_transfer( - { - amount = amount; - from_subaccount = null; - created_at_time = null; - fee = ?10; - memo = null; - to = { - owner = Principal.fromText(receiver); - subaccount = null; - }; - } - ); + let transferResult = await CkBtcLedger.icrc1_transfer({ + amount = amount; + from_subaccount = null; + created_at_time = null; + fee = ?10; + memo = null; + to = { + owner = Principal.fromText(receiver); + subaccount = null; + }; + }); - Debug.print("transffer result " # debug_show (transferResult)); + Debug.print("transffer result " # debug_show (transferResult)); switch (transferResult) { case (#Err(transferError)) { return #err("Couldn't transfer funds to Principal account:\n" # debug_show (transferError)); }; - + case (_) {}; }; } catch (error : Error) { @@ -598,7 +701,7 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { }; return; }; - private func ring() : async () { + private func ring() : async () { Debug.print("Motoko Timer Ring!"); }; @@ -612,20 +715,17 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { // // let next = Nat64.fromIntWrap(Time.now()) + 20_000_000_000; // 20 seconds // let next = Nat64.fromIntWrap(Time.now()) + 1_000_000_000 * 60 * 1; // One minute // setGlobalTimer(next); - // // Debug.print("Timer is up now"); + // // Debug.print("Timer is up now"); // // ignore recurringTimer(#seconds thirtyMinutes, ring); // // await notify(); // }; - - // public shared func schedulePayment() : async () { // let now = Time.now(); // let thirtyMinutes = 1_000_000_000 * 60 * 1; // let next = Nat64.fromIntWrap(Time.now()) + 1_000_000_000 * 60 * 1; // One minute - - // }; + // }; // ignore setTimer(#seconds (oneMinute), // func () : async () { @@ -634,39 +734,16 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { // } // ); - // #region get_account_identifier - /* - * Get Caller Identifier - * Allows a caller to the accountIdentifier for a given principal - * for a specific token. - */ - public query func get_account_identifier(args : Types.GetAccountIdentifierArgs) : async Types.GetAccountIdentifierResult { - let principal = args.principal; - let canisterId = Principal.fromActor(this); - - let subaccount = Utils.getDefaultAccount({ principal; canisterId }); - let hexEncoded = Hex.encode( - Blob.toArray(subaccount) - ); - let result : AccountIdentifier = #text(hexEncoded); - #ok({ accountIdentifier = result }); - - }; - // #endregion // #region Utils - public func accountIdentifierToBlob(accountIdentifier : Types.AccountIdentifier) : async Types.AccountIdentifierToBlobResult { - Utils.accountIdentifierToBlob({ - accountIdentifier; - canisterId = ?Principal.fromActor(this); - }); - }; + // #endregion // #region Upgrade Hooks system func preupgrade() { transactionsStable := Iter.toArray(transactions.entries()); contactsStable := Iter.toArray(contacts.entries()); + stableEmployees := Iter.toArray(employees.entries()); notificationsStable := Iter.toArray(notifications.entries()); invoicesStable := Iter.toArray(invoices.entries()); }; @@ -675,14 +752,14 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { // Make sure we start to montitor transactions from the block set on deployment latestTransactionIndex := _startBlock; transactions := HashMap.fromIter(Iter.fromArray(transactionsStable), transactionsStable.size(), Nat.equal, Hash.hash); - // transactions := HashMap.fromIter(Iter.fromArray(transactionsStable), contactsStable.size(), Nat.equal, Hash.hash); - transactionsStable := []; + transactionsStable := []; contacts := HashMap.fromIter(Iter.fromArray(contactsStable), contactsStable.size(), Nat.equal, Hash.hash); contactsStable := []; + employees := HashMap.fromIter(Iter.fromArray(stableEmployees), stableEmployees.size(), Nat.equal, Hash.hash); + stableEmployees := []; notifications := HashMap.fromIter(Iter.fromArray(notificationsStable), notificationsStable.size(), Nat.equal, Hash.hash); notificationsStable := []; - // invoices := HashMap.fromIter(Iter.fromArray(invoicesStable), invoicesStable.size(), Nat.equal, Hash.hash); - // invoicesStable := []; + }; @@ -787,17 +864,16 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { switch (Trie.get(userStore, userKey(args.wallet), Text.equal)) { case (?user) { - let employee : Employee = { id; creator = caller; - name = user.name; + name = user.first_name; email_address = user.email_address; phone_number = user.phone_number; created_at = Time.now(); modified_at = Time.now(); wallet = args.wallet; - emp_type = args.emp_type; + emp_type = args.emp_type; access_type = args.access_type; }; @@ -822,11 +898,166 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { }; }; + //create new employee + public shared ({ caller }) func create_emp(args : Types.CreateEmpArgs) : async Types.Response { + let id : Nat = noOfEmployees; + // increment counter + noOfEmployees += 1; + + let newEmp : Emp = { + creator = caller; + first_name = args.first_name; + last_name = args.last_name; + identity = args.identity; + email_address = args.email_address; + phone_number = args.phone_number; + joining_date = args.joining_date; + gender = args.gender; + disability = args.disability; + organization = args.organization; + department = args.department; + designation = args.designation; + employee_type = args.employee_type; + job_group = args.job_group; + gross_salary = args.gross_salary; + role = args.role; + permissions = ?{ + canAdd = true; + canView = false; + canEdit = true; + canDelete = true; + canUpdate = true; + canPay = true; + }; + }; + + employees.put(id, newEmp); + + { + status = 200; + status_text = "OK"; + data = ?newEmp; + error_text = null; + }; + + }; + + // #region Create Department + public shared ({ caller }) func create_department(args : Types.CreateDepartmentArgs) : async Types.Response { + let id : Nat = departmentsCounter; + // increment counter + departmentsCounter += 1; + + let department : Department = { + code = args.code; + name = args.name; + creator = caller; + }; + + departments.put(id, department); + + { + status = 200; + status_text = "OK"; + data = ?department; + error_text = null; + }; + + }; + + // #endregion + + // #region Create Organization + public shared ({ caller }) func create_organization(args : Types.CreateOrganizationArgs) : async Types.Response { + let id : Nat = organizationsCounter; + // increment counter + organizationsCounter += 1; + + let organization : Organization = { + code = args.code; + name = args.name; + creator = caller; + }; + + organizations.put(id, organization); + + { + status = 200; + status_text = "OK"; + data = ?organization; + error_text = null; + }; + + }; + + // #endregion + + //get no of my organizations + public shared query ({ caller }) func getOrganizationsLength() : async Text { + let allEntries = Iter.toArray(organizations.entries()); + var size = 0; + for ((_, organization) in allEntries.vals()) { + if (organization.creator == caller) { + size += 1; + }; + }; + return Nat.toText(size); + }; + + //get no of my departments + public shared query ({ caller }) func getDepartmentsLength() : async Text { + let allEntries = Iter.toArray(departments.entries()); + var size = 0; + for ((_, department) in allEntries.vals()) { + if (department.creator == caller) { + size += 1; + }; + }; + return Nat.toText(size); + }; + + //get no of my designations + public shared query ({ caller }) func getDesignationsLength() : async Text { + let allEntries = Iter.toArray(designations.entries()); + var size = 0; + for ((_, designation) in allEntries.vals()) { + if (designation.creator == caller) { + size += 1; + }; + }; + return Nat.toText(size); + }; + + // #region Create Designation + public shared ({ caller }) func create_designation(args : Types.CreateDesignationArgs) : async Types.Response { + let id : Nat = designationsCounter; + // increment counter + designationsCounter += 1; + + let designation : Designation = { + code = args.code; + name = args.name; + creator = caller; + }; + + designations.put(id, designation); + + { + status = 200; + status_text = "OK"; + data = ?designation; + error_text = null; + }; + + }; + + // #endregion + // #region delete employee - public shared ({ caller }) func remove_employee(wallet : Text) : async Types.Response { + public shared ({ caller }) func remove_employee(wallet : Text) : async Types.Response { - let employee = await getEmployeeByPrincipal(Principal.fromText(wallet)); - //let allEntries = Iter.toArray(contacts.entries()); + let employee = await getEmployeeByPrincipal(Principal.fromText(wallet)); + //let allEntries = Iter.toArray(contacts.entries()); // //get employee by principal and then if creator is caller return employee // for ((_, contact) in allEntries.vals()) { @@ -844,9 +1075,9 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { // }; Debug.print("Employee to remove: " # debug_show (employee)); - return employee; + return employee; -}; + }; //get no of employees added by caller public shared ({ caller }) func getMyContactsLength() : async Text { @@ -873,6 +1104,58 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { return Buffer.toArray(my_contacts); }; + //get employees added by caller + public shared ({ caller }) func getEmployees() : async [Emp] { + let allEntries = Iter.toArray(employees.entries()); + let my_contacts = Buffer.Buffer(50); + for ((_, contact) in allEntries.vals()) { + if (contact.creator == caller) { + my_contacts.add(contact); + }; + }; + + return Buffer.toArray(my_contacts); + }; + + //get organizations added by caller + public shared query ({ caller }) func getOrganizations() : async [Organization] { + let allEntries = Iter.toArray(organizations.entries()); + let my_organizations = Buffer.Buffer(50); + for ((_, organization) in allEntries.vals()) { + if (organization.creator == caller) { + my_organizations.add(organization); + }; + }; + + return Buffer.toArray(my_organizations); + }; + + //get departments added by caller + public shared query ({ caller }) func getDepartments() : async [Department] { + let allEntries = Iter.toArray(departments.entries()); + let my_departments = Buffer.Buffer(50); + for ((_, department) in allEntries.vals()) { + if (department.creator == caller) { + my_departments.add(department); + }; + }; + + return Buffer.toArray(my_departments); + }; + + //get designation added by caller + public shared query ({ caller }) func getDesignations() : async [Designation] { + let allEntries = Iter.toArray(designations.entries()); + let my_designations = Buffer.Buffer(50); + for ((_, designation) in allEntries.vals()) { + if (designation.creator == caller) { + my_designations.add(designation); + }; + }; + + return Buffer.toArray(my_designations); + }; + //get employee data based on principal public shared ({ caller }) func getEmployeeByPrincipal(principal : Principal) : async Types.Response { let allEntries = Iter.toArray(contacts.entries()); @@ -899,6 +1182,31 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { }; }; + public shared ({ caller }) func getEmpByPrincipal(principal : Principal) : async Types.Response { + let allEntries = Iter.toArray(employees.entries()); + + //get employee by principal and then if creator is caller return employee + for ((_, employee) in allEntries.vals()) { + if (Principal.fromText(employee.identity) == principal) { + if (employee.creator == caller) { + return { + status = 200; + status_text = "OK"; + data = ?employee; + error_text = null; + }; + }; + }; + }; + + return { + status = 404; + status_text = "Not Found"; + data = null; + error_text = null; + }; + }; + //transfer funds from owner caller to oter owner caller public shared ({ caller }) func save_notification(args : Types.CreateNotificationArgs) : async Types.CreateNotificationResult { @@ -975,12 +1283,10 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { Debug.print("total: " # debug_show (total)); //check balance - let balance = await CkBtcLedger.icrc1_balance_of( - { - owner = Principal.fromActor(this); - subaccount = ?toSubaccount(caller); - } - ); + let balance = await CkBtcLedger.icrc1_balance_of({ + owner = Principal.fromActor(this); + subaccount = ?toSubaccount(caller); + }); Debug.print("balance: " # debug_show (balance)); if (balance < total) { @@ -1104,7 +1410,7 @@ shared (actorContext) actor class Backend(_startBlock : Nat) = this { //check if email exists public query func emailExists(email : Text) : async Bool { let usersArray : [(Text, User)] = Iter.toArray(Trie.iter(userStore)); - // let allEntries = Iter.toArray(userStore.entries()); + // let allEntries = Iter.toArray(userStore.entries()); for ((_, user) in usersArray.vals()) { if (user.email_address == email) { return true; diff --git a/canisters/backend/taxcalculator.mo b/canisters/backend/taxcalculator.mo new file mode 100644 index 00000000..6e2c8081 --- /dev/null +++ b/canisters/backend/taxcalculator.mo @@ -0,0 +1,168 @@ +import Principal "mo:base/Principal"; +import Nat8 "mo:base/Nat8"; +import Nat32 "mo:base/Nat32"; +import Result "mo:base/Result"; +import Text "mo:base/Text"; +import Types "types"; +module { + + type Payslip = Types.Payslip; + + public type Taxbands = { + #tenpercent; + #twentyfivepercent; + #thirtypercent; + #thirtytwofivepercent; + #thirtyfivepercent; + }; + + public func nhifCalculator(income : Nat) : async Nat { + var gross_salary : Nat = income; + + if (gross_salary > 0 and gross_salary <= 5999) { return 150 } else if (gross_salary >= 6000 and gross_salary <= 7999) { + return 300; + } else if (gross_salary >= 8000 and gross_salary <= 11999) { return 400 } else if (gross_salary >= 12000 and gross_salary <= 14999) { + return 500; + } else if (gross_salary >= 15000 and gross_salary <= 19999) { return 600 } else if (gross_salary >= 20000 and gross_salary <= 24999) { + return 750; + } else if (gross_salary >= 25000 and gross_salary <= 29999) { return 850 } else if (gross_salary >= 30000 and gross_salary <= 34999) { + return 950; + } else if (gross_salary >= 40000 and gross_salary <= 44999) { return 1000 } else if (gross_salary >= 45000 and gross_salary <= 49999) { + return 1100; + } else if (gross_salary >= 50000 and gross_salary <= 59999) { return 1200 } else if (gross_salary >= 60000 and gross_salary <= 69999) { + return 1300; + } else if (gross_salary >= 70000 and gross_salary <= 79999) { return 1400 } else if (gross_salary >= 80000 and gross_salary <= 89999) { + return 1500; + } else if (gross_salary >= 90000 and gross_salary <= 99999) { return 1600 } else if (gross_salary >= 100000) { + return 1700; + } else { return 0 } // default case + }; + public func nssfCalculator(income : Nat) : async Nat { + var gross_salary : Nat = income; + var maxnssf : Nat = 2160; + + // if(gross_salary < 18000){ + // 360; + // }else (gross_salary > 18000){ + // 720; + // }; + 360; + + }; + + public func calculateTax(income : Nat) : async Types.Response { + let personalRelief : Nat = 2400; + let minimumTaxableIncome : Nat = 24001; + var paye : Nat = 0; + var nhif : Nat = 0; + var nssf : Nat = 0; + var housing : Nat = 0; + var other_deductions : Nat = 0; + var total_tax : Nat = 0; + var net_salary : Nat = 0; + var gross_salary : Nat = income; + + var remainingIncome : Nat = 0; + + nhif := await nhifCalculator(income); + nssf := await nssfCalculator(income); + + if (income >= minimumTaxableIncome) { + remainingIncome := income; + + if (remainingIncome > 24001 and remainingIncome < 32000) { + paye := remainingIncome * 10 / 100; // Apply a 10% tax rate + housing := remainingIncome * 25 / 1000; // Apply a 2.5% tax rate + total_tax := paye + nhif + nssf + housing; + net_salary := income - total_tax; + let payslip : Payslip = { + gross_salary = gross_salary; + taxable_income = remainingIncome; + net_salary = net_salary; + nhif_deductions = nhif; + housing = housing; + nssf_deductions = nssf; + personal_relief = personalRelief; + paye = paye; + other_deductions = other_deductions; + total_tax = total_tax; + }; + + return { + status = 200; + status_text = "OK"; + data = ?payslip; + error_text = null; + }; + } else if (remainingIncome > 32000 and remainingIncome < 32500) { + paye := remainingIncome * 10 / 100; // Apply a 10% tax rate + housing := remainingIncome * 25 / 1000; // Apply a 2.5% tax rate + total_tax := paye + nhif + nssf + housing; + net_salary := income - total_tax; + let payslip : Payslip = { + gross_salary = gross_salary; + taxable_income = remainingIncome; + net_salary = net_salary; + nhif_deductions = nhif; + housing = housing; + nssf_deductions = nssf; + personal_relief = personalRelief; + paye = paye; + other_deductions = other_deductions; + total_tax = total_tax; + }; + + return { + status = 200; + status_text = "OK"; + data = ?payslip; + error_text = null; + }; + } else { + paye := remainingIncome * 10 / 100; // Apply a 10% tax rate + housing := remainingIncome * 25 / 1000; // Apply a 2.5% tax rate + total_tax := paye + nhif + nssf + housing; + net_salary := income - total_tax; + let payslip : Payslip = { + gross_salary = gross_salary; + taxable_income = remainingIncome; + net_salary = net_salary; + nhif_deductions = nhif; + housing = housing; + nssf_deductions = nssf; + personal_relief = personalRelief; + paye = paye; + other_deductions = other_deductions; + total_tax = total_tax; + }; + + return { + status = 200; + status_text = "OK"; + data = ?payslip; + error_text = null; + }; + }; + + } else { + let payslip : Payslip = { + gross_salary = gross_salary; + taxable_income = 0; + net_salary = 0; + nhif_deductions = 0; + housing = 0; + nssf_deductions = 0; + personal_relief = 0; + paye = 0; + other_deductions = 0; + total_tax = 0; + }; + return { + status = 400; + status_text = "Bad Request"; + data = ?payslip; + error_text = ?"Income is less than minimum taxable income"; + }; + }; + }; +}; diff --git a/canisters/backend/types.mo b/canisters/backend/types.mo index 35786c77..7b21457b 100644 --- a/canisters/backend/types.mo +++ b/canisters/backend/types.mo @@ -4,6 +4,7 @@ import Nat32 "mo:base/Nat32"; import Blob "mo:base/Blob"; import Text "mo:base/Text"; import Result "mo:base/Result"; +import Bool "mo:base/Bool"; module { @@ -89,6 +90,11 @@ module { #Unpaid : Text; }; + public type AccountType = { + #Individual : Text; + #Company : Text; + }; + public type Invoice = { id : Nat; creator : Text; @@ -102,65 +108,104 @@ module { modified_at : Int; }; - public type Percentage = Float; - public type Ticker = Text; - public type Timestamp = Int; - public type SubPrice = Float; - public type TransactionID = Text; + // #region department type + public type Department = { + code : Text; + name : Text; + creator : Principal; + }; + + //region payslip information + public type Payslip = { + gross_salary : Nat; + taxable_income : Nat; + net_salary : Nat; + housing : Nat; + nhif_deductions : Nat; + nssf_deductions : Nat; + personal_relief : Nat; + paye : Nat; + other_deductions : Nat; + total_tax : Nat; + }; + + public type PayslipData = { + name : Text; + organization : Text; + department : Text; + designation : Text; + gross_salary : Nat; + taxable_income : Nat; + net_salary : Nat; + housing : Nat; + nhif_deductions : Nat; + nssf_deductions : Nat; + personal_relief : Nat; + paye : Nat; + other_deductions : Nat; + total_tax : Nat; + }; + + public type Jobgroup = { + id : Nat; + name : Text; + + }; + + // #endregion + + public type Organization = { + code : Text; + name : Text; + creator : Principal; + }; + + public type Designation = { + code : Text; + name : Text; + creator : Principal; + }; + + public type Percentage = Float; + public type Ticker = Text; + public type Timestamp = Int; + public type SubPrice = Float; + public type TransactionID = Text; - public type AccessType = ?{ - #edit ; - #add ; - #view ; + public type AccessType = ?{ + #edit; + #add; + #view; #delete; }; - public type EmployeeType = ?{ - #permanent ; - #intern ; - #contract ; - #freelancer ; + public type EmployeeType = ?{ + #permanent; + #intern; + #contract; + #freelancer; }; - public type AccessLevel =?{ + public type AccessLevel = ?{ #administrator; #user; #owner; #finance; }; - public type TaxType = ?{ - #paye : Percentage ; + public type TaxType = ?{ + #paye : Percentage; #contract : Percentage; #withholding : Percentage; }; public type PaymentSchedule = { - #daily; + #daily; #weekly; #monthly; #yearly; }; - public type Departments = { - #hr; - #finance; - #legal; - #engineering; - #marketing; - #admin; - }; - - // public type PayrollType = { - // id : Nat; - // created_at : Int; - // creator : Text; - // amount : Nat; - // approved : Bool; - // successful : Bool; - // destination : Text; - // }; - public type PayrollType = { id : Nat; created_at : Int; @@ -180,15 +225,14 @@ module { }; public type User = { - name : Text; + first_name : Text; + last_name : Text ; email_notifications : Bool; email_address : Text; phone_notifications : Bool; phone_number : Text; }; - - //type representing a user that is an employee/freelancer public type Employee = { id : Nat; @@ -203,9 +247,35 @@ module { access_type : Text; }; - - - + public type Emp = { + creator : Principal; + first_name : Text; + last_name : Text; + identity : Text; + email_address : Text; + phone_number : Text; + joining_date : Text; + gender : Text; + disability : Bool; + organization : Text; + department : Text; + designation : Text; + employee_type : Text; + job_group : Text; + gross_salary : Text; + role : Text; + permissions : ?Permissions; + }; + + //user permissions + public type Permissions = { + canAdd : Bool; + canView : Bool; + canEdit : Bool; + canDelete : Bool; + canUpdate : Bool; + canPay : Bool; + }; public type Response = { status : Nat16; @@ -312,10 +382,43 @@ module { }; // #endregion + //region create Emp + public type CreateEmpArgs = { + first_name : Text; + last_name : Text; + email_address : Text; + identity : Text; + phone_number : Text; + joining_date : Text; + gender : Text; + disability : Bool; + organization : Text; + department : Text; + designation : Text; + employee_type : Text; + job_group : Text; + gross_salary : Text; + role : Text; + // permissions : ?Permissions; + }; + + public type CreateEmpResult = Result.Result; + public type CreateEmpSuccess = { + employee : Emp; + }; + public type CreateEmpErr = { + message : ?Text; + kind : { + #InvalidUser; + #InvalidPrincipal; + #Other; + }; + }; + // #region create employee public type CreateEmployeeArgs = { wallet : Text; - emp_type : Text; + emp_type : Text; access_type : Text; }; public type CreateEmployeeResult = Result.Result; @@ -331,6 +434,60 @@ module { }; }; + // #region create Department + public type CreateDepartmentArgs = { + code : Text; + name : Text; + }; + public type CreateDepartmentResult = Result.Result; + public type CreateDepartmentSuccess = { + department : Department; + }; + public type CreateDepartmentErr = { + message : ?Text; + kind : { + #InvalidDepartment; + #InvalidPrincipal; + #Other; + }; + }; + + // #region create Organization + public type CreateOrganizationArgs = { + code : Text; + name : Text; + }; + public type CreateOrganizationResult = Result.Result; + public type CreateOrganizationSuccess = { + organization : Organization; + }; + public type CreateOrganizationErr = { + message : ?Text; + kind : { + #InvalidOrganization; + #InvalidPrincipal; + #Other; + }; + }; + + // #region create Designation + public type CreateDesignationArgs = { + code : Text; + name : Text; + }; + public type CreateDesignationResult = Result.Result; + public type CreateDesignationSuccess = { + designation : Designation; + }; + public type CreateDesignationErr = { + message : ?Text; + kind : { + #InvalidDesignation; + #InvalidPrincipal; + #Other; + }; + }; + //region create notification public type CreateNotificationArgs = { sender : Text; @@ -372,8 +529,7 @@ module { }; }; - - // #region create_tpayroll instance + // #region create_tpayroll instance public type SchedulePaymentsArgs = { receivers : [PayrollType]; diff --git a/canisters/backend/utils.mo b/canisters/backend/utils.mo index 4f704586..c94db4e7 100644 --- a/canisters/backend/utils.mo +++ b/canisters/backend/utils.mo @@ -94,108 +94,14 @@ module { Blob.fromArrayMut(Array.init(32, 0 : Nat8)); }; - /** - * args : { accountIdentifier : AccountIdentifier, canisterId : ?Principal } - * Takes an account identifier and returns a Blob - * - * Canister ID is required only for Principal, and will return an account identifier using that principal as a subaccount for the provided canisterId - */ - public func accountIdentifierToBlob(args : Types.AccountIdentifierToBlobArgs) : Types.AccountIdentifierToBlobResult { - let accountIdentifier = args.accountIdentifier; - let canisterId = args.canisterId; - let err = { - kind = #InvalidAccountIdentifier; - message = ?"Invalid account identifier"; - }; - switch (accountIdentifier) { - case (#text(identifier)) { - switch (Hex.decode(identifier)) { - case (#ok v) { - let blob = Blob.fromArray(v); - if (Account.validateAccountIdentifier(blob)) { - #ok(blob); - } else { - #err(err); - }; - }; - case (#err _) { - #err(err); - }; - }; - }; - case (#principal principal) { - switch (canisterId) { - case (null) { - #err({ - kind = #Other; - message = ?"Canister Id is required for account identifiers of type principal"; - }); - }; - case (?id) { - let identifier = Account.accountIdentifier(id, Account.principalToSubaccount(principal)); - if (Account.validateAccountIdentifier(identifier)) { - #ok(identifier); - } else { - #err(err); - }; - }; - }; - }; - case (#blob(identifier)) { - if (Account.validateAccountIdentifier(identifier)) { - #ok(identifier); - } else { - #err(err); - }; - }; - }; - }; - /** - * args : { accountIdentifier : AccountIdentifier, canisterId : ?Principal } - * Takes an account identifier and returns Hex-encoded Text - * - * Canister ID is required only for Principal, and will return an account identifier using that principal as a subaccount for the provided canisterId - */ - public func accountIdentifierToText(args : Types.AccountIdentifierToTextArgs) : Types.AccountIdentifierToTextResult { - let accountIdentifier = args.accountIdentifier; - let canisterId = args.canisterId; - switch (accountIdentifier) { - case (#text(identifier)) { - #ok(identifier); - }; - case (#principal(identifier)) { - let blobResult = accountIdentifierToBlob(args); - switch (blobResult) { - case (#ok(blob)) { - #ok(Hex.encode(Blob.toArray(blob))); - }; - case (#err(err)) { - #err(err); - }; - }; - }; - case (#blob(identifier)) { - let blobResult = accountIdentifierToBlob(args); - switch (blobResult) { - case (#ok(blob)) { - #ok(Hex.encode(Blob.toArray(blob))); - }; - case (#err(err)) { - #err(err); - }; - }; - }; - }; - }; + type DefaultAccountArgs = { // Hex-encoded AccountIdentifier canisterId : Principal; principal : Principal; }; - public func getDefaultAccount(args : DefaultAccountArgs) : Blob { - Account.accountIdentifier(args.canisterId, Account.principalToSubaccount(args.principal)); - }; + }; diff --git a/canisters/ethlogin/Cargo.toml b/canisters/ethlogin/Cargo.toml new file mode 100644 index 00000000..67cd6c26 --- /dev/null +++ b/canisters/ethlogin/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "ethlogin" +version = "0.1.0" +edition = "2021" + +[dependencies] +ic_siwe = "0.0.6" diff --git a/.dfx/network/local/ic-btc-adapter-config.json b/canisters/ethlogin/src/lib.rs similarity index 100% rename from .dfx/network/local/ic-btc-adapter-config.json rename to canisters/ethlogin/src/lib.rs diff --git a/canisters/ext/HttpTypes.mo b/canisters/ext/HttpTypes.mo index bdb2e1af..6ee6a6ee 100644 --- a/canisters/ext/HttpTypes.mo +++ b/canisters/ext/HttpTypes.mo @@ -1,40 +1,38 @@ - - module { - public type HeaderField = (Text, Text); - - public type StreamingStrategy = { - #Callback: { - callback : StreamingCallback; - token : StreamingCallbackToken; - }; - }; - - public type StreamingCallback = query (StreamingCallbackToken) -> async (StreamingCallbackResponse); - - public type StreamingCallbackToken = { - content_encoding : Text; - index : Nat; - key : Text; - }; - - public type StreamingCallbackResponse = { - body : Blob; - token : ?StreamingCallbackToken; - }; - - public type Request = { - body : Blob; - headers : [HeaderField]; - method : Text; - url : Text; - }; + public type HeaderField = (Text, Text); - public type Response = { - body : Blob; - headers : [HeaderField]; - streaming_strategy : ?StreamingStrategy; - status_code : Nat16; + public type StreamingStrategy = { + #Callback : { + callback : StreamingCallback; + token : StreamingCallbackToken; }; + }; + + public type StreamingCallback = query (StreamingCallbackToken) -> async (StreamingCallbackResponse); + + public type StreamingCallbackToken = { + content_encoding : Text; + index : Nat; + key : Text; + }; + + public type StreamingCallbackResponse = { + body : Blob; + token : ?StreamingCallbackToken; + }; + + public type Request = { + body : Blob; + headers : [HeaderField]; + method : Text; + url : Text; + }; + + public type Response = { + body : Blob; + headers : [HeaderField]; + streaming_strategy : ?StreamingStrategy; + status_code : Nat16; + }; }; diff --git a/canisters/image_tank/main.mo b/canisters/image_tank/main.mo new file mode 100644 index 00000000..bd444ad7 --- /dev/null +++ b/canisters/image_tank/main.mo @@ -0,0 +1,167 @@ +import Text "mo:base/Text"; +import Nat "mo:base/Nat"; +import Nat32 "mo:base/Nat32"; +import Nat64 "mo:base/Nat64"; +import Iter "mo:base/Iter"; + +import Blob "mo:base/Blob"; +import Array "mo:base/Array"; +import HttpTypes "../ext/HttpTypes"; + +import Memory "mo:base/ExperimentalStableMemory"; +import HashMap "mo:base/HashMap"; + +actor { + + type ImgId = Text; + + private stable var _currentMemoryOffset : Nat64 = 2; + private stable var _imgOffset : [(ImgId, Nat64)] = []; + private var imgOffset : HashMap.HashMap = HashMap.fromIter(_imgOffset.vals(), 0, Text.equal, Text.hash); + private stable var _imgSize : [(ImgId, Nat)] = []; + private var imgSize : HashMap.HashMap = HashMap.fromIter(_imgSize.vals(), 0, Text.equal, Text.hash); + + // thumbnail handling + private stable var _thumbs : [(ImgId, Blob)] = []; + private var thumbs = HashMap.HashMap(0, Text.equal, Text.hash); + + system func preupgrade() { + _imgOffset := Iter.toArray(imgOffset.entries()); + _imgSize := Iter.toArray(imgSize.entries()); + + _thumbs := Iter.toArray(thumbs.entries()); + }; + + system func postupgrade() { + _imgOffset := []; + _imgSize := []; + + thumbs := HashMap.fromIter(_thumbs.vals(), 10, Text.equal, Text.hash); + _thumbs := []; + }; + + public shared (msg) func uploadImg(imgId : ImgId, image : Blob) { + storeBlobImg(imgId, image); + }; + + public shared (msg) func uploadThumbnail(imgId : ImgId, thumbnail : Blob) { + thumbs.put(imgId, thumbnail); + }; + + public query ({ caller }) func getPic(id : ImgId) : async Blob { + var pic = loadBlobImg(id); + switch (pic) { + case (null) { + return Blob.fromArray([]); + }; + case (?existingPic) { + return existingPic; + }; + }; + }; + + public query ({ caller }) func getThumbnail(id : ImgId) : async Blob { + var pic = thumbs.get(id); + switch (pic) { + case (null) { + return Blob.fromArray([]); + }; + case (?existingPic) { + return existingPic; + }; + }; + }; + + private func storeBlobImg(imgId : ImgId, value : Blob) { + var size : Nat = Nat32.toNat(Nat32.fromIntWrap(value.size())); + // Each page is 64KiB (65536 bytes) + var growBy : Nat = size / 65536 + 1; + let a = Memory.grow(Nat64.fromNat(growBy)); + Memory.storeBlob(_currentMemoryOffset, value); + imgOffset.put(imgId, _currentMemoryOffset); + imgSize.put(imgId, size); + size := size + 4; + _currentMemoryOffset += Nat64.fromNat(size); + }; + + private func loadBlobImg(imgId : ImgId) : ?Blob { + let offset = imgOffset.get(imgId); + switch (offset) { + case (null) { + return null; + }; + case (?offset) { + let size = imgSize.get(imgId); + switch (size) { + case (null) { + return null; + }; + case (?size) { + return ?Memory.loadBlob(offset, size); + }; + }; + }; + }; + }; + + public query func http_request(request : HttpTypes.Request) : async HttpTypes.Response { + if (Text.contains(request.url, #text("imgid"))) { + let imgId = Iter.toArray(Text.tokens(request.url, #text("imgid=")))[1]; + + if (Text.contains(request.url, #text("thumbnail"))) { + var pic = thumbs.get(imgId); + switch (pic) { + case (null) { + return http404(?"no pic available"); + }; + case (?existingPic) { + return picture(existingPic); + }; + }; + } else { + var pic = loadBlobImg(imgId); + switch (pic) { + case (null) { + return http404(?"no thumbnail available"); + }; + case (?existingPic) { + return picture(existingPic); + }; + }; + }; + }; + return http404(?"Path not found."); + }; + + // A 200 Ok response with picture + private func picture(pic : Blob) : HttpTypes.Response { + { + body = pic; + headers = [ + ("Content-Type", "image/jpg"), + ("Access-Control-Allow-Origin", "*"), + ("Expires", "Wed, 9 Jan 2099 09:09:09 GMT"), + ]; + status_code = 200; + streaming_strategy = null; + }; + }; + + // A 404 response with an optional error message. + private func http404(msg : ?Text) : HttpTypes.Response { + { + body = Text.encodeUtf8( + switch (msg) { + case (?msg) msg; + case null "Not found."; + } + ); + headers = [ + ("Content-Type", "text/plain"), + ]; + status_code = 404; + streaming_strategy = null; + }; + }; + +}; diff --git a/canisters/siwe_ic/Cargo.toml b/canisters/siwe_ic/Cargo.toml new file mode 100644 index 00000000..4da540be --- /dev/null +++ b/canisters/siwe_ic/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "siwe_ic" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +candid = "0.8.4" +futures = "0.3.28" +hex = "0.4.3" +ic-cdk = "0.7.4" +ic-cdk-macros = "0.6.10" +siwe = { git = "https://github.com/domwoe/siwe-rs" } +time = { version = "0.3.15", default-features = false } diff --git a/canisters/siwe_ic/siwe_ic.did b/canisters/siwe_ic/siwe_ic.did new file mode 100644 index 00000000..3b290101 --- /dev/null +++ b/canisters/siwe_ic/siwe_ic.did @@ -0,0 +1,17 @@ + +type Session = record { + "address": text; + "expires_at": int64; +}; + +type SessionResult = variant { + "Ok": Session; + "Err": text; +}; + +service : { + "create_session": (text, text) -> (SessionResult); + "get_session": () -> (SessionResult) query; + "clear_session": () -> (); + "greet": (text) -> (text) query; +}; diff --git a/canisters/siwe_ic/src/lib.rs b/canisters/siwe_ic/src/lib.rs new file mode 100644 index 00000000..69f1ed93 --- /dev/null +++ b/canisters/siwe_ic/src/lib.rs @@ -0,0 +1,147 @@ +use candid::{Principal, CandidType}; +use futures::executor::block_on; +use hex::FromHex; +use ic_cdk_macros::{query, update}; +use siwe::{Message, VerificationOpts}; +use std::collections::BTreeMap; +use std::str::FromStr; +use time::format_description::well_known::Rfc3339; +use time::OffsetDateTime; + + +const SESSION_EXPIRATION_IN_MINS: i64 = 5; +const CLEANUP_INTERCAL_IN_MINS: i64 = 15; + +#[derive(Clone, Debug, CandidType)] +struct Session { + address: String, + expires_at: i64, +} + +type SessionMap = BTreeMap; + +thread_local! { + static SESSIONS: std::cell::RefCell = std::cell::RefCell::new(BTreeMap::new()); + static LAST_CLEANUP: std::cell::RefCell = std::cell::RefCell::new(OffsetDateTime::from_unix_timestamp(0).unwrap()); +} + + +async fn validate(msg: &Message, sig: &str) -> [u8; 20] { + + let opts = VerificationOpts { + domain: None, + nonce: None, + timestamp: Some(OffsetDateTime::from_unix_timestamp((ic_cdk::api::time() / (1_000_000_000)) as i64).unwrap()) + }; + + // Check if uri is equal to the caller + msg.uri.to_string().eq(&format!("did:icp:{}",ic_cdk::api::caller().to_text())).then(|| ()).ok_or("Invoked by unauthorized principal").unwrap(); + + // Check if target (canister and method) is part of authorized resources + let target = format!("icp:{}",ic_cdk::api::id().to_text()); + msg.resources.clone().into_iter().find(|r| r.as_str().eq(&target)).ok_or(format!("Unauthorized for resource: {}", &target)).unwrap(); + + let sig = <[u8; 65]>::from_hex( sig.strip_prefix("0x").unwrap_or(sig)).unwrap(); + + block_on(msg.verify(&sig, &opts)).unwrap(); + + msg.address +} + +fn check_session() -> Result { + + let caller = ic_cdk::api::caller(); + let now = (ic_cdk::api::time() / (1_000_000_000)) as i64; + + ic_cdk::api::print(std::format!("Checking session for {}", ic_cdk::api::caller().to_text())); + + SESSIONS.with(|sessions| { + let mut sessions = sessions.borrow_mut(); + let session = sessions.get(&caller).ok_or("No session found")?; + if session.expires_at < now { + sessions.remove(&caller); + Err("Session expired".to_string()) + } else { + Ok(session.address.clone()) + } + + }) +} + + +#[query] +fn greet(name: String) -> String { + let caller = check_session().unwrap(); + ic_cdk::api::print(std::format!("Active session for {}", caller)); + format!("Hello, {}!", name) +} + + +#[update] +async fn create_session(siwe_msg: String, siwe_sig: String) -> Result { + + ic_cdk::api::print(std::format!("Creating session for {}...", ic_cdk::api::caller().to_text())); + + let msg = Message::from_str(&siwe_msg).unwrap(); + block_on(validate(&msg, &siwe_sig)); + + let address = hex::encode(msg.address); + + ic_cdk::api::print(std::format!("Associated ETH account {:?}", address)); + + let now = OffsetDateTime::from_unix_timestamp((ic_cdk::api::time() / 1_000_000_000) as i64).unwrap(); + + let issued_at = OffsetDateTime::parse(&msg.issued_at.to_string(), &Rfc3339).unwrap(); + let expires_at = issued_at + time::Duration::minutes(SESSION_EXPIRATION_IN_MINS); + + + + let session = Session { + address, + expires_at: expires_at.unix_timestamp(), + }; + + SESSIONS.with(|sessions| { + let mut sessions = sessions.borrow_mut(); + sessions.insert(ic_cdk::api::caller(), session.clone()); + }); + + ic_cdk::api::print(std::format!("Created session for {}, expires at {:?}", ic_cdk::api::caller().to_text(), expires_at)); + + LAST_CLEANUP.with(|last_cleanup| { + let mut last_cleanup = last_cleanup.borrow_mut(); + if now - *last_cleanup > time::Duration::minutes(CLEANUP_INTERCAL_IN_MINS) { + _cleanup_sessions(); + *last_cleanup = now; + } + }); + + Ok(session) +} + +#[query] +fn get_session() -> Result { + check_session().unwrap(); + SESSIONS.with(|sessions| { + let sessions = sessions.borrow(); + let session = sessions.get(&ic_cdk::api::caller()).ok_or("No session found. Please sign in.")?; + Ok(session.clone()) + }) +} + +#[update] +fn clear_session() { + SESSIONS.with(|sessions| { + let mut sessions = sessions.borrow_mut(); + sessions.remove(&ic_cdk::api::caller()); + }); +} + +fn _cleanup_sessions() { + let now = (ic_cdk::api::time() / 1_000_000_000) as i64; + + SESSIONS.with(|sessions| { + let mut sessions = sessions.borrow_mut(); + sessions.retain(|_, session| session.expires_at > now); + }); +} \ No newline at end of file diff --git a/dfx.json b/dfx.json index d859add9..3134ccdc 100644 --- a/dfx.json +++ b/dfx.json @@ -1,19 +1,18 @@ { "canisters": { + "backend": { "main": "canisters/backend/main.mo", "type": "motoko", "dependencies": [ "ckbtc_ledger" + + ], "declarations": { "node_compatibility": true } }, - "imgTank": { - "main": "canisters/imgTank/main.mo", - "type": "motoko" - }, "assets": { "dependencies": [ "backend" @@ -28,9 +27,9 @@ }, "internet_identity": { "type": "custom", - "candid": "https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity.did", - "wasm": "https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_dev.wasm.gz", - "remote": { + "candid": "https://github.com/dfinity/internet-identity/releases/download/release-2024-05-13/internet_identity.did", + "wasm": "https://github.com/dfinity/internet-identity/releases/download/release-2024-05-13/internet_identity_dev.wasm.gz", + "remote": { "id": { "ic": "rdmx6-jaaaa-aaaaa-aaadq-cai" } diff --git a/dist/index.html b/dist/index.html index 3dac1bac..c6430e50 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ IC-Payroll - + diff --git a/frontend/App.vue b/frontend/App.vue index c66c2bab..756fc38f 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -1,21 +1,1480 @@ +<<<<<<< HEAD