@frak-labs/nexus-sdk 0.0.8 → 0.0.10

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 (39) hide show
  1. package/dist/chunk-3T2FNW6E.cjs +100 -0
  2. package/dist/chunk-72IEHEQX.js +48 -0
  3. package/dist/chunk-BPFJZRJ6.cjs +152 -0
  4. package/dist/chunk-ETV4XYOV.cjs +7 -0
  5. package/dist/{chunk-OXP3VK26.js → chunk-HOX3RRO6.js} +58 -30
  6. package/dist/chunk-NIFJZD3M.cjs +48 -0
  7. package/dist/chunk-PKBMQBKP.js +7 -0
  8. package/dist/{chunk-JXQKTLEE.cjs → chunk-SGLR6RFA.cjs} +59 -31
  9. package/dist/chunk-T54VMWHQ.js +100 -0
  10. package/dist/chunk-TPC5PMRC.js +152 -0
  11. package/dist/{client-MgLVRfPw.d.cts → client--U_6SK0l.d.cts} +101 -12
  12. package/dist/{client-MgLVRfPw.d.ts → client-6_BJp7Ub.d.ts} +101 -12
  13. package/dist/core/actions/index.cjs +10 -3
  14. package/dist/core/actions/index.d.cts +31 -3
  15. package/dist/core/actions/index.d.ts +31 -3
  16. package/dist/core/actions/index.js +9 -2
  17. package/dist/core/index.cjs +4 -7
  18. package/dist/core/index.d.cts +8 -35
  19. package/dist/core/index.d.ts +8 -35
  20. package/dist/core/index.js +9 -12
  21. package/dist/core/interactions/index.cjs +9 -0
  22. package/dist/core/interactions/index.d.cts +39 -0
  23. package/dist/core/interactions/index.d.ts +39 -0
  24. package/dist/core/interactions/index.js +9 -0
  25. package/dist/error-C4Zm5nQe.d.cts +27 -0
  26. package/dist/error-C4Zm5nQe.d.ts +27 -0
  27. package/dist/interaction-D_CzyqRE.d.cts +22 -0
  28. package/dist/interaction-D_CzyqRE.d.ts +22 -0
  29. package/dist/react/index.cjs +276 -42
  30. package/dist/react/index.d.cts +72 -12
  31. package/dist/react/index.d.ts +72 -12
  32. package/dist/react/index.js +272 -38
  33. package/dist/{watchUnlockStatus-DQYfUj46.d.ts → watchUnlockStatus-CxnibdQx.d.cts} +3 -3
  34. package/dist/{watchUnlockStatus-DqWkImYK.d.cts → watchUnlockStatus-g8wIxpeM.d.ts} +3 -3
  35. package/package.json +11 -5
  36. package/dist/chunk-2XUJYDD3.cjs +0 -160
  37. package/dist/chunk-4VFMYMTH.js +0 -74
  38. package/dist/chunk-5QWG35A2.js +0 -160
  39. package/dist/chunk-6V4UCVTD.cjs +0 -74
@@ -1,12 +1,25 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkJXQKTLEEcjs = require('../chunk-JXQKTLEE.cjs');
3
+ var _chunkSGLR6RFAcjs = require('../chunk-SGLR6RFA.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunk6V4UCVTDcjs = require('../chunk-6V4UCVTD.cjs');
9
- require('../chunk-2XUJYDD3.cjs');
8
+
9
+
10
+
11
+ var _chunk3T2FNW6Ecjs = require('../chunk-3T2FNW6E.cjs');
12
+
13
+
14
+
15
+
16
+
17
+
18
+ var _chunkBPFJZRJ6cjs = require('../chunk-BPFJZRJ6.cjs');
19
+
20
+
21
+ var _chunkNIFJZD3Mcjs = require('../chunk-NIFJZD3M.cjs');
22
+ require('../chunk-ETV4XYOV.cjs');
10
23
 
11
24
  // src/react/provider/NexusConfigProvider.ts
12
25
  var _react = require('react');
@@ -15,7 +28,12 @@ function NexusConfigProvider(parameters) {
15
28
  const { children, config } = parameters;
16
29
  return _react.createElement.call(void 0,
17
30
  NexusConfigContext.Provider,
18
- { value: config },
31
+ {
32
+ value: {
33
+ ...config,
34
+ domain: _nullishCoalesce(_nullishCoalesce(config.domain, () => ( (typeof window !== "undefined" ? _optionalChain([window, 'optionalAccess', _ => _.location, 'optionalAccess', _2 => _2.host]) : void 0))), () => ( "not-found"))
35
+ }
36
+ },
19
37
  children
20
38
  );
21
39
  }
@@ -28,13 +46,15 @@ function NexusConfigProvider(parameters) {
28
46
 
29
47
 
30
48
 
31
-
32
49
  // src/react/hook/useNexusConfig.ts
33
50
 
34
51
  function useNexusConfig() {
35
52
  const config = _react.useContext.call(void 0, NexusConfigContext);
36
53
  if (!config) {
37
- throw new Error("NexusConfigProvider is not found");
54
+ throw new (0, _chunkBPFJZRJ6cjs.FrakRpcError)(
55
+ _chunkBPFJZRJ6cjs.RpcErrorCodes.configError,
56
+ "Nexus config not found"
57
+ );
38
58
  }
39
59
  return config;
40
60
  }
@@ -42,11 +62,7 @@ function useNexusConfig() {
42
62
  // src/react/hook/useNexusClient.ts
43
63
 
44
64
  function useNexusClient() {
45
- const client = _react.useContext.call(void 0, NexusIFrameClientContext);
46
- if (!client) {
47
- throw new Error("NexusIFrameClientProvider is not found");
48
- }
49
- return client;
65
+ return _react.useContext.call(void 0, NexusIFrameClientContext);
50
66
  }
51
67
 
52
68
  // src/react/hook/useArticleUnlockOptions.ts
@@ -57,17 +73,22 @@ function useArticleUnlockOptions({
57
73
  }) {
58
74
  const client = useNexusClient();
59
75
  return _reactquery.useQuery.call(void 0, {
60
- queryKey: ["articleUnlockOptions", _nullishCoalesce(articleId, () => ( "no-article-id"))],
76
+ queryKey: [
77
+ "nexus-sdk",
78
+ "article-unlock-options",
79
+ _nullishCoalesce(articleId, () => ( "no-article-id"))
80
+ ],
61
81
  queryFn: async () => {
82
+ if (!client) return;
62
83
  if (!(articleId && contentId)) {
63
84
  throw new Error("No article id provided");
64
85
  }
65
- return await _chunk6V4UCVTDcjs.getArticleUnlockOptions.call(void 0, client, {
86
+ return await _chunk3T2FNW6Ecjs.getArticleUnlockOptions.call(void 0, client, {
66
87
  articleId,
67
88
  contentId
68
89
  });
69
90
  },
70
- enabled: !!articleId && !!contentId,
91
+ enabled: !!client && !!articleId && !!contentId,
71
92
  gcTime: 0
72
93
  });
73
94
  }
@@ -80,17 +101,24 @@ function useWalletStatus() {
80
101
  const client = useNexusClient();
81
102
  const newStatusUpdated = _react.useCallback.call(void 0,
82
103
  (event) => {
83
- queryClient.setQueryData(["walletStatusListener"], event);
104
+ queryClient.setQueryData(
105
+ ["nexus-sdk", "wallet-status-listener"],
106
+ event
107
+ );
84
108
  },
85
109
  [queryClient]
86
110
  );
87
111
  return _reactquery.useQuery.call(void 0, {
88
112
  gcTime: 0,
89
- queryKey: ["walletStatusListener"],
113
+ queryKey: ["nexus-sdk", "wallet-status-listener"],
90
114
  queryFn: async () => {
91
- await _chunk6V4UCVTDcjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
115
+ if (!client) {
116
+ return { key: "waiting-response" };
117
+ }
118
+ await _chunk3T2FNW6Ecjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
92
119
  return { key: "waiting-response" };
93
- }
120
+ },
121
+ enabled: !!client
94
122
  });
95
123
  }
96
124
 
@@ -107,7 +135,8 @@ function useArticleUnlockStatus({
107
135
  (event) => {
108
136
  queryClient.setQueryData(
109
137
  [
110
- "articleUnlockStatusListener",
138
+ "nexus-sdk",
139
+ "article-unlock-status",
111
140
  _nullishCoalesce(articleId, () => ( "no-article-id")),
112
141
  _nullishCoalesce(contentId, () => ( "no-contentId-id"))
113
142
  ],
@@ -118,16 +147,23 @@ function useArticleUnlockStatus({
118
147
  );
119
148
  return _reactquery.useQuery.call(void 0, {
120
149
  queryKey: [
121
- "articleUnlockStatusListener",
150
+ "nexus-sdk",
151
+ "article-unlock-status",
122
152
  _nullishCoalesce(articleId, () => ( "no-article-id")),
123
153
  _nullishCoalesce(contentId, () => ( "no-contentId-id"))
124
154
  ],
125
155
  gcTime: 0,
126
156
  queryFn: async () => {
157
+ if (!client) {
158
+ return {
159
+ status: "waiting-response",
160
+ key: "waiting-response"
161
+ };
162
+ }
127
163
  if (!(articleId && contentId)) {
128
164
  return null;
129
165
  }
130
- await _chunk6V4UCVTDcjs.watchUnlockStatus.call(void 0,
166
+ await _chunk3T2FNW6Ecjs.watchUnlockStatus.call(void 0,
131
167
  client,
132
168
  { articleId, contentId },
133
169
  newStatusUpdated
@@ -137,43 +173,237 @@ function useArticleUnlockStatus({
137
173
  key: "waiting-response"
138
174
  };
139
175
  },
140
- enabled: !!articleId && !!contentId
176
+ enabled: !!client && !!articleId && !!contentId
177
+ });
178
+ }
179
+
180
+ // src/react/hook/useSendTransaction.ts
181
+
182
+ function useSendTransactionAction({
183
+ mutations
184
+ } = {}) {
185
+ const client = useNexusClient();
186
+ return _reactquery.useMutation.call(void 0, {
187
+ ...mutations,
188
+ mutationKey: ["nexus-sdk", "send-transaction"],
189
+ mutationFn: async (params) => {
190
+ if (!client) {
191
+ throw new (0, _chunkBPFJZRJ6cjs.ClientNotFound)();
192
+ }
193
+ return _chunk3T2FNW6Ecjs.sendTransaction.call(void 0, client, params);
194
+ }
195
+ });
196
+ }
197
+
198
+ // src/react/hook/useSiweAuthenticate.ts
199
+
200
+ function useSiweAuthenticate({
201
+ mutations
202
+ } = {}) {
203
+ const client = useNexusClient();
204
+ return _reactquery.useMutation.call(void 0, {
205
+ ...mutations,
206
+ mutationKey: [
207
+ "nexus-sdk",
208
+ "siwe-authenticate",
209
+ _nullishCoalesce(_optionalChain([client, 'optionalAccess', _3 => _3.config, 'access', _4 => _4.domain]), () => ( "no-domain"))
210
+ ],
211
+ mutationFn: async (params) => {
212
+ if (!client) {
213
+ throw new (0, _chunkBPFJZRJ6cjs.ClientNotFound)();
214
+ }
215
+ return _chunk3T2FNW6Ecjs.siweAuthenticate.call(void 0, client, params);
216
+ }
217
+ });
218
+ }
219
+
220
+ // src/react/hook/helper/usePressReferralInteraction.ts
221
+
222
+
223
+ var _viem = require('viem');
224
+
225
+ // src/react/hook/useSendInteraction.ts
226
+
227
+ function useSendInteraction({
228
+ mutations
229
+ } = {}) {
230
+ const client = useNexusClient();
231
+ return _reactquery.useMutation.call(void 0, {
232
+ ...mutations,
233
+ mutationKey: ["nexus-sdk", "send-interaction"],
234
+ mutationFn: async (params) => {
235
+ if (!client) {
236
+ throw new (0, _chunkBPFJZRJ6cjs.ClientNotFound)();
237
+ }
238
+ return _chunk3T2FNW6Ecjs.sendInteraction.call(void 0, client, params);
239
+ }
240
+ });
241
+ }
242
+
243
+ // src/react/hook/utils/useNexusContext.ts
244
+
245
+
246
+ // src/react/hook/utils/useWindowLocation.ts
247
+
248
+
249
+ // src/react/hook/utils/useMounted.ts
250
+
251
+ function useMounted() {
252
+ const [mounted, setMounted] = _react.useState.call(void 0, false);
253
+ _react.useEffect.call(void 0, () => {
254
+ setMounted(true);
255
+ }, []);
256
+ return mounted;
257
+ }
258
+
259
+ // src/react/hook/utils/useWindowLocation.ts
260
+ function useWindowLocation() {
261
+ const isMounted = useMounted();
262
+ const [location, setLocation] = _react.useState.call(void 0,
263
+ isMounted ? window.location : void 0
264
+ );
265
+ _react.useEffect.call(void 0, () => {
266
+ if (!isMounted) return;
267
+ function setWindowLocation() {
268
+ setLocation(window.location);
269
+ }
270
+ if (!location) {
271
+ setWindowLocation();
272
+ }
273
+ window.addEventListener("popstate", setWindowLocation);
274
+ return () => {
275
+ window.removeEventListener("popstate", setWindowLocation);
276
+ };
277
+ }, [isMounted, location]);
278
+ const href = _react.useMemo.call(void 0, () => _optionalChain([location, 'optionalAccess', _5 => _5.href]), [_optionalChain([location, 'optionalAccess', _6 => _6.href])]);
279
+ return { location, href };
280
+ }
281
+
282
+ // src/react/hook/utils/useNexusContext.ts
283
+ var contextKey = "nCtx";
284
+ function useNexusContext() {
285
+ const { location } = useWindowLocation();
286
+ const { data: nexusContext } = _reactquery.useQuery.call(void 0, {
287
+ queryKey: ["nexus-sdk", "context", _nullishCoalesce(_optionalChain([location, 'optionalAccess', _7 => _7.href]), () => ( "no-href"))],
288
+ queryFn: async () => {
289
+ if (!_optionalChain([location, 'optionalAccess', _8 => _8.href])) return null;
290
+ const url = new URL(location.href);
291
+ const nexusContext2 = url.searchParams.get(contextKey);
292
+ if (!nexusContext2) return null;
293
+ const parsedContext = await _chunkBPFJZRJ6cjs.decompressJson.call(void 0, nexusContext2);
294
+ if (!parsedContext) return null;
295
+ return parsedContext;
296
+ }
297
+ });
298
+ const { mutate: updateContext, mutateAsync: updateContextAsync } = _reactquery.useMutation.call(void 0, {
299
+ mutationKey: ["nexus-sdk", "update-context"],
300
+ mutationFn: async (newContext) => {
301
+ if (!location || typeof window === "undefined") return;
302
+ const fullNewContext = nexusContext ? { ...nexusContext, ...newContext } : newContext;
303
+ const compressedContext = await _chunkBPFJZRJ6cjs.compressJson.call(void 0, fullNewContext);
304
+ if (!compressedContext) return;
305
+ const url = new URL(location.href);
306
+ url.searchParams.set(contextKey, compressedContext);
307
+ window.history.replaceState(null, "", url.toString());
308
+ }
309
+ });
310
+ return { nexusContext, updateContext, updateContextAsync };
311
+ }
312
+
313
+ // src/react/hook/helper/usePressReferralInteraction.ts
314
+ function usePressReferralInteraction({ contentId }) {
315
+ const { nexusContext, updateContextAsync } = useNexusContext();
316
+ const { data: walletStatus } = useWalletStatus();
317
+ const { mutateAsync: sendInteraction2 } = useSendInteraction();
318
+ const { data, error, status } = _reactquery.useQuery.call(void 0, {
319
+ gcTime: 0,
320
+ queryKey: [
321
+ "nexus-sdk",
322
+ "auto-press-referral-interaction",
323
+ _nullishCoalesce(_optionalChain([nexusContext, 'optionalAccess', _9 => _9.r]), () => ( "no-referrer")),
324
+ _nullishCoalesce(_optionalChain([walletStatus, 'optionalAccess', _10 => _10.key]), () => ( "no-wallet-status"))
325
+ ],
326
+ queryFn: async () => {
327
+ if (!nexusContext && _optionalChain([walletStatus, 'optionalAccess', _11 => _11.key]) === "connected") {
328
+ await updateContextAsync({ r: walletStatus.wallet });
329
+ return null;
330
+ }
331
+ if (!nexusContext || _optionalChain([walletStatus, 'optionalAccess', _12 => _12.key]) !== "connected") return null;
332
+ if (_viem.isAddressEqual.call(void 0, nexusContext.r, walletStatus.wallet))
333
+ return null;
334
+ const interaction = _chunkNIFJZD3Mcjs.PressInteractionEncoder.referred({
335
+ referrer: nexusContext.r
336
+ });
337
+ await sendInteraction2({ contentId, interaction });
338
+ await updateContextAsync({ r: walletStatus.wallet });
339
+ return { referrer: nexusContext.r };
340
+ }
141
341
  });
342
+ return useOutputStateMapper({ data, error, status });
343
+ }
344
+ function useOutputStateMapper({
345
+ data,
346
+ error,
347
+ status
348
+ }) {
349
+ const errorState = _react.useMemo.call(void 0, () => {
350
+ if (!(error instanceof _chunkBPFJZRJ6cjs.FrakRpcError)) return null;
351
+ switch (error.code) {
352
+ case _chunkBPFJZRJ6cjs.RpcErrorCodes.walletNotConnected:
353
+ return "no-wallet";
354
+ case _chunkBPFJZRJ6cjs.RpcErrorCodes.noInteractionSession:
355
+ return "no-session";
356
+ default:
357
+ return "error";
358
+ }
359
+ }, [error]);
360
+ return _react.useMemo.call(void 0, () => {
361
+ switch (status) {
362
+ case "pending":
363
+ return "loading";
364
+ case "success":
365
+ return data === null ? "no-referral" : "referred";
366
+ case "error":
367
+ return _nullishCoalesce(errorState, () => ( "error"));
368
+ }
369
+ }, [data, errorState, status]);
142
370
  }
143
371
 
144
372
  // src/react/provider/NexusIFrameClientProvider.ts
145
373
  var NexusIFrameClientContext = _react.createContext.call(void 0,
146
374
  void 0
147
375
  );
376
+ var defaultIframeStyle = {
377
+ width: "0",
378
+ height: "0",
379
+ border: "0",
380
+ position: "absolute",
381
+ zIndex: 1e3,
382
+ top: "-1000px",
383
+ left: "-1000px"
384
+ };
148
385
  function NexusIFrameClientProvider({
386
+ style,
149
387
  children
150
388
  }) {
151
389
  const config = useNexusConfig();
152
- const [iframeElem, setIframeElem] = _react.useState.call(void 0,
153
- void 0
154
- );
155
- const client = _react.useMemo.call(void 0,
156
- () => iframeElem ? _chunkJXQKTLEEcjs.createIFrameNexusClient.call(void 0, { iframe: iframeElem, config }) : void 0,
157
- [iframeElem, config]
158
- );
390
+ const [client, setClient] = _react.useState.call(void 0, void 0);
159
391
  const iFrame = _react.createElement.call(void 0, "iframe", {
160
392
  id: "nexus-wallet",
161
393
  name: "nexus-wallet",
162
394
  src: `${config.walletUrl}/listener`,
163
- style: {
164
- width: "0",
165
- height: "0",
166
- border: "0",
167
- position: "absolute",
168
- top: "-1000px",
169
- left: "-1000px"
170
- },
395
+ style: _nullishCoalesce(style, () => ( defaultIframeStyle)),
396
+ allow: "publickey-credentials-get *",
171
397
  ref: (iframe) => {
172
- if (!iframe) {
173
- setIframeElem(void 0);
398
+ if (!iframe || client) {
174
399
  return;
175
400
  }
176
- setIframeElem(iframe);
401
+ setClient(
402
+ _chunkSGLR6RFAcjs.createIFrameNexusClient.call(void 0, {
403
+ iframe,
404
+ config
405
+ })
406
+ );
177
407
  }
178
408
  });
179
409
  const providerComponent = _react.createElement.call(void 0,
@@ -193,4 +423,8 @@ function NexusIFrameClientProvider({
193
423
 
194
424
 
195
425
 
196
- exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.useArticleUnlockOptions = useArticleUnlockOptions; exports.useArticleUnlockStatus = useArticleUnlockStatus; exports.useNexusClient = useNexusClient; exports.useNexusConfig = useNexusConfig; exports.useWalletStatus = useWalletStatus;
426
+
427
+
428
+
429
+
430
+ exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.useArticleUnlockOptions = useArticleUnlockOptions; exports.useArticleUnlockStatus = useArticleUnlockStatus; exports.useNexusClient = useNexusClient; exports.useNexusConfig = useNexusConfig; exports.usePressReferralInteraction = usePressReferralInteraction; exports.useSendInteraction = useSendInteraction; exports.useSendTransactionAction = useSendTransactionAction; exports.useSiweAuthenticate = useSiweAuthenticate; exports.useWalletStatus = 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 } from '../client-MgLVRfPw.cjs';
2
+ import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
3
+ import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType, e as SendTransactionTxType, d as SendTransactionReturnType, c as SendTransactionActionParamsType, h as SiweAuthenticationParams, f as SiweAuthenticateReturnType, g as SiweAuthenticateActionParamsType } from '../client--U_6SK0l.cjs';
4
4
  import * as _tanstack_react_query from '@tanstack/react-query';
5
- import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-DqWkImYK.cjs';
6
- import 'viem';
5
+ import { UseMutationOptions } from '@tanstack/react-query';
6
+ import * as viem from 'viem';
7
+ import { Hex } from 'viem';
8
+ import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-CxnibdQx.cjs';
9
+ import { F as FrakRpcError } from '../error-C4Zm5nQe.cjs';
10
+ import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D_CzyqRE.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
@@ -14,12 +19,15 @@ declare const NexusConfigContext: react.Context<Readonly<{
14
19
  metadata: {
15
20
  name: string;
16
21
  };
22
+ domain: string;
17
23
  }> | undefined>;
18
24
  /**
19
25
  * Props to instantiate the Nexus Wallet SDK configuration provider
20
26
  */
21
27
  type NexusConfigProviderProps = {
22
- config: NexusWalletSdkConfig;
28
+ config: Omit<NexusWalletSdkConfig, "domain"> & {
29
+ domain?: string;
30
+ };
23
31
  };
24
32
  /**
25
33
  * Simple config provider for the Nexus Wallet SDK
@@ -31,6 +39,7 @@ declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigPr
31
39
  metadata: {
32
40
  name: string;
33
41
  };
42
+ domain: string;
34
43
  }> | undefined>>;
35
44
 
36
45
  /**
@@ -49,10 +58,11 @@ type NexusIFrameClientProps = {
49
58
  * @param parameters
50
59
  * @constructor
51
60
  */
52
- declare function NexusIFrameClientProvider({ children, }: {
61
+ declare function NexusIFrameClientProvider({ style, children, }: {
62
+ style?: CSSProperties;
53
63
  children?: ReactNode;
54
64
  }): react.FunctionComponentElement<{
55
- children?: ReactNode;
65
+ children?: ReactNode | undefined;
56
66
  }>;
57
67
 
58
68
  /**
@@ -63,25 +73,26 @@ declare function useNexusConfig(): Readonly<{
63
73
  metadata: {
64
74
  name: string;
65
75
  };
76
+ domain: string;
66
77
  }>;
67
78
 
68
79
  /**
69
80
  * Use the current nexus iframe client
70
81
  */
71
- declare function useNexusClient(): NexusClient;
82
+ declare function useNexusClient(): NexusClient | undefined;
72
83
 
73
84
  /**
74
85
  * Hook used to get the unlock options for an article
75
86
  */
76
87
  declare function useArticleUnlockOptions({ articleId, contentId, }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
77
- frkBalanceAsHex?: `0x${string}` | undefined;
88
+ frkBalanceAsHex?: viem.Hex;
78
89
  prices: {
79
90
  index: number;
80
91
  unlockDurationInSec: number;
81
- frkAmount: `0x${string}`;
92
+ frkAmount: viem.Hex;
82
93
  isUserAccessible: boolean | null;
83
94
  }[];
84
- }>, Error>;
95
+ }> | undefined, Error>;
85
96
 
86
97
  type WalletStatusQueryReturnType = WalletStatusReturnType | {
87
98
  key: "waiting-response";
@@ -100,4 +111,53 @@ type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
100
111
  */
101
112
  declare function useArticleUnlockStatus({ articleId, contentId, }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
102
113
 
103
- export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
114
+ type MutationOptions$2 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionActionParamsType>, "mutationFn" | "mutationKey">;
115
+ interface UseSendTransactionParams {
116
+ mutations?: MutationOptions$2;
117
+ }
118
+ /**
119
+ * Trigger a dashboard action to the wallet
120
+ */
121
+ declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): _tanstack_react_query.UseMutationResult<Readonly<{
122
+ hash: viem.Hex;
123
+ }>, FrakRpcError<undefined>, Readonly<{
124
+ tx: SendTransactionTxType | SendTransactionTxType[];
125
+ context?: string;
126
+ }>, unknown>;
127
+
128
+ type MutationOptions$1 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateActionParamsType>, "mutationFn" | "mutationKey">;
129
+ interface UseSiweAuthenticateParams {
130
+ mutations?: MutationOptions$1;
131
+ }
132
+ /**
133
+ * Trigger a dashboard action to the wallet
134
+ */
135
+ declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): _tanstack_react_query.UseMutationResult<Readonly<{
136
+ signature: viem.Hex;
137
+ message: string;
138
+ }>, FrakRpcError<undefined>, Readonly<{
139
+ siwe?: Partial<SiweAuthenticationParams>;
140
+ context?: string;
141
+ }>, unknown>;
142
+
143
+ /**
144
+ * Helper hook to automatically submit a press referral interaction when detected
145
+ * -> And automatically set the referral context in the url
146
+ * @param contentId
147
+ */
148
+ declare function usePressReferralInteraction({ contentId }: {
149
+ contentId: Hex;
150
+ }): "error" | "loading" | "no-referral" | "referred" | "no-wallet" | "no-session";
151
+
152
+ type MutationOptions = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
153
+ interface UseSendInteractionParams {
154
+ mutations?: MutationOptions;
155
+ }
156
+ /**
157
+ * Send a user interaction
158
+ */
159
+ declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<Readonly<{
160
+ hash: viem.Hex;
161
+ }>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
162
+
163
+ export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, usePressReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };