@frak-labs/nexus-sdk 0.0.22 → 0.0.24
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/{FrakContext-DBdWC7ls.d.cts → FrakContext-DKSVaeVb.d.cts} +62 -3
- package/dist/{FrakContext-CDVlUN75.d.ts → FrakContext-DjeuWC2U.d.ts} +62 -3
- package/dist/bundle/bundle.js +5 -5
- package/dist/{chunk-ZQSA2VQ4.js → chunk-2VNIEGOJ.js} +10 -6
- package/dist/{chunk-Q3SIIAX2.js → chunk-4MMSQL44.js} +147 -28
- package/dist/{chunk-4OJ2NPAS.cjs → chunk-4PVF24BB.cjs} +15 -15
- package/dist/{chunk-H3T2GAEC.js → chunk-BOGCLEPR.js} +2 -1
- package/dist/chunk-DE2KWQVP.cjs +351 -0
- package/dist/{chunk-P4QEVLVV.js → chunk-FETGS7X7.js} +1 -1
- package/dist/{chunk-F3F4BCGV.cjs → chunk-H4BK3CNV.cjs} +20 -16
- package/dist/{chunk-QSXZKZJA.cjs → chunk-P3J2BIUT.cjs} +2 -1
- package/dist/{chunk-QYOOKB34.cjs → chunk-QLM5NFMZ.cjs} +22 -22
- package/dist/{chunk-VVF4NKYR.js → chunk-YPQA63LW.js} +2 -2
- package/dist/core/actions/index.cjs +9 -5
- package/dist/core/actions/index.d.cts +51 -6
- package/dist/core/actions/index.d.ts +51 -6
- package/dist/core/actions/index.js +10 -6
- package/dist/core/index.cjs +4 -4
- package/dist/core/index.d.cts +13 -25
- package/dist/core/index.d.ts +13 -25
- package/dist/core/index.js +3 -3
- package/dist/core/interactions/index.cjs +3 -3
- package/dist/core/interactions/index.js +2 -2
- package/dist/{processReferral-CFyGAENf.d.ts → processReferral-CJI_Rc4K.d.ts} +1 -1
- package/dist/{processReferral-BWSIamn2.d.cts → processReferral-DUP8imQV.d.cts} +1 -1
- package/dist/react/index.cjs +52 -31
- package/dist/react/index.d.cts +20 -13
- package/dist/react/index.d.ts +20 -13
- package/dist/react/index.js +32 -11
- package/package.json +42 -19
- package/dist/chunk-4CWA7EWX.cjs +0 -232
package/dist/react/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType,
|
|
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
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { UseMutationOptions } from '@tanstack/react-query';
|
|
5
|
+
import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
6
6
|
import * as viem from 'viem';
|
|
7
7
|
import { Hex } from 'viem';
|
|
8
8
|
import { F as FrakRpcError } from '../error-Dflr3G5x.cjs';
|
|
9
|
-
import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-
|
|
9
|
+
import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-DUP8imQV.cjs';
|
|
10
10
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.cjs';
|
|
11
11
|
import 'viem/chains';
|
|
12
12
|
import 'viem/siwe';
|
|
@@ -15,21 +15,19 @@ import 'viem/siwe';
|
|
|
15
15
|
* The context that will keep the Nexus Wallet SDK configuration
|
|
16
16
|
*/
|
|
17
17
|
declare const NexusConfigContext: react.Context<Readonly<{
|
|
18
|
-
walletUrl
|
|
18
|
+
walletUrl?: string;
|
|
19
19
|
metadata: {
|
|
20
20
|
name: string;
|
|
21
21
|
css?: string;
|
|
22
22
|
buttonShare?: string;
|
|
23
23
|
};
|
|
24
|
-
domain
|
|
24
|
+
domain?: string;
|
|
25
25
|
}> | undefined>;
|
|
26
26
|
/**
|
|
27
27
|
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
28
28
|
*/
|
|
29
29
|
type NexusConfigProviderProps = {
|
|
30
|
-
config:
|
|
31
|
-
domain?: string;
|
|
32
|
-
};
|
|
30
|
+
config: NexusWalletSdkConfig;
|
|
33
31
|
};
|
|
34
32
|
/**
|
|
35
33
|
* Simple config provider for the Nexus Wallet SDK
|
|
@@ -37,13 +35,13 @@ type NexusConfigProviderProps = {
|
|
|
37
35
|
* @constructor
|
|
38
36
|
*/
|
|
39
37
|
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
40
|
-
walletUrl
|
|
38
|
+
walletUrl?: string;
|
|
41
39
|
metadata: {
|
|
42
40
|
name: string;
|
|
43
41
|
css?: string;
|
|
44
42
|
buttonShare?: string;
|
|
45
43
|
};
|
|
46
|
-
domain
|
|
44
|
+
domain?: string;
|
|
47
45
|
}> | undefined>>;
|
|
48
46
|
|
|
49
47
|
/**
|
|
@@ -73,13 +71,13 @@ declare function NexusIFrameClientProvider({ style, children, }: {
|
|
|
73
71
|
* Use the current nexus config
|
|
74
72
|
*/
|
|
75
73
|
declare function useNexusConfig(): Readonly<{
|
|
76
|
-
walletUrl
|
|
74
|
+
walletUrl?: string;
|
|
77
75
|
metadata: {
|
|
78
76
|
name: string;
|
|
79
77
|
css?: string;
|
|
80
78
|
buttonShare?: string;
|
|
81
79
|
};
|
|
82
|
-
domain
|
|
80
|
+
domain?: string;
|
|
83
81
|
}>;
|
|
84
82
|
|
|
85
83
|
/**
|
|
@@ -157,4 +155,13 @@ interface UseSendInteractionParams {
|
|
|
157
155
|
*/
|
|
158
156
|
declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
159
157
|
|
|
160
|
-
|
|
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
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { N as NexusWalletSdkConfig, a as NexusClient, W as WalletStatusReturnType,
|
|
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
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { UseMutationOptions } from '@tanstack/react-query';
|
|
5
|
+
import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
|
|
6
6
|
import * as viem from 'viem';
|
|
7
7
|
import { Hex } from 'viem';
|
|
8
8
|
import { F as FrakRpcError } from '../error-Dflr3G5x.js';
|
|
9
|
-
import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-
|
|
9
|
+
import { S as SendTransactionParams, a as SiweAuthenticateModalParams, P as ProcessReferralOptions } from '../processReferral-CJI_Rc4K.js';
|
|
10
10
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-BngPoHA0.js';
|
|
11
11
|
import 'viem/chains';
|
|
12
12
|
import 'viem/siwe';
|
|
@@ -15,21 +15,19 @@ import 'viem/siwe';
|
|
|
15
15
|
* The context that will keep the Nexus Wallet SDK configuration
|
|
16
16
|
*/
|
|
17
17
|
declare const NexusConfigContext: react.Context<Readonly<{
|
|
18
|
-
walletUrl
|
|
18
|
+
walletUrl?: string;
|
|
19
19
|
metadata: {
|
|
20
20
|
name: string;
|
|
21
21
|
css?: string;
|
|
22
22
|
buttonShare?: string;
|
|
23
23
|
};
|
|
24
|
-
domain
|
|
24
|
+
domain?: string;
|
|
25
25
|
}> | undefined>;
|
|
26
26
|
/**
|
|
27
27
|
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
28
28
|
*/
|
|
29
29
|
type NexusConfigProviderProps = {
|
|
30
|
-
config:
|
|
31
|
-
domain?: string;
|
|
32
|
-
};
|
|
30
|
+
config: NexusWalletSdkConfig;
|
|
33
31
|
};
|
|
34
32
|
/**
|
|
35
33
|
* Simple config provider for the Nexus Wallet SDK
|
|
@@ -37,13 +35,13 @@ type NexusConfigProviderProps = {
|
|
|
37
35
|
* @constructor
|
|
38
36
|
*/
|
|
39
37
|
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
40
|
-
walletUrl
|
|
38
|
+
walletUrl?: string;
|
|
41
39
|
metadata: {
|
|
42
40
|
name: string;
|
|
43
41
|
css?: string;
|
|
44
42
|
buttonShare?: string;
|
|
45
43
|
};
|
|
46
|
-
domain
|
|
44
|
+
domain?: string;
|
|
47
45
|
}> | undefined>>;
|
|
48
46
|
|
|
49
47
|
/**
|
|
@@ -73,13 +71,13 @@ declare function NexusIFrameClientProvider({ style, children, }: {
|
|
|
73
71
|
* Use the current nexus config
|
|
74
72
|
*/
|
|
75
73
|
declare function useNexusConfig(): Readonly<{
|
|
76
|
-
walletUrl
|
|
74
|
+
walletUrl?: string;
|
|
77
75
|
metadata: {
|
|
78
76
|
name: string;
|
|
79
77
|
css?: string;
|
|
80
78
|
buttonShare?: string;
|
|
81
79
|
};
|
|
82
|
-
domain
|
|
80
|
+
domain?: string;
|
|
83
81
|
}>;
|
|
84
82
|
|
|
85
83
|
/**
|
|
@@ -157,4 +155,13 @@ interface UseSendInteractionParams {
|
|
|
157
155
|
*/
|
|
158
156
|
declare function useOpenSso({ mutations }?: UseSendInteractionParams): _tanstack_react_query.UseMutationResult<void, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
|
|
159
157
|
|
|
160
|
-
|
|
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
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createIFrameNexusClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-YPQA63LW.js";
|
|
4
4
|
import {
|
|
5
5
|
displayModal,
|
|
6
|
+
getProductInformation,
|
|
6
7
|
openSso,
|
|
7
8
|
processReferral,
|
|
8
9
|
sendInteraction,
|
|
9
10
|
sendTransaction,
|
|
10
11
|
siweAuthenticate,
|
|
11
|
-
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
watchWalletStatus
|
|
13
|
+
} from "../chunk-4MMSQL44.js";
|
|
13
14
|
import {
|
|
14
15
|
ClientNotFound,
|
|
15
16
|
FrakContextManager,
|
|
16
17
|
FrakRpcError,
|
|
17
18
|
RpcErrorCodes,
|
|
18
19
|
baseIframeProps
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import "../chunk-
|
|
20
|
+
} from "../chunk-2VNIEGOJ.js";
|
|
21
|
+
import "../chunk-FETGS7X7.js";
|
|
22
|
+
import "../chunk-BOGCLEPR.js";
|
|
22
23
|
|
|
23
24
|
// src/react/provider/NexusConfigProvider.ts
|
|
24
25
|
import { createContext, createElement } from "react";
|
|
@@ -30,6 +31,7 @@ function NexusConfigProvider(parameters) {
|
|
|
30
31
|
{
|
|
31
32
|
value: {
|
|
32
33
|
...config,
|
|
34
|
+
walletUrl: config.walletUrl ?? "https://wallet.frak.id",
|
|
33
35
|
domain: config.domain ?? (typeof window !== "undefined" ? window?.location?.host : void 0) ?? "not-found"
|
|
34
36
|
}
|
|
35
37
|
},
|
|
@@ -87,7 +89,7 @@ function useWalletStatus() {
|
|
|
87
89
|
if (!client) {
|
|
88
90
|
throw new ClientNotFound();
|
|
89
91
|
}
|
|
90
|
-
return
|
|
92
|
+
return watchWalletStatus(client, newStatusUpdated);
|
|
91
93
|
},
|
|
92
94
|
enabled: !!client
|
|
93
95
|
});
|
|
@@ -207,7 +209,7 @@ function useReferralInteraction({
|
|
|
207
209
|
} = {}) {
|
|
208
210
|
const client = useNexusClient();
|
|
209
211
|
const { frakContext } = useFrakContext();
|
|
210
|
-
const { data:
|
|
212
|
+
const { data: walletStatus } = useWalletStatus();
|
|
211
213
|
const {
|
|
212
214
|
data: referralState,
|
|
213
215
|
error,
|
|
@@ -219,7 +221,7 @@ function useReferralInteraction({
|
|
|
219
221
|
"nexus-sdk",
|
|
220
222
|
"auto-referral-interaction",
|
|
221
223
|
frakContext?.r ?? "no-referrer",
|
|
222
|
-
|
|
224
|
+
walletStatus?.key ?? "no-wallet-status",
|
|
223
225
|
productId ?? "no-product-id"
|
|
224
226
|
],
|
|
225
227
|
queryFn: () => {
|
|
@@ -227,14 +229,14 @@ function useReferralInteraction({
|
|
|
227
229
|
throw new ClientNotFound();
|
|
228
230
|
}
|
|
229
231
|
return processReferral(client, {
|
|
230
|
-
walletStatus
|
|
232
|
+
walletStatus,
|
|
231
233
|
frakContext,
|
|
232
234
|
modalConfig,
|
|
233
235
|
productId,
|
|
234
236
|
options
|
|
235
237
|
});
|
|
236
238
|
},
|
|
237
|
-
enabled: !!
|
|
239
|
+
enabled: !!walletStatus
|
|
238
240
|
});
|
|
239
241
|
return useMemo3(() => {
|
|
240
242
|
if (status === "pending") return "processing";
|
|
@@ -295,6 +297,24 @@ function useOpenSso({ mutations } = {}) {
|
|
|
295
297
|
});
|
|
296
298
|
}
|
|
297
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
|
+
|
|
298
318
|
// src/react/provider/NexusIFrameClientProvider.ts
|
|
299
319
|
var NexusIFrameClientContext = createContext2(
|
|
300
320
|
void 0
|
|
@@ -334,6 +354,7 @@ export {
|
|
|
334
354
|
NexusIFrameClientContext,
|
|
335
355
|
NexusIFrameClientProvider,
|
|
336
356
|
useDisplayModal,
|
|
357
|
+
useGetProductInformation,
|
|
337
358
|
useNexusClient,
|
|
338
359
|
useNexusConfig,
|
|
339
360
|
useOpenSso,
|
package/package.json
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.24",
|
|
15
15
|
"description": "Frak Wallet client SDK, helping any person to interact with the Frak wallet, and require the unlock of a premium article within the Frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
18
18
|
"directory": "packages/sdk"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://docs.frak.id/wallet-sdk",
|
|
20
|
+
"homepage": "https://docs.frak.id/wallet-sdk/overview",
|
|
21
21
|
"keywords": [
|
|
22
22
|
"frak-labs",
|
|
23
23
|
"nexus-wallet",
|
|
@@ -34,24 +34,44 @@
|
|
|
34
34
|
],
|
|
35
35
|
"exports": {
|
|
36
36
|
"./core": {
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./dist/core/index.d.ts",
|
|
39
|
+
"default": "./dist/core/index.js"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/core/index.d.cts",
|
|
43
|
+
"default": "./dist/core/index.cjs"
|
|
44
|
+
}
|
|
40
45
|
},
|
|
41
46
|
"./actions": {
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./dist/core/actions/index.d.ts",
|
|
49
|
+
"default": "./dist/core/actions/index.js"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/core/actions/index.d.cts",
|
|
53
|
+
"default": "./dist/core/actions/index.cjs"
|
|
54
|
+
}
|
|
45
55
|
},
|
|
46
56
|
"./interactions": {
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./dist/core/interactions/index.d.ts",
|
|
59
|
+
"default": "./dist/core/interactions/index.js"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/core/interactions/index.d.cts",
|
|
63
|
+
"default": "./dist/core/interactions/index.cjs"
|
|
64
|
+
}
|
|
50
65
|
},
|
|
51
66
|
"./react": {
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
"import": {
|
|
68
|
+
"types": "./dist/react/index.d.ts",
|
|
69
|
+
"default": "./dist/react/index.js"
|
|
70
|
+
},
|
|
71
|
+
"require": {
|
|
72
|
+
"types": "./dist/react/index.d.cts",
|
|
73
|
+
"default": "./dist/react/index.cjs"
|
|
74
|
+
}
|
|
55
75
|
}
|
|
56
76
|
},
|
|
57
77
|
"scripts": {
|
|
@@ -59,8 +79,9 @@
|
|
|
59
79
|
"format:check": "biome check .",
|
|
60
80
|
"format": "biome check --write .",
|
|
61
81
|
"clean": "rimraf dist",
|
|
62
|
-
"build": "tsup",
|
|
63
|
-
"build:watch": "tsup --watch"
|
|
82
|
+
"build": "tsup && bun run check-exports",
|
|
83
|
+
"build:watch": "tsup --watch",
|
|
84
|
+
"check-exports": "attw --pack --profile node16 ."
|
|
64
85
|
},
|
|
65
86
|
"peerDependencies": {
|
|
66
87
|
"viem": "^2.x",
|
|
@@ -72,9 +93,11 @@
|
|
|
72
93
|
"js-sha256": "^0.11.0"
|
|
73
94
|
},
|
|
74
95
|
"devDependencies": {
|
|
75
|
-
"@
|
|
96
|
+
"@arethetypeswrong/cli": "^0.17.1",
|
|
97
|
+
"@tanstack/react-query": ">=5.62.3",
|
|
76
98
|
"@types/node": "^22",
|
|
77
|
-
"
|
|
99
|
+
"@types/react": ">=18",
|
|
100
|
+
"tsup": "^8.3.5",
|
|
78
101
|
"typescript": "^5"
|
|
79
102
|
}
|
|
80
|
-
}
|
|
103
|
+
}
|
package/dist/chunk-4CWA7EWX.cjs
DELETED
|
@@ -1,232 +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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkF3F4BCGVcjs = require('./chunk-F3F4BCGV.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk4OJ2NPAScjs = require('./chunk-4OJ2NPAS.cjs');
|
|
10
|
-
|
|
11
|
-
// src/core/actions/watchWalletStatus.ts
|
|
12
|
-
function watchWalletStatus(client, callback) {
|
|
13
|
-
return client.listenerRequest(
|
|
14
|
-
{
|
|
15
|
-
method: "frak_listenToWalletStatus"
|
|
16
|
-
},
|
|
17
|
-
callback
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/core/utils/computeProductId.ts
|
|
22
|
-
var _viem = require('viem');
|
|
23
|
-
function computeProductId({ domain }) {
|
|
24
|
-
return _viem.keccak256.call(void 0, _viem.toHex.call(void 0, domain));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/core/actions/sendInteraction.ts
|
|
28
|
-
async function sendInteraction(client, { productId, interaction, validation }) {
|
|
29
|
-
const pId = _nullishCoalesce(productId, () => ( computeProductId(client.config)));
|
|
30
|
-
return await client.request({
|
|
31
|
-
method: "frak_sendInteraction",
|
|
32
|
-
params: [pId, interaction, validation]
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// src/core/actions/displayModal.ts
|
|
37
|
-
async function displayModal(client, { steps, metadata }) {
|
|
38
|
-
return await client.request({
|
|
39
|
-
method: "frak_displayModal",
|
|
40
|
-
params: [steps, client.config.metadata.name, metadata]
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/core/actions/openSso.ts
|
|
45
|
-
async function openSso(client, args) {
|
|
46
|
-
const { metadata } = client.config;
|
|
47
|
-
await client.request({
|
|
48
|
-
method: "frak_sso",
|
|
49
|
-
params: [args, metadata.name, metadata.css]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/core/actions/wrapper/siweAuthenticate.ts
|
|
54
|
-
var _siwe = require('viem/siwe');
|
|
55
|
-
async function siweAuthenticate(client, { siwe, metadata }) {
|
|
56
|
-
const realStatement = _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _ => _.statement]), () => ( `I confirm that I want to use my Frak wallet on: ${client.config.metadata.name}`));
|
|
57
|
-
const builtSiwe = {
|
|
58
|
-
...siwe,
|
|
59
|
-
statement: realStatement,
|
|
60
|
-
nonce: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _2 => _2.nonce]), () => ( _siwe.generateSiweNonce.call(void 0, ))),
|
|
61
|
-
uri: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _3 => _3.uri]), () => ( `https://${client.config.domain}`)),
|
|
62
|
-
version: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _4 => _4.version]), () => ( "1")),
|
|
63
|
-
domain: client.config.domain
|
|
64
|
-
};
|
|
65
|
-
const result = await displayModal(client, {
|
|
66
|
-
metadata,
|
|
67
|
-
steps: {
|
|
68
|
-
login: {},
|
|
69
|
-
siweAuthenticate: {
|
|
70
|
-
siwe: builtSiwe
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return result.siweAuthenticate;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// src/core/actions/wrapper/sendTransaction.ts
|
|
78
|
-
async function sendTransaction(client, { tx, metadata }) {
|
|
79
|
-
const result = await displayModal(client, {
|
|
80
|
-
metadata,
|
|
81
|
-
steps: {
|
|
82
|
-
login: {},
|
|
83
|
-
sendTransaction: { tx }
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
return result.sendTransaction;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// src/core/actions/wrapper/walletStatus.ts
|
|
90
|
-
async function walletStatus(client, callback) {
|
|
91
|
-
const firstResult = new (0, _chunkF3F4BCGVcjs.Deferred)();
|
|
92
|
-
let hasResolved = false;
|
|
93
|
-
await watchWalletStatus(client, (status) => {
|
|
94
|
-
_optionalChain([callback, 'optionalCall', _5 => _5(status)]);
|
|
95
|
-
if (!hasResolved) {
|
|
96
|
-
firstResult.resolve(status);
|
|
97
|
-
hasResolved = true;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return firstResult.promise;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/core/actions/referral/processReferral.ts
|
|
104
|
-
|
|
105
|
-
async function processReferral(client, {
|
|
106
|
-
walletStatus: walletStatus2,
|
|
107
|
-
frakContext,
|
|
108
|
-
modalConfig,
|
|
109
|
-
productId,
|
|
110
|
-
options
|
|
111
|
-
}) {
|
|
112
|
-
let walletRequest = false;
|
|
113
|
-
async function getFreshWalletStatus() {
|
|
114
|
-
if (walletRequest) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
walletRequest = true;
|
|
118
|
-
return ensureWalletConnected(client, {
|
|
119
|
-
modalConfig,
|
|
120
|
-
walletStatus: walletStatus2
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
async function pushReferralInteraction(referrer) {
|
|
124
|
-
const interaction = _chunk4OJ2NPAScjs.ReferralInteractionEncoder.referred({
|
|
125
|
-
referrer
|
|
126
|
-
});
|
|
127
|
-
await sendInteraction(client, { productId, interaction });
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
const { status, currentWallet } = await processReferralLogic({
|
|
131
|
-
initialWalletStatus: walletStatus2,
|
|
132
|
-
getFreshWalletStatus,
|
|
133
|
-
pushReferralInteraction,
|
|
134
|
-
frakContext
|
|
135
|
-
});
|
|
136
|
-
_chunkF3F4BCGVcjs.FrakContextManager.replaceUrl({
|
|
137
|
-
url: _optionalChain([window, 'access', _6 => _6.location, 'optionalAccess', _7 => _7.href]),
|
|
138
|
-
context: _optionalChain([options, 'optionalAccess', _8 => _8.alwaysAppendUrl]) ? { r: currentWallet } : null
|
|
139
|
-
});
|
|
140
|
-
return status;
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.log("Error processing referral", { error });
|
|
143
|
-
_chunkF3F4BCGVcjs.FrakContextManager.replaceUrl({
|
|
144
|
-
url: _optionalChain([window, 'access', _9 => _9.location, 'optionalAccess', _10 => _10.href]),
|
|
145
|
-
context: _optionalChain([options, 'optionalAccess', _11 => _11.alwaysAppendUrl]) ? { r: _optionalChain([walletStatus2, 'optionalAccess', _12 => _12.wallet]) } : null
|
|
146
|
-
});
|
|
147
|
-
return mapErrorToState(error);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async function processReferralLogic({
|
|
151
|
-
initialWalletStatus,
|
|
152
|
-
getFreshWalletStatus,
|
|
153
|
-
pushReferralInteraction,
|
|
154
|
-
frakContext
|
|
155
|
-
}) {
|
|
156
|
-
let currentWallet = _optionalChain([initialWalletStatus, 'optionalAccess', _13 => _13.wallet]);
|
|
157
|
-
if (!_optionalChain([frakContext, 'optionalAccess', _14 => _14.r])) {
|
|
158
|
-
return { status: "no-referrer", currentWallet };
|
|
159
|
-
}
|
|
160
|
-
if (!currentWallet) {
|
|
161
|
-
currentWallet = await getFreshWalletStatus();
|
|
162
|
-
}
|
|
163
|
-
if (currentWallet && _viem.isAddressEqual.call(void 0, frakContext.r, currentWallet)) {
|
|
164
|
-
return { status: "self-referral", currentWallet };
|
|
165
|
-
}
|
|
166
|
-
if (!_optionalChain([initialWalletStatus, 'optionalAccess', _15 => _15.interactionSession])) {
|
|
167
|
-
currentWallet = await getFreshWalletStatus();
|
|
168
|
-
}
|
|
169
|
-
await pushReferralInteraction(frakContext.r);
|
|
170
|
-
return { status: "success", currentWallet };
|
|
171
|
-
}
|
|
172
|
-
async function ensureWalletConnected(client, {
|
|
173
|
-
modalConfig,
|
|
174
|
-
walletStatus: walletStatus2
|
|
175
|
-
}) {
|
|
176
|
-
if (!_optionalChain([walletStatus2, 'optionalAccess', _16 => _16.interactionSession])) {
|
|
177
|
-
if (!modalConfig) {
|
|
178
|
-
return void 0;
|
|
179
|
-
}
|
|
180
|
-
const result = await displayModal(client, modalConfig);
|
|
181
|
-
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _17 => _17.login, 'optionalAccess', _18 => _18.wallet]), () => ( void 0));
|
|
182
|
-
}
|
|
183
|
-
return _nullishCoalesce(walletStatus2.wallet, () => ( void 0));
|
|
184
|
-
}
|
|
185
|
-
function mapErrorToState(error) {
|
|
186
|
-
if (error instanceof _chunkF3F4BCGVcjs.FrakRpcError) {
|
|
187
|
-
switch (error.code) {
|
|
188
|
-
case _chunkF3F4BCGVcjs.RpcErrorCodes.walletNotConnected:
|
|
189
|
-
return "no-wallet";
|
|
190
|
-
case _chunkF3F4BCGVcjs.RpcErrorCodes.serverErrorForInteractionDelegation:
|
|
191
|
-
return "no-session";
|
|
192
|
-
default:
|
|
193
|
-
return "error";
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return "error";
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// src/core/actions/referral/referralInteraction.ts
|
|
200
|
-
async function referralInteraction(client, {
|
|
201
|
-
productId,
|
|
202
|
-
modalConfig,
|
|
203
|
-
options
|
|
204
|
-
} = {}) {
|
|
205
|
-
const frakContext = _chunkF3F4BCGVcjs.FrakContextManager.parse({
|
|
206
|
-
url: window.location.href
|
|
207
|
-
});
|
|
208
|
-
const currentWalletStatus = await walletStatus(client);
|
|
209
|
-
try {
|
|
210
|
-
return await processReferral(client, {
|
|
211
|
-
walletStatus: currentWalletStatus,
|
|
212
|
-
frakContext,
|
|
213
|
-
modalConfig,
|
|
214
|
-
productId,
|
|
215
|
-
options
|
|
216
|
-
});
|
|
217
|
-
} catch (error) {
|
|
218
|
-
return error;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
exports.watchWalletStatus = watchWalletStatus; exports.sendInteraction = sendInteraction; exports.displayModal = displayModal; exports.openSso = openSso; exports.siweAuthenticate = siweAuthenticate; exports.sendTransaction = sendTransaction; exports.walletStatus = walletStatus; exports.processReferral = processReferral; exports.referralInteraction = referralInteraction;
|