@gitmyabi/storage 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,517 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * Storage_json ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const Storage_jsonAbi = [
10
+ {
11
+ "inputs": [],
12
+ "name": "InvalidOwner",
13
+ "type": "error"
14
+ },
15
+ {
16
+ "inputs": [],
17
+ "name": "InvalidSessionId",
18
+ "type": "error"
19
+ },
20
+ {
21
+ "inputs": [
22
+ {
23
+ "internalType": "address",
24
+ "name": "validator",
25
+ "type": "address"
26
+ }
27
+ ],
28
+ "name": "InvalidValidator",
29
+ "type": "error"
30
+ },
31
+ {
32
+ "anonymous": false,
33
+ "inputs": [
34
+ {
35
+ "indexed": false,
36
+ "internalType": "uint256",
37
+ "name": "utilisedNonce",
38
+ "type": "uint256"
39
+ }
40
+ ],
41
+ "name": "NonceConsumed",
42
+ "type": "event"
43
+ },
44
+ {
45
+ "anonymous": false,
46
+ "inputs": [
47
+ {
48
+ "indexed": false,
49
+ "internalType": "uint256",
50
+ "name": "id",
51
+ "type": "uint256"
52
+ }
53
+ ],
54
+ "name": "SessionRevoked",
55
+ "type": "event"
56
+ },
57
+ {
58
+ "anonymous": false,
59
+ "inputs": [
60
+ {
61
+ "indexed": false,
62
+ "internalType": "address",
63
+ "name": "validator",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "indexed": false,
68
+ "internalType": "bool",
69
+ "name": "status",
70
+ "type": "bool"
71
+ }
72
+ ],
73
+ "name": "ValidatorStatusUpdated",
74
+ "type": "event"
75
+ },
76
+ {
77
+ "inputs": [],
78
+ "name": "getNonce",
79
+ "outputs": [
80
+ {
81
+ "internalType": "uint256",
82
+ "name": "",
83
+ "type": "uint256"
84
+ }
85
+ ],
86
+ "stateMutability": "view",
87
+ "type": "function"
88
+ },
89
+ {
90
+ "inputs": [],
91
+ "name": "getOwner",
92
+ "outputs": [
93
+ {
94
+ "internalType": "address",
95
+ "name": "",
96
+ "type": "address"
97
+ }
98
+ ],
99
+ "stateMutability": "view",
100
+ "type": "function"
101
+ },
102
+ {
103
+ "inputs": [
104
+ {
105
+ "internalType": "address",
106
+ "name": "validator",
107
+ "type": "address"
108
+ }
109
+ ],
110
+ "name": "readAndUpdateNonce",
111
+ "outputs": [
112
+ {
113
+ "internalType": "uint256",
114
+ "name": "",
115
+ "type": "uint256"
116
+ }
117
+ ],
118
+ "stateMutability": "nonpayable",
119
+ "type": "function"
120
+ },
121
+ {
122
+ "inputs": [
123
+ {
124
+ "internalType": "uint256",
125
+ "name": "id",
126
+ "type": "uint256"
127
+ }
128
+ ],
129
+ "name": "revokeSession",
130
+ "outputs": [],
131
+ "stateMutability": "nonpayable",
132
+ "type": "function"
133
+ },
134
+ {
135
+ "inputs": [
136
+ {
137
+ "internalType": "address",
138
+ "name": "validator",
139
+ "type": "address"
140
+ },
141
+ {
142
+ "internalType": "bool",
143
+ "name": "isValid",
144
+ "type": "bool"
145
+ }
146
+ ],
147
+ "name": "setValidatorStatus",
148
+ "outputs": [],
149
+ "stateMutability": "nonpayable",
150
+ "type": "function"
151
+ },
152
+ {
153
+ "inputs": [
154
+ {
155
+ "internalType": "uint256",
156
+ "name": "id",
157
+ "type": "uint256"
158
+ },
159
+ {
160
+ "internalType": "address",
161
+ "name": "validator",
162
+ "type": "address"
163
+ }
164
+ ],
165
+ "name": "validateSession",
166
+ "outputs": [],
167
+ "stateMutability": "view",
168
+ "type": "function"
169
+ },
170
+ {
171
+ "inputs": [
172
+ {
173
+ "internalType": "address",
174
+ "name": "validator",
175
+ "type": "address"
176
+ }
177
+ ],
178
+ "name": "validateValidator",
179
+ "outputs": [],
180
+ "stateMutability": "view",
181
+ "type": "function"
182
+ }
183
+ ] as const satisfies Abi;
184
+
185
+ /**
186
+ * Type-safe ABI for Storage_json
187
+ */
188
+ export type Storage_jsonAbi = typeof Storage_jsonAbi;
189
+
190
+ /**
191
+ * Contract instance type for Storage_json
192
+ */
193
+ // Use any for contract type to avoid complex viem type issues
194
+ // The runtime behavior is type-safe through viem's ABI typing
195
+ export type Storage_jsonContract = any;
196
+
197
+ /**
198
+ * Storage_json Contract Class
199
+ *
200
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * import { createPublicClient, createWalletClient, http } from 'viem';
205
+ * import { mainnet } from 'viem/chains';
206
+ * import { Storage_json } from 'Storage_json';
207
+ *
208
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
209
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
210
+ *
211
+ * const contract = new Storage_json('0x...', { publicClient, walletClient });
212
+ *
213
+ * // Read functions
214
+ * const result = await contract.balanceOf('0x...');
215
+ *
216
+ * // Write functions
217
+ * const hash = await contract.transfer('0x...', 1000n);
218
+ *
219
+ * // Simulate transactions (dry-run)
220
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
221
+ * console.log('Gas estimate:', simulation.request.gas);
222
+ *
223
+ * // Watch events
224
+ * const unwatch = contract.watch.Transfer((event) => {
225
+ * console.log('Transfer event:', event);
226
+ * });
227
+ * ```
228
+ */
229
+ export class Storage_json {
230
+ private contract: Storage_jsonContract;
231
+ private contractAddress: Address;
232
+ private publicClient: PublicClient;
233
+
234
+ constructor(
235
+ address: Address,
236
+ clients: {
237
+ publicClient: PublicClient;
238
+ walletClient?: WalletClient;
239
+ }
240
+ ) {
241
+ this.contractAddress = address;
242
+ this.publicClient = clients.publicClient;
243
+ this.contract = getContract({
244
+ address,
245
+ abi: Storage_jsonAbi,
246
+ client: {
247
+ public: clients.publicClient,
248
+ wallet: clients.walletClient,
249
+ },
250
+ });
251
+ }
252
+
253
+ /**
254
+ * Get the contract address
255
+ */
256
+ get address(): Address {
257
+ return this.contractAddress;
258
+ }
259
+
260
+ /**
261
+ * Get the underlying viem contract instance
262
+ */
263
+ getContract(): Storage_jsonContract {
264
+ return this.contract;
265
+ }
266
+
267
+ /**
268
+ * getNonce
269
+ * view
270
+ */
271
+ async getNonce(): Promise<bigint> {
272
+ return this.contract.read.getNonce() as Promise<bigint>;
273
+ }
274
+
275
+ /**
276
+ * getOwner
277
+ * view
278
+ */
279
+ async getOwner(): Promise<`0x${string}`> {
280
+ return this.contract.read.getOwner() as Promise<`0x${string}`>;
281
+ }
282
+
283
+ /**
284
+ * validateSession
285
+ * view
286
+ */
287
+ async validateSession(id: bigint, validator: `0x${string}`): Promise<void> {
288
+ return this.contract.read.validateSession([id, validator] as const) as Promise<void>;
289
+ }
290
+
291
+ /**
292
+ * validateValidator
293
+ * view
294
+ */
295
+ async validateValidator(validator: `0x${string}`): Promise<void> {
296
+ return this.contract.read.validateValidator([validator] as const) as Promise<void>;
297
+ }
298
+
299
+ /**
300
+ * readAndUpdateNonce
301
+ * nonpayable
302
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
303
+ */
304
+ async readAndUpdateNonce(validator: `0x${string}`, options?: {
305
+ accessList?: import('viem').AccessList;
306
+ authorizationList?: import('viem').AuthorizationList;
307
+ chain?: import('viem').Chain | null;
308
+ dataSuffix?: `0x${string}`;
309
+ gas?: bigint;
310
+ gasPrice?: bigint;
311
+ maxFeePerGas?: bigint;
312
+ maxPriorityFeePerGas?: bigint;
313
+ nonce?: number;
314
+ value?: bigint;
315
+ }): Promise<`0x${string}`> {
316
+ if (!this.contract.write) {
317
+ throw new Error('Wallet client is required for write operations');
318
+ }
319
+ return this.contract.write.readAndUpdateNonce([validator] as const, options) as Promise<`0x${string}`>;
320
+ }
321
+
322
+ /**
323
+ * revokeSession
324
+ * nonpayable
325
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
326
+ */
327
+ async revokeSession(id: bigint, options?: {
328
+ accessList?: import('viem').AccessList;
329
+ authorizationList?: import('viem').AuthorizationList;
330
+ chain?: import('viem').Chain | null;
331
+ dataSuffix?: `0x${string}`;
332
+ gas?: bigint;
333
+ gasPrice?: bigint;
334
+ maxFeePerGas?: bigint;
335
+ maxPriorityFeePerGas?: bigint;
336
+ nonce?: number;
337
+ value?: bigint;
338
+ }): Promise<`0x${string}`> {
339
+ if (!this.contract.write) {
340
+ throw new Error('Wallet client is required for write operations');
341
+ }
342
+ return this.contract.write.revokeSession([id] as const, options) as Promise<`0x${string}`>;
343
+ }
344
+
345
+ /**
346
+ * setValidatorStatus
347
+ * nonpayable
348
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
349
+ */
350
+ async setValidatorStatus(validator: `0x${string}`, isValid: boolean, options?: {
351
+ accessList?: import('viem').AccessList;
352
+ authorizationList?: import('viem').AuthorizationList;
353
+ chain?: import('viem').Chain | null;
354
+ dataSuffix?: `0x${string}`;
355
+ gas?: bigint;
356
+ gasPrice?: bigint;
357
+ maxFeePerGas?: bigint;
358
+ maxPriorityFeePerGas?: bigint;
359
+ nonce?: number;
360
+ value?: bigint;
361
+ }): Promise<`0x${string}`> {
362
+ if (!this.contract.write) {
363
+ throw new Error('Wallet client is required for write operations');
364
+ }
365
+ return this.contract.write.setValidatorStatus([validator, isValid] as const, options) as Promise<`0x${string}`>;
366
+ }
367
+
368
+
369
+
370
+ /**
371
+ * Simulate contract write operations (dry-run without sending transaction)
372
+ *
373
+ * @example
374
+ * const result = await contract.simulate.transfer('0x...', 1000n);
375
+ * console.log('Gas estimate:', result.request.gas);
376
+ * console.log('Would succeed:', result.result);
377
+ */
378
+ get simulate() {
379
+ const contract = this.contract;
380
+ if (!contract.simulate) {
381
+ throw new Error('Public client is required for simulation');
382
+ }
383
+ return {
384
+ /**
385
+ * Simulate readAndUpdateNonce
386
+ * Returns gas estimate and result without sending transaction
387
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
388
+ */
389
+ async readAndUpdateNonce(validator: `0x${string}`, options?: {
390
+ accessList?: import('viem').AccessList;
391
+ authorizationList?: import('viem').AuthorizationList;
392
+ chain?: import('viem').Chain | null;
393
+ dataSuffix?: `0x${string}`;
394
+ gas?: bigint;
395
+ gasPrice?: bigint;
396
+ maxFeePerGas?: bigint;
397
+ maxPriorityFeePerGas?: bigint;
398
+ nonce?: number;
399
+ value?: bigint;
400
+ }): Promise<bigint> {
401
+ return contract.simulate.readAndUpdateNonce([validator] as const, options) as Promise<bigint>;
402
+ },
403
+ /**
404
+ * Simulate revokeSession
405
+ * Returns gas estimate and result without sending transaction
406
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
407
+ */
408
+ async revokeSession(id: bigint, options?: {
409
+ accessList?: import('viem').AccessList;
410
+ authorizationList?: import('viem').AuthorizationList;
411
+ chain?: import('viem').Chain | null;
412
+ dataSuffix?: `0x${string}`;
413
+ gas?: bigint;
414
+ gasPrice?: bigint;
415
+ maxFeePerGas?: bigint;
416
+ maxPriorityFeePerGas?: bigint;
417
+ nonce?: number;
418
+ value?: bigint;
419
+ }): Promise<void> {
420
+ return contract.simulate.revokeSession([id] as const, options) as Promise<void>;
421
+ },
422
+ /**
423
+ * Simulate setValidatorStatus
424
+ * Returns gas estimate and result without sending transaction
425
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
426
+ */
427
+ async setValidatorStatus(validator: `0x${string}`, isValid: boolean, options?: {
428
+ accessList?: import('viem').AccessList;
429
+ authorizationList?: import('viem').AuthorizationList;
430
+ chain?: import('viem').Chain | null;
431
+ dataSuffix?: `0x${string}`;
432
+ gas?: bigint;
433
+ gasPrice?: bigint;
434
+ maxFeePerGas?: bigint;
435
+ maxPriorityFeePerGas?: bigint;
436
+ nonce?: number;
437
+ value?: bigint;
438
+ }): Promise<void> {
439
+ return contract.simulate.setValidatorStatus([validator, isValid] as const, options) as Promise<void>;
440
+ }
441
+ };
442
+ }
443
+
444
+ /**
445
+ * Watch contract events
446
+ *
447
+ * @example
448
+ * // Watch all Transfer events
449
+ * const unwatch = contract.watch.Transfer((event) => {
450
+ * console.log('Transfer:', event);
451
+ * });
452
+ *
453
+ * // Stop watching
454
+ * unwatch();
455
+ */
456
+ get watch() {
457
+ return {
458
+ /**
459
+ * Watch NonceConsumed events
460
+ * @param callback Function to call when event is emitted
461
+ * @param filter Optional filter for indexed parameters
462
+ * @returns Unwatch function to stop listening
463
+ */
464
+ NonceConsumed: (callback: (event: { utilisedNonce: bigint }) => void) => {
465
+ return this.publicClient.watchContractEvent({
466
+ address: this.contractAddress,
467
+ abi: Storage_jsonAbi,
468
+ eventName: 'NonceConsumed',
469
+
470
+ onLogs: (logs: any[]) => {
471
+ logs.forEach((log: any) => {
472
+ callback(log.args as any);
473
+ });
474
+ },
475
+ }) as () => void;
476
+ },
477
+ /**
478
+ * Watch SessionRevoked events
479
+ * @param callback Function to call when event is emitted
480
+ * @param filter Optional filter for indexed parameters
481
+ * @returns Unwatch function to stop listening
482
+ */
483
+ SessionRevoked: (callback: (event: { id: bigint }) => void) => {
484
+ return this.publicClient.watchContractEvent({
485
+ address: this.contractAddress,
486
+ abi: Storage_jsonAbi,
487
+ eventName: 'SessionRevoked',
488
+
489
+ onLogs: (logs: any[]) => {
490
+ logs.forEach((log: any) => {
491
+ callback(log.args as any);
492
+ });
493
+ },
494
+ }) as () => void;
495
+ },
496
+ /**
497
+ * Watch ValidatorStatusUpdated events
498
+ * @param callback Function to call when event is emitted
499
+ * @param filter Optional filter for indexed parameters
500
+ * @returns Unwatch function to stop listening
501
+ */
502
+ ValidatorStatusUpdated: (callback: (event: { validator: `0x${string}`; status: boolean }) => void) => {
503
+ return this.publicClient.watchContractEvent({
504
+ address: this.contractAddress,
505
+ abi: Storage_jsonAbi,
506
+ eventName: 'ValidatorStatusUpdated',
507
+
508
+ onLogs: (logs: any[]) => {
509
+ logs.forEach((log: any) => {
510
+ callback(log.args as any);
511
+ });
512
+ },
513
+ }) as () => void;
514
+ }
515
+ };
516
+ }
517
+ }
@@ -0,0 +1,2 @@
1
+ export { Storage_jsonAbi, Storage_json } from './Storage_json';
2
+ export type { Storage_jsonAbi as Storage_jsonAbiType, Storage_jsonContract } from './Storage_json';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Storage_json = exports.Storage_jsonAbi = void 0;
4
+ // Auto-generated exports for all contracts
5
+ var Storage_json_1 = require("./Storage_json");
6
+ Object.defineProperty(exports, "Storage_jsonAbi", { enumerable: true, get: function () { return Storage_json_1.Storage_jsonAbi; } });
7
+ Object.defineProperty(exports, "Storage_json", { enumerable: true, get: function () { return Storage_json_1.Storage_json; } });
@@ -0,0 +1,3 @@
1
+ // Auto-generated exports for all contracts
2
+ export { Storage_jsonAbi, Storage_json } from './Storage_json';
3
+ export type { Storage_jsonAbi as Storage_jsonAbiType, Storage_jsonContract } from './Storage_json';
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);
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@gitmyabi/storage",
3
+ "version": "1.0.0",
4
+ "description": "Auto-generated TypeScript type bindings for Storage (build etherscan-storage-eb2864a0-1785467151251, commit 4759d25, branch etherscan)",
5
+ "main": "./index.js",
6
+ "types": "./index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./index.js",
10
+ "require": "./index.js",
11
+ "types": "./index.d.ts"
12
+ },
13
+ "./contracts": {
14
+ "import": "./contracts/index.js",
15
+ "require": "./contracts/index.js",
16
+ "types": "./contracts/index.d.ts"
17
+ }
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "contracts"
23
+ ],
24
+ "keywords": [
25
+ "ethereum",
26
+ "smart-contracts",
27
+ "viem",
28
+ "wagmi",
29
+ "typescript",
30
+ "abi",
31
+ "ethers-v6"
32
+ ],
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "viem": "^2.0.0"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/etherscan/storage"
40
+ },
41
+ "branch": "etherscan",
42
+ "shortHash": "4759d25"
43
+ }