@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,1333 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/vue/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ provideDjeon402: () => provideDjeon402,
24
+ useApprove: () => useApprove,
25
+ useBalance: () => useBalance,
26
+ useDjeon402: () => useDjeon402,
27
+ useIsBlacklisted: () => useIsBlacklisted,
28
+ useKYCData: () => useKYCData,
29
+ useTokenInfo: () => useTokenInfo,
30
+ useTransfer: () => useTransfer,
31
+ useX402Receive: () => useX402Receive,
32
+ useX402Transfer: () => useX402Transfer
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+
36
+ // src/vue/useApprove.ts
37
+ var import_vue2 = require("vue");
38
+
39
+ // src/vue/useDjeon402.ts
40
+ var import_vue = require("vue");
41
+
42
+ // src/client.ts
43
+ var import_viem = require("viem");
44
+ var import_chains = require("viem/chains");
45
+
46
+ // src/modules/admin.ts
47
+ var import_djeon402_core = require("@bbuilders/djeon402-core");
48
+ var AdminModule = class {
49
+ constructor(sdk) {
50
+ this.sdk = sdk;
51
+ }
52
+ /**
53
+ * Get role hashes
54
+ */
55
+ async getRoles() {
56
+ const [minter, burner, pauser, blacklister, admin] = await Promise.all([
57
+ this.sdk.publicClient.readContract({
58
+ address: this.sdk.contractAddress,
59
+ abi: import_djeon402_core.DJEON402_ABI,
60
+ functionName: "MINTER_ROLE"
61
+ }),
62
+ this.sdk.publicClient.readContract({
63
+ address: this.sdk.contractAddress,
64
+ abi: import_djeon402_core.DJEON402_ABI,
65
+ functionName: "BURNER_ROLE"
66
+ }),
67
+ this.sdk.publicClient.readContract({
68
+ address: this.sdk.contractAddress,
69
+ abi: import_djeon402_core.DJEON402_ABI,
70
+ functionName: "PAUSER_ROLE"
71
+ }),
72
+ this.sdk.publicClient.readContract({
73
+ address: this.sdk.contractAddress,
74
+ abi: import_djeon402_core.DJEON402_ABI,
75
+ functionName: "BLACKLISTER_ROLE"
76
+ }),
77
+ this.sdk.publicClient.readContract({
78
+ address: this.sdk.contractAddress,
79
+ abi: import_djeon402_core.DJEON402_ABI,
80
+ functionName: "DEFAULT_ADMIN_ROLE"
81
+ })
82
+ ]);
83
+ return {
84
+ MINTER_ROLE: minter,
85
+ BURNER_ROLE: burner,
86
+ PAUSER_ROLE: pauser,
87
+ BLACKLISTER_ROLE: blacklister,
88
+ DEFAULT_ADMIN_ROLE: admin
89
+ };
90
+ }
91
+ /**
92
+ * Check if address has role
93
+ */
94
+ async hasRole(role, account) {
95
+ (0, import_djeon402_core.validateAddress)(account);
96
+ const result = await this.sdk.publicClient.readContract({
97
+ address: this.sdk.contractAddress,
98
+ abi: import_djeon402_core.DJEON402_ABI,
99
+ functionName: "hasRole",
100
+ args: [role, account]
101
+ });
102
+ return {
103
+ role,
104
+ address: account,
105
+ hasRole: result
106
+ };
107
+ }
108
+ /**
109
+ * Check if address is blacklisted
110
+ */
111
+ async isBlacklisted(account) {
112
+ (0, import_djeon402_core.validateAddress)(account);
113
+ const isBlacklisted = await this.sdk.publicClient.readContract({
114
+ address: this.sdk.contractAddress,
115
+ abi: import_djeon402_core.DJEON402_ABI,
116
+ functionName: "isBlacklisted",
117
+ args: [account]
118
+ });
119
+ return {
120
+ isBlacklisted,
121
+ address: account
122
+ };
123
+ }
124
+ /**
125
+ * Blacklist an address
126
+ */
127
+ async blacklist(params) {
128
+ const { walletClient, account } = params;
129
+ if (!walletClient.account) {
130
+ throw new Error("Wallet client must have an account");
131
+ }
132
+ (0, import_djeon402_core.validateAddress)(account);
133
+ const hash = await walletClient.writeContract({
134
+ address: this.sdk.contractAddress,
135
+ abi: import_djeon402_core.DJEON402_ABI,
136
+ functionName: "blacklist",
137
+ args: [account],
138
+ account: walletClient.account,
139
+ chain: walletClient.chain
140
+ });
141
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
142
+ return {
143
+ success: receipt.status === "success",
144
+ hash,
145
+ blockNumber: receipt.blockNumber.toString()
146
+ };
147
+ }
148
+ /**
149
+ * Remove from blacklist
150
+ */
151
+ async unBlacklist(params) {
152
+ const { walletClient, account } = params;
153
+ if (!walletClient.account) {
154
+ throw new Error("Wallet client must have an account");
155
+ }
156
+ (0, import_djeon402_core.validateAddress)(account);
157
+ const hash = await walletClient.writeContract({
158
+ address: this.sdk.contractAddress,
159
+ abi: import_djeon402_core.DJEON402_ABI,
160
+ functionName: "unBlacklist",
161
+ args: [account],
162
+ account: walletClient.account,
163
+ chain: walletClient.chain
164
+ });
165
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
166
+ return {
167
+ success: receipt.status === "success",
168
+ hash,
169
+ blockNumber: receipt.blockNumber.toString()
170
+ };
171
+ }
172
+ /**
173
+ * Pause contract
174
+ */
175
+ async pause(params) {
176
+ const { walletClient } = params;
177
+ if (!walletClient.account) {
178
+ throw new Error("Wallet client must have an account");
179
+ }
180
+ const hash = await walletClient.writeContract({
181
+ address: this.sdk.contractAddress,
182
+ abi: import_djeon402_core.DJEON402_ABI,
183
+ functionName: "pause",
184
+ account: walletClient.account,
185
+ chain: walletClient.chain
186
+ });
187
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
188
+ return {
189
+ success: receipt.status === "success",
190
+ hash,
191
+ blockNumber: receipt.blockNumber.toString()
192
+ };
193
+ }
194
+ /**
195
+ * Unpause contract
196
+ */
197
+ async unpause(params) {
198
+ const { walletClient } = params;
199
+ if (!walletClient.account) {
200
+ throw new Error("Wallet client must have an account");
201
+ }
202
+ const hash = await walletClient.writeContract({
203
+ address: this.sdk.contractAddress,
204
+ abi: import_djeon402_core.DJEON402_ABI,
205
+ functionName: "unpause",
206
+ account: walletClient.account,
207
+ chain: walletClient.chain
208
+ });
209
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
210
+ return {
211
+ success: receipt.status === "success",
212
+ hash,
213
+ blockNumber: receipt.blockNumber.toString()
214
+ };
215
+ }
216
+ };
217
+
218
+ // src/modules/kyc.ts
219
+ var import_djeon402_core2 = require("@bbuilders/djeon402-core");
220
+ var KYCModule = class {
221
+ constructor(sdk) {
222
+ this.sdk = sdk;
223
+ }
224
+ /**
225
+ * Get KYC data for an address
226
+ */
227
+ async getData(address) {
228
+ if (!this.sdk.kycRegistryAddress) {
229
+ throw new Error("KYC Registry address not configured");
230
+ }
231
+ (0, import_djeon402_core2.validateAddress)(address);
232
+ const kycData = await this.sdk.publicClient.readContract({
233
+ address: this.sdk.kycRegistryAddress,
234
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
235
+ functionName: "getKYCData",
236
+ args: [address]
237
+ });
238
+ const result = kycData;
239
+ const [level, expiryDate, kycHash, isActive, dailyLimit, dailySpent] = result;
240
+ const levelNames = ["None", "Tier1", "Tier2", "Tier3"];
241
+ const expiryDateReadable = new Date(Number(expiryDate) * 1e3).toISOString();
242
+ return {
243
+ level,
244
+ levelName: levelNames[level],
245
+ expiryDate: Number(expiryDate),
246
+ expiryDateReadable,
247
+ kycHash,
248
+ isActive,
249
+ dailyLimit: dailyLimit.toString(),
250
+ dailyLimitRaw: dailyLimit.toString(),
251
+ dailySpent: dailySpent.toString(),
252
+ dailySpentRaw: dailySpent.toString(),
253
+ userAddress: address
254
+ };
255
+ }
256
+ /**
257
+ * Get remaining daily limit
258
+ */
259
+ async getRemainingLimit(address) {
260
+ if (!this.sdk.kycRegistryAddress) {
261
+ throw new Error("KYC Registry address not configured");
262
+ }
263
+ (0, import_djeon402_core2.validateAddress)(address);
264
+ const remaining = await this.sdk.publicClient.readContract({
265
+ address: this.sdk.kycRegistryAddress,
266
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
267
+ functionName: "getRemainingDailyLimit",
268
+ args: [address]
269
+ });
270
+ return {
271
+ address,
272
+ remainingLimit: remaining.toString()
273
+ };
274
+ }
275
+ /**
276
+ * Verify KYC (admin only)
277
+ */
278
+ async verify(params) {
279
+ if (!this.sdk.kycRegistryAddress) {
280
+ throw new Error("KYC Registry address not configured");
281
+ }
282
+ const { walletClient, userAddress, level, expiryDate, documentHash } = params;
283
+ if (!walletClient.account) {
284
+ throw new Error("Wallet client must have an account");
285
+ }
286
+ (0, import_djeon402_core2.validateAddress)(userAddress);
287
+ if (level < 0 || level > 3) {
288
+ throw new Error("Invalid KYC level. Must be 0-3");
289
+ }
290
+ const hash = await walletClient.writeContract({
291
+ address: this.sdk.kycRegistryAddress,
292
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
293
+ functionName: "verifyKYC",
294
+ args: [userAddress, level, BigInt(expiryDate), documentHash],
295
+ account: walletClient.account,
296
+ chain: walletClient.chain
297
+ });
298
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
299
+ return {
300
+ success: receipt.status === "success",
301
+ hash,
302
+ blockNumber: receipt.blockNumber.toString()
303
+ };
304
+ }
305
+ /**
306
+ * Update KYC level (admin only)
307
+ */
308
+ async updateKYC(params) {
309
+ if (!this.sdk.kycRegistryAddress) {
310
+ throw new Error("KYC Registry address not configured");
311
+ }
312
+ const { walletClient, userAddress, level, expiryDate = 0 } = params;
313
+ if (!walletClient.account) {
314
+ throw new Error("Wallet client must have an account");
315
+ }
316
+ (0, import_djeon402_core2.validateAddress)(userAddress);
317
+ const hash = await walletClient.writeContract({
318
+ address: this.sdk.kycRegistryAddress,
319
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
320
+ functionName: "updateKYC",
321
+ args: [userAddress, level, BigInt(expiryDate)],
322
+ account: walletClient.account,
323
+ chain: walletClient.chain
324
+ });
325
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
326
+ return {
327
+ success: receipt.status === "success",
328
+ hash,
329
+ blockNumber: receipt.blockNumber.toString()
330
+ };
331
+ }
332
+ /**
333
+ * Revoke KYC (admin only)
334
+ */
335
+ async revokeKYC(params) {
336
+ if (!this.sdk.kycRegistryAddress) {
337
+ throw new Error("KYC Registry address not configured");
338
+ }
339
+ const { walletClient, userAddress } = params;
340
+ if (!walletClient.account) {
341
+ throw new Error("Wallet client must have an account");
342
+ }
343
+ (0, import_djeon402_core2.validateAddress)(userAddress);
344
+ const hash = await walletClient.writeContract({
345
+ address: this.sdk.kycRegistryAddress,
346
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
347
+ functionName: "revokeKYC",
348
+ args: [userAddress],
349
+ account: walletClient.account,
350
+ chain: walletClient.chain
351
+ });
352
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
353
+ return {
354
+ success: receipt.status === "success",
355
+ hash,
356
+ blockNumber: receipt.blockNumber.toString()
357
+ };
358
+ }
359
+ /**
360
+ * Set daily limit for a user (admin only)
361
+ */
362
+ async setDailyLimit(params) {
363
+ if (!this.sdk.kycRegistryAddress) {
364
+ throw new Error("KYC Registry address not configured");
365
+ }
366
+ const { walletClient, userAddress, limitUSD } = params;
367
+ if (!walletClient.account) {
368
+ throw new Error("Wallet client must have an account");
369
+ }
370
+ (0, import_djeon402_core2.validateAddress)(userAddress);
371
+ const limitInSmallestUnit = BigInt(parseFloat(limitUSD) * 1e6);
372
+ const hash = await walletClient.writeContract({
373
+ address: this.sdk.kycRegistryAddress,
374
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
375
+ functionName: "setDailyLimit",
376
+ args: [userAddress, limitInSmallestUnit],
377
+ account: walletClient.account,
378
+ chain: walletClient.chain
379
+ });
380
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
381
+ return {
382
+ success: receipt.status === "success",
383
+ hash,
384
+ blockNumber: receipt.blockNumber.toString()
385
+ };
386
+ }
387
+ /**
388
+ * Check if a transaction amount is within the user's daily limit
389
+ */
390
+ async checkDailyLimit(params) {
391
+ if (!this.sdk.kycRegistryAddress) {
392
+ throw new Error("KYC Registry address not configured");
393
+ }
394
+ const { walletClient, userAddress, amountUSD } = params;
395
+ if (!walletClient.account) {
396
+ throw new Error("Wallet client must have an account");
397
+ }
398
+ (0, import_djeon402_core2.validateAddress)(userAddress);
399
+ const amountInSmallestUnit = BigInt(parseFloat(amountUSD) * 1e6);
400
+ const result = await walletClient.writeContract({
401
+ address: this.sdk.kycRegistryAddress,
402
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
403
+ functionName: "checkDailyLimit",
404
+ args: [userAddress, amountInSmallestUnit],
405
+ account: walletClient.account,
406
+ chain: walletClient.chain
407
+ });
408
+ return result;
409
+ }
410
+ /**
411
+ * Check if a user's KYC is valid (view)
412
+ */
413
+ async isKYCValid(userAddress) {
414
+ if (!this.sdk.kycRegistryAddress) {
415
+ throw new Error("KYC Registry address not configured");
416
+ }
417
+ (0, import_djeon402_core2.validateAddress)(userAddress);
418
+ const result = await this.sdk.publicClient.readContract({
419
+ address: this.sdk.kycRegistryAddress,
420
+ abi: import_djeon402_core2.KYC_REGISTRY_ABI,
421
+ functionName: "isKYCValid",
422
+ args: [userAddress]
423
+ });
424
+ return result;
425
+ }
426
+ };
427
+
428
+ // src/modules/token.ts
429
+ var import_djeon402_core3 = require("@bbuilders/djeon402-core");
430
+ var TokenModule = class {
431
+ constructor(sdk) {
432
+ this.sdk = sdk;
433
+ }
434
+ /**
435
+ * Get token information
436
+ */
437
+ async getInfo() {
438
+ const [name, symbol, decimals, totalSupply, paused] = await Promise.all([
439
+ this.sdk.publicClient.readContract({
440
+ address: this.sdk.contractAddress,
441
+ abi: import_djeon402_core3.DJEON402_ABI,
442
+ functionName: "name"
443
+ }),
444
+ this.sdk.publicClient.readContract({
445
+ address: this.sdk.contractAddress,
446
+ abi: import_djeon402_core3.DJEON402_ABI,
447
+ functionName: "symbol"
448
+ }),
449
+ this.sdk.publicClient.readContract({
450
+ address: this.sdk.contractAddress,
451
+ abi: import_djeon402_core3.DJEON402_ABI,
452
+ functionName: "decimals"
453
+ }),
454
+ this.sdk.publicClient.readContract({
455
+ address: this.sdk.contractAddress,
456
+ abi: import_djeon402_core3.DJEON402_ABI,
457
+ functionName: "totalSupply"
458
+ }),
459
+ this.sdk.publicClient.readContract({
460
+ address: this.sdk.contractAddress,
461
+ abi: import_djeon402_core3.DJEON402_ABI,
462
+ functionName: "paused"
463
+ })
464
+ ]);
465
+ return {
466
+ name,
467
+ symbol,
468
+ decimals,
469
+ totalSupply: (0, import_djeon402_core3.formatTokenAmount)(totalSupply, decimals),
470
+ totalSupplyRaw: totalSupply.toString(),
471
+ paused,
472
+ contractAddress: this.sdk.contractAddress
473
+ };
474
+ }
475
+ /**
476
+ * Get balance of an address
477
+ */
478
+ async getBalance(address) {
479
+ (0, import_djeon402_core3.validateAddress)(address);
480
+ const [balance, decimals] = await Promise.all([
481
+ this.sdk.publicClient.readContract({
482
+ address: this.sdk.contractAddress,
483
+ abi: import_djeon402_core3.DJEON402_ABI,
484
+ functionName: "balanceOf",
485
+ args: [address]
486
+ }),
487
+ this.sdk.publicClient.readContract({
488
+ address: this.sdk.contractAddress,
489
+ abi: import_djeon402_core3.DJEON402_ABI,
490
+ functionName: "decimals"
491
+ })
492
+ ]);
493
+ return {
494
+ address,
495
+ balance: (0, import_djeon402_core3.formatTokenAmount)(balance, decimals),
496
+ balanceRaw: balance.toString()
497
+ };
498
+ }
499
+ /**
500
+ * Get allowance
501
+ */
502
+ async getAllowance(owner, spender) {
503
+ (0, import_djeon402_core3.validateAddress)(owner);
504
+ (0, import_djeon402_core3.validateAddress)(spender);
505
+ const [allowance, decimals] = await Promise.all([
506
+ this.sdk.publicClient.readContract({
507
+ address: this.sdk.contractAddress,
508
+ abi: import_djeon402_core3.DJEON402_ABI,
509
+ functionName: "allowance",
510
+ args: [owner, spender]
511
+ }),
512
+ this.sdk.publicClient.readContract({
513
+ address: this.sdk.contractAddress,
514
+ abi: import_djeon402_core3.DJEON402_ABI,
515
+ functionName: "decimals"
516
+ })
517
+ ]);
518
+ return {
519
+ owner,
520
+ spender,
521
+ allowance: (0, import_djeon402_core3.formatTokenAmount)(allowance, decimals),
522
+ allowanceRaw: allowance.toString()
523
+ };
524
+ }
525
+ /**
526
+ * Transfer tokens using wallet client
527
+ */
528
+ async transfer(params) {
529
+ const { walletClient, to, amount } = params;
530
+ if (!walletClient.account) {
531
+ throw new Error("Wallet client must have an account");
532
+ }
533
+ (0, import_djeon402_core3.validateAddress)(to);
534
+ (0, import_djeon402_core3.validateAmount)(amount);
535
+ const decimals = await this.sdk.publicClient.readContract({
536
+ address: this.sdk.contractAddress,
537
+ abi: import_djeon402_core3.DJEON402_ABI,
538
+ functionName: "decimals"
539
+ });
540
+ const amountBigInt = (0, import_djeon402_core3.parseTokenAmount)(amount, decimals);
541
+ const hash = await walletClient.writeContract({
542
+ address: this.sdk.contractAddress,
543
+ abi: import_djeon402_core3.DJEON402_ABI,
544
+ functionName: "transfer",
545
+ args: [to, amountBigInt],
546
+ account: walletClient.account,
547
+ chain: walletClient.chain
548
+ });
549
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({
550
+ hash
551
+ });
552
+ return {
553
+ success: receipt.status === "success",
554
+ hash,
555
+ from: walletClient.account.address,
556
+ to,
557
+ amount,
558
+ amountRaw: amountBigInt.toString(),
559
+ blockNumber: receipt.blockNumber.toString(),
560
+ status: receipt.status
561
+ };
562
+ }
563
+ /**
564
+ * Approve spending
565
+ */
566
+ async approve(params) {
567
+ const { walletClient, spender, amount } = params;
568
+ if (!walletClient.account) {
569
+ throw new Error("Wallet client must have an account");
570
+ }
571
+ (0, import_djeon402_core3.validateAddress)(spender);
572
+ (0, import_djeon402_core3.validateAmount)(amount);
573
+ const decimals = await this.sdk.publicClient.readContract({
574
+ address: this.sdk.contractAddress,
575
+ abi: import_djeon402_core3.DJEON402_ABI,
576
+ functionName: "decimals"
577
+ });
578
+ const amountBigInt = (0, import_djeon402_core3.parseTokenAmount)(amount, decimals);
579
+ const hash = await walletClient.writeContract({
580
+ address: this.sdk.contractAddress,
581
+ abi: import_djeon402_core3.DJEON402_ABI,
582
+ functionName: "approve",
583
+ args: [spender, amountBigInt],
584
+ account: walletClient.account,
585
+ chain: walletClient.chain
586
+ });
587
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
588
+ return {
589
+ success: receipt.status === "success",
590
+ hash,
591
+ blockNumber: receipt.blockNumber.toString()
592
+ };
593
+ }
594
+ /**
595
+ * Mint tokens (requires MINTER_ROLE)
596
+ */
597
+ async mint(params) {
598
+ const { walletClient, to, amount } = params;
599
+ if (!walletClient.account) {
600
+ throw new Error("Wallet client must have an account");
601
+ }
602
+ (0, import_djeon402_core3.validateAddress)(to);
603
+ (0, import_djeon402_core3.validateAmount)(amount);
604
+ const decimals = await this.sdk.publicClient.readContract({
605
+ address: this.sdk.contractAddress,
606
+ abi: import_djeon402_core3.DJEON402_ABI,
607
+ functionName: "decimals"
608
+ });
609
+ const amountBigInt = (0, import_djeon402_core3.parseTokenAmount)(amount, decimals);
610
+ const hash = await walletClient.writeContract({
611
+ address: this.sdk.contractAddress,
612
+ abi: import_djeon402_core3.DJEON402_ABI,
613
+ functionName: "mint",
614
+ args: [to, amountBigInt],
615
+ account: walletClient.account,
616
+ chain: walletClient.chain
617
+ });
618
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
619
+ return {
620
+ success: receipt.status === "success",
621
+ hash,
622
+ blockNumber: receipt.blockNumber.toString()
623
+ };
624
+ }
625
+ /**
626
+ * Burn tokens (requires BURNER_ROLE)
627
+ */
628
+ async burn(params) {
629
+ const { walletClient, amount } = params;
630
+ if (!walletClient.account) {
631
+ throw new Error("Wallet client must have an account");
632
+ }
633
+ (0, import_djeon402_core3.validateAmount)(amount);
634
+ const decimals = await this.sdk.publicClient.readContract({
635
+ address: this.sdk.contractAddress,
636
+ abi: import_djeon402_core3.DJEON402_ABI,
637
+ functionName: "decimals"
638
+ });
639
+ const amountBigInt = (0, import_djeon402_core3.parseTokenAmount)(amount, decimals);
640
+ const hash = await walletClient.writeContract({
641
+ address: this.sdk.contractAddress,
642
+ abi: import_djeon402_core3.DJEON402_ABI,
643
+ functionName: "burn",
644
+ args: [amountBigInt],
645
+ account: walletClient.account,
646
+ chain: walletClient.chain
647
+ });
648
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
649
+ return {
650
+ success: receipt.status === "success",
651
+ hash,
652
+ blockNumber: receipt.blockNumber.toString()
653
+ };
654
+ }
655
+ };
656
+
657
+ // src/modules/x402.ts
658
+ var import_djeon402_core4 = require("@bbuilders/djeon402-core");
659
+ var X402Module = class {
660
+ constructor(sdk) {
661
+ this.sdk = sdk;
662
+ }
663
+ /**
664
+ * Generate a random nonce
665
+ */
666
+ generateNonce() {
667
+ const randomBytes = new Uint8Array(32);
668
+ crypto.getRandomValues(randomBytes);
669
+ return `0x${Array.from(randomBytes).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
670
+ }
671
+ /**
672
+ * Get EIP-712 domain separator
673
+ */
674
+ async getDomainSeparator() {
675
+ const domain = await this.sdk.publicClient.readContract({
676
+ address: this.sdk.contractAddress,
677
+ abi: import_djeon402_core4.DJEON402_ABI,
678
+ functionName: "DOMAIN_SEPARATOR"
679
+ });
680
+ return domain;
681
+ }
682
+ /**
683
+ * Get authorization state (whether a nonce has been used)
684
+ */
685
+ async getAuthorizationState(authorizer, nonce) {
686
+ return await this.sdk.publicClient.readContract({
687
+ address: this.sdk.contractAddress,
688
+ abi: import_djeon402_core4.DJEON402_ABI,
689
+ functionName: "authorizationState",
690
+ args: [authorizer, nonce]
691
+ });
692
+ }
693
+ /**
694
+ * Sign transfer authorization using wallet
695
+ */
696
+ async signTransferWithWallet(params) {
697
+ const { walletClient, to, amount, validAfter = 0n, validBefore, nonce } = params;
698
+ if (!walletClient.account) {
699
+ throw new Error("Wallet client must have an account");
700
+ }
701
+ (0, import_djeon402_core4.validateAddress)(to);
702
+ (0, import_djeon402_core4.validateAmount)(amount);
703
+ const from = walletClient.account.address;
704
+ const decimals = await this.sdk.publicClient.readContract({
705
+ address: this.sdk.contractAddress,
706
+ abi: import_djeon402_core4.DJEON402_ABI,
707
+ functionName: "decimals"
708
+ });
709
+ const value = (0, import_djeon402_core4.parseTokenAmount)(amount, decimals);
710
+ const transferNonce = nonce || this.generateNonce();
711
+ const validBeforeTimestamp = validBefore ?? BigInt(Math.floor(Date.now() / 1e3) + 3600);
712
+ const name = await this.sdk.publicClient.readContract({
713
+ address: this.sdk.contractAddress,
714
+ abi: import_djeon402_core4.DJEON402_ABI,
715
+ functionName: "name"
716
+ });
717
+ const domain = {
718
+ name,
719
+ version: "1",
720
+ chainId: this.sdk.chainId,
721
+ verifyingContract: this.sdk.contractAddress
722
+ };
723
+ const types = {
724
+ TransferWithAuthorization: [
725
+ { name: "from", type: "address" },
726
+ { name: "to", type: "address" },
727
+ { name: "value", type: "uint256" },
728
+ { name: "validAfter", type: "uint256" },
729
+ { name: "validBefore", type: "uint256" },
730
+ { name: "nonce", type: "bytes32" }
731
+ ]
732
+ };
733
+ const message = {
734
+ from,
735
+ to,
736
+ value,
737
+ validAfter,
738
+ validBefore: validBeforeTimestamp,
739
+ nonce: transferNonce
740
+ };
741
+ const signature = await walletClient.signTypedData({
742
+ account: walletClient.account,
743
+ domain,
744
+ types,
745
+ primaryType: "TransferWithAuthorization",
746
+ message
747
+ });
748
+ const v = parseInt(signature.slice(130, 132), 16);
749
+ const r = `0x${signature.slice(2, 66)}`;
750
+ const s = `0x${signature.slice(66, 130)}`;
751
+ return {
752
+ from,
753
+ to,
754
+ value,
755
+ validAfter,
756
+ validBefore: validBeforeTimestamp,
757
+ nonce: transferNonce,
758
+ v,
759
+ r,
760
+ s
761
+ };
762
+ }
763
+ /**
764
+ * Sign receive authorization using wallet (receiver signs)
765
+ */
766
+ async signReceiveWithWallet(params) {
767
+ const { walletClient, from, amount, validAfter = 0n, validBefore, nonce } = params;
768
+ if (!walletClient.account) {
769
+ throw new Error("Wallet client must have an account");
770
+ }
771
+ (0, import_djeon402_core4.validateAddress)(from);
772
+ (0, import_djeon402_core4.validateAmount)(amount);
773
+ const to = walletClient.account.address;
774
+ const decimals = await this.sdk.publicClient.readContract({
775
+ address: this.sdk.contractAddress,
776
+ abi: import_djeon402_core4.DJEON402_ABI,
777
+ functionName: "decimals"
778
+ });
779
+ const value = (0, import_djeon402_core4.parseTokenAmount)(amount, decimals);
780
+ const receiveNonce = nonce || this.generateNonce();
781
+ const validBeforeTimestamp = validBefore ?? BigInt(Math.floor(Date.now() / 1e3) + 3600);
782
+ const name = await this.sdk.publicClient.readContract({
783
+ address: this.sdk.contractAddress,
784
+ abi: import_djeon402_core4.DJEON402_ABI,
785
+ functionName: "name"
786
+ });
787
+ const domain = {
788
+ name,
789
+ version: "1",
790
+ chainId: this.sdk.chainId,
791
+ verifyingContract: this.sdk.contractAddress
792
+ };
793
+ const types = {
794
+ ReceiveWithAuthorization: [
795
+ { name: "from", type: "address" },
796
+ { name: "to", type: "address" },
797
+ { name: "value", type: "uint256" },
798
+ { name: "validAfter", type: "uint256" },
799
+ { name: "validBefore", type: "uint256" },
800
+ { name: "nonce", type: "bytes32" }
801
+ ]
802
+ };
803
+ const message = {
804
+ from,
805
+ to,
806
+ value,
807
+ validAfter,
808
+ validBefore: validBeforeTimestamp,
809
+ nonce: receiveNonce
810
+ };
811
+ const signature = await walletClient.signTypedData({
812
+ account: walletClient.account,
813
+ domain,
814
+ types,
815
+ primaryType: "ReceiveWithAuthorization",
816
+ message
817
+ });
818
+ const v = parseInt(signature.slice(130, 132), 16);
819
+ const r = `0x${signature.slice(2, 66)}`;
820
+ const s = `0x${signature.slice(66, 130)}`;
821
+ return {
822
+ from,
823
+ to,
824
+ value,
825
+ validAfter,
826
+ validBefore: validBeforeTimestamp,
827
+ nonce: receiveNonce,
828
+ v,
829
+ r,
830
+ s
831
+ };
832
+ }
833
+ /**
834
+ * Execute receive with authorization (caller must be the receiver)
835
+ */
836
+ async executeReceive(params) {
837
+ const { walletClient, authorization } = params;
838
+ if (!walletClient.account) {
839
+ throw new Error("Wallet client must have an account");
840
+ }
841
+ const { from, to, value, validAfter, validBefore, nonce, v, r, s } = authorization;
842
+ const hash = await walletClient.writeContract({
843
+ address: this.sdk.contractAddress,
844
+ abi: import_djeon402_core4.DJEON402_ABI,
845
+ functionName: "receiveWithAuthorization",
846
+ args: [from, to, value, validAfter, validBefore, nonce, v, r, s],
847
+ account: walletClient.account,
848
+ chain: walletClient.chain
849
+ });
850
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
851
+ return {
852
+ success: receipt.status === "success",
853
+ hash,
854
+ blockNumber: receipt.blockNumber.toString()
855
+ };
856
+ }
857
+ /**
858
+ * Sign cancel authorization using wallet
859
+ */
860
+ async signCancelWithWallet(params) {
861
+ const { walletClient, authorizer, nonce: authNonce } = params;
862
+ if (!walletClient.account) {
863
+ throw new Error("Wallet client must have an account");
864
+ }
865
+ const name = await this.sdk.publicClient.readContract({
866
+ address: this.sdk.contractAddress,
867
+ abi: import_djeon402_core4.DJEON402_ABI,
868
+ functionName: "name"
869
+ });
870
+ const domain = {
871
+ name,
872
+ version: "1",
873
+ chainId: this.sdk.chainId,
874
+ verifyingContract: this.sdk.contractAddress
875
+ };
876
+ const types = {
877
+ CancelAuthorization: [
878
+ { name: "authorizer", type: "address" },
879
+ { name: "nonce", type: "bytes32" }
880
+ ]
881
+ };
882
+ const message = { authorizer, nonce: authNonce };
883
+ const signature = await walletClient.signTypedData({
884
+ account: walletClient.account,
885
+ domain,
886
+ types,
887
+ primaryType: "CancelAuthorization",
888
+ message
889
+ });
890
+ const v = parseInt(signature.slice(130, 132), 16);
891
+ const r = `0x${signature.slice(2, 66)}`;
892
+ const s = `0x${signature.slice(66, 130)}`;
893
+ return { authorizer, nonce: authNonce, v, r, s };
894
+ }
895
+ /**
896
+ * Cancel an authorization (marks nonce as used)
897
+ */
898
+ async cancelAuthorization(params) {
899
+ const { walletClient } = params;
900
+ const { authorizer, nonce, v, r, s } = await this.signCancelWithWallet(params);
901
+ const hash = await walletClient.writeContract({
902
+ address: this.sdk.contractAddress,
903
+ abi: import_djeon402_core4.DJEON402_ABI,
904
+ functionName: "cancelAuthorization",
905
+ args: [authorizer, nonce, v, r, s],
906
+ account: walletClient.account,
907
+ chain: walletClient.chain
908
+ });
909
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
910
+ return {
911
+ success: receipt.status === "success",
912
+ hash,
913
+ blockNumber: receipt.blockNumber.toString()
914
+ };
915
+ }
916
+ /**
917
+ * Execute transfer with authorization (relayer function)
918
+ */
919
+ async executeTransfer(params) {
920
+ const { walletClient, authorization } = params;
921
+ if (!walletClient.account) {
922
+ throw new Error("Wallet client must have an account");
923
+ }
924
+ const { from, to, value, validAfter, validBefore, nonce, v, r, s } = authorization;
925
+ const hash = await walletClient.writeContract({
926
+ address: this.sdk.contractAddress,
927
+ abi: import_djeon402_core4.DJEON402_ABI,
928
+ functionName: "transferWithAuthorization",
929
+ args: [from, to, value, validAfter, validBefore, nonce, v, r, s],
930
+ account: walletClient.account,
931
+ chain: walletClient.chain
932
+ });
933
+ const receipt = await this.sdk.publicClient.waitForTransactionReceipt({ hash });
934
+ return {
935
+ success: receipt.status === "success",
936
+ hash,
937
+ blockNumber: receipt.blockNumber.toString()
938
+ };
939
+ }
940
+ /**
941
+ * Fetch wrapper that auto-handles 402 Payment Required responses.
942
+ * On 402, decodes PAYMENT-REQUIRED header, signs authorization, retries with PAYMENT-SIGNATURE.
943
+ */
944
+ async fetchWithPayment(walletClient, url, options = {}) {
945
+ const response = await fetch(url, options);
946
+ if (response.status !== 402) return response;
947
+ const paymentRequiredHeader = response.headers.get("PAYMENT-REQUIRED");
948
+ if (!paymentRequiredHeader) {
949
+ throw new Error("402 response missing PAYMENT-REQUIRED header");
950
+ }
951
+ const paymentRequired = JSON.parse(atob(paymentRequiredHeader));
952
+ const accepted = paymentRequired.accepts?.[0];
953
+ if (!accepted) {
954
+ throw new Error("No accepted payment methods in 402 response");
955
+ }
956
+ const authData = await this.signTransferWithWallet({
957
+ walletClient,
958
+ to: accepted.payTo,
959
+ amount: accepted.amount
960
+ });
961
+ const paymentPayload = {
962
+ x402Version: paymentRequired.x402Version || 2,
963
+ resource: paymentRequired.resource,
964
+ accepted,
965
+ payload: {
966
+ signature: `0x${authData.r.slice(2)}${authData.s.slice(2)}${authData.v.toString(16).padStart(2, "0")}`,
967
+ authorization: {
968
+ from: authData.from,
969
+ to: authData.to,
970
+ value: authData.value.toString(),
971
+ validAfter: authData.validAfter.toString(),
972
+ validBefore: authData.validBefore.toString(),
973
+ nonce: authData.nonce
974
+ }
975
+ }
976
+ };
977
+ const encoded = btoa(JSON.stringify(paymentPayload));
978
+ return fetch(url, {
979
+ ...options,
980
+ headers: {
981
+ ...Object.fromEntries(new Headers(options.headers).entries()),
982
+ "PAYMENT-SIGNATURE": encoded
983
+ }
984
+ });
985
+ }
986
+ };
987
+
988
+ // src/client.ts
989
+ var Djeon402ClientSDK = class {
990
+ constructor(config) {
991
+ const { rpcUrl, contractAddress, kycRegistryAddress, chainId } = config;
992
+ this.contractAddress = contractAddress;
993
+ this.kycRegistryAddress = kycRegistryAddress;
994
+ this.chainId = chainId;
995
+ const chain = chainId === 8453 ? import_chains.base : {
996
+ id: chainId,
997
+ name: "Custom Chain",
998
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
999
+ rpcUrls: {
1000
+ default: { http: [rpcUrl || ""] },
1001
+ public: { http: [rpcUrl || ""] }
1002
+ }
1003
+ };
1004
+ this.publicClient = (0, import_viem.createPublicClient)({
1005
+ chain,
1006
+ transport: (0, import_viem.http)(rpcUrl)
1007
+ });
1008
+ this.token = new TokenModule(this);
1009
+ this.admin = new AdminModule(this);
1010
+ this.kyc = new KYCModule(this);
1011
+ this.x402 = new X402Module(this);
1012
+ }
1013
+ /**
1014
+ * Get chain configuration
1015
+ */
1016
+ getChain() {
1017
+ return this.chainId === 8453 ? import_chains.base : {
1018
+ id: this.chainId,
1019
+ name: "Custom Chain",
1020
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
1021
+ rpcUrls: {
1022
+ default: { http: [this.publicClient.transport.url || ""] },
1023
+ public: { http: [this.publicClient.transport.url || ""] }
1024
+ }
1025
+ };
1026
+ }
1027
+ };
1028
+
1029
+ // src/vue/useDjeon402.ts
1030
+ var Djeon402Key = /* @__PURE__ */ Symbol("djeon402");
1031
+ function provideDjeon402(config) {
1032
+ const sdk = new Djeon402ClientSDK({
1033
+ contractAddress: config.contractAddress,
1034
+ kycRegistryAddress: config.kycRegistryAddress,
1035
+ chainId: config.chainId,
1036
+ rpcUrl: config.rpcUrl || ""
1037
+ });
1038
+ const context = {
1039
+ sdk,
1040
+ config: (0, import_vue.readonly)(config)
1041
+ };
1042
+ (0, import_vue.provide)(Djeon402Key, context);
1043
+ return context;
1044
+ }
1045
+ function useDjeon402() {
1046
+ const context = (0, import_vue.inject)(Djeon402Key);
1047
+ if (!context) {
1048
+ throw new Error("useDjeon402 must be used within provideDjeon402");
1049
+ }
1050
+ return context;
1051
+ }
1052
+
1053
+ // src/vue/useApprove.ts
1054
+ function useApprove(walletClient) {
1055
+ const { sdk } = useDjeon402();
1056
+ const data = (0, import_vue2.ref)(null);
1057
+ const error = (0, import_vue2.ref)(null);
1058
+ const isLoading = (0, import_vue2.ref)(false);
1059
+ const approve = async (spender, amount) => {
1060
+ if (!walletClient.value) {
1061
+ throw new Error("Wallet not connected");
1062
+ }
1063
+ isLoading.value = true;
1064
+ error.value = null;
1065
+ try {
1066
+ data.value = await sdk.token.approve({
1067
+ walletClient: walletClient.value,
1068
+ spender,
1069
+ amount
1070
+ });
1071
+ return data.value;
1072
+ } catch (e) {
1073
+ error.value = e;
1074
+ throw e;
1075
+ } finally {
1076
+ isLoading.value = false;
1077
+ }
1078
+ };
1079
+ return {
1080
+ approve,
1081
+ data,
1082
+ error,
1083
+ isLoading
1084
+ };
1085
+ }
1086
+
1087
+ // src/vue/useBalance.ts
1088
+ var import_vue3 = require("vue");
1089
+ function useBalance(address) {
1090
+ const { sdk } = useDjeon402();
1091
+ const data = (0, import_vue3.ref)(null);
1092
+ const error = (0, import_vue3.ref)(null);
1093
+ const isLoading = (0, import_vue3.ref)(false);
1094
+ const fetch2 = async () => {
1095
+ if (!address.value) return;
1096
+ isLoading.value = true;
1097
+ error.value = null;
1098
+ try {
1099
+ data.value = await sdk.token.getBalance(address.value);
1100
+ } catch (e) {
1101
+ error.value = e;
1102
+ } finally {
1103
+ isLoading.value = false;
1104
+ }
1105
+ };
1106
+ (0, import_vue3.watch)(
1107
+ address,
1108
+ () => {
1109
+ fetch2();
1110
+ },
1111
+ { immediate: true }
1112
+ );
1113
+ return {
1114
+ data,
1115
+ error,
1116
+ isLoading,
1117
+ refetch: fetch2
1118
+ };
1119
+ }
1120
+
1121
+ // src/vue/useIsBlacklisted.ts
1122
+ var import_vue4 = require("vue");
1123
+ function useIsBlacklisted(address) {
1124
+ const { sdk } = useDjeon402();
1125
+ const data = (0, import_vue4.ref)(null);
1126
+ const error = (0, import_vue4.ref)(null);
1127
+ const isLoading = (0, import_vue4.ref)(false);
1128
+ const fetch2 = async () => {
1129
+ if (!address.value) return;
1130
+ isLoading.value = true;
1131
+ error.value = null;
1132
+ try {
1133
+ data.value = await sdk.admin.isBlacklisted(address.value);
1134
+ } catch (e) {
1135
+ error.value = e;
1136
+ } finally {
1137
+ isLoading.value = false;
1138
+ }
1139
+ };
1140
+ (0, import_vue4.watch)(
1141
+ address,
1142
+ () => {
1143
+ fetch2();
1144
+ },
1145
+ { immediate: true }
1146
+ );
1147
+ return {
1148
+ data,
1149
+ error,
1150
+ isLoading,
1151
+ refetch: fetch2
1152
+ };
1153
+ }
1154
+
1155
+ // src/vue/useKYCData.ts
1156
+ var import_vue5 = require("vue");
1157
+ function useKYCData(address) {
1158
+ const { sdk } = useDjeon402();
1159
+ const data = (0, import_vue5.ref)(null);
1160
+ const error = (0, import_vue5.ref)(null);
1161
+ const isLoading = (0, import_vue5.ref)(false);
1162
+ const fetch2 = async () => {
1163
+ if (!address.value) return;
1164
+ isLoading.value = true;
1165
+ error.value = null;
1166
+ try {
1167
+ data.value = await sdk.kyc.getData(address.value);
1168
+ } catch (e) {
1169
+ error.value = e;
1170
+ } finally {
1171
+ isLoading.value = false;
1172
+ }
1173
+ };
1174
+ (0, import_vue5.watch)(
1175
+ address,
1176
+ () => {
1177
+ fetch2();
1178
+ },
1179
+ { immediate: true }
1180
+ );
1181
+ return {
1182
+ data,
1183
+ error,
1184
+ isLoading,
1185
+ refetch: fetch2
1186
+ };
1187
+ }
1188
+
1189
+ // src/vue/useTokenInfo.ts
1190
+ var import_vue6 = require("vue");
1191
+ function useTokenInfo() {
1192
+ const { sdk } = useDjeon402();
1193
+ const data = (0, import_vue6.ref)(null);
1194
+ const error = (0, import_vue6.ref)(null);
1195
+ const isLoading = (0, import_vue6.ref)(false);
1196
+ const fetch2 = async () => {
1197
+ isLoading.value = true;
1198
+ error.value = null;
1199
+ try {
1200
+ data.value = await sdk.token.getInfo();
1201
+ } catch (e) {
1202
+ error.value = e;
1203
+ } finally {
1204
+ isLoading.value = false;
1205
+ }
1206
+ };
1207
+ (0, import_vue6.onMounted)(() => {
1208
+ fetch2();
1209
+ });
1210
+ return {
1211
+ data,
1212
+ error,
1213
+ isLoading,
1214
+ refetch: fetch2
1215
+ };
1216
+ }
1217
+
1218
+ // src/vue/useTransfer.ts
1219
+ var import_vue7 = require("vue");
1220
+ function useTransfer(walletClient) {
1221
+ const { sdk } = useDjeon402();
1222
+ const data = (0, import_vue7.ref)(null);
1223
+ const error = (0, import_vue7.ref)(null);
1224
+ const isLoading = (0, import_vue7.ref)(false);
1225
+ const transfer = async (to, amount) => {
1226
+ if (!walletClient.value) {
1227
+ throw new Error("Wallet not connected");
1228
+ }
1229
+ isLoading.value = true;
1230
+ error.value = null;
1231
+ try {
1232
+ data.value = await sdk.token.transfer({
1233
+ walletClient: walletClient.value,
1234
+ to,
1235
+ amount
1236
+ });
1237
+ return data.value;
1238
+ } catch (e) {
1239
+ error.value = e;
1240
+ throw e;
1241
+ } finally {
1242
+ isLoading.value = false;
1243
+ }
1244
+ };
1245
+ return {
1246
+ transfer,
1247
+ data,
1248
+ error,
1249
+ isLoading
1250
+ };
1251
+ }
1252
+
1253
+ // src/vue/useX402Receive.ts
1254
+ var import_vue8 = require("vue");
1255
+ function useX402Receive(walletClient) {
1256
+ const { sdk } = useDjeon402();
1257
+ const data = (0, import_vue8.ref)(null);
1258
+ const error = (0, import_vue8.ref)(null);
1259
+ const isLoading = (0, import_vue8.ref)(false);
1260
+ const signReceive = async (params) => {
1261
+ if (!walletClient.value) {
1262
+ throw new Error("Wallet not connected");
1263
+ }
1264
+ isLoading.value = true;
1265
+ error.value = null;
1266
+ try {
1267
+ data.value = await sdk.x402.signReceiveWithWallet({
1268
+ walletClient: walletClient.value,
1269
+ ...params
1270
+ });
1271
+ return data.value;
1272
+ } catch (e) {
1273
+ error.value = e;
1274
+ throw e;
1275
+ } finally {
1276
+ isLoading.value = false;
1277
+ }
1278
+ };
1279
+ return {
1280
+ signReceive,
1281
+ authorization: data,
1282
+ error,
1283
+ isLoading
1284
+ };
1285
+ }
1286
+
1287
+ // src/vue/useX402Transfer.ts
1288
+ var import_vue9 = require("vue");
1289
+ function useX402Transfer(walletClient) {
1290
+ const { sdk } = useDjeon402();
1291
+ const data = (0, import_vue9.ref)(null);
1292
+ const error = (0, import_vue9.ref)(null);
1293
+ const isLoading = (0, import_vue9.ref)(false);
1294
+ const signTransfer = async (params) => {
1295
+ if (!walletClient.value) {
1296
+ throw new Error("Wallet not connected");
1297
+ }
1298
+ isLoading.value = true;
1299
+ error.value = null;
1300
+ try {
1301
+ data.value = await sdk.x402.signTransferWithWallet({
1302
+ walletClient: walletClient.value,
1303
+ ...params
1304
+ });
1305
+ return data.value;
1306
+ } catch (e) {
1307
+ error.value = e;
1308
+ throw e;
1309
+ } finally {
1310
+ isLoading.value = false;
1311
+ }
1312
+ };
1313
+ return {
1314
+ signTransfer,
1315
+ authorization: data,
1316
+ error,
1317
+ isLoading
1318
+ };
1319
+ }
1320
+ // Annotate the CommonJS export names for ESM import in node:
1321
+ 0 && (module.exports = {
1322
+ provideDjeon402,
1323
+ useApprove,
1324
+ useBalance,
1325
+ useDjeon402,
1326
+ useIsBlacklisted,
1327
+ useKYCData,
1328
+ useTokenInfo,
1329
+ useTransfer,
1330
+ useX402Receive,
1331
+ useX402Transfer
1332
+ });
1333
+ //# sourceMappingURL=index.cjs.map