@frak-labs/react-sdk 0.0.17 → 0.0.18-beta.27947565
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/index.cjs +1 -1
- package/dist/index.d.cts +25 -22
- package/dist/index.d.ts +25 -22
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useGetProductInformation:()=>useGetProductInformation,FrakConfigContext:()=>FrakConfigContext,useDisplayModal:()=>useDisplayModal,useFrakClient:()=>useFrakClient,FrakIFrameClientProvider:()=>FrakIFrameClientProvider,useOpenSso:()=>useOpenSso,useSendTransactionAction:()=>useSendTransactionAction,useSiweAuthenticate:()=>useSiweAuthenticate,useFrakConfig:()=>useFrakConfig,useReferralInteraction:()=>useReferralInteraction,useWalletStatus:()=>useWalletStatus,FrakIFrameClientContext:()=>FrakIFrameClientContext,FrakConfigProvider:()=>FrakConfigProvider,useSendInteraction:()=>useSendInteraction});let external_react_namespaceObject=require("react"),FrakConfigContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakConfigProvider(e){let{children:t,config:a}=e;return(0,external_react_namespaceObject.createElement)(FrakConfigContext.Provider,{value:{...a,walletUrl:a.walletUrl??"https://wallet.frak.id",domain:a.domain??("undefined"!=typeof window?window?.location?.host:void 0)??"not-found"}},t)}let core_sdk_namespaceObject=require("@frak-labs/core-sdk");function useFrakConfig(){let e=(0,external_react_namespaceObject.useContext)(FrakConfigContext);if(!e)throw new
|
|
1
|
+
"use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{useGetProductInformation:()=>useGetProductInformation,FrakConfigContext:()=>FrakConfigContext,useDisplayModal:()=>useDisplayModal,useFrakClient:()=>useFrakClient,FrakIFrameClientProvider:()=>FrakIFrameClientProvider,useOpenSso:()=>useOpenSso,useSendTransactionAction:()=>useSendTransactionAction,useSiweAuthenticate:()=>useSiweAuthenticate,useFrakConfig:()=>useFrakConfig,useReferralInteraction:()=>useReferralInteraction,useWalletStatus:()=>useWalletStatus,FrakIFrameClientContext:()=>FrakIFrameClientContext,FrakConfigProvider:()=>FrakConfigProvider,useSendInteraction:()=>useSendInteraction});let external_react_namespaceObject=require("react"),FrakConfigContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakConfigProvider(e){let{children:t,config:a}=e;return(0,external_react_namespaceObject.createElement)(FrakConfigContext.Provider,{value:{...a,walletUrl:a.walletUrl??"https://wallet.frak.id",domain:a.domain??("undefined"!=typeof window?window?.location?.host:void 0)??"not-found"}},t)}let core_sdk_namespaceObject=require("@frak-labs/core-sdk"),rpc_namespaceObject=require("@frak-labs/rpc");function useFrakConfig(){let e=(0,external_react_namespaceObject.useContext)(FrakConfigContext);if(!e)throw new rpc_namespaceObject.FrakRpcError(rpc_namespaceObject.RpcErrorCodes.configError,"Frak config not found");return e}let FrakIFrameClientContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakIFrameClientProvider({style:e,children:t}){let a=useFrakConfig(),[r,n]=(0,external_react_namespaceObject.useState)(void 0),o=(0,external_react_namespaceObject.createElement)("iframe",{...core_sdk_namespaceObject.baseIframeProps,src:`${a.walletUrl}/listener`,style:e??core_sdk_namespaceObject.baseIframeProps.style,ref:e=>{e&&!r&&n((0,core_sdk_namespaceObject.createIFrameFrakClient)({iframe:e,config:a}))}}),c=(0,external_react_namespaceObject.createElement)(FrakIFrameClientContext.Provider,{value:r},t);return(0,external_react_namespaceObject.createElement)(external_react_namespaceObject.Fragment,null,o,c)}function useFrakClient(){return(0,external_react_namespaceObject.useContext)(FrakIFrameClientContext)}let actions_namespaceObject=require("@frak-labs/core-sdk/actions"),react_query_namespaceObject=require("@tanstack/react-query");function useWalletStatus(){let e=(0,react_query_namespaceObject.useQueryClient)(),t=useFrakClient(),a=(0,external_react_namespaceObject.useCallback)(t=>{e.setQueryData(["frak-sdk","wallet-status-listener"],t)},[e]);return(0,react_query_namespaceObject.useQuery)({gcTime:0,staleTime:0,queryKey:["frak-sdk","wallet-status-listener"],queryFn:async()=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.watchWalletStatus)(t,a)},enabled:!!t})}function useSendTransactionAction({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","send-transaction"],mutationFn:async e=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.sendTransaction)(t,e)}})}function useSendInteraction({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","send-interaction"],mutationFn:async e=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.sendInteraction)(t,e)}})}function useSiweAuthenticate({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","siwe-authenticate",t?.config.domain??"no-domain"],mutationFn:async e=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.siweAuthenticate)(t,e)}})}function useMounted(){let[e,t]=(0,external_react_namespaceObject.useState)(!1);return(0,external_react_namespaceObject.useEffect)(()=>{t(!0)},[]),e}function useWindowLocation(){let e=useMounted(),[t,a]=(0,external_react_namespaceObject.useState)(e?window.location:void 0);(0,external_react_namespaceObject.useEffect)(()=>{if(e)return t||r(),window.addEventListener("popstate",r),()=>{window.removeEventListener("popstate",r)};function r(){a(window.location)}},[e,t]);let r=(0,external_react_namespaceObject.useMemo)(()=>t?.href,[t?.href]);return{location:t,href:r}}function useFrakContext(){let{location:e}=useWindowLocation();return{frakContext:(0,external_react_namespaceObject.useMemo)(()=>e?.href?core_sdk_namespaceObject.FrakContextManager.parse({url:e.href}):null,[e?.href]),updateContext:(0,external_react_namespaceObject.useCallback)(t=>{console.log("Updating context",{newContext:t}),core_sdk_namespaceObject.FrakContextManager.replaceUrl({url:e?.href,context:t})},[e?.href])}}function useReferralInteraction({productId:e,modalConfig:t,options:a}={}){let r=useFrakClient(),{frakContext:n}=useFrakContext(),{data:o}=useWalletStatus(),{data:c,error:s,status:i}=(0,react_query_namespaceObject.useQuery)({gcTime:0,staleTime:0,queryKey:["frak-sdk","auto-referral-interaction",n?.r??"no-referrer",o?.key??"no-wallet-status",e??"no-product-id"],queryFn:()=>{if(!r)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.processReferral)(r,{walletStatus:o,frakContext:n,modalConfig:t,productId:e,options:a})},enabled:!!o});return(0,external_react_namespaceObject.useMemo)(()=>"pending"===i?"processing":"error"===i?s:c||"idle",[c,i,s])}function useDisplayModal({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","display-modal"],mutationFn:async e=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.displayModal)(t,e)}})}function useOpenSso({mutations:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useMutation)({...e,mutationKey:["frak-sdk","open-sso"],mutationFn:async e=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.openSso)(t,e)}})}function useGetProductInformation({query:e}={}){let t=useFrakClient();return(0,react_query_namespaceObject.useQuery)({...e,queryKey:["frak-sdk","get-product-information"],queryFn:async()=>{if(!t)throw new rpc_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.getProductInformation)(t)}})}for(var __webpack_i__ in exports.FrakConfigContext=__webpack_exports__.FrakConfigContext,exports.FrakConfigProvider=__webpack_exports__.FrakConfigProvider,exports.FrakIFrameClientContext=__webpack_exports__.FrakIFrameClientContext,exports.FrakIFrameClientProvider=__webpack_exports__.FrakIFrameClientProvider,exports.useDisplayModal=__webpack_exports__.useDisplayModal,exports.useFrakClient=__webpack_exports__.useFrakClient,exports.useFrakConfig=__webpack_exports__.useFrakConfig,exports.useGetProductInformation=__webpack_exports__.useGetProductInformation,exports.useOpenSso=__webpack_exports__.useOpenSso,exports.useReferralInteraction=__webpack_exports__.useReferralInteraction,exports.useSendInteraction=__webpack_exports__.useSendInteraction,exports.useSendTransactionAction=__webpack_exports__.useSendTransactionAction,exports.useSiweAuthenticate=__webpack_exports__.useSiweAuthenticate,exports.useWalletStatus=__webpack_exports__.useWalletStatus,__webpack_exports__)-1===["FrakConfigContext","FrakConfigProvider","FrakIFrameClientContext","FrakIFrameClientProvider","useDisplayModal","useFrakClient","useFrakConfig","useGetProductInformation","useOpenSso","useReferralInteraction","useSendInteraction","useSendTransactionAction","useSiweAuthenticate","useWalletStatus"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { Context } from 'react';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
|
|
4
|
-
import { DisplayModalParamsType } from '@frak-labs/core-sdk';
|
|
3
|
+
import type { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
|
|
4
|
+
import type { DisplayModalParamsType } from '@frak-labs/core-sdk';
|
|
5
5
|
import { FragmentProps } from 'react';
|
|
6
6
|
import { FrakClient } from '@frak-labs/core-sdk';
|
|
7
|
-
import { FrakRpcError } from '@frak-labs/
|
|
7
|
+
import { FrakRpcError } from '@frak-labs/rpc';
|
|
8
8
|
import { FrakWalletSdkConfig } from '@frak-labs/core-sdk';
|
|
9
9
|
import { FunctionComponentElement } from 'react';
|
|
10
|
-
import { GetProductInformationReturnType } from '@frak-labs/core-sdk';
|
|
10
|
+
import type { GetProductInformationReturnType } from '@frak-labs/core-sdk';
|
|
11
11
|
import { Hex } from 'viem';
|
|
12
|
-
import { ModalRpcStepsResultType } from '@frak-labs/core-sdk';
|
|
13
|
-
import { ModalStepTypes } from '@frak-labs/core-sdk';
|
|
14
|
-
import { OpenSsoParamsType } from '@frak-labs/core-sdk';
|
|
12
|
+
import type { ModalRpcStepsResultType } from '@frak-labs/core-sdk';
|
|
13
|
+
import type { ModalStepTypes } from '@frak-labs/core-sdk';
|
|
14
|
+
import type { OpenSsoParamsType } from '@frak-labs/core-sdk';
|
|
15
|
+
import type { OpenSsoReturnType } from '@frak-labs/core-sdk';
|
|
15
16
|
import { ProcessReferralOptions } from '@frak-labs/core-sdk/actions';
|
|
16
17
|
import { PropsWithChildren } from 'react';
|
|
17
18
|
import { ProviderProps } from 'react';
|
|
18
19
|
import { ReactNode } from 'react';
|
|
19
|
-
import { SendInteractionParamsType } from '@frak-labs/core-sdk';
|
|
20
|
-
import { SendInteractionReturnType } from '@frak-labs/core-sdk';
|
|
20
|
+
import type { SendInteractionParamsType } from '@frak-labs/core-sdk';
|
|
21
|
+
import type { SendInteractionReturnType } from '@frak-labs/core-sdk';
|
|
21
22
|
import { SendTransactionParams } from '@frak-labs/core-sdk/actions';
|
|
22
|
-
import { SendTransactionReturnType } from '@frak-labs/core-sdk';
|
|
23
|
+
import type { SendTransactionReturnType } from '@frak-labs/core-sdk';
|
|
23
24
|
import { SiweAuthenticateModalParams } from '@frak-labs/core-sdk/actions';
|
|
24
|
-
import { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
|
|
25
|
+
import type { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
|
|
25
26
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
26
27
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
27
28
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
28
29
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
29
|
-
import { WalletStatusReturnType } from '@frak-labs/core-sdk';
|
|
30
|
+
import type { WalletStatusReturnType } from '@frak-labs/core-sdk';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The context that will keep the Frak Wallet SDK configuration
|
|
@@ -104,7 +105,7 @@ declare type MutationOptions_3 = Omit<UseMutationOptions<SiweAuthenticateReturnT
|
|
|
104
105
|
declare type MutationOptions_4<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
|
|
105
106
|
|
|
106
107
|
/** @ignore */
|
|
107
|
-
declare type MutationOptions_5 = Omit<UseMutationOptions<
|
|
108
|
+
declare type MutationOptions_5 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
|
|
108
109
|
|
|
109
110
|
/** @ignore */
|
|
110
111
|
declare type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
|
|
@@ -203,7 +204,17 @@ declare interface UseGetProductInformationParams {
|
|
|
203
204
|
* @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
|
|
204
205
|
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
205
206
|
*/
|
|
206
|
-
export declare function useOpenSso({ mutations }?:
|
|
207
|
+
export declare function useOpenSso({ mutations }?: UseOpenSsoParams): UseMutationResult< {
|
|
208
|
+
wallet?: Hex;
|
|
209
|
+
}, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
210
|
+
|
|
211
|
+
/** @inline */
|
|
212
|
+
declare interface UseOpenSsoParams {
|
|
213
|
+
/**
|
|
214
|
+
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
215
|
+
*/
|
|
216
|
+
mutations?: MutationOptions_5;
|
|
217
|
+
}
|
|
207
218
|
|
|
208
219
|
/**
|
|
209
220
|
* Helper hook to automatically submit a referral interaction when detected
|
|
@@ -256,14 +267,6 @@ declare interface UseSendInteractionParams {
|
|
|
256
267
|
mutations?: MutationOptions_2;
|
|
257
268
|
}
|
|
258
269
|
|
|
259
|
-
/** @inline */
|
|
260
|
-
declare interface UseSendInteractionParams_2 {
|
|
261
|
-
/**
|
|
262
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
263
|
-
*/
|
|
264
|
-
mutations?: MutationOptions_5;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
270
|
/**
|
|
268
271
|
* Hook that return a mutation helping to send a transaction
|
|
269
272
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { Context } from 'react';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
-
import { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
|
|
4
|
-
import { DisplayModalParamsType } from '@frak-labs/core-sdk';
|
|
3
|
+
import type { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
|
|
4
|
+
import type { DisplayModalParamsType } from '@frak-labs/core-sdk';
|
|
5
5
|
import { FragmentProps } from 'react';
|
|
6
6
|
import { FrakClient } from '@frak-labs/core-sdk';
|
|
7
|
-
import { FrakRpcError } from '@frak-labs/
|
|
7
|
+
import { FrakRpcError } from '@frak-labs/rpc';
|
|
8
8
|
import { FrakWalletSdkConfig } from '@frak-labs/core-sdk';
|
|
9
9
|
import { FunctionComponentElement } from 'react';
|
|
10
|
-
import { GetProductInformationReturnType } from '@frak-labs/core-sdk';
|
|
10
|
+
import type { GetProductInformationReturnType } from '@frak-labs/core-sdk';
|
|
11
11
|
import { Hex } from 'viem';
|
|
12
|
-
import { ModalRpcStepsResultType } from '@frak-labs/core-sdk';
|
|
13
|
-
import { ModalStepTypes } from '@frak-labs/core-sdk';
|
|
14
|
-
import { OpenSsoParamsType } from '@frak-labs/core-sdk';
|
|
12
|
+
import type { ModalRpcStepsResultType } from '@frak-labs/core-sdk';
|
|
13
|
+
import type { ModalStepTypes } from '@frak-labs/core-sdk';
|
|
14
|
+
import type { OpenSsoParamsType } from '@frak-labs/core-sdk';
|
|
15
|
+
import type { OpenSsoReturnType } from '@frak-labs/core-sdk';
|
|
15
16
|
import { ProcessReferralOptions } from '@frak-labs/core-sdk/actions';
|
|
16
17
|
import { PropsWithChildren } from 'react';
|
|
17
18
|
import { ProviderProps } from 'react';
|
|
18
19
|
import { ReactNode } from 'react';
|
|
19
|
-
import { SendInteractionParamsType } from '@frak-labs/core-sdk';
|
|
20
|
-
import { SendInteractionReturnType } from '@frak-labs/core-sdk';
|
|
20
|
+
import type { SendInteractionParamsType } from '@frak-labs/core-sdk';
|
|
21
|
+
import type { SendInteractionReturnType } from '@frak-labs/core-sdk';
|
|
21
22
|
import { SendTransactionParams } from '@frak-labs/core-sdk/actions';
|
|
22
|
-
import { SendTransactionReturnType } from '@frak-labs/core-sdk';
|
|
23
|
+
import type { SendTransactionReturnType } from '@frak-labs/core-sdk';
|
|
23
24
|
import { SiweAuthenticateModalParams } from '@frak-labs/core-sdk/actions';
|
|
24
|
-
import { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
|
|
25
|
+
import type { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
|
|
25
26
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
26
27
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
27
28
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
28
29
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
29
|
-
import { WalletStatusReturnType } from '@frak-labs/core-sdk';
|
|
30
|
+
import type { WalletStatusReturnType } from '@frak-labs/core-sdk';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* The context that will keep the Frak Wallet SDK configuration
|
|
@@ -104,7 +105,7 @@ declare type MutationOptions_3 = Omit<UseMutationOptions<SiweAuthenticateReturnT
|
|
|
104
105
|
declare type MutationOptions_4<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
|
|
105
106
|
|
|
106
107
|
/** @ignore */
|
|
107
|
-
declare type MutationOptions_5 = Omit<UseMutationOptions<
|
|
108
|
+
declare type MutationOptions_5 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
|
|
108
109
|
|
|
109
110
|
/** @ignore */
|
|
110
111
|
declare type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
|
|
@@ -203,7 +204,17 @@ declare interface UseGetProductInformationParams {
|
|
|
203
204
|
* @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
|
|
204
205
|
* @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
|
|
205
206
|
*/
|
|
206
|
-
export declare function useOpenSso({ mutations }?:
|
|
207
|
+
export declare function useOpenSso({ mutations }?: UseOpenSsoParams): UseMutationResult< {
|
|
208
|
+
wallet?: Hex;
|
|
209
|
+
}, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
210
|
+
|
|
211
|
+
/** @inline */
|
|
212
|
+
declare interface UseOpenSsoParams {
|
|
213
|
+
/**
|
|
214
|
+
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
215
|
+
*/
|
|
216
|
+
mutations?: MutationOptions_5;
|
|
217
|
+
}
|
|
207
218
|
|
|
208
219
|
/**
|
|
209
220
|
* Helper hook to automatically submit a referral interaction when detected
|
|
@@ -256,14 +267,6 @@ declare interface UseSendInteractionParams {
|
|
|
256
267
|
mutations?: MutationOptions_2;
|
|
257
268
|
}
|
|
258
269
|
|
|
259
|
-
/** @inline */
|
|
260
|
-
declare interface UseSendInteractionParams_2 {
|
|
261
|
-
/**
|
|
262
|
-
* Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
|
|
263
|
-
*/
|
|
264
|
-
mutations?: MutationOptions_5;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
270
|
/**
|
|
268
271
|
* Hook that return a mutation helping to send a transaction
|
|
269
272
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as t,createContext as e,createElement as n,useCallback as r,useContext as o,useEffect as i,useMemo as a,useState as u}from"react";import{
|
|
1
|
+
import{Fragment as t,createContext as e,createElement as n,useCallback as r,useContext as o,useEffect as i,useMemo as a,useState as u}from"react";import{FrakContextManager as l,baseIframeProps as f,createIFrameFrakClient as s}from"@frak-labs/core-sdk";import{ClientNotFound as c,FrakRpcError as d,RpcErrorCodes as w}from"@frak-labs/rpc";import{displayModal as m,getProductInformation as k,openSso as y,processReferral as p,sendInteraction as h,sendTransaction as F,siweAuthenticate as v,watchWalletStatus as g}from"@frak-labs/core-sdk/actions";import{useMutation as C,useQuery as K,useQueryClient as q}from"@tanstack/react-query";let x=e(void 0);function b(t){let{children:e,config:r}=t;return n(x.Provider,{value:{...r,walletUrl:r.walletUrl??"https://wallet.frak.id",domain:r.domain??("undefined"!=typeof window?window?.location?.host:void 0)??"not-found"}},e)}function I(){let t=o(x);if(!t)throw new d(w.configError,"Frak config not found");return t}let P=e(void 0);function S({style:e,children:r}){let o=I(),[i,a]=u(void 0),l=n("iframe",{...f,src:`${o.walletUrl}/listener`,style:e??f.style,ref:t=>{t&&!i&&a(s({iframe:t,config:o}))}}),c=n(P.Provider,{value:i},r);return n(t,null,l,c)}function T(){return o(P)}function U(){let t=q(),e=T(),n=r(e=>{t.setQueryData(["frak-sdk","wallet-status-listener"],e)},[t]);return K({gcTime:0,staleTime:0,queryKey:["frak-sdk","wallet-status-listener"],queryFn:async()=>{if(!e)throw new c;return g(e,n)},enabled:!!e})}function E({mutations:t}={}){let e=T();return C({...t,mutationKey:["frak-sdk","send-transaction"],mutationFn:async t=>{if(!e)throw new c;return F(e,t)}})}function A({mutations:t}={}){let e=T();return C({...t,mutationKey:["frak-sdk","send-interaction"],mutationFn:async t=>{if(!e)throw new c;return h(e,t)}})}function D({mutations:t}={}){let e=T();return C({...t,mutationKey:["frak-sdk","siwe-authenticate",e?.config.domain??"no-domain"],mutationFn:async t=>{if(!e)throw new c;return v(e,t)}})}function L({productId:t,modalConfig:e,options:n}={}){let o=T(),{frakContext:f}=function(){let{location:t}=function(){let t=function(){let[t,e]=u(!1);return i(()=>{e(!0)},[]),t}(),[e,n]=u(t?window.location:void 0);i(()=>{if(t)return e||r(),window.addEventListener("popstate",r),()=>{window.removeEventListener("popstate",r)};function r(){n(window.location)}},[t,e]);let r=a(()=>e?.href,[e?.href]);return{location:e,href:r}}();return{frakContext:a(()=>t?.href?l.parse({url:t.href}):null,[t?.href]),updateContext:r(e=>{console.log("Updating context",{newContext:e}),l.replaceUrl({url:t?.href,context:e})},[t?.href])}}(),{data:s}=U(),{data:d,error:w,status:m}=K({gcTime:0,staleTime:0,queryKey:["frak-sdk","auto-referral-interaction",f?.r??"no-referrer",s?.key??"no-wallet-status",t??"no-product-id"],queryFn:()=>{if(!o)throw new c;return p(o,{walletStatus:s,frakContext:f,modalConfig:e,productId:t,options:n})},enabled:!!s});return a(()=>"pending"===m?"processing":"error"===m?w:d||"idle",[d,m,w])}function G({mutations:t}={}){let e=T();return C({...t,mutationKey:["frak-sdk","display-modal"],mutationFn:async t=>{if(!e)throw new c;return m(e,t)}})}function M({mutations:t}={}){let e=T();return C({...t,mutationKey:["frak-sdk","open-sso"],mutationFn:async t=>{if(!e)throw new c;return y(e,t)}})}function O({query:t}={}){let e=T();return K({...t,queryKey:["frak-sdk","get-product-information"],queryFn:async()=>{if(!e)throw new c;return k(e)}})}export{x as FrakConfigContext,b as FrakConfigProvider,P as FrakIFrameClientContext,S as FrakIFrameClientProvider,G as useDisplayModal,T as useFrakClient,I as useFrakConfig,O as useGetProductInformation,M as useOpenSso,L as useReferralInteraction,A as useSendInteraction,E as useSendTransactionAction,D as useSiweAuthenticate,U as useWalletStatus};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.18-beta.27947565",
|
|
15
15
|
"description": "React SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"publish": "echo 'Publishing react...'"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@frak-labs/
|
|
65
|
+
"@frak-labs/rpc": "0.0.0",
|
|
66
|
+
"@frak-labs/core-sdk": "0.0.18"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
69
|
"viem": "^2.x",
|