@gitmyabi-stg/atos 1.0.0

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