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.
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/bench/$USER_BENCH_FILE.mo +0 -45
- package/dist/bench/bench-canister.mo +0 -57
- package/dist/commands/bench/$USER_BENCH_FILE.mo +0 -45
- package/dist/commands/bench/bench/$USER_BENCH_FILE.mo +0 -45
- package/dist/commands/bench/bench/bench-canister.mo +0 -57
- package/dist/commands/bench/bench-canister.mo +0 -89
- package/dist/commands/bench/declarations/bench/bench.did.d.ts +0 -6
- package/dist/commands/bench/declarations/bench/bench.did.js +0 -22
- package/dist/commands/bench/declarations/bench/index.d.ts +0 -2
- package/dist/commands/bench/declarations/bench/index.js +0 -30
- package/dist/commands/bench/declarations/main/index.d.ts +0 -2
- package/dist/commands/bench/declarations/main/index.js +0 -30
- package/dist/commands/bench/declarations/main/main.did.d.ts +0 -6
- package/dist/commands/bench/declarations/main/main.did.js +0 -242
- package/dist/commands/bench/declarations/storage/index.d.ts +0 -4
- package/dist/commands/bench/declarations/storage/index.js +0 -26
- package/dist/commands/bench/declarations/storage/storage.did.d.ts +0 -6
- package/dist/commands/bench/declarations/storage/storage.did.js +0 -34
- package/dist/commands/bench/user-bench.mo +0 -14
- package/dist/commands/bench.d.ts +0 -11
- package/dist/commands/bench.js +0 -255
- package/dist/commands/mmf1.d.ts +0 -21
- package/dist/commands/mmf1.js +0 -93
- package/dist/commands/test/reporter-files.d.ts +0 -10
- package/dist/commands/test/reporter-files.js +0 -48
- package/dist/commands/test/reporter-verbose.d.ts +0 -10
- package/dist/commands/test/reporter-verbose.js +0 -56
- package/dist/commands/test.d.ts +0 -4
- package/dist/commands/test.js +0 -186
- package/dist/declarations/bench/bench.did +0 -25
- package/dist/declarations/bench/bench.did.d.ts +0 -25
- package/dist/declarations/bench/bench.did.js +0 -25
- package/dist/declarations/bench/index.d.ts +0 -50
- package/dist/declarations/bench/index.js +0 -41
- package/dist/helpers/get-dfx-version.d.ts +0 -1
- package/dist/helpers/get-dfx-version.js +0 -9
- package/dist/helpers/get-moc-path.d.ts +0 -1
- package/dist/helpers/get-moc-path.js +0 -11
- package/dist/helpers/get-moc-version.d.ts +0 -1
- package/dist/helpers/get-moc-version.js +0 -7
- package/dist/integrity.d.ts +0 -4
- package/dist/integrity.js +0 -92
- package/dist/out/cli.d.ts +0 -2
- package/dist/out/cli.js +0 -114581
- package/dist/parse-changelog.d.ts +0 -1
- package/dist/parse-changelog.js +0 -1435
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -1411
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Nat "mo:base/Nat";
|
|
2
|
-
import Iter "mo:base/Iter";
|
|
3
|
-
import Buffer "mo:base/Buffer";
|
|
4
|
-
import Vector "mo:vector/Class";
|
|
5
|
-
// import Bench "./bench";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
module {
|
|
9
|
-
public func init() : Bench.Bench {
|
|
10
|
-
let bench = Bench.Bench();
|
|
11
|
-
|
|
12
|
-
bench.setName("Add items one-by-one");
|
|
13
|
-
|
|
14
|
-
bench.addRow("Vector");
|
|
15
|
-
bench.addRow("Buffer");
|
|
16
|
-
|
|
17
|
-
bench.addCol("10");
|
|
18
|
-
bench.addCol("10000");
|
|
19
|
-
bench.addCol("1000000");
|
|
20
|
-
|
|
21
|
-
bench.setRunner(func(row, col) {
|
|
22
|
-
let ?n = Nat.fromText(col);
|
|
23
|
-
|
|
24
|
-
// Vector
|
|
25
|
-
if (row == "Vector") {
|
|
26
|
-
let vec = Vector.Vector<Nat>();
|
|
27
|
-
for (i in Iter.range(1, n)) {
|
|
28
|
-
vec.add(i);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Buffer
|
|
32
|
-
else if (row == "Buffer") {
|
|
33
|
-
let buf = Buffer.Buffer<Nat>(0);
|
|
34
|
-
for (i in Iter.range(1, n)) {
|
|
35
|
-
buf.add(i);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// bench.table(["Vector", "Buffer"], ["10", "10000", "1000000"], func(row, col) {
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
bench;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import Nat64 "mo:base/Nat64";
|
|
2
|
-
import Debug "mo:base/Debug";
|
|
3
|
-
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
4
|
-
import Prim "mo:prim";
|
|
5
|
-
|
|
6
|
-
// import Bench "./bench";
|
|
7
|
-
import Bench "mo:bench";
|
|
8
|
-
|
|
9
|
-
import UserBench "$USER_BENCH_FILE";
|
|
10
|
-
|
|
11
|
-
actor class() {
|
|
12
|
-
var benchOpt : ?Bench.Bench = null;
|
|
13
|
-
|
|
14
|
-
public func init() : async Bench.BenchSchema {
|
|
15
|
-
let bench = UserBench.init();
|
|
16
|
-
benchOpt := ?bench;
|
|
17
|
-
bench.getSchema();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// public composite query func noop() : async () {};
|
|
21
|
-
|
|
22
|
-
public func runCell(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
23
|
-
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
24
|
-
|
|
25
|
-
let rts_heap_size_before = Prim.rts_heap_size();
|
|
26
|
-
let rts_memory_size_before = Prim.rts_memory_size();
|
|
27
|
-
let rts_total_allocation_before = Prim.rts_total_allocation();
|
|
28
|
-
let rts_mutator_instructions_before = Prim.rts_mutator_instructions();
|
|
29
|
-
let rts_collector_instructions_before = Prim.rts_collector_instructions();
|
|
30
|
-
|
|
31
|
-
let mode : Bench.BenchMode = #replica;
|
|
32
|
-
let instructions = switch(mode) {
|
|
33
|
-
case (#replica) {
|
|
34
|
-
ExperimentalInternetComputer.countInstructions(func() {
|
|
35
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
case (#wasi) {
|
|
39
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
40
|
-
0 : Nat64;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// await noop();
|
|
45
|
-
|
|
46
|
-
// await (func() : async () {})();
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
instructions = Nat64.toNat(instructions);
|
|
50
|
-
rts_heap_size = Prim.rts_heap_size() - rts_heap_size_before;
|
|
51
|
-
rts_memory_size = Prim.rts_memory_size() - rts_memory_size_before;
|
|
52
|
-
rts_total_allocation = Prim.rts_total_allocation() - rts_total_allocation_before;
|
|
53
|
-
rts_mutator_instructions = Prim.rts_mutator_instructions() - rts_mutator_instructions_before;
|
|
54
|
-
rts_collector_instructions = Prim.rts_collector_instructions() - rts_collector_instructions_before;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Nat "mo:base/Nat";
|
|
2
|
-
import Iter "mo:base/Iter";
|
|
3
|
-
import Buffer "mo:base/Buffer";
|
|
4
|
-
import Vector "mo:vector/Class";
|
|
5
|
-
// import Bench "./bench";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
module {
|
|
9
|
-
public func init() : Bench.Bench {
|
|
10
|
-
let bench = Bench.Bench();
|
|
11
|
-
|
|
12
|
-
bench.setName("Add items one-by-one");
|
|
13
|
-
|
|
14
|
-
bench.addRow("Vector");
|
|
15
|
-
bench.addRow("Buffer");
|
|
16
|
-
|
|
17
|
-
bench.addCol("10");
|
|
18
|
-
bench.addCol("10000");
|
|
19
|
-
bench.addCol("1000000");
|
|
20
|
-
|
|
21
|
-
bench.setRunner(func(row, col) {
|
|
22
|
-
let ?n = Nat.fromText(col);
|
|
23
|
-
|
|
24
|
-
// Vector
|
|
25
|
-
if (row == "Vector") {
|
|
26
|
-
let vec = Vector.Vector<Nat>();
|
|
27
|
-
for (i in Iter.range(1, n)) {
|
|
28
|
-
vec.add(i);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Buffer
|
|
32
|
-
else if (row == "Buffer") {
|
|
33
|
-
let buf = Buffer.Buffer<Nat>(0);
|
|
34
|
-
for (i in Iter.range(1, n)) {
|
|
35
|
-
buf.add(i);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// bench.table(["Vector", "Buffer"], ["10", "10000", "1000000"], func(row, col) {
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
bench;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Nat "mo:base/Nat";
|
|
2
|
-
import Iter "mo:base/Iter";
|
|
3
|
-
import Buffer "mo:base/Buffer";
|
|
4
|
-
import Vector "mo:vector/Class";
|
|
5
|
-
// import Bench "./bench";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
module {
|
|
9
|
-
public func init() : Bench.Bench {
|
|
10
|
-
let bench = Bench.Bench();
|
|
11
|
-
|
|
12
|
-
bench.setName("Add items one-by-one");
|
|
13
|
-
|
|
14
|
-
bench.addRow("Vector");
|
|
15
|
-
bench.addRow("Buffer");
|
|
16
|
-
|
|
17
|
-
bench.addCol("10");
|
|
18
|
-
bench.addCol("10000");
|
|
19
|
-
bench.addCol("1000000");
|
|
20
|
-
|
|
21
|
-
bench.setRunner(func(row, col) {
|
|
22
|
-
let ?n = Nat.fromText(col);
|
|
23
|
-
|
|
24
|
-
// Vector
|
|
25
|
-
if (row == "Vector") {
|
|
26
|
-
let vec = Vector.Vector<Nat>();
|
|
27
|
-
for (i in Iter.range(1, n)) {
|
|
28
|
-
vec.add(i);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Buffer
|
|
32
|
-
else if (row == "Buffer") {
|
|
33
|
-
let buf = Buffer.Buffer<Nat>(0);
|
|
34
|
-
for (i in Iter.range(1, n)) {
|
|
35
|
-
buf.add(i);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// bench.table(["Vector", "Buffer"], ["10", "10000", "1000000"], func(row, col) {
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
bench;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import Nat64 "mo:base/Nat64";
|
|
2
|
-
import Debug "mo:base/Debug";
|
|
3
|
-
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
4
|
-
import Prim "mo:prim";
|
|
5
|
-
|
|
6
|
-
// import Bench "./bench";
|
|
7
|
-
import Bench "mo:bench";
|
|
8
|
-
|
|
9
|
-
import UserBench "$USER_BENCH_FILE";
|
|
10
|
-
|
|
11
|
-
actor class() {
|
|
12
|
-
var benchOpt : ?Bench.Bench = null;
|
|
13
|
-
|
|
14
|
-
public func init() : async Bench.BenchSchema {
|
|
15
|
-
let bench = UserBench.init();
|
|
16
|
-
benchOpt := ?bench;
|
|
17
|
-
bench.getSchema();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// public composite query func noop() : async () {};
|
|
21
|
-
|
|
22
|
-
public func runCell(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
23
|
-
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
24
|
-
|
|
25
|
-
let rts_heap_size_before = Prim.rts_heap_size();
|
|
26
|
-
let rts_memory_size_before = Prim.rts_memory_size();
|
|
27
|
-
let rts_total_allocation_before = Prim.rts_total_allocation();
|
|
28
|
-
let rts_mutator_instructions_before = Prim.rts_mutator_instructions();
|
|
29
|
-
let rts_collector_instructions_before = Prim.rts_collector_instructions();
|
|
30
|
-
|
|
31
|
-
let mode : Bench.BenchMode = #replica;
|
|
32
|
-
let instructions = switch(mode) {
|
|
33
|
-
case (#replica) {
|
|
34
|
-
ExperimentalInternetComputer.countInstructions(func() {
|
|
35
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
case (#wasi) {
|
|
39
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
40
|
-
0 : Nat64;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// await noop();
|
|
45
|
-
|
|
46
|
-
// await (func() : async () {})();
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
instructions = Nat64.toNat(instructions);
|
|
50
|
-
rts_heap_size = Prim.rts_heap_size() - rts_heap_size_before;
|
|
51
|
-
rts_memory_size = Prim.rts_memory_size() - rts_memory_size_before;
|
|
52
|
-
rts_total_allocation = Prim.rts_total_allocation() - rts_total_allocation_before;
|
|
53
|
-
rts_mutator_instructions = Prim.rts_mutator_instructions() - rts_mutator_instructions_before;
|
|
54
|
-
rts_collector_instructions = Prim.rts_collector_instructions() - rts_collector_instructions_before;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import Nat64 "mo:base/Nat64";
|
|
2
|
-
import Nat "mo:base/Nat";
|
|
3
|
-
import Debug "mo:base/Debug";
|
|
4
|
-
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
5
|
-
import Prim "mo:prim";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
import UserBench "./user-bench";
|
|
9
|
-
|
|
10
|
-
actor class() {
|
|
11
|
-
var benchOpt : ?Bench.Bench = null;
|
|
12
|
-
|
|
13
|
-
public func init() : async Bench.BenchSchema {
|
|
14
|
-
let bench = UserBench.init();
|
|
15
|
-
benchOpt := ?bench;
|
|
16
|
-
bench.getSchema();
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
func _getStats() : Bench.BenchResult {
|
|
20
|
-
{
|
|
21
|
-
instructions = 0;
|
|
22
|
-
rts_heap_size = Prim.rts_heap_size();
|
|
23
|
-
rts_memory_size = Prim.rts_memory_size();
|
|
24
|
-
rts_total_allocation = Prim.rts_total_allocation();
|
|
25
|
-
rts_mutator_instructions = Prim.rts_mutator_instructions();
|
|
26
|
-
rts_collector_instructions = Prim.rts_collector_instructions();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
func _runCell(rowIndex : Nat, colIndex : Nat) : Bench.BenchResult {
|
|
31
|
-
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
32
|
-
let statsBefore = _getStats();
|
|
33
|
-
|
|
34
|
-
let instructions = ExperimentalInternetComputer.countInstructions(func() {
|
|
35
|
-
bench.runCell(rowIndex, colIndex);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// await (func() : async () {})();
|
|
39
|
-
|
|
40
|
-
let statsAfter = _getStats();
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
instructions = Nat64.toNat(instructions);
|
|
44
|
-
rts_heap_size = statsAfter.rts_heap_size - statsBefore.rts_heap_size;
|
|
45
|
-
rts_memory_size = statsAfter.rts_memory_size - statsBefore.rts_memory_size;
|
|
46
|
-
rts_total_allocation = statsAfter.rts_total_allocation - statsBefore.rts_total_allocation;
|
|
47
|
-
rts_mutator_instructions = statsAfter.rts_mutator_instructions - statsBefore.rts_mutator_instructions;
|
|
48
|
-
rts_collector_instructions = statsAfter.rts_collector_instructions - statsBefore.rts_collector_instructions;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
func _runCellAwait(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
53
|
-
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
54
|
-
let statsBefore = _getStats();
|
|
55
|
-
|
|
56
|
-
let instructions = ExperimentalInternetComputer.countInstructions(func() {
|
|
57
|
-
bench.runCell(rowIndex, colIndex);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
await (func() : async () {})();
|
|
61
|
-
|
|
62
|
-
let statsAfter = _getStats();
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
instructions = Nat64.toNat(instructions);
|
|
66
|
-
rts_heap_size = statsAfter.rts_heap_size - statsBefore.rts_heap_size;
|
|
67
|
-
rts_memory_size = statsAfter.rts_memory_size - statsBefore.rts_memory_size;
|
|
68
|
-
rts_total_allocation = statsAfter.rts_total_allocation - statsBefore.rts_total_allocation;
|
|
69
|
-
rts_mutator_instructions = statsAfter.rts_mutator_instructions - statsBefore.rts_mutator_instructions;
|
|
70
|
-
rts_collector_instructions = statsAfter.rts_collector_instructions - statsBefore.rts_collector_instructions;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
public query func getStats() : async Bench.BenchResult {
|
|
75
|
-
_getStats();
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
public query func runCellQuery(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
79
|
-
_runCell(rowIndex, colIndex);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
public func runCellUpdate(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
83
|
-
await _runCellAwait(rowIndex, colIndex);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
public func runCellUpdateAwait(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
87
|
-
_runCell(rowIndex, colIndex);
|
|
88
|
-
};
|
|
89
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const idlFactory = ({ IDL }) => {
|
|
2
|
-
const BenchSchema = IDL.Record({
|
|
3
|
-
'title': IDL.Text,
|
|
4
|
-
'cols': IDL.Vec(IDL.Text),
|
|
5
|
-
'rows': IDL.Vec(IDL.Text),
|
|
6
|
-
'description': IDL.Text,
|
|
7
|
-
});
|
|
8
|
-
const BenchResult = IDL.Record({
|
|
9
|
-
'instructions': IDL.Nat,
|
|
10
|
-
'rts_memory_size': IDL.Nat,
|
|
11
|
-
'rts_total_allocation': IDL.Nat,
|
|
12
|
-
'rts_collector_instructions': IDL.Nat,
|
|
13
|
-
'rts_mutator_instructions': IDL.Nat,
|
|
14
|
-
'rts_heap_size': IDL.Nat,
|
|
15
|
-
});
|
|
16
|
-
const anon_class_11_1 = IDL.Service({
|
|
17
|
-
'init': IDL.Func([], [BenchSchema], []),
|
|
18
|
-
'runCell': IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
|
|
19
|
-
});
|
|
20
|
-
return anon_class_11_1;
|
|
21
|
-
};
|
|
22
|
-
export const init = ({ IDL }) => { return []; };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
|
-
// Imports and re-exports candid interface
|
|
3
|
-
import { idlFactory } from "./bench.did.js";
|
|
4
|
-
export { idlFactory } from "./bench.did.js";
|
|
5
|
-
/* CANISTER_ID is replaced by webpack based on node environment
|
|
6
|
-
* Note: canister environment variable will be standardized as
|
|
7
|
-
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
|
|
8
|
-
* beginning in dfx 0.15.0
|
|
9
|
-
*/
|
|
10
|
-
export const canisterId = process.env.CANISTER_ID_BENCH ||
|
|
11
|
-
process.env.BENCH_CANISTER_ID;
|
|
12
|
-
export const createActor = (canisterId, options = {}) => {
|
|
13
|
-
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
14
|
-
if (options.agent && options.agentOptions) {
|
|
15
|
-
console.warn("Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.");
|
|
16
|
-
}
|
|
17
|
-
// Fetch root key for certificate validation during development
|
|
18
|
-
if (process.env.DFX_NETWORK !== "ic") {
|
|
19
|
-
agent.fetchRootKey().catch((err) => {
|
|
20
|
-
console.warn("Unable to fetch root key. Check to ensure that your local replica is running");
|
|
21
|
-
console.error(err);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
// Creates an actor with using the candid interface and the HttpAgent
|
|
25
|
-
return Actor.createActor(idlFactory, {
|
|
26
|
-
agent,
|
|
27
|
-
canisterId,
|
|
28
|
-
...options.actorOptions,
|
|
29
|
-
});
|
|
30
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
|
-
// Imports and re-exports candid interface
|
|
3
|
-
import { idlFactory } from "./main.did.js";
|
|
4
|
-
export { idlFactory } from "./main.did.js";
|
|
5
|
-
/* CANISTER_ID is replaced by webpack based on node environment
|
|
6
|
-
* Note: canister environment variable will be standardized as
|
|
7
|
-
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
|
|
8
|
-
* beginning in dfx 0.15.0
|
|
9
|
-
*/
|
|
10
|
-
export const canisterId = process.env.CANISTER_ID_MAIN ||
|
|
11
|
-
process.env.MAIN_CANISTER_ID;
|
|
12
|
-
export const createActor = (canisterId, options = {}) => {
|
|
13
|
-
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
14
|
-
if (options.agent && options.agentOptions) {
|
|
15
|
-
console.warn("Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.");
|
|
16
|
-
}
|
|
17
|
-
// Fetch root key for certificate validation during development
|
|
18
|
-
if (process.env.DFX_NETWORK !== "ic") {
|
|
19
|
-
agent.fetchRootKey().catch((err) => {
|
|
20
|
-
console.warn("Unable to fetch root key. Check to ensure that your local replica is running");
|
|
21
|
-
console.error(err);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
// Creates an actor with using the candid interface and the HttpAgent
|
|
25
|
-
return Actor.createActor(idlFactory, {
|
|
26
|
-
agent,
|
|
27
|
-
canisterId,
|
|
28
|
-
...options.actorOptions,
|
|
29
|
-
});
|
|
30
|
-
};
|