@gitmyabi/migrations 0.0.0-stage → 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.
- package/README.md +107 -2
- package/contracts/Migrations.d.ts +154 -0
- package/contracts/Migrations.js +166 -0
- package/contracts/Migrations.ts +218 -0
- package/contracts/index.d.ts +2 -0
- package/contracts/index.js +7 -0
- package/contracts/index.ts +3 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/package.json +40 -3
package/README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gitmyabi/migrations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Auto-generated TypeScript type bindings for **Migrations**
|
|
4
|
+
|
|
5
|
+
- **Build ID**: `etherscan-migrations-e57d3c97-1794001043665`
|
|
6
|
+
- **Build Number**: 1
|
|
7
|
+
- **Commit**: `fc2b8c2`
|
|
8
|
+
- **Branch**: `etherscan`
|
|
9
|
+
- **Target**: `ethers-v6`
|
|
10
|
+
- **Contracts**: 1
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @gitmyabi/migrations@1.0.0
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Class-based API (TypeChain-like)
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createPublicClient, createWalletClient, http } from 'viem';
|
|
24
|
+
import { mainnet } from 'viem/chains';
|
|
25
|
+
import { YourContract } from '@gitmyabi/migrations';
|
|
26
|
+
|
|
27
|
+
const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
28
|
+
const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
29
|
+
|
|
30
|
+
// Create contract instance
|
|
31
|
+
const contract = new YourContract('0x...', { publicClient, walletClient });
|
|
32
|
+
|
|
33
|
+
// Read functions - call directly like TypeChain!
|
|
34
|
+
const result = await contract.yourMethod(param1, param2);
|
|
35
|
+
|
|
36
|
+
// Write functions - also call directly!
|
|
37
|
+
const hash = await contract.transfer('0x...', 1000n);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### With viem directly
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { createPublicClient, http } from 'viem';
|
|
44
|
+
import { mainnet } from 'viem/chains';
|
|
45
|
+
import { YourContractAbi } from '@gitmyabi/migrations';
|
|
46
|
+
|
|
47
|
+
const client = createPublicClient({
|
|
48
|
+
chain: mainnet,
|
|
49
|
+
transport: http(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Fully typed contract read
|
|
53
|
+
const result = await client.readContract({
|
|
54
|
+
address: '0x...',
|
|
55
|
+
abi: YourContractAbi,
|
|
56
|
+
functionName: 'yourMethod',
|
|
57
|
+
args: [param1, param2],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Fully typed contract write
|
|
61
|
+
const hash = await client.writeContract({
|
|
62
|
+
address: '0x...',
|
|
63
|
+
abi: YourContractAbi,
|
|
64
|
+
functionName: 'yourMethod',
|
|
65
|
+
args: [param1, param2],
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### With wagmi
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { useReadContract, useWriteContract } from 'wagmi';
|
|
73
|
+
import { YourContractAbi } from '@gitmyabi/migrations';
|
|
74
|
+
|
|
75
|
+
function MyComponent() {
|
|
76
|
+
const { data } = useReadContract({
|
|
77
|
+
address: '0x...',
|
|
78
|
+
abi: YourContractAbi,
|
|
79
|
+
functionName: 'yourMethod',
|
|
80
|
+
args: [param1, param2],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const { writeContract } = useWriteContract();
|
|
84
|
+
|
|
85
|
+
const handleWrite = () => {
|
|
86
|
+
writeContract({
|
|
87
|
+
address: '0x...',
|
|
88
|
+
abi: YourContractAbi,
|
|
89
|
+
functionName: 'yourMethod',
|
|
90
|
+
args: [param1, param2],
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return <button onClick={handleWrite}>Call Contract</button>;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Type Safety
|
|
99
|
+
|
|
100
|
+
This package provides full TypeScript type safety for all contract methods, events, and parameters using viem's type system. All ABIs are exported as `const` assertions for maximum type inference.
|
|
101
|
+
|
|
102
|
+
## Generated Contracts
|
|
103
|
+
|
|
104
|
+
This package includes type bindings for 1 contract(s) generated from ABI artifacts.
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
Apache License 2.0
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { Address, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Migrations ABI
|
|
4
|
+
*
|
|
5
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MigrationsAbi: readonly [{
|
|
8
|
+
readonly inputs: readonly [];
|
|
9
|
+
readonly name: "last_completed_migration";
|
|
10
|
+
readonly outputs: readonly [{
|
|
11
|
+
readonly internalType: "uint256";
|
|
12
|
+
readonly name: "";
|
|
13
|
+
readonly type: "uint256";
|
|
14
|
+
}];
|
|
15
|
+
readonly stateMutability: "view";
|
|
16
|
+
readonly type: "function";
|
|
17
|
+
}, {
|
|
18
|
+
readonly inputs: readonly [];
|
|
19
|
+
readonly name: "owner";
|
|
20
|
+
readonly outputs: readonly [{
|
|
21
|
+
readonly internalType: "address";
|
|
22
|
+
readonly name: "";
|
|
23
|
+
readonly type: "address";
|
|
24
|
+
}];
|
|
25
|
+
readonly stateMutability: "view";
|
|
26
|
+
readonly type: "function";
|
|
27
|
+
}, {
|
|
28
|
+
readonly inputs: readonly [{
|
|
29
|
+
readonly internalType: "uint256";
|
|
30
|
+
readonly name: "completed";
|
|
31
|
+
readonly type: "uint256";
|
|
32
|
+
}];
|
|
33
|
+
readonly name: "setCompleted";
|
|
34
|
+
readonly outputs: readonly [];
|
|
35
|
+
readonly stateMutability: "nonpayable";
|
|
36
|
+
readonly type: "function";
|
|
37
|
+
}];
|
|
38
|
+
/**
|
|
39
|
+
* Type-safe ABI for Migrations
|
|
40
|
+
*/
|
|
41
|
+
export type MigrationsAbi = typeof MigrationsAbi;
|
|
42
|
+
/**
|
|
43
|
+
* Contract instance type for Migrations
|
|
44
|
+
*/
|
|
45
|
+
export type MigrationsContract = any;
|
|
46
|
+
/**
|
|
47
|
+
* Migrations Contract Class
|
|
48
|
+
*
|
|
49
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
54
|
+
* import { mainnet } from 'viem/chains';
|
|
55
|
+
* import { Migrations } from 'Migrations';
|
|
56
|
+
*
|
|
57
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
58
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
59
|
+
*
|
|
60
|
+
* const contract = new Migrations('0x...', { publicClient, walletClient });
|
|
61
|
+
*
|
|
62
|
+
* // Read functions
|
|
63
|
+
* const result = await contract.balanceOf('0x...');
|
|
64
|
+
*
|
|
65
|
+
* // Write functions
|
|
66
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
67
|
+
*
|
|
68
|
+
* // Simulate transactions (dry-run)
|
|
69
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
70
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
71
|
+
*
|
|
72
|
+
* // Watch events
|
|
73
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
74
|
+
* console.log('Transfer event:', event);
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare class Migrations {
|
|
79
|
+
private contract;
|
|
80
|
+
private contractAddress;
|
|
81
|
+
private publicClient;
|
|
82
|
+
constructor(address: Address, clients: {
|
|
83
|
+
publicClient: PublicClient;
|
|
84
|
+
walletClient?: WalletClient;
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Get the contract address
|
|
88
|
+
*/
|
|
89
|
+
get address(): Address;
|
|
90
|
+
/**
|
|
91
|
+
* Get the underlying viem contract instance.
|
|
92
|
+
*/
|
|
93
|
+
getContract(): MigrationsContract;
|
|
94
|
+
/**
|
|
95
|
+
* last_completed_migration
|
|
96
|
+
* view
|
|
97
|
+
*/
|
|
98
|
+
last_completed_migration(): Promise<bigint>;
|
|
99
|
+
/**
|
|
100
|
+
* owner
|
|
101
|
+
* view
|
|
102
|
+
*/
|
|
103
|
+
owner(): Promise<`0x${string}`>;
|
|
104
|
+
/**
|
|
105
|
+
* setCompleted
|
|
106
|
+
* nonpayable
|
|
107
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
108
|
+
*/
|
|
109
|
+
setCompleted(completed: bigint, options?: {
|
|
110
|
+
accessList?: import('viem').AccessList;
|
|
111
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
112
|
+
chain?: import('viem').Chain | null;
|
|
113
|
+
dataSuffix?: `0x${string}`;
|
|
114
|
+
gas?: bigint;
|
|
115
|
+
gasPrice?: bigint;
|
|
116
|
+
maxFeePerGas?: bigint;
|
|
117
|
+
maxPriorityFeePerGas?: bigint;
|
|
118
|
+
nonce?: number;
|
|
119
|
+
value?: bigint;
|
|
120
|
+
}): Promise<`0x${string}`>;
|
|
121
|
+
/**
|
|
122
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
126
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
127
|
+
* console.log('Would succeed:', result.result);
|
|
128
|
+
*/
|
|
129
|
+
get simulate(): {
|
|
130
|
+
/**
|
|
131
|
+
* Simulate setCompleted
|
|
132
|
+
* Returns gas estimate and result without sending transaction
|
|
133
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
134
|
+
*/
|
|
135
|
+
setCompleted(completed: bigint, options?: {
|
|
136
|
+
accessList?: import("viem").AccessList;
|
|
137
|
+
authorizationList?: import("viem").AuthorizationList;
|
|
138
|
+
chain?: import("viem").Chain | null;
|
|
139
|
+
dataSuffix?: `0x${string}`;
|
|
140
|
+
gas?: bigint;
|
|
141
|
+
gasPrice?: bigint;
|
|
142
|
+
maxFeePerGas?: bigint;
|
|
143
|
+
maxPriorityFeePerGas?: bigint;
|
|
144
|
+
nonce?: number;
|
|
145
|
+
value?: bigint;
|
|
146
|
+
}): Promise<void>;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Watch contract events
|
|
150
|
+
*
|
|
151
|
+
* Note: This contract has no events, so watch returns an empty object.
|
|
152
|
+
*/
|
|
153
|
+
get watch(): {};
|
|
154
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migrations = exports.MigrationsAbi = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* Migrations ABI
|
|
7
|
+
*
|
|
8
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
9
|
+
*/
|
|
10
|
+
exports.MigrationsAbi = [
|
|
11
|
+
{
|
|
12
|
+
"inputs": [],
|
|
13
|
+
"name": "last_completed_migration",
|
|
14
|
+
"outputs": [
|
|
15
|
+
{
|
|
16
|
+
"internalType": "uint256",
|
|
17
|
+
"name": "",
|
|
18
|
+
"type": "uint256"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"stateMutability": "view",
|
|
22
|
+
"type": "function"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"inputs": [],
|
|
26
|
+
"name": "owner",
|
|
27
|
+
"outputs": [
|
|
28
|
+
{
|
|
29
|
+
"internalType": "address",
|
|
30
|
+
"name": "",
|
|
31
|
+
"type": "address"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"stateMutability": "view",
|
|
35
|
+
"type": "function"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"inputs": [
|
|
39
|
+
{
|
|
40
|
+
"internalType": "uint256",
|
|
41
|
+
"name": "completed",
|
|
42
|
+
"type": "uint256"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"name": "setCompleted",
|
|
46
|
+
"outputs": [],
|
|
47
|
+
"stateMutability": "nonpayable",
|
|
48
|
+
"type": "function"
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Migrations Contract Class
|
|
53
|
+
*
|
|
54
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
59
|
+
* import { mainnet } from 'viem/chains';
|
|
60
|
+
* import { Migrations } from 'Migrations';
|
|
61
|
+
*
|
|
62
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
63
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
64
|
+
*
|
|
65
|
+
* const contract = new Migrations('0x...', { publicClient, walletClient });
|
|
66
|
+
*
|
|
67
|
+
* // Read functions
|
|
68
|
+
* const result = await contract.balanceOf('0x...');
|
|
69
|
+
*
|
|
70
|
+
* // Write functions
|
|
71
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
72
|
+
*
|
|
73
|
+
* // Simulate transactions (dry-run)
|
|
74
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
75
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
76
|
+
*
|
|
77
|
+
* // Watch events
|
|
78
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
79
|
+
* console.log('Transfer event:', event);
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
class Migrations {
|
|
84
|
+
constructor(address, clients) {
|
|
85
|
+
this.contractAddress = address;
|
|
86
|
+
this.publicClient = clients.publicClient;
|
|
87
|
+
this.contract = (0, viem_1.getContract)({
|
|
88
|
+
address,
|
|
89
|
+
abi: exports.MigrationsAbi,
|
|
90
|
+
client: {
|
|
91
|
+
public: clients.publicClient,
|
|
92
|
+
wallet: clients.walletClient,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get the contract address
|
|
98
|
+
*/
|
|
99
|
+
get address() {
|
|
100
|
+
return this.contractAddress;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the underlying viem contract instance.
|
|
104
|
+
*/
|
|
105
|
+
getContract() {
|
|
106
|
+
return this.contract;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* last_completed_migration
|
|
110
|
+
* view
|
|
111
|
+
*/
|
|
112
|
+
async last_completed_migration() {
|
|
113
|
+
return this.contract.read.last_completed_migration();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* owner
|
|
117
|
+
* view
|
|
118
|
+
*/
|
|
119
|
+
async owner() {
|
|
120
|
+
return this.contract.read.owner();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* setCompleted
|
|
124
|
+
* nonpayable
|
|
125
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
126
|
+
*/
|
|
127
|
+
async setCompleted(completed, options) {
|
|
128
|
+
if (!this.contract.write) {
|
|
129
|
+
throw new Error('Wallet client is required for write operations');
|
|
130
|
+
}
|
|
131
|
+
return this.contract.write.setCompleted([completed], options);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
138
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
139
|
+
* console.log('Would succeed:', result.result);
|
|
140
|
+
*/
|
|
141
|
+
get simulate() {
|
|
142
|
+
const contract = this.contract;
|
|
143
|
+
if (!contract.simulate) {
|
|
144
|
+
throw new Error('Public client is required for simulation');
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
/**
|
|
148
|
+
* Simulate setCompleted
|
|
149
|
+
* Returns gas estimate and result without sending transaction
|
|
150
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
151
|
+
*/
|
|
152
|
+
async setCompleted(completed, options) {
|
|
153
|
+
return contract.simulate.setCompleted([completed], options);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Watch contract events
|
|
159
|
+
*
|
|
160
|
+
* Note: This contract has no events, so watch returns an empty object.
|
|
161
|
+
*/
|
|
162
|
+
get watch() {
|
|
163
|
+
return {};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.Migrations = Migrations;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Migrations ABI
|
|
6
|
+
*
|
|
7
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
+
*/
|
|
9
|
+
export const MigrationsAbi = [
|
|
10
|
+
{
|
|
11
|
+
"inputs": [],
|
|
12
|
+
"name": "last_completed_migration",
|
|
13
|
+
"outputs": [
|
|
14
|
+
{
|
|
15
|
+
"internalType": "uint256",
|
|
16
|
+
"name": "",
|
|
17
|
+
"type": "uint256"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"stateMutability": "view",
|
|
21
|
+
"type": "function"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"inputs": [],
|
|
25
|
+
"name": "owner",
|
|
26
|
+
"outputs": [
|
|
27
|
+
{
|
|
28
|
+
"internalType": "address",
|
|
29
|
+
"name": "",
|
|
30
|
+
"type": "address"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"stateMutability": "view",
|
|
34
|
+
"type": "function"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"inputs": [
|
|
38
|
+
{
|
|
39
|
+
"internalType": "uint256",
|
|
40
|
+
"name": "completed",
|
|
41
|
+
"type": "uint256"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"name": "setCompleted",
|
|
45
|
+
"outputs": [],
|
|
46
|
+
"stateMutability": "nonpayable",
|
|
47
|
+
"type": "function"
|
|
48
|
+
}
|
|
49
|
+
] as const satisfies Abi;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Type-safe ABI for Migrations
|
|
53
|
+
*/
|
|
54
|
+
export type MigrationsAbi = typeof MigrationsAbi;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Contract instance type for Migrations
|
|
58
|
+
*/
|
|
59
|
+
// Use any for contract type to avoid complex viem type issues
|
|
60
|
+
// The runtime behavior is type-safe through viem's ABI typing
|
|
61
|
+
export type MigrationsContract = any;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Migrations Contract Class
|
|
65
|
+
*
|
|
66
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
71
|
+
* import { mainnet } from 'viem/chains';
|
|
72
|
+
* import { Migrations } from 'Migrations';
|
|
73
|
+
*
|
|
74
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
75
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
76
|
+
*
|
|
77
|
+
* const contract = new Migrations('0x...', { publicClient, walletClient });
|
|
78
|
+
*
|
|
79
|
+
* // Read functions
|
|
80
|
+
* const result = await contract.balanceOf('0x...');
|
|
81
|
+
*
|
|
82
|
+
* // Write functions
|
|
83
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
84
|
+
*
|
|
85
|
+
* // Simulate transactions (dry-run)
|
|
86
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
87
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
88
|
+
*
|
|
89
|
+
* // Watch events
|
|
90
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
91
|
+
* console.log('Transfer event:', event);
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export class Migrations {
|
|
96
|
+
private contract: MigrationsContract;
|
|
97
|
+
private contractAddress: Address;
|
|
98
|
+
private publicClient: PublicClient;
|
|
99
|
+
|
|
100
|
+
constructor(
|
|
101
|
+
address: Address,
|
|
102
|
+
clients: {
|
|
103
|
+
publicClient: PublicClient;
|
|
104
|
+
walletClient?: WalletClient;
|
|
105
|
+
}
|
|
106
|
+
) {
|
|
107
|
+
this.contractAddress = address;
|
|
108
|
+
this.publicClient = clients.publicClient;
|
|
109
|
+
this.contract = getContract({
|
|
110
|
+
address,
|
|
111
|
+
abi: MigrationsAbi,
|
|
112
|
+
client: {
|
|
113
|
+
public: clients.publicClient,
|
|
114
|
+
wallet: clients.walletClient,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get the contract address
|
|
121
|
+
*/
|
|
122
|
+
get address(): Address {
|
|
123
|
+
return this.contractAddress;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get the underlying viem contract instance.
|
|
128
|
+
*/
|
|
129
|
+
getContract(): MigrationsContract {
|
|
130
|
+
return this.contract;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* last_completed_migration
|
|
135
|
+
* view
|
|
136
|
+
*/
|
|
137
|
+
async last_completed_migration(): Promise<bigint> {
|
|
138
|
+
return this.contract.read.last_completed_migration() as Promise<bigint>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* owner
|
|
143
|
+
* view
|
|
144
|
+
*/
|
|
145
|
+
async owner(): Promise<`0x${string}`> {
|
|
146
|
+
return this.contract.read.owner() as Promise<`0x${string}`>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* setCompleted
|
|
151
|
+
* nonpayable
|
|
152
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
153
|
+
*/
|
|
154
|
+
async setCompleted(completed: bigint, options?: {
|
|
155
|
+
accessList?: import('viem').AccessList;
|
|
156
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
157
|
+
chain?: import('viem').Chain | null;
|
|
158
|
+
dataSuffix?: `0x${string}`;
|
|
159
|
+
gas?: bigint;
|
|
160
|
+
gasPrice?: bigint;
|
|
161
|
+
maxFeePerGas?: bigint;
|
|
162
|
+
maxPriorityFeePerGas?: bigint;
|
|
163
|
+
nonce?: number;
|
|
164
|
+
value?: bigint;
|
|
165
|
+
}): Promise<`0x${string}`> {
|
|
166
|
+
if (!this.contract.write) {
|
|
167
|
+
throw new Error('Wallet client is required for write operations');
|
|
168
|
+
}
|
|
169
|
+
return this.contract.write.setCompleted([completed] as const, options) as Promise<`0x${string}`>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
179
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
180
|
+
* console.log('Would succeed:', result.result);
|
|
181
|
+
*/
|
|
182
|
+
get simulate() {
|
|
183
|
+
const contract = this.contract;
|
|
184
|
+
if (!contract.simulate) {
|
|
185
|
+
throw new Error('Public client is required for simulation');
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
/**
|
|
189
|
+
* Simulate setCompleted
|
|
190
|
+
* Returns gas estimate and result without sending transaction
|
|
191
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
192
|
+
*/
|
|
193
|
+
async setCompleted(completed: bigint, options?: {
|
|
194
|
+
accessList?: import('viem').AccessList;
|
|
195
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
196
|
+
chain?: import('viem').Chain | null;
|
|
197
|
+
dataSuffix?: `0x${string}`;
|
|
198
|
+
gas?: bigint;
|
|
199
|
+
gasPrice?: bigint;
|
|
200
|
+
maxFeePerGas?: bigint;
|
|
201
|
+
maxPriorityFeePerGas?: bigint;
|
|
202
|
+
nonce?: number;
|
|
203
|
+
value?: bigint;
|
|
204
|
+
}): Promise<void> {
|
|
205
|
+
return contract.simulate.setCompleted([completed] as const, options) as Promise<void>;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Watch contract events
|
|
212
|
+
*
|
|
213
|
+
* Note: This contract has no events, so watch returns an empty object.
|
|
214
|
+
*/
|
|
215
|
+
get watch() {
|
|
216
|
+
return {};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migrations = exports.MigrationsAbi = void 0;
|
|
4
|
+
// Auto-generated exports for all contracts
|
|
5
|
+
var Migrations_1 = require("./Migrations");
|
|
6
|
+
Object.defineProperty(exports, "MigrationsAbi", { enumerable: true, get: function () { return Migrations_1.MigrationsAbi; } });
|
|
7
|
+
Object.defineProperty(exports, "Migrations", { enumerable: true, get: function () { return Migrations_1.Migrations; } });
|
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
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitmyabi/migrations",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Auto-generated TypeScript type bindings for Migrations (build etherscan-migrations-e57d3c97-1794001043665, commit fc2b8c2, 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/migrations"
|
|
40
|
+
},
|
|
41
|
+
"branch": "etherscan",
|
|
42
|
+
"shortHash": "fc2b8c2"
|
|
6
43
|
}
|