@ic-reactor/core 1.0.0 → 1.0.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 +162 -94
- package/dist/actor/index.d.ts +2 -2
- package/dist/actor/index.js +0 -15
- package/dist/agent/index.d.ts +0 -4
- package/dist/agent/index.js +3 -11
- package/dist/{tools/candid.d.ts → candid/index.d.ts} +1 -4
- package/dist/{tools/candid.js → candid/index.js} +3 -4
- package/dist/index.d.ts +23 -23
- package/dist/index.js +48 -35
- package/dist/tools/constants.d.ts +6 -0
- package/dist/tools/constants.js +9 -0
- package/dist/tools/helper.d.ts +3 -2
- package/dist/tools/helper.js +10 -4
- package/dist/tools/index.d.ts +1 -2
- package/dist/tools/index.js +1 -2
- package/dist/types.d.ts +8 -4
- package/dist/types.js +17 -0
- package/package.json +3 -3
- /package/dist/{tools → candid}/types.d.ts +0 -0
- /package/dist/{tools → candid}/types.js +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
The `@ic-reactor/core` package provides a streamlined way to interact with the Internet Computer (IC) by simplifying agent and actor management. It offers utilities for creating and managing IC agents, enabling seamless communication with canisters through a friendly API.
|
|
1
|
+
The `@ic-reactor/core` package provides a streamlined way to interact with the Internet Computer (IC). It simplifies agent and actor management, ensuring type-safe communication with canisters. This package offers utilities for creating and managing IC agents, enabling seamless interaction through a friendly API.
|
|
4
2
|
|
|
5
3
|
## Installation
|
|
6
4
|
|
|
@@ -18,111 +16,92 @@ npm install @ic-reactor/core
|
|
|
18
16
|
yarn add @ic-reactor/core
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`@ic-reactor/core` can be utilized in two primary ways: automatic agent creation and manual agent management. Below are examples of both approaches to suit your project's needs.
|
|
24
|
-
|
|
25
|
-
### Automatic Agent Creation
|
|
19
|
+
### Using `createReactorCore`
|
|
26
20
|
|
|
27
|
-
For ease of use, the `
|
|
21
|
+
For ease of use, the `createReactorCore` factory function automatically sets up a new Reactor instance, managing the agent and its state internally, and providing a simple API for authenticating, querying, and updating actors.
|
|
28
22
|
|
|
29
23
|
**Example:**
|
|
30
24
|
|
|
31
25
|
```typescript
|
|
32
|
-
import {
|
|
33
|
-
import { candid, canisterId, idlFactory } from "./candid"
|
|
26
|
+
import { createReactorCore } from "@ic-reactor/core"
|
|
27
|
+
import { candid, canisterId, idlFactory } from "./declarations/candid"
|
|
34
28
|
|
|
35
29
|
type Candid = typeof candid
|
|
36
30
|
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const identity = await authenticate()
|
|
44
|
-
const data = await callMethod("version")
|
|
45
|
-
console.log(data)
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Manual Agent Creation
|
|
49
|
-
|
|
50
|
-
If you require more control over the agent's lifecycle or configuration, `@ic-reactor/core` provides the `createAgentManager` function for manual agent instantiation.
|
|
51
|
-
|
|
52
|
-
**IC Agent Example:**
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
// agent.ts
|
|
56
|
-
import { createAgentManager } from "@ic-reactor/core"
|
|
57
|
-
|
|
58
|
-
export const agentManager = createAgentManager() // Connects to IC network by default
|
|
59
|
-
|
|
60
|
-
// Usage example
|
|
61
|
-
await agentManager.authenticate()
|
|
62
|
-
// Then use the store to access the authClient, identity, and more...
|
|
63
|
-
const { authClient, identity, authenticating } =
|
|
64
|
-
agentManager.authStore.getState()
|
|
31
|
+
const { queryCall, updateCall, getPrincipal, login } =
|
|
32
|
+
createReactorCore<Candid>({
|
|
33
|
+
canisterId,
|
|
34
|
+
idlFactory,
|
|
35
|
+
withProcessEnv: true, // will use process.env.DFX_NETWORK
|
|
36
|
+
})
|
|
65
37
|
```
|
|
66
38
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
For development purposes, you might want to connect to a local instance of the IC network:
|
|
39
|
+
You can find All available methods are returned from the `createReactorCore` function here: [ReactorCore](https://b3pay.github.io/ic-reactor/interfaces/core.types.ReactorCore.html)
|
|
70
40
|
|
|
71
41
|
```typescript
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
42
|
+
// later in your code
|
|
43
|
+
await login({
|
|
44
|
+
onSuccess: () => {
|
|
45
|
+
console.log("Logged in successfully")
|
|
46
|
+
},
|
|
47
|
+
onError: (error) => {
|
|
48
|
+
console.error("Failed to login:", error)
|
|
49
|
+
},
|
|
78
50
|
})
|
|
79
|
-
```
|
|
80
51
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
host: "http://localhost:8000",
|
|
52
|
+
// queryCall, will automatically call and return a promise with the result
|
|
53
|
+
const { dataPromise, call } = queryCall({
|
|
54
|
+
functionName: "icrc1_balance_of",
|
|
55
|
+
args: [{ owner: getPrincipal(), subaccount: [] }],
|
|
86
56
|
})
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Creating an Actor Manager
|
|
90
|
-
|
|
91
|
-
Once you have an agent manager, use `createActorManager` to instantiate an actor manager for calling methods on your canisters.
|
|
92
57
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
58
|
+
console.log(await dataPromise)
|
|
59
|
+
|
|
60
|
+
// updateCall
|
|
61
|
+
const { call, subscribe } = updateCall({
|
|
62
|
+
functionName: "icrc1_transfer",
|
|
63
|
+
args: [
|
|
64
|
+
{
|
|
65
|
+
to: { owner: getPrincipal(), subaccount: [] },
|
|
66
|
+
amount: BigInt(10000000000),
|
|
67
|
+
fee: [],
|
|
68
|
+
memo: [],
|
|
69
|
+
created_at_time: [],
|
|
70
|
+
from_subaccount: [],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
})
|
|
74
|
+
// subscribe to the update call
|
|
75
|
+
subscribe(({ loading, error, data }) => {
|
|
76
|
+
console.log({ loading, error, data })
|
|
105
77
|
})
|
|
106
78
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
console.log(data)
|
|
79
|
+
const result = await call()
|
|
80
|
+
console.log(result)
|
|
110
81
|
```
|
|
111
82
|
|
|
112
83
|
### Managing Multiple Actors
|
|
113
84
|
|
|
114
|
-
When interacting with multiple canisters using `@ic-reactor/core`, you can create separate
|
|
115
|
-
|
|
116
|
-
|
|
85
|
+
When interacting with multiple canisters using `@ic-reactor/core`, you need one agent manager for each canister. This way, you can create separate reactor for each canister. This enables modular interaction with different services on the Internet Computer,
|
|
86
|
+
and allows you to manage the state of each actor independently.
|
|
87
|
+
Here's how to adjust the example to handle methods that require multiple arguments:
|
|
117
88
|
|
|
118
|
-
|
|
89
|
+
Fist you need to create a agent manager:
|
|
119
90
|
|
|
120
91
|
```typescript
|
|
121
|
-
//
|
|
92
|
+
// agent.ts
|
|
93
|
+
import { createAgentManager } from "@ic-reactor/core"
|
|
122
94
|
|
|
95
|
+
export const agentManager = createAgentManager() // Connects to IC network by default
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then you can create a reactor for each canister:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// Assuming you've already set up `candidA`, `candidB`, and `agentManager`
|
|
123
102
|
import { createActorManager } from "@ic-reactor/core"
|
|
124
|
-
import
|
|
125
|
-
import
|
|
103
|
+
import candidA from "./declarations/candidA"
|
|
104
|
+
import candidB from "./declarations/candidB"
|
|
126
105
|
import { agentManager } from "./agent"
|
|
127
106
|
|
|
128
107
|
type CandidA = typeof candidA
|
|
@@ -141,18 +120,20 @@ const actorB = createActorManager<CandidB>({
|
|
|
141
120
|
})
|
|
142
121
|
```
|
|
143
122
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
To call a method on a canister that requires multiple arguments, pass the method name followed by the arguments as separate parameters to `callMethod`:
|
|
123
|
+
You can now use the `actorA` and `actorB` instances to interact with their respective canisters:
|
|
147
124
|
|
|
148
125
|
```typescript
|
|
149
126
|
// Example usage with CanisterA calling a method that requires one argument
|
|
150
|
-
const
|
|
151
|
-
|
|
127
|
+
const { dataPromise: versionActorA } = actorA.queryCall({
|
|
128
|
+
functionName: "version",
|
|
129
|
+
})
|
|
130
|
+
console.log("Response from CanisterA method:", await versionActorA)
|
|
152
131
|
|
|
153
132
|
// Example usage with CanisterB calling a different method also with two arguments
|
|
154
|
-
const
|
|
155
|
-
|
|
133
|
+
const { dataPromise: versionActorB } = actorB.queryCall({
|
|
134
|
+
functionName: "version",
|
|
135
|
+
})
|
|
136
|
+
console.log("Response from CanisterB method:", await versionActorB)
|
|
156
137
|
```
|
|
157
138
|
|
|
158
139
|
### Using Candid Adapter
|
|
@@ -177,12 +158,12 @@ try {
|
|
|
177
158
|
}
|
|
178
159
|
```
|
|
179
160
|
|
|
180
|
-
### Using `
|
|
161
|
+
### Using `createReactorCore` with `CandidAdapter`
|
|
181
162
|
|
|
182
|
-
You can use the `candidAdapter` to fetch the Candid definition and then pass it to the `
|
|
163
|
+
You can use the `candidAdapter` to fetch the Candid definition and then pass it to the `createReactorCore` function.
|
|
183
164
|
|
|
184
165
|
```typescript
|
|
185
|
-
import {
|
|
166
|
+
import { createReactorCore, createCandidAdapter } from "@ic-reactor/core"
|
|
186
167
|
import { agentManager } from "./agent"
|
|
187
168
|
|
|
188
169
|
const candidAdapter = createCandidAdapter({ agentManager })
|
|
@@ -192,7 +173,7 @@ const canisterId = "ryjl3-tyaaa-aaaaa-aaaba-cai" // NNS ICP Ledger Canister
|
|
|
192
173
|
// Usage example
|
|
193
174
|
try {
|
|
194
175
|
const { idlFactory } = await candidAdapter.getCandidDefinition(canisterId)
|
|
195
|
-
const { callMethod } =
|
|
176
|
+
const { callMethod } = createReactorCore({
|
|
196
177
|
agentManager,
|
|
197
178
|
canisterId,
|
|
198
179
|
idlFactory,
|
|
@@ -205,6 +186,93 @@ try {
|
|
|
205
186
|
}
|
|
206
187
|
```
|
|
207
188
|
|
|
208
|
-
|
|
189
|
+
### Using store to lower level control
|
|
209
190
|
|
|
210
|
-
|
|
191
|
+
If you require more control over the state management, you can use the `createReactorStore` function to create a store that provides methods for querying and updating actors.
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import { createReactorStore } from "@ic-reactor/core"
|
|
195
|
+
import { candid, canisterId, idlFactory } from "./declarations/candid"
|
|
196
|
+
|
|
197
|
+
type Candid = typeof candid
|
|
198
|
+
|
|
199
|
+
const { agentManager, callMethod } = createReactorStore<Candid>({
|
|
200
|
+
canisterId,
|
|
201
|
+
idlFactory,
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
// Usage example
|
|
205
|
+
await agentManager.authenticate()
|
|
206
|
+
const authClient = agentManager.getAuthClient()
|
|
207
|
+
|
|
208
|
+
authClient?.login({
|
|
209
|
+
onSuccess: () => {
|
|
210
|
+
console.log("Logged in successfully")
|
|
211
|
+
},
|
|
212
|
+
onError: (error) => {
|
|
213
|
+
console.error("Failed to login:", error)
|
|
214
|
+
},
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
// Call a method
|
|
218
|
+
const version = callMethod("version")
|
|
219
|
+
|
|
220
|
+
console.log("Response from version method:", await version)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**IC Agent Example:**
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
// agent.ts
|
|
227
|
+
import { createAgentManager } from "@ic-reactor/core"
|
|
228
|
+
|
|
229
|
+
export const agentManager = createAgentManager() // Connects to IC network by default
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Local Agent Example:**
|
|
233
|
+
|
|
234
|
+
For development purposes, you might want to connect to a local instance of the IC network:
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
// agent.ts
|
|
238
|
+
import { createAgentManager } from "@ic-reactor/core"
|
|
239
|
+
|
|
240
|
+
export const agentManager = createAgentManager({
|
|
241
|
+
isLocalEnv: true,
|
|
242
|
+
port: 8000, // Default port is 4943
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Alternatively, you can specify a host directly:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
// agent.ts
|
|
250
|
+
import { createAgentManager } from "@ic-reactor/core"
|
|
251
|
+
|
|
252
|
+
export const agentManager = createAgentManager({
|
|
253
|
+
host: "http://localhost:8000",
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Creating an Actor Manager
|
|
258
|
+
|
|
259
|
+
You can use Actor Managers to create your implementation of an actor. This allows you to manage the actor's lifecycle and state, as well as interact with the actor's methods.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
// actor.ts
|
|
263
|
+
import { createActorManager } from "@ic-reactor/core"
|
|
264
|
+
import { candid, canisterId, idlFactory } from "./declarations/candid"
|
|
265
|
+
import { agentManager } from "./agent"
|
|
266
|
+
|
|
267
|
+
type Candid = typeof candid
|
|
268
|
+
|
|
269
|
+
const candidActor = createActorManager<Candid>({
|
|
270
|
+
agentManager,
|
|
271
|
+
canisterId,
|
|
272
|
+
idlFactory,
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
// Usage example
|
|
276
|
+
const data = await candidActor.callMethod("version")
|
|
277
|
+
console.log(data)
|
|
278
|
+
```
|
package/dist/actor/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HttpAgent } from "@dfinity/agent";
|
|
2
2
|
import type { CanisterId, ActorMethodArgs, ActorMethodReturnType, ActorStore, ActorManagerOptions, FunctionName, VisitService, BaseActor, ActorMethodState } from "./types";
|
|
3
|
-
import type { AgentManager
|
|
4
|
-
|
|
3
|
+
import type { AgentManager } from "../agent";
|
|
4
|
+
import type { UpdateAgentOptions } from "../types";
|
|
5
5
|
export declare class ActorManager<A = BaseActor> {
|
|
6
6
|
private _actor;
|
|
7
7
|
private _idlFactory;
|
package/dist/actor/index.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -28,7 +14,6 @@ exports.ActorManager = void 0;
|
|
|
28
14
|
const agent_1 = require("@dfinity/agent");
|
|
29
15
|
const helper_1 = require("../tools/helper");
|
|
30
16
|
const candid_1 = require("@dfinity/candid");
|
|
31
|
-
__exportStar(require("./types"), exports);
|
|
32
17
|
class ActorManager {
|
|
33
18
|
constructor(actorConfig) {
|
|
34
19
|
this._actor = null;
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { HttpAgent } from "@dfinity/agent";
|
|
2
2
|
import type { AgentStore, AgentManagerOptions, UpdateAgentOptions, AuthStore } from "./types";
|
|
3
|
-
export * from "./types";
|
|
4
|
-
export declare const IC_HOST_NETWORK_URI = "https://ic0.app";
|
|
5
|
-
export declare const LOCAL_HOST_NETWORK_URI = "http://127.0.0.1:4943";
|
|
6
3
|
export declare class AgentManager {
|
|
7
4
|
private _agent;
|
|
8
5
|
private _subscribers;
|
|
@@ -21,7 +18,6 @@ export declare class AgentManager {
|
|
|
21
18
|
updateAgent: (options?: UpdateAgentOptions) => Promise<void>;
|
|
22
19
|
authenticate: () => Promise<import("@dfinity/agent").Identity>;
|
|
23
20
|
getAgent: () => HttpAgent;
|
|
24
|
-
getAgentStore: () => AgentStore;
|
|
25
21
|
getAgentState: AgentStore["getState"];
|
|
26
22
|
subscribeAgentState: AgentStore["subscribe"];
|
|
27
23
|
getAuthState: AuthStore["getState"];
|
package/dist/agent/index.js
CHANGED
|
@@ -15,9 +15,6 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
-
};
|
|
21
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
19
|
if (mod && mod.__esModule) return mod;
|
|
23
20
|
var result = {};
|
|
@@ -46,12 +43,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
46
43
|
return t;
|
|
47
44
|
};
|
|
48
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.AgentManager =
|
|
46
|
+
exports.AgentManager = void 0;
|
|
50
47
|
const agent_1 = require("@dfinity/agent");
|
|
51
48
|
const helper_1 = require("../tools/helper");
|
|
52
|
-
|
|
53
|
-
exports.IC_HOST_NETWORK_URI = "https://ic0.app";
|
|
54
|
-
exports.LOCAL_HOST_NETWORK_URI = "http://127.0.0.1:4943";
|
|
49
|
+
const constants_1 = require("../tools/constants");
|
|
55
50
|
class AgentManager {
|
|
56
51
|
constructor(options) {
|
|
57
52
|
this._subscribers = [];
|
|
@@ -137,9 +132,6 @@ class AgentManager {
|
|
|
137
132
|
this.getAgent = () => {
|
|
138
133
|
return this._agent;
|
|
139
134
|
};
|
|
140
|
-
this.getAgentStore = () => {
|
|
141
|
-
return this.agentStore;
|
|
142
|
-
};
|
|
143
135
|
this.getAgentState = () => {
|
|
144
136
|
return this.agentStore.getState();
|
|
145
137
|
};
|
|
@@ -170,7 +162,7 @@ class AgentManager {
|
|
|
170
162
|
? optionHost.includes("localhost")
|
|
171
163
|
? optionHost.replace("localhost", "127.0.0.1")
|
|
172
164
|
: optionHost
|
|
173
|
-
:
|
|
165
|
+
: constants_1.IC_HOST_NETWORK_URI;
|
|
174
166
|
this.agentStore = (0, helper_1.createStoreWithOptionalDevtools)(this.initialAgentState, {
|
|
175
167
|
withDevtools,
|
|
176
168
|
store: "agent",
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { HttpAgent } from "@dfinity/agent";
|
|
2
|
-
import { CanisterId } from "../
|
|
3
|
-
import { CandidAdapterOptions, CandidDefenition } from "./types";
|
|
4
|
-
export declare const DEFAULT_LOCAL_DIDJS_ID = "bd3sg-teaaa-aaaaa-qaaba-cai";
|
|
5
|
-
export declare const DEFAULT_IC_DIDJS_ID = "a4gq6-oaaaa-aaaab-qaa4q-cai";
|
|
2
|
+
import type { CanisterId, CandidAdapterOptions, CandidDefenition } from "../types";
|
|
6
3
|
export declare class CandidAdapter {
|
|
7
4
|
agent: HttpAgent;
|
|
8
5
|
didjsCanisterId: string;
|
|
@@ -9,11 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CandidAdapter =
|
|
12
|
+
exports.CandidAdapter = void 0;
|
|
13
13
|
const agent_1 = require("@dfinity/agent");
|
|
14
14
|
const principal_1 = require("@dfinity/principal");
|
|
15
|
-
|
|
16
|
-
exports.DEFAULT_IC_DIDJS_ID = "a4gq6-oaaaa-aaaab-qaa4q-cai";
|
|
15
|
+
const constants_1 = require("../tools/constants");
|
|
17
16
|
class CandidAdapter {
|
|
18
17
|
constructor({ agentManager, agent, didjsCanisterId }) {
|
|
19
18
|
if (agent) {
|
|
@@ -32,7 +31,7 @@ class CandidAdapter {
|
|
|
32
31
|
this.didjsCanisterId = didjsCanisterId || this.getDefaultDidJsId();
|
|
33
32
|
}
|
|
34
33
|
getDefaultDidJsId() {
|
|
35
|
-
return this.agent.isLocal() ?
|
|
34
|
+
return this.agent.isLocal() ? constants_1.DEFAULT_LOCAL_DIDJS_ID : constants_1.DEFAULT_IC_DIDJS_ID;
|
|
36
35
|
}
|
|
37
36
|
getCandidDefinition(canisterId) {
|
|
38
37
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import type { ActorManagerOptions, BaseActor } from "./actor/types";
|
|
2
|
-
import type { AgentManagerOptions } from "./agent/types";
|
|
3
1
|
import { ActorManager } from "./actor";
|
|
4
2
|
import { AgentManager } from "./agent";
|
|
5
|
-
import type {
|
|
6
|
-
import { CandidAdapter
|
|
7
|
-
export * from "./types";
|
|
8
|
-
export * from "./actor";
|
|
9
|
-
export * from "./agent";
|
|
10
|
-
export * from "./tools";
|
|
3
|
+
import type { ActorManagerOptions, BaseActor, AgentManagerOptions, ReactorCore, CreateReactorOptions, CreateReactorStoreOptions, CandidAdapterOptions } from "./types";
|
|
4
|
+
import { CandidAdapter } from "./candid";
|
|
11
5
|
/**
|
|
6
|
+
* The Core module is the main entry point for the library.
|
|
12
7
|
* Create a new actor manager with the given options.
|
|
13
8
|
* Its create a new agent manager if not provided.
|
|
14
9
|
*
|
|
15
10
|
* @category Main
|
|
16
|
-
* @includeExample ./packages/core/README.md:
|
|
11
|
+
* @includeExample ./packages/core/README.md:26-80
|
|
12
|
+
*/
|
|
13
|
+
export declare const createReactorCore: <A = BaseActor>({ isLocalEnv, withProcessEnv, ...options }: CreateReactorOptions) => ReactorCore<A>;
|
|
14
|
+
/**
|
|
15
|
+
* The `CandidAdapter` class is used to interact with a canister and retrieve its Candid interface definition.
|
|
16
|
+
* It provides methods to fetch the Candid definition either from the canister's metadata or by using a temporary hack method.
|
|
17
|
+
* If both methods fail, it throws an error.
|
|
18
|
+
*
|
|
19
|
+
* @category Main
|
|
20
|
+
* @includeExample ./packages/core/README.md:145-186
|
|
17
21
|
*/
|
|
18
|
-
export declare const
|
|
22
|
+
export declare const createCandidAdapter: (options: CandidAdapterOptions) => CandidAdapter;
|
|
19
23
|
/**
|
|
20
24
|
* Create a new actor manager with the given options.
|
|
21
25
|
* Its create a new agent manager if not provided.
|
|
22
26
|
* It also creates a new actor manager with the given options.
|
|
23
27
|
*
|
|
24
28
|
* @category Main
|
|
25
|
-
* @includeExample ./packages/core/README.md:
|
|
29
|
+
* @includeExample ./packages/core/README.md:194-220
|
|
26
30
|
*/
|
|
27
|
-
export declare const
|
|
31
|
+
export declare const createReactorStore: <A = BaseActor>(options: CreateReactorStoreOptions) => ActorManager<A>;
|
|
28
32
|
/**
|
|
29
33
|
* Agent manager handles the lifecycle of the `@dfinity/agent`.
|
|
30
34
|
* It is responsible for creating agent and managing the agent's state.
|
|
@@ -32,7 +36,7 @@ export declare const createReActorStore: <A = BaseActor>(options: CreateReActorS
|
|
|
32
36
|
* login and logout to the internet identity.
|
|
33
37
|
*
|
|
34
38
|
* @category Main
|
|
35
|
-
* @includeExample ./packages/core/README.md:
|
|
39
|
+
* @includeExample ./packages/core/README.md:226-254
|
|
36
40
|
*/
|
|
37
41
|
export declare const createAgentManager: (options?: AgentManagerOptions) => AgentManager;
|
|
38
42
|
/**
|
|
@@ -42,15 +46,11 @@ export declare const createAgentManager: (options?: AgentManagerOptions) => Agen
|
|
|
42
46
|
* It also provides a way to interact with the actor's state.
|
|
43
47
|
*
|
|
44
48
|
* @category Main
|
|
45
|
-
* @includeExample ./packages/core/README.md:
|
|
49
|
+
* @includeExample ./packages/core/README.md:262-277
|
|
46
50
|
*/
|
|
47
51
|
export declare const createActorManager: <A = BaseActor>(options: ActorManagerOptions) => ActorManager<A>;
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @category Main
|
|
54
|
-
* @includeExample ./packages/core/README.md:164-205
|
|
55
|
-
*/
|
|
56
|
-
export declare const createCandidAdapter: (options: CandidAdapterOptions) => CandidAdapter;
|
|
52
|
+
export * from "./actor";
|
|
53
|
+
export * from "./agent";
|
|
54
|
+
export * from "./candid";
|
|
55
|
+
export * as types from "./types";
|
|
56
|
+
export * as tools from "./tools";
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,21 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,31 +46,24 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
34
46
|
return t;
|
|
35
47
|
};
|
|
36
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
49
|
+
exports.tools = exports.types = exports.createActorManager = exports.createAgentManager = exports.createReactorStore = exports.createCandidAdapter = exports.createReactorCore = void 0;
|
|
38
50
|
const actor_1 = require("./actor");
|
|
39
51
|
const agent_1 = require("./agent");
|
|
52
|
+
const constants_1 = require("./tools/constants");
|
|
40
53
|
const tools_1 = require("./tools");
|
|
41
|
-
|
|
42
|
-
__exportStar(require("./actor"), exports);
|
|
43
|
-
__exportStar(require("./agent"), exports);
|
|
44
|
-
__exportStar(require("./tools"), exports);
|
|
54
|
+
const candid_1 = require("./candid");
|
|
45
55
|
/**
|
|
56
|
+
* The Core module is the main entry point for the library.
|
|
46
57
|
* Create a new actor manager with the given options.
|
|
47
58
|
* Its create a new agent manager if not provided.
|
|
48
59
|
*
|
|
49
60
|
* @category Main
|
|
50
|
-
* @includeExample ./packages/core/README.md:
|
|
61
|
+
* @includeExample ./packages/core/README.md:26-80
|
|
51
62
|
*/
|
|
52
|
-
const
|
|
63
|
+
const createReactorCore = (_a) => {
|
|
53
64
|
var { isLocalEnv, withProcessEnv = false } = _a, options = __rest(_a, ["isLocalEnv", "withProcessEnv"]);
|
|
54
|
-
isLocalEnv =
|
|
55
|
-
|
|
56
|
-
(withProcessEnv
|
|
57
|
-
? typeof process !== "undefined" &&
|
|
58
|
-
(process.env.DFX_NETWORK === "local" ||
|
|
59
|
-
process.env.NODE_ENV === "development")
|
|
60
|
-
: false);
|
|
61
|
-
const _b = (0, exports.createReActorStore)(Object.assign({ isLocalEnv }, options)), { subscribeActorState, updateMethodState, callMethod, getState, agentManager } = _b, rest = __rest(_b, ["subscribeActorState", "updateMethodState", "callMethod", "getState", "agentManager"]);
|
|
65
|
+
isLocalEnv = isLocalEnv || (withProcessEnv ? (0, tools_1.isInLocalOrDevelopment)() : false);
|
|
66
|
+
const _b = (0, exports.createReactorStore)(Object.assign({ isLocalEnv }, options)), { subscribeActorState, updateMethodState, callMethod, getState, agentManager } = _b, rest = __rest(_b, ["subscribeActorState", "updateMethodState", "callMethod", "getState", "agentManager"]);
|
|
62
67
|
const reActorMethod = (functionName, ...args) => {
|
|
63
68
|
const requestHash = (0, tools_1.generateRequestHash)(args);
|
|
64
69
|
const updateState = (newState = {}) => {
|
|
@@ -143,9 +148,12 @@ const createReActor = (_a) => {
|
|
|
143
148
|
if (!authClient) {
|
|
144
149
|
yield agentManager.authenticate();
|
|
145
150
|
}
|
|
151
|
+
if (!authClient) {
|
|
152
|
+
throw new Error("Auth client not initialized");
|
|
153
|
+
}
|
|
146
154
|
yield authClient.login(Object.assign({ identityProvider: isLocalEnv
|
|
147
|
-
?
|
|
148
|
-
:
|
|
155
|
+
? constants_1.IC_INTERNET_IDENTITY_PROVIDER
|
|
156
|
+
: constants_1.LOCAL_INTERNET_IDENTITY_PROVIDER }, options));
|
|
149
157
|
});
|
|
150
158
|
const logout = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
159
|
const authClient = agentManager.getAuthClient();
|
|
@@ -163,16 +171,28 @@ const createReActor = (_a) => {
|
|
|
163
171
|
logout,
|
|
164
172
|
subscribeActorState }, agentManager), rest);
|
|
165
173
|
};
|
|
166
|
-
exports.
|
|
174
|
+
exports.createReactorCore = createReactorCore;
|
|
175
|
+
/**
|
|
176
|
+
* The `CandidAdapter` class is used to interact with a canister and retrieve its Candid interface definition.
|
|
177
|
+
* It provides methods to fetch the Candid definition either from the canister's metadata or by using a temporary hack method.
|
|
178
|
+
* If both methods fail, it throws an error.
|
|
179
|
+
*
|
|
180
|
+
* @category Main
|
|
181
|
+
* @includeExample ./packages/core/README.md:145-186
|
|
182
|
+
*/
|
|
183
|
+
const createCandidAdapter = (options) => {
|
|
184
|
+
return new candid_1.CandidAdapter(options);
|
|
185
|
+
};
|
|
186
|
+
exports.createCandidAdapter = createCandidAdapter;
|
|
167
187
|
/**
|
|
168
188
|
* Create a new actor manager with the given options.
|
|
169
189
|
* Its create a new agent manager if not provided.
|
|
170
190
|
* It also creates a new actor manager with the given options.
|
|
171
191
|
*
|
|
172
192
|
* @category Main
|
|
173
|
-
* @includeExample ./packages/core/README.md:
|
|
193
|
+
* @includeExample ./packages/core/README.md:194-220
|
|
174
194
|
*/
|
|
175
|
-
const
|
|
195
|
+
const createReactorStore = (options) => {
|
|
176
196
|
const { idlFactory, canisterId, withDevtools = false, initializeOnCreate = true, withVisitor = false, agentManager: maybeAgentManager } = options, agentOptions = __rest(options, ["idlFactory", "canisterId", "withDevtools", "initializeOnCreate", "withVisitor", "agentManager"]);
|
|
177
197
|
const agentManager = maybeAgentManager ||
|
|
178
198
|
(0, exports.createAgentManager)(Object.assign({ withDevtools }, agentOptions));
|
|
@@ -186,7 +206,7 @@ const createReActorStore = (options) => {
|
|
|
186
206
|
});
|
|
187
207
|
return actorManager;
|
|
188
208
|
};
|
|
189
|
-
exports.
|
|
209
|
+
exports.createReactorStore = createReactorStore;
|
|
190
210
|
/**
|
|
191
211
|
* Agent manager handles the lifecycle of the `@dfinity/agent`.
|
|
192
212
|
* It is responsible for creating agent and managing the agent's state.
|
|
@@ -194,7 +214,7 @@ exports.createReActorStore = createReActorStore;
|
|
|
194
214
|
* login and logout to the internet identity.
|
|
195
215
|
*
|
|
196
216
|
* @category Main
|
|
197
|
-
* @includeExample ./packages/core/README.md:
|
|
217
|
+
* @includeExample ./packages/core/README.md:226-254
|
|
198
218
|
*/
|
|
199
219
|
const createAgentManager = (options) => {
|
|
200
220
|
return new agent_1.AgentManager(options);
|
|
@@ -207,21 +227,14 @@ exports.createAgentManager = createAgentManager;
|
|
|
207
227
|
* It also provides a way to interact with the actor's state.
|
|
208
228
|
*
|
|
209
229
|
* @category Main
|
|
210
|
-
* @includeExample ./packages/core/README.md:
|
|
230
|
+
* @includeExample ./packages/core/README.md:262-277
|
|
211
231
|
*/
|
|
212
232
|
const createActorManager = (options) => {
|
|
213
233
|
return new actor_1.ActorManager(options);
|
|
214
234
|
};
|
|
215
235
|
exports.createActorManager = createActorManager;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
* @category Main
|
|
222
|
-
* @includeExample ./packages/core/README.md:164-205
|
|
223
|
-
*/
|
|
224
|
-
const createCandidAdapter = (options) => {
|
|
225
|
-
return new tools_1.CandidAdapter(options);
|
|
226
|
-
};
|
|
227
|
-
exports.createCandidAdapter = createCandidAdapter;
|
|
236
|
+
__exportStar(require("./actor"), exports);
|
|
237
|
+
__exportStar(require("./agent"), exports);
|
|
238
|
+
__exportStar(require("./candid"), exports);
|
|
239
|
+
exports.types = __importStar(require("./types"));
|
|
240
|
+
exports.tools = __importStar(require("./tools"));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const IC_HOST_NETWORK_URI = "https://ic0.app";
|
|
2
|
+
export declare const LOCAL_HOST_NETWORK_URI = "http://127.0.0.1:4943";
|
|
3
|
+
export declare const DEFAULT_LOCAL_DIDJS_ID = "bd3sg-teaaa-aaaaa-qaaba-cai";
|
|
4
|
+
export declare const DEFAULT_IC_DIDJS_ID = "a4gq6-oaaaa-aaaab-qaa4q-cai";
|
|
5
|
+
export declare const IC_INTERNET_IDENTITY_PROVIDER = "https://identity.ic0.app/#authorize";
|
|
6
|
+
export declare const LOCAL_INTERNET_IDENTITY_PROVIDER = "http://rdmx6-jaaaa-aaaaa-aaadq-cai.localhost:4943/#authorize";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LOCAL_INTERNET_IDENTITY_PROVIDER = exports.IC_INTERNET_IDENTITY_PROVIDER = exports.DEFAULT_IC_DIDJS_ID = exports.DEFAULT_LOCAL_DIDJS_ID = exports.LOCAL_HOST_NETWORK_URI = exports.IC_HOST_NETWORK_URI = void 0;
|
|
4
|
+
exports.IC_HOST_NETWORK_URI = "https://ic0.app";
|
|
5
|
+
exports.LOCAL_HOST_NETWORK_URI = "http://127.0.0.1:4943";
|
|
6
|
+
exports.DEFAULT_LOCAL_DIDJS_ID = "bd3sg-teaaa-aaaaa-qaaba-cai";
|
|
7
|
+
exports.DEFAULT_IC_DIDJS_ID = "a4gq6-oaaaa-aaaab-qaa4q-cai";
|
|
8
|
+
exports.IC_INTERNET_IDENTITY_PROVIDER = "https://identity.ic0.app/#authorize";
|
|
9
|
+
exports.LOCAL_INTERNET_IDENTITY_PROVIDER = "http://rdmx6-jaaaa-aaaaa-aaadq-cai.localhost:4943/#authorize";
|
package/dist/tools/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseActor } from "../
|
|
1
|
+
import { BaseActor } from "../types";
|
|
2
2
|
interface StoreOptions {
|
|
3
3
|
withDevtools?: boolean;
|
|
4
4
|
store: string;
|
|
@@ -8,7 +8,8 @@ export declare function createStoreWithOptionalDevtools<T>(initialState: T, opti
|
|
|
8
8
|
type: string;
|
|
9
9
|
}>(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
10
10
|
};
|
|
11
|
-
export declare
|
|
11
|
+
export declare const isInLocalOrDevelopment: () => boolean;
|
|
12
|
+
export declare const jsonToString: (json: unknown) => string;
|
|
12
13
|
export declare const generateRequestHash: (args?: unknown[]) => `0x${string}`;
|
|
13
14
|
export declare const generateHash: (field?: unknown) => `0x${string}`;
|
|
14
15
|
export declare const generateActorHash: (actor: BaseActor) => `0x${string}`;
|
package/dist/tools/helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToHash = exports.generateActorHash = exports.generateHash = exports.generateRequestHash = exports.jsonToString = exports.createStoreWithOptionalDevtools = void 0;
|
|
3
|
+
exports.stringToHash = exports.generateActorHash = exports.generateHash = exports.generateRequestHash = exports.jsonToString = exports.isInLocalOrDevelopment = exports.createStoreWithOptionalDevtools = void 0;
|
|
4
4
|
const agent_1 = require("@dfinity/agent");
|
|
5
5
|
const candid_1 = require("@dfinity/candid");
|
|
6
6
|
const middleware_1 = require("zustand/middleware");
|
|
@@ -8,7 +8,7 @@ const vanilla_1 = require("zustand/vanilla");
|
|
|
8
8
|
function createStoreWithOptionalDevtools(initialState, options) {
|
|
9
9
|
if (options.withDevtools) {
|
|
10
10
|
return (0, vanilla_1.createStore)((0, middleware_1.devtools)(() => initialState, {
|
|
11
|
-
name: "
|
|
11
|
+
name: "Reactor",
|
|
12
12
|
store: options.store,
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
@@ -17,9 +17,15 @@ function createStoreWithOptionalDevtools(initialState, options) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.createStoreWithOptionalDevtools = createStoreWithOptionalDevtools;
|
|
20
|
-
|
|
20
|
+
const isInLocalOrDevelopment = () => {
|
|
21
|
+
return (typeof process !== "undefined" &&
|
|
22
|
+
(process.env.DFX_NETWORK === "local" ||
|
|
23
|
+
process.env.NODE_ENV === "development"));
|
|
24
|
+
};
|
|
25
|
+
exports.isInLocalOrDevelopment = isInLocalOrDevelopment;
|
|
26
|
+
const jsonToString = (json) => {
|
|
21
27
|
return JSON.stringify(json, (_, value) => (typeof value === "bigint" ? `BigInt(${value})` : value), 2);
|
|
22
|
-
}
|
|
28
|
+
};
|
|
23
29
|
exports.jsonToString = jsonToString;
|
|
24
30
|
const generateRequestHash = (args = []) => {
|
|
25
31
|
const serializedArgs = args
|
package/dist/tools/index.d.ts
CHANGED
package/dist/tools/index.js
CHANGED
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./candid"), exports);
|
|
18
17
|
__exportStar(require("./helper"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./constants"), exports);
|
package/dist/types.d.ts
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
import type { ActorMethod, ActorSubclass, HttpAgentOptions, HttpAgent, Identity } from "@dfinity/agent";
|
|
3
3
|
import type { Principal } from "@dfinity/principal";
|
|
4
4
|
import type { IDL } from "@dfinity/candid";
|
|
5
|
-
import type { ActorManager
|
|
5
|
+
import type { ActorManager } from "./actor";
|
|
6
|
+
import type { ActorManagerOptions, ActorMethodArgs, ActorMethodReturnType, ActorMethodState, BaseActor, FunctionName } from "./actor/types";
|
|
6
7
|
import type { AgentManager } from "./agent";
|
|
7
8
|
import type { AuthClientLoginOptions } from "@dfinity/auth-client";
|
|
9
|
+
export * from "./agent/types";
|
|
10
|
+
export * from "./actor/types";
|
|
11
|
+
export * from "./candid/types";
|
|
8
12
|
export type { ActorMethod, HttpAgentOptions, ActorSubclass, Principal, HttpAgent, Identity, IDL, };
|
|
9
|
-
export interface
|
|
13
|
+
export interface CreateReactorOptions extends CreateReactorStoreOptions {
|
|
10
14
|
}
|
|
11
|
-
export interface
|
|
15
|
+
export interface CreateReactorStoreOptions extends HttpAgentOptions, Omit<ActorManagerOptions, "agentManager"> {
|
|
12
16
|
agentManager?: AgentManager;
|
|
13
17
|
withProcessEnv?: boolean;
|
|
14
18
|
isLocalEnv?: boolean;
|
|
@@ -49,7 +53,7 @@ export type ActorUpdateArgs<A, M extends FunctionName<A>> = {
|
|
|
49
53
|
export type ActorMethodCall<A = Record<string, ActorMethod>> = <M extends FunctionName<A>>(functionName: M, ...args: ActorMethodArgs<A[M]>) => ActorUpdateReturn<A, M>;
|
|
50
54
|
export type ActorQuery<A = Record<string, ActorMethod>> = <M extends FunctionName<A>>(options: ActorQueryArgs<A, M>) => ActorQueryReturn<A, M>;
|
|
51
55
|
export type ActorUpdate<A = Record<string, ActorMethod>> = <M extends FunctionName<A>>(options: ActorUpdateArgs<A, M>) => ActorUpdateReturn<A, M>;
|
|
52
|
-
export interface
|
|
56
|
+
export interface ReactorCore<A = BaseActor> extends AgentManager, Omit<ActorManager<A>, "updateMethodState"> {
|
|
53
57
|
login: (options?: AuthClientLoginOptions) => Promise<void>;
|
|
54
58
|
logout: (options?: {
|
|
55
59
|
returnTo?: string;
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./agent/types"), exports);
|
|
18
|
+
__exportStar(require("./actor/types"), exports);
|
|
19
|
+
__exportStar(require("./candid/types"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/b3hr4d/ic-reactor/issues"
|
|
26
26
|
},
|
|
27
|
-
"homepage": "https://github.
|
|
27
|
+
"homepage": "https://b3pay.github.io/ic-reactor/modules/core.html",
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@dfinity/agent": ">=1.0",
|
|
30
30
|
"@dfinity/auth-client": ">=1.0",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=10"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "4d19bef671056c8046ec64037f51d85380ff5bae"
|
|
47
47
|
}
|
|
File without changes
|
|
File without changes
|