@0xweb/hardhat 0.1.33 → 0.1.34

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,208 @@
1
+ /**
2
+ * AUTO-Generated Class: 2025-12-03 10:56
3
+ * Implementation: coverage/contracts/test/fixtures/coverage/Foo.sol
4
+ */
5
+ import di from 'a-di';
6
+ import { TAddress } from 'dequanto/models/TAddress';
7
+ import { TAccount } from 'dequanto/models/TAccount';
8
+ import { TBufferLike } from 'dequanto/models/TBufferLike';
9
+ import { ClientEventsStream, TClientEventsStreamData } from 'dequanto/clients/ClientEventsStream';
10
+ import { ContractBase } from 'dequanto/contracts/ContractBase';
11
+ import { ContractBaseUtils } from 'dequanto/contracts/utils/ContractBaseUtils';
12
+ import { ContractStorageReaderBase } from 'dequanto/contracts/ContractStorageReaderBase';
13
+ import { TxWriter } from 'dequanto/txs/TxWriter';
14
+ import { ITxLogItem } from 'dequanto/txs/receipt/ITxLogItem';
15
+ import { Web3Client } from 'dequanto/clients/Web3Client';
16
+ import { IBlockchainExplorer } from 'dequanto/explorer/IBlockchainExplorer';
17
+ import { SubjectStream } from 'dequanto/class/SubjectStream';
18
+
19
+
20
+ import type { ContractWriter } from 'dequanto/contracts/ContractWriter';
21
+ import type { TAbiItem } from 'dequanto/types/TAbi';
22
+ import type { TEth } from 'dequanto/models/TEth';
23
+ import type { TOverrideReturns } from 'dequanto/utils/types';
24
+
25
+
26
+ import { Etherscan } from 'dequanto/explorer/Etherscan';
27
+ import { HardhatWeb3Client } from 'dequanto/hardhat/HardhatWeb3Client';
28
+
29
+
30
+
31
+ export class Foo extends ContractBase {
32
+ constructor(
33
+ public address: TEth.Address = null,
34
+ public client: Web3Client = di.resolve(HardhatWeb3Client, ),
35
+ public explorer: IBlockchainExplorer = di.resolve(Etherscan, ),
36
+ ) {
37
+ super(address, client, explorer)
38
+
39
+ this.storage = new FooStorageReader(this.address, this.client, this.explorer);
40
+ }
41
+
42
+ Types: TFooTypes;
43
+
44
+ $meta = {
45
+ "artifact": "artifacts/coverage/contracts/test/fixtures/coverage/Foo.sol/Foo.json",
46
+ "class": "./0xc/hardhat/Foo/Foo.ts"
47
+ }
48
+
49
+ async $constructor (deployer: TSender, _name: string): Promise<TxWriter> {
50
+ throw new Error('Not implemented. Typing purpose. Use the ContractDeployer class to deploy the contract');
51
+ }
52
+
53
+ // 0x17d7de7c
54
+ async getName (): Promise<string> {
55
+ return this.$read(this.$getAbiItem('function', 'getName'));
56
+ }
57
+
58
+ // 0x06fdde03
59
+ async name (): Promise<string> {
60
+ return this.$read(this.$getAbiItem('function', 'name'));
61
+ }
62
+
63
+ // 0xc47f0027
64
+ async setName (sender: TSender, _name: string): Promise<TxWriter> {
65
+ return this.$write(this.$getAbiItem('function', 'setName'), sender, _name);
66
+ }
67
+
68
+ $call () {
69
+ return super.$call() as IFooTxCaller;
70
+ }
71
+ $signed (): TOverrideReturns<IFooTxCaller, Promise<{ signed: TEth.Hex, error?: Error & { data?: { type: string, params } } }>> {
72
+ return super.$signed() as any;
73
+ }
74
+ $data (): IFooTxData {
75
+ return super.$data() as IFooTxData;
76
+ }
77
+ $gas (): TOverrideReturns<IFooTxCaller, Promise<{ gas?: bigint, price?: bigint, error?: Error & { data?: { type: string, params } } }>> {
78
+ return super.$gas() as any;
79
+ }
80
+
81
+ onTransaction <TMethod extends keyof TFooTypes['Methods']> (method: TMethod, options: Parameters<ContractBase['$onTransaction']>[0]): SubjectStream<{
82
+ tx: TEth.Tx
83
+ block: TEth.Block<TEth.Hex>
84
+ calldata: {
85
+ method: TMethod
86
+ arguments: TFooTypes['Methods'][TMethod]['arguments']
87
+ }
88
+ }> {
89
+ options ??= {};
90
+ options.filter ??= {};
91
+ options.filter.method = method;
92
+ return <any> this.$onTransaction(options);
93
+ }
94
+
95
+ onLog (event: keyof TEvents, cb?: (event: TClientEventsStreamData) => void): ClientEventsStream<TClientEventsStreamData> {
96
+ return this.$onLog(event, cb);
97
+ }
98
+
99
+ async getPastLogs <TEventName extends keyof TEvents> (
100
+ events: TEventName[]
101
+ , options?: TEventLogOptions<TEventParams<TEventName>>
102
+ ): Promise<ITxLogItem<TEventParams<TEventName>, TEventName>[]>
103
+ async getPastLogs <TEventName extends keyof TEvents> (
104
+ event: TEventName
105
+ , options?: TEventLogOptions<TEventParams<TEventName>>
106
+ ): Promise<ITxLogItem<TEventParams<TEventName>, TEventName>[]>
107
+ async getPastLogs (mix: any, options?): Promise<any> {
108
+ return await super.getPastLogs(mix, options) as any;
109
+ }
110
+
111
+ onUpdated (fn?: (event: TClientEventsStreamData<TEventArguments<'Updated'>>) => void): ClientEventsStream<TClientEventsStreamData<TEventArguments<'Updated'>>> {
112
+ return this.$onLog('Updated', fn);
113
+ }
114
+
115
+ extractLogsUpdated (tx: TEth.TxReceipt): ITxLogItem<TEventParams<'Updated'>>[] {
116
+ let abi = this.$getAbiItem('event', 'Updated');
117
+ return this.$extractLogs(tx, abi) as any as ITxLogItem<TEventParams<'Updated'>>[];
118
+ }
119
+
120
+ async getPastLogsUpdated (options?: {
121
+ fromBlock?: number | Date
122
+ toBlock?: number | Date
123
+ params?: { }
124
+ }): Promise<ITxLogItem<TEventParams<'Updated'>>[]> {
125
+ return await this.$getPastLogsParsed('Updated', options) as any;
126
+ }
127
+
128
+ abi: TAbiItem[] = [{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"newName","type":"string"}],"name":"Updated","type":"event"},{"inputs":[],"name":"getName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"setName","outputs":[],"stateMutability":"nonpayable","type":"function"}]
129
+
130
+ declare storage: FooStorageReader
131
+ }
132
+
133
+ type TSender = TAccount & {
134
+ value?: string | number | bigint
135
+ }
136
+
137
+ type TEventLogOptions<TParams> = {
138
+ fromBlock?: number | Date
139
+ toBlock?: number | Date
140
+ params?: TParams
141
+ }
142
+
143
+ export type TFooTypes = {
144
+ Events: {
145
+ Updated: {
146
+ outputParams: { newName: string },
147
+ outputArgs: [ newName: string ],
148
+ }
149
+ },
150
+ Methods: {
151
+ getName: {
152
+ method: "getName"
153
+ arguments: [ ]
154
+ }
155
+ name: {
156
+ method: "name"
157
+ arguments: [ ]
158
+ }
159
+ setName: {
160
+ method: "setName"
161
+ arguments: [ _name: string ]
162
+ }
163
+ }
164
+ }
165
+
166
+
167
+
168
+ class FooStorageReader extends ContractStorageReaderBase {
169
+ constructor(
170
+ public address: TAddress,
171
+ public client: Web3Client,
172
+ public explorer: IBlockchainExplorer,
173
+ ) {
174
+ super(address, client, explorer);
175
+
176
+ this.$createHandler(this.$slots);
177
+ }
178
+
179
+ async name(): Promise<string> {
180
+ return this.$storage.get(['name', ]);
181
+ }
182
+
183
+ $slots = [
184
+ {
185
+ "slot": 0,
186
+ "position": 0,
187
+ "name": "name",
188
+ "size": null,
189
+ "type": "string"
190
+ }
191
+ ]
192
+
193
+ }
194
+
195
+
196
+ interface IFooTxCaller {
197
+ setName (sender: TSender, _name: string): Promise<{ error?: Error & { data?: { type: string, params } }, result? }>
198
+ }
199
+
200
+
201
+ interface IFooTxData {
202
+ setName (sender: TSender, _name: string): Promise<TEth.TxLike>
203
+ }
204
+
205
+
206
+ type TEvents = TFooTypes['Events'];
207
+ type TEventParams<TEventName extends keyof TEvents> = Partial<TEvents[TEventName]['outputParams']>;
208
+ type TEventArguments<TEventName extends keyof TEvents> = Partial<TEvents[TEventName]['outputArgs']>;
@@ -0,0 +1,65 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "string",
6
+ "name": "_name",
7
+ "type": "string"
8
+ }
9
+ ],
10
+ "stateMutability": "nonpayable",
11
+ "type": "constructor"
12
+ },
13
+ {
14
+ "anonymous": false,
15
+ "inputs": [
16
+ {
17
+ "indexed": false,
18
+ "internalType": "string",
19
+ "name": "newName",
20
+ "type": "string"
21
+ }
22
+ ],
23
+ "name": "Updated",
24
+ "type": "event"
25
+ },
26
+ {
27
+ "inputs": [],
28
+ "name": "getName",
29
+ "outputs": [
30
+ {
31
+ "internalType": "string",
32
+ "name": "",
33
+ "type": "string"
34
+ }
35
+ ],
36
+ "stateMutability": "view",
37
+ "type": "function"
38
+ },
39
+ {
40
+ "inputs": [],
41
+ "name": "name",
42
+ "outputs": [
43
+ {
44
+ "internalType": "string",
45
+ "name": "",
46
+ "type": "string"
47
+ }
48
+ ],
49
+ "stateMutability": "view",
50
+ "type": "function"
51
+ },
52
+ {
53
+ "inputs": [
54
+ {
55
+ "internalType": "string",
56
+ "name": "_name",
57
+ "type": "string"
58
+ }
59
+ ],
60
+ "name": "setName",
61
+ "outputs": [],
62
+ "stateMutability": "nonpayable",
63
+ "type": "function"
64
+ }
65
+ ]
package/0xweb.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "dependencies": {
3
+ "Foo": {
4
+ "main": "./0xc/hardhat/Foo/Foo.ts",
5
+ "contractName": "Foo",
6
+ "source": {
7
+ "path": "file:///home/runner/work/hardhat/hardhat/artifacts/coverage/contracts/test/fixtures/coverage/Foo.sol/Foo.json"
8
+ },
9
+ "deployments": {
10
+ "hardhat": {
11
+ "address": null
12
+ }
13
+ }
14
+ }
15
+ }
16
+ }