ic-mops 0.28.1 → 0.28.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.
- package/commands/init.ts +16 -9
- package/declarations/main/main.did +36 -0
- package/declarations/main/main.did.d.ts +28 -0
- package/declarations/main/main.did.js +32 -0
- package/dist/bench/$USER_BENCH_FILE.mo +45 -0
- package/dist/bench/bench-canister.mo +57 -0
- package/dist/commands/bench/$USER_BENCH_FILE.mo +45 -0
- package/dist/commands/bench/bench/$USER_BENCH_FILE.mo +45 -0
- package/dist/commands/bench/bench/bench-canister.mo +57 -0
- package/dist/commands/bench/bench-canister.mo +85 -0
- package/dist/commands/bench/declarations/bench/bench.did.d.ts +6 -0
- package/dist/commands/bench/declarations/bench/bench.did.js +22 -0
- package/dist/commands/bench/declarations/bench/index.d.ts +2 -0
- package/dist/commands/bench/declarations/bench/index.js +30 -0
- package/dist/commands/bench/declarations/main/index.d.ts +2 -0
- package/dist/commands/bench/declarations/main/index.js +30 -0
- package/dist/commands/bench/declarations/main/main.did.d.ts +6 -0
- package/dist/commands/bench/declarations/main/main.did.js +242 -0
- package/dist/commands/bench/declarations/storage/index.d.ts +4 -0
- package/dist/commands/bench/declarations/storage/index.js +26 -0
- package/dist/commands/bench/declarations/storage/storage.did.d.ts +6 -0
- package/dist/commands/bench/declarations/storage/storage.did.js +34 -0
- package/dist/commands/bench/user-bench.mo +14 -0
- package/dist/commands/bench.d.ts +9 -2
- package/dist/commands/bench.js +155 -71
- package/dist/commands/init.js +16 -9
- package/dist/declarations/bench/bench.did +24 -0
- package/dist/declarations/bench/bench.did.d.ts +24 -0
- package/dist/declarations/bench/bench.did.js +24 -0
- package/dist/declarations/bench/index.d.ts +50 -0
- package/dist/declarations/bench/index.js +41 -0
- package/dist/declarations/main/main.did +36 -0
- package/dist/declarations/main/main.did.d.ts +28 -0
- package/dist/declarations/main/main.did.js +32 -0
- package/dist/helpers/get-dfx-version.d.ts +1 -0
- package/dist/helpers/get-dfx-version.js +9 -0
- package/dist/helpers/get-moc-path.d.ts +1 -0
- package/dist/helpers/get-moc-path.js +11 -0
- package/dist/helpers/get-moc-version.d.ts +1 -0
- package/dist/helpers/get-moc-version.js +7 -0
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type anon_class_10_1 =
|
|
2
|
+
service {
|
|
3
|
+
getStats: () -> (BenchResult) query;
|
|
4
|
+
init: () -> (BenchSchema);
|
|
5
|
+
runCellQuery: (nat, nat) -> (BenchResult) query;
|
|
6
|
+
runCellUpdate: (nat, nat) -> (BenchResult);
|
|
7
|
+
};
|
|
8
|
+
type BenchSchema =
|
|
9
|
+
record {
|
|
10
|
+
cols: vec text;
|
|
11
|
+
description: text;
|
|
12
|
+
name: text;
|
|
13
|
+
rows: vec text;
|
|
14
|
+
};
|
|
15
|
+
type BenchResult =
|
|
16
|
+
record {
|
|
17
|
+
instructions: int;
|
|
18
|
+
rts_collector_instructions: int;
|
|
19
|
+
rts_heap_size: int;
|
|
20
|
+
rts_memory_size: int;
|
|
21
|
+
rts_mutator_instructions: int;
|
|
22
|
+
rts_total_allocation: int;
|
|
23
|
+
};
|
|
24
|
+
service : () -> anon_class_10_1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Principal } from '@dfinity/principal';
|
|
2
|
+
import type { ActorMethod } from '@dfinity/agent';
|
|
3
|
+
|
|
4
|
+
export interface BenchResult {
|
|
5
|
+
'instructions' : bigint,
|
|
6
|
+
'rts_memory_size' : bigint,
|
|
7
|
+
'rts_total_allocation' : bigint,
|
|
8
|
+
'rts_collector_instructions' : bigint,
|
|
9
|
+
'rts_mutator_instructions' : bigint,
|
|
10
|
+
'rts_heap_size' : bigint,
|
|
11
|
+
}
|
|
12
|
+
export interface BenchSchema {
|
|
13
|
+
'cols' : Array<string>,
|
|
14
|
+
'name' : string,
|
|
15
|
+
'rows' : Array<string>,
|
|
16
|
+
'description' : string,
|
|
17
|
+
}
|
|
18
|
+
export interface anon_class_10_1 {
|
|
19
|
+
'getStats' : ActorMethod<[], BenchResult>,
|
|
20
|
+
'init' : ActorMethod<[], BenchSchema>,
|
|
21
|
+
'runCellQuery' : ActorMethod<[bigint, bigint], BenchResult>,
|
|
22
|
+
'runCellUpdate' : ActorMethod<[bigint, bigint], BenchResult>,
|
|
23
|
+
}
|
|
24
|
+
export interface _SERVICE extends anon_class_10_1 {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const idlFactory = ({ IDL }) => {
|
|
2
|
+
const BenchResult = IDL.Record({
|
|
3
|
+
'instructions' : IDL.Int,
|
|
4
|
+
'rts_memory_size' : IDL.Int,
|
|
5
|
+
'rts_total_allocation' : IDL.Int,
|
|
6
|
+
'rts_collector_instructions' : IDL.Int,
|
|
7
|
+
'rts_mutator_instructions' : IDL.Int,
|
|
8
|
+
'rts_heap_size' : IDL.Int,
|
|
9
|
+
});
|
|
10
|
+
const BenchSchema = IDL.Record({
|
|
11
|
+
'cols' : IDL.Vec(IDL.Text),
|
|
12
|
+
'name' : IDL.Text,
|
|
13
|
+
'rows' : IDL.Vec(IDL.Text),
|
|
14
|
+
'description' : IDL.Text,
|
|
15
|
+
});
|
|
16
|
+
const anon_class_10_1 = IDL.Service({
|
|
17
|
+
'getStats' : IDL.Func([], [BenchResult], ['query']),
|
|
18
|
+
'init' : IDL.Func([], [BenchSchema], []),
|
|
19
|
+
'runCellQuery' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], ['query']),
|
|
20
|
+
'runCellUpdate' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
|
|
21
|
+
});
|
|
22
|
+
return anon_class_10_1;
|
|
23
|
+
};
|
|
24
|
+
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,41 @@
|
|
|
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
|
+
process.env.BENCH_CANISTER_ID;
|
|
15
|
+
|
|
16
|
+
export const createActor = (canisterId, options = {}) => {
|
|
17
|
+
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
18
|
+
|
|
19
|
+
if (options.agent && options.agentOptions) {
|
|
20
|
+
console.warn(
|
|
21
|
+
"Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Fetch root key for certificate validation during development
|
|
26
|
+
if (process.env.DFX_NETWORK !== "ic") {
|
|
27
|
+
agent.fetchRootKey().catch((err) => {
|
|
28
|
+
console.warn(
|
|
29
|
+
"Unable to fetch root key. Check to ensure that your local replica is running"
|
|
30
|
+
);
|
|
31
|
+
console.error(err);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Creates an actor with using the candid interface and the HttpAgent
|
|
36
|
+
return Actor.createActor(idlFactory, {
|
|
37
|
+
agent,
|
|
38
|
+
canisterId,
|
|
39
|
+
...options.actorOptions,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -41,6 +41,20 @@ type TestStats =
|
|
|
41
41
|
passed: nat;
|
|
42
42
|
passedNames: vec text;
|
|
43
43
|
};
|
|
44
|
+
type StreamingToken = blob;
|
|
45
|
+
type StreamingStrategy = variant {
|
|
46
|
+
Callback:
|
|
47
|
+
record {
|
|
48
|
+
callback: StreamingCallback;
|
|
49
|
+
token: StreamingToken;
|
|
50
|
+
};};
|
|
51
|
+
type StreamingCallbackResponse =
|
|
52
|
+
record {
|
|
53
|
+
body: blob;
|
|
54
|
+
token: opt StreamingToken;
|
|
55
|
+
};
|
|
56
|
+
type StreamingCallback = func (StreamingToken) ->
|
|
57
|
+
(opt StreamingCallbackResponse) query;
|
|
44
58
|
type StorageStats =
|
|
45
59
|
record {
|
|
46
60
|
cyclesBalance: nat;
|
|
@@ -102,6 +116,22 @@ type Result =
|
|
|
102
116
|
err: Err;
|
|
103
117
|
ok;
|
|
104
118
|
};
|
|
119
|
+
type Response =
|
|
120
|
+
record {
|
|
121
|
+
body: blob;
|
|
122
|
+
headers: vec Header;
|
|
123
|
+
status_code: nat16;
|
|
124
|
+
streaming_strategy: opt StreamingStrategy;
|
|
125
|
+
upgrade: opt bool;
|
|
126
|
+
};
|
|
127
|
+
type Request =
|
|
128
|
+
record {
|
|
129
|
+
body: blob;
|
|
130
|
+
certificate_version: opt nat16;
|
|
131
|
+
headers: vec Header;
|
|
132
|
+
method: text;
|
|
133
|
+
url: text;
|
|
134
|
+
};
|
|
105
135
|
type PublishingId = text;
|
|
106
136
|
type PublishingErr = text;
|
|
107
137
|
type PageCount = nat;
|
|
@@ -232,6 +262,11 @@ type PackageChanges =
|
|
|
232
262
|
notes: text;
|
|
233
263
|
tests: TestsChanges;
|
|
234
264
|
};
|
|
265
|
+
type Header =
|
|
266
|
+
record {
|
|
267
|
+
text;
|
|
268
|
+
text;
|
|
269
|
+
};
|
|
235
270
|
type FileId = text;
|
|
236
271
|
type Err = text;
|
|
237
272
|
type DownloadsSnapshot__1 =
|
|
@@ -300,6 +335,7 @@ service : {
|
|
|
300
335
|
getTotalDownloads: () -> (nat) query;
|
|
301
336
|
getTotalPackages: () -> (nat) query;
|
|
302
337
|
getUser: (principal) -> (opt User__1) query;
|
|
338
|
+
http_request: (Request) -> (Response) query;
|
|
303
339
|
notifyInstall: (PackageName__1, PackageVersion) -> () oneway;
|
|
304
340
|
notifyInstalls: (vec record {
|
|
305
341
|
PackageName__1;
|
|
@@ -23,6 +23,7 @@ export interface DownloadsSnapshot__1 {
|
|
|
23
23
|
}
|
|
24
24
|
export type Err = string;
|
|
25
25
|
export type FileId = string;
|
|
26
|
+
export type Header = [string, string];
|
|
26
27
|
export interface PackageChanges {
|
|
27
28
|
'tests' : TestsChanges,
|
|
28
29
|
'deps' : Array<DepChange>,
|
|
@@ -142,6 +143,20 @@ export type PackageVersion = string;
|
|
|
142
143
|
export type PageCount = bigint;
|
|
143
144
|
export type PublishingErr = string;
|
|
144
145
|
export type PublishingId = string;
|
|
146
|
+
export interface Request {
|
|
147
|
+
'url' : string,
|
|
148
|
+
'method' : string,
|
|
149
|
+
'body' : Uint8Array | number[],
|
|
150
|
+
'headers' : Array<Header>,
|
|
151
|
+
'certificate_version' : [] | [number],
|
|
152
|
+
}
|
|
153
|
+
export interface Response {
|
|
154
|
+
'body' : Uint8Array | number[],
|
|
155
|
+
'headers' : Array<Header>,
|
|
156
|
+
'upgrade' : [] | [boolean],
|
|
157
|
+
'streaming_strategy' : [] | [StreamingStrategy],
|
|
158
|
+
'status_code' : number,
|
|
159
|
+
}
|
|
145
160
|
export type Result = { 'ok' : null } |
|
|
146
161
|
{ 'err' : Err };
|
|
147
162
|
export type Result_1 = { 'ok' : PublishingId } |
|
|
@@ -168,6 +183,18 @@ export interface StorageStats {
|
|
|
168
183
|
'cyclesBalance' : bigint,
|
|
169
184
|
'memorySize' : bigint,
|
|
170
185
|
}
|
|
186
|
+
export type StreamingCallback = ActorMethod<
|
|
187
|
+
[StreamingToken],
|
|
188
|
+
[] | [StreamingCallbackResponse]
|
|
189
|
+
>;
|
|
190
|
+
export interface StreamingCallbackResponse {
|
|
191
|
+
'token' : [] | [StreamingToken],
|
|
192
|
+
'body' : Uint8Array | number[],
|
|
193
|
+
}
|
|
194
|
+
export type StreamingStrategy = {
|
|
195
|
+
'Callback' : { 'token' : StreamingToken, 'callback' : StreamingCallback }
|
|
196
|
+
};
|
|
197
|
+
export type StreamingToken = Uint8Array | number[];
|
|
171
198
|
export interface TestStats { 'passedNames' : Array<string>, 'passed' : bigint }
|
|
172
199
|
export interface TestStats__1 {
|
|
173
200
|
'passedNames' : Array<string>,
|
|
@@ -246,6 +273,7 @@ export interface _SERVICE {
|
|
|
246
273
|
'getTotalDownloads' : ActorMethod<[], bigint>,
|
|
247
274
|
'getTotalPackages' : ActorMethod<[], bigint>,
|
|
248
275
|
'getUser' : ActorMethod<[Principal], [] | [User__1]>,
|
|
276
|
+
'http_request' : ActorMethod<[Request], Response>,
|
|
249
277
|
'notifyInstall' : ActorMethod<[PackageName__1, PackageVersion], undefined>,
|
|
250
278
|
'notifyInstalls' : ActorMethod<
|
|
251
279
|
[Array<[PackageName__1, PackageVersion]>],
|
|
@@ -174,6 +174,37 @@ export const idlFactory = ({ IDL }) => {
|
|
|
174
174
|
'githubVerified' : IDL.Bool,
|
|
175
175
|
'github' : IDL.Text,
|
|
176
176
|
});
|
|
177
|
+
const Header = IDL.Tuple(IDL.Text, IDL.Text);
|
|
178
|
+
const Request = IDL.Record({
|
|
179
|
+
'url' : IDL.Text,
|
|
180
|
+
'method' : IDL.Text,
|
|
181
|
+
'body' : IDL.Vec(IDL.Nat8),
|
|
182
|
+
'headers' : IDL.Vec(Header),
|
|
183
|
+
'certificate_version' : IDL.Opt(IDL.Nat16),
|
|
184
|
+
});
|
|
185
|
+
const StreamingToken = IDL.Vec(IDL.Nat8);
|
|
186
|
+
const StreamingCallbackResponse = IDL.Record({
|
|
187
|
+
'token' : IDL.Opt(StreamingToken),
|
|
188
|
+
'body' : IDL.Vec(IDL.Nat8),
|
|
189
|
+
});
|
|
190
|
+
const StreamingCallback = IDL.Func(
|
|
191
|
+
[StreamingToken],
|
|
192
|
+
[IDL.Opt(StreamingCallbackResponse)],
|
|
193
|
+
['query'],
|
|
194
|
+
);
|
|
195
|
+
const StreamingStrategy = IDL.Variant({
|
|
196
|
+
'Callback' : IDL.Record({
|
|
197
|
+
'token' : StreamingToken,
|
|
198
|
+
'callback' : StreamingCallback,
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
const Response = IDL.Record({
|
|
202
|
+
'body' : IDL.Vec(IDL.Nat8),
|
|
203
|
+
'headers' : IDL.Vec(Header),
|
|
204
|
+
'upgrade' : IDL.Opt(IDL.Bool),
|
|
205
|
+
'streaming_strategy' : IDL.Opt(StreamingStrategy),
|
|
206
|
+
'status_code' : IDL.Nat16,
|
|
207
|
+
});
|
|
177
208
|
const PageCount = IDL.Nat;
|
|
178
209
|
const Result_3 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
|
|
179
210
|
const Result_2 = IDL.Variant({ 'ok' : FileId, 'err' : Err });
|
|
@@ -270,6 +301,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
270
301
|
'getTotalDownloads' : IDL.Func([], [IDL.Nat], ['query']),
|
|
271
302
|
'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
|
|
272
303
|
'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User__1)], ['query']),
|
|
304
|
+
'http_request' : IDL.Func([Request], [Response], ['query']),
|
|
273
305
|
'notifyInstall' : IDL.Func(
|
|
274
306
|
[PackageName__1, PackageVersion],
|
|
275
307
|
[],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDfxVersion(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMocPath(): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
export function getMocPath() {
|
|
3
|
+
let mocPath = process.env.DFX_MOC_PATH;
|
|
4
|
+
if (!mocPath) {
|
|
5
|
+
mocPath = execSync('dfx cache show').toString().trim() + '/moc';
|
|
6
|
+
}
|
|
7
|
+
if (!mocPath) {
|
|
8
|
+
mocPath = 'moc';
|
|
9
|
+
}
|
|
10
|
+
return mocPath;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMocVersion(): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import { getMocPath } from './get-moc-path.js';
|
|
3
|
+
export function getMocVersion() {
|
|
4
|
+
let mocPath = getMocPath();
|
|
5
|
+
let match = execSync(mocPath).toString().trim().match(/Motoko compiler ([^\s]+) .*/);
|
|
6
|
+
return match?.[1] || '';
|
|
7
|
+
}
|
package/dist/package.json
CHANGED