@ic-reactor/react 1.10.3 → 2.0.0-alpha.0
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.
|
@@ -18,6 +18,7 @@ exports.createActorContext = void 0;
|
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const useActor_1 = require("../../hooks/useActor");
|
|
20
20
|
const extractActorContext_1 = require("../../helpers/extractActorContext");
|
|
21
|
+
const agent_1 = require("../agent");
|
|
21
22
|
/**
|
|
22
23
|
* Creates a React context specifically designed for managing the state and interactions with an actor on the Internet Computer (IC) blockchain.
|
|
23
24
|
* This context facilitates the dynamic creation and management of IC actors within React applications, leveraging the provided configuration options.
|
|
@@ -87,7 +88,9 @@ function createActorContext(contextConfig = {}) {
|
|
|
87
88
|
throw new Error("canisterId is required");
|
|
88
89
|
}
|
|
89
90
|
const config = react_1.default.useMemo(() => (Object.assign(Object.assign({}, defaultConfig), restConfig)), [defaultConfig, restConfig]);
|
|
90
|
-
const
|
|
91
|
+
const agentManager = (0, agent_1.useAgentManager)();
|
|
92
|
+
const { fetchError, authenticating, initializeActor, hooks } = (0, useActor_1.useActor)(Object.assign({ agentManager,
|
|
93
|
+
canisterId }, config));
|
|
91
94
|
const useInitializeActor = react_1.default.useCallback(() => {
|
|
92
95
|
return initializeActor;
|
|
93
96
|
}, [initializeActor]);
|
package/dist/hooks/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { IDL, ActorHooksReturnType, ActorManagerParameters, BaseActor, CanisterId } from "../types";
|
|
1
|
+
import { IDL, ActorHooksReturnType, ActorManagerParameters, BaseActor, CanisterId, AgentManager } from "../types";
|
|
2
2
|
export type ActorReConfigParameters = Omit<ActorManagerParameters, "idlFactory" | "canisterId" | "agentManager">;
|
|
3
3
|
export interface UseActorParameters extends ActorReConfigParameters {
|
|
4
4
|
candidString?: string;
|
|
5
|
+
agentManager: AgentManager;
|
|
5
6
|
canisterId: CanisterId;
|
|
6
7
|
idlFactory?: IDL.InterfaceFactory;
|
|
7
8
|
disableAutoFetch?: boolean;
|
package/dist/hooks/useActor.js
CHANGED
|
@@ -91,7 +91,7 @@ const agent_1 = require("../context/agent");
|
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
const useActor = (config) => {
|
|
94
|
-
const { canisterId, candidString, idlFactory: maybeIdlFactory, disableAutoFetch } = config, actorConfig = __rest(config, ["canisterId", "candidString", "idlFactory", "disableAutoFetch"]);
|
|
94
|
+
const { canisterId, candidString, idlFactory: maybeIdlFactory, disableAutoFetch, agentManager } = config, actorConfig = __rest(config, ["canisterId", "candidString", "idlFactory", "disableAutoFetch", "agentManager"]);
|
|
95
95
|
if (!canisterId) {
|
|
96
96
|
throw new Error("canisterId is required");
|
|
97
97
|
}
|
|
@@ -149,7 +149,6 @@ const useActor = (config) => {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
}), [candidString]);
|
|
152
|
-
const agentManager = (0, agent_1.useAgentManager)();
|
|
153
152
|
const initializeActor = (0, react_1.useCallback)((idlFactory, actorReConfig) => {
|
|
154
153
|
if (authenticating || !idlFactory)
|
|
155
154
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"description": "A React library for interacting with Internet Computer canisters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"node": ">=10"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ic-reactor/core": "^
|
|
38
|
+
"@ic-reactor/core": "^2.0.0-alpha.0",
|
|
39
39
|
"zustand-utils": "^1.3"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"react": ">=16.8",
|
|
48
48
|
"zustand": "4.5"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "081197439510ef0327c5a807e0e35ec7aa841fd4"
|
|
51
51
|
}
|