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