diff --git a/motoko/minimal-counter-dapp/README_images/project_files.png b/motoko/minimal-counter-dapp/README_images/project_files.png deleted file mode 100644 index 205feef51..000000000 Binary files a/motoko/minimal-counter-dapp/README_images/project_files.png and /dev/null differ diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/index.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/index.d.ts deleted file mode 100644 index 1ccf38540..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { - ActorSubclass, - HttpAgentOptions, - ActorConfig, - Agent, -} from "@dfinity/agent"; -import type { Principal } from "@dfinity/principal"; -import type { IDL } from "@dfinity/candid"; - -import { _SERVICE } from './minimal_dapp.did'; - -export declare const idlFactory: IDL.InterfaceFactory; -export declare const canisterId: string; - -export declare interface CreateActorOptions { - /** - * @see {@link Agent} - */ - agent?: Agent; - /** - * @see {@link HttpAgentOptions} - */ - agentOptions?: HttpAgentOptions; - /** - * @see {@link ActorConfig} - */ - actorOptions?: ActorConfig; -} - -/** - * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. - * @constructs {@link ActorSubClass} - * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to - * @param {CreateActorOptions} options - see {@link CreateActorOptions} - * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions - * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent - * @see {@link HttpAgentOptions} - * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor - * @see {@link ActorConfig} - */ -export declare const createActor: ( - canisterId: string | Principal, - options?: CreateActorOptions -) => ActorSubclass<_SERVICE>; - -/** - * Intialized Actor using default settings, ready to talk to a canister using its candid interface - * @constructs {@link ActorSubClass} - */ -export declare const minimal_dapp: ActorSubclass<_SERVICE>; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/index.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/index.js deleted file mode 100644 index e063d6132..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from "./minimal_dapp.did.js"; -export { idlFactory } from "./minimal_dapp.did.js"; - -/* CANISTER_ID is replaced by webpack based on node environment - * Note: canister environment variable will be standardized as - * process.env.CANISTER_ID_ - * beginning in dfx 0.15.0 - */ -export const canisterId = - process.env.CANISTER_ID_MINIMAL_DAPP; - -export const createActor = (canisterId, options = {}) => { - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - if (options.agent && options.agentOptions) { - console.warn( - "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." - ); - } - - // Fetch root key for certificate validation during development - if (process.env.DFX_NETWORK !== "ic") { - agent.fetchRootKey().catch((err) => { - console.warn( - "Unable to fetch root key. Check to ensure that your local replica is running" - ); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options.actorOptions, - }); -}; - -export const minimal_dapp = canisterId ? createActor(canisterId) : undefined; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did deleted file mode 100644 index 02f270c71..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did +++ /dev/null @@ -1,5 +0,0 @@ -service : { - count: () -> (nat); - getCount: () -> (nat) query; - reset: () -> (nat); -} diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did.d.ts deleted file mode 100644 index 39a44ae65..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export interface _SERVICE { - 'count' : ActorMethod<[], bigint>, - 'getCount' : ActorMethod<[], bigint>, - 'reset' : ActorMethod<[], bigint>, -} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did.js deleted file mode 100644 index 7de678128..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp/minimal_dapp.did.js +++ /dev/null @@ -1,8 +0,0 @@ -export const idlFactory = ({ IDL }) => { - return IDL.Service({ - 'count' : IDL.Func([], [IDL.Nat], []), - 'getCount' : IDL.Func([], [IDL.Nat], ['query']), - 'reset' : IDL.Func([], [IDL.Nat], []), - }); -}; -export const init = ({ IDL }) => { return []; }; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/index.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/index.d.ts deleted file mode 100644 index 0ad1f5ede..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { - ActorSubclass, - HttpAgentOptions, - ActorConfig, - Agent, -} from "@dfinity/agent"; -import type { Principal } from "@dfinity/principal"; -import type { IDL } from "@dfinity/candid"; - -import { _SERVICE } from './minimal_dapp_assets.did'; - -export declare const idlFactory: IDL.InterfaceFactory; -export declare const canisterId: string; - -export declare interface CreateActorOptions { - /** - * @see {@link Agent} - */ - agent?: Agent; - /** - * @see {@link HttpAgentOptions} - */ - agentOptions?: HttpAgentOptions; - /** - * @see {@link ActorConfig} - */ - actorOptions?: ActorConfig; -} - -/** - * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. - * @constructs {@link ActorSubClass} - * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to - * @param {CreateActorOptions} options - see {@link CreateActorOptions} - * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions - * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent - * @see {@link HttpAgentOptions} - * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor - * @see {@link ActorConfig} - */ -export declare const createActor: ( - canisterId: string | Principal, - options?: CreateActorOptions -) => ActorSubclass<_SERVICE>; - -/** - * Intialized Actor using default settings, ready to talk to a canister using its candid interface - * @constructs {@link ActorSubClass} - */ -export declare const minimal_dapp_assets: ActorSubclass<_SERVICE>; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/index.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/index.js deleted file mode 100644 index 6fbf4efd0..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from "./minimal_dapp_assets.did.js"; -export { idlFactory } from "./minimal_dapp_assets.did.js"; - -/* CANISTER_ID is replaced by webpack based on node environment - * Note: canister environment variable will be standardized as - * process.env.CANISTER_ID_ - * beginning in dfx 0.15.0 - */ -export const canisterId = - process.env.CANISTER_ID_MINIMAL_DAPP_ASSETS || - process.env.MINIMAL_DAPP_ASSETS_CANISTER_ID; - -export const createActor = (canisterId, options = {}) => { - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - if (options.agent && options.agentOptions) { - console.warn( - "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." - ); - } - - // Fetch root key for certificate validation during development - if (process.env.DFX_NETWORK !== "ic") { - agent.fetchRootKey().catch((err) => { - console.warn( - "Unable to fetch root key. Check to ensure that your local replica is running" - ); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options.actorOptions, - }); -}; - -export const minimal_dapp_assets = createActor(canisterId); diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did deleted file mode 100644 index 508bda651..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did +++ /dev/null @@ -1,228 +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 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 }; - -service: { - 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) query; - grant_permission: (GrantPermission) -> (); - revoke_permission: (RevokePermission) -> (); - list_permitted: (ListPermitted) -> (vec principal) query; - 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) -> (); - - validate_grant_permission: (GrantPermission) -> (ValidationResult); - validate_revoke_permission: (RevokePermission) -> (ValidationResult); - validate_take_ownership: () -> (ValidationResult); - validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); -} diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did.d.ts deleted file mode 100644 index d5bc1a4b4..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did.d.ts +++ /dev/null @@ -1,215 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; - -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 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 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 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 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[]] - >, - '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[] } - >, - '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_grant_permission' : ActorMethod< - [GrantPermission], - ValidationResult - >, - 'validate_revoke_permission' : ActorMethod< - [RevokePermission], - ValidationResult - >, - 'validate_take_ownership' : ActorMethod<[], ValidationResult>, -} diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did.js deleted file mode 100644 index d390f7c0d..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_assets/minimal_dapp_assets.did.js +++ /dev/null @@ -1,245 +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 DeleteBatchArguments = IDL.Record({ 'batch_id' : BatchId }); - 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))], - [], - ), - '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'], - ), - '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)], ['query']), - 'list_permitted' : IDL.Func( - [ListPermitted], - [IDL.Vec(IDL.Principal)], - ['query'], - ), - '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_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/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/index.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/index.d.ts deleted file mode 100644 index 8e773a7e9..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { - ActorSubclass, - HttpAgentOptions, - ActorConfig, - Agent, -} from "@dfinity/agent"; -import type { Principal } from "@dfinity/principal"; -import type { IDL } from "@dfinity/candid"; - -import { _SERVICE } from './minimal_dapp_backend.did'; - -export declare const idlFactory: IDL.InterfaceFactory; -export declare const canisterId: string; - -export declare interface CreateActorOptions { - /** - * @see {@link Agent} - */ - agent?: Agent; - /** - * @see {@link HttpAgentOptions} - */ - agentOptions?: HttpAgentOptions; - /** - * @see {@link ActorConfig} - */ - actorOptions?: ActorConfig; -} - -/** - * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. - * @constructs {@link ActorSubClass} - * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to - * @param {CreateActorOptions} options - see {@link CreateActorOptions} - * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions - * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent - * @see {@link HttpAgentOptions} - * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor - * @see {@link ActorConfig} - */ -export declare const createActor: ( - canisterId: string | Principal, - options?: CreateActorOptions -) => ActorSubclass<_SERVICE>; - -/** - * Intialized Actor using default settings, ready to talk to a canister using its candid interface - * @constructs {@link ActorSubClass} - */ -export declare const minimal_dapp_backend: ActorSubclass<_SERVICE>; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/index.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/index.js deleted file mode 100644 index 9e8462832..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from "./minimal_dapp_backend.did.js"; -export { idlFactory } from "./minimal_dapp_backend.did.js"; - -/* CANISTER_ID is replaced by webpack based on node environment - * Note: canister environment variable will be standardized as - * process.env.CANISTER_ID_ - * beginning in dfx 0.15.0 - */ -export const canisterId = - process.env.CANISTER_ID_MINIMAL_DAPP_BACKEND; - -export const createActor = (canisterId, options = {}) => { - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - if (options.agent && options.agentOptions) { - console.warn( - "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." - ); - } - - // Fetch root key for certificate validation during development - if (process.env.DFX_NETWORK !== "ic") { - agent.fetchRootKey().catch((err) => { - console.warn( - "Unable to fetch root key. Check to ensure that your local replica is running" - ); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options.actorOptions, - }); -}; - -export const minimal_dapp_backend = canisterId ? createActor(canisterId) : undefined; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did deleted file mode 100644 index 366328ff3..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did +++ /dev/null @@ -1,6 +0,0 @@ -service : { - decrement: () -> (nat); - getCount: () -> (nat) query; - increment: () -> (nat); - reset: () -> (nat); -} diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did.d.ts deleted file mode 100644 index 216b6fe93..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { Principal } from '@dfinity/principal'; -import type { ActorMethod } from '@dfinity/agent'; -import type { IDL } from '@dfinity/candid'; - -export interface _SERVICE { - 'decrement' : ActorMethod<[], bigint>, - 'getCount' : ActorMethod<[], bigint>, - 'increment' : ActorMethod<[], bigint>, - 'reset' : ActorMethod<[], bigint>, -} -export declare const idlFactory: IDL.InterfaceFactory; -export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did.js deleted file mode 100644 index c8788f7c1..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_backend/minimal_dapp_backend.did.js +++ /dev/null @@ -1,9 +0,0 @@ -export const idlFactory = ({ IDL }) => { - return IDL.Service({ - 'decrement' : IDL.Func([], [IDL.Nat], []), - 'getCount' : IDL.Func([], [IDL.Nat], ['query']), - 'increment' : IDL.Func([], [IDL.Nat], []), - 'reset' : IDL.Func([], [IDL.Nat], []), - }); -}; -export const init = ({ IDL }) => { return []; }; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/index.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/index.d.ts deleted file mode 100644 index 1e5e96e41..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { - ActorSubclass, - HttpAgentOptions, - ActorConfig, - Agent, -} from "@dfinity/agent"; -import type { Principal } from "@dfinity/principal"; -import type { IDL } from "@dfinity/candid"; - -import { _SERVICE } from './minimal_dapp_frontend.did'; - -export declare const idlFactory: IDL.InterfaceFactory; -export declare const canisterId: string; - -export declare interface CreateActorOptions { - /** - * @see {@link Agent} - */ - agent?: Agent; - /** - * @see {@link HttpAgentOptions} - */ - agentOptions?: HttpAgentOptions; - /** - * @see {@link ActorConfig} - */ - actorOptions?: ActorConfig; -} - -/** - * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. - * @constructs {@link ActorSubClass} - * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to - * @param {CreateActorOptions} options - see {@link CreateActorOptions} - * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions - * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent - * @see {@link HttpAgentOptions} - * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor - * @see {@link ActorConfig} - */ -export declare const createActor: ( - canisterId: string | Principal, - options?: CreateActorOptions -) => ActorSubclass<_SERVICE>; - -/** - * Intialized Actor using default settings, ready to talk to a canister using its candid interface - * @constructs {@link ActorSubClass} - */ -export declare const minimal_dapp_frontend: ActorSubclass<_SERVICE>; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/index.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/index.js deleted file mode 100644 index 8ea1f23c2..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from "./minimal_dapp_frontend.did.js"; -export { idlFactory } from "./minimal_dapp_frontend.did.js"; - -/* CANISTER_ID is replaced by webpack based on node environment - * Note: canister environment variable will be standardized as - * process.env.CANISTER_ID_ - * beginning in dfx 0.15.0 - */ -export const canisterId = - process.env.CANISTER_ID_MINIMAL_DAPP_FRONTEND; - -export const createActor = (canisterId, options = {}) => { - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - if (options.agent && options.agentOptions) { - console.warn( - "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." - ); - } - - // Fetch root key for certificate validation during development - if (process.env.DFX_NETWORK !== "ic") { - agent.fetchRootKey().catch((err) => { - console.warn( - "Unable to fetch root key. Check to ensure that your local replica is running" - ); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options.actorOptions, - }); -}; - -export const minimal_dapp_frontend = canisterId ? createActor(canisterId) : undefined; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did deleted file mode 100644 index ccf075ffc..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did +++ /dev/null @@ -1,263 +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 }); - create_chunks: (record { batch_id: BatchId; content: vec blob }) -> (record { chunk_ids: vec 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/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did.d.ts b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did.d.ts deleted file mode 100644 index 5412f47ab..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did.d.ts +++ /dev/null @@ -1,244 +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 } - >, - 'create_chunks' : ActorMethod< - [{ 'content' : Array, 'batch_id' : BatchId }], - { 'chunk_ids' : Array } - >, - '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: (args: { IDL: typeof IDL }) => IDL.Type[]; diff --git a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did.js b/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did.js deleted file mode 100644 index 00c0ddde8..000000000 --- a/motoko/minimal-counter-dapp/src/declarations/minimal_dapp_frontend/minimal_dapp_frontend.did.js +++ /dev/null @@ -1,296 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const SetPermissions = IDL.Record({ - 'prepare' : IDL.Vec(IDL.Principal), - 'commit' : IDL.Vec(IDL.Principal), - 'manage_permissions' : IDL.Vec(IDL.Principal), - }); - const UpgradeArgs = IDL.Record({ - 'set_permissions' : IDL.Opt(SetPermissions), - }); - const InitArgs = IDL.Record({}); - const AssetCanisterArgs = IDL.Variant({ - 'Upgrade' : UpgradeArgs, - 'Init' : InitArgs, - }); - 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 })], - [], - ), - 'create_chunks' : IDL.Func( - [ - IDL.Record({ - 'content' : IDL.Vec(IDL.Vec(IDL.Nat8)), - 'batch_id' : BatchId, - }), - ], - [IDL.Record({ 'chunk_ids' : IDL.Vec(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 }) => { - const SetPermissions = IDL.Record({ - 'prepare' : IDL.Vec(IDL.Principal), - 'commit' : IDL.Vec(IDL.Principal), - 'manage_permissions' : IDL.Vec(IDL.Principal), - }); - const UpgradeArgs = IDL.Record({ - 'set_permissions' : IDL.Opt(SetPermissions), - }); - const InitArgs = IDL.Record({}); - const AssetCanisterArgs = IDL.Variant({ - 'Upgrade' : UpgradeArgs, - 'Init' : InitArgs, - }); - return [IDL.Opt(AssetCanisterArgs)]; -}; diff --git a/motoko/minimal-counter-dapp/webpack.config.js b/motoko/minimal-counter-dapp/webpack.config.js deleted file mode 100644 index e2b20a7b7..000000000 --- a/motoko/minimal-counter-dapp/webpack.config.js +++ /dev/null @@ -1,112 +0,0 @@ -const path = require("path"); -const webpack = require("webpack"); -const HtmlWebpackPlugin = require("html-webpack-plugin"); -const TerserPlugin = require("terser-webpack-plugin"); - -function initCanisterEnv() { - let localCanisters, prodCanisters; - try { - localCanisters = require(path.resolve( - ".dfx", - "local", - "canister_ids.json" - )); - } catch (error) { - console.log("No local canister_ids.json found. Continuing production"); - } - try { - prodCanisters = require(path.resolve("canister_ids.json")); - } catch (error) { - console.log("No production canister_ids.json found. Continuing with local"); - } - - const network = - process.env.DFX_NETWORK || - (process.env.NODE_ENV === "production" ? "ic" : "local"); - - const canisterConfig = network === "local" ? localCanisters : prodCanisters; - - return Object.entries(canisterConfig).reduce((prev, current) => { - const [canisterName, canisterDetails] = current; - prev[canisterName.toUpperCase() + "_CANISTER_ID"] = - canisterDetails[network]; - return prev; - }, {}); -} -const canisterEnvVariables = initCanisterEnv(); - -const isDevelopment = process.env.NODE_ENV !== "production"; - -const frontendDirectory = "minimal_dapp_assets"; - -const asset_entry = path.join("src", frontendDirectory, "src", "index.html"); - -module.exports = { - target: "web", - mode: isDevelopment ? "development" : "production", - entry: { - // The frontend.entrypoint points to the HTML file for this build, so we need - // to replace the extension to `.js`. - index: path.join(__dirname, asset_entry).replace(/\.html$/, ".js"), - }, - devtool: isDevelopment ? "source-map" : false, - optimization: { - minimize: !isDevelopment, - minimizer: [new TerserPlugin()], - }, - resolve: { - extensions: [".js", ".ts", ".jsx", ".tsx"], - fallback: { - assert: require.resolve("assert/"), - buffer: require.resolve("buffer/"), - events: require.resolve("events/"), - stream: require.resolve("stream-browserify/"), - util: require.resolve("util/"), - }, - }, - output: { - filename: "index.js", - path: path.join(__dirname, "dist", frontendDirectory), - }, - - // Depending in the language or framework you are using for - // front-end development, add module loaders to the default - // webpack configuration. For example, if you are using React - // modules and CSS as described in the "Adding a stylesheet" - // tutorial, uncomment the following lines: - // module: { - // rules: [ - // { test: /\.(ts|tsx|jsx)$/, loader: "ts-loader" }, - // { test: /\.css$/, use: ["style-loader","css-loader"] } - // ] - // }, - plugins: [ - new HtmlWebpackPlugin({ - template: path.join(__dirname, asset_entry), - cache: false, - }), - new webpack.EnvironmentPlugin({ - NODE_ENV: "development", - ...canisterEnvVariables, - }), - new webpack.ProvidePlugin({ - Buffer: [require.resolve("buffer/"), "Buffer"], - process: require.resolve("process/browser"), - }), - ], - // proxy /api to port 8000 during development - devServer: { - proxy: { - "/api": { - target: "http://localhost:8000", - changeOrigin: true, - pathRewrite: { - "^/api": "/api", - }, - }, - }, - hot: true, - watchFiles: [path.resolve(__dirname, "src", frontendDirectory)], - liveReload: true, - }, -};