ic-mops 0.37.1 → 0.37.3

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 (69) hide show
  1. package/commands/docs.ts +1 -1
  2. package/commands/test/test.ts +1 -1
  3. package/dist/bin/mops.js +0 -0
  4. package/dist/commands/docs.js +1 -1
  5. package/dist/commands/test/test.js +1 -1
  6. package/dist/package.json +1 -1
  7. package/package.json +1 -1
  8. package/dist/cli-local.d.ts +0 -2
  9. package/dist/cli-local.js +0 -2
  10. package/dist/commands/toolchain/mocv.d.ts +0 -1
  11. package/dist/commands/toolchain/mocv.js +0 -271
  12. package/dist/moc-wrapper.d.ts +0 -2
  13. package/dist/moc-wrapper.js +0 -8
  14. package/dist/out/cli.d.ts +0 -2
  15. package/dist/out/cli.js +0 -115242
  16. package/dist/pic-js/examples/clock/tests/clock/index.d.ts +0 -1
  17. package/dist/pic-js/examples/clock/tests/clock/index.js +0 -5
  18. package/dist/pic-js/examples/clock/tests/jest.config.d.ts +0 -3
  19. package/dist/pic-js/examples/clock/tests/jest.config.js +0 -8
  20. package/dist/pic-js/examples/clock/tests/src/clock.spec.d.ts +0 -1
  21. package/dist/pic-js/examples/clock/tests/src/clock.spec.js +0 -48
  22. package/dist/pic-js/examples/counter/tests/counter/index.d.ts +0 -1
  23. package/dist/pic-js/examples/counter/tests/counter/index.js +0 -5
  24. package/dist/pic-js/examples/counter/tests/jest.config.d.ts +0 -3
  25. package/dist/pic-js/examples/counter/tests/jest.config.js +0 -8
  26. package/dist/pic-js/examples/counter/tests/src/counter.spec.d.ts +0 -1
  27. package/dist/pic-js/examples/counter/tests/src/counter.spec.js +0 -80
  28. package/dist/pic-js/examples/todo/tests/jest.config.d.ts +0 -3
  29. package/dist/pic-js/examples/todo/tests/jest.config.js +0 -8
  30. package/dist/pic-js/examples/todo/tests/src/todo.spec.d.ts +0 -1
  31. package/dist/pic-js/examples/todo/tests/src/todo.spec.js +0 -211
  32. package/dist/pic-js/examples/todo/tests/todo/index.d.ts +0 -1
  33. package/dist/pic-js/examples/todo/tests/todo/index.js +0 -5
  34. package/dist/pic-js/packages/pic/src/error.d.ts +0 -12
  35. package/dist/pic-js/packages/pic/src/error.js +0 -36
  36. package/dist/pic-js/packages/pic/src/http-client.d.ts +0 -15
  37. package/dist/pic-js/packages/pic/src/http-client.js +0 -37
  38. package/dist/pic-js/packages/pic/src/identity.d.ts +0 -66
  39. package/dist/pic-js/packages/pic/src/identity.js +0 -86
  40. package/dist/pic-js/packages/pic/src/index.d.ts +0 -4
  41. package/dist/pic-js/packages/pic/src/index.js +0 -8
  42. package/dist/pic-js/packages/pic/src/management-canister.d.ts +0 -30
  43. package/dist/pic-js/packages/pic/src/management-canister.js +0 -43
  44. package/dist/pic-js/packages/pic/src/pocket-ic-actor.d.ts +0 -83
  45. package/dist/pic-js/packages/pic/src/pocket-ic-actor.js +0 -58
  46. package/dist/pic-js/packages/pic/src/pocket-ic-client-types.d.ts +0 -61
  47. package/dist/pic-js/packages/pic/src/pocket-ic-client-types.js +0 -2
  48. package/dist/pic-js/packages/pic/src/pocket-ic-client.d.ts +0 -24
  49. package/dist/pic-js/packages/pic/src/pocket-ic-client.js +0 -123
  50. package/dist/pic-js/packages/pic/src/pocket-ic-server.d.ts +0 -10
  51. package/dist/pic-js/packages/pic/src/pocket-ic-server.js +0 -55
  52. package/dist/pic-js/packages/pic/src/pocket-ic-types.d.ts +0 -40
  53. package/dist/pic-js/packages/pic/src/pocket-ic-types.js +0 -2
  54. package/dist/pic-js/packages/pic/src/pocket-ic.d.ts +0 -447
  55. package/dist/pic-js/packages/pic/src/pocket-ic.js +0 -551
  56. package/dist/pic-js/packages/pic/src/util/candid.d.ts +0 -1
  57. package/dist/pic-js/packages/pic/src/util/candid.js +0 -7
  58. package/dist/pic-js/packages/pic/src/util/encoding.d.ts +0 -5
  59. package/dist/pic-js/packages/pic/src/util/encoding.js +0 -19
  60. package/dist/pic-js/packages/pic/src/util/fs.d.ts +0 -4
  61. package/dist/pic-js/packages/pic/src/util/fs.js +0 -29
  62. package/dist/pic-js/packages/pic/src/util/index.d.ts +0 -5
  63. package/dist/pic-js/packages/pic/src/util/index.js +0 -21
  64. package/dist/pic-js/packages/pic/src/util/os.d.ts +0 -4
  65. package/dist/pic-js/packages/pic/src/util/os.js +0 -19
  66. package/dist/pic-js/packages/pic/src/util/poll.d.ts +0 -5
  67. package/dist/pic-js/packages/pic/src/util/poll.js +0 -28
  68. package/dist/templates/cli.d.ts +0 -2
  69. package/dist/templates/cli.js +0 -3660
@@ -1,447 +0,0 @@
1
- import { Principal } from '@dfinity/principal';
2
- import { IDL } from '@dfinity/candid';
3
- import { ActorInterface, Actor } from './pocket-ic-actor';
4
- import { CanisterFixture, CreateCanisterOptions } from './pocket-ic-types';
5
- /**
6
- * PocketIC is a local development environment for Internet Computer canisters.
7
- *
8
- * @category API
9
- *
10
- * @example
11
- * The easist way to use PocketIC is to use {@link setupCanister} convenience method:
12
- * ```ts
13
- * import { PocketIc } from '@hadronous/pic';
14
- * import { _SERVICE, idlFactory } from '../declarations';
15
- *
16
- * const wasmPath = resolve('..', '..', 'canister.wasm');
17
- *
18
- * const pic = await PocketIc.create();
19
- * const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
20
- * const { actor } = fixture;
21
- *
22
- * // perform tests...
23
- *
24
- * await pic.tearDown();
25
- * ```
26
- *
27
- * If more control is needed, then the {@link createCanister}, {@link installCode} and
28
- * {@link createActor} methods can be used directly:
29
- * ```ts
30
- * import { PocketIc } from '@hadronous/pic';
31
- * import { _SERVICE, idlFactory } from '../declarations';
32
- *
33
- * const wasmPath = resolve('..', '..', 'canister.wasm');
34
- *
35
- * const pic = await PocketIc.create();
36
- *
37
- * const canisterId = await pic.createCanister();
38
- * await pic.installCode(canisterId, wasmPath);
39
- * const actor = pic.createActor<_SERVICE>(idlFactory, canisterId);
40
- *
41
- * // perform tests...
42
- *
43
- * await pic.tearDown();
44
- * ```
45
- */
46
- export declare class PocketIc {
47
- private readonly client;
48
- private readonly server?;
49
- private constructor();
50
- /**
51
- * Starts the PocketIC server and creates a PocketIC instance.
52
- *
53
- * @returns A new PocketIC instance.
54
- *
55
- * @example
56
- * ```ts
57
- * import { PocketIc } from '@hadronous/pic';
58
- *
59
- * const pic = await PocketIc.create();
60
- * ```
61
- */
62
- static create(): Promise<PocketIc>;
63
- /**
64
- * Creates a PocketIC instance that connects to an existing PocketIC server.
65
- *
66
- * @param url The URL of an existing PocketIC server to connect to.
67
- * @returns A new PocketIC instance.
68
- *
69
- * @example
70
- * ```ts
71
- * import { PocketIc } from '@hadronous/pic';
72
- *
73
- * const url = 'http://localhost:8080';
74
- * const pic = await PocketIc.createFromUrl(url);
75
- * ```
76
- */
77
- static createFromUrl(url: string): Promise<PocketIc>;
78
- /**
79
- * A convenience method that creates a new canister,
80
- * installs the given WASM module to it and returns a typesafe {@link Actor}
81
- * that implements the Candid interface of the canister.
82
- * To just create a canister, see {@link createCanister}.
83
- * To just install code to an existing canister, see {@link installCode}.
84
- * To just create an Actor for an existing canister, see {@link createActor}.
85
- *
86
- * @param interfaceFactory The interface factory to use for the {@link Actor}.
87
- * @param wasm The WASM module to install to the canister.
88
- * If a string is passed, it is treated as a path to a file.
89
- * If an Uint8Array is passed, it is treated as the WASM module itself.
90
- * @param createCanisterOptions Options for creating the canister, see {@link CreateCanisterOptions}.
91
- * @param arg Candid encoded argument to pass to the canister's init function.
92
- * @param sender The Principal to send the request as.
93
- * @returns The {@link Actor} instance.
94
- *
95
- * @see [Candid](https://internetcomputer.org/docs/current/references/candid-ref)
96
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
97
- *
98
- * @example
99
- * ```ts
100
- * import { PocketIc } from '@hadronous/pic';
101
- * import { _SERVICE, idlFactory } from '../declarations';
102
- *
103
- * const wasmPath = resolve('..', '..', 'canister.wasm');
104
- *
105
- * const pic = await PocketIc.create();
106
- * const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
107
- * const { actor } = fixture;
108
- * ```
109
- */
110
- setupCanister<T = ActorInterface>(interfaceFactory: IDL.InterfaceFactory, wasm: Uint8Array | string, createCanisterOptions?: CreateCanisterOptions, arg?: Uint8Array, sender?: Principal): Promise<CanisterFixture<T>>;
111
- /**
112
- * Creates a new canister.
113
- * For a more convenient way of creating a PocketIC instance,
114
- * creating a canister and installing code, see {@link setupCanister}.
115
- *
116
- * @param options Options for creating the canister, see {@link CreateCanisterOptions}.
117
- * @param sender The Principal to send the request as.
118
- * @returns The Principal of the newly created canister.
119
- *
120
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
121
- *
122
- * @example
123
- * ```ts
124
- * import { PocketIc } from '@hadronous/pic';
125
- *
126
- * const pic = await PocketIc.create();
127
- * const canisterId = await pic.createCanister();
128
- * ```
129
- */
130
- createCanister(options?: CreateCanisterOptions, sender?: Principal): Promise<Principal>;
131
- /**
132
- * Installs the given WASM module to the provided canister.
133
- * To create a canister to install code to, see {@link createCanister}.
134
- * For a more convenient way of creating a PocketIC instance,
135
- * creating a canister and installing code, see {@link setupCanister}.
136
- *
137
- * @param canisterId The Principal of the canister to install the code to.
138
- * @param wasm The WASM module to install to the canister.
139
- * If a string is passed, it is treated as a path to a file.
140
- * If an Uint8Array is passed, it is treated as the WASM module itself.
141
- * @param arg Candid encoded argument to pass to the canister's init function.
142
- * @param sender The Principal to send the request as.
143
- *
144
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
145
- *
146
- * @example
147
- * ```ts
148
- * import { Principal } from '@dfinity/principal';
149
- * import { PocketIc } from '@hadronous/pic';
150
- * import { resolve } from 'node:path';
151
- *
152
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
153
- * const wasmPath = resolve('..', '..', 'canister.wasm');
154
- *
155
- * const pic = await PocketIc.create();
156
- * await pic.installCode(canisterId, wasmPath);
157
- * ```
158
- */
159
- installCode(canisterId: Principal, wasm: Uint8Array | string, arg?: Uint8Array, sender?: Principal): Promise<void>;
160
- /**
161
- * Reinstalls the given WASM module to the provided canister.
162
- * This will reset both the canister's heap and its stable memory.
163
- * To create a canister to upgrade, see {@link createCanister}.
164
- * To install the initial WASM module to a new canister, see {@link installCode}.
165
- *
166
- * @param canisterId The Principal of the canister to reinstall code to.
167
- * @param wasm The WASM module to install to the canister.
168
- * If a string is passed, it is treated as a path to a file.
169
- * If an Uint8Array is passed, it is treated as the WASM module itself.
170
- * @param arg Candid encoded argument to pass to the canister's init function.
171
- * @param sender The Principal to send the request as.
172
- *
173
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
174
- *
175
- * @example
176
- * ```ts
177
- * import { Principal } from '@dfinity/principal';
178
- * import { PocketIc } from '@hadronous/pic';
179
- * import { resolve } from 'node:path';
180
- *
181
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
182
- * const wasmPath = resolve('..', '..', 'canister.wasm');
183
- *
184
- * const pic = await PocketIc.create();
185
- * await pic.reinstallCode(canisterId, wasmPath);
186
- * ```
187
- */
188
- reinstallCode(canisterId: Principal, wasm: Uint8Array | string, arg?: Uint8Array, sender?: Principal): Promise<void>;
189
- /**
190
- * Upgrades the given canister with the given WASM module.
191
- * This will reset the canister's heap, but preserve stable memory.
192
- * To create a canister to upgrade to, see {@link createCanister}.
193
- * To install the initial WASM module to a new canister, see {@link installCode}.
194
- *
195
- * @param canisterId The Principal of the canister to upgrade.
196
- * @param wasm The WASM module to install to the canister.
197
- * If a string is passed, it is treated as a path to a file.
198
- * If an Uint8Array is passed, it is treated as the WASM module itself.
199
- * @param arg Candid encoded argument to pass to the canister's init function.
200
- * @param sender The Principal to send the request as.
201
- *
202
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
203
- *
204
- * @example
205
- * ```ts
206
- * import { Principal } from '@dfinity/principal';
207
- * import { PocketIc } from '@hadronous/pic';
208
- * import { resolve } from 'node:path';
209
- *
210
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
211
- * const wasmPath = resolve('..', '..', 'canister.wasm');
212
- *
213
- * const pic = await PocketIc.create();
214
- * await pic.upgradeCanister(canisterId, wasmPath);
215
- * ```
216
- */
217
- upgradeCanister(canisterId: Principal, wasm: Uint8Array | string, arg?: Uint8Array, sender?: Principal): Promise<void>;
218
- /**
219
- * Creates an {@link Actor} for the given canister.
220
- * An {@link Actor} is a typesafe class that implements the Candid interface of a canister.
221
- * To create a canister for the Actor, see {@link createCanister}.
222
- * For a more convenient way of creating a PocketIC instance,
223
- * creating a canister and installing code, see {@link setupCanister}.
224
- *
225
- * @param interfaceFactory The InterfaceFactory to use for the {@link Actor}.
226
- * @param canisterId The Principal of the canister to create the Actor for.
227
- * @typeparam T The type of the {@link Actor}. Must implement {@link ActorInterface}.
228
- * @returns The {@link Actor} instance.
229
- *
230
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
231
- * @see [InterfaceFactory](https://agent-js.icp.xyz/candid/modules/IDL.html#InterfaceFactory)
232
- *
233
- * @example
234
- * ```ts
235
- * import { Principal } from '@dfinity/principal';
236
- * import { PocketIc } from '@hadronous/pic';
237
- * import { _SERVICE, idlFactory } from '../declarations';
238
- *
239
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
240
- *
241
- * const pic = await PocketIc.create();
242
- * const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
243
- * const { actor } = fixture;
244
- * ```
245
- */
246
- createActor<T = ActorInterface>(interfaceFactory: IDL.InterfaceFactory, canisterId: Principal): Actor<T>;
247
- /**
248
- * Deletes the PocketIC instance and disconnects from the server.
249
- *
250
- * @example
251
- * ```ts
252
- * import { PocketIc } from '@hadronous/pic';
253
- *
254
- * const pic = await PocketIc.create();
255
- * await pic.tearDown();
256
- * ```
257
- */
258
- tearDown(): Promise<void>;
259
- /**
260
- * Make the IC produce and progress by one block.
261
- *
262
- * ```ts
263
- * import { PocketIc } from '@hadronous/pic';
264
- *
265
- * const pic = await PocketIc.create();
266
- * await pic.tick();
267
- * ```
268
- */
269
- tick(): Promise<void>;
270
- /**
271
- * Get the current time of the IC in milliseconds since the Unix epoch.
272
- *
273
- * @returns The current time in milliseconds since the UNIX epoch.
274
- *
275
- * @example
276
- * ```ts
277
- * import { PocketIc } from '@hadronous/pic';
278
- *
279
- * const pic = await PocketIc.create();
280
- *
281
- * const time = await pic.getTime();
282
- * ```
283
- */
284
- getTime(): Promise<number>;
285
- /**
286
- * Reset the time of the IC to the current time.
287
- *
288
- * @example
289
- * ```ts
290
- * import { PocketIc } from '@hadronous/pic';
291
- *
292
- * const pic = await PocketIc.create();
293
- *
294
- * await pic.resetTime();
295
- * const time = await pic.getTime();
296
- * ```
297
- */
298
- resetTime(): Promise<void>;
299
- /**
300
- * Set the current time of the IC.
301
- *
302
- * @param time The time to set in milliseconds since the Unix epoch.
303
- *
304
- * @example
305
- * ```ts
306
- * import { PocketIc } from '@hadronous/pic';
307
- *
308
- * const pic = await PocketIc.create();
309
- *
310
- * const date = new Date();
311
- * await pic.setTime(date.getTime());
312
- * const time = await pic.getTime();
313
- * ```
314
- */
315
- setTime(time: number): Promise<void>;
316
- /**
317
- * Advance the time of the IC by the given duration in milliseconds.
318
- *
319
- * @param duration The duration to advance the time by.
320
- *
321
- * @example
322
- * ```ts
323
- * import { PocketIc } from '@hadronous/pic';
324
- *
325
- * const pic = await PocketIc.create();
326
- *
327
- * const initialTime = await pic.getTime();
328
- * await pic.advanceTime(1_000);
329
- * const newTime = await pic.getTime();
330
- * ```
331
- */
332
- advanceTime(duration: number): Promise<void>;
333
- /**
334
- * Fetch the root key of the IC.
335
- *
336
- * @returns The root key of the IC.
337
- *
338
- * @example
339
- * ```ts
340
- * import { PocketIc } from '@hadronous/pic';
341
- *
342
- * const pic = await PocketIc.create();
343
- * const rootKey = await pic.fetchRootKey();
344
- */
345
- fetchRootKey(): Promise<Uint8Array>;
346
- /**
347
- * Checks if the provided canister exists.
348
- *
349
- * @param canisterId The Principal of the canister to check.
350
- * @returns `true` if the canister exists, `false` otherwise.
351
- *
352
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
353
- *
354
- * @example
355
- * ```ts
356
- * import { PocketIc } from '@hadronous/pic';
357
- *
358
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
359
- *
360
- * const pic = await PocketIc.create();
361
- * const canisterExists = await pic.checkCanisterExists(canisterId);
362
- * ```
363
- */
364
- checkCanisterExists(canisterId: Principal): Promise<boolean>;
365
- /**
366
- * Gets the current cycle balance of the specified canister.
367
- *
368
- * @param canisterId The Principal of the canister to check.
369
- * @returns The current cycles balance of the canister.
370
- *
371
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
372
- *
373
- * @example
374
- * ```ts
375
- * import { Principal } from '@dfinity/principal';
376
- * import { PocketIc } from '@hadronous/pic';
377
- *
378
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
379
- *
380
- * const pic = await PocketIc.create();
381
- * const cyclesBalance = await pic.getCyclesBalance(canisterId);
382
- * ```
383
- */
384
- getCyclesBalance(canisterId: Principal): Promise<number>;
385
- /**
386
- * Add cycles to the specified canister.
387
- *
388
- * @param canisterId The Principal of the canister to add cycles to.
389
- * @param amount The amount of cycles to add.
390
- * @returns The new cycle balance of the canister.
391
- *
392
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
393
- *
394
- * @example
395
- * ```ts
396
- * import { Principal } from '@dfinity/principal';
397
- * import { PocketIc } from '@hadronous/pic';
398
- *
399
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
400
- *
401
- * const pic = await PocketIc.create();
402
- * const newCyclesBalance = await pic.addCycles(canisterId, 10_000_000);
403
- * ```
404
- */
405
- addCycles(canisterId: Principal, amount: number): Promise<number>;
406
- /**
407
- * Set the stable memory of a given canister.
408
- *
409
- * @param canisterId The Principal of the canister to set the stable memory of.
410
- * @param stableMemory A blob containing the stable memory to set.
411
- *
412
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
413
- *
414
- * @example
415
- * ```ts
416
- * import { Principal } from '@dfinity/principal';
417
- * import { PocketIc } from '@hadronous/pic';
418
- *
419
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
420
- * const stableMemory = new Uint8Array([0, 1, 2, 3, 4]);
421
- *
422
- * const pic = await PocketIc.create();
423
- * await pic.setStableMemory(canisterId, stableMemory);
424
- * ```
425
- */
426
- setStableMemory(canisterId: Principal, stableMemory: Uint8Array): Promise<void>;
427
- /**
428
- * Get the stable memory of a given canister.
429
- *
430
- * @param canisterId The Principal of the canister to get the stable memory of.
431
- * @returns A blob containing the canister's stable memory.
432
- *
433
- * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
434
- *
435
- * @example
436
- * ```ts
437
- * import { Principal } from '@dfinity/principal';
438
- * import { PocketIc } from '@hadronous/pic';
439
- *
440
- * const canisterId = Principal.fromUint8Array(new Uint8Array([0]));
441
- *
442
- * const pic = await PocketIc.create();
443
- * const stableMemory = await pic.getStableMemory(canisterId);
444
- * ```
445
- */
446
- getStableMemory(canisterId: Principal): Promise<Uint8Array>;
447
- }