@frak-labs/nexus-sdk 0.0.7 → 0.0.8
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 +7 -6
- package/dist/{chunk-DI2REDPX.js → chunk-4VFMYMTH.js} +5 -9
- package/dist/{chunk-3LF3FGI6.cjs → chunk-6V4UCVTD.cjs} +5 -9
- package/dist/{client-DWLJ8zR-.d.cts → client-MgLVRfPw.d.cts} +4 -3
- package/dist/{client-DWLJ8zR-.d.ts → client-MgLVRfPw.d.ts} +4 -3
- package/dist/core/actions/index.cjs +2 -2
- package/dist/core/actions/index.d.cts +3 -3
- package/dist/core/actions/index.d.ts +3 -3
- package/dist/core/actions/index.js +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/react/index.cjs +34 -13
- package/dist/react/index.d.cts +14 -10
- package/dist/react/index.d.ts +14 -10
- package/dist/react/index.js +33 -12
- package/dist/{watchUnlockStatus--7dFtOJr.d.ts → watchUnlockStatus-DQYfUj46.d.ts} +8 -3
- package/dist/{watchUnlockStatus-B4kRztOM.d.cts → watchUnlockStatus-DqWkImYK.d.cts} +8 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Nexus Wallet SDK
|
|
2
2
|
|
|
3
|
-
This SDK help any dApps, or gated content provider, use the [Nexus Wallet](https://
|
|
3
|
+
This SDK help any dApps, or gated content provider, use the [Nexus Wallet](https://nexus.frak.id/) as a regular wallet, with smoother UX for your end-users (pay for his gas fees, check the paywall options, track his consumption etc.)
|
|
4
4
|
|
|
5
5
|
Checkout our documentation for more informations about the usage:
|
|
6
6
|
- [React client usage](https://docs.frak.id/wallet-sdk/how-to/client-react)
|
|
@@ -29,11 +29,12 @@ import type { NexusClient, NexusWalletSdkConfig } from "@frak-labs/nexus-sdk/cor
|
|
|
29
29
|
// Create the config for the Nexus Wallet SDK
|
|
30
30
|
export const nexusConfig: NexusWalletSdkConfig = {
|
|
31
31
|
// The current url for the wallet sdk
|
|
32
|
-
walletUrl: "https://
|
|
33
|
-
// The
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
walletUrl: "https://nexus-dev.frak.id",
|
|
33
|
+
// The name of your dapp
|
|
34
|
+
metadata: {
|
|
35
|
+
// Your app name
|
|
36
|
+
name: string,
|
|
37
|
+
},
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
// Create the iFrame and the associated NexusClient
|
|
@@ -6,19 +6,19 @@ import {
|
|
|
6
6
|
} from "./chunk-5QWG35A2.js";
|
|
7
7
|
|
|
8
8
|
// src/core/actions/getUnlockOptions.ts
|
|
9
|
-
function getArticleUnlockOptions(client, { articleId }) {
|
|
9
|
+
function getArticleUnlockOptions(client, { articleId, contentId }) {
|
|
10
10
|
return client.request({
|
|
11
11
|
method: "frak_getArticleUnlockOptions",
|
|
12
|
-
params: [
|
|
12
|
+
params: [contentId, articleId]
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// src/core/actions/watchUnlockStatus.ts
|
|
17
|
-
function watchUnlockStatus(client, { articleId }, callback) {
|
|
17
|
+
function watchUnlockStatus(client, { articleId, contentId }, callback) {
|
|
18
18
|
return client.listenerRequest(
|
|
19
19
|
{
|
|
20
20
|
method: "frak_listenToArticleUnlockStatus",
|
|
21
|
-
params: [
|
|
21
|
+
params: [contentId, articleId]
|
|
22
22
|
},
|
|
23
23
|
callback
|
|
24
24
|
);
|
|
@@ -39,11 +39,7 @@ async function getStartArticleUnlockUrl(config, params) {
|
|
|
39
39
|
const { compressed, compressedHash } = await hashAndCompressData(
|
|
40
40
|
{
|
|
41
41
|
method: "frak_startArticleUnlock",
|
|
42
|
-
params
|
|
43
|
-
...params,
|
|
44
|
-
contentId: config.contentId,
|
|
45
|
-
contentTitle: config.contentTitle
|
|
46
|
-
}
|
|
42
|
+
params
|
|
47
43
|
},
|
|
48
44
|
redirectRequestKeyProvider
|
|
49
45
|
);
|
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
var _chunk2XUJYDD3cjs = require('./chunk-2XUJYDD3.cjs');
|
|
7
7
|
|
|
8
8
|
// src/core/actions/getUnlockOptions.ts
|
|
9
|
-
function getArticleUnlockOptions(client, { articleId }) {
|
|
9
|
+
function getArticleUnlockOptions(client, { articleId, contentId }) {
|
|
10
10
|
return client.request({
|
|
11
11
|
method: "frak_getArticleUnlockOptions",
|
|
12
|
-
params: [
|
|
12
|
+
params: [contentId, articleId]
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// src/core/actions/watchUnlockStatus.ts
|
|
17
|
-
function watchUnlockStatus(client, { articleId }, callback) {
|
|
17
|
+
function watchUnlockStatus(client, { articleId, contentId }, callback) {
|
|
18
18
|
return client.listenerRequest(
|
|
19
19
|
{
|
|
20
20
|
method: "frak_listenToArticleUnlockStatus",
|
|
21
|
-
params: [
|
|
21
|
+
params: [contentId, articleId]
|
|
22
22
|
},
|
|
23
23
|
callback
|
|
24
24
|
);
|
|
@@ -39,11 +39,7 @@ async function getStartArticleUnlockUrl(config, params) {
|
|
|
39
39
|
const { compressed, compressedHash } = await _chunk2XUJYDD3cjs.hashAndCompressData.call(void 0,
|
|
40
40
|
{
|
|
41
41
|
method: "frak_startArticleUnlock",
|
|
42
|
-
params
|
|
43
|
-
...params,
|
|
44
|
-
contentId: config.contentId,
|
|
45
|
-
contentTitle: config.contentTitle
|
|
46
|
-
}
|
|
42
|
+
params
|
|
47
43
|
},
|
|
48
44
|
_chunk2XUJYDD3cjs.redirectRequestKeyProvider
|
|
49
45
|
);
|
|
@@ -6,8 +6,9 @@ import { Prettify } from 'viem/chains';
|
|
|
6
6
|
*/
|
|
7
7
|
type NexusWalletSdkConfig = Readonly<{
|
|
8
8
|
walletUrl: string;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
metadata: {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
11
12
|
}>;
|
|
12
13
|
|
|
13
14
|
type PaidArticleUnlockPrice = Readonly<{
|
|
@@ -57,6 +58,7 @@ type UnlockError = {
|
|
|
57
58
|
* The response to the get unlock options response
|
|
58
59
|
*/
|
|
59
60
|
type UnlockOptionsReturnType = Readonly<{
|
|
61
|
+
frkBalanceAsHex?: Hex;
|
|
60
62
|
prices: {
|
|
61
63
|
index: number;
|
|
62
64
|
unlockDurationInSec: number;
|
|
@@ -116,7 +118,6 @@ type WalletStatusReturnType = Readonly<WalletConnected | WalletNotConnected>;
|
|
|
116
118
|
type WalletConnected = {
|
|
117
119
|
key: "connected";
|
|
118
120
|
wallet: Address;
|
|
119
|
-
frkBalanceAsHex: Hex;
|
|
120
121
|
};
|
|
121
122
|
type WalletNotConnected = {
|
|
122
123
|
key: "not-connected";
|
|
@@ -6,8 +6,9 @@ import { Prettify } from 'viem/chains';
|
|
|
6
6
|
*/
|
|
7
7
|
type NexusWalletSdkConfig = Readonly<{
|
|
8
8
|
walletUrl: string;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
metadata: {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
11
12
|
}>;
|
|
12
13
|
|
|
13
14
|
type PaidArticleUnlockPrice = Readonly<{
|
|
@@ -57,6 +58,7 @@ type UnlockError = {
|
|
|
57
58
|
* The response to the get unlock options response
|
|
58
59
|
*/
|
|
59
60
|
type UnlockOptionsReturnType = Readonly<{
|
|
61
|
+
frkBalanceAsHex?: Hex;
|
|
60
62
|
prices: {
|
|
61
63
|
index: number;
|
|
62
64
|
unlockDurationInSec: number;
|
|
@@ -116,7 +118,6 @@ type WalletStatusReturnType = Readonly<WalletConnected | WalletNotConnected>;
|
|
|
116
118
|
type WalletConnected = {
|
|
117
119
|
key: "connected";
|
|
118
120
|
wallet: Address;
|
|
119
|
-
frkBalanceAsHex: Hex;
|
|
120
121
|
};
|
|
121
122
|
type WalletNotConnected = {
|
|
122
123
|
key: "not-connected";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6V4UCVTDcjs = require('../../chunk-6V4UCVTD.cjs');
|
|
8
8
|
require('../../chunk-2XUJYDD3.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
@@ -12,4 +12,4 @@ require('../../chunk-2XUJYDD3.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.decodeStartUnlockReturn =
|
|
15
|
+
exports.decodeStartUnlockReturn = _chunk6V4UCVTDcjs.decodeStartUnlockReturn; exports.getArticleUnlockOptions = _chunk6V4UCVTDcjs.getArticleUnlockOptions; exports.getStartArticleUnlockUrl = _chunk6V4UCVTDcjs.getStartArticleUnlockUrl; exports.watchUnlockStatus = _chunk6V4UCVTDcjs.watchUnlockStatus; exports.watchWalletStatus = _chunk6V4UCVTDcjs.watchWalletStatus;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus-
|
|
2
|
-
import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-
|
|
1
|
+
export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus-DqWkImYK.cjs';
|
|
2
|
+
import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-MgLVRfPw.cjs';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import 'viem/chains';
|
|
|
10
10
|
*/
|
|
11
11
|
declare function watchWalletStatus(client: NexusClient, callback: (status: WalletStatusReturnType) => void): Promise<void>;
|
|
12
12
|
|
|
13
|
-
type GetStartUnlockUrlParams =
|
|
13
|
+
type GetStartUnlockUrlParams = StartArticleUnlockParams;
|
|
14
14
|
/**
|
|
15
15
|
* Function used to build the unlock URL for a given article
|
|
16
16
|
* @param config
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus
|
|
2
|
-
import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-
|
|
1
|
+
export { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams, g as getArticleUnlockOptions, w as watchUnlockStatus } from '../../watchUnlockStatus-DQYfUj46.js';
|
|
2
|
+
import { N as NexusClient, W as WalletStatusReturnType, a as NexusWalletSdkConfig, S as StartArticleUnlockReturnType, b as StartArticleUnlockParams } from '../../client-MgLVRfPw.js';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import 'viem/chains';
|
|
|
10
10
|
*/
|
|
11
11
|
declare function watchWalletStatus(client: NexusClient, callback: (status: WalletStatusReturnType) => void): Promise<void>;
|
|
12
12
|
|
|
13
|
-
type GetStartUnlockUrlParams =
|
|
13
|
+
type GetStartUnlockUrlParams = StartArticleUnlockParams;
|
|
14
14
|
/**
|
|
15
15
|
* Function used to build the unlock URL for a given article
|
|
16
16
|
* @param config
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-
|
|
2
|
-
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-
|
|
1
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-MgLVRfPw.cjs';
|
|
2
|
+
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-MgLVRfPw.cjs';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
5
5
|
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-
|
|
2
|
-
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-
|
|
1
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, E as ExtractedParametersFromRpc, I as IFrameRpcSchema, c as ExtractedReturnTypeFromRpc, R as RedirectRpcSchema } from '../client-MgLVRfPw.js';
|
|
2
|
+
export { A as ArticleUnlockStatusReturnType, f as IFrameEvent, e as IFrameRpcEvent, d as IFrameTransport, P as PaidArticleUnlockPrice, b as StartArticleUnlockParams, S as StartArticleUnlockReturnType, U as UnlockOptionsReturnType, W as WalletStatusReturnType } from '../client-MgLVRfPw.js';
|
|
3
3
|
import 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
5
5
|
|
package/dist/react/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkJXQKTLEEcjs = require('../chunk-JXQKTLEE.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk6V4UCVTDcjs = require('../chunk-6V4UCVTD.cjs');
|
|
9
9
|
require('../chunk-2XUJYDD3.cjs');
|
|
10
10
|
|
|
11
11
|
// src/react/provider/NexusConfigProvider.ts
|
|
@@ -51,17 +51,23 @@ function useNexusClient() {
|
|
|
51
51
|
|
|
52
52
|
// src/react/hook/useArticleUnlockOptions.ts
|
|
53
53
|
var _reactquery = require('@tanstack/react-query');
|
|
54
|
-
function useArticleUnlockOptions({
|
|
54
|
+
function useArticleUnlockOptions({
|
|
55
|
+
articleId,
|
|
56
|
+
contentId
|
|
57
|
+
}) {
|
|
55
58
|
const client = useNexusClient();
|
|
56
59
|
return _reactquery.useQuery.call(void 0, {
|
|
57
60
|
queryKey: ["articleUnlockOptions", _nullishCoalesce(articleId, () => ( "no-article-id"))],
|
|
58
61
|
queryFn: async () => {
|
|
59
|
-
if (!articleId) {
|
|
62
|
+
if (!(articleId && contentId)) {
|
|
60
63
|
throw new Error("No article id provided");
|
|
61
64
|
}
|
|
62
|
-
return await
|
|
65
|
+
return await _chunk6V4UCVTDcjs.getArticleUnlockOptions.call(void 0, client, {
|
|
66
|
+
articleId,
|
|
67
|
+
contentId
|
|
68
|
+
});
|
|
63
69
|
},
|
|
64
|
-
enabled: !!articleId,
|
|
70
|
+
enabled: !!articleId && !!contentId,
|
|
65
71
|
gcTime: 0
|
|
66
72
|
});
|
|
67
73
|
}
|
|
@@ -82,7 +88,7 @@ function useWalletStatus() {
|
|
|
82
88
|
gcTime: 0,
|
|
83
89
|
queryKey: ["walletStatusListener"],
|
|
84
90
|
queryFn: async () => {
|
|
85
|
-
await
|
|
91
|
+
await _chunk6V4UCVTDcjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
|
|
86
92
|
return { key: "waiting-response" };
|
|
87
93
|
}
|
|
88
94
|
});
|
|
@@ -91,32 +97,47 @@ function useWalletStatus() {
|
|
|
91
97
|
// src/react/hook/useArticleUnlockStatus.ts
|
|
92
98
|
|
|
93
99
|
|
|
94
|
-
function useArticleUnlockStatus({
|
|
100
|
+
function useArticleUnlockStatus({
|
|
101
|
+
articleId,
|
|
102
|
+
contentId
|
|
103
|
+
}) {
|
|
95
104
|
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
96
105
|
const client = useNexusClient();
|
|
97
106
|
const newStatusUpdated = _react.useCallback.call(void 0,
|
|
98
107
|
(event) => {
|
|
99
108
|
queryClient.setQueryData(
|
|
100
|
-
[
|
|
109
|
+
[
|
|
110
|
+
"articleUnlockStatusListener",
|
|
111
|
+
_nullishCoalesce(articleId, () => ( "no-article-id")),
|
|
112
|
+
_nullishCoalesce(contentId, () => ( "no-contentId-id"))
|
|
113
|
+
],
|
|
101
114
|
event
|
|
102
115
|
);
|
|
103
116
|
},
|
|
104
|
-
[articleId, queryClient]
|
|
117
|
+
[articleId, contentId, queryClient]
|
|
105
118
|
);
|
|
106
119
|
return _reactquery.useQuery.call(void 0, {
|
|
107
|
-
queryKey: [
|
|
120
|
+
queryKey: [
|
|
121
|
+
"articleUnlockStatusListener",
|
|
122
|
+
_nullishCoalesce(articleId, () => ( "no-article-id")),
|
|
123
|
+
_nullishCoalesce(contentId, () => ( "no-contentId-id"))
|
|
124
|
+
],
|
|
108
125
|
gcTime: 0,
|
|
109
126
|
queryFn: async () => {
|
|
110
|
-
if (!articleId) {
|
|
127
|
+
if (!(articleId && contentId)) {
|
|
111
128
|
return null;
|
|
112
129
|
}
|
|
113
|
-
await
|
|
130
|
+
await _chunk6V4UCVTDcjs.watchUnlockStatus.call(void 0,
|
|
131
|
+
client,
|
|
132
|
+
{ articleId, contentId },
|
|
133
|
+
newStatusUpdated
|
|
134
|
+
);
|
|
114
135
|
return {
|
|
115
136
|
status: "waiting-response",
|
|
116
137
|
key: "waiting-response"
|
|
117
138
|
};
|
|
118
139
|
},
|
|
119
|
-
enabled: !!articleId
|
|
140
|
+
enabled: !!articleId && !!contentId
|
|
120
141
|
});
|
|
121
142
|
}
|
|
122
143
|
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
-
import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-
|
|
3
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-MgLVRfPw.cjs';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-
|
|
5
|
+
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-DqWkImYK.cjs';
|
|
6
6
|
import 'viem';
|
|
7
7
|
import 'viem/chains';
|
|
8
8
|
|
|
@@ -11,8 +11,9 @@ import 'viem/chains';
|
|
|
11
11
|
*/
|
|
12
12
|
declare const NexusConfigContext: react.Context<Readonly<{
|
|
13
13
|
walletUrl: string;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
metadata: {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
16
17
|
}> | undefined>;
|
|
17
18
|
/**
|
|
18
19
|
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
@@ -27,8 +28,9 @@ type NexusConfigProviderProps = {
|
|
|
27
28
|
*/
|
|
28
29
|
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
29
30
|
walletUrl: string;
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
metadata: {
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
32
34
|
}> | undefined>>;
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -58,8 +60,9 @@ declare function NexusIFrameClientProvider({ children, }: {
|
|
|
58
60
|
*/
|
|
59
61
|
declare function useNexusConfig(): Readonly<{
|
|
60
62
|
walletUrl: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
metadata: {
|
|
64
|
+
name: string;
|
|
65
|
+
};
|
|
63
66
|
}>;
|
|
64
67
|
|
|
65
68
|
/**
|
|
@@ -70,7 +73,8 @@ declare function useNexusClient(): NexusClient;
|
|
|
70
73
|
/**
|
|
71
74
|
* Hook used to get the unlock options for an article
|
|
72
75
|
*/
|
|
73
|
-
declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
|
|
76
|
+
declare function useArticleUnlockOptions({ articleId, contentId, }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
|
|
77
|
+
frkBalanceAsHex?: `0x${string}` | undefined;
|
|
74
78
|
prices: {
|
|
75
79
|
index: number;
|
|
76
80
|
unlockDurationInSec: number;
|
|
@@ -94,6 +98,6 @@ type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
|
|
|
94
98
|
/**
|
|
95
99
|
* Hooks used to listen to the current article unlock status
|
|
96
100
|
*/
|
|
97
|
-
declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
|
|
101
|
+
declare function useArticleUnlockStatus({ articleId, contentId, }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
|
|
98
102
|
|
|
99
103
|
export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
-
import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-
|
|
3
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-MgLVRfPw.js';
|
|
4
4
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus
|
|
5
|
+
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-DQYfUj46.js';
|
|
6
6
|
import 'viem';
|
|
7
7
|
import 'viem/chains';
|
|
8
8
|
|
|
@@ -11,8 +11,9 @@ import 'viem/chains';
|
|
|
11
11
|
*/
|
|
12
12
|
declare const NexusConfigContext: react.Context<Readonly<{
|
|
13
13
|
walletUrl: string;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
metadata: {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
16
17
|
}> | undefined>;
|
|
17
18
|
/**
|
|
18
19
|
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
@@ -27,8 +28,9 @@ type NexusConfigProviderProps = {
|
|
|
27
28
|
*/
|
|
28
29
|
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
29
30
|
walletUrl: string;
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
metadata: {
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
32
34
|
}> | undefined>>;
|
|
33
35
|
|
|
34
36
|
/**
|
|
@@ -58,8 +60,9 @@ declare function NexusIFrameClientProvider({ children, }: {
|
|
|
58
60
|
*/
|
|
59
61
|
declare function useNexusConfig(): Readonly<{
|
|
60
62
|
walletUrl: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
metadata: {
|
|
64
|
+
name: string;
|
|
65
|
+
};
|
|
63
66
|
}>;
|
|
64
67
|
|
|
65
68
|
/**
|
|
@@ -70,7 +73,8 @@ declare function useNexusClient(): NexusClient;
|
|
|
70
73
|
/**
|
|
71
74
|
* Hook used to get the unlock options for an article
|
|
72
75
|
*/
|
|
73
|
-
declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
|
|
76
|
+
declare function useArticleUnlockOptions({ articleId, contentId, }: GetUnlockOptionsParams): _tanstack_react_query.UseQueryResult<Readonly<{
|
|
77
|
+
frkBalanceAsHex?: `0x${string}` | undefined;
|
|
74
78
|
prices: {
|
|
75
79
|
index: number;
|
|
76
80
|
unlockDurationInSec: number;
|
|
@@ -94,6 +98,6 @@ type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
|
|
|
94
98
|
/**
|
|
95
99
|
* Hooks used to listen to the current article unlock status
|
|
96
100
|
*/
|
|
97
|
-
declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
|
|
101
|
+
declare function useArticleUnlockStatus({ articleId, contentId, }: WatchUnlockStatusParams): _tanstack_react_query.UseQueryResult<ArticleUnlockStatusQueryReturnType | null, Error>;
|
|
98
102
|
|
|
99
103
|
export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
|
package/dist/react/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getArticleUnlockOptions,
|
|
6
6
|
watchUnlockStatus,
|
|
7
7
|
watchWalletStatus
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-4VFMYMTH.js";
|
|
9
9
|
import "../chunk-5QWG35A2.js";
|
|
10
10
|
|
|
11
11
|
// src/react/provider/NexusConfigProvider.ts
|
|
@@ -51,17 +51,23 @@ function useNexusClient() {
|
|
|
51
51
|
|
|
52
52
|
// src/react/hook/useArticleUnlockOptions.ts
|
|
53
53
|
import { useQuery } from "@tanstack/react-query";
|
|
54
|
-
function useArticleUnlockOptions({
|
|
54
|
+
function useArticleUnlockOptions({
|
|
55
|
+
articleId,
|
|
56
|
+
contentId
|
|
57
|
+
}) {
|
|
55
58
|
const client = useNexusClient();
|
|
56
59
|
return useQuery({
|
|
57
60
|
queryKey: ["articleUnlockOptions", articleId ?? "no-article-id"],
|
|
58
61
|
queryFn: async () => {
|
|
59
|
-
if (!articleId) {
|
|
62
|
+
if (!(articleId && contentId)) {
|
|
60
63
|
throw new Error("No article id provided");
|
|
61
64
|
}
|
|
62
|
-
return await getArticleUnlockOptions(client, {
|
|
65
|
+
return await getArticleUnlockOptions(client, {
|
|
66
|
+
articleId,
|
|
67
|
+
contentId
|
|
68
|
+
});
|
|
63
69
|
},
|
|
64
|
-
enabled: !!articleId,
|
|
70
|
+
enabled: !!articleId && !!contentId,
|
|
65
71
|
gcTime: 0
|
|
66
72
|
});
|
|
67
73
|
}
|
|
@@ -91,32 +97,47 @@ function useWalletStatus() {
|
|
|
91
97
|
// src/react/hook/useArticleUnlockStatus.ts
|
|
92
98
|
import { useQuery as useQuery3, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
93
99
|
import { useCallback as useCallback2 } from "react";
|
|
94
|
-
function useArticleUnlockStatus({
|
|
100
|
+
function useArticleUnlockStatus({
|
|
101
|
+
articleId,
|
|
102
|
+
contentId
|
|
103
|
+
}) {
|
|
95
104
|
const queryClient = useQueryClient2();
|
|
96
105
|
const client = useNexusClient();
|
|
97
106
|
const newStatusUpdated = useCallback2(
|
|
98
107
|
(event) => {
|
|
99
108
|
queryClient.setQueryData(
|
|
100
|
-
[
|
|
109
|
+
[
|
|
110
|
+
"articleUnlockStatusListener",
|
|
111
|
+
articleId ?? "no-article-id",
|
|
112
|
+
contentId ?? "no-contentId-id"
|
|
113
|
+
],
|
|
101
114
|
event
|
|
102
115
|
);
|
|
103
116
|
},
|
|
104
|
-
[articleId, queryClient]
|
|
117
|
+
[articleId, contentId, queryClient]
|
|
105
118
|
);
|
|
106
119
|
return useQuery3({
|
|
107
|
-
queryKey: [
|
|
120
|
+
queryKey: [
|
|
121
|
+
"articleUnlockStatusListener",
|
|
122
|
+
articleId ?? "no-article-id",
|
|
123
|
+
contentId ?? "no-contentId-id"
|
|
124
|
+
],
|
|
108
125
|
gcTime: 0,
|
|
109
126
|
queryFn: async () => {
|
|
110
|
-
if (!articleId) {
|
|
127
|
+
if (!(articleId && contentId)) {
|
|
111
128
|
return null;
|
|
112
129
|
}
|
|
113
|
-
await watchUnlockStatus(
|
|
130
|
+
await watchUnlockStatus(
|
|
131
|
+
client,
|
|
132
|
+
{ articleId, contentId },
|
|
133
|
+
newStatusUpdated
|
|
134
|
+
);
|
|
114
135
|
return {
|
|
115
136
|
status: "waiting-response",
|
|
116
137
|
key: "waiting-response"
|
|
117
138
|
};
|
|
118
139
|
},
|
|
119
|
-
enabled: !!articleId
|
|
140
|
+
enabled: !!articleId && !!contentId
|
|
120
141
|
});
|
|
121
142
|
}
|
|
122
143
|
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
|
-
import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-
|
|
2
|
+
import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-MgLVRfPw.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Type used to get the unlock options
|
|
6
6
|
*/
|
|
7
7
|
type GetUnlockOptionsParams = {
|
|
8
8
|
articleId: Hex;
|
|
9
|
+
contentId: Hex;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* Function used to fetch the unlock option for the given client
|
|
12
13
|
* @param client
|
|
13
14
|
* @param articleId
|
|
15
|
+
* @param contentId
|
|
14
16
|
*/
|
|
15
|
-
declare function getArticleUnlockOptions(client: NexusClient, { articleId }: GetUnlockOptionsParams): Promise<Readonly<{
|
|
17
|
+
declare function getArticleUnlockOptions(client: NexusClient, { articleId, contentId }: GetUnlockOptionsParams): Promise<Readonly<{
|
|
18
|
+
frkBalanceAsHex?: `0x${string}` | undefined;
|
|
16
19
|
prices: {
|
|
17
20
|
index: number;
|
|
18
21
|
unlockDurationInSec: number;
|
|
@@ -26,13 +29,15 @@ declare function getArticleUnlockOptions(client: NexusClient, { articleId }: Get
|
|
|
26
29
|
*/
|
|
27
30
|
type WatchUnlockStatusParams = {
|
|
28
31
|
articleId: Hex;
|
|
32
|
+
contentId: Hex;
|
|
29
33
|
};
|
|
30
34
|
/**
|
|
31
35
|
* Function used to watch a current article unlock status
|
|
32
36
|
* @param client
|
|
33
37
|
* @param articleId
|
|
38
|
+
* @param contentId
|
|
34
39
|
* @param callback
|
|
35
40
|
*/
|
|
36
|
-
declare function watchUnlockStatus(client: NexusClient, { articleId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
|
|
41
|
+
declare function watchUnlockStatus(client: NexusClient, { articleId, contentId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
|
|
37
42
|
|
|
38
43
|
export { type GetUnlockOptionsParams as G, type WatchUnlockStatusParams as W, getArticleUnlockOptions as g, watchUnlockStatus as w };
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
|
-
import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-
|
|
2
|
+
import { N as NexusClient, A as ArticleUnlockStatusReturnType } from './client-MgLVRfPw.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Type used to get the unlock options
|
|
6
6
|
*/
|
|
7
7
|
type GetUnlockOptionsParams = {
|
|
8
8
|
articleId: Hex;
|
|
9
|
+
contentId: Hex;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* Function used to fetch the unlock option for the given client
|
|
12
13
|
* @param client
|
|
13
14
|
* @param articleId
|
|
15
|
+
* @param contentId
|
|
14
16
|
*/
|
|
15
|
-
declare function getArticleUnlockOptions(client: NexusClient, { articleId }: GetUnlockOptionsParams): Promise<Readonly<{
|
|
17
|
+
declare function getArticleUnlockOptions(client: NexusClient, { articleId, contentId }: GetUnlockOptionsParams): Promise<Readonly<{
|
|
18
|
+
frkBalanceAsHex?: `0x${string}` | undefined;
|
|
16
19
|
prices: {
|
|
17
20
|
index: number;
|
|
18
21
|
unlockDurationInSec: number;
|
|
@@ -26,13 +29,15 @@ declare function getArticleUnlockOptions(client: NexusClient, { articleId }: Get
|
|
|
26
29
|
*/
|
|
27
30
|
type WatchUnlockStatusParams = {
|
|
28
31
|
articleId: Hex;
|
|
32
|
+
contentId: Hex;
|
|
29
33
|
};
|
|
30
34
|
/**
|
|
31
35
|
* Function used to watch a current article unlock status
|
|
32
36
|
* @param client
|
|
33
37
|
* @param articleId
|
|
38
|
+
* @param contentId
|
|
34
39
|
* @param callback
|
|
35
40
|
*/
|
|
36
|
-
declare function watchUnlockStatus(client: NexusClient, { articleId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
|
|
41
|
+
declare function watchUnlockStatus(client: NexusClient, { articleId, contentId }: WatchUnlockStatusParams, callback: (status: ArticleUnlockStatusReturnType) => void): Promise<void>;
|
|
37
42
|
|
|
38
43
|
export { type GetUnlockOptionsParams as G, type WatchUnlockStatusParams as W, getArticleUnlockOptions as g, watchUnlockStatus as w };
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.8",
|
|
15
15
|
"description": "Nexus 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": "https://github.com/frak-id/wallet",
|
|
17
17
|
"homepage": "https://docs.frak.id/wallet-sdk",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"js-sha256": "^0.11.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@tanstack/react-query": ">=5.
|
|
75
|
+
"@tanstack/react-query": ">=5.32.0",
|
|
76
76
|
"@types/node": "^20",
|
|
77
77
|
"tsup": "^8.0.2",
|
|
78
78
|
"typescript": "^5"
|