@frak-labs/nexus-sdk 0.0.9 → 0.0.11

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 (43) hide show
  1. package/dist/chunk-5CFD5FM2.js +86 -0
  2. package/dist/chunk-7MVQQ2X6.js +381 -0
  3. package/dist/chunk-ETV4XYOV.cjs +7 -0
  4. package/dist/chunk-GUDT2W6I.js +70 -0
  5. package/dist/chunk-IQQTTKJL.cjs +70 -0
  6. package/dist/chunk-PKBMQBKP.js +7 -0
  7. package/dist/chunk-S5FVCA2E.cjs +86 -0
  8. package/dist/chunk-V3S6RBRJ.cjs +381 -0
  9. package/dist/client-C7u9zGwC.d.cts +332 -0
  10. package/dist/client-gE3fYzkD.d.ts +332 -0
  11. package/dist/core/actions/index.cjs +3 -3
  12. package/dist/core/actions/index.d.cts +21 -28
  13. package/dist/core/actions/index.d.ts +21 -28
  14. package/dist/core/actions/index.js +12 -12
  15. package/dist/core/index.cjs +3 -8
  16. package/dist/core/index.d.cts +8 -35
  17. package/dist/core/index.d.ts +8 -35
  18. package/dist/core/index.js +9 -14
  19. package/dist/core/interactions/index.cjs +13 -0
  20. package/dist/core/interactions/index.d.cts +53 -0
  21. package/dist/core/interactions/index.d.ts +53 -0
  22. package/dist/core/interactions/index.js +13 -0
  23. package/dist/error-C4Zm5nQe.d.cts +27 -0
  24. package/dist/error-C4Zm5nQe.d.ts +27 -0
  25. package/dist/interaction-D3-M3nBh.d.cts +22 -0
  26. package/dist/interaction-D3-M3nBh.d.ts +22 -0
  27. package/dist/react/index.cjs +279 -166
  28. package/dist/react/index.d.cts +80 -37
  29. package/dist/react/index.d.ts +80 -37
  30. package/dist/react/index.js +291 -178
  31. package/dist/sendTransaction-BZW627cT.d.cts +30 -0
  32. package/dist/sendTransaction-DpJTfGJc.d.ts +30 -0
  33. package/package.json +16 -7
  34. package/dist/chunk-AYZHGMEV.cjs +0 -171
  35. package/dist/chunk-PDR3CF3P.js +0 -86
  36. package/dist/chunk-SZUN32YC.js +0 -171
  37. package/dist/chunk-VK7GPKK4.js +0 -169
  38. package/dist/chunk-X4JNNWJ4.cjs +0 -86
  39. package/dist/chunk-ZOLP2FJZ.cjs +0 -169
  40. package/dist/client-BwzXSgqQ.d.cts +0 -278
  41. package/dist/client-BwzXSgqQ.d.ts +0 -278
  42. package/dist/watchUnlockStatus-DXClCYH9.d.cts +0 -43
  43. package/dist/watchUnlockStatus-WJxoDliF.d.ts +0 -43
@@ -1,10 +1,15 @@
1
1
  import * as react from 'react';
2
- import { PropsWithChildren, ReactNode } from 'react';
3
- import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType, e as SetUserReferredParams, c as SetUserReferredReturnType } from '../client-BwzXSgqQ.cjs';
2
+ import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
3
+ import { f as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, c as SendTransactionReturnType, a as SiweAuthenticateReturnType, D as DisplayModalParamsType, d as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-C7u9zGwC.cjs';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
- import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-DXClCYH9.cjs';
6
- import 'viem';
5
+ import { UseMutationOptions } from '@tanstack/react-query';
6
+ import * as viem from 'viem';
7
+ import { Hex } from 'viem';
8
+ import { F as FrakRpcError } from '../error-C4Zm5nQe.cjs';
9
+ import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-BZW627cT.cjs';
10
+ import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.cjs';
7
11
  import 'viem/chains';
12
+ import 'viem/siwe';
8
13
 
9
14
  /**
10
15
  * The context that will keep the Nexus Wallet SDK configuration
@@ -13,13 +18,17 @@ declare const NexusConfigContext: react.Context<Readonly<{
13
18
  walletUrl: string;
14
19
  metadata: {
15
20
  name: string;
21
+ css?: string;
16
22
  };
23
+ domain: string;
17
24
  }> | undefined>;
18
25
  /**
19
26
  * Props to instantiate the Nexus Wallet SDK configuration provider
20
27
  */
21
28
  type NexusConfigProviderProps = {
22
- config: NexusWalletSdkConfig;
29
+ config: Omit<NexusWalletSdkConfig, "domain"> & {
30
+ domain?: string;
31
+ };
23
32
  };
24
33
  /**
25
34
  * Simple config provider for the Nexus Wallet SDK
@@ -30,7 +39,9 @@ declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigPr
30
39
  walletUrl: string;
31
40
  metadata: {
32
41
  name: string;
42
+ css?: string;
33
43
  };
44
+ domain: string;
34
45
  }> | undefined>>;
35
46
 
36
47
  /**
@@ -49,10 +60,11 @@ type NexusIFrameClientProps = {
49
60
  * @param parameters
50
61
  * @constructor
51
62
  */
52
- declare function NexusIFrameClientProvider({ children, }: {
63
+ declare function NexusIFrameClientProvider({ style, children, }: {
64
+ style?: CSSProperties;
53
65
  children?: ReactNode;
54
66
  }): react.FunctionComponentElement<{
55
- children?: ReactNode;
67
+ children?: ReactNode | undefined;
56
68
  }>;
57
69
 
58
70
  /**
@@ -62,52 +74,83 @@ declare function useNexusConfig(): Readonly<{
62
74
  walletUrl: string;
63
75
  metadata: {
64
76
  name: string;
77
+ css?: string;
65
78
  };
79
+ domain: string;
66
80
  }>;
67
81
 
68
82
  /**
69
83
  * Use the current nexus iframe client
70
84
  */
71
- declare function useNexusClient(): NexusClient;
85
+ declare function useNexusClient(): NexusClient | undefined;
72
86
 
73
87
  /**
74
- * Hook used to get the unlock options for an article
88
+ * Hooks used to listen to the current wallet status
75
89
  */
76
- declare function useArticleUnlockOptions({ articleId, contentId, }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
77
- frkBalanceAsHex?: `0x${string}` | undefined;
78
- prices: {
79
- index: number;
80
- unlockDurationInSec: number;
81
- frkAmount: `0x${string}`;
82
- isUserAccessible: boolean | null;
83
- }[];
84
- }>, Error>;
90
+ declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusReturnType, Error>;
85
91
 
86
- type WalletStatusQueryReturnType = WalletStatusReturnType | {
87
- key: "waiting-response";
88
- };
92
+ type MutationOptions$4 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
93
+ interface UseSendTransactionParams {
94
+ mutations?: MutationOptions$4;
95
+ }
89
96
  /**
90
- * Hooks used to listen to the current wallet status
97
+ * Trigger a dashboard action to the wallet
91
98
  */
92
- declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusQueryReturnType, Error>;
99
+ declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): _tanstack_react_query.UseMutationResult<Readonly<{
100
+ hash: viem.Hex;
101
+ }>, FrakRpcError<undefined>, SendTransactionParams, unknown>;
93
102
 
94
- type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
95
- status: "waiting-response";
96
- key: "waiting-response";
97
- };
103
+ type MutationOptions$3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
104
+ interface UseSiweAuthenticateParams {
105
+ mutations?: MutationOptions$3;
106
+ }
98
107
  /**
99
- * Hooks used to listen to the current article unlock status
108
+ * Trigger a dashboard action to the wallet
100
109
  */
101
- declare function useArticleUnlockStatus({ articleId, contentId, }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
110
+ declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): _tanstack_react_query.UseMutationResult<Readonly<{
111
+ signature: viem.Hex;
112
+ message: string;
113
+ }>, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
102
114
 
103
- type SetUserReferredQueryReturnType = SetUserReferredReturnType | {
104
- key: "waiting-response";
105
- } | {
106
- key: "no-referrer";
107
- };
115
+ type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
116
+ /**
117
+ * Helper hook to automatically submit a referral interaction when detected
118
+ * -> And automatically set the referral context in the url
119
+ * @param contentId
120
+ * @param modalConfig
121
+ */
122
+ declare function useReferralInteraction({ contentId, modalConfig, }?: {
123
+ contentId?: Hex;
124
+ modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
125
+ }): ReferralState;
126
+
127
+ type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
128
+ interface UseSendInteractionParams$1 {
129
+ mutations?: MutationOptions$2;
130
+ }
131
+ /**
132
+ * Send a user interaction
133
+ */
134
+ declare function useSendInteraction({ mutations, }?: UseSendInteractionParams$1): _tanstack_react_query.UseMutationResult<Readonly<{
135
+ delegationId: string;
136
+ }>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
137
+
138
+ type MutationOptions$1<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
139
+ interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
140
+ mutations?: MutationOptions$1<T>;
141
+ }
142
+ /**
143
+ * Send a user interaction
144
+ */
145
+ declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): _tanstack_react_query.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
146
+
147
+ type MutationOptions = Omit<UseMutationOptions<void, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
148
+ interface UseSendInteractionParams {
149
+ mutations?: MutationOptions;
150
+ }
108
151
  /**
109
- * Use the current nexus referral
152
+ * Open the SSO
110
153
  */
111
- declare function useNexusReferral({ contentId }: SetUserReferredParams): _tanstack_react_query.UseQueryResult<SetUserReferredQueryReturnType, Error>;
154
+ declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
112
155
 
113
- export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useNexusReferral, useWalletStatus };
156
+ export { NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, useDisplayModal, useNexusClient, useNexusConfig, useOpenSso, useReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };
@@ -1,10 +1,15 @@
1
1
  import * as react from 'react';
2
- import { PropsWithChildren, ReactNode } from 'react';
3
- import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType, e as SetUserReferredParams, c as SetUserReferredReturnType } from '../client-BwzXSgqQ.js';
2
+ import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
3
+ import { f as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, c as SendTransactionReturnType, a as SiweAuthenticateReturnType, D as DisplayModalParamsType, d as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType } from '../client-gE3fYzkD.js';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
- import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-WJxoDliF.js';
6
- import 'viem';
5
+ import { UseMutationOptions } from '@tanstack/react-query';
6
+ import * as viem from 'viem';
7
+ import { Hex } from 'viem';
8
+ import { F as FrakRpcError } from '../error-C4Zm5nQe.js';
9
+ import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-DpJTfGJc.js';
10
+ import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.js';
7
11
  import 'viem/chains';
12
+ import 'viem/siwe';
8
13
 
9
14
  /**
10
15
  * The context that will keep the Nexus Wallet SDK configuration
@@ -13,13 +18,17 @@ declare const NexusConfigContext: react.Context<Readonly<{
13
18
  walletUrl: string;
14
19
  metadata: {
15
20
  name: string;
21
+ css?: string;
16
22
  };
23
+ domain: string;
17
24
  }> | undefined>;
18
25
  /**
19
26
  * Props to instantiate the Nexus Wallet SDK configuration provider
20
27
  */
21
28
  type NexusConfigProviderProps = {
22
- config: NexusWalletSdkConfig;
29
+ config: Omit<NexusWalletSdkConfig, "domain"> & {
30
+ domain?: string;
31
+ };
23
32
  };
24
33
  /**
25
34
  * Simple config provider for the Nexus Wallet SDK
@@ -30,7 +39,9 @@ declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigPr
30
39
  walletUrl: string;
31
40
  metadata: {
32
41
  name: string;
42
+ css?: string;
33
43
  };
44
+ domain: string;
34
45
  }> | undefined>>;
35
46
 
36
47
  /**
@@ -49,10 +60,11 @@ type NexusIFrameClientProps = {
49
60
  * @param parameters
50
61
  * @constructor
51
62
  */
52
- declare function NexusIFrameClientProvider({ children, }: {
63
+ declare function NexusIFrameClientProvider({ style, children, }: {
64
+ style?: CSSProperties;
53
65
  children?: ReactNode;
54
66
  }): react.FunctionComponentElement<{
55
- children?: ReactNode;
67
+ children?: ReactNode | undefined;
56
68
  }>;
57
69
 
58
70
  /**
@@ -62,52 +74,83 @@ declare function useNexusConfig(): Readonly<{
62
74
  walletUrl: string;
63
75
  metadata: {
64
76
  name: string;
77
+ css?: string;
65
78
  };
79
+ domain: string;
66
80
  }>;
67
81
 
68
82
  /**
69
83
  * Use the current nexus iframe client
70
84
  */
71
- declare function useNexusClient(): NexusClient;
85
+ declare function useNexusClient(): NexusClient | undefined;
72
86
 
73
87
  /**
74
- * Hook used to get the unlock options for an article
88
+ * Hooks used to listen to the current wallet status
75
89
  */
76
- declare function useArticleUnlockOptions({ articleId, contentId, }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
77
- frkBalanceAsHex?: `0x${string}` | undefined;
78
- prices: {
79
- index: number;
80
- unlockDurationInSec: number;
81
- frkAmount: `0x${string}`;
82
- isUserAccessible: boolean | null;
83
- }[];
84
- }>, Error>;
90
+ declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusReturnType, Error>;
85
91
 
86
- type WalletStatusQueryReturnType = WalletStatusReturnType | {
87
- key: "waiting-response";
88
- };
92
+ type MutationOptions$4 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
93
+ interface UseSendTransactionParams {
94
+ mutations?: MutationOptions$4;
95
+ }
89
96
  /**
90
- * Hooks used to listen to the current wallet status
97
+ * Trigger a dashboard action to the wallet
91
98
  */
92
- declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusQueryReturnType, Error>;
99
+ declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): _tanstack_react_query.UseMutationResult<Readonly<{
100
+ hash: viem.Hex;
101
+ }>, FrakRpcError<undefined>, SendTransactionParams, unknown>;
93
102
 
94
- type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
95
- status: "waiting-response";
96
- key: "waiting-response";
97
- };
103
+ type MutationOptions$3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
104
+ interface UseSiweAuthenticateParams {
105
+ mutations?: MutationOptions$3;
106
+ }
98
107
  /**
99
- * Hooks used to listen to the current article unlock status
108
+ * Trigger a dashboard action to the wallet
100
109
  */
101
- declare function useArticleUnlockStatus({ articleId, contentId, }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
110
+ declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): _tanstack_react_query.UseMutationResult<Readonly<{
111
+ signature: viem.Hex;
112
+ message: string;
113
+ }>, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
102
114
 
103
- type SetUserReferredQueryReturnType = SetUserReferredReturnType | {
104
- key: "waiting-response";
105
- } | {
106
- key: "no-referrer";
107
- };
115
+ type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
116
+ /**
117
+ * Helper hook to automatically submit a referral interaction when detected
118
+ * -> And automatically set the referral context in the url
119
+ * @param contentId
120
+ * @param modalConfig
121
+ */
122
+ declare function useReferralInteraction({ contentId, modalConfig, }?: {
123
+ contentId?: Hex;
124
+ modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
125
+ }): ReferralState;
126
+
127
+ type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
128
+ interface UseSendInteractionParams$1 {
129
+ mutations?: MutationOptions$2;
130
+ }
131
+ /**
132
+ * Send a user interaction
133
+ */
134
+ declare function useSendInteraction({ mutations, }?: UseSendInteractionParams$1): _tanstack_react_query.UseMutationResult<Readonly<{
135
+ delegationId: string;
136
+ }>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
137
+
138
+ type MutationOptions$1<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
139
+ interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
140
+ mutations?: MutationOptions$1<T>;
141
+ }
142
+ /**
143
+ * Send a user interaction
144
+ */
145
+ declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): _tanstack_react_query.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
146
+
147
+ type MutationOptions = Omit<UseMutationOptions<void, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
148
+ interface UseSendInteractionParams {
149
+ mutations?: MutationOptions;
150
+ }
108
151
  /**
109
- * Use the current nexus referral
152
+ * Open the SSO
110
153
  */
111
- declare function useNexusReferral({ contentId }: SetUserReferredParams): _tanstack_react_query.UseQueryResult<SetUserReferredQueryReturnType, Error>;
154
+ declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
112
155
 
113
- export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useNexusReferral, useWalletStatus };
156
+ export { NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, useDisplayModal, useNexusClient, useNexusConfig, useOpenSso, useReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };