@ic-reactor/core 1.1.1 → 1.1.2
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CanisterId, ActorMethodParameters, ActorMethodReturnType, ActorStore, ActorManagerParameters, FunctionName, VisitService, BaseActor, ActorMethodState } from "./types";
|
|
2
|
+
import { IDL } from "@dfinity/candid";
|
|
2
3
|
import type { AgentManager } from "../agent";
|
|
3
4
|
import type { UpdateAgentParameters } from "../../types";
|
|
4
5
|
export declare class ActorManager<A = BaseActor> {
|
|
@@ -20,6 +21,7 @@ export declare class ActorManager<A = BaseActor> {
|
|
|
20
21
|
constructor(actorConfig: ActorManagerParameters);
|
|
21
22
|
initialize: (options?: UpdateAgentParameters) => Promise<void>;
|
|
22
23
|
extractService: () => VisitService<A>;
|
|
24
|
+
extractInterface: () => IDL.ServiceClass;
|
|
23
25
|
private initializeActor;
|
|
24
26
|
callMethod: <M extends FunctionName<A>>(functionName: M, ...args: ActorMethodParameters<A[M]>) => Promise<ActorMethodReturnType<A[M]>>;
|
|
25
27
|
get agentManager(): AgentManager;
|
|
@@ -38,10 +38,8 @@ class ActorManager {
|
|
|
38
38
|
yield this._agentManager.updateAgent(options);
|
|
39
39
|
});
|
|
40
40
|
this.extractService = () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return agent_1.Actor.interfaceOf(this._actor)._fields.reduce((acc, service) => {
|
|
41
|
+
const iface = this.extractInterface();
|
|
42
|
+
return iface._fields.reduce((acc, service) => {
|
|
45
43
|
const functionName = service[0];
|
|
46
44
|
const type = service[1];
|
|
47
45
|
const visit = ((extractorClass, data) => {
|
|
@@ -51,6 +49,12 @@ class ActorManager {
|
|
|
51
49
|
return acc;
|
|
52
50
|
}, {});
|
|
53
51
|
};
|
|
52
|
+
this.extractInterface = () => {
|
|
53
|
+
if (this._actor === null) {
|
|
54
|
+
throw new Error("For extracting interface, actor must be initialized");
|
|
55
|
+
}
|
|
56
|
+
return agent_1.Actor.interfaceOf(this._actor);
|
|
57
|
+
};
|
|
54
58
|
this.initializeActor = (agent) => {
|
|
55
59
|
console.info(`Initializing actor ${this.canisterId} on ${agent.isLocal() ? "local" : "ic"} network`);
|
|
56
60
|
const { _idlFactory, canisterId } = this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A library for intracting with the Internet Computer canisters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=10"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5203d7142eda0153581cb3b6de00e12fc128eb33"
|
|
50
50
|
}
|