@gitmyabi/hdsf 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,670 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERC20Token_json = exports.ERC20Token_jsonAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * ERC20Token_json ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.ERC20Token_jsonAbi = [
11
+ {
12
+ "inputs": [],
13
+ "stateMutability": "nonpayable",
14
+ "type": "constructor"
15
+ },
16
+ {
17
+ "anonymous": false,
18
+ "inputs": [
19
+ {
20
+ "indexed": true,
21
+ "internalType": "address",
22
+ "name": "tokenOwner",
23
+ "type": "address"
24
+ },
25
+ {
26
+ "indexed": true,
27
+ "internalType": "address",
28
+ "name": "spender",
29
+ "type": "address"
30
+ },
31
+ {
32
+ "indexed": false,
33
+ "internalType": "uint256",
34
+ "name": "tokens",
35
+ "type": "uint256"
36
+ }
37
+ ],
38
+ "name": "Approval",
39
+ "type": "event"
40
+ },
41
+ {
42
+ "anonymous": false,
43
+ "inputs": [
44
+ {
45
+ "indexed": true,
46
+ "internalType": "address",
47
+ "name": "from",
48
+ "type": "address"
49
+ },
50
+ {
51
+ "indexed": true,
52
+ "internalType": "address",
53
+ "name": "to",
54
+ "type": "address"
55
+ },
56
+ {
57
+ "indexed": false,
58
+ "internalType": "uint256",
59
+ "name": "tokens",
60
+ "type": "uint256"
61
+ }
62
+ ],
63
+ "name": "Transfer",
64
+ "type": "event"
65
+ },
66
+ {
67
+ "inputs": [],
68
+ "name": "_admin",
69
+ "outputs": [
70
+ {
71
+ "internalType": "address",
72
+ "name": "",
73
+ "type": "address"
74
+ }
75
+ ],
76
+ "stateMutability": "view",
77
+ "type": "function"
78
+ },
79
+ {
80
+ "inputs": [],
81
+ "name": "_owner",
82
+ "outputs": [
83
+ {
84
+ "internalType": "address",
85
+ "name": "",
86
+ "type": "address"
87
+ }
88
+ ],
89
+ "stateMutability": "view",
90
+ "type": "function"
91
+ },
92
+ {
93
+ "inputs": [],
94
+ "name": "_totalSupply",
95
+ "outputs": [
96
+ {
97
+ "internalType": "uint256",
98
+ "name": "",
99
+ "type": "uint256"
100
+ }
101
+ ],
102
+ "stateMutability": "view",
103
+ "type": "function"
104
+ },
105
+ {
106
+ "inputs": [
107
+ {
108
+ "internalType": "address",
109
+ "name": "tokenOwner",
110
+ "type": "address"
111
+ },
112
+ {
113
+ "internalType": "address",
114
+ "name": "spender",
115
+ "type": "address"
116
+ }
117
+ ],
118
+ "name": "allowance",
119
+ "outputs": [
120
+ {
121
+ "internalType": "uint256",
122
+ "name": "remaining",
123
+ "type": "uint256"
124
+ }
125
+ ],
126
+ "stateMutability": "view",
127
+ "type": "function"
128
+ },
129
+ {
130
+ "inputs": [
131
+ {
132
+ "internalType": "address",
133
+ "name": "spender",
134
+ "type": "address"
135
+ },
136
+ {
137
+ "internalType": "uint256",
138
+ "name": "tokens",
139
+ "type": "uint256"
140
+ }
141
+ ],
142
+ "name": "approve",
143
+ "outputs": [
144
+ {
145
+ "internalType": "bool",
146
+ "name": "success",
147
+ "type": "bool"
148
+ }
149
+ ],
150
+ "stateMutability": "nonpayable",
151
+ "type": "function"
152
+ },
153
+ {
154
+ "inputs": [
155
+ {
156
+ "internalType": "address",
157
+ "name": "tokenOwner",
158
+ "type": "address"
159
+ }
160
+ ],
161
+ "name": "balanceOf",
162
+ "outputs": [
163
+ {
164
+ "internalType": "uint256",
165
+ "name": "balance",
166
+ "type": "uint256"
167
+ }
168
+ ],
169
+ "stateMutability": "view",
170
+ "type": "function"
171
+ },
172
+ {
173
+ "inputs": [],
174
+ "name": "decimals",
175
+ "outputs": [
176
+ {
177
+ "internalType": "uint8",
178
+ "name": "",
179
+ "type": "uint8"
180
+ }
181
+ ],
182
+ "stateMutability": "view",
183
+ "type": "function"
184
+ },
185
+ {
186
+ "inputs": [],
187
+ "name": "name",
188
+ "outputs": [
189
+ {
190
+ "internalType": "string",
191
+ "name": "",
192
+ "type": "string"
193
+ }
194
+ ],
195
+ "stateMutability": "view",
196
+ "type": "function"
197
+ },
198
+ {
199
+ "inputs": [],
200
+ "name": "owner",
201
+ "outputs": [
202
+ {
203
+ "internalType": "address",
204
+ "name": "",
205
+ "type": "address"
206
+ }
207
+ ],
208
+ "stateMutability": "view",
209
+ "type": "function"
210
+ },
211
+ {
212
+ "inputs": [
213
+ {
214
+ "internalType": "uint256",
215
+ "name": "a",
216
+ "type": "uint256"
217
+ },
218
+ {
219
+ "internalType": "uint256",
220
+ "name": "b",
221
+ "type": "uint256"
222
+ }
223
+ ],
224
+ "name": "safeAdd",
225
+ "outputs": [
226
+ {
227
+ "internalType": "uint256",
228
+ "name": "c",
229
+ "type": "uint256"
230
+ }
231
+ ],
232
+ "stateMutability": "pure",
233
+ "type": "function"
234
+ },
235
+ {
236
+ "inputs": [
237
+ {
238
+ "internalType": "uint256",
239
+ "name": "a",
240
+ "type": "uint256"
241
+ },
242
+ {
243
+ "internalType": "uint256",
244
+ "name": "b",
245
+ "type": "uint256"
246
+ }
247
+ ],
248
+ "name": "safeDiv",
249
+ "outputs": [
250
+ {
251
+ "internalType": "uint256",
252
+ "name": "c",
253
+ "type": "uint256"
254
+ }
255
+ ],
256
+ "stateMutability": "pure",
257
+ "type": "function"
258
+ },
259
+ {
260
+ "inputs": [
261
+ {
262
+ "internalType": "uint256",
263
+ "name": "a",
264
+ "type": "uint256"
265
+ },
266
+ {
267
+ "internalType": "uint256",
268
+ "name": "b",
269
+ "type": "uint256"
270
+ }
271
+ ],
272
+ "name": "safeMul",
273
+ "outputs": [
274
+ {
275
+ "internalType": "uint256",
276
+ "name": "c",
277
+ "type": "uint256"
278
+ }
279
+ ],
280
+ "stateMutability": "pure",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "inputs": [
285
+ {
286
+ "internalType": "uint256",
287
+ "name": "a",
288
+ "type": "uint256"
289
+ },
290
+ {
291
+ "internalType": "uint256",
292
+ "name": "b",
293
+ "type": "uint256"
294
+ }
295
+ ],
296
+ "name": "safeSub",
297
+ "outputs": [
298
+ {
299
+ "internalType": "uint256",
300
+ "name": "c",
301
+ "type": "uint256"
302
+ }
303
+ ],
304
+ "stateMutability": "pure",
305
+ "type": "function"
306
+ },
307
+ {
308
+ "inputs": [],
309
+ "name": "symbol",
310
+ "outputs": [
311
+ {
312
+ "internalType": "string",
313
+ "name": "",
314
+ "type": "string"
315
+ }
316
+ ],
317
+ "stateMutability": "view",
318
+ "type": "function"
319
+ },
320
+ {
321
+ "inputs": [],
322
+ "name": "totalSupply",
323
+ "outputs": [
324
+ {
325
+ "internalType": "uint256",
326
+ "name": "",
327
+ "type": "uint256"
328
+ }
329
+ ],
330
+ "stateMutability": "view",
331
+ "type": "function"
332
+ },
333
+ {
334
+ "inputs": [
335
+ {
336
+ "internalType": "address",
337
+ "name": "to",
338
+ "type": "address"
339
+ },
340
+ {
341
+ "internalType": "uint256",
342
+ "name": "tokens",
343
+ "type": "uint256"
344
+ }
345
+ ],
346
+ "name": "transfer",
347
+ "outputs": [
348
+ {
349
+ "internalType": "bool",
350
+ "name": "success",
351
+ "type": "bool"
352
+ }
353
+ ],
354
+ "stateMutability": "nonpayable",
355
+ "type": "function"
356
+ },
357
+ {
358
+ "inputs": [
359
+ {
360
+ "internalType": "address",
361
+ "name": "from",
362
+ "type": "address"
363
+ },
364
+ {
365
+ "internalType": "address",
366
+ "name": "to",
367
+ "type": "address"
368
+ },
369
+ {
370
+ "internalType": "uint256",
371
+ "name": "tokens",
372
+ "type": "uint256"
373
+ }
374
+ ],
375
+ "name": "transferFrom",
376
+ "outputs": [
377
+ {
378
+ "internalType": "bool",
379
+ "name": "success",
380
+ "type": "bool"
381
+ }
382
+ ],
383
+ "stateMutability": "nonpayable",
384
+ "type": "function"
385
+ }
386
+ ];
387
+ /**
388
+ * ERC20Token_json Contract Class
389
+ *
390
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
391
+ *
392
+ * @example
393
+ * ```typescript
394
+ * import { createPublicClient, createWalletClient, http } from 'viem';
395
+ * import { mainnet } from 'viem/chains';
396
+ * import { ERC20Token_json } from 'ERC20Token_json';
397
+ *
398
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
399
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
400
+ *
401
+ * const contract = new ERC20Token_json('0x...', { publicClient, walletClient });
402
+ *
403
+ * // Read functions
404
+ * const result = await contract.balanceOf('0x...');
405
+ *
406
+ * // Write functions
407
+ * const hash = await contract.transfer('0x...', 1000n);
408
+ *
409
+ * // Simulate transactions (dry-run)
410
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
411
+ * console.log('Gas estimate:', simulation.request.gas);
412
+ *
413
+ * // Watch events
414
+ * const unwatch = contract.watch.Transfer((event) => {
415
+ * console.log('Transfer event:', event);
416
+ * });
417
+ * ```
418
+ */
419
+ class ERC20Token_json {
420
+ constructor(address, clients) {
421
+ this.contractAddress = address;
422
+ this.publicClient = clients.publicClient;
423
+ this.contract = (0, viem_1.getContract)({
424
+ address,
425
+ abi: exports.ERC20Token_jsonAbi,
426
+ client: {
427
+ public: clients.publicClient,
428
+ wallet: clients.walletClient,
429
+ },
430
+ });
431
+ }
432
+ /**
433
+ * Get the contract address
434
+ */
435
+ get address() {
436
+ return this.contractAddress;
437
+ }
438
+ /**
439
+ * Get the underlying viem contract instance
440
+ */
441
+ getContract() {
442
+ return this.contract;
443
+ }
444
+ /**
445
+ * _admin
446
+ * view
447
+ */
448
+ async _admin() {
449
+ return this.contract.read._admin();
450
+ }
451
+ /**
452
+ * _owner
453
+ * view
454
+ */
455
+ async _owner() {
456
+ return this.contract.read._owner();
457
+ }
458
+ /**
459
+ * _totalSupply
460
+ * view
461
+ */
462
+ async _totalSupply() {
463
+ return this.contract.read._totalSupply();
464
+ }
465
+ /**
466
+ * allowance
467
+ * view
468
+ */
469
+ async allowance(tokenOwner, spender) {
470
+ return this.contract.read.allowance([tokenOwner, spender]);
471
+ }
472
+ /**
473
+ * balanceOf
474
+ * view
475
+ */
476
+ async balanceOf(tokenOwner) {
477
+ return this.contract.read.balanceOf([tokenOwner]);
478
+ }
479
+ /**
480
+ * decimals
481
+ * view
482
+ */
483
+ async decimals() {
484
+ return this.contract.read.decimals();
485
+ }
486
+ /**
487
+ * name
488
+ * view
489
+ */
490
+ async name() {
491
+ return this.contract.read.name();
492
+ }
493
+ /**
494
+ * owner
495
+ * view
496
+ */
497
+ async owner() {
498
+ return this.contract.read.owner();
499
+ }
500
+ /**
501
+ * safeAdd
502
+ * pure
503
+ */
504
+ async safeAdd(a, b) {
505
+ return this.contract.read.safeAdd([a, b]);
506
+ }
507
+ /**
508
+ * safeDiv
509
+ * pure
510
+ */
511
+ async safeDiv(a, b) {
512
+ return this.contract.read.safeDiv([a, b]);
513
+ }
514
+ /**
515
+ * safeMul
516
+ * pure
517
+ */
518
+ async safeMul(a, b) {
519
+ return this.contract.read.safeMul([a, b]);
520
+ }
521
+ /**
522
+ * safeSub
523
+ * pure
524
+ */
525
+ async safeSub(a, b) {
526
+ return this.contract.read.safeSub([a, b]);
527
+ }
528
+ /**
529
+ * symbol
530
+ * view
531
+ */
532
+ async symbol() {
533
+ return this.contract.read.symbol();
534
+ }
535
+ /**
536
+ * totalSupply
537
+ * view
538
+ */
539
+ async totalSupply() {
540
+ return this.contract.read.totalSupply();
541
+ }
542
+ /**
543
+ * approve
544
+ * nonpayable
545
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
546
+ */
547
+ async approve(spender, tokens, options) {
548
+ if (!this.contract.write) {
549
+ throw new Error('Wallet client is required for write operations');
550
+ }
551
+ return this.contract.write.approve([spender, tokens], options);
552
+ }
553
+ /**
554
+ * transfer
555
+ * nonpayable
556
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
557
+ */
558
+ async transfer(to, tokens, options) {
559
+ if (!this.contract.write) {
560
+ throw new Error('Wallet client is required for write operations');
561
+ }
562
+ return this.contract.write.transfer([to, tokens], options);
563
+ }
564
+ /**
565
+ * transferFrom
566
+ * nonpayable
567
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
568
+ */
569
+ async transferFrom(from, to, tokens, options) {
570
+ if (!this.contract.write) {
571
+ throw new Error('Wallet client is required for write operations');
572
+ }
573
+ return this.contract.write.transferFrom([from, to, tokens], options);
574
+ }
575
+ /**
576
+ * Simulate contract write operations (dry-run without sending transaction)
577
+ *
578
+ * @example
579
+ * const result = await contract.simulate.transfer('0x...', 1000n);
580
+ * console.log('Gas estimate:', result.request.gas);
581
+ * console.log('Would succeed:', result.result);
582
+ */
583
+ get simulate() {
584
+ const contract = this.contract;
585
+ if (!contract.simulate) {
586
+ throw new Error('Public client is required for simulation');
587
+ }
588
+ return {
589
+ /**
590
+ * Simulate approve
591
+ * Returns gas estimate and result without sending transaction
592
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
593
+ */
594
+ async approve(spender, tokens, options) {
595
+ return contract.simulate.approve([spender, tokens], options);
596
+ },
597
+ /**
598
+ * Simulate transfer
599
+ * Returns gas estimate and result without sending transaction
600
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
601
+ */
602
+ async transfer(to, tokens, options) {
603
+ return contract.simulate.transfer([to, tokens], options);
604
+ },
605
+ /**
606
+ * Simulate transferFrom
607
+ * Returns gas estimate and result without sending transaction
608
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
609
+ */
610
+ async transferFrom(from, to, tokens, options) {
611
+ return contract.simulate.transferFrom([from, to, tokens], options);
612
+ }
613
+ };
614
+ }
615
+ /**
616
+ * Watch contract events
617
+ *
618
+ * @example
619
+ * // Watch all Transfer events
620
+ * const unwatch = contract.watch.Transfer((event) => {
621
+ * console.log('Transfer:', event);
622
+ * });
623
+ *
624
+ * // Stop watching
625
+ * unwatch();
626
+ */
627
+ get watch() {
628
+ return {
629
+ /**
630
+ * Watch Approval events
631
+ * @param callback Function to call when event is emitted
632
+ * @param filter Optional filter for indexed parameters
633
+ * @returns Unwatch function to stop listening
634
+ */
635
+ Approval: (callback, filter) => {
636
+ return this.publicClient.watchContractEvent({
637
+ address: this.contractAddress,
638
+ abi: exports.ERC20Token_jsonAbi,
639
+ eventName: 'Approval',
640
+ args: filter,
641
+ onLogs: (logs) => {
642
+ logs.forEach((log) => {
643
+ callback(log.args);
644
+ });
645
+ },
646
+ });
647
+ },
648
+ /**
649
+ * Watch Transfer events
650
+ * @param callback Function to call when event is emitted
651
+ * @param filter Optional filter for indexed parameters
652
+ * @returns Unwatch function to stop listening
653
+ */
654
+ Transfer: (callback, filter) => {
655
+ return this.publicClient.watchContractEvent({
656
+ address: this.contractAddress,
657
+ abi: exports.ERC20Token_jsonAbi,
658
+ eventName: 'Transfer',
659
+ args: filter,
660
+ onLogs: (logs) => {
661
+ logs.forEach((log) => {
662
+ callback(log.args);
663
+ });
664
+ },
665
+ });
666
+ }
667
+ };
668
+ }
669
+ }
670
+ exports.ERC20Token_json = ERC20Token_json;