@gitmyabi-stg/iost 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,562 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * IOSToken ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const IOSTokenAbi = [
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": "",
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": "",
81
+ "type": "bool"
82
+ }
83
+ ],
84
+ "payable": false,
85
+ "stateMutability": "nonpayable",
86
+ "type": "function"
87
+ },
88
+ {
89
+ "constant": true,
90
+ "inputs": [],
91
+ "name": "decimals",
92
+ "outputs": [
93
+ {
94
+ "name": "",
95
+ "type": "uint8"
96
+ }
97
+ ],
98
+ "payable": false,
99
+ "stateMutability": "view",
100
+ "type": "function"
101
+ },
102
+ {
103
+ "constant": true,
104
+ "inputs": [
105
+ {
106
+ "name": "_owner",
107
+ "type": "address"
108
+ }
109
+ ],
110
+ "name": "balanceOf",
111
+ "outputs": [
112
+ {
113
+ "name": "",
114
+ "type": "uint256"
115
+ }
116
+ ],
117
+ "payable": false,
118
+ "stateMutability": "view",
119
+ "type": "function"
120
+ },
121
+ {
122
+ "constant": true,
123
+ "inputs": [],
124
+ "name": "symbol",
125
+ "outputs": [
126
+ {
127
+ "name": "",
128
+ "type": "string"
129
+ }
130
+ ],
131
+ "payable": false,
132
+ "stateMutability": "view",
133
+ "type": "function"
134
+ },
135
+ {
136
+ "constant": false,
137
+ "inputs": [
138
+ {
139
+ "name": "_to",
140
+ "type": "address"
141
+ },
142
+ {
143
+ "name": "_value",
144
+ "type": "uint256"
145
+ }
146
+ ],
147
+ "name": "transfer",
148
+ "outputs": [
149
+ {
150
+ "name": "",
151
+ "type": "bool"
152
+ }
153
+ ],
154
+ "payable": false,
155
+ "stateMutability": "nonpayable",
156
+ "type": "function"
157
+ },
158
+ {
159
+ "constant": true,
160
+ "inputs": [
161
+ {
162
+ "name": "_owner",
163
+ "type": "address"
164
+ },
165
+ {
166
+ "name": "_spender",
167
+ "type": "address"
168
+ }
169
+ ],
170
+ "name": "allowance",
171
+ "outputs": [
172
+ {
173
+ "name": "",
174
+ "type": "uint256"
175
+ }
176
+ ],
177
+ "payable": false,
178
+ "stateMutability": "view",
179
+ "type": "function"
180
+ },
181
+ {
182
+ "inputs": [],
183
+ "payable": false,
184
+ "stateMutability": "nonpayable",
185
+ "type": "constructor"
186
+ },
187
+ {
188
+ "anonymous": false,
189
+ "inputs": [
190
+ {
191
+ "indexed": true,
192
+ "name": "_from",
193
+ "type": "address"
194
+ },
195
+ {
196
+ "indexed": true,
197
+ "name": "_to",
198
+ "type": "address"
199
+ },
200
+ {
201
+ "indexed": false,
202
+ "name": "_value",
203
+ "type": "uint256"
204
+ }
205
+ ],
206
+ "name": "Transfer",
207
+ "type": "event"
208
+ },
209
+ {
210
+ "anonymous": false,
211
+ "inputs": [
212
+ {
213
+ "indexed": true,
214
+ "name": "_owner",
215
+ "type": "address"
216
+ },
217
+ {
218
+ "indexed": true,
219
+ "name": "_spender",
220
+ "type": "address"
221
+ },
222
+ {
223
+ "indexed": false,
224
+ "name": "_value",
225
+ "type": "uint256"
226
+ }
227
+ ],
228
+ "name": "Approval",
229
+ "type": "event"
230
+ }
231
+ ] as const satisfies Abi;
232
+
233
+ /**
234
+ * Type-safe ABI for IOSToken
235
+ */
236
+ export type IOSTokenAbi = typeof IOSTokenAbi;
237
+
238
+ /**
239
+ * Contract instance type for IOSToken
240
+ */
241
+ // Use any for contract type to avoid complex viem type issues
242
+ // The runtime behavior is type-safe through viem's ABI typing
243
+ export type IOSTokenContract = any;
244
+
245
+ /**
246
+ * IOSToken Contract Class
247
+ *
248
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
249
+ *
250
+ * @example
251
+ * ```typescript
252
+ * import { createPublicClient, createWalletClient, http } from 'viem';
253
+ * import { mainnet } from 'viem/chains';
254
+ * import { IOSToken } from 'IOSToken';
255
+ *
256
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
257
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
258
+ *
259
+ * const contract = new IOSToken('0x...', { publicClient, walletClient });
260
+ *
261
+ * // Read functions
262
+ * const result = await contract.balanceOf('0x...');
263
+ *
264
+ * // Write functions
265
+ * const hash = await contract.transfer('0x...', 1000n);
266
+ *
267
+ * // Simulate transactions (dry-run)
268
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
269
+ * console.log('Gas estimate:', simulation.request.gas);
270
+ *
271
+ * // Watch events
272
+ * const unwatch = contract.watch.Transfer((event) => {
273
+ * console.log('Transfer event:', event);
274
+ * });
275
+ * ```
276
+ */
277
+ export class IOSToken {
278
+ private contract: IOSTokenContract;
279
+ private contractAddress: Address;
280
+ private publicClient: PublicClient;
281
+
282
+ constructor(
283
+ address: Address,
284
+ clients: {
285
+ publicClient: PublicClient;
286
+ walletClient?: WalletClient;
287
+ }
288
+ ) {
289
+ this.contractAddress = address;
290
+ this.publicClient = clients.publicClient;
291
+ this.contract = getContract({
292
+ address,
293
+ abi: IOSTokenAbi,
294
+ client: {
295
+ public: clients.publicClient,
296
+ wallet: clients.walletClient,
297
+ },
298
+ });
299
+ }
300
+
301
+ /**
302
+ * Get the contract address
303
+ */
304
+ get address(): Address {
305
+ return this.contractAddress;
306
+ }
307
+
308
+ /**
309
+ * Get the underlying viem contract instance.
310
+ */
311
+ getContract(): IOSTokenContract {
312
+ return this.contract;
313
+ }
314
+
315
+ /**
316
+ * name
317
+ * view
318
+ */
319
+ async name(): Promise<string> {
320
+ return this.contract.read.name() as Promise<string>;
321
+ }
322
+
323
+ /**
324
+ * totalSupply
325
+ * view
326
+ */
327
+ async totalSupply(): Promise<bigint> {
328
+ return this.contract.read.totalSupply() as Promise<bigint>;
329
+ }
330
+
331
+ /**
332
+ * decimals
333
+ * view
334
+ */
335
+ async decimals(): Promise<bigint> {
336
+ return this.contract.read.decimals() as Promise<bigint>;
337
+ }
338
+
339
+ /**
340
+ * balanceOf
341
+ * view
342
+ */
343
+ async balanceOf(_owner: `0x${string}`): Promise<bigint> {
344
+ return this.contract.read.balanceOf([_owner] as const) as Promise<bigint>;
345
+ }
346
+
347
+ /**
348
+ * symbol
349
+ * view
350
+ */
351
+ async symbol(): Promise<string> {
352
+ return this.contract.read.symbol() as Promise<string>;
353
+ }
354
+
355
+ /**
356
+ * allowance
357
+ * view
358
+ */
359
+ async allowance(_owner: `0x${string}`, _spender: `0x${string}`): Promise<bigint> {
360
+ return this.contract.read.allowance([_owner, _spender] as const) as Promise<bigint>;
361
+ }
362
+
363
+ /**
364
+ * approve
365
+ * nonpayable
366
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
367
+ */
368
+ async approve(_spender: `0x${string}`, _value: bigint, options?: {
369
+ accessList?: import('viem').AccessList;
370
+ authorizationList?: import('viem').AuthorizationList;
371
+ chain?: import('viem').Chain | null;
372
+ dataSuffix?: `0x${string}`;
373
+ gas?: bigint;
374
+ gasPrice?: bigint;
375
+ maxFeePerGas?: bigint;
376
+ maxPriorityFeePerGas?: bigint;
377
+ nonce?: number;
378
+ value?: bigint;
379
+ }): Promise<`0x${string}`> {
380
+ if (!this.contract.write) {
381
+ throw new Error('Wallet client is required for write operations');
382
+ }
383
+ return this.contract.write.approve([_spender, _value] as const, options) as Promise<`0x${string}`>;
384
+ }
385
+
386
+ /**
387
+ * transferFrom
388
+ * nonpayable
389
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
390
+ */
391
+ async transferFrom(_from: `0x${string}`, _to: `0x${string}`, _value: bigint, options?: {
392
+ accessList?: import('viem').AccessList;
393
+ authorizationList?: import('viem').AuthorizationList;
394
+ chain?: import('viem').Chain | null;
395
+ dataSuffix?: `0x${string}`;
396
+ gas?: bigint;
397
+ gasPrice?: bigint;
398
+ maxFeePerGas?: bigint;
399
+ maxPriorityFeePerGas?: bigint;
400
+ nonce?: number;
401
+ value?: bigint;
402
+ }): Promise<`0x${string}`> {
403
+ if (!this.contract.write) {
404
+ throw new Error('Wallet client is required for write operations');
405
+ }
406
+ return this.contract.write.transferFrom([_from, _to, _value] as const, options) as Promise<`0x${string}`>;
407
+ }
408
+
409
+ /**
410
+ * transfer
411
+ * nonpayable
412
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
413
+ */
414
+ async transfer(_to: `0x${string}`, _value: bigint, options?: {
415
+ accessList?: import('viem').AccessList;
416
+ authorizationList?: import('viem').AuthorizationList;
417
+ chain?: import('viem').Chain | null;
418
+ dataSuffix?: `0x${string}`;
419
+ gas?: bigint;
420
+ gasPrice?: bigint;
421
+ maxFeePerGas?: bigint;
422
+ maxPriorityFeePerGas?: bigint;
423
+ nonce?: number;
424
+ value?: bigint;
425
+ }): Promise<`0x${string}`> {
426
+ if (!this.contract.write) {
427
+ throw new Error('Wallet client is required for write operations');
428
+ }
429
+ return this.contract.write.transfer([_to, _value] as const, options) as Promise<`0x${string}`>;
430
+ }
431
+
432
+
433
+
434
+ /**
435
+ * Simulate contract write operations (dry-run without sending transaction)
436
+ *
437
+ * @example
438
+ * const result = await contract.simulate.transfer('0x...', 1000n);
439
+ * console.log('Gas estimate:', result.request.gas);
440
+ * console.log('Would succeed:', result.result);
441
+ */
442
+ get simulate() {
443
+ const contract = this.contract;
444
+ if (!contract.simulate) {
445
+ throw new Error('Public client is required for simulation');
446
+ }
447
+ return {
448
+ /**
449
+ * Simulate approve
450
+ * Returns gas estimate and result without sending transaction
451
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
452
+ */
453
+ async approve(_spender: `0x${string}`, _value: bigint, options?: {
454
+ accessList?: import('viem').AccessList;
455
+ authorizationList?: import('viem').AuthorizationList;
456
+ chain?: import('viem').Chain | null;
457
+ dataSuffix?: `0x${string}`;
458
+ gas?: bigint;
459
+ gasPrice?: bigint;
460
+ maxFeePerGas?: bigint;
461
+ maxPriorityFeePerGas?: bigint;
462
+ nonce?: number;
463
+ value?: bigint;
464
+ }): Promise<boolean> {
465
+ return contract.simulate.approve([_spender, _value] as const, options) as Promise<boolean>;
466
+ },
467
+ /**
468
+ * Simulate transferFrom
469
+ * Returns gas estimate and result without sending transaction
470
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
471
+ */
472
+ async transferFrom(_from: `0x${string}`, _to: `0x${string}`, _value: bigint, options?: {
473
+ accessList?: import('viem').AccessList;
474
+ authorizationList?: import('viem').AuthorizationList;
475
+ chain?: import('viem').Chain | null;
476
+ dataSuffix?: `0x${string}`;
477
+ gas?: bigint;
478
+ gasPrice?: bigint;
479
+ maxFeePerGas?: bigint;
480
+ maxPriorityFeePerGas?: bigint;
481
+ nonce?: number;
482
+ value?: bigint;
483
+ }): Promise<boolean> {
484
+ return contract.simulate.transferFrom([_from, _to, _value] as const, options) as Promise<boolean>;
485
+ },
486
+ /**
487
+ * Simulate transfer
488
+ * Returns gas estimate and result without sending transaction
489
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
490
+ */
491
+ async transfer(_to: `0x${string}`, _value: bigint, options?: {
492
+ accessList?: import('viem').AccessList;
493
+ authorizationList?: import('viem').AuthorizationList;
494
+ chain?: import('viem').Chain | null;
495
+ dataSuffix?: `0x${string}`;
496
+ gas?: bigint;
497
+ gasPrice?: bigint;
498
+ maxFeePerGas?: bigint;
499
+ maxPriorityFeePerGas?: bigint;
500
+ nonce?: number;
501
+ value?: bigint;
502
+ }): Promise<boolean> {
503
+ return contract.simulate.transfer([_to, _value] as const, options) as Promise<boolean>;
504
+ }
505
+ };
506
+ }
507
+
508
+ /**
509
+ * Watch contract events
510
+ *
511
+ * @example
512
+ * // Watch all Transfer events
513
+ * const unwatch = contract.watch.Transfer((event) => {
514
+ * console.log('Transfer:', event);
515
+ * });
516
+ *
517
+ * // Stop watching
518
+ * unwatch();
519
+ */
520
+ get watch() {
521
+ return {
522
+ /**
523
+ * Watch Transfer events
524
+ * @param callback Function to call when event is emitted
525
+ * @param filter Optional filter for indexed parameters
526
+ * @returns Unwatch function to stop listening
527
+ */
528
+ 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 }) => {
529
+ return this.publicClient.watchContractEvent({
530
+ address: this.contractAddress,
531
+ abi: IOSTokenAbi,
532
+ eventName: 'Transfer',
533
+ args: filter as any,
534
+ onLogs: (logs: any[]) => {
535
+ logs.forEach((log: any) => {
536
+ callback(log.args as any);
537
+ });
538
+ },
539
+ }) as () => void;
540
+ },
541
+ /**
542
+ * Watch Approval events
543
+ * @param callback Function to call when event is emitted
544
+ * @param filter Optional filter for indexed parameters
545
+ * @returns Unwatch function to stop listening
546
+ */
547
+ 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 }) => {
548
+ return this.publicClient.watchContractEvent({
549
+ address: this.contractAddress,
550
+ abi: IOSTokenAbi,
551
+ eventName: 'Approval',
552
+ args: filter as any,
553
+ onLogs: (logs: any[]) => {
554
+ logs.forEach((log: any) => {
555
+ callback(log.args as any);
556
+ });
557
+ },
558
+ }) as () => void;
559
+ }
560
+ };
561
+ }
562
+ }
@@ -0,0 +1,2 @@
1
+ export { IOSTokenAbi, IOSToken } from './IOSToken';
2
+ export type { IOSTokenAbi as IOSTokenAbiType, IOSTokenContract } from './IOSToken';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IOSToken = exports.IOSTokenAbi = void 0;
4
+ // Auto-generated exports for all contracts
5
+ var IOSToken_1 = require("./IOSToken");
6
+ Object.defineProperty(exports, "IOSTokenAbi", { enumerable: true, get: function () { return IOSToken_1.IOSTokenAbi; } });
7
+ Object.defineProperty(exports, "IOSToken", { enumerable: true, get: function () { return IOSToken_1.IOSToken; } });
@@ -0,0 +1,3 @@
1
+ // Auto-generated exports for all contracts
2
+ export { IOSTokenAbi, IOSToken } from './IOSToken';
3
+ export type { IOSTokenAbi as IOSTokenAbiType, IOSTokenContract } from './IOSToken';
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-stg/iost",
3
+ "version": "1.0.0",
4
+ "description": "Auto-generated TypeScript type bindings for IOST (build etherscan-iost-fa1a856c-1780492299192, commit 33239e3, 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": "Apache-2.0",
34
+ "dependencies": {
35
+ "viem": "^2.0.0"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/etherscan/iost"
40
+ },
41
+ "branch": "etherscan",
42
+ "shortHash": "33239e3"
43
+ }