@gitmyabi/basewallet 1.0.2 → 1.0.3
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 +5 -5
- package/contracts/BaseWallet_json.d.ts +5 -2
- package/contracts/BaseWallet_json.js +6 -1
- package/contracts/BaseWallet_json.ts +8 -3
- package/contracts/index.d.ts +0 -2
- package/contracts/index.js +1 -4
- package/contracts/index.ts +0 -2
- package/package.json +3 -3
- package/contracts/Proxy_json.d.ts +0 -127
- package/contracts/Proxy_json.js +0 -153
- package/contracts/Proxy_json.ts +0 -182
package/README.md
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Auto-generated TypeScript type bindings for **BaseWallet**
|
|
4
4
|
|
|
5
|
-
- **Build ID**: `etherscan-basewallet-
|
|
5
|
+
- **Build ID**: `etherscan-basewallet-b6d64221-1790544139002`
|
|
6
6
|
- **Build Number**: 1
|
|
7
|
-
- **Commit**: `
|
|
7
|
+
- **Commit**: `b3f2bbc`
|
|
8
8
|
- **Branch**: `etherscan`
|
|
9
9
|
- **Target**: `ethers-v6`
|
|
10
|
-
- **Contracts**:
|
|
10
|
+
- **Contracts**: 1
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm install @gitmyabi/basewallet@1.0.
|
|
15
|
+
npm install @gitmyabi/basewallet@1.0.3
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -101,7 +101,7 @@ This package provides full TypeScript type safety for all contract methods, even
|
|
|
101
101
|
|
|
102
102
|
## Generated Contracts
|
|
103
103
|
|
|
104
|
-
This package includes type bindings for
|
|
104
|
+
This package includes type bindings for 1 contract(s) generated from ABI artifacts.
|
|
105
105
|
|
|
106
106
|
## License
|
|
107
107
|
|
|
@@ -106,7 +106,10 @@ export declare const BaseWallet_jsonAbi: readonly [{
|
|
|
106
106
|
readonly type: "bytes";
|
|
107
107
|
}];
|
|
108
108
|
readonly name: "invoke";
|
|
109
|
-
readonly outputs: readonly [
|
|
109
|
+
readonly outputs: readonly [{
|
|
110
|
+
readonly name: "_result";
|
|
111
|
+
readonly type: "bytes";
|
|
112
|
+
}];
|
|
110
113
|
readonly payable: false;
|
|
111
114
|
readonly stateMutability: "nonpayable";
|
|
112
115
|
readonly type: "function";
|
|
@@ -472,7 +475,7 @@ export declare class BaseWallet_json {
|
|
|
472
475
|
maxPriorityFeePerGas?: bigint;
|
|
473
476
|
nonce?: number;
|
|
474
477
|
value?: bigint;
|
|
475
|
-
}): Promise
|
|
478
|
+
}): Promise<`0x${string}`>;
|
|
476
479
|
};
|
|
477
480
|
/**
|
|
478
481
|
* Watch contract events
|
|
@@ -140,7 +140,12 @@ exports.BaseWallet_jsonAbi = [
|
|
|
140
140
|
}
|
|
141
141
|
],
|
|
142
142
|
"name": "invoke",
|
|
143
|
-
"outputs": [
|
|
143
|
+
"outputs": [
|
|
144
|
+
{
|
|
145
|
+
"name": "_result",
|
|
146
|
+
"type": "bytes"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
144
149
|
"payable": false,
|
|
145
150
|
"stateMutability": "nonpayable",
|
|
146
151
|
"type": "function"
|
|
@@ -139,7 +139,12 @@ export const BaseWallet_jsonAbi = [
|
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
141
|
"name": "invoke",
|
|
142
|
-
"outputs": [
|
|
142
|
+
"outputs": [
|
|
143
|
+
{
|
|
144
|
+
"name": "_result",
|
|
145
|
+
"type": "bytes"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
143
148
|
"payable": false,
|
|
144
149
|
"stateMutability": "nonpayable",
|
|
145
150
|
"type": "function"
|
|
@@ -624,8 +629,8 @@ export class BaseWallet_json {
|
|
|
624
629
|
maxPriorityFeePerGas?: bigint;
|
|
625
630
|
nonce?: number;
|
|
626
631
|
value?: bigint;
|
|
627
|
-
}): Promise
|
|
628
|
-
return contract.simulate.invoke([_target, _value, _data] as const, options) as Promise
|
|
632
|
+
}): Promise<`0x${string}`> {
|
|
633
|
+
return contract.simulate.invoke([_target, _value, _data] as const, options) as Promise<`0x${string}`>;
|
|
629
634
|
}
|
|
630
635
|
};
|
|
631
636
|
}
|
package/contracts/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export { Proxy_jsonAbi, Proxy_json } from './Proxy_json';
|
|
2
|
-
export type { Proxy_jsonAbi as Proxy_jsonAbiType, Proxy_jsonContract } from './Proxy_json';
|
|
3
1
|
export { BaseWallet_jsonAbi, BaseWallet_json } from './BaseWallet_json';
|
|
4
2
|
export type { BaseWallet_jsonAbi as BaseWallet_jsonAbiType, BaseWallet_jsonContract } from './BaseWallet_json';
|
package/contracts/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseWallet_json = exports.BaseWallet_jsonAbi =
|
|
3
|
+
exports.BaseWallet_json = exports.BaseWallet_jsonAbi = void 0;
|
|
4
4
|
// Auto-generated exports for all contracts
|
|
5
|
-
var Proxy_json_1 = require("./Proxy_json");
|
|
6
|
-
Object.defineProperty(exports, "Proxy_jsonAbi", { enumerable: true, get: function () { return Proxy_json_1.Proxy_jsonAbi; } });
|
|
7
|
-
Object.defineProperty(exports, "Proxy_json", { enumerable: true, get: function () { return Proxy_json_1.Proxy_json; } });
|
|
8
5
|
var BaseWallet_json_1 = require("./BaseWallet_json");
|
|
9
6
|
Object.defineProperty(exports, "BaseWallet_jsonAbi", { enumerable: true, get: function () { return BaseWallet_json_1.BaseWallet_jsonAbi; } });
|
|
10
7
|
Object.defineProperty(exports, "BaseWallet_json", { enumerable: true, get: function () { return BaseWallet_json_1.BaseWallet_json; } });
|
package/contracts/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
// Auto-generated exports for all contracts
|
|
2
|
-
export { Proxy_jsonAbi, Proxy_json } from './Proxy_json';
|
|
3
|
-
export type { Proxy_jsonAbi as Proxy_jsonAbiType, Proxy_jsonContract } from './Proxy_json';
|
|
4
2
|
export { BaseWallet_jsonAbi, BaseWallet_json } from './BaseWallet_json';
|
|
5
3
|
export type { BaseWallet_jsonAbi as BaseWallet_jsonAbiType, BaseWallet_jsonContract } from './BaseWallet_json';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitmyabi/basewallet",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Auto-generated TypeScript type bindings for BaseWallet (build etherscan-basewallet-
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Auto-generated TypeScript type bindings for BaseWallet (build etherscan-basewallet-b6d64221-1790544139002, commit b3f2bbc, branch etherscan)",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"url": "https://github.com/etherscan/basewallet"
|
|
40
40
|
},
|
|
41
41
|
"branch": "etherscan",
|
|
42
|
-
"shortHash": "
|
|
42
|
+
"shortHash": "b3f2bbc"
|
|
43
43
|
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import type { Address, PublicClient, WalletClient } from 'viem';
|
|
2
|
-
/**
|
|
3
|
-
* Proxy_json ABI
|
|
4
|
-
*
|
|
5
|
-
* This ABI is typed using viem's type system for full type safety.
|
|
6
|
-
*/
|
|
7
|
-
export declare const Proxy_jsonAbi: readonly [{
|
|
8
|
-
readonly inputs: readonly [{
|
|
9
|
-
readonly name: "_implementation";
|
|
10
|
-
readonly type: "address";
|
|
11
|
-
}];
|
|
12
|
-
readonly payable: false;
|
|
13
|
-
readonly stateMutability: "nonpayable";
|
|
14
|
-
readonly type: "constructor";
|
|
15
|
-
}, {
|
|
16
|
-
readonly payable: true;
|
|
17
|
-
readonly stateMutability: "payable";
|
|
18
|
-
readonly type: "fallback";
|
|
19
|
-
}, {
|
|
20
|
-
readonly anonymous: false;
|
|
21
|
-
readonly inputs: readonly [{
|
|
22
|
-
readonly indexed: true;
|
|
23
|
-
readonly name: "value";
|
|
24
|
-
readonly type: "uint256";
|
|
25
|
-
}, {
|
|
26
|
-
readonly indexed: true;
|
|
27
|
-
readonly name: "sender";
|
|
28
|
-
readonly type: "address";
|
|
29
|
-
}, {
|
|
30
|
-
readonly indexed: false;
|
|
31
|
-
readonly name: "data";
|
|
32
|
-
readonly type: "bytes";
|
|
33
|
-
}];
|
|
34
|
-
readonly name: "Received";
|
|
35
|
-
readonly type: "event";
|
|
36
|
-
}];
|
|
37
|
-
/**
|
|
38
|
-
* Type-safe ABI for Proxy_json
|
|
39
|
-
*/
|
|
40
|
-
export type Proxy_jsonAbi = typeof Proxy_jsonAbi;
|
|
41
|
-
/**
|
|
42
|
-
* Contract instance type for Proxy_json
|
|
43
|
-
*/
|
|
44
|
-
export type Proxy_jsonContract = any;
|
|
45
|
-
/**
|
|
46
|
-
* Proxy_json Contract Class
|
|
47
|
-
*
|
|
48
|
-
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
53
|
-
* import { mainnet } from 'viem/chains';
|
|
54
|
-
* import { Proxy_json } from 'Proxy_json';
|
|
55
|
-
*
|
|
56
|
-
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
57
|
-
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
58
|
-
*
|
|
59
|
-
* const contract = new Proxy_json('0x...', { publicClient, walletClient });
|
|
60
|
-
*
|
|
61
|
-
* // Read functions
|
|
62
|
-
* const result = await contract.balanceOf('0x...');
|
|
63
|
-
*
|
|
64
|
-
* // Write functions
|
|
65
|
-
* const hash = await contract.transfer('0x...', 1000n);
|
|
66
|
-
*
|
|
67
|
-
* // Simulate transactions (dry-run)
|
|
68
|
-
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
69
|
-
* console.log('Gas estimate:', simulation.request.gas);
|
|
70
|
-
*
|
|
71
|
-
* // Watch events
|
|
72
|
-
* const unwatch = contract.watch.Transfer((event) => {
|
|
73
|
-
* console.log('Transfer event:', event);
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare class Proxy_json {
|
|
78
|
-
private contract;
|
|
79
|
-
private contractAddress;
|
|
80
|
-
private publicClient;
|
|
81
|
-
constructor(address: Address, clients: {
|
|
82
|
-
publicClient: PublicClient;
|
|
83
|
-
walletClient?: WalletClient;
|
|
84
|
-
});
|
|
85
|
-
/**
|
|
86
|
-
* Get the contract address
|
|
87
|
-
*/
|
|
88
|
-
get address(): Address;
|
|
89
|
-
/**
|
|
90
|
-
* Get the underlying viem contract instance
|
|
91
|
-
*/
|
|
92
|
-
getContract(): Proxy_jsonContract;
|
|
93
|
-
/**
|
|
94
|
-
* Simulate contract write operations (dry-run without sending transaction)
|
|
95
|
-
*
|
|
96
|
-
* Note: This contract has no write functions, so simulate returns an empty object.
|
|
97
|
-
*/
|
|
98
|
-
get simulate(): {};
|
|
99
|
-
/**
|
|
100
|
-
* Watch contract events
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* // Watch all Transfer events
|
|
104
|
-
* const unwatch = contract.watch.Transfer((event) => {
|
|
105
|
-
* console.log('Transfer:', event);
|
|
106
|
-
* });
|
|
107
|
-
*
|
|
108
|
-
* // Stop watching
|
|
109
|
-
* unwatch();
|
|
110
|
-
*/
|
|
111
|
-
get watch(): {
|
|
112
|
-
/**
|
|
113
|
-
* Watch Received events
|
|
114
|
-
* @param callback Function to call when event is emitted
|
|
115
|
-
* @param filter Optional filter for indexed parameters
|
|
116
|
-
* @returns Unwatch function to stop listening
|
|
117
|
-
*/
|
|
118
|
-
Received: (callback: (event: {
|
|
119
|
-
value: bigint;
|
|
120
|
-
sender: `0x${string}`;
|
|
121
|
-
data: `0x${string}`;
|
|
122
|
-
}) => void, filter?: {
|
|
123
|
-
value: bigint;
|
|
124
|
-
sender: `0x${string}`;
|
|
125
|
-
}) => () => void;
|
|
126
|
-
};
|
|
127
|
-
}
|
package/contracts/Proxy_json.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Proxy_json = exports.Proxy_jsonAbi = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
/**
|
|
6
|
-
* Proxy_json ABI
|
|
7
|
-
*
|
|
8
|
-
* This ABI is typed using viem's type system for full type safety.
|
|
9
|
-
*/
|
|
10
|
-
exports.Proxy_jsonAbi = [
|
|
11
|
-
{
|
|
12
|
-
"inputs": [
|
|
13
|
-
{
|
|
14
|
-
"name": "_implementation",
|
|
15
|
-
"type": "address"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"payable": false,
|
|
19
|
-
"stateMutability": "nonpayable",
|
|
20
|
-
"type": "constructor"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"payable": true,
|
|
24
|
-
"stateMutability": "payable",
|
|
25
|
-
"type": "fallback"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"anonymous": false,
|
|
29
|
-
"inputs": [
|
|
30
|
-
{
|
|
31
|
-
"indexed": true,
|
|
32
|
-
"name": "value",
|
|
33
|
-
"type": "uint256"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"indexed": true,
|
|
37
|
-
"name": "sender",
|
|
38
|
-
"type": "address"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"indexed": false,
|
|
42
|
-
"name": "data",
|
|
43
|
-
"type": "bytes"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"name": "Received",
|
|
47
|
-
"type": "event"
|
|
48
|
-
}
|
|
49
|
-
];
|
|
50
|
-
/**
|
|
51
|
-
* Proxy_json Contract Class
|
|
52
|
-
*
|
|
53
|
-
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
58
|
-
* import { mainnet } from 'viem/chains';
|
|
59
|
-
* import { Proxy_json } from 'Proxy_json';
|
|
60
|
-
*
|
|
61
|
-
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
62
|
-
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
63
|
-
*
|
|
64
|
-
* const contract = new Proxy_json('0x...', { publicClient, walletClient });
|
|
65
|
-
*
|
|
66
|
-
* // Read functions
|
|
67
|
-
* const result = await contract.balanceOf('0x...');
|
|
68
|
-
*
|
|
69
|
-
* // Write functions
|
|
70
|
-
* const hash = await contract.transfer('0x...', 1000n);
|
|
71
|
-
*
|
|
72
|
-
* // Simulate transactions (dry-run)
|
|
73
|
-
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
74
|
-
* console.log('Gas estimate:', simulation.request.gas);
|
|
75
|
-
*
|
|
76
|
-
* // Watch events
|
|
77
|
-
* const unwatch = contract.watch.Transfer((event) => {
|
|
78
|
-
* console.log('Transfer event:', event);
|
|
79
|
-
* });
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
class Proxy_json {
|
|
83
|
-
constructor(address, clients) {
|
|
84
|
-
this.contractAddress = address;
|
|
85
|
-
this.publicClient = clients.publicClient;
|
|
86
|
-
this.contract = (0, viem_1.getContract)({
|
|
87
|
-
address,
|
|
88
|
-
abi: exports.Proxy_jsonAbi,
|
|
89
|
-
client: {
|
|
90
|
-
public: clients.publicClient,
|
|
91
|
-
wallet: clients.walletClient,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get the contract address
|
|
97
|
-
*/
|
|
98
|
-
get address() {
|
|
99
|
-
return this.contractAddress;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get the underlying viem contract instance
|
|
103
|
-
*/
|
|
104
|
-
getContract() {
|
|
105
|
-
return this.contract;
|
|
106
|
-
}
|
|
107
|
-
// No read functions
|
|
108
|
-
// No write functions
|
|
109
|
-
/**
|
|
110
|
-
* Simulate contract write operations (dry-run without sending transaction)
|
|
111
|
-
*
|
|
112
|
-
* Note: This contract has no write functions, so simulate returns an empty object.
|
|
113
|
-
*/
|
|
114
|
-
get simulate() {
|
|
115
|
-
return {};
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Watch contract events
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* // Watch all Transfer events
|
|
122
|
-
* const unwatch = contract.watch.Transfer((event) => {
|
|
123
|
-
* console.log('Transfer:', event);
|
|
124
|
-
* });
|
|
125
|
-
*
|
|
126
|
-
* // Stop watching
|
|
127
|
-
* unwatch();
|
|
128
|
-
*/
|
|
129
|
-
get watch() {
|
|
130
|
-
return {
|
|
131
|
-
/**
|
|
132
|
-
* Watch Received events
|
|
133
|
-
* @param callback Function to call when event is emitted
|
|
134
|
-
* @param filter Optional filter for indexed parameters
|
|
135
|
-
* @returns Unwatch function to stop listening
|
|
136
|
-
*/
|
|
137
|
-
Received: (callback, filter) => {
|
|
138
|
-
return this.publicClient.watchContractEvent({
|
|
139
|
-
address: this.contractAddress,
|
|
140
|
-
abi: exports.Proxy_jsonAbi,
|
|
141
|
-
eventName: 'Received',
|
|
142
|
-
args: filter,
|
|
143
|
-
onLogs: (logs) => {
|
|
144
|
-
logs.forEach((log) => {
|
|
145
|
-
callback(log.args);
|
|
146
|
-
});
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
exports.Proxy_json = Proxy_json;
|
package/contracts/Proxy_json.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
-
import { getContract } from 'viem';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Proxy_json ABI
|
|
6
|
-
*
|
|
7
|
-
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
-
*/
|
|
9
|
-
export const Proxy_jsonAbi = [
|
|
10
|
-
{
|
|
11
|
-
"inputs": [
|
|
12
|
-
{
|
|
13
|
-
"name": "_implementation",
|
|
14
|
-
"type": "address"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
"payable": false,
|
|
18
|
-
"stateMutability": "nonpayable",
|
|
19
|
-
"type": "constructor"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"payable": true,
|
|
23
|
-
"stateMutability": "payable",
|
|
24
|
-
"type": "fallback"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"anonymous": false,
|
|
28
|
-
"inputs": [
|
|
29
|
-
{
|
|
30
|
-
"indexed": true,
|
|
31
|
-
"name": "value",
|
|
32
|
-
"type": "uint256"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"indexed": true,
|
|
36
|
-
"name": "sender",
|
|
37
|
-
"type": "address"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"indexed": false,
|
|
41
|
-
"name": "data",
|
|
42
|
-
"type": "bytes"
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
"name": "Received",
|
|
46
|
-
"type": "event"
|
|
47
|
-
}
|
|
48
|
-
] as const satisfies Abi;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Type-safe ABI for Proxy_json
|
|
52
|
-
*/
|
|
53
|
-
export type Proxy_jsonAbi = typeof Proxy_jsonAbi;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Contract instance type for Proxy_json
|
|
57
|
-
*/
|
|
58
|
-
// Use any for contract type to avoid complex viem type issues
|
|
59
|
-
// The runtime behavior is type-safe through viem's ABI typing
|
|
60
|
-
export type Proxy_jsonContract = any;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Proxy_json Contract Class
|
|
64
|
-
*
|
|
65
|
-
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
70
|
-
* import { mainnet } from 'viem/chains';
|
|
71
|
-
* import { Proxy_json } from 'Proxy_json';
|
|
72
|
-
*
|
|
73
|
-
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
74
|
-
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
75
|
-
*
|
|
76
|
-
* const contract = new Proxy_json('0x...', { publicClient, walletClient });
|
|
77
|
-
*
|
|
78
|
-
* // Read functions
|
|
79
|
-
* const result = await contract.balanceOf('0x...');
|
|
80
|
-
*
|
|
81
|
-
* // Write functions
|
|
82
|
-
* const hash = await contract.transfer('0x...', 1000n);
|
|
83
|
-
*
|
|
84
|
-
* // Simulate transactions (dry-run)
|
|
85
|
-
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
86
|
-
* console.log('Gas estimate:', simulation.request.gas);
|
|
87
|
-
*
|
|
88
|
-
* // Watch events
|
|
89
|
-
* const unwatch = contract.watch.Transfer((event) => {
|
|
90
|
-
* console.log('Transfer event:', event);
|
|
91
|
-
* });
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
export class Proxy_json {
|
|
95
|
-
private contract: Proxy_jsonContract;
|
|
96
|
-
private contractAddress: Address;
|
|
97
|
-
private publicClient: PublicClient;
|
|
98
|
-
|
|
99
|
-
constructor(
|
|
100
|
-
address: Address,
|
|
101
|
-
clients: {
|
|
102
|
-
publicClient: PublicClient;
|
|
103
|
-
walletClient?: WalletClient;
|
|
104
|
-
}
|
|
105
|
-
) {
|
|
106
|
-
this.contractAddress = address;
|
|
107
|
-
this.publicClient = clients.publicClient;
|
|
108
|
-
this.contract = getContract({
|
|
109
|
-
address,
|
|
110
|
-
abi: Proxy_jsonAbi,
|
|
111
|
-
client: {
|
|
112
|
-
public: clients.publicClient,
|
|
113
|
-
wallet: clients.walletClient,
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Get the contract address
|
|
120
|
-
*/
|
|
121
|
-
get address(): Address {
|
|
122
|
-
return this.contractAddress;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get the underlying viem contract instance
|
|
127
|
-
*/
|
|
128
|
-
getContract(): Proxy_jsonContract {
|
|
129
|
-
return this.contract;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// No read functions
|
|
133
|
-
|
|
134
|
-
// No write functions
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Simulate contract write operations (dry-run without sending transaction)
|
|
140
|
-
*
|
|
141
|
-
* Note: This contract has no write functions, so simulate returns an empty object.
|
|
142
|
-
*/
|
|
143
|
-
get simulate() {
|
|
144
|
-
return {};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Watch contract events
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* // Watch all Transfer events
|
|
152
|
-
* const unwatch = contract.watch.Transfer((event) => {
|
|
153
|
-
* console.log('Transfer:', event);
|
|
154
|
-
* });
|
|
155
|
-
*
|
|
156
|
-
* // Stop watching
|
|
157
|
-
* unwatch();
|
|
158
|
-
*/
|
|
159
|
-
get watch() {
|
|
160
|
-
return {
|
|
161
|
-
/**
|
|
162
|
-
* Watch Received events
|
|
163
|
-
* @param callback Function to call when event is emitted
|
|
164
|
-
* @param filter Optional filter for indexed parameters
|
|
165
|
-
* @returns Unwatch function to stop listening
|
|
166
|
-
*/
|
|
167
|
-
Received: (callback: (event: { value: bigint; sender: `0x${string}`; data: `0x${string}` }) => void, filter?: { value: bigint; sender: `0x${string}` }) => {
|
|
168
|
-
return this.publicClient.watchContractEvent({
|
|
169
|
-
address: this.contractAddress,
|
|
170
|
-
abi: Proxy_jsonAbi,
|
|
171
|
-
eventName: 'Received',
|
|
172
|
-
args: filter,
|
|
173
|
-
onLogs: (logs: any[]) => {
|
|
174
|
-
logs.forEach((log: any) => {
|
|
175
|
-
callback(log.args as any);
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
}) as () => void;
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
}
|