@frak-labs/nexus-sdk 0.0.2-alpha → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4X75PGSK.cjs → chunk-2XUJYDD3.cjs} +4 -4
- package/dist/chunk-3LF3FGI6.cjs +78 -0
- package/dist/{chunk-JE64MPH2.js → chunk-5QWG35A2.js} +4 -4
- package/dist/chunk-DI2REDPX.js +78 -0
- package/dist/chunk-JXQKTLEE.cjs +171 -0
- package/dist/chunk-OXP3VK26.js +171 -0
- package/dist/{client-SCwoh_kP.d.cts → client-gnNyzrko.d.cts} +9 -7
- package/dist/{client-SCwoh_kP.d.ts → client-gnNyzrko.d.ts} +9 -7
- package/dist/core/actions/index.cjs +3 -65
- package/dist/core/actions/index.d.cts +6 -39
- package/dist/core/actions/index.d.ts +6 -39
- package/dist/core/actions/index.js +7 -69
- package/dist/core/index.cjs +22 -179
- package/dist/core/index.d.cts +7 -7
- package/dist/core/index.d.ts +7 -7
- package/dist/core/index.js +5 -162
- package/dist/react/index.cjs +169 -0
- package/dist/react/index.d.cts +99 -0
- package/dist/react/index.d.ts +99 -0
- package/dist/react/index.js +169 -0
- package/dist/watchUnlockStatus-Btjg-WTs.d.ts +38 -0
- package/dist/watchUnlockStatus-DvDS55TN.d.cts +38 -0
- package/package.json +10 -2
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createIFrameNexusClient
|
|
3
|
+
} from "../chunk-OXP3VK26.js";
|
|
4
|
+
import {
|
|
3
5
|
createIframe,
|
|
4
6
|
decompressDataAndCheckHash,
|
|
5
7
|
getIFrameResponseKeyProvider,
|
|
@@ -7,168 +9,9 @@ import {
|
|
|
7
9
|
hashAndCompressData,
|
|
8
10
|
iFrameRequestKeyProvider,
|
|
9
11
|
redirectRequestKeyProvider
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
|
|
12
|
-
// src/core/utils/Deferred.ts
|
|
13
|
-
var Deferred = class {
|
|
14
|
-
constructor() {
|
|
15
|
-
__publicField(this, "_promise");
|
|
16
|
-
__publicField(this, "_resolve");
|
|
17
|
-
__publicField(this, "_reject");
|
|
18
|
-
__publicField(this, "resolve", (value) => {
|
|
19
|
-
this._resolve?.(value);
|
|
20
|
-
});
|
|
21
|
-
__publicField(this, "reject", (reason) => {
|
|
22
|
-
this._reject?.(reason);
|
|
23
|
-
});
|
|
24
|
-
this._promise = new Promise((resolve, reject) => {
|
|
25
|
-
this._resolve = resolve;
|
|
26
|
-
this._reject = reject;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
get promise() {
|
|
30
|
-
return this._promise;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// src/core/clients/transports/iframeChannelManager.ts
|
|
35
|
-
function createIFrameChannelManager() {
|
|
36
|
-
const channels = /* @__PURE__ */ new Map();
|
|
37
|
-
return {
|
|
38
|
-
// TODO: Better id system?? uid stuff?
|
|
39
|
-
createChannel: (resolver) => {
|
|
40
|
-
const id = Math.random().toString(36).substring(7);
|
|
41
|
-
channels.set(id, resolver);
|
|
42
|
-
return id;
|
|
43
|
-
},
|
|
44
|
-
getRpcResolver: (id) => channels.get(id),
|
|
45
|
-
removeChannel: (id) => channels.delete(id),
|
|
46
|
-
destroy: () => channels.clear()
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/core/clients/transports/iframeMessageHandler.ts
|
|
51
|
-
function createIFrameMessageHandler({
|
|
52
|
-
frakWalletUrl,
|
|
53
|
-
iframe,
|
|
54
|
-
channelManager
|
|
55
|
-
}) {
|
|
56
|
-
if (typeof window === "undefined") {
|
|
57
|
-
throw new Error("iframe client should be used in the browser");
|
|
58
|
-
}
|
|
59
|
-
if (!iframe.contentWindow) {
|
|
60
|
-
throw new Error("The iframe does not have a content window");
|
|
61
|
-
}
|
|
62
|
-
const contentWindow = iframe.contentWindow;
|
|
63
|
-
const isConnected = new Deferred();
|
|
64
|
-
const msgHandler = async (event) => {
|
|
65
|
-
if (!event.origin) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (new URL(event.origin).origin.toLowerCase() !== new URL(frakWalletUrl).origin.toLowerCase()) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if ("lifecycle" in event.data) {
|
|
72
|
-
isConnected.resolve(event.data.lifecycle === "connected");
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const channel = event.data.id;
|
|
76
|
-
const resolver = channelManager.getRpcResolver(channel);
|
|
77
|
-
if (!resolver) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
await resolver(event.data);
|
|
81
|
-
};
|
|
82
|
-
window.addEventListener("message", msgHandler);
|
|
83
|
-
const sendEvent = (message) => {
|
|
84
|
-
contentWindow.postMessage(message, {
|
|
85
|
-
targetOrigin: frakWalletUrl
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
const cleanup = () => {
|
|
89
|
-
window.removeEventListener("message", msgHandler);
|
|
90
|
-
};
|
|
91
|
-
return {
|
|
92
|
-
isConnected: isConnected.promise,
|
|
93
|
-
sendEvent,
|
|
94
|
-
cleanup
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/core/clients/createIFrameFrakClient.ts
|
|
99
|
-
function createIFrameFrakClient({
|
|
100
|
-
config,
|
|
101
|
-
iframe
|
|
102
|
-
}) {
|
|
103
|
-
const channelManager = createIFrameChannelManager();
|
|
104
|
-
const messageHandler = createIFrameMessageHandler({
|
|
105
|
-
frakWalletUrl: config.walletUrl,
|
|
106
|
-
iframe,
|
|
107
|
-
channelManager
|
|
108
|
-
});
|
|
109
|
-
const request = async (args) => {
|
|
110
|
-
const isConnected = await messageHandler.isConnected;
|
|
111
|
-
if (!isConnected) {
|
|
112
|
-
throw new Error("The iframe provider isn't connected yet");
|
|
113
|
-
}
|
|
114
|
-
const result = new Deferred();
|
|
115
|
-
const resultCompressionKeyProvider = getIFrameResponseKeyProvider(args);
|
|
116
|
-
const channelId = channelManager.createChannel(async (message) => {
|
|
117
|
-
const decompressed = await decompressDataAndCheckHash(
|
|
118
|
-
message.data,
|
|
119
|
-
resultCompressionKeyProvider
|
|
120
|
-
);
|
|
121
|
-
result.resolve(decompressed);
|
|
122
|
-
channelManager.removeChannel(channelId);
|
|
123
|
-
});
|
|
124
|
-
const compressedMessage = await hashAndCompressData(
|
|
125
|
-
args,
|
|
126
|
-
iFrameRequestKeyProvider
|
|
127
|
-
);
|
|
128
|
-
messageHandler.sendEvent({
|
|
129
|
-
id: channelId,
|
|
130
|
-
topic: args.method,
|
|
131
|
-
data: compressedMessage
|
|
132
|
-
});
|
|
133
|
-
return result.promise;
|
|
134
|
-
};
|
|
135
|
-
const listenerRequest = async (args, callback) => {
|
|
136
|
-
const isConnected = await messageHandler.isConnected;
|
|
137
|
-
if (!isConnected) {
|
|
138
|
-
throw new Error("The iframe provider isn't connected yet");
|
|
139
|
-
}
|
|
140
|
-
const resultCompressionKeyProvider = getIFrameResponseKeyProvider(args);
|
|
141
|
-
const channelId = channelManager.createChannel(async (message) => {
|
|
142
|
-
const decompressed = await decompressDataAndCheckHash(
|
|
143
|
-
message.data,
|
|
144
|
-
resultCompressionKeyProvider
|
|
145
|
-
);
|
|
146
|
-
callback(decompressed);
|
|
147
|
-
});
|
|
148
|
-
const compressedMessage = await hashAndCompressData(
|
|
149
|
-
args,
|
|
150
|
-
iFrameRequestKeyProvider
|
|
151
|
-
);
|
|
152
|
-
messageHandler.sendEvent({
|
|
153
|
-
id: channelId,
|
|
154
|
-
topic: args.method,
|
|
155
|
-
data: compressedMessage
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
const destroy = async () => {
|
|
159
|
-
channelManager.destroy();
|
|
160
|
-
messageHandler.cleanup();
|
|
161
|
-
};
|
|
162
|
-
return {
|
|
163
|
-
config,
|
|
164
|
-
waitForConnection: messageHandler.isConnected,
|
|
165
|
-
request,
|
|
166
|
-
listenerRequest,
|
|
167
|
-
destroy
|
|
168
|
-
};
|
|
169
|
-
}
|
|
12
|
+
} from "../chunk-5QWG35A2.js";
|
|
170
13
|
export {
|
|
171
|
-
|
|
14
|
+
createIFrameNexusClient,
|
|
172
15
|
createIframe,
|
|
173
16
|
decompressDataAndCheckHash,
|
|
174
17
|
getIFrameResponseKeyProvider,
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkJXQKTLEEcjs = require('../chunk-JXQKTLEE.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk3LF3FGI6cjs = require('../chunk-3LF3FGI6.cjs');
|
|
9
|
+
require('../chunk-2XUJYDD3.cjs');
|
|
10
|
+
|
|
11
|
+
// src/react/provider/NexusConfigProvider.ts
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var NexusConfigContext = _react.createContext.call(void 0, void 0);
|
|
14
|
+
function NexusConfigProvider(parameters) {
|
|
15
|
+
const { children, config } = parameters;
|
|
16
|
+
return _react.createElement.call(void 0,
|
|
17
|
+
NexusConfigContext.Provider,
|
|
18
|
+
{ value: config },
|
|
19
|
+
children
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/react/provider/NexusIFrameClientProvider.ts
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// src/react/hook/useNexusConfig.ts
|
|
33
|
+
|
|
34
|
+
function useNexusConfig() {
|
|
35
|
+
const config = _react.useContext.call(void 0, NexusConfigContext);
|
|
36
|
+
if (!config) {
|
|
37
|
+
throw new Error("NexusConfigProvider is not found");
|
|
38
|
+
}
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/react/hook/useNexusClient.ts
|
|
43
|
+
|
|
44
|
+
function useNexusClient() {
|
|
45
|
+
const client = _react.useContext.call(void 0, NexusIFrameClientContext);
|
|
46
|
+
if (!client) {
|
|
47
|
+
throw new Error("NexusIFrameClientProvider is not found");
|
|
48
|
+
}
|
|
49
|
+
return client;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/react/hook/useArticleUnlockOptions.ts
|
|
53
|
+
var _reactquery = require('@tanstack/react-query');
|
|
54
|
+
function useArticleUnlockOptions({ articleId }) {
|
|
55
|
+
const client = useNexusClient();
|
|
56
|
+
return _reactquery.useQuery.call(void 0, {
|
|
57
|
+
queryKey: ["articleUnlockOptions", _nullishCoalesce(articleId, () => ( "no-article-id"))],
|
|
58
|
+
queryFn: async () => {
|
|
59
|
+
if (!articleId) {
|
|
60
|
+
throw new Error("No article id provided");
|
|
61
|
+
}
|
|
62
|
+
return await _chunk3LF3FGI6cjs.getArticleUnlockOptions.call(void 0, client, { articleId });
|
|
63
|
+
},
|
|
64
|
+
enabled: !!articleId
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/react/hook/useWalletStatus.ts
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
function useWalletStatus() {
|
|
72
|
+
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
73
|
+
const client = useNexusClient();
|
|
74
|
+
const newStatusUpdated = _react.useCallback.call(void 0,
|
|
75
|
+
(event) => {
|
|
76
|
+
queryClient.setQueryData(["walletStatusListener"], event);
|
|
77
|
+
},
|
|
78
|
+
[queryClient]
|
|
79
|
+
);
|
|
80
|
+
return _reactquery.useQuery.call(void 0, {
|
|
81
|
+
queryKey: ["walletStatusListener"],
|
|
82
|
+
queryFn: async () => {
|
|
83
|
+
await _chunk3LF3FGI6cjs.watchWalletStatus.call(void 0, client, newStatusUpdated);
|
|
84
|
+
return { key: "waiting-response" };
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/react/hook/useArticleUnlockStatus.ts
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
function useArticleUnlockStatus({ articleId }) {
|
|
93
|
+
const queryClient = _reactquery.useQueryClient.call(void 0, );
|
|
94
|
+
const client = useNexusClient();
|
|
95
|
+
const newStatusUpdated = _react.useCallback.call(void 0,
|
|
96
|
+
(event) => {
|
|
97
|
+
queryClient.setQueryData(
|
|
98
|
+
["articleUnlockStatusListener", _nullishCoalesce(articleId, () => ( "no-article-id"))],
|
|
99
|
+
event
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
[articleId, queryClient]
|
|
103
|
+
);
|
|
104
|
+
return _reactquery.useQuery.call(void 0, {
|
|
105
|
+
queryKey: ["articleUnlockStatusListener", _nullishCoalesce(articleId, () => ( "no-article-id"))],
|
|
106
|
+
queryFn: async () => {
|
|
107
|
+
await _chunk3LF3FGI6cjs.watchUnlockStatus.call(void 0, client, { articleId }, newStatusUpdated);
|
|
108
|
+
return {
|
|
109
|
+
status: "waiting-response",
|
|
110
|
+
key: "waiting-response"
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
enabled: !!articleId
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/react/provider/NexusIFrameClientProvider.ts
|
|
118
|
+
var NexusIFrameClientContext = _react.createContext.call(void 0,
|
|
119
|
+
void 0
|
|
120
|
+
);
|
|
121
|
+
function NexusIFrameClientProvider({
|
|
122
|
+
children
|
|
123
|
+
}) {
|
|
124
|
+
const config = useNexusConfig();
|
|
125
|
+
const [iframeElem, setIframElem] = _react.useState.call(void 0,
|
|
126
|
+
void 0
|
|
127
|
+
);
|
|
128
|
+
const client = _react.useMemo.call(void 0,
|
|
129
|
+
() => iframeElem ? _chunkJXQKTLEEcjs.createIFrameNexusClient.call(void 0, { iframe: iframeElem, config }) : void 0,
|
|
130
|
+
[iframeElem, config]
|
|
131
|
+
);
|
|
132
|
+
const iFrame = _react.createElement.call(void 0, "iframe", {
|
|
133
|
+
id: "nexus-wallet",
|
|
134
|
+
name: "nexus-wallet",
|
|
135
|
+
src: `${config.walletUrl}/listener`,
|
|
136
|
+
style: {
|
|
137
|
+
width: "0",
|
|
138
|
+
height: "0",
|
|
139
|
+
border: "0",
|
|
140
|
+
position: "absolute",
|
|
141
|
+
top: "-1000px",
|
|
142
|
+
left: "-1000px"
|
|
143
|
+
},
|
|
144
|
+
ref: (iframe) => {
|
|
145
|
+
if (!iframe) {
|
|
146
|
+
setIframElem(void 0);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
setIframElem(iframe);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
const providerComponent = _react.createElement.call(void 0,
|
|
153
|
+
NexusIFrameClientContext.Provider,
|
|
154
|
+
{ value: client },
|
|
155
|
+
children
|
|
156
|
+
);
|
|
157
|
+
return _react.createElement.call(void 0, _react.Fragment, null, iFrame, providerComponent);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
exports.NexusConfigContext = NexusConfigContext; exports.NexusConfigProvider = NexusConfigProvider; exports.NexusIFrameClientContext = NexusIFrameClientContext; exports.NexusIFrameClientProvider = NexusIFrameClientProvider; exports.useArticleUnlockOptions = useArticleUnlockOptions; exports.useArticleUnlockStatus = useArticleUnlockStatus; exports.useNexusClient = useNexusClient; exports.useNexusConfig = useNexusConfig; exports.useWalletStatus = useWalletStatus;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-gnNyzrko.cjs';
|
|
4
|
+
import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types';
|
|
5
|
+
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-DvDS55TN.cjs';
|
|
6
|
+
import 'viem';
|
|
7
|
+
import 'viem/chains';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The context that will keep the Nexus Wallet SDK configuration
|
|
11
|
+
*/
|
|
12
|
+
declare const NexusConfigContext: react.Context<Readonly<{
|
|
13
|
+
walletUrl: string;
|
|
14
|
+
contentId: `0x${string}`;
|
|
15
|
+
contentTitle: string;
|
|
16
|
+
}> | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
19
|
+
*/
|
|
20
|
+
type NexusConfigProviderProps = {
|
|
21
|
+
config: NexusWalletSdkConfig;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Simple config provider for the Nexus Wallet SDK
|
|
25
|
+
* @param parameters
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
29
|
+
walletUrl: string;
|
|
30
|
+
contentId: `0x${string}`;
|
|
31
|
+
contentTitle: string;
|
|
32
|
+
}> | undefined>>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The context that will keep the Nexus Wallet SDK client
|
|
36
|
+
*/
|
|
37
|
+
declare const NexusIFrameClientContext: react.Context<NexusClient | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
40
|
+
*/
|
|
41
|
+
type NexusIFrameClientProps = {
|
|
42
|
+
config: NexusWalletSdkConfig;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* IFrame client provider for the Nexus Wallet SDK
|
|
46
|
+
* - Automatically set the config provider
|
|
47
|
+
* @param parameters
|
|
48
|
+
* @constructor
|
|
49
|
+
*/
|
|
50
|
+
declare function NexusIFrameClientProvider({ children, }: {
|
|
51
|
+
children?: ReactNode;
|
|
52
|
+
}): react.FunctionComponentElement<{
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Use the current nexus config
|
|
58
|
+
*/
|
|
59
|
+
declare function useNexusConfig(): Readonly<{
|
|
60
|
+
walletUrl: string;
|
|
61
|
+
contentId: `0x${string}`;
|
|
62
|
+
contentTitle: string;
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Use the current nexus iframe client
|
|
67
|
+
*/
|
|
68
|
+
declare function useNexusClient(): NexusClient;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Hook used to get the unlock options for an article
|
|
72
|
+
*/
|
|
73
|
+
declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query_build_legacy_types.UseQueryResult<Readonly<{
|
|
74
|
+
prices: {
|
|
75
|
+
index: number;
|
|
76
|
+
unlockDurationInSec: number;
|
|
77
|
+
frkAmount: `0x${string}`;
|
|
78
|
+
isUserAccessible: boolean | null;
|
|
79
|
+
}[];
|
|
80
|
+
}>, Error>;
|
|
81
|
+
|
|
82
|
+
type WalletStatusQueryReturnType = WalletStatusReturnType | {
|
|
83
|
+
key: "waiting-response";
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Hooks used to listen to the current wallet status
|
|
87
|
+
*/
|
|
88
|
+
declare function useWalletStatus(): _tanstack_react_query_build_legacy_types.UseQueryResult<WalletStatusQueryReturnType, Error>;
|
|
89
|
+
|
|
90
|
+
type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
|
|
91
|
+
status: "waiting-response";
|
|
92
|
+
key: "waiting-response";
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Hooks used to listen to the current wallet status
|
|
96
|
+
*/
|
|
97
|
+
declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query_build_legacy_types.UseQueryResult<ArticleUnlockStatusQueryReturnType, Error>;
|
|
98
|
+
|
|
99
|
+
export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
+
import { a as NexusWalletSdkConfig, N as NexusClient, W as WalletStatusReturnType, A as ArticleUnlockStatusReturnType } from '../client-gnNyzrko.js';
|
|
4
|
+
import * as _tanstack_react_query_build_legacy_types from '@tanstack/react-query/build/legacy/types';
|
|
5
|
+
import { G as GetUnlockOptionsParams, W as WatchUnlockStatusParams } from '../watchUnlockStatus-Btjg-WTs.js';
|
|
6
|
+
import 'viem';
|
|
7
|
+
import 'viem/chains';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The context that will keep the Nexus Wallet SDK configuration
|
|
11
|
+
*/
|
|
12
|
+
declare const NexusConfigContext: react.Context<Readonly<{
|
|
13
|
+
walletUrl: string;
|
|
14
|
+
contentId: `0x${string}`;
|
|
15
|
+
contentTitle: string;
|
|
16
|
+
}> | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
19
|
+
*/
|
|
20
|
+
type NexusConfigProviderProps = {
|
|
21
|
+
config: NexusWalletSdkConfig;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Simple config provider for the Nexus Wallet SDK
|
|
25
|
+
* @param parameters
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
declare function NexusConfigProvider(parameters: PropsWithChildren<NexusConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<Readonly<{
|
|
29
|
+
walletUrl: string;
|
|
30
|
+
contentId: `0x${string}`;
|
|
31
|
+
contentTitle: string;
|
|
32
|
+
}> | undefined>>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The context that will keep the Nexus Wallet SDK client
|
|
36
|
+
*/
|
|
37
|
+
declare const NexusIFrameClientContext: react.Context<NexusClient | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Props to instantiate the Nexus Wallet SDK configuration provider
|
|
40
|
+
*/
|
|
41
|
+
type NexusIFrameClientProps = {
|
|
42
|
+
config: NexusWalletSdkConfig;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* IFrame client provider for the Nexus Wallet SDK
|
|
46
|
+
* - Automatically set the config provider
|
|
47
|
+
* @param parameters
|
|
48
|
+
* @constructor
|
|
49
|
+
*/
|
|
50
|
+
declare function NexusIFrameClientProvider({ children, }: {
|
|
51
|
+
children?: ReactNode;
|
|
52
|
+
}): react.FunctionComponentElement<{
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Use the current nexus config
|
|
58
|
+
*/
|
|
59
|
+
declare function useNexusConfig(): Readonly<{
|
|
60
|
+
walletUrl: string;
|
|
61
|
+
contentId: `0x${string}`;
|
|
62
|
+
contentTitle: string;
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Use the current nexus iframe client
|
|
67
|
+
*/
|
|
68
|
+
declare function useNexusClient(): NexusClient;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Hook used to get the unlock options for an article
|
|
72
|
+
*/
|
|
73
|
+
declare function useArticleUnlockOptions({ articleId }: GetUnlockOptionsParams): _tanstack_react_query_build_legacy_types.UseQueryResult<Readonly<{
|
|
74
|
+
prices: {
|
|
75
|
+
index: number;
|
|
76
|
+
unlockDurationInSec: number;
|
|
77
|
+
frkAmount: `0x${string}`;
|
|
78
|
+
isUserAccessible: boolean | null;
|
|
79
|
+
}[];
|
|
80
|
+
}>, Error>;
|
|
81
|
+
|
|
82
|
+
type WalletStatusQueryReturnType = WalletStatusReturnType | {
|
|
83
|
+
key: "waiting-response";
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Hooks used to listen to the current wallet status
|
|
87
|
+
*/
|
|
88
|
+
declare function useWalletStatus(): _tanstack_react_query_build_legacy_types.UseQueryResult<WalletStatusQueryReturnType, Error>;
|
|
89
|
+
|
|
90
|
+
type ArticleUnlockStatusQueryReturnType = ArticleUnlockStatusReturnType | {
|
|
91
|
+
status: "waiting-response";
|
|
92
|
+
key: "waiting-response";
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Hooks used to listen to the current wallet status
|
|
96
|
+
*/
|
|
97
|
+
declare function useArticleUnlockStatus({ articleId }: WatchUnlockStatusParams): _tanstack_react_query_build_legacy_types.UseQueryResult<ArticleUnlockStatusQueryReturnType, Error>;
|
|
98
|
+
|
|
99
|
+
export { type ArticleUnlockStatusQueryReturnType, NexusConfigContext, NexusConfigProvider, type NexusConfigProviderProps, NexusIFrameClientContext, type NexusIFrameClientProps, NexusIFrameClientProvider, type WalletStatusQueryReturnType, useArticleUnlockOptions, useArticleUnlockStatus, useNexusClient, useNexusConfig, useWalletStatus };
|