ic-mops 0.31.0 → 0.31.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 (50) hide show
  1. package/dist/package.json +1 -1
  2. package/package.json +1 -1
  3. package/dist/bench/$USER_BENCH_FILE.mo +0 -45
  4. package/dist/bench/bench-canister.mo +0 -57
  5. package/dist/commands/bench/$USER_BENCH_FILE.mo +0 -45
  6. package/dist/commands/bench/bench/$USER_BENCH_FILE.mo +0 -45
  7. package/dist/commands/bench/bench/bench-canister.mo +0 -57
  8. package/dist/commands/bench/bench-canister.mo +0 -89
  9. package/dist/commands/bench/declarations/bench/bench.did.d.ts +0 -6
  10. package/dist/commands/bench/declarations/bench/bench.did.js +0 -22
  11. package/dist/commands/bench/declarations/bench/index.d.ts +0 -2
  12. package/dist/commands/bench/declarations/bench/index.js +0 -30
  13. package/dist/commands/bench/declarations/main/index.d.ts +0 -2
  14. package/dist/commands/bench/declarations/main/index.js +0 -30
  15. package/dist/commands/bench/declarations/main/main.did.d.ts +0 -6
  16. package/dist/commands/bench/declarations/main/main.did.js +0 -242
  17. package/dist/commands/bench/declarations/storage/index.d.ts +0 -4
  18. package/dist/commands/bench/declarations/storage/index.js +0 -26
  19. package/dist/commands/bench/declarations/storage/storage.did.d.ts +0 -6
  20. package/dist/commands/bench/declarations/storage/storage.did.js +0 -34
  21. package/dist/commands/bench/user-bench.mo +0 -14
  22. package/dist/commands/bench.d.ts +0 -11
  23. package/dist/commands/bench.js +0 -255
  24. package/dist/commands/mmf1.d.ts +0 -21
  25. package/dist/commands/mmf1.js +0 -93
  26. package/dist/commands/test/reporter-files.d.ts +0 -10
  27. package/dist/commands/test/reporter-files.js +0 -48
  28. package/dist/commands/test/reporter-verbose.d.ts +0 -10
  29. package/dist/commands/test/reporter-verbose.js +0 -56
  30. package/dist/commands/test.d.ts +0 -4
  31. package/dist/commands/test.js +0 -186
  32. package/dist/declarations/bench/bench.did +0 -25
  33. package/dist/declarations/bench/bench.did.d.ts +0 -25
  34. package/dist/declarations/bench/bench.did.js +0 -25
  35. package/dist/declarations/bench/index.d.ts +0 -50
  36. package/dist/declarations/bench/index.js +0 -41
  37. package/dist/helpers/get-dfx-version.d.ts +0 -1
  38. package/dist/helpers/get-dfx-version.js +0 -9
  39. package/dist/helpers/get-moc-path.d.ts +0 -1
  40. package/dist/helpers/get-moc-path.js +0 -11
  41. package/dist/helpers/get-moc-version.d.ts +0 -1
  42. package/dist/helpers/get-moc-version.js +0 -7
  43. package/dist/integrity.d.ts +0 -4
  44. package/dist/integrity.js +0 -92
  45. package/dist/out/cli.d.ts +0 -2
  46. package/dist/out/cli.js +0 -114581
  47. package/dist/parse-changelog.d.ts +0 -1
  48. package/dist/parse-changelog.js +0 -1435
  49. package/dist/test.d.ts +0 -1
  50. package/dist/test.js +0 -1411
@@ -1,93 +0,0 @@
1
- // mops message format v1
2
- // mops:1:start
3
- // mops:1:end
4
- // mops:1:skip
5
- import chalk from 'chalk';
6
- export class MMF1 {
7
- constructor(srategy) {
8
- this.stack = [];
9
- this.currSuite = '';
10
- this.failed = 0;
11
- this.passed = 0;
12
- this.skipped = 0;
13
- this.output = [];
14
- this.srategy = srategy;
15
- }
16
- _log(...args) {
17
- if (this.srategy === 'store') {
18
- this.output.push(args.join(' '));
19
- }
20
- else if (this.srategy === 'print') {
21
- console.log(...args);
22
- }
23
- }
24
- flush() {
25
- for (let out of this.output) {
26
- console.log(out);
27
- }
28
- this.output = [];
29
- }
30
- parseLine(line) {
31
- if (line.startsWith('mops:1:start ')) {
32
- this._testStart(line.split('mops:1:start ')[1] || '');
33
- }
34
- else if (line.startsWith('mops:1:end ')) {
35
- this._testEnd(line.split('mops:1:end ')[1] || '');
36
- }
37
- else if (line.startsWith('mops:1:skip ')) {
38
- this._testSkip(line.split('mops:1:skip ')[1] || '');
39
- }
40
- else {
41
- this._log(' '.repeat(this.stack.length * 2), chalk.gray('stdout'), line);
42
- }
43
- }
44
- _testStart(name) {
45
- let suite = this.stack[this.stack.length - 1];
46
- if (suite) {
47
- if (this.currSuite !== suite) {
48
- this.currSuite = suite;
49
- this._log(' '.repeat((this.stack.length - 1) * 2), (chalk.gray('•')) + '', suite);
50
- }
51
- }
52
- this.stack.push(name);
53
- }
54
- _testEnd(name) {
55
- if (name !== this.stack.pop()) {
56
- throw 'mmf1._testEnd: start and end test mismatch';
57
- }
58
- this._status(name, 'pass');
59
- }
60
- _testSkip(name) {
61
- this._status(name, 'skip');
62
- }
63
- _status(name, status) {
64
- if (status === 'pass') {
65
- // do not print suite at the end
66
- if (name === this.currSuite) {
67
- return;
68
- }
69
- this.passed++;
70
- this._log(' '.repeat(this.stack.length * 2), chalk.green('✓'), name);
71
- }
72
- else if (status === 'fail') {
73
- this.failed++;
74
- this._log(' '.repeat(this.stack.length * 2), chalk.red('✖'), name);
75
- }
76
- else if (status === 'skip') {
77
- this.skipped++;
78
- this._log(' '.repeat(this.stack.length * 2), chalk.yellow('−'), name);
79
- }
80
- }
81
- fail(stderr) {
82
- let name = this.stack.pop() || '';
83
- this._status(name, 'fail');
84
- this._log(' '.repeat(this.stack.length * 2), chalk.red('FAIL'), stderr);
85
- }
86
- pass() {
87
- let name = this.stack.pop();
88
- if (name) {
89
- this._status(name, 'pass');
90
- }
91
- this._log(' '.repeat(this.stack.length * 2), chalk.green('PASS'));
92
- }
93
- }
@@ -1,10 +0,0 @@
1
- import { MMF1 } from './mmf1.js';
2
- export declare class FilesReporter {
3
- #private;
4
- passed: number;
5
- failed: number;
6
- skipped: number;
7
- addFiles(files: string[]): void;
8
- addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
9
- done(): boolean;
10
- }
@@ -1,48 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _FilesReporter_startTime;
7
- import chalk from 'chalk';
8
- import { absToRel } from './utils.js';
9
- export class FilesReporter {
10
- constructor() {
11
- this.passed = 0;
12
- this.failed = 0;
13
- this.skipped = 0;
14
- _FilesReporter_startTime.set(this, Date.now());
15
- }
16
- addFiles(files) {
17
- console.log(`Test files: ${files.length}`);
18
- console.log('='.repeat(50));
19
- }
20
- addRun(file, mmf, state, wasiMode) {
21
- state.then(() => {
22
- this.passed += mmf.passed;
23
- this.failed += mmf.failed;
24
- this.skipped += mmf.skipped;
25
- if (this.failed) {
26
- mmf.flush();
27
- }
28
- else {
29
- console.log(`${chalk.green('✓')} ${absToRel(file)} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
30
- }
31
- });
32
- }
33
- done() {
34
- console.log('='.repeat(50));
35
- if (this.failed) {
36
- console.log(chalk.redBright('Tests failed'));
37
- }
38
- else {
39
- console.log(chalk.greenBright('Tests passed'));
40
- }
41
- console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _FilesReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
42
- + `, passed ${chalk.greenBright(this.passed)}`
43
- + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)}` : '')
44
- + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
45
- return this.failed === 0;
46
- }
47
- }
48
- _FilesReporter_startTime = new WeakMap();
@@ -1,10 +0,0 @@
1
- import { MMF1 } from './mmf1.js';
2
- export declare class VerboseReporter {
3
- #private;
4
- passed: number;
5
- failed: number;
6
- skipped: number;
7
- addFiles(files: string[]): void;
8
- addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
9
- done(): boolean;
10
- }
@@ -1,56 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _VerboseReporter_startTime, _VerboseReporter_curFileIndex;
13
- import chalk from 'chalk';
14
- import { absToRel } from './utils.js';
15
- export class VerboseReporter {
16
- constructor() {
17
- this.passed = 0;
18
- this.failed = 0;
19
- this.skipped = 0;
20
- _VerboseReporter_startTime.set(this, Date.now());
21
- _VerboseReporter_curFileIndex.set(this, 0);
22
- }
23
- addFiles(files) {
24
- console.log('Test files:');
25
- for (let file of files) {
26
- console.log(chalk.gray(`• ${absToRel(file)}`));
27
- }
28
- console.log('='.repeat(50));
29
- }
30
- addRun(file, mmf, state, wasiMode) {
31
- state.then(() => {
32
- var _a, _b;
33
- this.passed += mmf.passed;
34
- this.failed += mmf.failed;
35
- this.skipped += mmf.skipped;
36
- (__classPrivateFieldSet(this, _VerboseReporter_curFileIndex, (_b = __classPrivateFieldGet(this, _VerboseReporter_curFileIndex, "f"), _a = _b++, _b), "f"), _a) && console.log('-'.repeat(50));
37
- console.log(`Running ${chalk.gray(absToRel(file))} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
38
- mmf.flush();
39
- });
40
- }
41
- done() {
42
- console.log('='.repeat(50));
43
- if (this.failed) {
44
- console.log(chalk.redBright('Tests failed'));
45
- }
46
- else {
47
- console.log(chalk.greenBright('Tests passed'));
48
- }
49
- console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _VerboseReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
50
- + `, passed ${chalk.greenBright(this.passed)}`
51
- + (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)}` : '')
52
- + (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
53
- return this.failed === 0;
54
- }
55
- }
56
- _VerboseReporter_startTime = new WeakMap(), _VerboseReporter_curFileIndex = new WeakMap();
@@ -1,4 +0,0 @@
1
- export declare function test(filter?: string, { watch }?: {
2
- watch?: boolean | undefined;
3
- }): Promise<void>;
4
- export declare function runAll(filter?: string): Promise<boolean | undefined>;
@@ -1,186 +0,0 @@
1
- import { spawn, execSync } from 'node:child_process';
2
- import path from 'node:path';
3
- import fs from 'node:fs';
4
- import os from 'node:os';
5
- import chalk from 'chalk';
6
- import { globSync } from 'glob';
7
- import chokidar from 'chokidar';
8
- import debounce from 'debounce';
9
- import { MMF1 } from './mmf1.js';
10
- import { sources } from './sources.js';
11
- import { getRootDir } from '../mops.js';
12
- import { parallel } from '../parallel.js';
13
- import { absToRel } from './test/utils.js';
14
- import { VerboseReporter } from './test/reporter-verbose.js';
15
- let ignore = [
16
- '**/node_modules/**',
17
- '**/.mops/**',
18
- '**/.vessel/**',
19
- '**/.git/**',
20
- ];
21
- let globConfig = {
22
- nocase: true,
23
- ignore: ignore,
24
- };
25
- export async function test(filter = '', { watch = false } = {}) {
26
- let rootDir = getRootDir();
27
- if (watch) {
28
- // todo: run only changed for *.test.mo?
29
- // todo: run all for *.mo?
30
- let run = debounce(async () => {
31
- console.clear();
32
- process.stdout.write('\x1Bc');
33
- await runAll(filter);
34
- console.log('-'.repeat(50));
35
- console.log('Waiting for file changes...');
36
- console.log(chalk.gray((`Press ${chalk.gray('Ctrl+C')} to exit.`)));
37
- }, 200);
38
- let watcher = chokidar.watch([
39
- path.join(rootDir, '**/*.mo'),
40
- path.join(rootDir, 'mops.toml'),
41
- ], {
42
- ignored: ignore,
43
- ignoreInitial: true,
44
- });
45
- watcher.on('all', () => {
46
- run();
47
- });
48
- run();
49
- }
50
- else {
51
- let passed = await runAll(filter);
52
- if (!passed) {
53
- process.exit(1);
54
- }
55
- }
56
- }
57
- let mocPath = process.env.DFX_MOC_PATH;
58
- export async function runAll(filter = '') {
59
- let reporter = new VerboseReporter;
60
- let rootDir = getRootDir();
61
- let files = [];
62
- let libFiles = globSync('**/test?(s)/lib.mo', globConfig);
63
- if (libFiles[0]) {
64
- files = [libFiles[0]];
65
- }
66
- else {
67
- let globStr = '**/test?(s)/**/*.test.mo';
68
- if (filter) {
69
- globStr = `**/test?(s)/**/*${filter}*.mo`;
70
- }
71
- files = globSync(path.join(rootDir, globStr), globConfig);
72
- }
73
- if (!files.length) {
74
- if (filter) {
75
- console.log(`No test files found for filter '${filter}'`);
76
- return;
77
- }
78
- console.log('No test files found');
79
- console.log('Put your tests in \'test\' directory in *.test.mo files');
80
- return;
81
- }
82
- reporter.addFiles(files);
83
- // console.log('Test files:');
84
- // for (let file of files) {
85
- // console.log(chalk.gray(`• ${absToRel(file)}`));
86
- // }
87
- // console.log('='.repeat(50));
88
- // let failed = 0;
89
- // let passed = 0;
90
- // let skipped = 0;
91
- let sourcesArr = await sources();
92
- if (!mocPath) {
93
- mocPath = execSync('dfx cache show').toString().trim() + '/moc';
94
- }
95
- let wasmDir = `${getRootDir()}/.mops/.test/`;
96
- fs.mkdirSync(wasmDir, { recursive: true });
97
- await parallel(os.cpus().length, files, async (file) => {
98
- let mmf = new MMF1('store');
99
- let wasiMode = fs.readFileSync(file, 'utf8').startsWith('// @testmode wasi');
100
- let promise = new Promise((resolve) => {
101
- if (!mocPath) {
102
- mocPath = 'moc';
103
- }
104
- let mocArgs = ['--hide-warnings', '--error-detail=2', ...sourcesArr.join(' ').split(' '), file].filter(x => x);
105
- // build and run wasm
106
- if (wasiMode) {
107
- let wasmFile = `${path.join(wasmDir, path.parse(file).name)}.wasm`;
108
- // build
109
- let buildProc = spawn(mocPath, [`-o=${wasmFile}`, '-wasi-system-api', ...mocArgs]);
110
- pipeMMF(buildProc, mmf).then(async () => {
111
- if (mmf.failed > 0) {
112
- return;
113
- }
114
- // run
115
- let proc = spawn('wasmtime', [wasmFile]);
116
- await pipeMMF(proc, mmf);
117
- }).finally(() => {
118
- fs.rmSync(wasmFile, { force: true });
119
- }).then(resolve);
120
- }
121
- // interpret
122
- else {
123
- let proc = spawn(mocPath, ['-r', '-ref-system-api', ...mocArgs]);
124
- pipeMMF(proc, mmf).then(resolve);
125
- }
126
- });
127
- reporter.addRun(file, mmf, promise, wasiMode);
128
- await promise;
129
- });
130
- fs.rmSync(wasmDir, { recursive: true, force: true });
131
- return reporter.done();
132
- }
133
- function pipeMMF(proc, mmf) {
134
- return new Promise((resolve) => {
135
- // stdout
136
- proc.stdout.on('data', (data) => {
137
- for (let line of data.toString().split('\n')) {
138
- line = line.trim();
139
- if (line) {
140
- mmf.parseLine(line);
141
- }
142
- }
143
- });
144
- // stderr
145
- proc.stderr.on('data', (data) => {
146
- let text = data.toString().trim();
147
- let failedLine = '';
148
- text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (_m0, m1, m2, m3) => {
149
- // change absolute file path to relative
150
- // change :line:col-line:col to :line:col to work in vscode
151
- let res = `${absToRel(m1)}:${m2}:${m3}`;
152
- if (!fs.existsSync(m1)) {
153
- return res;
154
- }
155
- // show failed line
156
- let content = fs.readFileSync(m1);
157
- let lines = content.toString().split('\n') || [];
158
- failedLine += chalk.dim `\n ...`;
159
- let lineBefore = lines[+m2 - 2];
160
- if (lineBefore) {
161
- failedLine += chalk.dim `\n ${+m2 - 1}\t| ${lineBefore.replaceAll('\t', ' ')}`;
162
- }
163
- failedLine += `\n${chalk.redBright `->`} ${m2}\t| ${lines[+m2 - 1]?.replaceAll('\t', ' ')}`;
164
- if (lines.length > +m2) {
165
- failedLine += chalk.dim `\n ${+m2 + 1}\t| ${lines[+m2]?.replaceAll('\t', ' ')}`;
166
- }
167
- failedLine += chalk.dim `\n ...`;
168
- return res;
169
- });
170
- if (failedLine) {
171
- text += failedLine;
172
- }
173
- mmf.fail(text);
174
- });
175
- // exit
176
- proc.on('close', (code) => {
177
- if (code === 0) {
178
- mmf.pass();
179
- }
180
- else if (code !== 1) {
181
- mmf.fail(`unknown exit code: ${code}`);
182
- }
183
- resolve();
184
- });
185
- });
186
- }
@@ -1,25 +0,0 @@
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
- runCellUpdateAwait: (nat, nat) -> (BenchResult);
8
- };
9
- type BenchSchema =
10
- record {
11
- cols: vec text;
12
- description: text;
13
- name: text;
14
- rows: vec text;
15
- };
16
- type BenchResult =
17
- record {
18
- instructions: int;
19
- rts_collector_instructions: int;
20
- rts_heap_size: int;
21
- rts_memory_size: int;
22
- rts_mutator_instructions: int;
23
- rts_total_allocation: int;
24
- };
25
- service : () -> anon_class_10_1
@@ -1,25 +0,0 @@
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
- 'runCellUpdateAwait' : ActorMethod<[bigint, bigint], BenchResult>,
24
- }
25
- export interface _SERVICE extends anon_class_10_1 {}
@@ -1,25 +0,0 @@
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
- 'runCellUpdateAwait' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
22
- });
23
- return anon_class_10_1;
24
- };
25
- export const init = ({ IDL }) => { return []; };
@@ -1,50 +0,0 @@
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>;
@@ -1,41 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- export declare function getDfxVersion(): string;
@@ -1,9 +0,0 @@
1
- import { execSync } from 'node:child_process';
2
- export function getDfxVersion() {
3
- try {
4
- let res = execSync('dfx --version').toString();
5
- return res.trim().split('dfx ')[1] || '';
6
- }
7
- catch { }
8
- return '';
9
- }
@@ -1 +0,0 @@
1
- export declare function getMocPath(): string;
@@ -1,11 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export declare function getMocVersion(): string;
@@ -1,7 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- export declare function getFileHashesFromRegistry(packageIds: string[]): Promise<[string, [string, Uint8Array | number[]][]][]>;
2
- export declare function checkIntegrity(): Promise<void>;
3
- export declare function saveLockFile(): Promise<void>;
4
- export declare function checkLockFile(): Promise<void>;