@frak-labs/nexus-sdk 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-5CFD5FM2.js +86 -0
- package/dist/chunk-BJ3CCN5P.cjs +424 -0
- package/dist/{chunk-72IEHEQX.js → chunk-GUDT2W6I.js} +32 -10
- package/dist/chunk-HXVDI2IY.js +424 -0
- package/dist/{chunk-NIFJZD3M.cjs → chunk-IQQTTKJL.cjs} +30 -8
- package/dist/chunk-S5FVCA2E.cjs +86 -0
- package/dist/client-B6_BIGc3.d.ts +357 -0
- package/dist/client-Oily5ph8.d.cts +357 -0
- package/dist/core/actions/index.cjs +2 -7
- package/dist/core/actions/index.d.cts +16 -35
- package/dist/core/actions/index.d.ts +16 -35
- package/dist/core/actions/index.js +5 -10
- package/dist/core/index.cjs +2 -4
- package/dist/core/index.d.cts +19 -19
- package/dist/core/index.d.ts +19 -19
- package/dist/core/index.js +2 -4
- package/dist/core/interactions/index.cjs +6 -2
- package/dist/core/interactions/index.d.cts +20 -6
- package/dist/core/interactions/index.d.ts +20 -6
- package/dist/core/interactions/index.js +7 -3
- package/dist/{interaction-D_CzyqRE.d.cts → interaction-D3-M3nBh.d.cts} +2 -2
- package/dist/{interaction-D_CzyqRE.d.ts → interaction-D3-M3nBh.d.ts} +2 -2
- package/dist/react/index.cjs +156 -158
- package/dist/react/index.d.cts +44 -51
- package/dist/react/index.d.ts +44 -51
- package/dist/react/index.js +162 -164
- package/dist/sendTransaction-BHqCq_9X.d.ts +30 -0
- package/dist/sendTransaction-BKKYEt8p.d.cts +30 -0
- package/package.json +8 -5
- package/dist/chunk-3T2FNW6E.cjs +0 -100
- package/dist/chunk-BPFJZRJ6.cjs +0 -152
- package/dist/chunk-HOX3RRO6.js +0 -199
- package/dist/chunk-SGLR6RFA.cjs +0 -199
- package/dist/chunk-T54VMWHQ.js +0 -100
- package/dist/chunk-TPC5PMRC.js +0 -152
- package/dist/client--U_6SK0l.d.cts +0 -339
- package/dist/client-6_BJp7Ub.d.ts +0 -339
- package/dist/watchUnlockStatus-CxnibdQx.d.cts +0 -43
- package/dist/watchUnlockStatus-g8wIxpeM.d.ts +0 -43
package/dist/react/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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 _chunkSGLR6RFAcjs = require('../chunk-SGLR6RFA.cjs');
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
|
|
@@ -8,17 +7,18 @@ var _chunkSGLR6RFAcjs = require('../chunk-SGLR6RFA.cjs');
|
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
var
|
|
10
|
+
var _chunkBJ3CCN5Pcjs = require('../chunk-BJ3CCN5P.cjs');
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
var _chunkBPFJZRJ6cjs = require('../chunk-BPFJZRJ6.cjs');
|
|
19
17
|
|
|
18
|
+
var _chunkS5FVCA2Ecjs = require('../chunk-S5FVCA2E.cjs');
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
|
|
21
|
+
var _chunkIQQTTKJLcjs = require('../chunk-IQQTTKJL.cjs');
|
|
22
22
|
require('../chunk-ETV4XYOV.cjs');
|
|
23
23
|
|
|
24
24
|
// src/react/provider/NexusConfigProvider.ts
|
|
@@ -51,8 +51,8 @@ function NexusConfigProvider(parameters) {
|
|
|
51
51
|
function useNexusConfig() {
|
|
52
52
|
const config = _react.useContext.call(void 0, NexusConfigContext);
|
|
53
53
|
if (!config) {
|
|
54
|
-
throw new (0,
|
|
55
|
-
|
|
54
|
+
throw new (0, _chunkBJ3CCN5Pcjs.FrakRpcError)(
|
|
55
|
+
_chunkBJ3CCN5Pcjs.RpcErrorCodes.configError,
|
|
56
56
|
"Nexus config not found"
|
|
57
57
|
);
|
|
58
58
|
}
|
|
@@ -65,36 +65,8 @@ function useNexusClient() {
|
|
|
65
65
|
return _react.useContext.call(void 0, NexusIFrameClientContext);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// src/react/hook/useArticleUnlockOptions.ts
|
|
69
|
-
var _reactquery = require('@tanstack/react-query');
|
|
70
|
-
function useArticleUnlockOptions({
|
|
71
|
-
articleId,
|
|
72
|
-
contentId
|
|
73
|
-
}) {
|
|
74
|
-
const client = useNexusClient();
|
|
75
|
-
return _reactquery.useQuery.call(void 0, {
|
|
76
|
-
queryKey: [
|
|
77
|
-
"nexus-sdk",
|
|
78
|
-
"article-unlock-options",
|
|
79
|
-
_nullishCoalesce(articleId, () => ( "no-article-id"))
|
|
80
|
-
],
|
|
81
|
-
queryFn: async () => {
|
|
82
|
-
if (!client) return;
|
|
83
|
-
if (!(articleId && contentId)) {
|
|
84
|
-
throw new Error("No article id provided");
|
|
85
|
-
}
|
|
86
|
-
return await _chunk3T2FNW6Ecjs.getArticleUnlockOptions.call(void 0, client, {
|
|
87
|
-
articleId,
|
|
88
|
-
contentId
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
enabled: !!client && !!articleId && !!contentId,
|
|
92
|
-
gcTime: 0
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
68
|
// src/react/hook/useWalletStatus.ts
|
|
97
|
-
|
|
69
|
+
var _reactquery = require('@tanstack/react-query');
|
|
98
70
|
|
|
99
71
|
function useWalletStatus() {
|
|
100
72
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
@@ -113,70 +85,23 @@ function useWalletStatus() {
|
|
|
113
85
|
queryKey: ["nexus-sdk", "wallet-status-listener"],
|
|
114
86
|
queryFn: async () => {
|
|
115
87
|
if (!client) {
|
|
116
|
-
|
|
88
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
117
89
|
}
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
const firstResult = new (0, _chunkBJ3CCN5Pcjs.Deferred)();
|
|
91
|
+
let hasResolved = false;
|
|
92
|
+
await _chunkS5FVCA2Ecjs.watchWalletStatus.call(void 0, client, (status) => {
|
|
93
|
+
newStatusUpdated(status);
|
|
94
|
+
if (!hasResolved) {
|
|
95
|
+
firstResult.resolve(status);
|
|
96
|
+
hasResolved = true;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return firstResult.promise;
|
|
120
100
|
},
|
|
121
101
|
enabled: !!client
|
|
122
102
|
});
|
|
123
103
|
}
|
|
124
104
|
|
|
125
|
-
// src/react/hook/useArticleUnlockStatus.ts
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
function useArticleUnlockStatus({
|
|
129
|
-
articleId,
|
|
130
|
-
contentId
|
|
131
|
-
}) {
|
|
132
|
-
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
133
|
-
const client = useNexusClient();
|
|
134
|
-
const newStatusUpdated = _react.useCallback.call(void 0,
|
|
135
|
-
(event) => {
|
|
136
|
-
queryClient.setQueryData(
|
|
137
|
-
[
|
|
138
|
-
"nexus-sdk",
|
|
139
|
-
"article-unlock-status",
|
|
140
|
-
_nullishCoalesce(articleId, () => ( "no-article-id")),
|
|
141
|
-
_nullishCoalesce(contentId, () => ( "no-contentId-id"))
|
|
142
|
-
],
|
|
143
|
-
event
|
|
144
|
-
);
|
|
145
|
-
},
|
|
146
|
-
[articleId, contentId, queryClient]
|
|
147
|
-
);
|
|
148
|
-
return _reactquery.useQuery.call(void 0, {
|
|
149
|
-
queryKey: [
|
|
150
|
-
"nexus-sdk",
|
|
151
|
-
"article-unlock-status",
|
|
152
|
-
_nullishCoalesce(articleId, () => ( "no-article-id")),
|
|
153
|
-
_nullishCoalesce(contentId, () => ( "no-contentId-id"))
|
|
154
|
-
],
|
|
155
|
-
gcTime: 0,
|
|
156
|
-
queryFn: async () => {
|
|
157
|
-
if (!client) {
|
|
158
|
-
return {
|
|
159
|
-
status: "waiting-response",
|
|
160
|
-
key: "waiting-response"
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
if (!(articleId && contentId)) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
await _chunk3T2FNW6Ecjs.watchUnlockStatus.call(void 0,
|
|
167
|
-
client,
|
|
168
|
-
{ articleId, contentId },
|
|
169
|
-
newStatusUpdated
|
|
170
|
-
);
|
|
171
|
-
return {
|
|
172
|
-
status: "waiting-response",
|
|
173
|
-
key: "waiting-response"
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
enabled: !!client && !!articleId && !!contentId
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
105
|
// src/react/hook/useSendTransaction.ts
|
|
181
106
|
|
|
182
107
|
function useSendTransactionAction({
|
|
@@ -188,9 +113,9 @@ function useSendTransactionAction({
|
|
|
188
113
|
mutationKey: ["nexus-sdk", "send-transaction"],
|
|
189
114
|
mutationFn: async (params) => {
|
|
190
115
|
if (!client) {
|
|
191
|
-
throw new (0,
|
|
116
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
192
117
|
}
|
|
193
|
-
return
|
|
118
|
+
return _chunkS5FVCA2Ecjs.sendTransaction.call(void 0, client, params);
|
|
194
119
|
}
|
|
195
120
|
});
|
|
196
121
|
}
|
|
@@ -210,18 +135,36 @@ function useSiweAuthenticate({
|
|
|
210
135
|
],
|
|
211
136
|
mutationFn: async (params) => {
|
|
212
137
|
if (!client) {
|
|
213
|
-
throw new (0,
|
|
138
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
214
139
|
}
|
|
215
|
-
return
|
|
140
|
+
return _chunkS5FVCA2Ecjs.siweAuthenticate.call(void 0, client, params);
|
|
216
141
|
}
|
|
217
142
|
});
|
|
218
143
|
}
|
|
219
144
|
|
|
220
|
-
// src/react/hook/helper/
|
|
145
|
+
// src/react/hook/helper/useReferralInteraction.ts
|
|
221
146
|
|
|
222
147
|
|
|
223
148
|
var _viem = require('viem');
|
|
224
149
|
|
|
150
|
+
// src/react/hook/useDisplayModal.ts
|
|
151
|
+
|
|
152
|
+
function useDisplayModal({
|
|
153
|
+
mutations
|
|
154
|
+
} = {}) {
|
|
155
|
+
const client = useNexusClient();
|
|
156
|
+
return _reactquery.useMutation.call(void 0, {
|
|
157
|
+
...mutations,
|
|
158
|
+
mutationKey: ["nexus-sdk", "display-modal"],
|
|
159
|
+
mutationFn: async (args) => {
|
|
160
|
+
if (!client) {
|
|
161
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
162
|
+
}
|
|
163
|
+
return _chunkS5FVCA2Ecjs.displayModal.call(void 0, client, args);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
225
168
|
// src/react/hook/useSendInteraction.ts
|
|
226
169
|
|
|
227
170
|
function useSendInteraction({
|
|
@@ -233,9 +176,9 @@ function useSendInteraction({
|
|
|
233
176
|
mutationKey: ["nexus-sdk", "send-interaction"],
|
|
234
177
|
mutationFn: async (params) => {
|
|
235
178
|
if (!client) {
|
|
236
|
-
throw new (0,
|
|
179
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
237
180
|
}
|
|
238
|
-
return
|
|
181
|
+
return _chunkS5FVCA2Ecjs.sendInteraction.call(void 0, client, params);
|
|
239
182
|
}
|
|
240
183
|
});
|
|
241
184
|
}
|
|
@@ -290,98 +233,155 @@ function useNexusContext() {
|
|
|
290
233
|
const url = new URL(location.href);
|
|
291
234
|
const nexusContext2 = url.searchParams.get(contextKey);
|
|
292
235
|
if (!nexusContext2) return null;
|
|
293
|
-
const parsedContext = await
|
|
236
|
+
const parsedContext = await _chunkBJ3CCN5Pcjs.decompressJson.call(void 0, nexusContext2);
|
|
294
237
|
if (!parsedContext) return null;
|
|
295
238
|
return parsedContext;
|
|
296
|
-
}
|
|
239
|
+
},
|
|
240
|
+
enabled: !!_optionalChain([location, 'optionalAccess', _9 => _9.href])
|
|
297
241
|
});
|
|
298
242
|
const { mutate: updateContext, mutateAsync: updateContextAsync } = _reactquery.useMutation.call(void 0, {
|
|
299
243
|
mutationKey: ["nexus-sdk", "update-context"],
|
|
300
244
|
mutationFn: async (newContext) => {
|
|
301
245
|
if (!location || typeof window === "undefined") return;
|
|
302
246
|
const fullNewContext = nexusContext ? { ...nexusContext, ...newContext } : newContext;
|
|
303
|
-
const compressedContext = await
|
|
247
|
+
const compressedContext = await _chunkBJ3CCN5Pcjs.compressJson.call(void 0, fullNewContext);
|
|
304
248
|
if (!compressedContext) return;
|
|
305
249
|
const url = new URL(location.href);
|
|
306
250
|
url.searchParams.set(contextKey, compressedContext);
|
|
307
251
|
window.history.replaceState(null, "", url.toString());
|
|
308
252
|
}
|
|
309
253
|
});
|
|
310
|
-
return {
|
|
254
|
+
return {
|
|
255
|
+
nexusContext,
|
|
256
|
+
updateContext,
|
|
257
|
+
updateContextAsync
|
|
258
|
+
};
|
|
311
259
|
}
|
|
312
260
|
|
|
313
|
-
// src/react/hook/helper/
|
|
314
|
-
function
|
|
261
|
+
// src/react/hook/helper/useReferralInteraction.ts
|
|
262
|
+
function useReferralInteraction({
|
|
263
|
+
contentId,
|
|
264
|
+
modalConfig
|
|
265
|
+
} = {}) {
|
|
315
266
|
const { nexusContext, updateContextAsync } = useNexusContext();
|
|
316
267
|
const { data: walletStatus } = useWalletStatus();
|
|
317
268
|
const { mutateAsync: sendInteraction2 } = useSendInteraction();
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (!
|
|
328
|
-
|
|
329
|
-
|
|
269
|
+
const ensureWalletConnected = useEnsureWalletConnected({
|
|
270
|
+
modalConfig,
|
|
271
|
+
walletStatus
|
|
272
|
+
});
|
|
273
|
+
const processReferral = _react.useCallback.call(void 0, async () => {
|
|
274
|
+
try {
|
|
275
|
+
let currentWallet = await ensureWalletConnected({
|
|
276
|
+
autoDisplay: false
|
|
277
|
+
});
|
|
278
|
+
if (!_optionalChain([nexusContext, 'optionalAccess', _10 => _10.r])) {
|
|
279
|
+
if (currentWallet) {
|
|
280
|
+
await updateContextAsync({ r: currentWallet });
|
|
281
|
+
}
|
|
282
|
+
return "no-referrer";
|
|
283
|
+
}
|
|
284
|
+
if (!currentWallet) {
|
|
285
|
+
currentWallet = await ensureWalletConnected({
|
|
286
|
+
autoDisplay: true
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (currentWallet && _viem.isAddressEqual.call(void 0, nexusContext.r, currentWallet)) {
|
|
290
|
+
return "self-referral";
|
|
330
291
|
}
|
|
331
|
-
|
|
332
|
-
if (_viem.isAddressEqual.call(void 0, nexusContext.r, walletStatus.wallet))
|
|
333
|
-
return null;
|
|
334
|
-
const interaction = _chunkNIFJZD3Mcjs.PressInteractionEncoder.referred({
|
|
292
|
+
const interaction = _chunkIQQTTKJLcjs.ReferralInteractionEncoder.referred({
|
|
335
293
|
referrer: nexusContext.r
|
|
336
294
|
});
|
|
337
295
|
await sendInteraction2({ contentId, interaction });
|
|
338
|
-
|
|
339
|
-
|
|
296
|
+
if (currentWallet) {
|
|
297
|
+
await updateContextAsync({ r: currentWallet });
|
|
298
|
+
}
|
|
299
|
+
return "success";
|
|
300
|
+
} catch (error2) {
|
|
301
|
+
return mapErrorToState(error2);
|
|
340
302
|
}
|
|
303
|
+
}, [
|
|
304
|
+
nexusContext,
|
|
305
|
+
contentId,
|
|
306
|
+
ensureWalletConnected,
|
|
307
|
+
sendInteraction2,
|
|
308
|
+
updateContextAsync
|
|
309
|
+
]);
|
|
310
|
+
const {
|
|
311
|
+
data: referralState,
|
|
312
|
+
error,
|
|
313
|
+
status
|
|
314
|
+
} = _reactquery.useQuery.call(void 0, {
|
|
315
|
+
gcTime: 0,
|
|
316
|
+
staleTime: 0,
|
|
317
|
+
queryKey: [
|
|
318
|
+
"nexus-sdk",
|
|
319
|
+
"auto-referral-interaction",
|
|
320
|
+
_nullishCoalesce(_optionalChain([nexusContext, 'optionalAccess', _11 => _11.r]), () => ( "no-referrer")),
|
|
321
|
+
_nullishCoalesce(_optionalChain([walletStatus, 'optionalAccess', _12 => _12.key]), () => ( "no-wallet-status"))
|
|
322
|
+
],
|
|
323
|
+
queryFn: processReferral,
|
|
324
|
+
enabled: !!walletStatus
|
|
341
325
|
});
|
|
342
|
-
return
|
|
326
|
+
return _react.useMemo.call(void 0, () => {
|
|
327
|
+
if (status === "pending") return "processing";
|
|
328
|
+
if (status === "error") return mapErrorToState(error);
|
|
329
|
+
return referralState || "idle";
|
|
330
|
+
}, [referralState, status, error]);
|
|
343
331
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
status
|
|
332
|
+
function useEnsureWalletConnected({
|
|
333
|
+
modalConfig,
|
|
334
|
+
walletStatus
|
|
348
335
|
}) {
|
|
349
|
-
const
|
|
350
|
-
|
|
336
|
+
const { mutateAsync: displayModal2 } = useDisplayModal();
|
|
337
|
+
return _react.useCallback.call(void 0,
|
|
338
|
+
async ({ autoDisplay }) => {
|
|
339
|
+
if (_optionalChain([walletStatus, 'optionalAccess', _13 => _13.key]) !== "connected" || !walletStatus.interactionSession) {
|
|
340
|
+
if (!(modalConfig && autoDisplay)) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const result = await displayModal2(modalConfig);
|
|
344
|
+
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _14 => _14.login, 'optionalAccess', _15 => _15.wallet]), () => ( void 0));
|
|
345
|
+
}
|
|
346
|
+
return _nullishCoalesce(walletStatus.wallet, () => ( void 0));
|
|
347
|
+
},
|
|
348
|
+
[walletStatus, modalConfig, displayModal2]
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
function mapErrorToState(error) {
|
|
352
|
+
if (error instanceof _chunkBJ3CCN5Pcjs.FrakRpcError) {
|
|
351
353
|
switch (error.code) {
|
|
352
|
-
case
|
|
354
|
+
case _chunkBJ3CCN5Pcjs.RpcErrorCodes.walletNotConnected:
|
|
353
355
|
return "no-wallet";
|
|
354
|
-
case
|
|
356
|
+
case _chunkBJ3CCN5Pcjs.RpcErrorCodes.noInteractionSession:
|
|
355
357
|
return "no-session";
|
|
356
358
|
default:
|
|
357
359
|
return "error";
|
|
358
360
|
}
|
|
359
|
-
}
|
|
360
|
-
return
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
361
|
+
}
|
|
362
|
+
return "error";
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/react/hook/useOpenSso.ts
|
|
366
|
+
|
|
367
|
+
function useOpenSso({ mutations } = {}) {
|
|
368
|
+
const client = useNexusClient();
|
|
369
|
+
return _reactquery.useMutation.call(void 0, {
|
|
370
|
+
...mutations,
|
|
371
|
+
mutationKey: ["nexus-sdk", "open-sso"],
|
|
372
|
+
mutationFn: async (params) => {
|
|
373
|
+
if (!client) {
|
|
374
|
+
throw new (0, _chunkBJ3CCN5Pcjs.ClientNotFound)();
|
|
375
|
+
}
|
|
376
|
+
return _chunkS5FVCA2Ecjs.openSso.call(void 0, client, params);
|
|
368
377
|
}
|
|
369
|
-
}
|
|
378
|
+
});
|
|
370
379
|
}
|
|
371
380
|
|
|
372
381
|
// src/react/provider/NexusIFrameClientProvider.ts
|
|
373
382
|
var NexusIFrameClientContext = _react.createContext.call(void 0,
|
|
374
383
|
void 0
|
|
375
384
|
);
|
|
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
|
-
};
|
|
385
385
|
function NexusIFrameClientProvider({
|
|
386
386
|
style,
|
|
387
387
|
children
|
|
@@ -389,17 +389,15 @@ function NexusIFrameClientProvider({
|
|
|
389
389
|
const config = useNexusConfig();
|
|
390
390
|
const [client, setClient] = _react.useState.call(void 0, void 0);
|
|
391
391
|
const iFrame = _react.createElement.call(void 0, "iframe", {
|
|
392
|
-
|
|
393
|
-
name: "nexus-wallet",
|
|
392
|
+
..._chunkBJ3CCN5Pcjs.baseIframeProps,
|
|
394
393
|
src: `${config.walletUrl}/listener`,
|
|
395
|
-
style: _nullishCoalesce(style, () => (
|
|
396
|
-
allow: "publickey-credentials-get *",
|
|
394
|
+
style: _nullishCoalesce(style, () => ( _chunkBJ3CCN5Pcjs.baseIframeProps.style)),
|
|
397
395
|
ref: (iframe) => {
|
|
398
396
|
if (!iframe || client) {
|
|
399
397
|
return;
|
|
400
398
|
}
|
|
401
399
|
setClient(
|
|
402
|
-
|
|
400
|
+
_chunkBJ3CCN5Pcjs.createIFrameNexusClient.call(void 0, {
|
|
403
401
|
iframe,
|
|
404
402
|
config
|
|
405
403
|
})
|
|
@@ -427,4 +425,4 @@ function NexusIFrameClientProvider({
|
|
|
427
425
|
|
|
428
426
|
|
|
429
427
|
|
|
430
|
-
exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.
|
|
428
|
+
exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.useDisplayModal = useDisplayModal; exports.useNexusClient = useNexusClient; exports.useNexusConfig = useNexusConfig; exports.useOpenSso = useOpenSso; exports.useReferralInteraction = useReferralInteraction; exports.useSendInteraction = useSendInteraction; exports.useSendTransactionAction = useSendTransactionAction; exports.useSiweAuthenticate = useSiweAuthenticate; exports.useWalletStatus = useWalletStatus;
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import {
|
|
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-Oily5ph8.cjs';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
5
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
6
6
|
import * as viem from 'viem';
|
|
7
7
|
import { Hex } from 'viem';
|
|
8
|
-
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-CxnibdQx.cjs';
|
|
9
8
|
import { F as FrakRpcError } from '../error-C4Zm5nQe.cjs';
|
|
10
|
-
import {
|
|
9
|
+
import { b as SendTransactionParams, S as SiweAuthenticateModalParams } from '../sendTransaction-BKKYEt8p.cjs';
|
|
10
|
+
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-D3-M3nBh.cjs';
|
|
11
11
|
import 'viem/chains';
|
|
12
12
|
import 'viem/siwe';
|
|
13
13
|
|
|
@@ -18,6 +18,7 @@ declare const NexusConfigContext: react.Context<Readonly<{
|
|
|
18
18
|
walletUrl: string;
|
|
19
19
|
metadata: {
|
|
20
20
|
name: string;
|
|
21
|
+
css?: string;
|
|
21
22
|
};
|
|
22
23
|
domain: string;
|
|
23
24
|
}> | undefined>;
|
|
@@ -38,6 +39,7 @@ declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigPr
|
|
|
38
39
|
walletUrl: string;
|
|
39
40
|
metadata: {
|
|
40
41
|
name: string;
|
|
42
|
+
css?: string;
|
|
41
43
|
};
|
|
42
44
|
domain: string;
|
|
43
45
|
}> | undefined>>;
|
|
@@ -72,6 +74,7 @@ declare function useNexusConfig(): Readonly<{
|
|
|
72
74
|
walletUrl: string;
|
|
73
75
|
metadata: {
|
|
74
76
|
name: string;
|
|
77
|
+
css?: string;
|
|
75
78
|
};
|
|
76
79
|
domain: string;
|
|
77
80
|
}>;
|
|
@@ -81,53 +84,25 @@ declare function useNexusConfig(): Readonly<{
|
|
|
81
84
|
*/
|
|
82
85
|
declare function useNexusClient(): NexusClient | undefined;
|
|
83
86
|
|
|
84
|
-
/**
|
|
85
|
-
* Hook used to get the unlock options for an article
|
|
86
|
-
*/
|
|
87
|
-
declare function useArticleUnlockOptions({ articleId, contentId, }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
|
|
88
|
-
frkBalanceAsHex?: viem.Hex;
|
|
89
|
-
prices: {
|
|
90
|
-
index: number;
|
|
91
|
-
unlockDurationInSec: number;
|
|
92
|
-
frkAmount: viem.Hex;
|
|
93
|
-
isUserAccessible: boolean | null;
|
|
94
|
-
}[];
|
|
95
|
-
}> | undefined, Error>;
|
|
96
|
-
|
|
97
|
-
type WalletStatusQueryReturnType = WalletStatusReturnType | {
|
|
98
|
-
key: "waiting-response";
|
|
99
|
-
};
|
|
100
87
|
/**
|
|
101
88
|
* Hooks used to listen to the current wallet status
|
|
102
89
|
*/
|
|
103
|
-
declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<
|
|
104
|
-
|
|
105
|
-
type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
|
|
106
|
-
status: "waiting-response";
|
|
107
|
-
key: "waiting-response";
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Hooks used to listen to the current article unlock status
|
|
111
|
-
*/
|
|
112
|
-
declare function useArticleUnlockStatus({ articleId, contentId, }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
|
|
90
|
+
declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusReturnType, Error>;
|
|
113
91
|
|
|
114
|
-
type MutationOptions$
|
|
92
|
+
type MutationOptions$4 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
|
|
115
93
|
interface UseSendTransactionParams {
|
|
116
|
-
mutations?: MutationOptions$
|
|
94
|
+
mutations?: MutationOptions$4;
|
|
117
95
|
}
|
|
118
96
|
/**
|
|
119
97
|
* Trigger a dashboard action to the wallet
|
|
120
98
|
*/
|
|
121
99
|
declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
122
100
|
hash: viem.Hex;
|
|
123
|
-
}>, FrakRpcError<undefined>,
|
|
124
|
-
tx: SendTransactionTxType | SendTransactionTxType[];
|
|
125
|
-
context?: string;
|
|
126
|
-
}>, unknown>;
|
|
101
|
+
}>, FrakRpcError<undefined>, SendTransactionParams, unknown>;
|
|
127
102
|
|
|
128
|
-
type MutationOptions$
|
|
103
|
+
type MutationOptions$3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
|
|
129
104
|
interface UseSiweAuthenticateParams {
|
|
130
|
-
mutations?: MutationOptions$
|
|
105
|
+
mutations?: MutationOptions$3;
|
|
131
106
|
}
|
|
132
107
|
/**
|
|
133
108
|
* Trigger a dashboard action to the wallet
|
|
@@ -135,29 +110,47 @@ interface UseSiweAuthenticateParams {
|
|
|
135
110
|
declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
136
111
|
signature: viem.Hex;
|
|
137
112
|
message: string;
|
|
138
|
-
}>, FrakRpcError<undefined>,
|
|
139
|
-
siwe?: Partial<SiweAuthenticationParams>;
|
|
140
|
-
context?: string;
|
|
141
|
-
}>, unknown>;
|
|
113
|
+
}>, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
|
|
142
114
|
|
|
115
|
+
type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
|
|
143
116
|
/**
|
|
144
|
-
* Helper hook to automatically submit a
|
|
117
|
+
* Helper hook to automatically submit a referral interaction when detected
|
|
145
118
|
* -> And automatically set the referral context in the url
|
|
146
119
|
* @param contentId
|
|
120
|
+
* @param modalConfig
|
|
147
121
|
*/
|
|
148
|
-
declare function
|
|
149
|
-
contentId
|
|
150
|
-
|
|
122
|
+
declare function useReferralInteraction({ contentId, modalConfig, }?: {
|
|
123
|
+
contentId?: Hex;
|
|
124
|
+
modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
|
|
125
|
+
}): ReferralState;
|
|
151
126
|
|
|
152
|
-
type MutationOptions = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
|
|
153
|
-
interface UseSendInteractionParams {
|
|
154
|
-
mutations?: MutationOptions;
|
|
127
|
+
type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
|
|
128
|
+
interface UseSendInteractionParams$1 {
|
|
129
|
+
mutations?: MutationOptions$2;
|
|
155
130
|
}
|
|
156
131
|
/**
|
|
157
132
|
* Send a user interaction
|
|
158
133
|
*/
|
|
159
|
-
declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
160
|
-
|
|
134
|
+
declare function useSendInteraction({ mutations, }?: UseSendInteractionParams$1): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
135
|
+
delegationId: string;
|
|
161
136
|
}>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
|
|
162
137
|
|
|
163
|
-
|
|
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
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Open the SSO
|
|
153
|
+
*/
|
|
154
|
+
declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
155
|
+
|
|
156
|
+
export { NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, useDisplayModal, useNexusClient, useNexusConfig, useOpenSso, useReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };
|