ic-mops 1.7.2 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/bundle/bench/bench-canister.mo +113 -0
  3. package/bundle/bench/user-bench.mo +14 -0
  4. package/bundle/bin/moc-wrapper.sh +40 -0
  5. package/bundle/bin/mops.js +3 -0
  6. package/bundle/cli.js +14 -14
  7. package/bundle/cli.tgz +0 -0
  8. package/bundle/declarations/bench/bench.did +30 -0
  9. package/bundle/declarations/bench/bench.did.d.ts +33 -0
  10. package/bundle/declarations/bench/bench.did.js +30 -0
  11. package/bundle/declarations/bench/index.d.ts +50 -0
  12. package/bundle/declarations/bench/index.js +40 -0
  13. package/bundle/declarations/main/index.d.ts +50 -0
  14. package/bundle/declarations/main/index.js +40 -0
  15. package/bundle/declarations/main/main.did +465 -0
  16. package/bundle/declarations/main/main.did.d.ts +392 -0
  17. package/bundle/declarations/main/main.did.js +454 -0
  18. package/bundle/declarations/storage/index.d.ts +50 -0
  19. package/bundle/declarations/storage/index.js +30 -0
  20. package/bundle/declarations/storage/storage.did +46 -0
  21. package/bundle/declarations/storage/storage.did.d.ts +40 -0
  22. package/bundle/declarations/storage/storage.did.js +38 -0
  23. package/bundle/package.json +35 -0
  24. package/bundle/templates/README.md +13 -0
  25. package/bundle/templates/licenses/Apache-2.0 +202 -0
  26. package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
  27. package/bundle/templates/licenses/MIT +21 -0
  28. package/bundle/templates/mops-publish.yml +17 -0
  29. package/bundle/templates/mops-test.yml +24 -0
  30. package/bundle/templates/src/lib.mo +15 -0
  31. package/bundle/templates/test/lib.test.mo +4 -0
  32. package/bundle/wasm_bg.wasm +0 -0
  33. package/cli.ts +16 -0
  34. package/commands/format.ts +169 -0
  35. package/commands/publish.ts +1 -0
  36. package/commands/watch/formatter.ts +74 -0
  37. package/commands/watch/watch.ts +23 -2
  38. package/dist/cli.js +15 -0
  39. package/dist/commands/format.d.ts +14 -0
  40. package/dist/commands/format.js +131 -0
  41. package/dist/commands/publish.js +1 -0
  42. package/dist/commands/watch/formatter.d.ts +19 -0
  43. package/dist/commands/watch/formatter.js +57 -0
  44. package/dist/commands/watch/watch.d.ts +1 -0
  45. package/dist/commands/watch/watch.js +19 -1
  46. package/dist/package.json +4 -2
  47. package/package.json +6 -4
  48. package/types.ts +10 -0
package/bundle/cli.tgz ADDED
Binary file
@@ -0,0 +1,30 @@
1
+ type _anon_class_13_1 =
2
+ service {
3
+ getSchema: () -> (BenchSchema) query;
4
+ getStats: () -> (BenchResult) query;
5
+ init: () -> (BenchSchema);
6
+ runCellQuery: (nat, nat) -> (BenchResult) query;
7
+ runCellUpdate: (nat, nat) -> (BenchResult);
8
+ runCellUpdateAwait: (nat, nat) -> (BenchResult);
9
+ };
10
+ type BenchSchema =
11
+ record {
12
+ cols: vec text;
13
+ description: text;
14
+ name: text;
15
+ rows: vec text;
16
+ };
17
+ type BenchResult =
18
+ record {
19
+ instructions: int;
20
+ rts_collector_instructions: int;
21
+ rts_heap_size: int;
22
+ rts_logical_stable_memory_size: int;
23
+ rts_memory_size: int;
24
+ rts_mutator_instructions: int;
25
+ rts_reclaimed: int;
26
+ rts_stable_memory_size: int;
27
+ rts_total_allocation: int;
28
+ stable_memory_size: int;
29
+ };
30
+ service : () -> _anon_class_13_1
@@ -0,0 +1,33 @@
1
+ import type { Principal } from '@dfinity/principal';
2
+ import type { ActorMethod } from '@dfinity/agent';
3
+ import type { IDL } from '@dfinity/candid';
4
+
5
+ export interface BenchResult {
6
+ 'rts_stable_memory_size' : bigint,
7
+ 'stable_memory_size' : bigint,
8
+ 'instructions' : bigint,
9
+ 'rts_memory_size' : bigint,
10
+ 'rts_total_allocation' : bigint,
11
+ 'rts_collector_instructions' : bigint,
12
+ 'rts_mutator_instructions' : bigint,
13
+ 'rts_logical_stable_memory_size' : bigint,
14
+ 'rts_heap_size' : bigint,
15
+ 'rts_reclaimed' : bigint,
16
+ }
17
+ export interface BenchSchema {
18
+ 'cols' : Array<string>,
19
+ 'name' : string,
20
+ 'rows' : Array<string>,
21
+ 'description' : string,
22
+ }
23
+ export interface _anon_class_13_1 {
24
+ 'getSchema' : ActorMethod<[], BenchSchema>,
25
+ 'getStats' : ActorMethod<[], BenchResult>,
26
+ 'init' : ActorMethod<[], BenchSchema>,
27
+ 'runCellQuery' : ActorMethod<[bigint, bigint], BenchResult>,
28
+ 'runCellUpdate' : ActorMethod<[bigint, bigint], BenchResult>,
29
+ 'runCellUpdateAwait' : ActorMethod<[bigint, bigint], BenchResult>,
30
+ }
31
+ export interface _SERVICE extends _anon_class_13_1 {}
32
+ export declare const idlFactory: IDL.InterfaceFactory;
33
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -0,0 +1,30 @@
1
+ export const idlFactory = ({ IDL }) => {
2
+ const BenchSchema = IDL.Record({
3
+ 'cols' : IDL.Vec(IDL.Text),
4
+ 'name' : IDL.Text,
5
+ 'rows' : IDL.Vec(IDL.Text),
6
+ 'description' : IDL.Text,
7
+ });
8
+ const BenchResult = IDL.Record({
9
+ 'rts_stable_memory_size' : IDL.Int,
10
+ 'stable_memory_size' : IDL.Int,
11
+ 'instructions' : IDL.Int,
12
+ 'rts_memory_size' : IDL.Int,
13
+ 'rts_total_allocation' : IDL.Int,
14
+ 'rts_collector_instructions' : IDL.Int,
15
+ 'rts_mutator_instructions' : IDL.Int,
16
+ 'rts_logical_stable_memory_size' : IDL.Int,
17
+ 'rts_heap_size' : IDL.Int,
18
+ 'rts_reclaimed' : IDL.Int,
19
+ });
20
+ const _anon_class_13_1 = IDL.Service({
21
+ 'getSchema' : IDL.Func([], [BenchSchema], ['query']),
22
+ 'getStats' : IDL.Func([], [BenchResult], ['query']),
23
+ 'init' : IDL.Func([], [BenchSchema], []),
24
+ 'runCellQuery' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], ['query']),
25
+ 'runCellUpdate' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
26
+ 'runCellUpdateAwait' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
27
+ });
28
+ return _anon_class_13_1;
29
+ };
30
+ export const init = ({ IDL }) => { return []; };
@@ -0,0 +1,50 @@
1
+ import type {
2
+ ActorSubclass,
3
+ HttpAgentOptions,
4
+ ActorConfig,
5
+ Agent,
6
+ } from "@dfinity/agent";
7
+ import type { Principal } from "@dfinity/principal";
8
+ import type { IDL } from "@dfinity/candid";
9
+
10
+ import { _SERVICE } from './bench.did';
11
+
12
+ export declare const idlFactory: IDL.InterfaceFactory;
13
+ export declare const canisterId: string;
14
+
15
+ export declare interface CreateActorOptions {
16
+ /**
17
+ * @see {@link Agent}
18
+ */
19
+ agent?: Agent;
20
+ /**
21
+ * @see {@link HttpAgentOptions}
22
+ */
23
+ agentOptions?: HttpAgentOptions;
24
+ /**
25
+ * @see {@link ActorConfig}
26
+ */
27
+ actorOptions?: ActorConfig;
28
+ }
29
+
30
+ /**
31
+ * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
32
+ * @constructs {@link ActorSubClass}
33
+ * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
34
+ * @param {CreateActorOptions} options - see {@link CreateActorOptions}
35
+ * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
36
+ * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
37
+ * @see {@link HttpAgentOptions}
38
+ * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
39
+ * @see {@link ActorConfig}
40
+ */
41
+ export declare const createActor: (
42
+ canisterId: string | Principal,
43
+ options?: CreateActorOptions
44
+ ) => ActorSubclass<_SERVICE>;
45
+
46
+ /**
47
+ * Intialized Actor using default settings, ready to talk to a canister using its candid interface
48
+ * @constructs {@link ActorSubClass}
49
+ */
50
+ export declare const bench: ActorSubclass<_SERVICE>;
@@ -0,0 +1,40 @@
1
+ import { Actor, HttpAgent } from "@dfinity/agent";
2
+
3
+ // Imports and re-exports candid interface
4
+ import { idlFactory } from "./bench.did.js";
5
+ export { idlFactory } from "./bench.did.js";
6
+
7
+ /* CANISTER_ID is replaced by webpack based on node environment
8
+ * Note: canister environment variable will be standardized as
9
+ * process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
10
+ * beginning in dfx 0.15.0
11
+ */
12
+ export const canisterId =
13
+ process.env.CANISTER_ID_BENCH;
14
+
15
+ export const createActor = (canisterId, options = {}) => {
16
+ const agent = options.agent || new HttpAgent({ ...options.agentOptions });
17
+
18
+ if (options.agent && options.agentOptions) {
19
+ console.warn(
20
+ "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent."
21
+ );
22
+ }
23
+
24
+ // Fetch root key for certificate validation during development
25
+ if (process.env.DFX_NETWORK !== "ic") {
26
+ agent.fetchRootKey().catch((err) => {
27
+ console.warn(
28
+ "Unable to fetch root key. Check to ensure that your local replica is running"
29
+ );
30
+ console.error(err);
31
+ });
32
+ }
33
+
34
+ // Creates an actor with using the candid interface and the HttpAgent
35
+ return Actor.createActor(idlFactory, {
36
+ agent,
37
+ canisterId,
38
+ ...options.actorOptions,
39
+ });
40
+ };
@@ -0,0 +1,50 @@
1
+ import type {
2
+ ActorSubclass,
3
+ HttpAgentOptions,
4
+ ActorConfig,
5
+ Agent,
6
+ } from "@dfinity/agent";
7
+ import type { Principal } from "@dfinity/principal";
8
+ import type { IDL } from "@dfinity/candid";
9
+
10
+ import { _SERVICE } from './main.did';
11
+
12
+ export declare const idlFactory: IDL.InterfaceFactory;
13
+ export declare const canisterId: string;
14
+
15
+ export declare interface CreateActorOptions {
16
+ /**
17
+ * @see {@link Agent}
18
+ */
19
+ agent?: Agent;
20
+ /**
21
+ * @see {@link HttpAgentOptions}
22
+ */
23
+ agentOptions?: HttpAgentOptions;
24
+ /**
25
+ * @see {@link ActorConfig}
26
+ */
27
+ actorOptions?: ActorConfig;
28
+ }
29
+
30
+ /**
31
+ * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
32
+ * @constructs {@link ActorSubClass}
33
+ * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
34
+ * @param {CreateActorOptions} options - see {@link CreateActorOptions}
35
+ * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
36
+ * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
37
+ * @see {@link HttpAgentOptions}
38
+ * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
39
+ * @see {@link ActorConfig}
40
+ */
41
+ export declare const createActor: (
42
+ canisterId: string | Principal,
43
+ options?: CreateActorOptions
44
+ ) => ActorSubclass<_SERVICE>;
45
+
46
+ /**
47
+ * Intialized Actor using default settings, ready to talk to a canister using its candid interface
48
+ * @constructs {@link ActorSubClass}
49
+ */
50
+ export declare const main: ActorSubclass<_SERVICE>;
@@ -0,0 +1,40 @@
1
+ import { Actor, HttpAgent } from "@dfinity/agent";
2
+
3
+ // Imports and re-exports candid interface
4
+ import { idlFactory } from "./main.did.js";
5
+ export { idlFactory } from "./main.did.js";
6
+
7
+ /* CANISTER_ID is replaced by webpack based on node environment
8
+ * Note: canister environment variable will be standardized as
9
+ * process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
10
+ * beginning in dfx 0.15.0
11
+ */
12
+ export const canisterId =
13
+ process.env.CANISTER_ID_MAIN;
14
+
15
+ export const createActor = (canisterId, options = {}) => {
16
+ const agent = options.agent || new HttpAgent({ ...options.agentOptions });
17
+
18
+ if (options.agent && options.agentOptions) {
19
+ console.warn(
20
+ "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent."
21
+ );
22
+ }
23
+
24
+ // Fetch root key for certificate validation during development
25
+ if (process.env.DFX_NETWORK !== "ic") {
26
+ agent.fetchRootKey().catch((err) => {
27
+ console.warn(
28
+ "Unable to fetch root key. Check to ensure that your local replica is running"
29
+ );
30
+ console.error(err);
31
+ });
32
+ }
33
+
34
+ // Creates an actor with using the candid interface and the HttpAgent
35
+ return Actor.createActor(idlFactory, {
36
+ agent,
37
+ canisterId,
38
+ ...options.actorOptions,
39
+ });
40
+ };