@getpara/react-sdk 2.0.0-alpha.7 → 2.0.0-alpha.9
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/provider/hooks/mutations/index.d.ts +1 -0
- package/dist/provider/hooks/mutations/index.js +3 -1
- package/dist/provider/hooks/mutations/utils.d.ts +2 -1
- package/dist/provider/hooks/mutations/utils.js +40 -3
- package/dist/provider/hooks/utils/useEventListeners.js +2 -0
- package/dist/provider/types/utils.d.ts +6 -2
- package/package.json +11 -11
|
@@ -24,3 +24,4 @@ export declare const useUpdatePregenWalletIdentifier: () => import("../../types/
|
|
|
24
24
|
export declare const useCreateGuestWallets: () => import("../../types/utils.js").CoreMethodHook<"createGuestWallets">;
|
|
25
25
|
export declare const useSignMessage: () => import("../../types/utils.js").CoreMethodHook<"signMessage">;
|
|
26
26
|
export declare const useSignTransaction: () => import("../../types/utils.js").CoreMethodHook<"signTransaction">;
|
|
27
|
+
export declare const useCreateGuestWalletsState: import("../../types/utils.js").CoreMethodStateHook<"createGuestWallets">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
3
|
import * as actions from "../../actions/index.js";
|
|
4
|
-
import { generateHook } from "./utils.js";
|
|
4
|
+
import { generateHook, generateStateHook } from "./utils.js";
|
|
5
5
|
const useSignUpOrLogIn = generateHook("signUpOrLogIn", actions.signUpOrLogIn);
|
|
6
6
|
const useVerifyNewAccount = generateHook("verifyNewAccount", actions.verifyNewAccount);
|
|
7
7
|
const useWaitForLogin = generateHook("waitForLogin", actions.waitForLogin);
|
|
@@ -31,9 +31,11 @@ const useUpdatePregenWalletIdentifier = generateHook(
|
|
|
31
31
|
const useCreateGuestWallets = generateHook("createGuestWallets", actions.createGuestWallets);
|
|
32
32
|
const useSignMessage = generateHook("signMessage", actions.signMessage);
|
|
33
33
|
const useSignTransaction = generateHook("signTransaction", actions.signTransaction);
|
|
34
|
+
const useCreateGuestWalletsState = generateStateHook("createGuestWallets");
|
|
34
35
|
export {
|
|
35
36
|
useClaimPregenWallets,
|
|
36
37
|
useCreateGuestWallets,
|
|
38
|
+
useCreateGuestWalletsState,
|
|
37
39
|
useCreatePregenWallet,
|
|
38
40
|
useCreatePregenWalletPerType,
|
|
39
41
|
useCreateWallet,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreMethodName, CoreMethodParams, CoreMethods } from '@getpara/web-sdk';
|
|
2
|
-
import { CoreMethodHook } from '../../types/utils.js';
|
|
2
|
+
import { CoreMethodHook, CoreMethodStateHook } from '../../types/utils.js';
|
|
3
3
|
import { CoreAction } from '../../actions/utils.js';
|
|
4
4
|
export declare function generateHook<const method extends CoreMethodName & keyof CoreMethods>(method: method, action: CoreAction<method>, defaultParams?: CoreMethodParams<method>): () => CoreMethodHook<method>;
|
|
5
|
+
export declare function generateStateHook<const method extends CoreMethodName & keyof CoreMethods>(method: method): CoreMethodStateHook<method>;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
__async
|
|
3
|
+
__async,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
4
6
|
} from "../../../chunk-MMUBH76A.js";
|
|
5
7
|
import { renameCoreMutations } from "../../utils/renameMutations.js";
|
|
6
8
|
import { useClient } from "../utils/index.js";
|
|
7
|
-
import { useMutation } from "@tanstack/react-query";
|
|
9
|
+
import { useMutation, useMutationState } from "@tanstack/react-query";
|
|
8
10
|
function generateHook(method, action, defaultParams) {
|
|
9
11
|
return () => {
|
|
10
12
|
const para = useClient();
|
|
11
13
|
const mutation = useMutation({
|
|
14
|
+
mutationKey: [method],
|
|
12
15
|
mutationFn: (args) => __async(this, null, function* () {
|
|
13
16
|
const result = yield action(para, args != null ? args : defaultParams);
|
|
14
17
|
return result;
|
|
@@ -17,6 +20,40 @@ function generateHook(method, action, defaultParams) {
|
|
|
17
20
|
return renameCoreMutations(mutation, method);
|
|
18
21
|
};
|
|
19
22
|
}
|
|
23
|
+
function generateStateHook(method) {
|
|
24
|
+
return () => {
|
|
25
|
+
const frames = useMutationState({
|
|
26
|
+
filters: { mutationKey: [method] },
|
|
27
|
+
select: (mutation) => mutation.state
|
|
28
|
+
});
|
|
29
|
+
const latest = frames[frames.length - 1];
|
|
30
|
+
if (!latest) {
|
|
31
|
+
return {
|
|
32
|
+
data: void 0,
|
|
33
|
+
error: null,
|
|
34
|
+
failureCount: 0,
|
|
35
|
+
isLoading: false,
|
|
36
|
+
isPaused: false,
|
|
37
|
+
isPending: false,
|
|
38
|
+
isError: false,
|
|
39
|
+
isSuccess: false,
|
|
40
|
+
isIdle: true,
|
|
41
|
+
status: "idle",
|
|
42
|
+
variables: void 0,
|
|
43
|
+
context: null,
|
|
44
|
+
failureReason: null,
|
|
45
|
+
submittedAt: 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return __spreadProps(__spreadValues({}, latest), {
|
|
49
|
+
isPending: latest.status === "pending",
|
|
50
|
+
isError: latest.status === "error",
|
|
51
|
+
isSuccess: latest.status === "success",
|
|
52
|
+
isIdle: latest.status === "idle"
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
20
56
|
export {
|
|
21
|
-
generateHook
|
|
57
|
+
generateHook,
|
|
58
|
+
generateStateHook
|
|
22
59
|
};
|
|
@@ -99,6 +99,8 @@ const useEventListeners = ({
|
|
|
99
99
|
);
|
|
100
100
|
const guestWalletsCreatedListener = useCallback(
|
|
101
101
|
(event) => {
|
|
102
|
+
queryClient.refetchQueries({ queryKey: [ACCOUNT_BASE_KEY] });
|
|
103
|
+
updateSelectedWallet();
|
|
102
104
|
onGuestWalletsCreated == null ? void 0 : onGuestWalletsCreated(event);
|
|
103
105
|
},
|
|
104
106
|
[onGuestWalletsCreated]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoreMethodName, CoreMethodParams, CoreMethodResponse, CoreMethods } from '@getpara/web-sdk';
|
|
2
2
|
import { UseMutationReturnType } from './query.js';
|
|
3
|
-
import { UseMutateFunction, UseMutateAsyncFunction } from '@tanstack/react-query';
|
|
3
|
+
import { UseMutateFunction, UseMutateAsyncFunction, MutationState, Mutation } from '@tanstack/react-query';
|
|
4
4
|
export type Compute<type> = {
|
|
5
5
|
[key in keyof type]: type[key];
|
|
6
6
|
} & unknown;
|
|
@@ -18,5 +18,9 @@ type AsyncHook<method extends CoreMethodName & keyof CoreMethods> = {
|
|
|
18
18
|
} & {
|
|
19
19
|
[K in `${method}Async`]: UseMutateAsyncFunction<CoreMethodResponse<method>, Error, CoreMethodParams<method> | void, unknown>;
|
|
20
20
|
};
|
|
21
|
-
export type
|
|
21
|
+
export type CoreMethodUseMutationReturnType<method extends CoreMethodName & keyof CoreMethods> = UseMutationReturnType<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
22
|
+
export type CoreMethodMutation<method extends CoreMethodName & keyof CoreMethods> = Mutation<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
23
|
+
export type CoreMethodMutationState<method extends CoreMethodName & keyof CoreMethods> = MutationState<Awaited<CoreMethodResponse<method>>, Error, CoreMethodParams<method> | void, unknown>;
|
|
24
|
+
export type CoreMethodHook<method extends CoreMethodName & keyof CoreMethods> = Compute<CoreMethodUseMutationReturnType<method> & SyncHook<method> & AsyncHook<method>>;
|
|
25
|
+
export type CoreMethodStateHook<method extends CoreMethodName & keyof CoreMethods> = () => Omit<CoreMethodUseMutationReturnType<method>, 'reset'>;
|
|
22
26
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"*.css"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
19
|
-
"@getpara/react-components": "2.0.0-alpha.
|
|
20
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
18
|
+
"@getpara/react-common": "2.0.0-alpha.9",
|
|
19
|
+
"@getpara/react-components": "2.0.0-alpha.9",
|
|
20
|
+
"@getpara/web-sdk": "2.0.0-alpha.9",
|
|
21
21
|
"date-fns": "^3.6.0",
|
|
22
22
|
"framer-motion": "11.3.28",
|
|
23
23
|
"libphonenumber-js": "^1.11.1",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"cli": "node ./dist/cli/cli.mjs"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.
|
|
37
|
-
"@getpara/evm-wallet-connectors": "2.0.0-alpha.
|
|
38
|
-
"@getpara/solana-wallet-connectors": "2.0.0-alpha.
|
|
36
|
+
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.9",
|
|
37
|
+
"@getpara/evm-wallet-connectors": "2.0.0-alpha.9",
|
|
38
|
+
"@getpara/solana-wallet-connectors": "2.0.0-alpha.9",
|
|
39
39
|
"@testing-library/dom": "^10.4.0",
|
|
40
40
|
"@testing-library/react": "^16.3.0",
|
|
41
41
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"wagmi": "^2.14.16"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.
|
|
52
|
-
"@getpara/evm-wallet-connectors": "^2.0.0-alpha.
|
|
53
|
-
"@getpara/solana-wallet-connectors": "^2.0.0-alpha.
|
|
51
|
+
"@getpara/cosmos-wallet-connectors": "^2.0.0-alpha.9",
|
|
52
|
+
"@getpara/evm-wallet-connectors": "^2.0.0-alpha.9",
|
|
53
|
+
"@getpara/solana-wallet-connectors": "^2.0.0-alpha.9",
|
|
54
54
|
"@tanstack/react-query": ">=5.0.0",
|
|
55
55
|
"react": "*",
|
|
56
56
|
"react-dom": "*"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"resolutions": {
|
|
64
64
|
"styled-components": "^6"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "16aae30867cc995bd825cfba04845192502d2b6e"
|
|
67
67
|
}
|