@dfinity/pic 0.12.0-b0
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.
- package/README.md +73 -0
- package/dist/error.d.ts +21 -0
- package/dist/error.js +55 -0
- package/dist/error.js.map +1 -0
- package/dist/http2-client.d.ts +27 -0
- package/dist/http2-client.js +137 -0
- package/dist/http2-client.js.map +1 -0
- package/dist/identity.d.ts +74 -0
- package/dist/identity.js +94 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/management-canister.d.ts +45 -0
- package/dist/management-canister.js +71 -0
- package/dist/management-canister.js.map +1 -0
- package/dist/pocket-ic-actor.d.ts +85 -0
- package/dist/pocket-ic-actor.js +58 -0
- package/dist/pocket-ic-actor.js.map +1 -0
- package/dist/pocket-ic-client-types.d.ts +372 -0
- package/dist/pocket-ic-client-types.js +395 -0
- package/dist/pocket-ic-client-types.js.map +1 -0
- package/dist/pocket-ic-client.d.ts +31 -0
- package/dist/pocket-ic-client.js +152 -0
- package/dist/pocket-ic-client.js.map +1 -0
- package/dist/pocket-ic-deferred-actor.d.ts +67 -0
- package/dist/pocket-ic-deferred-actor.js +44 -0
- package/dist/pocket-ic-deferred-actor.js.map +1 -0
- package/dist/pocket-ic-server-types.d.ts +13 -0
- package/dist/pocket-ic-server-types.js +3 -0
- package/dist/pocket-ic-server-types.js.map +1 -0
- package/dist/pocket-ic-server.d.ts +53 -0
- package/dist/pocket-ic-server.js +126 -0
- package/dist/pocket-ic-server.js.map +1 -0
- package/dist/pocket-ic-types.d.ts +679 -0
- package/dist/pocket-ic-types.js +72 -0
- package/dist/pocket-ic-types.js.map +1 -0
- package/dist/pocket-ic.d.ts +972 -0
- package/dist/pocket-ic.js +1248 -0
- package/dist/pocket-ic.js.map +1 -0
- package/dist/util/candid.d.ts +3 -0
- package/dist/util/candid.js +21 -0
- package/dist/util/candid.js.map +1 -0
- package/dist/util/encoding.d.ts +6 -0
- package/dist/util/encoding.js +24 -0
- package/dist/util/encoding.js.map +1 -0
- package/dist/util/fs.d.ts +4 -0
- package/dist/util/fs.js +28 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/index.d.ts +6 -0
- package/dist/util/index.js +23 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/is-nil.d.ts +2 -0
- package/dist/util/is-nil.js +11 -0
- package/dist/util/is-nil.js.map +1 -0
- package/dist/util/os.d.ts +4 -0
- package/dist/util/os.js +19 -0
- package/dist/util/os.js.map +1 -0
- package/dist/util/poll.d.ts +5 -0
- package/dist/util/poll.js +23 -0
- package/dist/util/poll.js.map +1 -0
- package/package.json +40 -0
- package/postinstall.mjs +25 -0
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
import { Principal } from '@dfinity/principal';
|
|
2
|
+
import { ActorInterface, Actor } from './pocket-ic-actor';
|
|
3
|
+
import { IDL } from '@dfinity/candid';
|
|
4
|
+
/**
|
|
5
|
+
* Options for creating a PocketIc instance.
|
|
6
|
+
*/
|
|
7
|
+
export interface CreateInstanceOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for creating an NNS subnet.
|
|
10
|
+
* If no config is provided, the NNS subnet is not setup.
|
|
11
|
+
*/
|
|
12
|
+
nns?: NnsSubnetConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options for creating an SNS subnet.
|
|
15
|
+
* If no config is provided, the SNS subnet is not setup.
|
|
16
|
+
*/
|
|
17
|
+
sns?: SnsSubnetConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Configuration options for creating an II subnet.
|
|
20
|
+
* If no config is provided, the II subnet is not setup.
|
|
21
|
+
*/
|
|
22
|
+
ii?: IiSubnetConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Configuration options for creating a Fiduciary subnet.
|
|
25
|
+
* If no config is provided, the Fiduciary subnet is not setup.
|
|
26
|
+
*/
|
|
27
|
+
fiduciary?: FiduciarySubnetConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Configuration options for creating a Bitcoin subnet.
|
|
30
|
+
* If no config is provided, the Bitcoin subnet is not setup.
|
|
31
|
+
*/
|
|
32
|
+
bitcoin?: BitcoinSubnetConfig;
|
|
33
|
+
/**
|
|
34
|
+
* Configuration options for creating system subnets.
|
|
35
|
+
* A system subnet will be created for each configuration object provided.
|
|
36
|
+
* If no config objects are provided, no system subnets are setup.
|
|
37
|
+
*/
|
|
38
|
+
system?: SystemSubnetConfig[];
|
|
39
|
+
/**
|
|
40
|
+
* Configuration options for creating application subnets.
|
|
41
|
+
* An application subnet will be created for each configuration object provided.
|
|
42
|
+
* If no config objects are provided, no application subnets are setup.
|
|
43
|
+
*/
|
|
44
|
+
application?: ApplicationSubnetConfig[];
|
|
45
|
+
/**
|
|
46
|
+
* Configuration options for creating verified application subnets.
|
|
47
|
+
* A verified application subnet will be created for each configuration object provided.
|
|
48
|
+
* If no config objects are provided, no verified application subnets are setup.
|
|
49
|
+
*/
|
|
50
|
+
verifiedApplication?: VerifiedApplicationSubnetConfig[];
|
|
51
|
+
/**
|
|
52
|
+
* How long the PocketIC client should wait for a response from the server.
|
|
53
|
+
*/
|
|
54
|
+
processingTimeoutMs?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Determines if non-mainnet features (e.g., best-effort responses) should be
|
|
57
|
+
* enabled for the PocketIC instance. Defaults to `false`.
|
|
58
|
+
*/
|
|
59
|
+
nonmainnetFeatures?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Common options for creating a subnet.
|
|
63
|
+
*/
|
|
64
|
+
export interface SubnetConfig<T extends NewSubnetStateConfig | FromPathSubnetStateConfig = NewSubnetStateConfig | FromPathSubnetStateConfig> {
|
|
65
|
+
/**
|
|
66
|
+
* Whether to enable deterministic time slicing.
|
|
67
|
+
* Defaults to `true`.
|
|
68
|
+
*/
|
|
69
|
+
enableDeterministicTimeSlicing?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether to enable benchmarking instruction limits.
|
|
72
|
+
* Defaults to `false`.
|
|
73
|
+
*/
|
|
74
|
+
enableBenchmarkingInstructionLimits?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* The state configuration for the subnet.
|
|
77
|
+
*/
|
|
78
|
+
state: T;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Options for creating an NNS subnet.
|
|
82
|
+
*/
|
|
83
|
+
export type NnsSubnetConfig = SubnetConfig<NnsSubnetStateConfig>;
|
|
84
|
+
/**
|
|
85
|
+
* Options for an NNS subnet's state.
|
|
86
|
+
*/
|
|
87
|
+
export type NnsSubnetStateConfig = NewSubnetStateConfig | FromPathSubnetStateConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Options for creating an SNS subnet.
|
|
90
|
+
*/
|
|
91
|
+
export type SnsSubnetConfig = SubnetConfig<SnsSubnetStateConfig>;
|
|
92
|
+
/**
|
|
93
|
+
* Options for an SNS subnet's state.
|
|
94
|
+
*/
|
|
95
|
+
export type SnsSubnetStateConfig = NewSubnetStateConfig;
|
|
96
|
+
/**
|
|
97
|
+
* Options for creating an II subnet.
|
|
98
|
+
*/
|
|
99
|
+
export type IiSubnetConfig = SubnetConfig<IiSubnetStateConfig>;
|
|
100
|
+
/**
|
|
101
|
+
* Options for an II subnet's state.
|
|
102
|
+
*/
|
|
103
|
+
export type IiSubnetStateConfig = NewSubnetStateConfig;
|
|
104
|
+
/**
|
|
105
|
+
* Options for creating a Fiduciary subnet.
|
|
106
|
+
*/
|
|
107
|
+
export type FiduciarySubnetConfig = SubnetConfig<FiduciarySubnetStateConfig>;
|
|
108
|
+
/**
|
|
109
|
+
* Options for a Fiduciary subnet's state.
|
|
110
|
+
*/
|
|
111
|
+
export type FiduciarySubnetStateConfig = NewSubnetStateConfig;
|
|
112
|
+
/**
|
|
113
|
+
* Options for creating a Bitcoin subnet.
|
|
114
|
+
*/
|
|
115
|
+
export type BitcoinSubnetConfig = SubnetConfig<BitcoinSubnetStateConfig>;
|
|
116
|
+
/**
|
|
117
|
+
* Options for a Bitcoin subnet's state.
|
|
118
|
+
*/
|
|
119
|
+
export type BitcoinSubnetStateConfig = NewSubnetStateConfig;
|
|
120
|
+
/**
|
|
121
|
+
* Options for creating a system subnet.
|
|
122
|
+
*/
|
|
123
|
+
export type SystemSubnetConfig = SubnetConfig<SystemSubnetStateConfig>;
|
|
124
|
+
/**
|
|
125
|
+
* Options for a system subnet's state.
|
|
126
|
+
*/
|
|
127
|
+
export type SystemSubnetStateConfig = NewSubnetStateConfig;
|
|
128
|
+
/**
|
|
129
|
+
* Options for creating an application subnet.
|
|
130
|
+
*/
|
|
131
|
+
export type ApplicationSubnetConfig = SubnetConfig<ApplicationSubnetStateConfig>;
|
|
132
|
+
/**
|
|
133
|
+
* Options for an application subnet's state.
|
|
134
|
+
*/
|
|
135
|
+
export type ApplicationSubnetStateConfig = NewSubnetStateConfig;
|
|
136
|
+
/**
|
|
137
|
+
* Options for creating a verified application subnet.
|
|
138
|
+
*/
|
|
139
|
+
export type VerifiedApplicationSubnetConfig = SubnetConfig<VerifiedApplicationSubnetStateConfig>;
|
|
140
|
+
/**
|
|
141
|
+
* Options for a verified application subnet's state.
|
|
142
|
+
*/
|
|
143
|
+
export type VerifiedApplicationSubnetStateConfig = NewSubnetStateConfig;
|
|
144
|
+
/**
|
|
145
|
+
* Options for creating a new subnet an empty state.
|
|
146
|
+
*/
|
|
147
|
+
export interface NewSubnetStateConfig {
|
|
148
|
+
/**
|
|
149
|
+
* The type of subnet state to initialize the subnet with.
|
|
150
|
+
*/
|
|
151
|
+
type: SubnetStateType.New;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Options for creating a subnet from an existing state on the filesystem.
|
|
155
|
+
*/
|
|
156
|
+
export interface FromPathSubnetStateConfig {
|
|
157
|
+
/**
|
|
158
|
+
* The type of subnet state to initialize the subnet with.
|
|
159
|
+
*/
|
|
160
|
+
type: SubnetStateType.FromPath;
|
|
161
|
+
/**
|
|
162
|
+
* The path to the subnet state.
|
|
163
|
+
*
|
|
164
|
+
* This directory should have the following structure:
|
|
165
|
+
* ```text
|
|
166
|
+
* |-- backups/
|
|
167
|
+
* |-- checkpoints/
|
|
168
|
+
* |-- diverged_checkpoints/
|
|
169
|
+
* |-- diverged_state_markers/
|
|
170
|
+
* |-- fs_tmp/
|
|
171
|
+
* |-- page_deltas/
|
|
172
|
+
* |-- tip/
|
|
173
|
+
* |-- tmp/
|
|
174
|
+
* |-- states_metadata.pbuf
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
path: string;
|
|
178
|
+
/**
|
|
179
|
+
* The subnet ID to setup the subnet on.
|
|
180
|
+
*
|
|
181
|
+
* The value can be obtained, e.g., via the following command for an NNS subnet:
|
|
182
|
+
* ```bash
|
|
183
|
+
* ic-regedit snapshot <path-to-ic_registry_local_store> | jq -r ".nns_subnet_id"
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
subnetId: Principal;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The type of state to initialize a subnet with.
|
|
190
|
+
*/
|
|
191
|
+
export declare enum SubnetStateType {
|
|
192
|
+
/**
|
|
193
|
+
* Create a new subnet with an empty state.
|
|
194
|
+
*/
|
|
195
|
+
New = "new",
|
|
196
|
+
/**
|
|
197
|
+
* Load existing subnet state from the given path.
|
|
198
|
+
* The path must be on a filesystem accessible by the PocketIC server.
|
|
199
|
+
*/
|
|
200
|
+
FromPath = "fromPath"
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The topology of a subnet.
|
|
204
|
+
*/
|
|
205
|
+
export interface SubnetTopology {
|
|
206
|
+
/**
|
|
207
|
+
* The subnet ID.
|
|
208
|
+
*/
|
|
209
|
+
id: Principal;
|
|
210
|
+
/**
|
|
211
|
+
* The subnet type. See {@link SubnetType}.
|
|
212
|
+
*/
|
|
213
|
+
type: SubnetType;
|
|
214
|
+
/**
|
|
215
|
+
* The number of nodes in the subnet.
|
|
216
|
+
*/
|
|
217
|
+
size: number;
|
|
218
|
+
/**
|
|
219
|
+
* The range of canister IDs that can be deployed to the subnet.
|
|
220
|
+
*/
|
|
221
|
+
canisterRanges: Array<{
|
|
222
|
+
start: Principal;
|
|
223
|
+
end: Principal;
|
|
224
|
+
}>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The type of a subnet.
|
|
228
|
+
*/
|
|
229
|
+
export declare enum SubnetType {
|
|
230
|
+
/**
|
|
231
|
+
* The subnet is an application subnet.
|
|
232
|
+
*/
|
|
233
|
+
Application = "Application",
|
|
234
|
+
/**
|
|
235
|
+
* The subnet is a Bitcoin subnet.
|
|
236
|
+
*/
|
|
237
|
+
Bitcoin = "Bitcoin",
|
|
238
|
+
/**
|
|
239
|
+
* The subnet is a Fiduciary subnet.
|
|
240
|
+
*/
|
|
241
|
+
Fiduciary = "Fiduciary",
|
|
242
|
+
/**
|
|
243
|
+
* The subnet is an Internet Identity subnet.
|
|
244
|
+
*/
|
|
245
|
+
InternetIdentity = "II",
|
|
246
|
+
/**
|
|
247
|
+
* The subnet is a NNS subnet.
|
|
248
|
+
*/
|
|
249
|
+
NNS = "NNS",
|
|
250
|
+
/**
|
|
251
|
+
* The subnet is an SNS subnet.
|
|
252
|
+
*/
|
|
253
|
+
SNS = "SNS",
|
|
254
|
+
/**
|
|
255
|
+
* The subnet is a system subnet.
|
|
256
|
+
*/
|
|
257
|
+
System = "System"
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Options for setting up a canister.
|
|
261
|
+
*/
|
|
262
|
+
export interface SetupCanisterOptions extends CreateCanisterOptions {
|
|
263
|
+
/**
|
|
264
|
+
* The interface factory to use for the {@link Actor}.
|
|
265
|
+
*/
|
|
266
|
+
idlFactory: IDL.InterfaceFactory;
|
|
267
|
+
/**
|
|
268
|
+
* The WASM module to install to the canister.
|
|
269
|
+
* If a string is passed, it is treated as a path to a file.
|
|
270
|
+
* If an `ArrayBufferLike` is passed, it is treated as the WASM module itself.
|
|
271
|
+
*/
|
|
272
|
+
wasm: ArrayBufferLike | string;
|
|
273
|
+
/**
|
|
274
|
+
* Candid encoded argument to pass to the canister's init function.
|
|
275
|
+
* Defaults to an empty ArrayBuffer.
|
|
276
|
+
*/
|
|
277
|
+
arg?: ArrayBufferLike;
|
|
278
|
+
/**
|
|
279
|
+
* The principal to setup the canister as.
|
|
280
|
+
* Defaults to the anonymous principal.
|
|
281
|
+
*/
|
|
282
|
+
sender?: Principal;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* A canister testing fixture for PocketIC that provides essential testing primitives
|
|
286
|
+
* such as an {@link Actor} and CanisterId.
|
|
287
|
+
*
|
|
288
|
+
* @category Types
|
|
289
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
290
|
+
*/
|
|
291
|
+
export interface CanisterFixture<T extends ActorInterface<T> = ActorInterface> {
|
|
292
|
+
/**
|
|
293
|
+
* The {@link Actor} instance.
|
|
294
|
+
*/
|
|
295
|
+
actor: Actor<T>;
|
|
296
|
+
/**
|
|
297
|
+
* The Principal of the canister.
|
|
298
|
+
*/
|
|
299
|
+
canisterId: Principal;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Canister settings.
|
|
303
|
+
*
|
|
304
|
+
* @category Types
|
|
305
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
306
|
+
*/
|
|
307
|
+
export interface CanisterSettings {
|
|
308
|
+
/**
|
|
309
|
+
* The controllers of the canister.
|
|
310
|
+
* Defaults to the sender, which defaults to the anonymous principal.
|
|
311
|
+
*/
|
|
312
|
+
controllers?: Principal[];
|
|
313
|
+
/**
|
|
314
|
+
* The compute allocation of the canister.
|
|
315
|
+
*/
|
|
316
|
+
computeAllocation?: bigint;
|
|
317
|
+
/**
|
|
318
|
+
* The memory allocation of the canister.
|
|
319
|
+
*/
|
|
320
|
+
memoryAllocation?: bigint;
|
|
321
|
+
/**
|
|
322
|
+
* The freezing threshold of the canister.
|
|
323
|
+
*/
|
|
324
|
+
freezingThreshold?: bigint;
|
|
325
|
+
/**
|
|
326
|
+
* The reserved cycles limit of the canister.
|
|
327
|
+
*/
|
|
328
|
+
reservedCyclesLimit?: bigint;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Options for creating a canister.
|
|
332
|
+
*
|
|
333
|
+
* @category Types
|
|
334
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
335
|
+
*/
|
|
336
|
+
export interface CreateCanisterOptions extends CanisterSettings {
|
|
337
|
+
/**
|
|
338
|
+
* The amount of cycles to send to the canister.
|
|
339
|
+
* Defaults to 1_000_000_000_000_000_000n.
|
|
340
|
+
*/
|
|
341
|
+
cycles?: bigint;
|
|
342
|
+
/**
|
|
343
|
+
* The principal to create the canister as.
|
|
344
|
+
* Defaults to the anonymous principal.
|
|
345
|
+
*/
|
|
346
|
+
sender?: Principal;
|
|
347
|
+
/**
|
|
348
|
+
* The Id of the subnet to create the canister on.
|
|
349
|
+
*/
|
|
350
|
+
targetSubnetId?: Principal;
|
|
351
|
+
/**
|
|
352
|
+
* The Id of the canister to create.
|
|
353
|
+
* Can only be used on Bitcoin, Fiduciary, II, SNS and NNS subnets.
|
|
354
|
+
*/
|
|
355
|
+
targetCanisterId?: Principal;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Options for starting a given canister.
|
|
359
|
+
*
|
|
360
|
+
* @category Types
|
|
361
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
362
|
+
*/
|
|
363
|
+
export interface StartCanisterOptions {
|
|
364
|
+
/**
|
|
365
|
+
* The Principal of the canister to start.
|
|
366
|
+
*/
|
|
367
|
+
canisterId: Principal;
|
|
368
|
+
/**
|
|
369
|
+
* The Principal to send the request as.
|
|
370
|
+
* Defaults to the anonymous principal.
|
|
371
|
+
*/
|
|
372
|
+
sender?: Principal;
|
|
373
|
+
/**
|
|
374
|
+
* The ID of the subnet that the canister resides on.
|
|
375
|
+
*/
|
|
376
|
+
targetSubnetId?: Principal;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Options for stopping a given canister.
|
|
380
|
+
*
|
|
381
|
+
* @category Types
|
|
382
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
383
|
+
*/
|
|
384
|
+
export interface StopCanisterOptions {
|
|
385
|
+
/**
|
|
386
|
+
* The Principal of the canister to stop.
|
|
387
|
+
*/
|
|
388
|
+
canisterId: Principal;
|
|
389
|
+
/**
|
|
390
|
+
* The Principal to send the request as.
|
|
391
|
+
* Defaults to the anonymous principal.
|
|
392
|
+
*/
|
|
393
|
+
sender?: Principal;
|
|
394
|
+
/**
|
|
395
|
+
* The ID of the subnet that the canister resides on.
|
|
396
|
+
*/
|
|
397
|
+
targetSubnetId?: Principal;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Options for installing a WASM module to a given canister.
|
|
401
|
+
*
|
|
402
|
+
* @category Types
|
|
403
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
404
|
+
*/
|
|
405
|
+
export interface InstallCodeOptions {
|
|
406
|
+
/**
|
|
407
|
+
* The Principal of the canister to install the code to.
|
|
408
|
+
*/
|
|
409
|
+
canisterId: Principal;
|
|
410
|
+
/**
|
|
411
|
+
* The WASM module to install to the canister.
|
|
412
|
+
* If a string is passed, it is treated as a path to a file.
|
|
413
|
+
* If an `ArrayBufferLike` is passed, it is treated as the WASM module itself.
|
|
414
|
+
*/
|
|
415
|
+
wasm: ArrayBufferLike | string;
|
|
416
|
+
/**
|
|
417
|
+
* Candid encoded argument to pass to the canister's init function.
|
|
418
|
+
* Defaults to an empty ArrayBuffer.
|
|
419
|
+
*/
|
|
420
|
+
arg?: ArrayBufferLike;
|
|
421
|
+
/**
|
|
422
|
+
* The principal to install the code as.
|
|
423
|
+
* Defaults to the anonymous principal.
|
|
424
|
+
*/
|
|
425
|
+
sender?: Principal;
|
|
426
|
+
/**
|
|
427
|
+
* The ID of the subnet that the canister resides on.
|
|
428
|
+
*/
|
|
429
|
+
targetSubnetId?: Principal;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Options for reinstalling a WASM module to a given canister.
|
|
433
|
+
* This will reset both the canister's heap and its stable memory.
|
|
434
|
+
*
|
|
435
|
+
* @category Types
|
|
436
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
437
|
+
*/
|
|
438
|
+
export interface ReinstallCodeOptions {
|
|
439
|
+
/**
|
|
440
|
+
* The Principal of the canister to reinstall code to.
|
|
441
|
+
*/
|
|
442
|
+
canisterId: Principal;
|
|
443
|
+
/**
|
|
444
|
+
* The WASM module to install to the canister.
|
|
445
|
+
* If a string is passed, it is treated as a path to a file.
|
|
446
|
+
* If an `ArrayBufferLike` is passed, it is treated as the WASM module itself.
|
|
447
|
+
*/
|
|
448
|
+
wasm: ArrayBufferLike | string;
|
|
449
|
+
/**
|
|
450
|
+
* Candid encoded argument to pass to the canister's init function.
|
|
451
|
+
*/
|
|
452
|
+
arg?: ArrayBufferLike;
|
|
453
|
+
/**
|
|
454
|
+
* The Principal to send the request as.
|
|
455
|
+
* Defaults to the anonymous principal.
|
|
456
|
+
*/
|
|
457
|
+
sender?: Principal;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Options for upgrading a given canister with a WASM module.
|
|
461
|
+
* This will reset the canister's heap, but preserve stable memory.
|
|
462
|
+
*
|
|
463
|
+
* @category Types
|
|
464
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
465
|
+
*/
|
|
466
|
+
export interface UpgradeCanisterOptions {
|
|
467
|
+
/**
|
|
468
|
+
* The Principal of the canister to upgrade.
|
|
469
|
+
*/
|
|
470
|
+
canisterId: Principal;
|
|
471
|
+
/**
|
|
472
|
+
* The WASM module to install to the canister.
|
|
473
|
+
* If a string is passed, it is treated as a path to a file.
|
|
474
|
+
* If an `ArrayBufferLike` is passed, it is treated as the WASM module itself.
|
|
475
|
+
*/
|
|
476
|
+
wasm: ArrayBufferLike | string;
|
|
477
|
+
/**
|
|
478
|
+
* Candid encoded argument to pass to the canister's init function.
|
|
479
|
+
*/
|
|
480
|
+
arg?: ArrayBufferLike;
|
|
481
|
+
/**
|
|
482
|
+
* The Principal to send the request as.
|
|
483
|
+
* Defaults to the anonymous principal.
|
|
484
|
+
*/
|
|
485
|
+
sender?: Principal;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Options for updating the settings of a given canister.
|
|
489
|
+
*
|
|
490
|
+
* @category Types
|
|
491
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
492
|
+
*/
|
|
493
|
+
export interface UpdateCanisterSettingsOptions extends Partial<CanisterSettings> {
|
|
494
|
+
/**
|
|
495
|
+
* The Principal of the canister to update the settings for.
|
|
496
|
+
*/
|
|
497
|
+
canisterId: Principal;
|
|
498
|
+
/**
|
|
499
|
+
* The Principal to send the request as.
|
|
500
|
+
* Defaults to the anonymous principal.
|
|
501
|
+
*/
|
|
502
|
+
sender?: Principal;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Options for making a query call to a given canister.
|
|
506
|
+
*
|
|
507
|
+
* @category Types
|
|
508
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
509
|
+
*/
|
|
510
|
+
export interface QueryCallOptions {
|
|
511
|
+
/**
|
|
512
|
+
* The Principal to send the request as.
|
|
513
|
+
* Defaults to the anonymous principal.
|
|
514
|
+
*/
|
|
515
|
+
sender?: Principal;
|
|
516
|
+
/**
|
|
517
|
+
* The Principal of the canister to query.
|
|
518
|
+
*/
|
|
519
|
+
canisterId: Principal;
|
|
520
|
+
/**
|
|
521
|
+
* The method to call on the canister.
|
|
522
|
+
*/
|
|
523
|
+
method: string;
|
|
524
|
+
/**
|
|
525
|
+
* A Candid encoded argument to pass to the canister's method.
|
|
526
|
+
* Defaults to an empty ArrayBuffer.
|
|
527
|
+
*/
|
|
528
|
+
arg?: ArrayBufferLike;
|
|
529
|
+
/**
|
|
530
|
+
* The ID of the subnet that the canister resides on.
|
|
531
|
+
*/
|
|
532
|
+
targetSubnetId?: Principal;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Options for making an update call to a given canister.
|
|
536
|
+
*
|
|
537
|
+
* @category Types
|
|
538
|
+
* @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
|
|
539
|
+
*/
|
|
540
|
+
export interface UpdateCallOptions {
|
|
541
|
+
/**
|
|
542
|
+
* The Principal to send the request as.
|
|
543
|
+
* Defaults to the anonymous principal.
|
|
544
|
+
*/
|
|
545
|
+
sender?: Principal;
|
|
546
|
+
/**
|
|
547
|
+
* The Principal of the canister to update.
|
|
548
|
+
*/
|
|
549
|
+
canisterId: Principal;
|
|
550
|
+
/**
|
|
551
|
+
* The method to call on the canister.
|
|
552
|
+
*/
|
|
553
|
+
method: string;
|
|
554
|
+
/**
|
|
555
|
+
* A Candid encoded argument to pass to the canister's method.
|
|
556
|
+
* Defaults to an empty ArrayBuffer.
|
|
557
|
+
*/
|
|
558
|
+
arg?: ArrayBufferLike;
|
|
559
|
+
/**
|
|
560
|
+
* The ID of the subnet that the canister resides on.
|
|
561
|
+
*/
|
|
562
|
+
targetSubnetId?: Principal;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* A pending HTTPS outcall.
|
|
566
|
+
*/
|
|
567
|
+
export interface PendingHttpsOutcall {
|
|
568
|
+
/**
|
|
569
|
+
* The subnet ID to that the HTTPS Outcall is being sent from.
|
|
570
|
+
*/
|
|
571
|
+
subnetId: Principal;
|
|
572
|
+
/**
|
|
573
|
+
* The HTTPS Outcall request Id. Use this Id when setting a mock response
|
|
574
|
+
* for this request.
|
|
575
|
+
*/
|
|
576
|
+
requestId: number;
|
|
577
|
+
/**
|
|
578
|
+
* The HTTP method used for this request.
|
|
579
|
+
*/
|
|
580
|
+
httpMethod: CanisterHttpMethod;
|
|
581
|
+
/**
|
|
582
|
+
* The target URL of the pending request.
|
|
583
|
+
*/
|
|
584
|
+
url: string;
|
|
585
|
+
/**
|
|
586
|
+
* The headers of the pending request.
|
|
587
|
+
*/
|
|
588
|
+
headers: CanisterHttpHeader[];
|
|
589
|
+
/**
|
|
590
|
+
* The body of the pending request.
|
|
591
|
+
*/
|
|
592
|
+
body: Uint8Array;
|
|
593
|
+
/**
|
|
594
|
+
* The maximum number of bytes expected in the response body that was set
|
|
595
|
+
* by the canister making the request.
|
|
596
|
+
*/
|
|
597
|
+
maxResponseBytes?: number;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* The HTTP method used for an HTTPS outcall.
|
|
601
|
+
*/
|
|
602
|
+
export declare enum CanisterHttpMethod {
|
|
603
|
+
/**
|
|
604
|
+
* A GET request.
|
|
605
|
+
*/
|
|
606
|
+
GET = "GET",
|
|
607
|
+
/**
|
|
608
|
+
* A POST request.
|
|
609
|
+
*/
|
|
610
|
+
POST = "POST",
|
|
611
|
+
/**
|
|
612
|
+
* A HEAD request.
|
|
613
|
+
*/
|
|
614
|
+
HEAD = "HEAD"
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* An HTTP header for an HTTPS outcall.
|
|
618
|
+
*/
|
|
619
|
+
export type CanisterHttpHeader = [string, string];
|
|
620
|
+
/**
|
|
621
|
+
* Options for mocking a response to a pending HTTPS outcall.
|
|
622
|
+
*/
|
|
623
|
+
export interface MockPendingHttpsOutcallOptions {
|
|
624
|
+
/**
|
|
625
|
+
* The subnet ID to that the HTTPS Outcall is being sent from.
|
|
626
|
+
*/
|
|
627
|
+
subnetId: Principal;
|
|
628
|
+
/**
|
|
629
|
+
* The HTTPS Outcall request Id to mock a response for.
|
|
630
|
+
*/
|
|
631
|
+
requestId: number;
|
|
632
|
+
/**
|
|
633
|
+
* The response to mock for the pending HTTPS outcall.
|
|
634
|
+
*/
|
|
635
|
+
response: HttpsOutcallResponseMock;
|
|
636
|
+
/**
|
|
637
|
+
* Additional responses to mock for the pending HTTPS outcall.
|
|
638
|
+
*
|
|
639
|
+
* If non-empty, the total number of responses (one plus the number of additional responses)
|
|
640
|
+
* must be equal to the size of the subnet on which the canister making the HTTP outcall is deployed.
|
|
641
|
+
*/
|
|
642
|
+
additionalResponses?: HttpsOutcallResponseMock[];
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* An HTTPS Outcall response mock.
|
|
646
|
+
*/
|
|
647
|
+
export type HttpsOutcallResponseMock = HttpsOutcallSuccessResponse | HttpsOutcallRejectResponse;
|
|
648
|
+
export interface HttpsOutcallSuccessResponse {
|
|
649
|
+
/**
|
|
650
|
+
* The type of the response, either `'success'` or `'response'`.
|
|
651
|
+
*/
|
|
652
|
+
type: 'success';
|
|
653
|
+
/**
|
|
654
|
+
* The status code of the response.
|
|
655
|
+
*/
|
|
656
|
+
statusCode: number;
|
|
657
|
+
/**
|
|
658
|
+
* The headers of the response.
|
|
659
|
+
*/
|
|
660
|
+
headers: CanisterHttpHeader[];
|
|
661
|
+
/**
|
|
662
|
+
* The body of the response.
|
|
663
|
+
*/
|
|
664
|
+
body: Uint8Array;
|
|
665
|
+
}
|
|
666
|
+
export interface HttpsOutcallRejectResponse {
|
|
667
|
+
/**
|
|
668
|
+
* The type of the response, either `'reject'` or `'response'`.
|
|
669
|
+
*/
|
|
670
|
+
type: 'reject';
|
|
671
|
+
/**
|
|
672
|
+
* The status code of the response.
|
|
673
|
+
*/
|
|
674
|
+
statusCode: number;
|
|
675
|
+
/**
|
|
676
|
+
* The message of the response.
|
|
677
|
+
*/
|
|
678
|
+
message: string;
|
|
679
|
+
}
|