@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.
Files changed (63) hide show
  1. package/README.md +73 -0
  2. package/dist/error.d.ts +21 -0
  3. package/dist/error.js +55 -0
  4. package/dist/error.js.map +1 -0
  5. package/dist/http2-client.d.ts +27 -0
  6. package/dist/http2-client.js +137 -0
  7. package/dist/http2-client.js.map +1 -0
  8. package/dist/identity.d.ts +74 -0
  9. package/dist/identity.js +94 -0
  10. package/dist/identity.js.map +1 -0
  11. package/dist/index.d.ts +7 -0
  12. package/dist/index.js +24 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/management-canister.d.ts +45 -0
  15. package/dist/management-canister.js +71 -0
  16. package/dist/management-canister.js.map +1 -0
  17. package/dist/pocket-ic-actor.d.ts +85 -0
  18. package/dist/pocket-ic-actor.js +58 -0
  19. package/dist/pocket-ic-actor.js.map +1 -0
  20. package/dist/pocket-ic-client-types.d.ts +372 -0
  21. package/dist/pocket-ic-client-types.js +395 -0
  22. package/dist/pocket-ic-client-types.js.map +1 -0
  23. package/dist/pocket-ic-client.d.ts +31 -0
  24. package/dist/pocket-ic-client.js +152 -0
  25. package/dist/pocket-ic-client.js.map +1 -0
  26. package/dist/pocket-ic-deferred-actor.d.ts +67 -0
  27. package/dist/pocket-ic-deferred-actor.js +44 -0
  28. package/dist/pocket-ic-deferred-actor.js.map +1 -0
  29. package/dist/pocket-ic-server-types.d.ts +13 -0
  30. package/dist/pocket-ic-server-types.js +3 -0
  31. package/dist/pocket-ic-server-types.js.map +1 -0
  32. package/dist/pocket-ic-server.d.ts +53 -0
  33. package/dist/pocket-ic-server.js +126 -0
  34. package/dist/pocket-ic-server.js.map +1 -0
  35. package/dist/pocket-ic-types.d.ts +679 -0
  36. package/dist/pocket-ic-types.js +72 -0
  37. package/dist/pocket-ic-types.js.map +1 -0
  38. package/dist/pocket-ic.d.ts +972 -0
  39. package/dist/pocket-ic.js +1248 -0
  40. package/dist/pocket-ic.js.map +1 -0
  41. package/dist/util/candid.d.ts +3 -0
  42. package/dist/util/candid.js +21 -0
  43. package/dist/util/candid.js.map +1 -0
  44. package/dist/util/encoding.d.ts +6 -0
  45. package/dist/util/encoding.js +24 -0
  46. package/dist/util/encoding.js.map +1 -0
  47. package/dist/util/fs.d.ts +4 -0
  48. package/dist/util/fs.js +28 -0
  49. package/dist/util/fs.js.map +1 -0
  50. package/dist/util/index.d.ts +6 -0
  51. package/dist/util/index.js +23 -0
  52. package/dist/util/index.js.map +1 -0
  53. package/dist/util/is-nil.d.ts +2 -0
  54. package/dist/util/is-nil.js +11 -0
  55. package/dist/util/is-nil.js.map +1 -0
  56. package/dist/util/os.d.ts +4 -0
  57. package/dist/util/os.js +19 -0
  58. package/dist/util/os.js.map +1 -0
  59. package/dist/util/poll.d.ts +5 -0
  60. package/dist/util/poll.js +23 -0
  61. package/dist/util/poll.js.map +1 -0
  62. package/package.json +40 -0
  63. package/postinstall.mjs +25 -0
@@ -0,0 +1,85 @@
1
+ import { IDL } from '@dfinity/candid';
2
+ import { Principal } from '@dfinity/principal';
3
+ import { Identity } from '@dfinity/agent';
4
+ import { PocketIcClient } from './pocket-ic-client';
5
+ /**
6
+ * Typesafe method of a canister.
7
+ *
8
+ * @category Types
9
+ */
10
+ export interface ActorMethod<Args extends any[] = any[], Ret = any> {
11
+ (...args: Args): Promise<Ret>;
12
+ }
13
+ /**
14
+ * Candid interface of a canister.
15
+ *
16
+ * @category Types
17
+ */
18
+ export type ActorInterface<T = object> = {
19
+ [K in keyof T]: ActorMethod;
20
+ };
21
+ /**
22
+ * A typesafe class that implements the Candid interface of a canister.
23
+ * This is acquired by calling {@link PocketIc.setupCanister | setupCanister}
24
+ * or {@link PocketIc.createActor | createActor}.
25
+ *
26
+ * @category API
27
+ * @typeparam T The type of the {@link Actor}. Must implement {@link ActorInterface}.
28
+ * @interface
29
+ */
30
+ export type Actor<T extends ActorInterface<T> = ActorInterface> = T & {
31
+ /**
32
+ * @ignore
33
+ */
34
+ new (): Actor<T>;
35
+ /**
36
+ * Set a Principal to be used as sender for all calls to the canister.
37
+ *
38
+ * @param principal The Principal to set.
39
+ *
40
+ * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { PocketIc } from '@dfinity/pic';
45
+ * import { Principal } from '@dfinity/principal';
46
+ * import { _SERVICE, idlFactory } from '../declarations';
47
+ *
48
+ * const wasmPath = resolve('..', '..', 'canister.wasm');
49
+ *
50
+ * const pic = await PocketIc.create();
51
+ * const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
52
+ * const { actor } = fixture;
53
+ *
54
+ * actor.setPrincipal(Principal.anonymous());
55
+ * ```
56
+ */
57
+ setPrincipal(principal: Principal): void;
58
+ /**
59
+ * Set a Principal to be used as sender for all calls to the canister.
60
+ * This is a convenience method over {@link setPrincipal} that accepts an
61
+ * Identity and internally extracts the Principal.
62
+ *
63
+ * @param identity The identity to set.
64
+ *
65
+ * @see [Identity](https://agent-js.icp.xyz/agent/interfaces/Identity.html)
66
+ * @see [Principal](https://agent-js.icp.xyz/principal/classes/Principal.html)
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * import { PocketIc } from '@dfinity/pic';
71
+ * import { AnonymousIdentity } from '@dfinity/agent';
72
+ * import { _SERVICE, idlFactory } from '../declarations';
73
+ *
74
+ * const wasmPath = resolve('..', '..', 'canister.wasm');
75
+ *
76
+ * const pic = await PocketIc.create();
77
+ * const fixture = await pic.setupCanister<_SERVICE>(idlFactory, wasmPath);
78
+ * const { actor } = fixture;
79
+ *
80
+ * actor.setIdentity(new AnonymousIdentity());
81
+ * ```
82
+ */
83
+ setIdentity(identity: Identity): void;
84
+ };
85
+ export declare function createActorClass<T extends ActorInterface<T> = ActorInterface>(interfaceFactory: IDL.InterfaceFactory, canisterId: Principal, pocketIcClient: PocketIcClient): Actor<T>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createActorClass = createActorClass;
4
+ const candid_1 = require("@dfinity/candid");
5
+ const principal_1 = require("@dfinity/principal");
6
+ const util_1 = require("./util");
7
+ function createActorClass(interfaceFactory, canisterId, pocketIcClient) {
8
+ const service = interfaceFactory({ IDL: candid_1.IDL });
9
+ let sender = null;
10
+ function createActorMethod(methodName, func) {
11
+ if (func.annotations.includes('query') ||
12
+ func.annotations.includes('composite_query')) {
13
+ return createQueryMethod(methodName, func);
14
+ }
15
+ return createCallMethod(methodName, func);
16
+ }
17
+ function getSender() {
18
+ return sender ?? principal_1.Principal.anonymous();
19
+ }
20
+ function createQueryMethod(method, func) {
21
+ return async function (...args) {
22
+ const arg = candid_1.IDL.encode(func.argTypes, args);
23
+ const sender = getSender();
24
+ const res = await pocketIcClient.queryCall({
25
+ canisterId,
26
+ sender,
27
+ method,
28
+ payload: new Uint8Array(arg),
29
+ });
30
+ return (0, util_1.decodeCandid)(func.retTypes, res.body);
31
+ };
32
+ }
33
+ function createCallMethod(method, func) {
34
+ return async function (...args) {
35
+ const arg = candid_1.IDL.encode(func.argTypes, args);
36
+ const sender = getSender();
37
+ const res = await pocketIcClient.updateCall({
38
+ canisterId,
39
+ sender,
40
+ method,
41
+ payload: new Uint8Array(arg),
42
+ });
43
+ return (0, util_1.decodeCandid)(func.retTypes, res.body);
44
+ };
45
+ }
46
+ function Actor() { }
47
+ Actor.prototype.setPrincipal = function (newSender) {
48
+ sender = newSender;
49
+ };
50
+ Actor.prototype.setIdentity = function (identity) {
51
+ sender = identity.getPrincipal();
52
+ };
53
+ service._fields.forEach(([methodName, func]) => {
54
+ Actor.prototype[methodName] = createActorMethod(methodName, func);
55
+ });
56
+ return Actor;
57
+ }
58
+ //# sourceMappingURL=pocket-ic-actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pocket-ic-actor.js","sourceRoot":"","sources":["../src/pocket-ic-actor.ts"],"names":[],"mappings":";;AAyFA,4CAyEC;AAlKD,4CAAsC;AACtC,kDAA+C;AAG/C,iCAAsC;AAqFtC,SAAgB,gBAAgB,CAC9B,gBAAsC,EACtC,UAAqB,EACrB,cAA8B;IAE9B,MAAM,OAAO,GAAG,gBAAgB,CAAC,EAAE,GAAG,EAAH,YAAG,EAAE,CAAC,CAAC;IAC1C,IAAI,MAAM,GAAqB,IAAI,CAAC;IAEpC,SAAS,iBAAiB,CACxB,UAAkB,EAClB,IAAmB;QAEnB,IACE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;YAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAC5C,CAAC;YACD,OAAO,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS,SAAS;QAChB,OAAO,MAAM,IAAI,qBAAS,CAAC,SAAS,EAAE,CAAC;IACzC,CAAC;IAED,SAAS,iBAAiB,CAAC,MAAc,EAAE,IAAmB;QAC5D,OAAO,KAAK,WAAW,GAAG,IAAI;YAC5B,MAAM,GAAG,GAAG,YAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAE3B,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,SAAS,CAAC;gBACzC,UAAU;gBACV,MAAM;gBACN,MAAM;gBACN,OAAO,EAAE,IAAI,UAAU,CAAC,GAAG,CAAC;aAC7B,CAAC,CAAC;YAEH,OAAO,IAAA,mBAAY,EAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC;IACJ,CAAC;IAED,SAAS,gBAAgB,CAAC,MAAc,EAAE,IAAmB;QAC3D,OAAO,KAAK,WAAW,GAAG,IAAI;YAC5B,MAAM,GAAG,GAAG,YAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAE3B,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC;gBAC1C,UAAU;gBACV,MAAM;gBACN,MAAM;gBACN,OAAO,EAAE,IAAI,UAAU,CAAC,GAAG,CAAC;aAC7B,CAAC,CAAC;YAEH,OAAO,IAAA,mBAAY,EAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC;IACJ,CAAC;IAED,SAAS,KAAK,KAAI,CAAC;IAEnB,KAAK,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,SAAoB;QAC3D,MAAM,GAAG,SAAS,CAAC;IACrB,CAAC,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,QAAkB;QACxD,MAAM,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC,CAAC;IAEF,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QAC7C,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,OAAO,KAA0B,CAAC;AACpC,CAAC"}
@@ -0,0 +1,372 @@
1
+ import { Principal } from '@dfinity/principal';
2
+ export interface CreateInstanceRequest {
3
+ nns?: NnsSubnetConfig;
4
+ sns?: SnsSubnetConfig;
5
+ ii?: IiSubnetConfig;
6
+ fiduciary?: FiduciarySubnetConfig;
7
+ bitcoin?: BitcoinSubnetConfig;
8
+ system?: SystemSubnetConfig[];
9
+ application?: ApplicationSubnetConfig[];
10
+ verifiedApplication?: VerifiedApplicationSubnetConfig[];
11
+ processingTimeoutMs?: number;
12
+ nonmainnetFeatures?: boolean;
13
+ }
14
+ export interface SubnetConfig<T extends NewSubnetStateConfig | FromPathSubnetStateConfig = NewSubnetStateConfig | FromPathSubnetStateConfig> {
15
+ enableDeterministicTimeSlicing?: boolean;
16
+ enableBenchmarkingInstructionLimits?: boolean;
17
+ state: T;
18
+ }
19
+ export type NnsSubnetConfig = SubnetConfig<NnsSubnetStateConfig>;
20
+ export type NnsSubnetStateConfig = NewSubnetStateConfig | FromPathSubnetStateConfig;
21
+ export type SnsSubnetConfig = SubnetConfig<SnsSubnetStateConfig>;
22
+ export type SnsSubnetStateConfig = NewSubnetStateConfig;
23
+ export type IiSubnetConfig = SubnetConfig<IiSubnetStateConfig>;
24
+ export type IiSubnetStateConfig = NewSubnetStateConfig;
25
+ export type FiduciarySubnetConfig = SubnetConfig<FiduciarySubnetStateConfig>;
26
+ export type FiduciarySubnetStateConfig = NewSubnetStateConfig;
27
+ export type BitcoinSubnetConfig = SubnetConfig<BitcoinSubnetStateConfig>;
28
+ export type BitcoinSubnetStateConfig = NewSubnetStateConfig;
29
+ export type SystemSubnetConfig = SubnetConfig<SystemSubnetStateConfig>;
30
+ export type SystemSubnetStateConfig = NewSubnetStateConfig;
31
+ export type ApplicationSubnetConfig = SubnetConfig<ApplicationSubnetStateConfig>;
32
+ export type ApplicationSubnetStateConfig = NewSubnetStateConfig;
33
+ export type VerifiedApplicationSubnetConfig = SubnetConfig<VerifiedApplicationSubnetStateConfig>;
34
+ export type VerifiedApplicationSubnetStateConfig = NewSubnetStateConfig;
35
+ export interface NewSubnetStateConfig {
36
+ type: SubnetStateType.New;
37
+ }
38
+ export interface FromPathSubnetStateConfig {
39
+ type: SubnetStateType.FromPath;
40
+ path: string;
41
+ subnetId: Principal;
42
+ }
43
+ export declare enum SubnetStateType {
44
+ New = "new",
45
+ FromPath = "fromPath"
46
+ }
47
+ export interface EncodedCreateInstanceRequest {
48
+ subnet_config_set: EncodedCreateInstanceSubnetConfig;
49
+ nonmainnet_features: boolean;
50
+ }
51
+ export interface EncodedCreateInstanceSubnetConfig {
52
+ nns?: EncodedSubnetConfig;
53
+ sns?: EncodedSubnetConfig;
54
+ ii?: EncodedSubnetConfig;
55
+ fiduciary?: EncodedSubnetConfig;
56
+ bitcoin?: EncodedSubnetConfig;
57
+ system: EncodedSubnetConfig[];
58
+ application: EncodedSubnetConfig[];
59
+ verified_application: EncodedSubnetConfig[];
60
+ }
61
+ export interface EncodedSubnetConfig {
62
+ dts_flag: 'Enabled' | 'Disabled';
63
+ instruction_config: 'Production' | 'Benchmarking';
64
+ state_config: 'New' | {
65
+ FromPath: [string, {
66
+ subnet_id: string;
67
+ }];
68
+ };
69
+ }
70
+ export declare function encodeCreateInstanceRequest(req?: CreateInstanceRequest): EncodedCreateInstanceRequest;
71
+ export interface GetPubKeyRequest {
72
+ subnetId: Principal;
73
+ }
74
+ export interface EncodedGetPubKeyRequest {
75
+ subnet_id: string;
76
+ }
77
+ export declare function encodeGetPubKeyRequest(req: GetPubKeyRequest): EncodedGetPubKeyRequest;
78
+ export type InstanceTopology = Record<string, SubnetTopology>;
79
+ export interface SubnetTopology {
80
+ id: Principal;
81
+ type: SubnetType;
82
+ size: number;
83
+ canisterRanges: Array<{
84
+ start: Principal;
85
+ end: Principal;
86
+ }>;
87
+ }
88
+ export declare enum SubnetType {
89
+ Application = "Application",
90
+ Bitcoin = "Bitcoin",
91
+ Fiduciary = "Fiduciary",
92
+ InternetIdentity = "II",
93
+ NNS = "NNS",
94
+ SNS = "SNS",
95
+ System = "System"
96
+ }
97
+ export interface EncodedGetTopologyResponse {
98
+ subnet_configs: Record<string, EncodedSubnetTopology>;
99
+ default_effective_canister_id: {
100
+ canister_id: string;
101
+ };
102
+ }
103
+ export interface EncodedSubnetTopology {
104
+ subnet_kind: EncodedSubnetKind;
105
+ size: number;
106
+ canister_ranges: Array<{
107
+ start: {
108
+ canister_id: string;
109
+ };
110
+ end: {
111
+ canister_id: string;
112
+ };
113
+ }>;
114
+ }
115
+ export type EncodedSubnetKind = 'Application' | 'Bitcoin' | 'Fiduciary' | 'II' | 'NNS' | 'SNS' | 'System';
116
+ export declare function decodeGetTopologyResponse(encoded: EncodedGetTopologyResponse): InstanceTopology;
117
+ export declare function decodeSubnetTopology(subnetId: string, encoded: EncodedSubnetTopology): SubnetTopology;
118
+ export declare function decodeSubnetKind(kind: EncodedSubnetKind): SubnetType;
119
+ export interface CreateInstanceSuccessResponse {
120
+ Created: {
121
+ instance_id: number;
122
+ topology: EncodedGetTopologyResponse;
123
+ };
124
+ }
125
+ export interface CreateInstanceErrorResponse {
126
+ Error: {
127
+ message: string;
128
+ };
129
+ }
130
+ export type CreateInstanceResponse = CreateInstanceSuccessResponse | CreateInstanceErrorResponse;
131
+ export interface GetControllersRequest {
132
+ canisterId: Principal;
133
+ }
134
+ export interface EncodedGetControllersRequest {
135
+ canister_id: string;
136
+ }
137
+ export declare function encodeGetControllersRequest(req: GetControllersRequest): EncodedGetControllersRequest;
138
+ export type GetControllersResponse = Principal[];
139
+ export type EncodedGetControllersResponse = {
140
+ principal_id: string;
141
+ }[];
142
+ export declare function decodeGetControllersResponse(res: EncodedGetControllersResponse): GetControllersResponse;
143
+ export interface GetTimeResponse {
144
+ millisSinceEpoch: number;
145
+ }
146
+ export interface EncodedGetTimeResponse {
147
+ nanos_since_epoch: number;
148
+ }
149
+ export declare function decodeGetTimeResponse(res: EncodedGetTimeResponse): GetTimeResponse;
150
+ export interface SetTimeRequest {
151
+ millisSinceEpoch: number;
152
+ }
153
+ export interface EncodedSetTimeRequest {
154
+ nanos_since_epoch: number;
155
+ }
156
+ export declare function encodeSetTimeRequest(req: SetTimeRequest): EncodedSetTimeRequest;
157
+ export interface GetSubnetIdRequest {
158
+ canisterId: Principal;
159
+ }
160
+ export interface EncodedGetSubnetIdRequest {
161
+ canister_id: string;
162
+ }
163
+ export declare function encodeGetSubnetIdRequest(req: GetSubnetIdRequest): EncodedGetSubnetIdRequest;
164
+ export type GetSubnetIdResponse = {
165
+ subnetId: Principal | null;
166
+ };
167
+ export type EncodedGetSubnetIdResponse = {
168
+ subnet_id: string;
169
+ } | {};
170
+ export declare function decodeGetSubnetIdResponse(res: EncodedGetSubnetIdResponse): GetSubnetIdResponse;
171
+ export interface GetCyclesBalanceRequest {
172
+ canisterId: Principal;
173
+ }
174
+ export interface EncodedGetCyclesBalanceRequest {
175
+ canister_id: string;
176
+ }
177
+ export declare function encodeGetCyclesBalanceRequest(req: GetCyclesBalanceRequest): EncodedGetCyclesBalanceRequest;
178
+ export interface EncodedGetCyclesBalanceResponse {
179
+ cycles: number;
180
+ }
181
+ export interface GetCyclesBalanceResponse {
182
+ cycles: number;
183
+ }
184
+ export declare function decodeGetCyclesBalanceResponse(res: EncodedGetCyclesBalanceResponse): GetCyclesBalanceResponse;
185
+ export interface AddCyclesRequest {
186
+ canisterId: Principal;
187
+ amount: number;
188
+ }
189
+ export interface EncodedAddCyclesRequest {
190
+ canister_id: string;
191
+ amount: number;
192
+ }
193
+ export declare function encodeAddCyclesRequest(req: AddCyclesRequest): EncodedAddCyclesRequest;
194
+ export interface AddCyclesResponse {
195
+ cycles: number;
196
+ }
197
+ export interface EncodedAddCyclesResponse {
198
+ cycles: number;
199
+ }
200
+ export declare function decodeAddCyclesResponse(res: EncodedAddCyclesResponse): AddCyclesResponse;
201
+ export interface UploadBlobRequest {
202
+ blob: Uint8Array;
203
+ }
204
+ export type EncodedUploadBlobRequest = Uint8Array;
205
+ export declare function encodeUploadBlobRequest(req: UploadBlobRequest): EncodedUploadBlobRequest;
206
+ export interface UploadBlobResponse {
207
+ blobId: Uint8Array;
208
+ }
209
+ export type EncodedUploadBlobResponse = string;
210
+ export declare function decodeUploadBlobResponse(res: EncodedUploadBlobResponse): UploadBlobResponse;
211
+ export interface SetStableMemoryRequest {
212
+ canisterId: Principal;
213
+ blobId: Uint8Array;
214
+ }
215
+ export interface EncodedSetStableMemoryRequest {
216
+ canister_id: string;
217
+ blob_id: string;
218
+ }
219
+ export declare function encodeSetStableMemoryRequest(req: SetStableMemoryRequest): EncodedSetStableMemoryRequest;
220
+ export interface GetStableMemoryRequest {
221
+ canisterId: Principal;
222
+ }
223
+ export interface EncodedGetStableMemoryRequest {
224
+ canister_id: string;
225
+ }
226
+ export declare function encodeGetStableMemoryRequest(req: GetStableMemoryRequest): EncodedGetStableMemoryRequest;
227
+ export interface GetStableMemoryResponse {
228
+ blob: Uint8Array;
229
+ }
230
+ export interface EncodedGetStableMemoryResponse {
231
+ blob: string;
232
+ }
233
+ export declare function decodeGetStableMemoryResponse(res: EncodedGetStableMemoryResponse): GetStableMemoryResponse;
234
+ export interface GetPendingHttpsOutcallsResponse {
235
+ subnetId: Principal;
236
+ requestId: number;
237
+ httpMethod: CanisterHttpMethod;
238
+ url: string;
239
+ headers: CanisterHttpHeader[];
240
+ body: Uint8Array;
241
+ maxResponseBytes?: number;
242
+ }
243
+ export declare enum CanisterHttpMethod {
244
+ GET = "GET",
245
+ POST = "POST",
246
+ HEAD = "HEAD"
247
+ }
248
+ export type CanisterHttpHeader = [string, string];
249
+ export interface EncodedGetPendingHttpsOutcallsResponse {
250
+ subnet_id: {
251
+ subnet_id: string;
252
+ };
253
+ request_id: number;
254
+ http_method: EncodedCanisterHttpMethod;
255
+ url: string;
256
+ headers: EncodedCanisterHttpHeader[];
257
+ body: string;
258
+ max_response_bytes?: number;
259
+ }
260
+ export declare enum EncodedCanisterHttpMethod {
261
+ GET = "GET",
262
+ POST = "POST",
263
+ HEAD = "HEAD"
264
+ }
265
+ export interface EncodedCanisterHttpHeader {
266
+ name: string;
267
+ value: string;
268
+ }
269
+ export declare function decodeGetPendingHttpsOutcallsResponse(res: EncodedGetPendingHttpsOutcallsResponse[]): GetPendingHttpsOutcallsResponse[];
270
+ export interface MockPendingHttpsOutcallRequest {
271
+ subnetId: Principal;
272
+ requestId: number;
273
+ response: HttpsOutcallResponseMock;
274
+ additionalResponses: HttpsOutcallResponseMock[];
275
+ }
276
+ export type HttpsOutcallResponseMock = HttpsOutcallSuccessResponseMock | HttpsOutcallRejectResponseMock;
277
+ export interface HttpsOutcallSuccessResponseMock {
278
+ type: 'success';
279
+ statusCode: number;
280
+ headers: CanisterHttpHeader[];
281
+ body: Uint8Array;
282
+ }
283
+ export interface HttpsOutcallRejectResponseMock {
284
+ type: 'reject';
285
+ statusCode: number;
286
+ message: string;
287
+ }
288
+ export interface EncodedMockPendingHttpsOutcallRequest {
289
+ subnet_id: {
290
+ subnet_id: string;
291
+ };
292
+ request_id: number;
293
+ response: EncodedHttpsOutcallResponseMock;
294
+ additional_responses: EncodedHttpsOutcallResponseMock[];
295
+ }
296
+ export type EncodedHttpsOutcallResponseMock = EncodedHttpsOutcallSuccessResponseMock | EncodedHttpsOutcallRejectResponseMock;
297
+ export interface EncodedHttpsOutcallSuccessResponseMock {
298
+ CanisterHttpReply: {
299
+ status: number;
300
+ headers: EncodedCanisterHttpHeader[];
301
+ body: string;
302
+ };
303
+ }
304
+ export interface EncodedHttpsOutcallRejectResponseMock {
305
+ CanisterHttpReject: {
306
+ reject_code: number;
307
+ message: string;
308
+ };
309
+ }
310
+ export declare function encodeMockPendingHttpsOutcallRequest(req: MockPendingHttpsOutcallRequest): EncodedMockPendingHttpsOutcallRequest;
311
+ export interface CanisterCallRequest {
312
+ sender: Principal;
313
+ canisterId: Principal;
314
+ method: string;
315
+ payload: Uint8Array;
316
+ effectivePrincipal?: EffectivePrincipal;
317
+ }
318
+ export type EffectivePrincipal = {
319
+ subnetId: Principal;
320
+ } | {
321
+ canisterId: Principal;
322
+ };
323
+ export interface EncodedCanisterCallRequest {
324
+ sender: string;
325
+ canister_id: string;
326
+ method: string;
327
+ payload: string;
328
+ effective_principal?: EncodedEffectivePrincipal;
329
+ }
330
+ export type EncodedEffectivePrincipal = {
331
+ SubnetId: string;
332
+ } | {
333
+ CanisterId: string;
334
+ } | 'None';
335
+ export declare function encodeEffectivePrincipal(effectivePrincipal?: EffectivePrincipal | null): EncodedEffectivePrincipal;
336
+ export declare function decodeEffectivePrincipal(effectivePrincipal: EncodedEffectivePrincipal): EffectivePrincipal | null;
337
+ export declare function encodeCanisterCallRequest(req: CanisterCallRequest): EncodedCanisterCallRequest;
338
+ export type EncodedCanisterCallResult<T> = {
339
+ Ok: T;
340
+ } | {
341
+ Err: EncodedCanisterCallRejectResponse;
342
+ };
343
+ export interface EncodedCanisterCallRejectResponse {
344
+ reject_code: number;
345
+ reject_message: string;
346
+ error_code: number;
347
+ certified: boolean;
348
+ }
349
+ export interface CanisterCallResponse {
350
+ body: Uint8Array;
351
+ }
352
+ export type EncodedCanisterCallResponse = EncodedCanisterCallResult<string>;
353
+ export declare function decodeCanisterCallResponse(res: EncodedCanisterCallResponse): CanisterCallResponse;
354
+ export type SubmitCanisterCallRequest = CanisterCallRequest;
355
+ export type EncodedSubmitCanisterCallRequest = EncodedCanisterCallRequest;
356
+ export declare function encodeSubmitCanisterCallRequest(req: SubmitCanisterCallRequest): EncodedSubmitCanisterCallRequest;
357
+ export interface SubmitCanisterCallResponse {
358
+ effectivePrincipal: EffectivePrincipal | null;
359
+ messageId: Uint8Array;
360
+ }
361
+ export interface EncodedCanisterCallId {
362
+ effective_principal: EncodedEffectivePrincipal;
363
+ message_id: Uint8Array;
364
+ }
365
+ export type EncodedSubmitCanisterCallResponse = EncodedCanisterCallResult<EncodedCanisterCallId>;
366
+ export declare function decodeSubmitCanisterCallResponse(res: EncodedSubmitCanisterCallResponse): SubmitCanisterCallResponse;
367
+ export type AwaitCanisterCallRequest = SubmitCanisterCallResponse;
368
+ export type EncodedAwaitCanisterCallRequest = EncodedCanisterCallId;
369
+ export declare function encodeAwaitCanisterCallRequest(req: AwaitCanisterCallRequest): EncodedAwaitCanisterCallRequest;
370
+ export type AwaitCanisterCallResponse = CanisterCallResponse;
371
+ export type EncodedAwaitCanisterCallResponse = EncodedCanisterCallResponse;
372
+ export declare function decodeAwaitCanisterCallResponse(res: EncodedAwaitCanisterCallResponse): AwaitCanisterCallResponse;