@frak-labs/react-sdk 0.0.19-beta.f259d7fc → 0.1.0-beta.267778ad

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.
Files changed (41) hide show
  1. package/dist/hook/helper/useReferralInteraction.d.cts +24 -0
  2. package/dist/hook/helper/useReferralInteraction.d.ts +24 -0
  3. package/dist/hook/index.d.cts +11 -0
  4. package/dist/hook/index.d.ts +11 -0
  5. package/dist/hook/useDisplayModal.d.cts +38 -0
  6. package/dist/hook/useDisplayModal.d.ts +38 -0
  7. package/dist/hook/useFrakClient.d.cts +6 -0
  8. package/dist/hook/useFrakClient.d.ts +6 -0
  9. package/dist/hook/useFrakConfig.d.cts +9 -0
  10. package/dist/hook/useFrakConfig.d.ts +9 -0
  11. package/dist/hook/useGetProductInformation.d.cts +30 -0
  12. package/dist/hook/useGetProductInformation.d.ts +30 -0
  13. package/dist/hook/useOpenSso.d.cts +33 -0
  14. package/dist/hook/useOpenSso.d.ts +33 -0
  15. package/dist/hook/usePrepareSso.d.cts +40 -0
  16. package/dist/hook/usePrepareSso.d.ts +40 -0
  17. package/dist/hook/useSendInteraction.d.cts +33 -0
  18. package/dist/hook/useSendInteraction.d.ts +33 -0
  19. package/dist/hook/useSendTransaction.d.cts +34 -0
  20. package/dist/hook/useSendTransaction.d.ts +34 -0
  21. package/dist/hook/useSiweAuthenticate.d.cts +35 -0
  22. package/dist/hook/useSiweAuthenticate.d.ts +35 -0
  23. package/dist/hook/useWalletStatus.d.cts +16 -0
  24. package/dist/hook/useWalletStatus.d.ts +16 -0
  25. package/dist/hook/utils/useFrakContext.d.cts +9 -0
  26. package/dist/hook/utils/useFrakContext.d.ts +9 -0
  27. package/dist/hook/utils/useMounted.d.cts +2 -0
  28. package/dist/hook/utils/useMounted.d.ts +2 -0
  29. package/dist/hook/utils/useWindowLocation.d.cts +8 -0
  30. package/dist/hook/utils/useWindowLocation.d.ts +8 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +3 -345
  33. package/dist/index.d.ts +3 -345
  34. package/dist/index.js +1 -1
  35. package/dist/provider/FrakConfigProvider.d.cts +29 -0
  36. package/dist/provider/FrakConfigProvider.d.ts +29 -0
  37. package/dist/provider/FrakIFrameClientProvider.d.cts +32 -0
  38. package/dist/provider/FrakIFrameClientProvider.d.ts +32 -0
  39. package/dist/provider/index.d.cts +4 -0
  40. package/dist/provider/index.d.ts +4 -0
  41. package/package.json +6 -3
@@ -0,0 +1,16 @@
1
+ import type { WalletStatusReturnType } from "@frak-labs/core-sdk";
2
+ /**
3
+ * Hook that return a query helping to get the current wallet status.
4
+ *
5
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
6
+ *
7
+ * @group hooks
8
+ *
9
+ * @returns
10
+ * The query hook wrapping the `watchWalletStatus()` action
11
+ * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
12
+ *
13
+ * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
14
+ * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
15
+ */
16
+ export declare function useWalletStatus(): import("@tanstack/react-query").UseQueryResult<WalletStatusReturnType, Error>;
@@ -0,0 +1,9 @@
1
+ import { type FrakContext } from "@frak-labs/core-sdk";
2
+ /**
3
+ * Extract the current frak context from the url
4
+ * @ignore
5
+ */
6
+ export declare function useFrakContext(): {
7
+ frakContext: FrakContext | null | undefined;
8
+ updateContext: (newContext: Partial<FrakContext>) => void;
9
+ };
@@ -0,0 +1,9 @@
1
+ import { type FrakContext } from "@frak-labs/core-sdk";
2
+ /**
3
+ * Extract the current frak context from the url
4
+ * @ignore
5
+ */
6
+ export declare function useFrakContext(): {
7
+ frakContext: FrakContext | null | undefined;
8
+ updateContext: (newContext: Partial<FrakContext>) => void;
9
+ };
@@ -0,0 +1,2 @@
1
+ /** @ignore */
2
+ export declare function useMounted(): boolean;
@@ -0,0 +1,2 @@
1
+ /** @ignore */
2
+ export declare function useMounted(): boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the current window location and href
3
+ * @ignore
4
+ */
5
+ export declare function useWindowLocation(): {
6
+ location: Location | undefined;
7
+ href: string | undefined;
8
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns the current window location and href
3
+ * @ignore
4
+ */
5
+ export declare function useWindowLocation(): {
6
+ location: Location | undefined;
7
+ href: string | undefined;
8
+ };
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"),frame_connector_namespaceObject=require("@frak-labs/frame-connector");function useFrakConfig(){let e=(0,external_react_namespaceObject.useContext)(FrakConfigContext);if(!e)throw new frame_connector_namespaceObject.FrakRpcError(frame_connector_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 frame_connector_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 frame_connector_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 frame_connector_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 frame_connector_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:_}=(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 frame_connector_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"===_?"processing":"error"===_?s:c||"idle",[c,_,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 frame_connector_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 frame_connector_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 frame_connector_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});
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 r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__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__,{useOpenSso:()=>useOpenSso,useWalletStatus:()=>useWalletStatus,useReferralInteraction:()=>useReferralInteraction,useSendTransactionAction:()=>useSendTransactionAction,FrakConfigProvider:()=>FrakConfigProvider,useSendInteraction:()=>useSendInteraction,useGetProductInformation:()=>useGetProductInformation,FrakConfigContext:()=>FrakConfigContext,useDisplayModal:()=>useDisplayModal,useFrakClient:()=>useFrakClient,FrakIFrameClientProvider:()=>FrakIFrameClientProvider,useFrakConfig:()=>useFrakConfig,usePrepareSso:()=>usePrepareSso,useSiweAuthenticate:()=>useSiweAuthenticate,FrakIFrameClientContext:()=>FrakIFrameClientContext});let external_react_namespaceObject=require("react"),FrakConfigContext=(0,external_react_namespaceObject.createContext)(void 0);function FrakConfigProvider(e){let{children:t,config:r}=e;return(0,external_react_namespaceObject.createElement)(FrakConfigContext.Provider,{value:{...r,walletUrl:r.walletUrl??"https://wallet.frak.id",domain:r.domain??("undefined"!=typeof window?window?.location?.host:void 0)??"not-found"}},t)}let core_sdk_namespaceObject=require("@frak-labs/core-sdk"),frame_connector_namespaceObject=require("@frak-labs/frame-connector");function useFrakConfig(){let e=(0,external_react_namespaceObject.useContext)(FrakConfigContext);if(!e)throw new frame_connector_namespaceObject.FrakRpcError(frame_connector_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 r=useFrakConfig(),[a,n]=(0,external_react_namespaceObject.useState)(void 0),o=(0,external_react_namespaceObject.createElement)("iframe",{...core_sdk_namespaceObject.baseIframeProps,src:`${r.walletUrl}/listener`,style:e??core_sdk_namespaceObject.baseIframeProps.style,ref:e=>{e&&!a&&n((0,core_sdk_namespaceObject.createIFrameFrakClient)({iframe:e,config:r}))}}),c=(0,external_react_namespaceObject.createElement)(FrakIFrameClientContext.Provider,{value:a},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(),r=(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 frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.watchWalletStatus)(t,r)},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 frame_connector_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 frame_connector_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 frame_connector_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,r]=(0,external_react_namespaceObject.useState)(e?window.location:void 0);(0,external_react_namespaceObject.useEffect)(()=>{if(e)return t||a(),window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)};function a(){r(window.location)}},[e,t]);let a=(0,external_react_namespaceObject.useMemo)(()=>t?.href,[t?.href]);return{location:t,href:a}}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:r}={}){let a=useFrakClient(),{frakContext:n}=useFrakContext(),{data:o}=useWalletStatus(),{data:c,error:s,status:_}=(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(!a)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.processReferral)(a,{walletStatus:o,frakContext:n,modalConfig:t,productId:e,options:r})},enabled:!!o});return(0,external_react_namespaceObject.useMemo)(()=>"pending"===_?"processing":"error"===_?s:c||"idle",[c,_,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 frame_connector_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 frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.openSso)(t,e)}})}function usePrepareSso(e){let t=useFrakClient();return(0,react_query_namespaceObject.useQuery)({queryKey:["frak-sdk","prepare-sso",e],queryFn:async()=>{if(!t)throw new frame_connector_namespaceObject.ClientNotFound;return(0,actions_namespaceObject.prepareSso)(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 frame_connector_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.usePrepareSso=__webpack_exports__.usePrepareSso,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","usePrepareSso","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,345 +1,3 @@
1
- import { Context } from 'react';
2
- import { CSSProperties } from 'react';
3
- import type { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
4
- import type { DisplayModalParamsType } from '@frak-labs/core-sdk';
5
- import { FragmentProps } from 'react';
6
- import { FrakClient } from '@frak-labs/core-sdk';
7
- import { FrakRpcError } from '@frak-labs/frame-connector';
8
- import { FrakWalletSdkConfig } from '@frak-labs/core-sdk';
9
- import { FunctionComponentElement } from 'react';
10
- import type { GetProductInformationReturnType } from '@frak-labs/core-sdk';
11
- import { Hex } from 'viem';
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';
16
- import { ProcessReferralOptions } from '@frak-labs/core-sdk/actions';
17
- import { PropsWithChildren } from 'react';
18
- import { ProviderProps } from 'react';
19
- import { ReactNode } from 'react';
20
- import type { SendInteractionParamsType } from '@frak-labs/core-sdk';
21
- import type { SendInteractionReturnType } from '@frak-labs/core-sdk';
22
- import { SendTransactionParams } from '@frak-labs/core-sdk/actions';
23
- import type { SendTransactionReturnType } from '@frak-labs/core-sdk';
24
- import { SiweAuthenticateModalParams } from '@frak-labs/core-sdk/actions';
25
- import type { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
26
- import { UseMutationOptions } from '@tanstack/react-query';
27
- import { UseMutationResult } from '@tanstack/react-query';
28
- import { UseQueryOptions } from '@tanstack/react-query';
29
- import { UseQueryResult } from '@tanstack/react-query';
30
- import type { WalletStatusReturnType } from '@frak-labs/core-sdk';
31
-
32
- /**
33
- * The context that will keep the Frak Wallet SDK configuration
34
- * @ignore
35
- */
36
- export declare const FrakConfigContext: Context<FrakWalletSdkConfig | undefined>;
37
-
38
- /**
39
- * Simple config provider for the Frak Wallet SDK
40
- *
41
- * Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
42
- *
43
- * @group provider
44
- *
45
- * @param parameters
46
- */
47
- export declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): FunctionComponentElement<ProviderProps<FrakWalletSdkConfig | undefined>>;
48
-
49
- /**
50
- * Props to instantiate the Frak Wallet SDK configuration provider
51
- *
52
- * @group provider
53
- */
54
- export declare type FrakConfigProviderProps = {
55
- /**
56
- * The wanted Frak configuration
57
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
58
- */
59
- config: FrakWalletSdkConfig;
60
- };
61
-
62
- /**
63
- * The context that will keep the Frak Wallet SDK client
64
- * @ignore
65
- */
66
- export declare const FrakIFrameClientContext: Context<FrakClient | undefined>;
67
-
68
- /**
69
- * Props to instantiate the Frak Wallet SDK configuration provider
70
- *
71
- * @group provider
72
- */
73
- export declare type FrakIFrameClientProps = {
74
- config: FrakWalletSdkConfig;
75
- };
76
-
77
- /**
78
- * IFrame client provider for the Frak Wallet SDK
79
- * It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
80
- *
81
- * @group provider
82
- *
83
- * @remarks
84
- * This provider must be wrapped within a {@link FrakConfigProvider} to work properly
85
- *
86
- * @param args
87
- * @param args.style - Some custom styles to apply to the iFrame
88
- * @param args.children - Descedant components that will have access to the Frak Client
89
- */
90
- export declare function FrakIFrameClientProvider({ style, children, }: {
91
- style?: CSSProperties;
92
- children?: ReactNode;
93
- }): FunctionComponentElement<FragmentProps>;
94
-
95
- /** @ignore */
96
- declare type MutationOptions = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
97
-
98
- /** @ignore */
99
- declare type MutationOptions_2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
100
-
101
- /** @inline */
102
- declare type MutationOptions_3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
103
-
104
- /** @ignore */
105
- declare type MutationOptions_4<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
106
-
107
- /** @ignore */
108
- declare type MutationOptions_5 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
109
-
110
- /** @ignore */
111
- declare type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
112
-
113
- /**
114
- * Hook that return a mutation helping to display a modal to the user
115
- *
116
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
117
- *
118
- * @param args
119
- *
120
- * @typeParam T
121
- * The modal steps types to display (the result will correspond to the steps types asked in params)
122
- * An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
123
- * If not provided, it will default to a generic array of `ModalStepTypes`
124
- *
125
- * @group hooks
126
- *
127
- * @returns
128
- * The mutation hook wrapping the `displayModal()` action
129
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.DisplayModalParamsType | `DisplayModalParamsType<T>`}, with type params `T` being the modal steps types to display
130
- * The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
131
- *
132
- * @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
133
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
134
- */
135
- export declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): UseMutationResult< { [K in T[number]["key"]]: Extract<T[number], {
136
- key: K;
137
- }>["returns"]; }, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
138
-
139
- /** @inline */
140
- declare interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
141
- /**
142
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
143
- */
144
- mutations?: MutationOptions_4<T>;
145
- }
146
-
147
- /**
148
- * Get the current Frak client
149
- *
150
- * @group hooks
151
- */
152
- export declare function useFrakClient(): FrakClient | undefined;
153
-
154
- /**
155
- * Get the current Frak config
156
- * @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
157
- * @group hooks
158
- *
159
- * @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
160
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
161
- */
162
- export declare function useFrakConfig(): FrakWalletSdkConfig;
163
-
164
- /**
165
- * Hook that return a query helping to get the current product information
166
- *
167
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} action
168
- *
169
- * @param args
170
- *
171
- * @group hooks
172
- *
173
- * @returns
174
- * The query hook wrapping the `getProductInformation()` action
175
- * The `data` result is a {@link @frak-labs/core-sdk!index.GetProductInformationReturnType | `GetProductInformationReturnType`}
176
- *
177
- * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the underlying action
178
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
179
- */
180
- export declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): UseQueryResult<undefined, FrakRpcError<undefined>>;
181
-
182
- /** @inline */
183
- declare interface UseGetProductInformationParams {
184
- /**
185
- * Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
186
- */
187
- query?: QueryOptions;
188
- }
189
-
190
- /**
191
- * Hook that return a mutation helping to open the SSO page
192
- *
193
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
194
- *
195
- * @param args
196
- *
197
- * @group hooks
198
- *
199
- * @returns
200
- * The mutation hook wrapping the `openSso()` action
201
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
202
- * The mutation doesn't output any value
203
- *
204
- * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
205
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
206
- */
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
- }
218
-
219
- /**
220
- * Helper hook to automatically submit a referral interaction when detected
221
- *
222
- * @group hooks
223
- *
224
- * @param args
225
- * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
226
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
227
- * @param args.options - Some options for the referral interaction
228
- *
229
- * @returns The resulting referral state, or a potential error
230
- *
231
- * @description This function will automatically handle the referral interaction process
232
- *
233
- * @see {@link @frak-labs/core-sdk!actions.processReferral | `processReferral()`} for more details on the automatic referral handling process
234
- */
235
- export declare function useReferralInteraction({ productId, modalConfig, options, }?: {
236
- productId?: Hex;
237
- modalConfig?: DisplayEmbeddedWalletParamsType;
238
- options?: ProcessReferralOptions;
239
- }): Error | ("error" | "no-referrer" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "self-referral");
240
-
241
- /**
242
- * Hook that return a mutation helping to send a user interaction
243
- *
244
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} action
245
- *
246
- * @param args
247
- *
248
- * @group hooks
249
- *
250
- * @returns
251
- * The mutation hook wrapping the `sendInteraction()` action
252
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.SendInteractionParamsType | `SendInteractionParamsType`}
253
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendInteractionReturnType | `SendInteractionReturnType`}
254
- *
255
- * @see {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} for more info about the underlying action
256
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
257
- */
258
- export declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): UseMutationResult< {
259
- delegationId: string;
260
- }, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
261
-
262
- /** @inline */
263
- declare interface UseSendInteractionParams {
264
- /**
265
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
266
- */
267
- mutations?: MutationOptions_2;
268
- }
269
-
270
- /**
271
- * Hook that return a mutation helping to send a transaction
272
- *
273
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
274
- *
275
- * @param args
276
- *
277
- * @group hooks
278
- *
279
- * @returns
280
- * The mutation hook wrapping the `sendTransaction()` action
281
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
282
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
283
- *
284
- * @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
285
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
286
- */
287
- export declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): UseMutationResult< {
288
- hash: Hex;
289
- }, FrakRpcError<undefined>, SendTransactionParams, unknown>;
290
-
291
- /** @inline */
292
- declare interface UseSendTransactionParams {
293
- /**
294
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
295
- */
296
- mutations?: MutationOptions;
297
- }
298
-
299
- /**
300
- * Hook that return a mutation helping to send perform a SIWE authentication
301
- *
302
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
303
- *
304
- * @param args
305
- *
306
- * @group hooks
307
- *
308
- * @returns
309
- * The mutation hook wrapping the `siweAuthenticate()` action
310
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
311
- * The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
312
- *
313
- * @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
314
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
315
- */
316
- export declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): UseMutationResult< {
317
- signature: Hex;
318
- message: string;
319
- }, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
320
-
321
- /** @ignore */
322
- declare interface UseSiweAuthenticateParams {
323
- /**
324
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
325
- */
326
- mutations?: MutationOptions_3;
327
- }
328
-
329
- /**
330
- * Hook that return a query helping to get the current wallet status.
331
- *
332
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
333
- *
334
- * @group hooks
335
- *
336
- * @returns
337
- * The query hook wrapping the `watchWalletStatus()` action
338
- * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
339
- *
340
- * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
341
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
342
- */
343
- export declare function useWalletStatus(): UseQueryResult<WalletStatusReturnType, Error>;
344
-
345
- export { }
1
+ export { FrakConfigContext, FrakConfigProvider, FrakIFrameClientContext, FrakIFrameClientProvider, } from "./provider";
2
+ export type { FrakConfigProviderProps, FrakIFrameClientProps, } from "./provider";
3
+ export { useFrakConfig, useFrakClient, useWalletStatus, useSendTransactionAction, useSendInteraction, useSiweAuthenticate, useReferralInteraction, useDisplayModal, useOpenSso, usePrepareSso, useGetProductInformation, } from "./hook";