@ic-reactor/react 1.5.3 → 1.5.5-beta.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.
package/dist/context/agent.js
CHANGED
|
@@ -20,7 +20,6 @@ const core_1 = require("@ic-reactor/core");
|
|
|
20
20
|
const agentHooks_1 = require("../helpers/agentHooks");
|
|
21
21
|
const authHooks_1 = require("../helpers/authHooks");
|
|
22
22
|
const extractAgentContext_1 = require("../helpers/extractAgentContext");
|
|
23
|
-
const utils_1 = require("../utils");
|
|
24
23
|
/**
|
|
25
24
|
* Creates a React context for managing IC agent and authentication states, providing hooks for interacting with the IC blockchain.
|
|
26
25
|
* This function initializes an `AgentContext` with a set of utilities and hooks based on the provided agent configuration.
|
|
@@ -97,10 +96,9 @@ const createAgentContext = (config = {}) => {
|
|
|
97
96
|
const { disableAuthenticateOnMount: defaultDisable } = config, contextOptions = __rest(config, ["disableAuthenticateOnMount"]);
|
|
98
97
|
const AgentContext = react_1.default.createContext(null);
|
|
99
98
|
const AgentProvider = (_a) => {
|
|
100
|
-
var { children, agentManager: mybeAgentManager,
|
|
99
|
+
var { children, agentManager: mybeAgentManager, disableAuthenticateOnMount = defaultDisable !== null && defaultDisable !== void 0 ? defaultDisable : false } = _a, options = __rest(_a, ["children", "agentManager", "disableAuthenticateOnMount"]);
|
|
101
100
|
const hooks = react_1.default.useMemo(() => {
|
|
102
|
-
const
|
|
103
|
-
const agentManager = mybeAgentManager !== null && mybeAgentManager !== void 0 ? mybeAgentManager : (0, core_1.createAgentManager)(Object.assign(Object.assign({ withLocalEnv }, options), contextOptions));
|
|
101
|
+
const agentManager = mybeAgentManager !== null && mybeAgentManager !== void 0 ? mybeAgentManager : (0, core_1.createAgentManager)(Object.assign(Object.assign({}, options), contextOptions));
|
|
104
102
|
if (!disableAuthenticateOnMount) {
|
|
105
103
|
agentManager.authenticate();
|
|
106
104
|
}
|
package/dist/context/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IDL, ActorHooksReturnType, AgentHooksReturnType, AuthHooksReturnType, BaseActor, AgentManager, ActorManagerParameters, AgentManagerParameters } from "../types";
|
|
1
|
+
import type { IDL, ActorHooksReturnType, AgentHooksReturnType, AuthHooksReturnType, BaseActor, AgentManager, ActorManagerParameters, AgentManagerParameters, CanisterId } from "../types";
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
3
|
export interface AgentContext extends AgentHooksReturnType, AuthHooksReturnType {
|
|
4
4
|
agentManager: AgentManager;
|
|
@@ -24,6 +24,6 @@ export interface ActorProviderProps extends CreateActorContextParameters {
|
|
|
24
24
|
}
|
|
25
25
|
export interface CreateActorContextParameters extends Omit<ActorManagerParameters, "idlFactory" | "agentManager" | "canisterId"> {
|
|
26
26
|
didjsId?: string;
|
|
27
|
-
canisterId?:
|
|
27
|
+
canisterId?: CanisterId;
|
|
28
28
|
idlFactory?: IDL.InterfaceFactory;
|
|
29
29
|
}
|
package/dist/createReactor.d.ts
CHANGED
|
@@ -35,9 +35,9 @@ import type { BaseActor, CreateReactorParameters, CreateReactorReturnType } from
|
|
|
35
35
|
* canisterId,
|
|
36
36
|
* idlFactory,
|
|
37
37
|
* host: "https://localhost:8000", // IC network host |
|
|
38
|
-
* withLocalEnv: true, // Set true for local network
|
|
38
|
+
* withLocalEnv: true, // Set true for local network | one of these
|
|
39
39
|
* withProcessEnv: true, // Use process.env to determine host |
|
|
40
|
-
* port: 8000, // Port number for local network
|
|
40
|
+
* port: 8000, // Port number for local network
|
|
41
41
|
* };
|
|
42
42
|
*
|
|
43
43
|
* export type YourActor = typeof yourActor;
|
package/dist/createReactor.js
CHANGED
|
@@ -39,9 +39,9 @@ const helpers_1 = require("./helpers");
|
|
|
39
39
|
* canisterId,
|
|
40
40
|
* idlFactory,
|
|
41
41
|
* host: "https://localhost:8000", // IC network host |
|
|
42
|
-
* withLocalEnv: true, // Set true for local network
|
|
42
|
+
* withLocalEnv: true, // Set true for local network | one of these
|
|
43
43
|
* withProcessEnv: true, // Use process.env to determine host |
|
|
44
|
-
* port: 8000, // Port number for local network
|
|
44
|
+
* port: 8000, // Port number for local network
|
|
45
45
|
* };
|
|
46
46
|
*
|
|
47
47
|
* export type YourActor = typeof yourActor;
|
package/dist/helpers/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ServiceClass } from "@dfinity/candid/lib/cjs/idl";
|
|
3
|
-
import type { ActorState,
|
|
3
|
+
import type { ActorState, AuthClientLoginOptions, ActorMethodParameters, ActorMethodReturnType, Identity, Principal, FunctionName, VisitService, AuthState, HttpAgent, AgentState, BaseActor, MethodAttributes } from "@ic-reactor/core/dist/types";
|
|
4
4
|
export interface AgentHooksReturnType {
|
|
5
5
|
useAgent: () => HttpAgent | undefined;
|
|
6
6
|
useAgentState: () => AgentState;
|
|
@@ -39,7 +39,7 @@ export type LogoutParameters = {
|
|
|
39
39
|
returnTo?: string;
|
|
40
40
|
};
|
|
41
41
|
export interface UseActorState extends Omit<ActorState, "methodState"> {
|
|
42
|
-
canisterId:
|
|
42
|
+
canisterId: string;
|
|
43
43
|
}
|
|
44
44
|
export type UseSharedCallParameters<A, M extends FunctionName<A>> = {
|
|
45
45
|
functionName: M;
|
package/dist/hooks/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IDL } from "@dfinity/candid";
|
|
2
|
-
import { ActorHooksReturnType, ActorManagerParameters, BaseActor } from "../types";
|
|
2
|
+
import { ActorHooksReturnType, ActorManagerParameters, BaseActor, CanisterId } from "../types";
|
|
3
3
|
export interface UseActorParameters extends Omit<ActorManagerParameters, "idlFactory" | "agentManager" | "canisterId"> {
|
|
4
|
-
canisterId:
|
|
4
|
+
canisterId: CanisterId;
|
|
5
5
|
idlFactory?: IDL.InterfaceFactory;
|
|
6
6
|
didjsCanisterId?: string;
|
|
7
7
|
}
|
package/dist/hooks/useActor.js
CHANGED
|
@@ -96,7 +96,7 @@ const useActor = (config) => {
|
|
|
96
96
|
}
|
|
97
97
|
const [actorManager, setActorManager] = (0, react_1.useState)(null);
|
|
98
98
|
(0, react_1.useEffect)(() => {
|
|
99
|
-
if ((actorManager === null || actorManager === void 0 ? void 0 : actorManager.canisterId) !== canisterId) {
|
|
99
|
+
if ((actorManager === null || actorManager === void 0 ? void 0 : actorManager.canisterId) !== canisterId.toString()) {
|
|
100
100
|
setActorManager(null);
|
|
101
101
|
}
|
|
102
102
|
return actorManager === null || actorManager === void 0 ? void 0 : actorManager.cleanup();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5-beta.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": "^1.5.
|
|
38
|
+
"@ic-reactor/core": "^1.5.4-beta.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": "dfc8ce03a6a0f8aadf28bba2b21c70729278b5fd"
|
|
51
51
|
}
|