@bbuilders/djeon402-sdk-client 1.0.1

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.
@@ -0,0 +1,339 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { Hex, Address, WalletClient, PublicClient, Chain } from 'viem';
4
+ import * as _bbuilders_djeon402_core from '@bbuilders/djeon402-core';
5
+ import { RolesResult, RoleCheckResult, TransferResult, KYCData, TokenInfo, BalanceResult, AllowanceResult, TransferAuthorizationSignature, ReceiveAuthorizationSignature, CancelAuthorizationResult, ClientSDKConfig } from '@bbuilders/djeon402-core';
6
+ import * as _tanstack_react_query from '@tanstack/react-query';
7
+
8
+ declare class AdminModule {
9
+ private sdk;
10
+ constructor(sdk: Djeon402ClientSDK);
11
+ /**
12
+ * Get role hashes
13
+ */
14
+ getRoles(): Promise<RolesResult>;
15
+ /**
16
+ * Check if address has role
17
+ */
18
+ hasRole(role: Hex, account: Address): Promise<RoleCheckResult>;
19
+ /**
20
+ * Check if address is blacklisted
21
+ */
22
+ isBlacklisted(account: Address): Promise<{
23
+ isBlacklisted: boolean;
24
+ address: Address;
25
+ }>;
26
+ /**
27
+ * Blacklist an address
28
+ */
29
+ blacklist(params: {
30
+ walletClient: WalletClient;
31
+ account: Address;
32
+ }): Promise<TransferResult>;
33
+ /**
34
+ * Remove from blacklist
35
+ */
36
+ unBlacklist(params: {
37
+ walletClient: WalletClient;
38
+ account: Address;
39
+ }): Promise<TransferResult>;
40
+ /**
41
+ * Pause contract
42
+ */
43
+ pause(params: {
44
+ walletClient: WalletClient;
45
+ }): Promise<TransferResult>;
46
+ /**
47
+ * Unpause contract
48
+ */
49
+ unpause(params: {
50
+ walletClient: WalletClient;
51
+ }): Promise<TransferResult>;
52
+ }
53
+
54
+ declare class KYCModule {
55
+ private sdk;
56
+ constructor(sdk: Djeon402ClientSDK);
57
+ /**
58
+ * Get KYC data for an address
59
+ */
60
+ getData(address: Address): Promise<KYCData>;
61
+ /**
62
+ * Get remaining daily limit
63
+ */
64
+ getRemainingLimit(address: Address): Promise<{
65
+ address: `0x${string}`;
66
+ remainingLimit: string;
67
+ }>;
68
+ /**
69
+ * Verify KYC (admin only)
70
+ */
71
+ verify(params: {
72
+ walletClient: WalletClient;
73
+ userAddress: Address;
74
+ level: number;
75
+ expiryDate: number;
76
+ documentHash: string;
77
+ }): Promise<TransferResult>;
78
+ /**
79
+ * Update KYC level (admin only)
80
+ */
81
+ updateKYC(params: {
82
+ walletClient: WalletClient;
83
+ userAddress: Address;
84
+ level: number;
85
+ expiryDate?: number;
86
+ }): Promise<TransferResult>;
87
+ /**
88
+ * Revoke KYC (admin only)
89
+ */
90
+ revokeKYC(params: {
91
+ walletClient: WalletClient;
92
+ userAddress: Address;
93
+ }): Promise<TransferResult>;
94
+ /**
95
+ * Set daily limit for a user (admin only)
96
+ */
97
+ setDailyLimit(params: {
98
+ walletClient: WalletClient;
99
+ userAddress: Address;
100
+ limitUSD: string;
101
+ }): Promise<TransferResult>;
102
+ /**
103
+ * Check if a transaction amount is within the user's daily limit
104
+ */
105
+ checkDailyLimit(params: {
106
+ walletClient: WalletClient;
107
+ userAddress: Address;
108
+ amountUSD: string;
109
+ }): Promise<boolean>;
110
+ /**
111
+ * Check if a user's KYC is valid (view)
112
+ */
113
+ isKYCValid(userAddress: Address): Promise<boolean>;
114
+ }
115
+
116
+ declare class TokenModule {
117
+ private sdk;
118
+ constructor(sdk: Djeon402ClientSDK);
119
+ /**
120
+ * Get token information
121
+ */
122
+ getInfo(): Promise<TokenInfo>;
123
+ /**
124
+ * Get balance of an address
125
+ */
126
+ getBalance(address: Address): Promise<BalanceResult>;
127
+ /**
128
+ * Get allowance
129
+ */
130
+ getAllowance(owner: Address, spender: Address): Promise<AllowanceResult>;
131
+ /**
132
+ * Transfer tokens using wallet client
133
+ */
134
+ transfer(params: {
135
+ walletClient: WalletClient;
136
+ to: Address;
137
+ amount: string;
138
+ }): Promise<TransferResult>;
139
+ /**
140
+ * Approve spending
141
+ */
142
+ approve(params: {
143
+ walletClient: WalletClient;
144
+ spender: Address;
145
+ amount: string;
146
+ }): Promise<TransferResult>;
147
+ /**
148
+ * Mint tokens (requires MINTER_ROLE)
149
+ */
150
+ mint(params: {
151
+ walletClient: WalletClient;
152
+ to: Address;
153
+ amount: string;
154
+ }): Promise<TransferResult>;
155
+ /**
156
+ * Burn tokens (requires BURNER_ROLE)
157
+ */
158
+ burn(params: {
159
+ walletClient: WalletClient;
160
+ amount: string;
161
+ }): Promise<TransferResult>;
162
+ }
163
+
164
+ declare class X402Module {
165
+ private sdk;
166
+ constructor(sdk: Djeon402ClientSDK);
167
+ /**
168
+ * Generate a random nonce
169
+ */
170
+ generateNonce(): Hex;
171
+ /**
172
+ * Get EIP-712 domain separator
173
+ */
174
+ getDomainSeparator(): Promise<Hex>;
175
+ /**
176
+ * Get authorization state (whether a nonce has been used)
177
+ */
178
+ getAuthorizationState(authorizer: Address, nonce: Hex): Promise<boolean>;
179
+ /**
180
+ * Sign transfer authorization using wallet
181
+ */
182
+ signTransferWithWallet(params: {
183
+ walletClient: WalletClient;
184
+ to: Address;
185
+ amount: string;
186
+ validAfter?: bigint;
187
+ validBefore?: bigint;
188
+ nonce?: Hex;
189
+ }): Promise<TransferAuthorizationSignature>;
190
+ /**
191
+ * Sign receive authorization using wallet (receiver signs)
192
+ */
193
+ signReceiveWithWallet(params: {
194
+ walletClient: WalletClient;
195
+ from: Address;
196
+ amount: string;
197
+ validAfter?: bigint;
198
+ validBefore?: bigint;
199
+ nonce?: Hex;
200
+ }): Promise<ReceiveAuthorizationSignature>;
201
+ /**
202
+ * Execute receive with authorization (caller must be the receiver)
203
+ */
204
+ executeReceive(params: {
205
+ walletClient: WalletClient;
206
+ authorization: ReceiveAuthorizationSignature;
207
+ }): Promise<TransferResult>;
208
+ /**
209
+ * Sign cancel authorization using wallet
210
+ */
211
+ signCancelWithWallet(params: {
212
+ walletClient: WalletClient;
213
+ authorizer: Address;
214
+ nonce: Hex;
215
+ }): Promise<{
216
+ authorizer: Address;
217
+ nonce: Hex;
218
+ v: number;
219
+ r: Hex;
220
+ s: Hex;
221
+ }>;
222
+ /**
223
+ * Cancel an authorization (marks nonce as used)
224
+ */
225
+ cancelAuthorization(params: {
226
+ walletClient: WalletClient;
227
+ authorizer: Address;
228
+ nonce: Hex;
229
+ }): Promise<CancelAuthorizationResult>;
230
+ /**
231
+ * Execute transfer with authorization (relayer function)
232
+ */
233
+ executeTransfer(params: {
234
+ walletClient: WalletClient;
235
+ authorization: TransferAuthorizationSignature;
236
+ }): Promise<TransferResult>;
237
+ /**
238
+ * Fetch wrapper that auto-handles 402 Payment Required responses.
239
+ * On 402, decodes PAYMENT-REQUIRED header, signs authorization, retries with PAYMENT-SIGNATURE.
240
+ */
241
+ fetchWithPayment(walletClient: WalletClient, url: string, options?: RequestInit): Promise<Response>;
242
+ }
243
+
244
+ /**
245
+ * DJEON402 Client SDK for browsers
246
+ * Works with wallet providers (MetaMask, WalletConnect, etc.)
247
+ */
248
+ declare class Djeon402ClientSDK {
249
+ readonly publicClient: PublicClient;
250
+ readonly contractAddress: Address;
251
+ readonly kycRegistryAddress?: Address;
252
+ readonly chainId: number;
253
+ readonly token: TokenModule;
254
+ readonly admin: AdminModule;
255
+ readonly kyc: KYCModule;
256
+ readonly x402: X402Module;
257
+ constructor(config: ClientSDKConfig);
258
+ /**
259
+ * Get chain configuration
260
+ */
261
+ getChain(): Chain;
262
+ }
263
+
264
+ interface Djeon402Config {
265
+ contractAddress: Address;
266
+ kycRegistryAddress?: Address;
267
+ chainId: number;
268
+ rpcUrl?: string;
269
+ }
270
+ interface Djeon402ContextValue {
271
+ sdk: Djeon402ClientSDK;
272
+ config: Djeon402Config;
273
+ }
274
+ declare function Djeon402Provider({ children, config, }: {
275
+ children: ReactNode;
276
+ config: Djeon402Config;
277
+ }): react_jsx_runtime.JSX.Element;
278
+ declare function useDjeon402(): Djeon402ContextValue;
279
+
280
+ declare function useApprove(): {
281
+ approve: _tanstack_react_query.UseMutateAsyncFunction<_bbuilders_djeon402_core.TransferResult, Error, {
282
+ spender: Address;
283
+ amount: string;
284
+ }, unknown>;
285
+ isLoading: boolean;
286
+ isSuccess: boolean;
287
+ error: Error | null;
288
+ data: _bbuilders_djeon402_core.TransferResult | undefined;
289
+ };
290
+
291
+ declare function useBalance(address?: Address): _tanstack_react_query.UseQueryResult<_bbuilders_djeon402_core.BalanceResult, Error>;
292
+
293
+ declare function useIsBlacklisted(address?: Address): _tanstack_react_query.UseQueryResult<{
294
+ isBlacklisted: boolean;
295
+ address: Address;
296
+ }, Error>;
297
+
298
+ declare function useKYCData(address?: Address): _tanstack_react_query.UseQueryResult<_bbuilders_djeon402_core.KYCData, Error>;
299
+
300
+ declare function useTokenInfo(): _tanstack_react_query.UseQueryResult<_bbuilders_djeon402_core.TokenInfo, Error>;
301
+
302
+ declare function useTransfer(): {
303
+ transfer: _tanstack_react_query.UseMutateAsyncFunction<_bbuilders_djeon402_core.TransferResult, Error, {
304
+ to: Address;
305
+ amount: string;
306
+ }, unknown>;
307
+ isLoading: boolean;
308
+ isSuccess: boolean;
309
+ error: Error | null;
310
+ data: _bbuilders_djeon402_core.TransferResult | undefined;
311
+ };
312
+
313
+ declare function useX402Receive(): {
314
+ signReceive: _tanstack_react_query.UseMutateAsyncFunction<_bbuilders_djeon402_core.ReceiveAuthorizationSignature, Error, {
315
+ from: Address;
316
+ amount: string;
317
+ validAfter?: bigint;
318
+ validBefore?: bigint;
319
+ }, unknown>;
320
+ isLoading: boolean;
321
+ isSuccess: boolean;
322
+ error: Error | null;
323
+ authorization: _bbuilders_djeon402_core.ReceiveAuthorizationSignature | undefined;
324
+ };
325
+
326
+ declare function useX402Transfer(): {
327
+ signTransfer: _tanstack_react_query.UseMutateAsyncFunction<_bbuilders_djeon402_core.TransferAuthorizationSignature, Error, {
328
+ to: Address;
329
+ amount: string;
330
+ validAfter?: bigint;
331
+ validBefore?: bigint;
332
+ }, unknown>;
333
+ isLoading: boolean;
334
+ isSuccess: boolean;
335
+ error: Error | null;
336
+ authorization: _bbuilders_djeon402_core.TransferAuthorizationSignature | undefined;
337
+ };
338
+
339
+ export { Djeon402Provider, useApprove, useBalance, useDjeon402, useIsBlacklisted, useKYCData, useTokenInfo, useTransfer, useX402Receive, useX402Transfer };