@dag-kit/kit 1.0.2 → 1.0.4-alpha.3

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.
Files changed (54) hide show
  1. package/dist/index.cjs +564 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +209 -0
  4. package/dist/index.d.ts +209 -0
  5. package/dist/index.js +544 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +16 -11
  8. package/src/clients/actions/contract.ts +1 -1
  9. package/src/clients/actions/example.ts +252 -252
  10. package/src/clients/actions/example2.ts +60 -60
  11. package/src/clients/actions/index.ts +145 -0
  12. package/src/clients/actions/main.ts +34 -17
  13. package/src/clients/actions/test.ts +210 -210
  14. package/src/clients/types.ts +2 -1
  15. package/src/exports/index.ts +7 -4
  16. package/src/exports/public-types.ts +6 -0
  17. package/src/index.ts +17 -0
  18. package/src/signers/PrivateKeySigner.ts +41 -0
  19. package/src/signers/PrivySigner.ts +93 -0
  20. package/src/signers/types.ts +45 -0
  21. package/src/version.ts +1 -1
  22. package/dist/esm/clients/actions/contract.js +0 -42
  23. package/dist/esm/clients/actions/example.js +0 -211
  24. package/dist/esm/clients/actions/example2.js +0 -50
  25. package/dist/esm/clients/actions/index.js +0 -1
  26. package/dist/esm/clients/actions/main.js +0 -415
  27. package/dist/esm/clients/actions/test.js +0 -1
  28. package/dist/esm/clients/actions/testPaymasterService.js +0 -88
  29. package/dist/esm/clients/chains.js +0 -19
  30. package/dist/esm/clients/types.js +0 -1
  31. package/dist/esm/exports/index.js +0 -2
  32. package/dist/esm/version.js +0 -3
  33. package/dist/types/clients/actions/contract.d.ts +0 -12
  34. package/dist/types/clients/actions/contract.d.ts.map +0 -1
  35. package/dist/types/clients/actions/example.d.ts +0 -2
  36. package/dist/types/clients/actions/example.d.ts.map +0 -1
  37. package/dist/types/clients/actions/example2.d.ts +0 -2
  38. package/dist/types/clients/actions/example2.d.ts.map +0 -1
  39. package/dist/types/clients/actions/index.d.ts +0 -1
  40. package/dist/types/clients/actions/index.d.ts.map +0 -1
  41. package/dist/types/clients/actions/main.d.ts +0 -40
  42. package/dist/types/clients/actions/main.d.ts.map +0 -1
  43. package/dist/types/clients/actions/test.d.ts +0 -1
  44. package/dist/types/clients/actions/test.d.ts.map +0 -1
  45. package/dist/types/clients/actions/testPaymasterService.d.ts +0 -2
  46. package/dist/types/clients/actions/testPaymasterService.d.ts.map +0 -1
  47. package/dist/types/clients/chains.d.ts +0 -81
  48. package/dist/types/clients/chains.d.ts.map +0 -1
  49. package/dist/types/clients/types.d.ts +0 -31
  50. package/dist/types/clients/types.d.ts.map +0 -1
  51. package/dist/types/exports/index.d.ts +0 -4
  52. package/dist/types/exports/index.d.ts.map +0 -1
  53. package/dist/types/version.d.ts +0 -2
  54. package/dist/types/version.d.ts.map +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,564 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ DagAAClient: () => DagAAClient,
23
+ PrivateKeySigner: () => PrivateKeySigner,
24
+ PrivySigner: () => PrivySigner,
25
+ arbitrumSep: () => arbitrumSep,
26
+ awakening: () => awakening,
27
+ createDagAAClient: () => createDagAAClient,
28
+ parseDAG: () => parseDAG
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
31
+
32
+ // src/clients/actions/main.ts
33
+ var import_viem = require("viem");
34
+ var import_accounts = require("viem/accounts");
35
+ var import_accounts2 = require("permissionless/accounts");
36
+ var import_pimlico = require("permissionless/clients/pimlico");
37
+ var import_account_abstraction = require("viem/account-abstraction");
38
+ var import_permissionless = require("permissionless");
39
+ var DagAAClient = class {
40
+ config;
41
+ publicClient;
42
+ walletClient;
43
+ bundlerClient = null;
44
+ smartAccount = null;
45
+ paymasterClient = null;
46
+ smartAccountClient = null;
47
+ constructor(config) {
48
+ this.config = {
49
+ ...config,
50
+ entryPointAddress: config.entryPointAddress || import_account_abstraction.entryPoint06Address
51
+ };
52
+ this.publicClient = (0, import_viem.createPublicClient)({
53
+ chain: config.chain,
54
+ transport: (0, import_viem.http)(config.rpcUrl)
55
+ });
56
+ this.walletClient = (0, import_viem.createWalletClient)({
57
+ chain: config.chain,
58
+ transport: (0, import_viem.http)(config.rpcUrl)
59
+ });
60
+ if (config.paymasterUrl) {
61
+ this.paymasterClient = this.createPaymasterClient(config.paymasterUrl);
62
+ }
63
+ }
64
+ // ==============================================================================
65
+ // Paymaster Client (Fixed Serialization)
66
+ // ==============================================================================
67
+ createPaymasterClient(paymasterUrl) {
68
+ const stringify = (data) => {
69
+ return JSON.stringify(
70
+ data,
71
+ (_, value) => typeof value === "bigint" ? `0x${value.toString(16)}` : value
72
+ );
73
+ };
74
+ return {
75
+ /**
76
+ * Get paymaster stub data for gas estimation
77
+ */
78
+ async getPaymasterStubData(userOp, entryPoint) {
79
+ try {
80
+ const response = await fetch(paymasterUrl, {
81
+ method: "POST",
82
+ headers: { "Content-Type": "application/json" },
83
+ // 👇 Use the robust stringify helper
84
+ body: stringify({
85
+ jsonrpc: "2.0",
86
+ id: 1,
87
+ method: "pm_getPaymasterStubData",
88
+ params: [userOp, entryPoint, {}]
89
+ })
90
+ });
91
+ const data = await response.json();
92
+ if (data.error) throw new Error(data.error.message);
93
+ return data.result;
94
+ } catch (error) {
95
+ console.warn("Failed to get paymaster stub data:", error);
96
+ return { paymasterAndData: "0x" };
97
+ }
98
+ },
99
+ /**
100
+ * Get paymaster data for actual transaction
101
+ */
102
+ async getPaymasterData(userOp, entryPoint) {
103
+ try {
104
+ const response = await fetch(paymasterUrl, {
105
+ method: "POST",
106
+ headers: { "Content-Type": "application/json" },
107
+ body: stringify({
108
+ jsonrpc: "2.0",
109
+ id: 1,
110
+ method: "pm_getPaymasterData",
111
+ params: [userOp, entryPoint, {}]
112
+ })
113
+ });
114
+ const data = await response.json();
115
+ if (data.error) throw new Error(data.error.message);
116
+ return data.result;
117
+ } catch (error) {
118
+ console.warn("Failed to get paymaster data:", error);
119
+ return null;
120
+ }
121
+ },
122
+ /**
123
+ * Sponsor user operation
124
+ */
125
+ async sponsorUserOperation(userOp, entryPoint) {
126
+ try {
127
+ const response = await fetch(paymasterUrl, {
128
+ method: "POST",
129
+ headers: { "Content-Type": "application/json" },
130
+ body: stringify({
131
+ jsonrpc: "2.0",
132
+ id: 1,
133
+ method: "pm_sponsorUserOperation",
134
+ params: [userOp, entryPoint, {}]
135
+ })
136
+ });
137
+ const data = await response.json();
138
+ if (data.error) throw new Error(data.error.message);
139
+ return data.result;
140
+ } catch (error) {
141
+ console.warn("Failed to sponsor user operation:", error);
142
+ throw error;
143
+ }
144
+ }
145
+ };
146
+ }
147
+ // ==============================================================================
148
+ // Smart Account Management
149
+ // ==============================================================================
150
+ async connectSmartAccount(accountConfig) {
151
+ const { signer, accountAddress } = accountConfig;
152
+ const isReady = await signer.isReady();
153
+ if (!isReady) {
154
+ throw new Error("Signer is not ready. Ensure wallet is connected.");
155
+ }
156
+ const owner = await signer.getAccount();
157
+ const signingClient = await signer.getWalletClient();
158
+ if (accountAddress) {
159
+ this.smartAccount = await (0, import_accounts2.toSimpleSmartAccount)({
160
+ client: signingClient,
161
+ owner,
162
+ factoryAddress: this.config.factoryAddress,
163
+ entryPoint: {
164
+ address: this.config.entryPointAddress,
165
+ version: "0.6"
166
+ },
167
+ address: accountAddress
168
+ });
169
+ } else {
170
+ this.smartAccount = await (0, import_accounts2.toSimpleSmartAccount)({
171
+ client: signingClient,
172
+ owner,
173
+ factoryAddress: this.config.factoryAddress,
174
+ entryPoint: {
175
+ address: this.config.entryPointAddress,
176
+ version: "0.6"
177
+ }
178
+ });
179
+ }
180
+ this.bundlerClient = (0, import_pimlico.createPimlicoClient)({
181
+ transport: (0, import_viem.http)(this.config.bundlerUrl),
182
+ entryPoint: {
183
+ address: this.config.entryPointAddress,
184
+ version: "0.6"
185
+ }
186
+ });
187
+ const clientConfig = {
188
+ bundlerTransport: (0, import_viem.http)(this.config.bundlerUrl),
189
+ chain: this.config.chain,
190
+ account: this.smartAccount
191
+ };
192
+ if (this.paymasterClient) {
193
+ clientConfig.paymaster = {
194
+ getPaymasterData: async (userOperation) => {
195
+ console.log("\u{1F3AB} Requesting paymaster sponsorship...");
196
+ console.log("UserOp sender:", userOperation.sender);
197
+ try {
198
+ const result = await this.paymasterClient.sponsorUserOperation(
199
+ userOperation,
200
+ this.config.entryPointAddress
201
+ );
202
+ console.log("Paymaster result:", result);
203
+ if (result && result.paymasterAndData) {
204
+ console.log("\u2705 Paymaster sponsorship approved!");
205
+ console.log("PaymasterAndData:", result.paymasterAndData);
206
+ return {
207
+ paymasterAndData: result.paymasterAndData,
208
+ ...result.preVerificationGas && {
209
+ preVerificationGas: BigInt(result.preVerificationGas)
210
+ },
211
+ ...result.verificationGasLimit && {
212
+ verificationGasLimit: BigInt(result.verificationGasLimit)
213
+ },
214
+ ...result.callGasLimit && {
215
+ callGasLimit: BigInt(result.callGasLimit)
216
+ }
217
+ };
218
+ } else {
219
+ console.error("\u274C No paymasterAndData in response:", result);
220
+ throw new Error("No paymaster data returned");
221
+ }
222
+ } catch (error) {
223
+ console.error("\u274C Paymaster sponsorship failed:", error);
224
+ throw error;
225
+ }
226
+ },
227
+ getPaymasterStubData: async (userOperation) => {
228
+ console.log("\u{1F4DD} Getting paymaster stub data for gas estimation...");
229
+ try {
230
+ const result = await this.paymasterClient.getPaymasterStubData(
231
+ userOperation,
232
+ this.config.entryPointAddress
233
+ );
234
+ console.log("Stub data result:", result);
235
+ if (result && result.paymasterAndData) {
236
+ console.log("\u2705 Got paymaster stub data");
237
+ return {
238
+ paymasterAndData: result.paymasterAndData
239
+ };
240
+ }
241
+ } catch (error) {
242
+ console.warn("\u26A0\uFE0F Failed to get paymaster stub data:", error);
243
+ }
244
+ console.log("\u26A0\uFE0F Using default stub data");
245
+ return {
246
+ paymasterAndData: "0x"
247
+ };
248
+ }
249
+ };
250
+ }
251
+ this.smartAccountClient = (0, import_permissionless.createSmartAccountClient)(clientConfig);
252
+ console.log(`\u2705 Connected to smart account: ${this.smartAccount.address}`);
253
+ return this.smartAccount.address;
254
+ }
255
+ // ==============================================================================
256
+ // Account Information
257
+ // ==============================================================================
258
+ getAddress() {
259
+ if (!this.smartAccount) {
260
+ throw new Error(
261
+ "Smart account not connected. Call connectSmartAccount() first."
262
+ );
263
+ }
264
+ return this.smartAccount.address;
265
+ }
266
+ async getBalance() {
267
+ if (!this.smartAccount) {
268
+ throw new Error("Smart account not connected");
269
+ }
270
+ return await this.publicClient.getBalance({
271
+ address: this.smartAccount.address
272
+ });
273
+ }
274
+ async isDeployed() {
275
+ if (!this.smartAccount) {
276
+ throw new Error("Smart account not connected");
277
+ }
278
+ const code = await this.publicClient.getCode({
279
+ address: this.smartAccount.address
280
+ });
281
+ return code !== void 0 && code !== "0x";
282
+ }
283
+ async getNonce() {
284
+ if (!this.smartAccount) {
285
+ throw new Error("Smart account not connected");
286
+ }
287
+ return await this.publicClient.readContract({
288
+ address: this.config.entryPointAddress,
289
+ abi: [
290
+ {
291
+ name: "getNonce",
292
+ type: "function",
293
+ stateMutability: "view",
294
+ inputs: [
295
+ { name: "sender", type: "address" },
296
+ { name: "key", type: "uint192" }
297
+ ],
298
+ outputs: [{ name: "nonce", type: "uint256" }]
299
+ }
300
+ ],
301
+ functionName: "getNonce",
302
+ args: [this.smartAccount.address, 0n]
303
+ });
304
+ }
305
+ // ==============================================================================
306
+ // Send UserOperations
307
+ // ==============================================================================
308
+ async sendUserOperation(params) {
309
+ if (!this.smartAccountClient) {
310
+ throw new Error("Smart account not connected");
311
+ }
312
+ const {
313
+ target,
314
+ data = "0x",
315
+ value = 0n,
316
+ maxFeePerGas,
317
+ maxPriorityFeePerGas,
318
+ callGasLimit,
319
+ verificationGasLimit,
320
+ preVerificationGas
321
+ } = params;
322
+ let gasPrices = {
323
+ maxFeePerGas,
324
+ maxPriorityFeePerGas
325
+ };
326
+ if (!maxFeePerGas || !maxPriorityFeePerGas) {
327
+ const estimatedGas = await this.bundlerClient.getUserOperationGasPrice();
328
+ gasPrices = {
329
+ maxFeePerGas: maxFeePerGas || estimatedGas.fast.maxFeePerGas,
330
+ maxPriorityFeePerGas: maxPriorityFeePerGas || estimatedGas.fast.maxPriorityFeePerGas
331
+ };
332
+ }
333
+ console.log("Sending UserOperation...");
334
+ console.log(` Target: ${target}`);
335
+ console.log(` Value: ${value}`);
336
+ console.log(
337
+ ` Gas: ${gasPrices.maxFeePerGas} / ${gasPrices.maxPriorityFeePerGas}`
338
+ );
339
+ const txOptions = {
340
+ calls: [
341
+ {
342
+ to: target,
343
+ value,
344
+ data
345
+ }
346
+ ],
347
+ maxFeePerGas: gasPrices.maxFeePerGas,
348
+ maxPriorityFeePerGas: gasPrices.maxPriorityFeePerGas
349
+ };
350
+ if (callGasLimit) txOptions.callGasLimit = callGasLimit;
351
+ if (verificationGasLimit)
352
+ txOptions.verificationGasLimit = verificationGasLimit;
353
+ if (preVerificationGas) txOptions.preVerificationGas = preVerificationGas;
354
+ const userOpHash = await this.smartAccountClient.sendTransaction(txOptions);
355
+ console.log(`\u2705 UserOperation sent: ${userOpHash}`);
356
+ return userOpHash;
357
+ }
358
+ // ==============================================================================
359
+ // Contract Interactions
360
+ // ==============================================================================
361
+ async writeContract(params) {
362
+ const { address, abi, functionName, args = [], value = 0n } = params;
363
+ const data = (0, import_viem.encodeFunctionData)({
364
+ abi,
365
+ functionName,
366
+ args
367
+ });
368
+ return await this.sendUserOperation({
369
+ target: address,
370
+ data,
371
+ value,
372
+ maxFeePerGas: params.maxFeePerGas,
373
+ maxPriorityFeePerGas: params.maxPriorityFeePerGas
374
+ });
375
+ }
376
+ async readContract(params) {
377
+ return await this.publicClient.readContract({
378
+ address: params.address,
379
+ abi: params.abi,
380
+ functionName: params.functionName,
381
+ args: params.args || []
382
+ });
383
+ }
384
+ // ==============================================================================
385
+ // Utilities
386
+ // ==============================================================================
387
+ async waitForUserOperationReceipt(userOpHash, timeout = 3e4) {
388
+ console.log(`Waiting for UserOperation receipt...`);
389
+ const startTime = Date.now();
390
+ while (Date.now() - startTime < timeout) {
391
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
392
+ console.log("Checking for receipt...");
393
+ }
394
+ return {
395
+ userOpHash,
396
+ success: true
397
+ };
398
+ }
399
+ async fundAccount(amount, fromPrivateKey) {
400
+ if (!this.smartAccount) {
401
+ throw new Error("Smart account not connected");
402
+ }
403
+ const signer = (0, import_accounts.privateKeyToAccount)(fromPrivateKey);
404
+ const client = (0, import_viem.createWalletClient)({
405
+ account: signer,
406
+ chain: this.config.chain,
407
+ transport: (0, import_viem.http)(this.config.rpcUrl)
408
+ });
409
+ console.log(`Funding account with ${amount} wei...`);
410
+ const hash = await client.sendTransaction({
411
+ account: signer,
412
+ // ✅ Add this line
413
+ to: this.smartAccount.address,
414
+ value: amount,
415
+ kzg: {
416
+ blobToKzgCommitment: function(blob) {
417
+ throw new Error("Function not implemented.");
418
+ },
419
+ computeBlobKzgProof: function(blob, commitment) {
420
+ throw new Error("Function not implemented.");
421
+ }
422
+ },
423
+ chain: void 0
424
+ });
425
+ console.log(`\u2705 Funded: ${hash}`);
426
+ return hash;
427
+ }
428
+ // ==============================================================================
429
+ // Batch Operations
430
+ // ==============================================================================
431
+ async sendBatchUserOperations(operations) {
432
+ const results = [];
433
+ for (const op of operations) {
434
+ const hash = await this.sendUserOperation(op);
435
+ results.push(hash);
436
+ }
437
+ return results;
438
+ }
439
+ };
440
+ function createDagAAClient(config) {
441
+ return new DagAAClient(config);
442
+ }
443
+ function parseDAG(amount) {
444
+ return (0, import_viem.parseEther)(amount);
445
+ }
446
+
447
+ // src/clients/chains.ts
448
+ var import_viem2 = require("viem");
449
+ var import_chains = require("viem/chains");
450
+ var awakening_ = (0, import_viem2.defineChain)({
451
+ id: 1043,
452
+ name: "Awakening Testnet",
453
+ nativeCurrency: { decimals: 18, name: "Dag", symbol: "DAG" },
454
+ rpcUrls: { default: { http: ["https://public-bdag.nownodes.io"] } },
455
+ blockExplorers: {
456
+ default: { name: "Explorer", url: "https://awakening.bdagscan.com/" }
457
+ }
458
+ });
459
+ var awakening = {
460
+ bundler_rpc: "http://0.0.0.0:3000/",
461
+ chain_config: awakening_
462
+ };
463
+ var arbitrumSep = {
464
+ bundler_rpc: "http://0.0.0.0:3001/",
465
+ chain_config: import_chains.arbitrumSepolia
466
+ };
467
+
468
+ // src/signers/PrivySigner.ts
469
+ var import_viem3 = require("viem");
470
+ var PrivySigner = class {
471
+ privyWallet;
472
+ // Privy wallet object
473
+ chain;
474
+ cachedAddress;
475
+ cachedWalletClient;
476
+ constructor(privyWallet, chain) {
477
+ if (!privyWallet) {
478
+ throw new Error("Privy wallet is required");
479
+ }
480
+ this.privyWallet = privyWallet;
481
+ this.chain = chain;
482
+ }
483
+ async getAccount() {
484
+ const provider = await this.privyWallet.getEthereumProvider();
485
+ if (!provider) {
486
+ throw new Error("No Ethereum provider found in Privy wallet");
487
+ }
488
+ return {
489
+ address: this.privyWallet.address,
490
+ type: "json-rpc",
491
+ // @ts-ignore - Privy provider compatible with viem
492
+ source: "privateKey"
493
+ };
494
+ }
495
+ async getWalletClient() {
496
+ if (this.cachedWalletClient) {
497
+ return this.cachedWalletClient;
498
+ }
499
+ const provider = await this.privyWallet.getEthereumProvider();
500
+ if (!provider) {
501
+ throw new Error("No Ethereum provider found in Privy wallet");
502
+ }
503
+ this.cachedWalletClient = (0, import_viem3.createWalletClient)({
504
+ account: await this.getAccount(),
505
+ chain: this.chain,
506
+ transport: (0, import_viem3.custom)(provider)
507
+ });
508
+ return this.cachedWalletClient;
509
+ }
510
+ async getAddress() {
511
+ if (this.cachedAddress) {
512
+ return this.cachedAddress;
513
+ }
514
+ this.cachedAddress = this.privyWallet.address;
515
+ return this.cachedAddress;
516
+ }
517
+ async isReady() {
518
+ try {
519
+ const provider = await this.privyWallet.getEthereumProvider();
520
+ return !!provider && !!this.privyWallet.address;
521
+ } catch {
522
+ return false;
523
+ }
524
+ }
525
+ };
526
+
527
+ // src/signers/PrivateKeySigner.ts
528
+ var import_viem4 = require("viem");
529
+ var import_accounts3 = require("viem/accounts");
530
+ var PrivateKeySigner = class {
531
+ account;
532
+ walletClient;
533
+ constructor(privateKey, chain, rpcUrl) {
534
+ this.account = (0, import_accounts3.privateKeyToAccount)(privateKey);
535
+ this.walletClient = (0, import_viem4.createWalletClient)({
536
+ account: this.account,
537
+ chain,
538
+ transport: (0, import_viem4.http)(rpcUrl)
539
+ });
540
+ }
541
+ getAccount() {
542
+ return this.account;
543
+ }
544
+ getWalletClient() {
545
+ return this.walletClient;
546
+ }
547
+ getAddress() {
548
+ return this.account.address;
549
+ }
550
+ isReady() {
551
+ return true;
552
+ }
553
+ };
554
+ // Annotate the CommonJS export names for ESM import in node:
555
+ 0 && (module.exports = {
556
+ DagAAClient,
557
+ PrivateKeySigner,
558
+ PrivySigner,
559
+ arbitrumSep,
560
+ awakening,
561
+ createDagAAClient,
562
+ parseDAG
563
+ });
564
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/clients/actions/main.ts","../src/clients/chains.ts","../src/signers/PrivySigner.ts","../src/signers/PrivateKeySigner.ts"],"sourcesContent":["export { createDagAAClient, parseDAG } from \"./clients/actions/main.js\";\nexport { awakening, arbitrumSep } from \"./clients/chains.js\";\nexport { DagAAClient } from \"./clients/actions/main.js\";\n\nexport type {\n DagAAConfig,\n SmartAccountConfig,\n SendUserOperationParams,\n UserOperationReceipt,\n} from \"./exports/public-types.js\";\n\nexport { PrivySigner } from \"./signers/PrivySigner.js\";\nexport { PrivateKeySigner } from \"./signers/PrivateKeySigner.js\";\n\n// Re-export commonly used viem types for convenience\nexport type { Address, Hash, Chain } from \"viem\";\nexport type { ISigner } from \"./signers/types.js\";\n","// ==============================================================================\n// DAG AA SDK - BlockDAG Account Abstraction SDK\n// Inspired by Alchemy AA SDK\n// ==============================================================================\n\nimport {\n createPublicClient,\n createWalletClient,\n http,\n type Chain,\n type Transport,\n type Account,\n type Hash,\n type Address,\n encodeFunctionData,\n parseEther,\n Client,\n ByteArray,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { toSimpleSmartAccount } from \"permissionless/accounts\";\nimport { createPimlicoClient } from \"permissionless/clients/pimlico\";\nimport { entryPoint06Address } from \"viem/account-abstraction\";\nimport { createSmartAccountClient } from \"permissionless\";\nimport {\n DagAAConfig,\n SmartAccountConfig,\n SendUserOperationParams,\n UserOperationReceipt,\n} from \"../types.js\";\nimport { ISigner } from \"../../signers/types.js\";\n\n// ==============================================================================\n// Main SDK Class\n// ==============================================================================\n\nexport class DagAAClient {\n private config: DagAAConfig;\n private publicClient: any | null;\n private walletClient: any | null;\n private bundlerClient: any | null = null;\n private smartAccount: any | null = null;\n private paymasterClient: any | null = null;\n private smartAccountClient: any | null = null;\n\n constructor(config: DagAAConfig) {\n this.config = {\n ...config,\n entryPointAddress: config.entryPointAddress || entryPoint06Address,\n };\n\n this.publicClient = createPublicClient({\n chain: config.chain,\n transport: http(config.rpcUrl),\n });\n\n this.walletClient = createWalletClient({\n chain: config.chain,\n transport: http(config.rpcUrl),\n });\n\n // Initialize paymaster client if URL provided\n if (config.paymasterUrl) {\n this.paymasterClient = this.createPaymasterClient(config.paymasterUrl);\n }\n }\n // ==============================================================================\n // Paymaster Client (Fixed Serialization)\n // ==============================================================================\n\n private createPaymasterClient(paymasterUrl: string) {\n // 1. Define a robust serializer that handles nested BigInts automatically\n const stringify = (data: any) => {\n return JSON.stringify(data, (_, value) =>\n typeof value === \"bigint\" ? `0x${value.toString(16)}` : value\n );\n };\n\n return {\n /**\n * Get paymaster stub data for gas estimation\n */\n async getPaymasterStubData(\n userOp: any,\n entryPoint: Address\n ): Promise<any> {\n try {\n const response = await fetch(paymasterUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n // 👇 Use the robust stringify helper\n body: stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"pm_getPaymasterStubData\",\n params: [userOp, entryPoint, {}],\n }),\n });\n\n const data = await response.json();\n if (data.error) throw new Error(data.error.message);\n\n return data.result;\n } catch (error) {\n console.warn(\"Failed to get paymaster stub data:\", error);\n // ⚠️ If this fails, the UserOp usually fails with AA21\n return { paymasterAndData: \"0x\" };\n }\n },\n\n /**\n * Get paymaster data for actual transaction\n */\n async getPaymasterData(userOp: any, entryPoint: Address): Promise<any> {\n try {\n const response = await fetch(paymasterUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"pm_getPaymasterData\",\n params: [userOp, entryPoint, {}],\n }),\n });\n\n const data = await response.json();\n if (data.error) throw new Error(data.error.message);\n\n return data.result;\n } catch (error) {\n console.warn(\"Failed to get paymaster data:\", error);\n return null;\n }\n },\n\n /**\n * Sponsor user operation\n */\n async sponsorUserOperation(\n userOp: any,\n entryPoint: Address\n ): Promise<any> {\n try {\n const response = await fetch(paymasterUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"pm_sponsorUserOperation\",\n params: [userOp, entryPoint, {}],\n }),\n });\n\n const data = await response.json();\n if (data.error) throw new Error(data.error.message);\n\n return data.result;\n } catch (error) {\n console.warn(\"Failed to sponsor user operation:\", error);\n throw error;\n }\n },\n };\n }\n // ==============================================================================\n // Smart Account Management\n // ==============================================================================\n\n async connectSmartAccount(\n accountConfig: SmartAccountConfig\n ): Promise<Address> {\n const { signer, accountAddress } = accountConfig;\n\n const isReady = await signer.isReady();\n if (!isReady) {\n throw new Error(\"Signer is not ready. Ensure wallet is connected.\");\n }\n\n const owner = await signer.getAccount();\n\n const signingClient = await signer.getWalletClient();\n\n if (accountAddress) {\n // Use existing account\n this.smartAccount = await toSimpleSmartAccount({\n client: signingClient as unknown as Client,\n owner: owner,\n factoryAddress: this.config.factoryAddress,\n entryPoint: {\n address: this.config.entryPointAddress!,\n version: \"0.6\",\n },\n address: accountAddress,\n });\n } else {\n // Create new account\n this.smartAccount = await toSimpleSmartAccount({\n client: signingClient as unknown as Client,\n owner: owner,\n factoryAddress: this.config.factoryAddress,\n entryPoint: {\n address: this.config.entryPointAddress!,\n version: \"0.6\",\n },\n });\n }\n\n // Create bundler client\n this.bundlerClient = createPimlicoClient({\n transport: http(this.config.bundlerUrl),\n entryPoint: {\n address: this.config.entryPointAddress!,\n version: \"0.6\",\n },\n });\n\n // Create smart account client with optional paymaster\n const clientConfig: any = {\n bundlerTransport: http(this.config.bundlerUrl),\n chain: this.config.chain,\n account: this.smartAccount,\n };\n\n // Add paymaster if configured\n if (this.paymasterClient) {\n clientConfig.paymaster = {\n getPaymasterData: async (userOperation: any) => {\n console.log(\"🎫 Requesting paymaster sponsorship...\");\n console.log(\"UserOp sender:\", userOperation.sender);\n\n try {\n const result = await this.paymasterClient!.sponsorUserOperation(\n userOperation,\n this.config.entryPointAddress!\n );\n\n console.log(\"Paymaster result:\", result);\n\n if (result && result.paymasterAndData) {\n console.log(\"✅ Paymaster sponsorship approved!\");\n console.log(\"PaymasterAndData:\", result.paymasterAndData);\n return {\n paymasterAndData: result.paymasterAndData,\n ...(result.preVerificationGas && {\n preVerificationGas: BigInt(result.preVerificationGas),\n }),\n ...(result.verificationGasLimit && {\n verificationGasLimit: BigInt(result.verificationGasLimit),\n }),\n ...(result.callGasLimit && {\n callGasLimit: BigInt(result.callGasLimit),\n }),\n };\n } else {\n console.error(\"❌ No paymasterAndData in response:\", result);\n throw new Error(\"No paymaster data returned\");\n }\n } catch (error) {\n console.error(\"❌ Paymaster sponsorship failed:\", error);\n throw error;\n }\n },\n\n getPaymasterStubData: async (userOperation: any) => {\n console.log(\"📝 Getting paymaster stub data for gas estimation...\");\n\n try {\n const result = await this.paymasterClient!.getPaymasterStubData(\n userOperation,\n this.config.entryPointAddress!\n );\n\n console.log(\"Stub data result:\", result);\n\n if (result && result.paymasterAndData) {\n console.log(\"✅ Got paymaster stub data\");\n return {\n paymasterAndData: result.paymasterAndData,\n };\n }\n } catch (error) {\n console.warn(\"⚠️ Failed to get paymaster stub data:\", error);\n }\n\n // Return default stub if fails\n console.log(\"⚠️ Using default stub data\");\n return {\n paymasterAndData: \"0x\",\n };\n },\n };\n }\n\n this.smartAccountClient = createSmartAccountClient(clientConfig);\n\n console.log(`✅ Connected to smart account: ${this.smartAccount.address}`);\n return this.smartAccount.address;\n }\n\n // ==============================================================================\n // Account Information\n // ==============================================================================\n\n getAddress(): Address {\n if (!this.smartAccount) {\n throw new Error(\n \"Smart account not connected. Call connectSmartAccount() first.\"\n );\n }\n return this.smartAccount.address;\n }\n\n async getBalance(): Promise<bigint> {\n if (!this.smartAccount) {\n throw new Error(\"Smart account not connected\");\n }\n\n return await this.publicClient.getBalance({\n address: this.smartAccount.address,\n });\n }\n\n async isDeployed(): Promise<boolean> {\n if (!this.smartAccount) {\n throw new Error(\"Smart account not connected\");\n }\n\n const code = await this.publicClient.getCode({\n address: this.smartAccount.address,\n });\n\n return code !== undefined && code !== \"0x\";\n }\n\n async getNonce(): Promise<bigint> {\n if (!this.smartAccount) {\n throw new Error(\"Smart account not connected\");\n }\n\n return await this.publicClient.readContract({\n address: this.config.entryPointAddress!,\n abi: [\n {\n name: \"getNonce\",\n type: \"function\",\n stateMutability: \"view\",\n inputs: [\n { name: \"sender\", type: \"address\" },\n { name: \"key\", type: \"uint192\" },\n ],\n outputs: [{ name: \"nonce\", type: \"uint256\" }],\n },\n ],\n functionName: \"getNonce\",\n args: [this.smartAccount.address, 0n],\n });\n }\n\n // ==============================================================================\n // Send UserOperations\n // ==============================================================================\n\n async sendUserOperation(params: SendUserOperationParams): Promise<Hash> {\n if (!this.smartAccountClient) {\n throw new Error(\"Smart account not connected\");\n }\n\n const {\n target,\n data = \"0x\",\n value = 0n,\n maxFeePerGas,\n maxPriorityFeePerGas,\n callGasLimit,\n verificationGasLimit,\n preVerificationGas,\n } = params;\n\n // Get gas prices if not provided\n let gasPrices = {\n maxFeePerGas: maxFeePerGas,\n maxPriorityFeePerGas: maxPriorityFeePerGas,\n };\n\n if (!maxFeePerGas || !maxPriorityFeePerGas) {\n const estimatedGas = await this.bundlerClient!.getUserOperationGasPrice();\n gasPrices = {\n maxFeePerGas: maxFeePerGas || estimatedGas.fast.maxFeePerGas,\n maxPriorityFeePerGas:\n maxPriorityFeePerGas || estimatedGas.fast.maxPriorityFeePerGas,\n };\n }\n\n console.log(\"Sending UserOperation...\");\n console.log(` Target: ${target}`);\n console.log(` Value: ${value}`);\n console.log(\n ` Gas: ${gasPrices.maxFeePerGas} / ${gasPrices.maxPriorityFeePerGas}`\n );\n\n const txOptions: any = {\n calls: [\n {\n to: target,\n value: value,\n data: data,\n },\n ],\n maxFeePerGas: gasPrices.maxFeePerGas,\n maxPriorityFeePerGas: gasPrices.maxPriorityFeePerGas,\n };\n\n // Add optional gas limits if provided\n if (callGasLimit) txOptions.callGasLimit = callGasLimit;\n if (verificationGasLimit)\n txOptions.verificationGasLimit = verificationGasLimit;\n if (preVerificationGas) txOptions.preVerificationGas = preVerificationGas;\n\n // Send transaction - paymaster is automatically called if configured\n const userOpHash = await this.smartAccountClient.sendTransaction(txOptions);\n\n console.log(`✅ UserOperation sent: ${userOpHash}`);\n return userOpHash;\n }\n\n // ==============================================================================\n // Contract Interactions\n // ==============================================================================\n\n async writeContract(params: {\n address: Address;\n abi: any[];\n functionName: string;\n args?: any[];\n value?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n }): Promise<Hash> {\n const { address, abi, functionName, args = [], value = 0n } = params;\n\n const data = encodeFunctionData({\n abi,\n functionName,\n args,\n });\n\n return await this.sendUserOperation({\n target: address,\n data,\n value,\n maxFeePerGas: params.maxFeePerGas,\n maxPriorityFeePerGas: params.maxPriorityFeePerGas,\n });\n }\n\n async readContract(params: {\n address: Address;\n abi: any[];\n functionName: string;\n args?: any[];\n }): Promise<any> {\n return await this.publicClient.readContract({\n address: params.address,\n abi: params.abi,\n functionName: params.functionName,\n args: params.args || [],\n });\n }\n\n // ==============================================================================\n // Utilities\n // ==============================================================================\n\n async waitForUserOperationReceipt(\n userOpHash: Hash,\n timeout: number = 30000\n ): Promise<UserOperationReceipt> {\n console.log(`Waiting for UserOperation receipt...`);\n\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n // In a real implementation, you'd query the bundler for receipt\n // For now, we'll return a basic receipt structure\n console.log(\"Checking for receipt...\");\n }\n\n return {\n userOpHash,\n success: true,\n };\n }\n\n async fundAccount(\n amount: bigint,\n fromPrivateKey: `0x${string}`\n ): Promise<Hash> {\n if (!this.smartAccount) {\n throw new Error(\"Smart account not connected\");\n }\n\n const signer = privateKeyToAccount(fromPrivateKey);\n const client = createWalletClient({\n account: signer,\n chain: this.config.chain,\n transport: http(this.config.rpcUrl),\n });\n\n console.log(`Funding account with ${amount} wei...`);\n\n const hash = await client.sendTransaction({\n account: signer, // ✅ Add this line\n to: this.smartAccount.address,\n value: amount,\n kzg: {\n blobToKzgCommitment: function (blob: ByteArray): ByteArray {\n throw new Error(\"Function not implemented.\");\n },\n computeBlobKzgProof: function (\n blob: ByteArray,\n commitment: ByteArray\n ): ByteArray {\n throw new Error(\"Function not implemented.\");\n },\n },\n chain: undefined,\n });\n\n console.log(`✅ Funded: ${hash}`);\n return hash;\n }\n\n // ==============================================================================\n // Batch Operations\n // ==============================================================================\n\n async sendBatchUserOperations(\n operations: SendUserOperationParams[]\n ): Promise<Hash[]> {\n const results: Hash[] = [];\n\n for (const op of operations) {\n const hash = await this.sendUserOperation(op);\n results.push(hash);\n }\n\n return results;\n }\n}\n\n// ==============================================================================\n// Helper Functions\n// ==============================================================================\n\nexport function createDagAAClient(config: DagAAConfig): DagAAClient {\n return new DagAAClient(config);\n}\n\nexport function parseDAG(amount: string): bigint {\n return parseEther(amount);\n}\n","import { defineChain } from \"viem\";\nimport { arbitrumSepolia } from \"viem/chains\";\nconst awakening_ = defineChain({\n id: 1043,\n name: \"Awakening Testnet\",\n nativeCurrency: { decimals: 18, name: \"Dag\", symbol: \"DAG\" },\n rpcUrls: { default: { http: [\"https://public-bdag.nownodes.io\"] } },\n blockExplorers: {\n default: { name: \"Explorer\", url: \"https://awakening.bdagscan.com/\" },\n },\n});\n\nexport const awakening = {\n bundler_rpc: \"http://0.0.0.0:3000/\",\n chain_config: awakening_,\n};\n\nexport const arbitrumSep = {\n bundler_rpc: \"http://0.0.0.0:3001/\",\n chain_config: arbitrumSepolia,\n};\n","// src/signers/PrivySigner.ts\nimport {\n type Account,\n type WalletClient,\n createWalletClient,\n custom,\n type Chain,\n LocalAccount,\n} from \"viem\";\nimport { ISigner } from \"./types.js\";\n\n/**\n * Privy Signer - Works with Privy's embedded wallets\n *\n * Usage in React:\n * ```tsx\n * import { useWallets } from '@privy-io/react-auth';\n *\n * const { wallets } = useWallets();\n * const embeddedWallet = wallets.find(w => w.walletClientType === 'privy');\n *\n * const signer = new PrivySigner(embeddedWallet, chain);\n * ```\n */\nexport class PrivySigner implements ISigner {\n private privyWallet: any; // Privy wallet object\n private chain: Chain;\n private cachedAddress?: `0x${string}`;\n private cachedWalletClient;\n\n constructor(privyWallet: any, chain: Chain) {\n if (!privyWallet) {\n throw new Error(\"Privy wallet is required\");\n }\n this.privyWallet = privyWallet;\n this.chain = chain;\n }\n\n async getAccount(): Promise<LocalAccount> {\n const provider = await this.privyWallet.getEthereumProvider();\n\n if (!provider) {\n throw new Error(\"No Ethereum provider found in Privy wallet\");\n }\n\n // Create a custom account from the provider\n return {\n address: this.privyWallet.address as `0x${string}`,\n type: \"json-rpc\",\n // @ts-ignore - Privy provider compatible with viem\n source: \"privateKey\",\n } as unknown as LocalAccount;\n }\n\n async getWalletClient(): Promise<WalletClient> {\n if (this.cachedWalletClient) {\n return this.cachedWalletClient;\n }\n\n const provider = await this.privyWallet.getEthereumProvider();\n\n if (!provider) {\n throw new Error(\"No Ethereum provider found in Privy wallet\");\n }\n\n // Create wallet client with Privy's provider\n this.cachedWalletClient = createWalletClient({\n account: await this.getAccount(),\n chain: this.chain,\n transport: custom(provider),\n });\n\n return this.cachedWalletClient;\n }\n\n async getAddress(): Promise<`0x${string}`> {\n if (this.cachedAddress) {\n return this.cachedAddress;\n }\n\n this.cachedAddress = this.privyWallet.address as `0x${string}`;\n return this.cachedAddress;\n }\n\n async isReady(): Promise<boolean> {\n try {\n const provider = await this.privyWallet.getEthereumProvider();\n return !!provider && !!this.privyWallet.address;\n } catch {\n return false;\n }\n }\n}\n","// src/signers/PrivateKeySigner.ts\nimport {\n createWalletClient,\n http,\n type Chain,\n type Account,\n type WalletClient,\n LocalAccount,\n} from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { ISigner } from \"./types.js\";\n\nexport class PrivateKeySigner implements ISigner {\n private account: LocalAccount;\n private walletClient;\n\n constructor(privateKey: `0x${string}`, chain: Chain, rpcUrl: string) {\n this.account = privateKeyToAccount(privateKey);\n this.walletClient = createWalletClient({\n account: this.account,\n chain,\n transport: http(rpcUrl),\n });\n }\n\n getAccount(): LocalAccount {\n return this.account;\n }\n\n getWalletClient(): WalletClient {\n return this.walletClient;\n }\n\n getAddress(): `0x${string}` {\n return this.account.address;\n }\n\n isReady(): boolean {\n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