@frak-labs/nexus-sdk 0.0.25 → 0.0.26
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/README.md +2 -72
- package/dist/bundle/bundle.js +6 -6
- package/package.json +11 -64
- package/dist/FrakContext-DKSVaeVb.d.cts +0 -450
- package/dist/FrakContext-DjeuWC2U.d.ts +0 -450
- package/dist/chunk-2VNIEGOJ.js +0 -864
- package/dist/chunk-4MMSQL44.js +0 -351
- package/dist/chunk-4PVF24BB.cjs +0 -114
- package/dist/chunk-BOGCLEPR.js +0 -80
- package/dist/chunk-DE2KWQVP.cjs +0 -351
- package/dist/chunk-FETGS7X7.js +0 -114
- package/dist/chunk-H4BK3CNV.cjs +0 -864
- package/dist/chunk-P3J2BIUT.cjs +0 -80
- package/dist/chunk-QLM5NFMZ.cjs +0 -245
- package/dist/chunk-YPQA63LW.js +0 -245
- package/dist/core/actions/index.cjs +0 -29
- package/dist/core/actions/index.d.cts +0 -92
- package/dist/core/actions/index.d.ts +0 -92
- package/dist/core/actions/index.js +0 -29
- package/dist/core/index.cjs +0 -34
- package/dist/core/index.d.cts +0 -167
- package/dist/core/index.d.ts +0 -167
- package/dist/core/index.js +0 -34
- package/dist/core/interactions/index.cjs +0 -13
- package/dist/core/interactions/index.d.cts +0 -65
- package/dist/core/interactions/index.d.ts +0 -65
- package/dist/core/interactions/index.js +0 -13
- package/dist/error-Dflr3G5x.d.cts +0 -27
- package/dist/error-Dflr3G5x.d.ts +0 -27
- package/dist/interaction-BngPoHA0.d.cts +0 -22
- package/dist/interaction-BngPoHA0.d.ts +0 -22
- package/dist/processReferral-CJI_Rc4K.d.ts +0 -53
- package/dist/processReferral-DUP8imQV.d.cts +0 -53
- package/dist/react/index.cjs +0 -366
- package/dist/react/index.d.cts +0 -167
- package/dist/react/index.d.ts +0 -167
- package/dist/react/index.js +0 -366
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic Frak RPC error
|
|
3
|
-
*/
|
|
4
|
-
declare class FrakRpcError<T = undefined> extends Error {
|
|
5
|
-
code: number;
|
|
6
|
-
data?: T | undefined;
|
|
7
|
-
constructor(code: number, message: string, data?: T | undefined);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* All the rpc error codes
|
|
11
|
-
*/
|
|
12
|
-
declare const RpcErrorCodes: {
|
|
13
|
-
readonly parseError: -32700;
|
|
14
|
-
readonly invalidRequest: -32600;
|
|
15
|
-
readonly methodNotFound: -32601;
|
|
16
|
-
readonly invalidParams: -32602;
|
|
17
|
-
readonly internalError: -32603;
|
|
18
|
-
readonly serverError: -32000;
|
|
19
|
-
readonly clientNotConnected: -32001;
|
|
20
|
-
readonly configError: -32002;
|
|
21
|
-
readonly corruptedResponse: -32003;
|
|
22
|
-
readonly clientAborted: -32004;
|
|
23
|
-
readonly walletNotConnected: -32005;
|
|
24
|
-
readonly serverErrorForInteractionDelegation: -32006;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { FrakRpcError as F, RpcErrorCodes as R };
|
package/dist/error-Dflr3G5x.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic Frak RPC error
|
|
3
|
-
*/
|
|
4
|
-
declare class FrakRpcError<T = undefined> extends Error {
|
|
5
|
-
code: number;
|
|
6
|
-
data?: T | undefined;
|
|
7
|
-
constructor(code: number, message: string, data?: T | undefined);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* All the rpc error codes
|
|
11
|
-
*/
|
|
12
|
-
declare const RpcErrorCodes: {
|
|
13
|
-
readonly parseError: -32700;
|
|
14
|
-
readonly invalidRequest: -32600;
|
|
15
|
-
readonly methodNotFound: -32601;
|
|
16
|
-
readonly invalidParams: -32602;
|
|
17
|
-
readonly internalError: -32603;
|
|
18
|
-
readonly serverError: -32000;
|
|
19
|
-
readonly clientNotConnected: -32001;
|
|
20
|
-
readonly configError: -32002;
|
|
21
|
-
readonly corruptedResponse: -32003;
|
|
22
|
-
readonly clientAborted: -32004;
|
|
23
|
-
readonly walletNotConnected: -32005;
|
|
24
|
-
readonly serverErrorForInteractionDelegation: -32006;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { FrakRpcError as F, RpcErrorCodes as R };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
2
|
-
|
|
3
|
-
type PreparedInteraction = Readonly<{
|
|
4
|
-
handlerTypeDenominator: Hex;
|
|
5
|
-
interactionData: Hex;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* Parameters of an interaction handling request
|
|
9
|
-
*/
|
|
10
|
-
type SendInteractionParamsType = {
|
|
11
|
-
productId?: Hex;
|
|
12
|
-
interaction: PreparedInteraction;
|
|
13
|
-
validation?: Hex;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Return type of the send interaction rpc request
|
|
17
|
-
*/
|
|
18
|
-
type SendInteractionReturnType = Readonly<{
|
|
19
|
-
delegationId: string;
|
|
20
|
-
}>;
|
|
21
|
-
|
|
22
|
-
export type { PreparedInteraction as P, SendInteractionParamsType as S, SendInteractionReturnType as a };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
2
|
-
|
|
3
|
-
type PreparedInteraction = Readonly<{
|
|
4
|
-
handlerTypeDenominator: Hex;
|
|
5
|
-
interactionData: Hex;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* Parameters of an interaction handling request
|
|
9
|
-
*/
|
|
10
|
-
type SendInteractionParamsType = {
|
|
11
|
-
productId?: Hex;
|
|
12
|
-
interaction: PreparedInteraction;
|
|
13
|
-
validation?: Hex;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Return type of the send interaction rpc request
|
|
17
|
-
*/
|
|
18
|
-
type SendInteractionReturnType = Readonly<{
|
|
19
|
-
delegationId: string;
|
|
20
|
-
}>;
|
|
21
|
-
|
|
22
|
-
export type { PreparedInteraction as P, SendInteractionParamsType as S, SendInteractionReturnType as a };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { h as SiweAuthenticationParams, c as ModalRpcMetadata, a as NexusClient, i as SiweAuthenticateReturnType, k as SendTransactionModalStepType, l as SendTransactionReturnType, W as WalletStatusReturnType, F as FrakContext, D as DisplayModalParamsType, M as ModalStepTypes } from './FrakContext-DjeuWC2U.js';
|
|
2
|
-
import { Hex } from 'viem';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Partial SIWE params, since we can rebuild them from the SDK if they are empty
|
|
6
|
-
*/
|
|
7
|
-
type SiweAuthenticateModalParams = {
|
|
8
|
-
siwe?: Partial<SiweAuthenticationParams>;
|
|
9
|
-
metadata?: ModalRpcMetadata;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Function used to launch a siwe authentication
|
|
13
|
-
* @param client
|
|
14
|
-
* @param siwe
|
|
15
|
-
* @param context
|
|
16
|
-
*/
|
|
17
|
-
declare function siweAuthenticate(client: NexusClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
|
|
18
|
-
|
|
19
|
-
type SendTransactionParams = {
|
|
20
|
-
tx: SendTransactionModalStepType["params"]["tx"];
|
|
21
|
-
metadata?: ModalRpcMetadata;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Function used to send a user transaction
|
|
25
|
-
* @param client
|
|
26
|
-
* @param tx
|
|
27
|
-
* @param context
|
|
28
|
-
*/
|
|
29
|
-
declare function sendTransaction(client: NexusClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
|
|
30
|
-
|
|
31
|
-
type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
|
|
32
|
-
type ProcessReferralOptions = {
|
|
33
|
-
alwaysAppendUrl?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Automatically submit a referral interaction when detected
|
|
37
|
-
* -> And automatically set the referral context in the url
|
|
38
|
-
* @param client
|
|
39
|
-
* @param walletStatus
|
|
40
|
-
* @param frakContext
|
|
41
|
-
* @param modalConfig
|
|
42
|
-
* @param productId
|
|
43
|
-
* @param options
|
|
44
|
-
*/
|
|
45
|
-
declare function processReferral(client: NexusClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
|
|
46
|
-
walletStatus?: WalletStatusReturnType;
|
|
47
|
-
frakContext?: Partial<FrakContext> | null;
|
|
48
|
-
modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
|
|
49
|
-
productId?: Hex;
|
|
50
|
-
options?: ProcessReferralOptions;
|
|
51
|
-
}): Promise<ReferralState>;
|
|
52
|
-
|
|
53
|
-
export { type ProcessReferralOptions as P, type SendTransactionParams as S, type SiweAuthenticateModalParams as a, sendTransaction as b, processReferral as p, siweAuthenticate as s };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { h as SiweAuthenticationParams, c as ModalRpcMetadata, a as NexusClient, i as SiweAuthenticateReturnType, k as SendTransactionModalStepType, l as SendTransactionReturnType, W as WalletStatusReturnType, F as FrakContext, D as DisplayModalParamsType, M as ModalStepTypes } from './FrakContext-DKSVaeVb.cjs';
|
|
2
|
-
import { Hex } from 'viem';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Partial SIWE params, since we can rebuild them from the SDK if they are empty
|
|
6
|
-
*/
|
|
7
|
-
type SiweAuthenticateModalParams = {
|
|
8
|
-
siwe?: Partial<SiweAuthenticationParams>;
|
|
9
|
-
metadata?: ModalRpcMetadata;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Function used to launch a siwe authentication
|
|
13
|
-
* @param client
|
|
14
|
-
* @param siwe
|
|
15
|
-
* @param context
|
|
16
|
-
*/
|
|
17
|
-
declare function siweAuthenticate(client: NexusClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
|
|
18
|
-
|
|
19
|
-
type SendTransactionParams = {
|
|
20
|
-
tx: SendTransactionModalStepType["params"]["tx"];
|
|
21
|
-
metadata?: ModalRpcMetadata;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Function used to send a user transaction
|
|
25
|
-
* @param client
|
|
26
|
-
* @param tx
|
|
27
|
-
* @param context
|
|
28
|
-
*/
|
|
29
|
-
declare function sendTransaction(client: NexusClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
|
|
30
|
-
|
|
31
|
-
type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
|
|
32
|
-
type ProcessReferralOptions = {
|
|
33
|
-
alwaysAppendUrl?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Automatically submit a referral interaction when detected
|
|
37
|
-
* -> And automatically set the referral context in the url
|
|
38
|
-
* @param client
|
|
39
|
-
* @param walletStatus
|
|
40
|
-
* @param frakContext
|
|
41
|
-
* @param modalConfig
|
|
42
|
-
* @param productId
|
|
43
|
-
* @param options
|
|
44
|
-
*/
|
|
45
|
-
declare function processReferral(client: NexusClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
|
|
46
|
-
walletStatus?: WalletStatusReturnType;
|
|
47
|
-
frakContext?: Partial<FrakContext> | null;
|
|
48
|
-
modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
|
|
49
|
-
productId?: Hex;
|
|
50
|
-
options?: ProcessReferralOptions;
|
|
51
|
-
}): Promise<ReferralState>;
|
|
52
|
-
|
|
53
|
-
export { type ProcessReferralOptions as P, type SendTransactionParams as S, type SiweAuthenticateModalParams as a, sendTransaction as b, processReferral as p, siweAuthenticate as s };
|
package/dist/react/index.cjs
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
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
|
-
|
|
3
|
-
var _chunkQLM5NFMZcjs = require('../chunk-QLM5NFMZ.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkDE2KWQVPcjs = require('../chunk-DE2KWQVP.cjs');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _chunkH4BK3CNVcjs = require('../chunk-H4BK3CNV.cjs');
|
|
21
|
-
require('../chunk-4PVF24BB.cjs');
|
|
22
|
-
require('../chunk-P3J2BIUT.cjs');
|
|
23
|
-
|
|
24
|
-
// src/react/provider/NexusConfigProvider.ts
|
|
25
|
-
var _react = require('react');
|
|
26
|
-
var NexusConfigContext = _react.createContext.call(void 0, void 0);
|
|
27
|
-
function NexusConfigProvider(parameters) {
|
|
28
|
-
const { children, config } = parameters;
|
|
29
|
-
return _react.createElement.call(void 0,
|
|
30
|
-
NexusConfigContext.Provider,
|
|
31
|
-
{
|
|
32
|
-
value: {
|
|
33
|
-
...config,
|
|
34
|
-
walletUrl: _nullishCoalesce(config.walletUrl, () => ( "https://wallet.frak.id")),
|
|
35
|
-
domain: _nullishCoalesce(_nullishCoalesce(config.domain, () => ( (typeof window !== "undefined" ? _optionalChain([window, 'optionalAccess', _ => _.location, 'optionalAccess', _2 => _2.host]) : void 0))), () => ( "not-found"))
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
children
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/react/provider/NexusIFrameClientProvider.ts
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// src/react/hook/useNexusConfig.ts
|
|
51
|
-
|
|
52
|
-
function useNexusConfig() {
|
|
53
|
-
const config = _react.useContext.call(void 0, NexusConfigContext);
|
|
54
|
-
if (!config) {
|
|
55
|
-
throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
|
|
56
|
-
_chunkH4BK3CNVcjs.RpcErrorCodes.configError,
|
|
57
|
-
"Nexus config not found"
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return config;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/react/hook/useNexusClient.ts
|
|
64
|
-
|
|
65
|
-
function useNexusClient() {
|
|
66
|
-
return _react.useContext.call(void 0, NexusIFrameClientContext);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/react/hook/useWalletStatus.ts
|
|
70
|
-
var _reactquery = require('@tanstack/react-query');
|
|
71
|
-
|
|
72
|
-
function useWalletStatus() {
|
|
73
|
-
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
74
|
-
const client = useNexusClient();
|
|
75
|
-
const newStatusUpdated = _react.useCallback.call(void 0,
|
|
76
|
-
(event) => {
|
|
77
|
-
queryClient.setQueryData(
|
|
78
|
-
["nexus-sdk", "wallet-status-listener"],
|
|
79
|
-
event
|
|
80
|
-
);
|
|
81
|
-
},
|
|
82
|
-
[queryClient]
|
|
83
|
-
);
|
|
84
|
-
return _reactquery.useQuery.call(void 0, {
|
|
85
|
-
gcTime: 0,
|
|
86
|
-
staleTime: 0,
|
|
87
|
-
queryKey: ["nexus-sdk", "wallet-status-listener"],
|
|
88
|
-
queryFn: async () => {
|
|
89
|
-
if (!client) {
|
|
90
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
91
|
-
}
|
|
92
|
-
return _chunkDE2KWQVPcjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
|
|
93
|
-
},
|
|
94
|
-
enabled: !!client
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/react/hook/useSendTransaction.ts
|
|
99
|
-
|
|
100
|
-
function useSendTransactionAction({
|
|
101
|
-
mutations
|
|
102
|
-
} = {}) {
|
|
103
|
-
const client = useNexusClient();
|
|
104
|
-
return _reactquery.useMutation.call(void 0, {
|
|
105
|
-
...mutations,
|
|
106
|
-
mutationKey: ["nexus-sdk", "send-transaction"],
|
|
107
|
-
mutationFn: async (params) => {
|
|
108
|
-
if (!client) {
|
|
109
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
110
|
-
}
|
|
111
|
-
return _chunkDE2KWQVPcjs.sendTransaction.call(void 0, client, params);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/react/hook/useSiweAuthenticate.ts
|
|
117
|
-
|
|
118
|
-
function useSiweAuthenticate({
|
|
119
|
-
mutations
|
|
120
|
-
} = {}) {
|
|
121
|
-
const client = useNexusClient();
|
|
122
|
-
return _reactquery.useMutation.call(void 0, {
|
|
123
|
-
...mutations,
|
|
124
|
-
mutationKey: [
|
|
125
|
-
"nexus-sdk",
|
|
126
|
-
"siwe-authenticate",
|
|
127
|
-
_nullishCoalesce(_optionalChain([client, 'optionalAccess', _3 => _3.config, 'access', _4 => _4.domain]), () => ( "no-domain"))
|
|
128
|
-
],
|
|
129
|
-
mutationFn: async (params) => {
|
|
130
|
-
if (!client) {
|
|
131
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
132
|
-
}
|
|
133
|
-
return _chunkDE2KWQVPcjs.siweAuthenticate.call(void 0, client, params);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/react/hook/helper/useReferralInteraction.ts
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// src/react/hook/utils/useFrakContext.ts
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// src/react/hook/utils/useWindowLocation.ts
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
// src/react/hook/utils/useMounted.ts
|
|
149
|
-
|
|
150
|
-
function useMounted() {
|
|
151
|
-
const [mounted, setMounted] = _react.useState.call(void 0, false);
|
|
152
|
-
_react.useEffect.call(void 0, () => {
|
|
153
|
-
setMounted(true);
|
|
154
|
-
}, []);
|
|
155
|
-
return mounted;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// src/react/hook/utils/useWindowLocation.ts
|
|
159
|
-
function useWindowLocation() {
|
|
160
|
-
const isMounted = useMounted();
|
|
161
|
-
const [location, setLocation] = _react.useState.call(void 0,
|
|
162
|
-
isMounted ? window.location : void 0
|
|
163
|
-
);
|
|
164
|
-
_react.useEffect.call(void 0, () => {
|
|
165
|
-
if (!isMounted) return;
|
|
166
|
-
function setWindowLocation() {
|
|
167
|
-
setLocation(window.location);
|
|
168
|
-
}
|
|
169
|
-
if (!location) {
|
|
170
|
-
setWindowLocation();
|
|
171
|
-
}
|
|
172
|
-
window.addEventListener("popstate", setWindowLocation);
|
|
173
|
-
return () => {
|
|
174
|
-
window.removeEventListener("popstate", setWindowLocation);
|
|
175
|
-
};
|
|
176
|
-
}, [isMounted, location]);
|
|
177
|
-
const href = _react.useMemo.call(void 0, () => _optionalChain([location, 'optionalAccess', _5 => _5.href]), [_optionalChain([location, 'optionalAccess', _6 => _6.href])]);
|
|
178
|
-
return { location, href };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// src/react/hook/utils/useFrakContext.ts
|
|
182
|
-
function useFrakContext() {
|
|
183
|
-
const { location } = useWindowLocation();
|
|
184
|
-
const frakContext = _react.useMemo.call(void 0, () => {
|
|
185
|
-
if (!_optionalChain([location, 'optionalAccess', _7 => _7.href])) return null;
|
|
186
|
-
return _chunkH4BK3CNVcjs.FrakContextManager.parse({ url: location.href });
|
|
187
|
-
}, [_optionalChain([location, 'optionalAccess', _8 => _8.href])]);
|
|
188
|
-
const updateContext = _react.useCallback.call(void 0,
|
|
189
|
-
(newContext) => {
|
|
190
|
-
console.log("Updating context", { newContext });
|
|
191
|
-
_chunkH4BK3CNVcjs.FrakContextManager.replaceUrl({
|
|
192
|
-
url: _optionalChain([location, 'optionalAccess', _9 => _9.href]),
|
|
193
|
-
context: newContext
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
[_optionalChain([location, 'optionalAccess', _10 => _10.href])]
|
|
197
|
-
);
|
|
198
|
-
return {
|
|
199
|
-
frakContext,
|
|
200
|
-
updateContext
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// src/react/hook/helper/useReferralInteraction.ts
|
|
205
|
-
function useReferralInteraction({
|
|
206
|
-
productId,
|
|
207
|
-
modalConfig,
|
|
208
|
-
options
|
|
209
|
-
} = {}) {
|
|
210
|
-
const client = useNexusClient();
|
|
211
|
-
const { frakContext } = useFrakContext();
|
|
212
|
-
const { data: walletStatus } = useWalletStatus();
|
|
213
|
-
const {
|
|
214
|
-
data: referralState,
|
|
215
|
-
error,
|
|
216
|
-
status
|
|
217
|
-
} = _reactquery.useQuery.call(void 0, {
|
|
218
|
-
gcTime: 0,
|
|
219
|
-
staleTime: 0,
|
|
220
|
-
queryKey: [
|
|
221
|
-
"nexus-sdk",
|
|
222
|
-
"auto-referral-interaction",
|
|
223
|
-
_nullishCoalesce(_optionalChain([frakContext, 'optionalAccess', _11 => _11.r]), () => ( "no-referrer")),
|
|
224
|
-
_nullishCoalesce(_optionalChain([walletStatus, 'optionalAccess', _12 => _12.key]), () => ( "no-wallet-status")),
|
|
225
|
-
_nullishCoalesce(productId, () => ( "no-product-id"))
|
|
226
|
-
],
|
|
227
|
-
queryFn: () => {
|
|
228
|
-
if (!client) {
|
|
229
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
230
|
-
}
|
|
231
|
-
return _chunkDE2KWQVPcjs.processReferral.call(void 0, client, {
|
|
232
|
-
walletStatus,
|
|
233
|
-
frakContext,
|
|
234
|
-
modalConfig,
|
|
235
|
-
productId,
|
|
236
|
-
options
|
|
237
|
-
});
|
|
238
|
-
},
|
|
239
|
-
enabled: !!walletStatus
|
|
240
|
-
});
|
|
241
|
-
return _react.useMemo.call(void 0, () => {
|
|
242
|
-
if (status === "pending") return "processing";
|
|
243
|
-
if (status === "error") return error;
|
|
244
|
-
return referralState || "idle";
|
|
245
|
-
}, [referralState, status, error]);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// src/react/hook/useSendInteraction.ts
|
|
249
|
-
|
|
250
|
-
function useSendInteraction({
|
|
251
|
-
mutations
|
|
252
|
-
} = {}) {
|
|
253
|
-
const client = useNexusClient();
|
|
254
|
-
return _reactquery.useMutation.call(void 0, {
|
|
255
|
-
...mutations,
|
|
256
|
-
mutationKey: ["nexus-sdk", "send-interaction"],
|
|
257
|
-
mutationFn: async (params) => {
|
|
258
|
-
if (!client) {
|
|
259
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
260
|
-
}
|
|
261
|
-
return _chunkDE2KWQVPcjs.sendInteraction.call(void 0, client, params);
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// src/react/hook/useDisplayModal.ts
|
|
267
|
-
|
|
268
|
-
function useDisplayModal({
|
|
269
|
-
mutations
|
|
270
|
-
} = {}) {
|
|
271
|
-
const client = useNexusClient();
|
|
272
|
-
return _reactquery.useMutation.call(void 0, {
|
|
273
|
-
...mutations,
|
|
274
|
-
mutationKey: ["nexus-sdk", "display-modal"],
|
|
275
|
-
mutationFn: async (args) => {
|
|
276
|
-
if (!client) {
|
|
277
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
278
|
-
}
|
|
279
|
-
return _chunkDE2KWQVPcjs.displayModal.call(void 0, client, args);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/react/hook/useOpenSso.ts
|
|
285
|
-
|
|
286
|
-
function useOpenSso({ mutations } = {}) {
|
|
287
|
-
const client = useNexusClient();
|
|
288
|
-
return _reactquery.useMutation.call(void 0, {
|
|
289
|
-
...mutations,
|
|
290
|
-
mutationKey: ["nexus-sdk", "open-sso"],
|
|
291
|
-
mutationFn: async (params) => {
|
|
292
|
-
if (!client) {
|
|
293
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
294
|
-
}
|
|
295
|
-
return _chunkDE2KWQVPcjs.openSso.call(void 0, client, params);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/react/hook/useGetProductInformation.ts
|
|
301
|
-
|
|
302
|
-
function useGetProductInformation({
|
|
303
|
-
query
|
|
304
|
-
} = {}) {
|
|
305
|
-
const client = useNexusClient();
|
|
306
|
-
return _reactquery.useQuery.call(void 0, {
|
|
307
|
-
...query,
|
|
308
|
-
queryKey: ["nexus-sdk", "get-product-information"],
|
|
309
|
-
queryFn: async () => {
|
|
310
|
-
if (!client) {
|
|
311
|
-
throw new (0, _chunkH4BK3CNVcjs.ClientNotFound)();
|
|
312
|
-
}
|
|
313
|
-
return _chunkDE2KWQVPcjs.getProductInformation.call(void 0, client);
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// src/react/provider/NexusIFrameClientProvider.ts
|
|
319
|
-
var NexusIFrameClientContext = _react.createContext.call(void 0,
|
|
320
|
-
void 0
|
|
321
|
-
);
|
|
322
|
-
function NexusIFrameClientProvider({
|
|
323
|
-
style,
|
|
324
|
-
children
|
|
325
|
-
}) {
|
|
326
|
-
const config = useNexusConfig();
|
|
327
|
-
const [client, setClient] = _react.useState.call(void 0, void 0);
|
|
328
|
-
const iFrame = _react.createElement.call(void 0, "iframe", {
|
|
329
|
-
..._chunkH4BK3CNVcjs.baseIframeProps,
|
|
330
|
-
src: `${config.walletUrl}/listener`,
|
|
331
|
-
style: _nullishCoalesce(style, () => ( _chunkH4BK3CNVcjs.baseIframeProps.style)),
|
|
332
|
-
ref: (iframe) => {
|
|
333
|
-
if (!iframe || client) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
setClient(
|
|
337
|
-
_chunkQLM5NFMZcjs.createIFrameNexusClient.call(void 0, {
|
|
338
|
-
iframe,
|
|
339
|
-
config
|
|
340
|
-
})
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
const providerComponent = _react.createElement.call(void 0,
|
|
345
|
-
NexusIFrameClientContext.Provider,
|
|
346
|
-
{ value: client },
|
|
347
|
-
children
|
|
348
|
-
);
|
|
349
|
-
return _react.createElement.call(void 0, _react.Fragment, null, iFrame, providerComponent);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.useDisplayModal = useDisplayModal; exports.useGetProductInformation = useGetProductInformation; exports.useNexusClient = useNexusClient; exports.useNexusConfig = useNexusConfig; exports.useOpenSso = useOpenSso; exports.useReferralInteraction = useReferralInteraction; exports.useSendInteraction = useSendInteraction; exports.useSendTransactionAction = useSendTransactionAction; exports.useSiweAuthenticate = useSiweAuthenticate; exports.useWalletStatus = useWalletStatus;
|