@frak-labs/nexus-sdk 0.0.10 → 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.
- package/dist/chunk-5CFD5FM2.js +86 -0
- package/dist/chunk-7MVQQ2X6.js +381 -0
- package/dist/{chunk-72IEHEQX.js → chunk-GUDT2W6I.js} +32 -10
- package/dist/{chunk-NIFJZD3M.cjs → chunk-IQQTTKJL.cjs} +30 -8
- package/dist/chunk-S5FVCA2E.cjs +86 -0
- package/dist/chunk-V3S6RBRJ.cjs +381 -0
- package/dist/{client-6_BJp7Ub.d.ts → client-C7u9zGwC.d.cts} +135 -142
- package/dist/{client--U_6SK0l.d.cts → client-gE3fYzkD.d.ts} +135 -142
- 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 +3 -3
- package/dist/core/index.d.ts +3 -3
- 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 +146 -158
- package/dist/react/index.d.cts +44 -51
- package/dist/react/index.d.ts +44 -51
- package/dist/react/index.js +152 -164
- package/dist/sendTransaction-BZW627cT.d.cts +30 -0
- package/dist/sendTransaction-DpJTfGJc.d.ts +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/watchUnlockStatus-CxnibdQx.d.cts +0 -43
- package/dist/watchUnlockStatus-g8wIxpeM.d.ts +0 -43
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hex, Address } from 'viem';
|
|
2
|
-
import { P as PreparedInteraction } from '../../interaction-
|
|
2
|
+
import { P as PreparedInteraction } from '../../interaction-D3-M3nBh.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* All the press interactions actions
|
|
@@ -7,7 +7,6 @@ import { P as PreparedInteraction } from '../../interaction-D_CzyqRE.cjs';
|
|
|
7
7
|
declare const PressActionsSelector: {
|
|
8
8
|
readonly OpenArticle: "0xc0a24ffb";
|
|
9
9
|
readonly ReadArticle: "0xd5bd0fbe";
|
|
10
|
-
readonly Referred: "0x3d1508ad";
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
13
12
|
* Encode an open article interaction
|
|
@@ -23,6 +22,22 @@ declare function openArticle({ articleId }: {
|
|
|
23
22
|
declare function readArticle({ articleId }: {
|
|
24
23
|
articleId: Hex;
|
|
25
24
|
}): PreparedInteraction;
|
|
25
|
+
declare const PressInteractionEncoder: {
|
|
26
|
+
openArticle: typeof openArticle;
|
|
27
|
+
readArticle: typeof readArticle;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* All the referral interactions actions
|
|
32
|
+
*/
|
|
33
|
+
declare const ReferralActionsSelector: {
|
|
34
|
+
readonly CreateLink: "0xb2c0f17c";
|
|
35
|
+
readonly Referred: "0x010cc3b9";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Encode a create referral link interaction
|
|
39
|
+
*/
|
|
40
|
+
declare function createLink(): PreparedInteraction;
|
|
26
41
|
/**
|
|
27
42
|
* Encode a referred interaction
|
|
28
43
|
* @param referrer
|
|
@@ -30,10 +45,9 @@ declare function readArticle({ articleId }: {
|
|
|
30
45
|
declare function referred({ referrer }: {
|
|
31
46
|
referrer: Address;
|
|
32
47
|
}): PreparedInteraction;
|
|
33
|
-
declare const
|
|
34
|
-
|
|
35
|
-
readArticle: typeof readArticle;
|
|
48
|
+
declare const ReferralInteractionEncoder: {
|
|
49
|
+
createLink: typeof createLink;
|
|
36
50
|
referred: typeof referred;
|
|
37
51
|
};
|
|
38
52
|
|
|
39
|
-
export { PressActionsSelector, PressInteractionEncoder };
|
|
53
|
+
export { PressActionsSelector, PressInteractionEncoder, ReferralActionsSelector, ReferralInteractionEncoder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hex, Address } from 'viem';
|
|
2
|
-
import { P as PreparedInteraction } from '../../interaction-
|
|
2
|
+
import { P as PreparedInteraction } from '../../interaction-D3-M3nBh.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* All the press interactions actions
|
|
@@ -7,7 +7,6 @@ import { P as PreparedInteraction } from '../../interaction-D_CzyqRE.js';
|
|
|
7
7
|
declare const PressActionsSelector: {
|
|
8
8
|
readonly OpenArticle: "0xc0a24ffb";
|
|
9
9
|
readonly ReadArticle: "0xd5bd0fbe";
|
|
10
|
-
readonly Referred: "0x3d1508ad";
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
13
12
|
* Encode an open article interaction
|
|
@@ -23,6 +22,22 @@ declare function openArticle({ articleId }: {
|
|
|
23
22
|
declare function readArticle({ articleId }: {
|
|
24
23
|
articleId: Hex;
|
|
25
24
|
}): PreparedInteraction;
|
|
25
|
+
declare const PressInteractionEncoder: {
|
|
26
|
+
openArticle: typeof openArticle;
|
|
27
|
+
readArticle: typeof readArticle;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* All the referral interactions actions
|
|
32
|
+
*/
|
|
33
|
+
declare const ReferralActionsSelector: {
|
|
34
|
+
readonly CreateLink: "0xb2c0f17c";
|
|
35
|
+
readonly Referred: "0x010cc3b9";
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Encode a create referral link interaction
|
|
39
|
+
*/
|
|
40
|
+
declare function createLink(): PreparedInteraction;
|
|
26
41
|
/**
|
|
27
42
|
* Encode a referred interaction
|
|
28
43
|
* @param referrer
|
|
@@ -30,10 +45,9 @@ declare function readArticle({ articleId }: {
|
|
|
30
45
|
declare function referred({ referrer }: {
|
|
31
46
|
referrer: Address;
|
|
32
47
|
}): PreparedInteraction;
|
|
33
|
-
declare const
|
|
34
|
-
|
|
35
|
-
readArticle: typeof readArticle;
|
|
48
|
+
declare const ReferralInteractionEncoder: {
|
|
49
|
+
createLink: typeof createLink;
|
|
36
50
|
referred: typeof referred;
|
|
37
51
|
};
|
|
38
52
|
|
|
39
|
-
export { PressActionsSelector, PressInteractionEncoder };
|
|
53
|
+
export { PressActionsSelector, PressInteractionEncoder, ReferralActionsSelector, ReferralInteractionEncoder };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PressActionsSelector,
|
|
3
|
-
PressInteractionEncoder
|
|
4
|
-
|
|
3
|
+
PressInteractionEncoder,
|
|
4
|
+
ReferralActionsSelector,
|
|
5
|
+
ReferralInteractionEncoder
|
|
6
|
+
} from "../../chunk-GUDT2W6I.js";
|
|
5
7
|
import "../../chunk-PKBMQBKP.js";
|
|
6
8
|
export {
|
|
7
9
|
PressActionsSelector,
|
|
8
|
-
PressInteractionEncoder
|
|
10
|
+
PressInteractionEncoder,
|
|
11
|
+
ReferralActionsSelector,
|
|
12
|
+
ReferralInteractionEncoder
|
|
9
13
|
};
|
|
@@ -8,7 +8,7 @@ type PreparedInteraction = Readonly<{
|
|
|
8
8
|
* Parameters of an interaction handling request
|
|
9
9
|
*/
|
|
10
10
|
type SendInteractionParamsType = {
|
|
11
|
-
contentId
|
|
11
|
+
contentId?: Hex;
|
|
12
12
|
interaction: PreparedInteraction;
|
|
13
13
|
validation?: Hex;
|
|
14
14
|
};
|
|
@@ -16,7 +16,7 @@ type SendInteractionParamsType = {
|
|
|
16
16
|
* Return type of the send interaction rpc request
|
|
17
17
|
*/
|
|
18
18
|
type SendInteractionReturnType = Readonly<{
|
|
19
|
-
|
|
19
|
+
delegationId: string;
|
|
20
20
|
}>;
|
|
21
21
|
|
|
22
22
|
export type { PreparedInteraction as P, SendInteractionParamsType as S, SendInteractionReturnType as a };
|
|
@@ -8,7 +8,7 @@ type PreparedInteraction = Readonly<{
|
|
|
8
8
|
* Parameters of an interaction handling request
|
|
9
9
|
*/
|
|
10
10
|
type SendInteractionParamsType = {
|
|
11
|
-
contentId
|
|
11
|
+
contentId?: Hex;
|
|
12
12
|
interaction: PreparedInteraction;
|
|
13
13
|
validation?: Hex;
|
|
14
14
|
};
|
|
@@ -16,7 +16,7 @@ type SendInteractionParamsType = {
|
|
|
16
16
|
* Return type of the send interaction rpc request
|
|
17
17
|
*/
|
|
18
18
|
type SendInteractionReturnType = Readonly<{
|
|
19
|
-
|
|
19
|
+
delegationId: string;
|
|
20
20
|
}>;
|
|
21
21
|
|
|
22
22
|
export type { PreparedInteraction as P, SendInteractionParamsType as S, SendInteractionReturnType as a };
|
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 _chunkV3S6RBRJcjs = require('../chunk-V3S6RBRJ.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, _chunkV3S6RBRJcjs.FrakRpcError)(
|
|
55
|
+
_chunkV3S6RBRJcjs.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, _chunkV3S6RBRJcjs.ClientNotFound)();
|
|
117
89
|
}
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
const firstResult = new (0, _chunkV3S6RBRJcjs.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, _chunkV3S6RBRJcjs.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, _chunkV3S6RBRJcjs.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, _chunkV3S6RBRJcjs.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, _chunkV3S6RBRJcjs.ClientNotFound)();
|
|
237
180
|
}
|
|
238
|
-
return
|
|
181
|
+
return _chunkS5FVCA2Ecjs.sendInteraction.call(void 0, client, params);
|
|
239
182
|
}
|
|
240
183
|
});
|
|
241
184
|
}
|
|
@@ -290,98 +233,145 @@ 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 _chunkV3S6RBRJcjs.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 _chunkV3S6RBRJcjs.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
|
-
|
|
328
|
-
|
|
329
|
-
return
|
|
269
|
+
const ensureWalletConnected = useEnsureWalletConnected({
|
|
270
|
+
modalConfig,
|
|
271
|
+
walletStatus
|
|
272
|
+
});
|
|
273
|
+
const processReferral = _react.useCallback.call(void 0, async () => {
|
|
274
|
+
try {
|
|
275
|
+
const currentWallet = await ensureWalletConnected();
|
|
276
|
+
if (!_optionalChain([nexusContext, 'optionalAccess', _10 => _10.r])) {
|
|
277
|
+
if (currentWallet) {
|
|
278
|
+
await updateContextAsync({ r: currentWallet });
|
|
279
|
+
}
|
|
280
|
+
return "no-referrer";
|
|
281
|
+
}
|
|
282
|
+
if (currentWallet && _viem.isAddressEqual.call(void 0, nexusContext.r, currentWallet)) {
|
|
283
|
+
return "self-referral";
|
|
330
284
|
}
|
|
331
|
-
|
|
332
|
-
if (_viem.isAddressEqual.call(void 0, nexusContext.r, walletStatus.wallet))
|
|
333
|
-
return null;
|
|
334
|
-
const interaction = _chunkNIFJZD3Mcjs.PressInteractionEncoder.referred({
|
|
285
|
+
const interaction = _chunkIQQTTKJLcjs.ReferralInteractionEncoder.referred({
|
|
335
286
|
referrer: nexusContext.r
|
|
336
287
|
});
|
|
337
288
|
await sendInteraction2({ contentId, interaction });
|
|
338
|
-
|
|
339
|
-
|
|
289
|
+
if (currentWallet) {
|
|
290
|
+
await updateContextAsync({ r: currentWallet });
|
|
291
|
+
}
|
|
292
|
+
return "success";
|
|
293
|
+
} catch (error2) {
|
|
294
|
+
return mapErrorToState(error2);
|
|
340
295
|
}
|
|
296
|
+
}, [
|
|
297
|
+
nexusContext,
|
|
298
|
+
contentId,
|
|
299
|
+
ensureWalletConnected,
|
|
300
|
+
sendInteraction2,
|
|
301
|
+
updateContextAsync
|
|
302
|
+
]);
|
|
303
|
+
const {
|
|
304
|
+
data: referralState,
|
|
305
|
+
error,
|
|
306
|
+
status
|
|
307
|
+
} = _reactquery.useQuery.call(void 0, {
|
|
308
|
+
gcTime: 0,
|
|
309
|
+
staleTime: 0,
|
|
310
|
+
queryKey: [
|
|
311
|
+
"nexus-sdk",
|
|
312
|
+
"auto-referral-interaction",
|
|
313
|
+
_nullishCoalesce(_optionalChain([nexusContext, 'optionalAccess', _11 => _11.r]), () => ( "no-referrer")),
|
|
314
|
+
_nullishCoalesce(_optionalChain([walletStatus, 'optionalAccess', _12 => _12.key]), () => ( "no-wallet-status"))
|
|
315
|
+
],
|
|
316
|
+
queryFn: processReferral,
|
|
317
|
+
enabled: !!walletStatus
|
|
341
318
|
});
|
|
342
|
-
return
|
|
319
|
+
return _react.useMemo.call(void 0, () => {
|
|
320
|
+
if (status === "pending") return "processing";
|
|
321
|
+
if (status === "error") return mapErrorToState(error);
|
|
322
|
+
return referralState || "idle";
|
|
323
|
+
}, [referralState, status, error]);
|
|
343
324
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
status
|
|
325
|
+
function useEnsureWalletConnected({
|
|
326
|
+
modalConfig,
|
|
327
|
+
walletStatus
|
|
348
328
|
}) {
|
|
349
|
-
const
|
|
350
|
-
|
|
329
|
+
const { mutateAsync: displayModal2 } = useDisplayModal();
|
|
330
|
+
return _react.useCallback.call(void 0, async () => {
|
|
331
|
+
if (_optionalChain([walletStatus, 'optionalAccess', _13 => _13.key]) !== "connected" || !walletStatus.interactionSession) {
|
|
332
|
+
if (!modalConfig) {
|
|
333
|
+
return void 0;
|
|
334
|
+
}
|
|
335
|
+
const result = await displayModal2(modalConfig);
|
|
336
|
+
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _14 => _14.login, 'optionalAccess', _15 => _15.wallet]), () => ( void 0));
|
|
337
|
+
}
|
|
338
|
+
return _nullishCoalesce(walletStatus.wallet, () => ( void 0));
|
|
339
|
+
}, [walletStatus, modalConfig, displayModal2]);
|
|
340
|
+
}
|
|
341
|
+
function mapErrorToState(error) {
|
|
342
|
+
if (error instanceof _chunkV3S6RBRJcjs.FrakRpcError) {
|
|
351
343
|
switch (error.code) {
|
|
352
|
-
case
|
|
344
|
+
case _chunkV3S6RBRJcjs.RpcErrorCodes.walletNotConnected:
|
|
353
345
|
return "no-wallet";
|
|
354
|
-
case
|
|
346
|
+
case _chunkV3S6RBRJcjs.RpcErrorCodes.noInteractionSession:
|
|
355
347
|
return "no-session";
|
|
356
348
|
default:
|
|
357
349
|
return "error";
|
|
358
350
|
}
|
|
359
|
-
}
|
|
360
|
-
return
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
351
|
+
}
|
|
352
|
+
return "error";
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// src/react/hook/useOpenSso.ts
|
|
356
|
+
|
|
357
|
+
function useOpenSso({ mutations } = {}) {
|
|
358
|
+
const client = useNexusClient();
|
|
359
|
+
return _reactquery.useMutation.call(void 0, {
|
|
360
|
+
...mutations,
|
|
361
|
+
mutationKey: ["nexus-sdk", "open-sso"],
|
|
362
|
+
mutationFn: async (params) => {
|
|
363
|
+
if (!client) {
|
|
364
|
+
throw new (0, _chunkV3S6RBRJcjs.ClientNotFound)();
|
|
365
|
+
}
|
|
366
|
+
return _chunkS5FVCA2Ecjs.openSso.call(void 0, client, params);
|
|
368
367
|
}
|
|
369
|
-
}
|
|
368
|
+
});
|
|
370
369
|
}
|
|
371
370
|
|
|
372
371
|
// src/react/provider/NexusIFrameClientProvider.ts
|
|
373
372
|
var NexusIFrameClientContext = _react.createContext.call(void 0,
|
|
374
373
|
void 0
|
|
375
374
|
);
|
|
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
375
|
function NexusIFrameClientProvider({
|
|
386
376
|
style,
|
|
387
377
|
children
|
|
@@ -389,17 +379,15 @@ function NexusIFrameClientProvider({
|
|
|
389
379
|
const config = useNexusConfig();
|
|
390
380
|
const [client, setClient] = _react.useState.call(void 0, void 0);
|
|
391
381
|
const iFrame = _react.createElement.call(void 0, "iframe", {
|
|
392
|
-
|
|
393
|
-
name: "nexus-wallet",
|
|
382
|
+
..._chunkV3S6RBRJcjs.baseIframeProps,
|
|
394
383
|
src: `${config.walletUrl}/listener`,
|
|
395
|
-
style: _nullishCoalesce(style, () => (
|
|
396
|
-
allow: "publickey-credentials-get *",
|
|
384
|
+
style: _nullishCoalesce(style, () => ( _chunkV3S6RBRJcjs.baseIframeProps.style)),
|
|
397
385
|
ref: (iframe) => {
|
|
398
386
|
if (!iframe || client) {
|
|
399
387
|
return;
|
|
400
388
|
}
|
|
401
389
|
setClient(
|
|
402
|
-
|
|
390
|
+
_chunkV3S6RBRJcjs.createIFrameNexusClient.call(void 0, {
|
|
403
391
|
iframe,
|
|
404
392
|
config
|
|
405
393
|
})
|
|
@@ -427,4 +415,4 @@ function NexusIFrameClientProvider({
|
|
|
427
415
|
|
|
428
416
|
|
|
429
417
|
|
|
430
|
-
exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.
|
|
418
|
+
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;
|