@getpara/react-sdk 1.1.0 → 1.2.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/modal/components/ModalContent/ModalContent.js +4 -2
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -1
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +1 -1
- package/dist/provider/ParaProvider.js +3 -2
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +1 -1
- package/dist/provider/stores/getters.js +5 -5
- package/dist/provider/stores/useStore.d.ts +7 -2
- package/dist/provider/stores/useStore.js +4 -2
- package/dist/provider/types/provider.d.ts +15 -3
- package/package.json +5 -5
|
@@ -168,8 +168,6 @@ export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFa
|
|
|
168
168
|
}, [isLogin, currentStep]);
|
|
169
169
|
function createAccountWithPassword() {
|
|
170
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
clearTimeout(createAccountTimeout.current);
|
|
172
|
-
createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
|
|
173
171
|
setStep(ModalStep.PASSWORD_CREATION);
|
|
174
172
|
});
|
|
175
173
|
}
|
|
@@ -223,6 +221,10 @@ export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFa
|
|
|
223
221
|
if (![ModalStep.AWAITING_OAUTH, ModalStep.FARCASTER_OAUTH].includes(currentStep)) {
|
|
224
222
|
para.exitOAuth();
|
|
225
223
|
}
|
|
224
|
+
if (currentStep === ModalStep.PASSWORD_CREATION) {
|
|
225
|
+
clearTimeout(createAccountTimeout.current);
|
|
226
|
+
createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
|
|
227
|
+
}
|
|
226
228
|
}, [currentStep]);
|
|
227
229
|
useEffect(() => {
|
|
228
230
|
if (!onRampConfig) {
|
|
@@ -43,7 +43,6 @@ const FarcasterOAuthStep = () => {
|
|
|
43
43
|
const pollStatus = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
44
|
const { userExists, username, pfpUrl } = yield para.waitForFarcasterStatus();
|
|
45
45
|
setAuthInfo({ farcasterUsername: username, pfpUrl });
|
|
46
|
-
setStep(ModalStep.AWAITING_OAUTH);
|
|
47
46
|
if (userExists) {
|
|
48
47
|
const supportedAuthMethods = yield para.initiateUserLoginV2({ farcasterUsername: username });
|
|
49
48
|
if (supportedAuthMethods.size > 0) {
|
|
@@ -87,7 +87,7 @@ export const VerificationCodeStep = () => {
|
|
|
87
87
|
setShouldRouteToStep(ModalStep.BIOMETRIC_CREATION);
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
else if (
|
|
90
|
+
else if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD)) {
|
|
91
91
|
setIsIFrameReady(false);
|
|
92
92
|
isEmail ? yield para.verifyEmail({ verificationCode: code }) : yield para.verifyPhone({ verificationCode: code });
|
|
93
93
|
const url = yield para.getSetupPasswordURL({ authType: authInfo === null || authInfo === void 0 ? void 0 : authInfo.authType, theme });
|
|
@@ -9,8 +9,9 @@ export const ParaProvider = ({ children, paraClientConfig, callbacks, config = D
|
|
|
9
9
|
useAutoSessionKeepAlive({ disabled: config.disableAutoSessionKeepAlive });
|
|
10
10
|
const setClient = useStore(state => state.setClient);
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
const newClient = (_a = config.paraClientOverride) !== null && _a !== void 0 ? _a : new ParaInternal(paraClientConfig.env, paraClientConfig.apiKey, paraClientConfig.opts);
|
|
13
14
|
setClient(newClient);
|
|
14
|
-
}, [paraClientConfig]);
|
|
15
|
+
}, [paraClientConfig, config.paraClientOverride]);
|
|
15
16
|
return children;
|
|
16
17
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Callbacks } from '../../types/provider.js';
|
|
2
|
-
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }
|
|
2
|
+
export declare const useEventListeners: ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }?: Callbacks) => void;
|
|
@@ -5,7 +5,7 @@ import { ParaEvent, } from '@getpara/web-sdk';
|
|
|
5
5
|
import { ACCOUNT_BASE_KEY } from '../queries/useAccount.js';
|
|
6
6
|
import { useStore } from '../../stores/useStore.js';
|
|
7
7
|
import { WALLET_BASE_KEY } from '../../hooks/queries/useWallet.js';
|
|
8
|
-
export const useEventListeners = ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, }) => {
|
|
8
|
+
export const useEventListeners = ({ onLogin, onLogout, onAccountSetup, onAccountCreation, onSignMessage, onSignTransaction, onWalletCreated, onPregenWalletClaimed, onExternalWalletChange, onWalletsChange, } = {}) => {
|
|
9
9
|
const queryClient = useQueryClient();
|
|
10
10
|
const client = useClient();
|
|
11
11
|
const clearSelectedWallet = useStore(state => state.clearSelectedWallet);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const getClient = () =>
|
|
3
|
-
export const getIsOpen = () =>
|
|
4
|
-
export const getSelectedWalletId = () =>
|
|
5
|
-
export const getSelectedWalletType = () =>
|
|
1
|
+
import { vanillaStore } from './useStore.js';
|
|
2
|
+
export const getClient = () => vanillaStore.getState().client;
|
|
3
|
+
export const getIsOpen = () => vanillaStore.getState().isOpen;
|
|
4
|
+
export const getSelectedWalletId = () => vanillaStore.getState().selectedWalletId;
|
|
5
|
+
export const getSelectedWalletType = () => vanillaStore.getState().selectedWalletType;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { StoreApi } from 'zustand';
|
|
1
2
|
import { Store } from './types.js';
|
|
2
|
-
export declare const
|
|
3
|
+
export declare const vanillaStore: Omit<StoreApi<Store>, "persist"> & {
|
|
3
4
|
persist: {
|
|
4
5
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<Store, Pick<Store, "selectedWalletId" | "selectedWalletType">>>) => void;
|
|
5
6
|
clearStorage: () => void;
|
|
@@ -9,4 +10,8 @@ export declare const useStore: import("zustand").UseBoundStore<Omit<import("zust
|
|
|
9
10
|
onFinishHydration: (fn: (state: Store) => void) => () => void;
|
|
10
11
|
getOptions: () => Partial<import("zustand/middleware").PersistOptions<Store, Pick<Store, "selectedWalletId" | "selectedWalletType">>>;
|
|
11
12
|
};
|
|
12
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare const useStore: {
|
|
15
|
+
(): Store;
|
|
16
|
+
<T>(selector: (state: Store) => T): T;
|
|
17
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createStore, useStore as useZustandStore } from 'zustand';
|
|
2
2
|
import { createClientSlice, createModalSlice, createWalletSlice } from './slices/index.js';
|
|
3
3
|
import { createJSONStorage, persist } from 'zustand/middleware';
|
|
4
|
-
export const
|
|
4
|
+
export const vanillaStore = createStore()(persist((...a) => (Object.assign(Object.assign(Object.assign({}, createClientSlice(...a)), createModalSlice(...a)), createWalletSlice(...a))), {
|
|
5
5
|
version: 1,
|
|
6
6
|
name: '@PARA/web-state',
|
|
7
7
|
storage: createJSONStorage(() => sessionStorage),
|
|
@@ -10,3 +10,5 @@ export const useStore = create()(persist((...a) => (Object.assign(Object.assign(
|
|
|
10
10
|
selectedWalletType: state.selectedWalletType,
|
|
11
11
|
}),
|
|
12
12
|
}));
|
|
13
|
+
const createBoundedUseStore = (store => selector => useZustandStore(store, selector));
|
|
14
|
+
export const useStore = createBoundedUseStore(vanillaStore);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCreationEvent, AccountSetupEvent, ConstructorOpts, Environment, ExternalWalletChangeEvent, LoginEvent, LogoutEvent, PregenWalletClaimedEvent, SignMessageEvent, SignTransactionEvent, WalletCreatedEvent, WalletsChangeEvent } from '@getpara/web-sdk';
|
|
1
|
+
import ParaWeb, { AccountCreationEvent, AccountSetupEvent, ConstructorOpts, Environment, ExternalWalletChangeEvent, LoginEvent, LogoutEvent, PregenWalletClaimedEvent, SignMessageEvent, SignTransactionEvent, WalletCreatedEvent, WalletsChangeEvent } from '@getpara/web-sdk';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
export type Callbacks = {
|
|
4
4
|
onLogout?: (event: LogoutEvent) => void;
|
|
@@ -15,8 +15,8 @@ export type Callbacks = {
|
|
|
15
15
|
export type ParaProviderConfig = {
|
|
16
16
|
disableAutoSessionKeepAlive?: boolean;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
paraClientConfig
|
|
18
|
+
interface ParaProviderPropsBase extends PropsWithChildren {
|
|
19
|
+
paraClientConfig?: {
|
|
20
20
|
env: Environment;
|
|
21
21
|
apiKey: string;
|
|
22
22
|
opts?: ConstructorOpts;
|
|
@@ -24,3 +24,15 @@ export interface ParaProviderProps extends PropsWithChildren {
|
|
|
24
24
|
callbacks?: Callbacks;
|
|
25
25
|
config?: ParaProviderConfig;
|
|
26
26
|
}
|
|
27
|
+
export type ParaProviderProps = ({
|
|
28
|
+
config: ParaProviderConfig & {
|
|
29
|
+
paraClientOverride: ParaWeb;
|
|
30
|
+
};
|
|
31
|
+
paraClientConfig?: never;
|
|
32
|
+
} & ParaProviderPropsBase) | ({
|
|
33
|
+
config?: ParaProviderConfig & {
|
|
34
|
+
paraClientOverride?: never;
|
|
35
|
+
};
|
|
36
|
+
paraClientConfig: ParaProviderPropsBase['paraClientConfig'];
|
|
37
|
+
} & ParaProviderPropsBase);
|
|
38
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"*.css"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getpara/react-common": "1.
|
|
16
|
-
"@getpara/react-components": "1.
|
|
17
|
-
"@getpara/web-sdk": "1.
|
|
15
|
+
"@getpara/react-common": "1.2.0",
|
|
16
|
+
"@getpara/react-components": "1.2.0",
|
|
17
|
+
"@getpara/web-sdk": "1.2.0",
|
|
18
18
|
"@tanstack/react-query": "^5.0.0",
|
|
19
19
|
"date-fns": "^3.6.0",
|
|
20
20
|
"detect-browser": "^5.3.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"resolutions": {
|
|
49
49
|
"styled-components": "^6"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "a9162c59be1456292d46c56787c1d5bf313bf24b"
|
|
52
52
|
}
|