@ic-reactor/core 1.2.1 → 1.2.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ yarn add @ic-reactor/core
19
19
  or you can use the UMD version:
20
20
 
21
21
  ```html
22
- <script src="https://github.com/B3Pay/ic-reactor/releases/download/v1.2.0/ic-reactor-core.min.js"></script>
22
+ <script src="https://github.com/B3Pay/ic-reactor/releases/download/v1.2.1/ic-reactor-core.min.js"></script>
23
23
  ```
24
24
 
25
25
  ### Using `createReactorCore`
@@ -8,6 +8,7 @@ export declare class ActorManager<A = BaseActor> {
8
8
  private _agentManager;
9
9
  private _unsubscribeAgent;
10
10
  private _subscribers;
11
+ methods: Array<FunctionName<A>>;
11
12
  canisterId: CanisterId;
12
13
  actorStore: ActorStore<A>;
13
14
  visitFunction: VisitService<A>;
@@ -20,6 +21,7 @@ export declare class ActorManager<A = BaseActor> {
20
21
  }>) => void;
21
22
  constructor(actorConfig: ActorManagerParameters);
22
23
  initialize: (options?: UpdateAgentParameters) => Promise<void>;
24
+ extractMethodNames: () => Array<FunctionName<A>>;
23
25
  extractService: () => VisitService<A>;
24
26
  extractInterface: () => IDL.ServiceClass;
25
27
  private initializeActor;
@@ -17,6 +17,7 @@ class ActorManager {
17
17
  constructor(actorConfig) {
18
18
  this._actor = null;
19
19
  this._subscribers = [];
20
+ this.methods = [];
20
21
  this.initialState = {
21
22
  methodState: {},
22
23
  initializing: false,
@@ -37,6 +38,10 @@ class ActorManager {
37
38
  this.initialize = (options) => __awaiter(this, void 0, void 0, function* () {
38
39
  yield this._agentManager.updateAgent(options);
39
40
  });
41
+ this.extractMethodNames = () => {
42
+ const iface = this.extractInterface();
43
+ return iface._fields.map((service) => service[0]);
44
+ };
40
45
  this.extractService = () => {
41
46
  const iface = this.extractInterface();
42
47
  return iface._fields.reduce((acc, service) => {
@@ -74,6 +79,7 @@ class ActorManager {
74
79
  if (!this._actor) {
75
80
  throw new Error("Failed to initialize actor");
76
81
  }
82
+ this.methods = this.extractMethodNames();
77
83
  this.updateState({
78
84
  initializing: false,
79
85
  initialized: true,
@@ -116,9 +122,12 @@ class ActorManager {
116
122
  this._subscribers.forEach((unsubscribe) => unsubscribe());
117
123
  };
118
124
  const { agentManager, canisterId, idlFactory, withVisitor = false, withDevtools = false, initializeOnCreate = true, } = actorConfig;
125
+ if (!canisterId) {
126
+ throw new Error("CanisterId is required!");
127
+ }
128
+ this._agentManager = agentManager;
119
129
  this.canisterId = canisterId;
120
130
  this._idlFactory = idlFactory;
121
- this._agentManager = agentManager;
122
131
  // Initialize stores
123
132
  this.actorStore = (0, helper_1.createStoreWithOptionalDevtools)(this.initialState, {
124
133
  withDevtools,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/core",
3
- "version": "1.2.1",
3
+ "version": "1.2.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",
@@ -52,5 +52,5 @@
52
52
  "engines": {
53
53
  "node": ">=10"
54
54
  },
55
- "gitHead": "c45e2ae6da1eee146b9e5f3178318de4d66419de"
55
+ "gitHead": "9d79b40cd3306d2f363ac7ab3a6b9815300648d6"
56
56
  }