@frak-labs/nexus-sdk 0.0.9 → 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-SZUN32YC.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-AYZHGMEV.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-BwzXSgqQ.d.ts → client--U_6SK0l.d.cts} +91 -30
  12. package/dist/{client-BwzXSgqQ.d.cts → client-6_BJp7Ub.d.ts} +91 -30
  13. package/dist/core/actions/index.cjs +8 -3
  14. package/dist/core/actions/index.d.cts +25 -13
  15. package/dist/core/actions/index.d.ts +25 -13
  16. package/dist/core/actions/index.js +9 -4
  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 +234 -109
  30. package/dist/react/index.d.cts +69 -19
  31. package/dist/react/index.d.ts +69 -19
  32. package/dist/react/index.js +236 -111
  33. package/dist/{watchUnlockStatus-WJxoDliF.d.ts → watchUnlockStatus-CxnibdQx.d.cts} +3 -3
  34. package/dist/{watchUnlockStatus-DXClCYH9.d.cts → watchUnlockStatus-g8wIxpeM.d.ts} +3 -3
  35. package/package.json +11 -5
  36. package/dist/chunk-PDR3CF3P.js +0 -86
  37. package/dist/chunk-VK7GPKK4.js +0 -169
  38. package/dist/chunk-X4JNNWJ4.cjs +0 -86
  39. package/dist/chunk-ZOLP2FJZ.cjs +0 -169
@@ -1,13 +1,25 @@
1
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 _chunkAYZHGMEVcjs = require('../chunk-AYZHGMEV.cjs');
3
+ var _chunkSGLR6RFAcjs = require('../chunk-SGLR6RFA.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
- var _chunkX4JNNWJ4cjs = require('../chunk-X4JNNWJ4.cjs');
10
- require('../chunk-ZOLP2FJZ.cjs');
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');
11
23
 
12
24
  // src/react/provider/NexusConfigProvider.ts
13
25
  var _react = require('react');
@@ -16,7 +28,12 @@ function NexusConfigProvider(parameters) {
16
28
  const { children, config } = parameters;
17
29
  return _react.createElement.call(void 0,
18
30
  NexusConfigContext.Provider,
19
- { 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
+ },
20
37
  children
21
38
  );
22
39
  }
@@ -29,13 +46,15 @@ function NexusConfigProvider(parameters) {
29
46
 
30
47
 
31
48
 
32
-
33
49
  // src/react/hook/useNexusConfig.ts
34
50
 
35
51
  function useNexusConfig() {
36
52
  const config = _react.useContext.call(void 0, NexusConfigContext);
37
53
  if (!config) {
38
- throw new Error("NexusConfigProvider is not found");
54
+ throw new (0, _chunkBPFJZRJ6cjs.FrakRpcError)(
55
+ _chunkBPFJZRJ6cjs.RpcErrorCodes.configError,
56
+ "Nexus config not found"
57
+ );
39
58
  }
40
59
  return config;
41
60
  }
@@ -43,11 +62,7 @@ function useNexusConfig() {
43
62
  // src/react/hook/useNexusClient.ts
44
63
 
45
64
  function useNexusClient() {
46
- const client = _react.useContext.call(void 0, NexusIFrameClientContext);
47
- if (!client) {
48
- throw new Error("NexusIFrameClientProvider is not found");
49
- }
50
- return client;
65
+ return _react.useContext.call(void 0, NexusIFrameClientContext);
51
66
  }
52
67
 
53
68
  // src/react/hook/useArticleUnlockOptions.ts
@@ -58,17 +73,22 @@ function useArticleUnlockOptions({
58
73
  }) {
59
74
  const client = useNexusClient();
60
75
  return _reactquery.useQuery.call(void 0, {
61
- queryKey: ["articleUnlockOptions", _nullishCoalesce(articleId, () => ( "no-article-id"))],
76
+ queryKey: [
77
+ "nexus-sdk",
78
+ "article-unlock-options",
79
+ _nullishCoalesce(articleId, () => ( "no-article-id"))
80
+ ],
62
81
  queryFn: async () => {
82
+ if (!client) return;
63
83
  if (!(articleId && contentId)) {
64
84
  throw new Error("No article id provided");
65
85
  }
66
- return await _chunkX4JNNWJ4cjs.getArticleUnlockOptions.call(void 0, client, {
86
+ return await _chunk3T2FNW6Ecjs.getArticleUnlockOptions.call(void 0, client, {
67
87
  articleId,
68
88
  contentId
69
89
  });
70
90
  },
71
- enabled: !!articleId && !!contentId,
91
+ enabled: !!client && !!articleId && !!contentId,
72
92
  gcTime: 0
73
93
  });
74
94
  }
@@ -81,17 +101,24 @@ function useWalletStatus() {
81
101
  const client = useNexusClient();
82
102
  const newStatusUpdated = _react.useCallback.call(void 0,
83
103
  (event) => {
84
- queryClient.setQueryData(["walletStatusListener"], event);
104
+ queryClient.setQueryData(
105
+ ["nexus-sdk", "wallet-status-listener"],
106
+ event
107
+ );
85
108
  },
86
109
  [queryClient]
87
110
  );
88
111
  return _reactquery.useQuery.call(void 0, {
89
112
  gcTime: 0,
90
- queryKey: ["walletStatusListener"],
113
+ queryKey: ["nexus-sdk", "wallet-status-listener"],
91
114
  queryFn: async () => {
92
- await _chunkX4JNNWJ4cjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
115
+ if (!client) {
116
+ return { key: "waiting-response" };
117
+ }
118
+ await _chunk3T2FNW6Ecjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
93
119
  return { key: "waiting-response" };
94
- }
120
+ },
121
+ enabled: !!client
95
122
  });
96
123
  }
97
124
 
@@ -108,7 +135,8 @@ function useArticleUnlockStatus({
108
135
  (event) => {
109
136
  queryClient.setQueryData(
110
137
  [
111
- "articleUnlockStatusListener",
138
+ "nexus-sdk",
139
+ "article-unlock-status",
112
140
  _nullishCoalesce(articleId, () => ( "no-article-id")),
113
141
  _nullishCoalesce(contentId, () => ( "no-contentId-id"))
114
142
  ],
@@ -119,16 +147,23 @@ function useArticleUnlockStatus({
119
147
  );
120
148
  return _reactquery.useQuery.call(void 0, {
121
149
  queryKey: [
122
- "articleUnlockStatusListener",
150
+ "nexus-sdk",
151
+ "article-unlock-status",
123
152
  _nullishCoalesce(articleId, () => ( "no-article-id")),
124
153
  _nullishCoalesce(contentId, () => ( "no-contentId-id"))
125
154
  ],
126
155
  gcTime: 0,
127
156
  queryFn: async () => {
157
+ if (!client) {
158
+ return {
159
+ status: "waiting-response",
160
+ key: "waiting-response"
161
+ };
162
+ }
128
163
  if (!(articleId && contentId)) {
129
164
  return null;
130
165
  }
131
- await _chunkX4JNNWJ4cjs.watchUnlockStatus.call(void 0,
166
+ await _chunk3T2FNW6Ecjs.watchUnlockStatus.call(void 0,
132
167
  client,
133
168
  { articleId, contentId },
134
169
  newStatusUpdated
@@ -138,19 +173,80 @@ function useArticleUnlockStatus({
138
173
  key: "waiting-response"
139
174
  };
140
175
  },
141
- enabled: !!articleId && !!contentId
176
+ enabled: !!client && !!articleId && !!contentId
142
177
  });
143
178
  }
144
179
 
145
- // src/react/hook/useNexusReferral.ts
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
146
221
 
147
222
 
148
223
  var _viem = require('viem');
149
224
 
150
- // src/react/hook/useWindowLocation.ts
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
+
151
245
 
246
+ // src/react/hook/utils/useWindowLocation.ts
152
247
 
153
- // src/react/hook/useMounted.ts
248
+
249
+ // src/react/hook/utils/useMounted.ts
154
250
 
155
251
  function useMounted() {
156
252
  const [mounted, setMounted] = _react.useState.call(void 0, false);
@@ -160,22 +256,17 @@ function useMounted() {
160
256
  return mounted;
161
257
  }
162
258
 
163
- // src/react/hook/useWindowLocation.ts
164
- var useWindowLocation = () => {
259
+ // src/react/hook/utils/useWindowLocation.ts
260
+ function useWindowLocation() {
165
261
  const isMounted = useMounted();
166
262
  const [location, setLocation] = _react.useState.call(void 0,
167
263
  isMounted ? window.location : void 0
168
264
  );
169
- const [href, setHref] = _react.useState.call(void 0,
170
- isMounted ? window.location.href : void 0
171
- );
172
265
  _react.useEffect.call(void 0, () => {
173
- if (!isMounted)
174
- return;
175
- const setWindowLocation = () => {
266
+ if (!isMounted) return;
267
+ function setWindowLocation() {
176
268
  setLocation(window.location);
177
- setHref(window.location.href);
178
- };
269
+ }
179
270
  if (!location) {
180
271
  setWindowLocation();
181
272
  }
@@ -184,104 +275,135 @@ var useWindowLocation = () => {
184
275
  window.removeEventListener("popstate", setWindowLocation);
185
276
  };
186
277
  }, [isMounted, location]);
278
+ const href = _react.useMemo.call(void 0, () => _optionalChain([location, 'optionalAccess', _5 => _5.href]), [_optionalChain([location, 'optionalAccess', _6 => _6.href])]);
187
279
  return { location, href };
188
- };
280
+ }
189
281
 
190
- // src/react/hook/useNexusReferral.ts
191
- function useNexusReferral({ contentId }) {
192
- const { href } = useWindowLocation();
193
- const queryClient = _reactquery.useQueryClient.call(void 0, );
194
- const client = useNexusClient();
195
- const { data: walletStatus } = useWalletStatus();
196
- const [referrerAddress, setReferrerAddress] = _react.useState.call(void 0, );
197
- const newStatusUpdated = _react.useCallback.call(void 0,
198
- (event) => {
199
- queryClient.setQueryData(
200
- ["setUserReferredQueryReturnTypeListener"],
201
- event
202
- );
203
- if (event.key === "referred-successful" || event.key === "referred-history") {
204
- if (!href)
205
- return;
206
- const url = new URL(href);
207
- if (_optionalChain([walletStatus, 'optionalAccess', _ => _.key]) === "connected") {
208
- url.searchParams.set("nexusContext", _optionalChain([walletStatus, 'optionalAccess', _2 => _2.wallet]));
209
- }
210
- if (_optionalChain([walletStatus, 'optionalAccess', _3 => _3.key]) === "not-connected") {
211
- url.searchParams.delete("nexusContext");
212
- }
213
- window.history.replaceState(null, "", url.toString());
214
- }
215
- },
216
- [queryClient, href, walletStatus]
217
- );
218
- _react.useEffect.call(void 0, () => {
219
- if (!href)
220
- return;
221
- const url = new URL(href);
222
- const context = url.searchParams.get("nexusContext");
223
- if (!context && _optionalChain([walletStatus, 'optionalAccess', _4 => _4.key]) === "connected") {
224
- url.searchParams.set("nexusContext", _optionalChain([walletStatus, 'optionalAccess', _5 => _5.wallet]));
225
- window.history.replaceState(null, "", url.toString());
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;
226
296
  }
227
- if (context) {
228
- setReferrerAddress(context);
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());
229
308
  }
230
- }, [href, walletStatus]);
231
- return _reactquery.useQuery.call(void 0, {
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, {
232
319
  gcTime: 0,
233
- queryKey: ["setUserReferredQueryReturnTypeListener"],
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
+ ],
234
326
  queryFn: async () => {
235
- if (!(contentId && referrerAddress)) {
236
- return { key: "no-referrer" };
237
- }
238
- if (_optionalChain([walletStatus, 'optionalAccess', _6 => _6.key]) === "connected" && _optionalChain([walletStatus, 'optionalAccess', _7 => _7.wallet]) && _viem.isAddressEqual.call(void 0, _optionalChain([walletStatus, 'optionalAccess', _8 => _8.wallet]), referrerAddress)) {
239
- return { key: "same-wallet" };
327
+ if (!nexusContext && _optionalChain([walletStatus, 'optionalAccess', _11 => _11.key]) === "connected") {
328
+ await updateContextAsync({ r: walletStatus.wallet });
329
+ return null;
240
330
  }
241
- await _chunkX4JNNWJ4cjs.setUserReferred.call(void 0,
242
- client,
243
- { contentId, walletAddress: referrerAddress },
244
- newStatusUpdated
245
- );
246
- return { key: "waiting-response" };
247
- },
248
- enabled: !!contentId && !!referrerAddress && _optionalChain([walletStatus, 'optionalAccess', _9 => _9.key]) !== void 0 && _optionalChain([walletStatus, 'optionalAccess', _10 => _10.key]) !== "waiting-response"
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
+ }
249
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]);
250
370
  }
251
371
 
252
372
  // src/react/provider/NexusIFrameClientProvider.ts
253
373
  var NexusIFrameClientContext = _react.createContext.call(void 0,
254
374
  void 0
255
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
+ };
256
385
  function NexusIFrameClientProvider({
386
+ style,
257
387
  children
258
388
  }) {
259
389
  const config = useNexusConfig();
260
- const [iframeElem, setIframeElem] = _react.useState.call(void 0,
261
- void 0
262
- );
263
- const client = _react.useMemo.call(void 0,
264
- () => iframeElem ? _chunkAYZHGMEVcjs.createIFrameNexusClient.call(void 0, { iframe: iframeElem, config }) : void 0,
265
- [iframeElem, config]
266
- );
390
+ const [client, setClient] = _react.useState.call(void 0, void 0);
267
391
  const iFrame = _react.createElement.call(void 0, "iframe", {
268
392
  id: "nexus-wallet",
269
393
  name: "nexus-wallet",
270
394
  src: `${config.walletUrl}/listener`,
271
- style: {
272
- width: "0",
273
- height: "0",
274
- border: "0",
275
- position: "absolute",
276
- top: "-1000px",
277
- left: "-1000px"
278
- },
395
+ style: _nullishCoalesce(style, () => ( defaultIframeStyle)),
396
+ allow: "publickey-credentials-get *",
279
397
  ref: (iframe) => {
280
- if (!iframe) {
281
- setIframeElem(void 0);
398
+ if (!iframe || client) {
282
399
  return;
283
400
  }
284
- setIframeElem(iframe);
401
+ setClient(
402
+ _chunkSGLR6RFAcjs.createIFrameNexusClient.call(void 0, {
403
+ iframe,
404
+ config
405
+ })
406
+ );
285
407
  }
286
408
  });
287
409
  const providerComponent = _react.createElement.call(void 0,
@@ -302,4 +424,7 @@ function NexusIFrameClientProvider({
302
424
 
303
425
 
304
426
 
305
- 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.useNexusReferral = useNexusReferral; exports.useWalletStatus = useWalletStatus;
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, e as SetUserReferredParams, c as SetUserReferredReturnType } from '../client-BwzXSgqQ.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-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 { 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,14 +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
- type SetUserReferredQueryReturnType = SetUserReferredReturnType | {
104
- key: "waiting-response";
105
- } | {
106
- key: "no-referrer";
107
- };
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
+ }
108
156
  /**
109
- * Use the current nexus referral
157
+ * Send a user interaction
110
158
  */
111
- declare function useNexusReferral({ contentId }: SetUserReferredParams): _tanstack_react_query.UseQueryResult<SetUserReferredQueryReturnType, Error>;
159
+ declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<Readonly<{
160
+ hash: viem.Hex;
161
+ }>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
112
162
 
113
- export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useNexusReferral, useWalletStatus };
163
+ export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, usePressReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };