@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
package/dist/react/index.d.cts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType, l as SendTransactionReturnType, i as SiweAuthenticateReturnType, D as DisplayModalParamsType, M as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType, G as GetProductInformationReturnType } from '../FrakContext-DKSVaeVb.cjs';
|
|
4
|
-
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
6
|
-
import * as viem from 'viem';
|
|
7
|
-
import { Hex } from 'viem';
|
|
8
|
-
import { F as FrakRpcError } from '../error-Dflr3G5x.cjs';
|
|
9
|
-
import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-DUP8imQV.cjs';
|
|
10
|
-
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.cjs';
|
|
11
|
-
import 'viem/chains';
|
|
12
|
-
import 'viem/siwe';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The context that will keep the Nexus Wallet SDK configuration
|
|
16
|
-
*/
|
|
17
|
-
declare const NexusConfigContext: react.Context<Readonly<{
|
|
18
|
-
walletUrl?: string;
|
|
19
|
-
metadata: {
|
|
20
|
-
name: string;
|
|
21
|
-
css?: string;
|
|
22
|
-
buttonShare?: string;
|
|
23
|
-
};
|
|
24
|
-
domain?: string;
|
|
25
|
-
}> | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
28
|
-
*/
|
|
29
|
-
type NexusConfigProviderProps = {
|
|
30
|
-
config: NexusWalletSdkConfig;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Simple config provider for the Nexus Wallet SDK
|
|
34
|
-
* @param parameters
|
|
35
|
-
* @constructor
|
|
36
|
-
*/
|
|
37
|
-
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
38
|
-
walletUrl?: string;
|
|
39
|
-
metadata: {
|
|
40
|
-
name: string;
|
|
41
|
-
css?: string;
|
|
42
|
-
buttonShare?: string;
|
|
43
|
-
};
|
|
44
|
-
domain?: string;
|
|
45
|
-
}> | undefined>>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The context that will keep the Nexus Wallet SDK client
|
|
49
|
-
*/
|
|
50
|
-
declare const NexusIFrameClientContext: react.Context<NexusClient | undefined>;
|
|
51
|
-
/**
|
|
52
|
-
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
53
|
-
*/
|
|
54
|
-
type NexusIFrameClientProps = {
|
|
55
|
-
config: NexusWalletSdkConfig;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* IFrame client provider for the Nexus Wallet SDK
|
|
59
|
-
* - Automatically set the config provider
|
|
60
|
-
* @param parameters
|
|
61
|
-
* @constructor
|
|
62
|
-
*/
|
|
63
|
-
declare function NexusIFrameClientProvider({ style, children, }: {
|
|
64
|
-
style?: CSSProperties;
|
|
65
|
-
children?: ReactNode;
|
|
66
|
-
}): react.FunctionComponentElement<{
|
|
67
|
-
children?: ReactNode | undefined;
|
|
68
|
-
}>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Use the current nexus config
|
|
72
|
-
*/
|
|
73
|
-
declare function useNexusConfig(): Readonly<{
|
|
74
|
-
walletUrl?: string;
|
|
75
|
-
metadata: {
|
|
76
|
-
name: string;
|
|
77
|
-
css?: string;
|
|
78
|
-
buttonShare?: string;
|
|
79
|
-
};
|
|
80
|
-
domain?: string;
|
|
81
|
-
}>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Use the current nexus iframe client
|
|
85
|
-
*/
|
|
86
|
-
declare function useNexusClient(): NexusClient | undefined;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Hooks used to listen to the current wallet status
|
|
90
|
-
*/
|
|
91
|
-
declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusReturnType, Error>;
|
|
92
|
-
|
|
93
|
-
type MutationOptions$4 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
|
|
94
|
-
interface UseSendTransactionParams {
|
|
95
|
-
mutations?: MutationOptions$4;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Trigger a dashboard action to the wallet
|
|
99
|
-
*/
|
|
100
|
-
declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
101
|
-
hash: viem.Hex;
|
|
102
|
-
}>, FrakRpcError<undefined>, SendTransactionParams, unknown>;
|
|
103
|
-
|
|
104
|
-
type MutationOptions$3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
|
|
105
|
-
interface UseSiweAuthenticateParams {
|
|
106
|
-
mutations?: MutationOptions$3;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Trigger a dashboard action to the wallet
|
|
110
|
-
*/
|
|
111
|
-
declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
112
|
-
signature: viem.Hex;
|
|
113
|
-
message: string;
|
|
114
|
-
}>, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Helper hook to automatically submit a referral interaction when detected
|
|
118
|
-
* -> And automatically set the referral context in the url
|
|
119
|
-
* @param productId
|
|
120
|
-
* @param modalConfig
|
|
121
|
-
* @param options
|
|
122
|
-
*/
|
|
123
|
-
declare function useReferralInteraction({ productId, modalConfig, options, }?: {
|
|
124
|
-
productId?: Hex;
|
|
125
|
-
modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
|
|
126
|
-
options?: ProcessReferralOptions;
|
|
127
|
-
}): Error | ("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral");
|
|
128
|
-
|
|
129
|
-
type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
|
|
130
|
-
interface UseSendInteractionParams$1 {
|
|
131
|
-
mutations?: MutationOptions$2;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Send a user interaction
|
|
135
|
-
*/
|
|
136
|
-
declare function useSendInteraction({ mutations, }?: UseSendInteractionParams$1): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
137
|
-
delegationId: string;
|
|
138
|
-
}>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
|
|
139
|
-
|
|
140
|
-
type MutationOptions$1<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
|
|
141
|
-
interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
|
|
142
|
-
mutations?: MutationOptions$1<T>;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Send a user interaction
|
|
146
|
-
*/
|
|
147
|
-
declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): _tanstack_react_query.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
|
|
148
|
-
|
|
149
|
-
type MutationOptions = Omit<UseMutationOptions<void, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
|
|
150
|
-
interface UseSendInteractionParams {
|
|
151
|
-
mutations?: MutationOptions;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Open the SSO
|
|
155
|
-
*/
|
|
156
|
-
declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
157
|
-
|
|
158
|
-
type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
|
|
159
|
-
interface UseGetProductInformationParams {
|
|
160
|
-
query?: QueryOptions;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Open the SSO
|
|
164
|
-
*/
|
|
165
|
-
declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): _tanstack_react_query.UseQueryResult<undefined, FrakRpcError<undefined>>;
|
|
166
|
-
|
|
167
|
-
export { NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, useDisplayModal, useGetProductInformation, useNexusClient, useNexusConfig, useOpenSso, useReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };
|
package/dist/react/index.d.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType, l as SendTransactionReturnType, i as SiweAuthenticateReturnType, D as DisplayModalParamsType, M as ModalStepTypes, e as ModalRpcStepsResultType, O as OpenSsoParamsType, G as GetProductInformationReturnType } from '../FrakContext-DjeuWC2U.js';
|
|
4
|
-
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
6
|
-
import * as viem from 'viem';
|
|
7
|
-
import { Hex } from 'viem';
|
|
8
|
-
import { F as FrakRpcError } from '../error-Dflr3G5x.js';
|
|
9
|
-
import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-CJI_Rc4K.js';
|
|
10
|
-
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.js';
|
|
11
|
-
import 'viem/chains';
|
|
12
|
-
import 'viem/siwe';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The context that will keep the Nexus Wallet SDK configuration
|
|
16
|
-
*/
|
|
17
|
-
declare const NexusConfigContext: react.Context<Readonly<{
|
|
18
|
-
walletUrl?: string;
|
|
19
|
-
metadata: {
|
|
20
|
-
name: string;
|
|
21
|
-
css?: string;
|
|
22
|
-
buttonShare?: string;
|
|
23
|
-
};
|
|
24
|
-
domain?: string;
|
|
25
|
-
}> | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
28
|
-
*/
|
|
29
|
-
type NexusConfigProviderProps = {
|
|
30
|
-
config: NexusWalletSdkConfig;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Simple config provider for the Nexus Wallet SDK
|
|
34
|
-
* @param parameters
|
|
35
|
-
* @constructor
|
|
36
|
-
*/
|
|
37
|
-
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
38
|
-
walletUrl?: string;
|
|
39
|
-
metadata: {
|
|
40
|
-
name: string;
|
|
41
|
-
css?: string;
|
|
42
|
-
buttonShare?: string;
|
|
43
|
-
};
|
|
44
|
-
domain?: string;
|
|
45
|
-
}> | undefined>>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The context that will keep the Nexus Wallet SDK client
|
|
49
|
-
*/
|
|
50
|
-
declare const NexusIFrameClientContext: react.Context<NexusClient | undefined>;
|
|
51
|
-
/**
|
|
52
|
-
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
53
|
-
*/
|
|
54
|
-
type NexusIFrameClientProps = {
|
|
55
|
-
config: NexusWalletSdkConfig;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* IFrame client provider for the Nexus Wallet SDK
|
|
59
|
-
* - Automatically set the config provider
|
|
60
|
-
* @param parameters
|
|
61
|
-
* @constructor
|
|
62
|
-
*/
|
|
63
|
-
declare function NexusIFrameClientProvider({ style, children, }: {
|
|
64
|
-
style?: CSSProperties;
|
|
65
|
-
children?: ReactNode;
|
|
66
|
-
}): react.FunctionComponentElement<{
|
|
67
|
-
children?: ReactNode | undefined;
|
|
68
|
-
}>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Use the current nexus config
|
|
72
|
-
*/
|
|
73
|
-
declare function useNexusConfig(): Readonly<{
|
|
74
|
-
walletUrl?: string;
|
|
75
|
-
metadata: {
|
|
76
|
-
name: string;
|
|
77
|
-
css?: string;
|
|
78
|
-
buttonShare?: string;
|
|
79
|
-
};
|
|
80
|
-
domain?: string;
|
|
81
|
-
}>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Use the current nexus iframe client
|
|
85
|
-
*/
|
|
86
|
-
declare function useNexusClient(): NexusClient | undefined;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Hooks used to listen to the current wallet status
|
|
90
|
-
*/
|
|
91
|
-
declare function useWalletStatus(): _tanstack_react_query.UseQueryResult<WalletStatusReturnType, Error>;
|
|
92
|
-
|
|
93
|
-
type MutationOptions$4 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
|
|
94
|
-
interface UseSendTransactionParams {
|
|
95
|
-
mutations?: MutationOptions$4;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Trigger a dashboard action to the wallet
|
|
99
|
-
*/
|
|
100
|
-
declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
101
|
-
hash: viem.Hex;
|
|
102
|
-
}>, FrakRpcError<undefined>, SendTransactionParams, unknown>;
|
|
103
|
-
|
|
104
|
-
type MutationOptions$3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
|
|
105
|
-
interface UseSiweAuthenticateParams {
|
|
106
|
-
mutations?: MutationOptions$3;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Trigger a dashboard action to the wallet
|
|
110
|
-
*/
|
|
111
|
-
declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
112
|
-
signature: viem.Hex;
|
|
113
|
-
message: string;
|
|
114
|
-
}>, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Helper hook to automatically submit a referral interaction when detected
|
|
118
|
-
* -> And automatically set the referral context in the url
|
|
119
|
-
* @param productId
|
|
120
|
-
* @param modalConfig
|
|
121
|
-
* @param options
|
|
122
|
-
*/
|
|
123
|
-
declare function useReferralInteraction({ productId, modalConfig, options, }?: {
|
|
124
|
-
productId?: Hex;
|
|
125
|
-
modalConfig?: DisplayModalParamsType<ModalStepTypes[]>;
|
|
126
|
-
options?: ProcessReferralOptions;
|
|
127
|
-
}): Error | ("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral");
|
|
128
|
-
|
|
129
|
-
type MutationOptions$2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
|
|
130
|
-
interface UseSendInteractionParams$1 {
|
|
131
|
-
mutations?: MutationOptions$2;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Send a user interaction
|
|
135
|
-
*/
|
|
136
|
-
declare function useSendInteraction({ mutations, }?: UseSendInteractionParams$1): _tanstack_react_query.UseMutationResult<Readonly<{
|
|
137
|
-
delegationId: string;
|
|
138
|
-
}>, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
|
|
139
|
-
|
|
140
|
-
type MutationOptions$1<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
|
|
141
|
-
interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
|
|
142
|
-
mutations?: MutationOptions$1<T>;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Send a user interaction
|
|
146
|
-
*/
|
|
147
|
-
declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): _tanstack_react_query.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
|
|
148
|
-
|
|
149
|
-
type MutationOptions = Omit<UseMutationOptions<void, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
|
|
150
|
-
interface UseSendInteractionParams {
|
|
151
|
-
mutations?: MutationOptions;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Open the SSO
|
|
155
|
-
*/
|
|
156
|
-
declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
157
|
-
|
|
158
|
-
type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
|
|
159
|
-
interface UseGetProductInformationParams {
|
|
160
|
-
query?: QueryOptions;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Open the SSO
|
|
164
|
-
*/
|
|
165
|
-
declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): _tanstack_react_query.UseQueryResult<undefined, FrakRpcError<undefined>>;
|
|
166
|
-
|
|
167
|
-
export { NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, useDisplayModal, useGetProductInformation, useNexusClient, useNexusConfig, useOpenSso, useReferralInteraction, useSendInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };
|
package/dist/react/index.js
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createIFrameNexusClient
|
|
3
|
-
} from "../chunk-YPQA63LW.js";
|
|
4
|
-
import {
|
|
5
|
-
displayModal,
|
|
6
|
-
getProductInformation,
|
|
7
|
-
openSso,
|
|
8
|
-
processReferral,
|
|
9
|
-
sendInteraction,
|
|
10
|
-
sendTransaction,
|
|
11
|
-
siweAuthenticate,
|
|
12
|
-
watchWalletStatus
|
|
13
|
-
} from "../chunk-4MMSQL44.js";
|
|
14
|
-
import {
|
|
15
|
-
ClientNotFound,
|
|
16
|
-
FrakContextManager,
|
|
17
|
-
FrakRpcError,
|
|
18
|
-
RpcErrorCodes,
|
|
19
|
-
baseIframeProps
|
|
20
|
-
} from "../chunk-2VNIEGOJ.js";
|
|
21
|
-
import "../chunk-FETGS7X7.js";
|
|
22
|
-
import "../chunk-BOGCLEPR.js";
|
|
23
|
-
|
|
24
|
-
// src/react/provider/NexusConfigProvider.ts
|
|
25
|
-
import { createContext, createElement } from "react";
|
|
26
|
-
var NexusConfigContext = createContext(void 0);
|
|
27
|
-
function NexusConfigProvider(parameters) {
|
|
28
|
-
const { children, config } = parameters;
|
|
29
|
-
return createElement(
|
|
30
|
-
NexusConfigContext.Provider,
|
|
31
|
-
{
|
|
32
|
-
value: {
|
|
33
|
-
...config,
|
|
34
|
-
walletUrl: config.walletUrl ?? "https://wallet.frak.id",
|
|
35
|
-
domain: config.domain ?? (typeof window !== "undefined" ? window?.location?.host : void 0) ?? "not-found"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
children
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/react/provider/NexusIFrameClientProvider.ts
|
|
43
|
-
import {
|
|
44
|
-
Fragment,
|
|
45
|
-
createContext as createContext2,
|
|
46
|
-
createElement as createElement2,
|
|
47
|
-
useState as useState3
|
|
48
|
-
} from "react";
|
|
49
|
-
|
|
50
|
-
// src/react/hook/useNexusConfig.ts
|
|
51
|
-
import { useContext } from "react";
|
|
52
|
-
function useNexusConfig() {
|
|
53
|
-
const config = useContext(NexusConfigContext);
|
|
54
|
-
if (!config) {
|
|
55
|
-
throw new FrakRpcError(
|
|
56
|
-
RpcErrorCodes.configError,
|
|
57
|
-
"Nexus config not found"
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return config;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/react/hook/useNexusClient.ts
|
|
64
|
-
import { useContext as useContext2 } from "react";
|
|
65
|
-
function useNexusClient() {
|
|
66
|
-
return useContext2(NexusIFrameClientContext);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/react/hook/useWalletStatus.ts
|
|
70
|
-
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
71
|
-
import { useCallback } from "react";
|
|
72
|
-
function useWalletStatus() {
|
|
73
|
-
const queryClient = useQueryClient();
|
|
74
|
-
const client = useNexusClient();
|
|
75
|
-
const newStatusUpdated = useCallback(
|
|
76
|
-
(event) => {
|
|
77
|
-
queryClient.setQueryData(
|
|
78
|
-
["nexus-sdk", "wallet-status-listener"],
|
|
79
|
-
event
|
|
80
|
-
);
|
|
81
|
-
},
|
|
82
|
-
[queryClient]
|
|
83
|
-
);
|
|
84
|
-
return useQuery({
|
|
85
|
-
gcTime: 0,
|
|
86
|
-
staleTime: 0,
|
|
87
|
-
queryKey: ["nexus-sdk", "wallet-status-listener"],
|
|
88
|
-
queryFn: async () => {
|
|
89
|
-
if (!client) {
|
|
90
|
-
throw new ClientNotFound();
|
|
91
|
-
}
|
|
92
|
-
return watchWalletStatus(client, newStatusUpdated);
|
|
93
|
-
},
|
|
94
|
-
enabled: !!client
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/react/hook/useSendTransaction.ts
|
|
99
|
-
import { useMutation } from "@tanstack/react-query";
|
|
100
|
-
function useSendTransactionAction({
|
|
101
|
-
mutations
|
|
102
|
-
} = {}) {
|
|
103
|
-
const client = useNexusClient();
|
|
104
|
-
return useMutation({
|
|
105
|
-
...mutations,
|
|
106
|
-
mutationKey: ["nexus-sdk", "send-transaction"],
|
|
107
|
-
mutationFn: async (params) => {
|
|
108
|
-
if (!client) {
|
|
109
|
-
throw new ClientNotFound();
|
|
110
|
-
}
|
|
111
|
-
return sendTransaction(client, params);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/react/hook/useSiweAuthenticate.ts
|
|
117
|
-
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
118
|
-
function useSiweAuthenticate({
|
|
119
|
-
mutations
|
|
120
|
-
} = {}) {
|
|
121
|
-
const client = useNexusClient();
|
|
122
|
-
return useMutation2({
|
|
123
|
-
...mutations,
|
|
124
|
-
mutationKey: [
|
|
125
|
-
"nexus-sdk",
|
|
126
|
-
"siwe-authenticate",
|
|
127
|
-
client?.config.domain ?? "no-domain"
|
|
128
|
-
],
|
|
129
|
-
mutationFn: async (params) => {
|
|
130
|
-
if (!client) {
|
|
131
|
-
throw new ClientNotFound();
|
|
132
|
-
}
|
|
133
|
-
return siweAuthenticate(client, params);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/react/hook/helper/useReferralInteraction.ts
|
|
139
|
-
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
140
|
-
import { useMemo as useMemo3 } from "react";
|
|
141
|
-
|
|
142
|
-
// src/react/hook/utils/useFrakContext.ts
|
|
143
|
-
import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
144
|
-
|
|
145
|
-
// src/react/hook/utils/useWindowLocation.ts
|
|
146
|
-
import { useEffect as useEffect2, useMemo, useState as useState2 } from "react";
|
|
147
|
-
|
|
148
|
-
// src/react/hook/utils/useMounted.ts
|
|
149
|
-
import { useEffect, useState } from "react";
|
|
150
|
-
function useMounted() {
|
|
151
|
-
const [mounted, setMounted] = useState(false);
|
|
152
|
-
useEffect(() => {
|
|
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] = useState2(
|
|
162
|
-
isMounted ? window.location : void 0
|
|
163
|
-
);
|
|
164
|
-
useEffect2(() => {
|
|
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 = useMemo(() => location?.href, [location?.href]);
|
|
178
|
-
return { location, href };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// src/react/hook/utils/useFrakContext.ts
|
|
182
|
-
function useFrakContext() {
|
|
183
|
-
const { location } = useWindowLocation();
|
|
184
|
-
const frakContext = useMemo2(() => {
|
|
185
|
-
if (!location?.href) return null;
|
|
186
|
-
return FrakContextManager.parse({ url: location.href });
|
|
187
|
-
}, [location?.href]);
|
|
188
|
-
const updateContext = useCallback2(
|
|
189
|
-
(newContext) => {
|
|
190
|
-
console.log("Updating context", { newContext });
|
|
191
|
-
FrakContextManager.replaceUrl({
|
|
192
|
-
url: location?.href,
|
|
193
|
-
context: newContext
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
[location?.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
|
-
} = useQuery2({
|
|
218
|
-
gcTime: 0,
|
|
219
|
-
staleTime: 0,
|
|
220
|
-
queryKey: [
|
|
221
|
-
"nexus-sdk",
|
|
222
|
-
"auto-referral-interaction",
|
|
223
|
-
frakContext?.r ?? "no-referrer",
|
|
224
|
-
walletStatus?.key ?? "no-wallet-status",
|
|
225
|
-
productId ?? "no-product-id"
|
|
226
|
-
],
|
|
227
|
-
queryFn: () => {
|
|
228
|
-
if (!client) {
|
|
229
|
-
throw new ClientNotFound();
|
|
230
|
-
}
|
|
231
|
-
return processReferral(client, {
|
|
232
|
-
walletStatus,
|
|
233
|
-
frakContext,
|
|
234
|
-
modalConfig,
|
|
235
|
-
productId,
|
|
236
|
-
options
|
|
237
|
-
});
|
|
238
|
-
},
|
|
239
|
-
enabled: !!walletStatus
|
|
240
|
-
});
|
|
241
|
-
return useMemo3(() => {
|
|
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
|
-
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
250
|
-
function useSendInteraction({
|
|
251
|
-
mutations
|
|
252
|
-
} = {}) {
|
|
253
|
-
const client = useNexusClient();
|
|
254
|
-
return useMutation3({
|
|
255
|
-
...mutations,
|
|
256
|
-
mutationKey: ["nexus-sdk", "send-interaction"],
|
|
257
|
-
mutationFn: async (params) => {
|
|
258
|
-
if (!client) {
|
|
259
|
-
throw new ClientNotFound();
|
|
260
|
-
}
|
|
261
|
-
return sendInteraction(client, params);
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// src/react/hook/useDisplayModal.ts
|
|
267
|
-
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
268
|
-
function useDisplayModal({
|
|
269
|
-
mutations
|
|
270
|
-
} = {}) {
|
|
271
|
-
const client = useNexusClient();
|
|
272
|
-
return useMutation4({
|
|
273
|
-
...mutations,
|
|
274
|
-
mutationKey: ["nexus-sdk", "display-modal"],
|
|
275
|
-
mutationFn: async (args) => {
|
|
276
|
-
if (!client) {
|
|
277
|
-
throw new ClientNotFound();
|
|
278
|
-
}
|
|
279
|
-
return displayModal(client, args);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/react/hook/useOpenSso.ts
|
|
285
|
-
import { useMutation as useMutation5 } from "@tanstack/react-query";
|
|
286
|
-
function useOpenSso({ mutations } = {}) {
|
|
287
|
-
const client = useNexusClient();
|
|
288
|
-
return useMutation5({
|
|
289
|
-
...mutations,
|
|
290
|
-
mutationKey: ["nexus-sdk", "open-sso"],
|
|
291
|
-
mutationFn: async (params) => {
|
|
292
|
-
if (!client) {
|
|
293
|
-
throw new ClientNotFound();
|
|
294
|
-
}
|
|
295
|
-
return openSso(client, params);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/react/hook/useGetProductInformation.ts
|
|
301
|
-
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
302
|
-
function useGetProductInformation({
|
|
303
|
-
query
|
|
304
|
-
} = {}) {
|
|
305
|
-
const client = useNexusClient();
|
|
306
|
-
return useQuery3({
|
|
307
|
-
...query,
|
|
308
|
-
queryKey: ["nexus-sdk", "get-product-information"],
|
|
309
|
-
queryFn: async () => {
|
|
310
|
-
if (!client) {
|
|
311
|
-
throw new ClientNotFound();
|
|
312
|
-
}
|
|
313
|
-
return getProductInformation(client);
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// src/react/provider/NexusIFrameClientProvider.ts
|
|
319
|
-
var NexusIFrameClientContext = createContext2(
|
|
320
|
-
void 0
|
|
321
|
-
);
|
|
322
|
-
function NexusIFrameClientProvider({
|
|
323
|
-
style,
|
|
324
|
-
children
|
|
325
|
-
}) {
|
|
326
|
-
const config = useNexusConfig();
|
|
327
|
-
const [client, setClient] = useState3(void 0);
|
|
328
|
-
const iFrame = createElement2("iframe", {
|
|
329
|
-
...baseIframeProps,
|
|
330
|
-
src: `${config.walletUrl}/listener`,
|
|
331
|
-
style: style ?? baseIframeProps.style,
|
|
332
|
-
ref: (iframe) => {
|
|
333
|
-
if (!iframe || client) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
setClient(
|
|
337
|
-
createIFrameNexusClient({
|
|
338
|
-
iframe,
|
|
339
|
-
config
|
|
340
|
-
})
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
const providerComponent = createElement2(
|
|
345
|
-
NexusIFrameClientContext.Provider,
|
|
346
|
-
{ value: client },
|
|
347
|
-
children
|
|
348
|
-
);
|
|
349
|
-
return createElement2(Fragment, null, iFrame, providerComponent);
|
|
350
|
-
}
|
|
351
|
-
export {
|
|
352
|
-
NexusConfigContext,
|
|
353
|
-
NexusConfigProvider,
|
|
354
|
-
NexusIFrameClientContext,
|
|
355
|
-
NexusIFrameClientProvider,
|
|
356
|
-
useDisplayModal,
|
|
357
|
-
useGetProductInformation,
|
|
358
|
-
useNexusClient,
|
|
359
|
-
useNexusConfig,
|
|
360
|
-
useOpenSso,
|
|
361
|
-
useReferralInteraction,
|
|
362
|
-
useSendInteraction,
|
|
363
|
-
useSendTransactionAction,
|
|
364
|
-
useSiweAuthenticate,
|
|
365
|
-
useWalletStatus
|
|
366
|
-
};
|