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