@0xweb/hardhat 0.1.34 → 0.1.37
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/hardhat.config.js +1 -0
- package/lib/index.js +50 -6
- package/package.json +1 -1
- package/0xc/hardhat/Foo/Foo.ts +0 -208
- package/0xc/hardhat/Foo/FooAbi.json +0 -65
- package/0xweb.json +0 -16
- package/artifacts/build-info/c1643630dd28520b4bf816afd2347880.json +0 -1
- package/cache/solidity-files-cache.json +0 -39
- package/coverage/report/base.css +0 -213
- package/coverage/report/coverage/Foo.sol.html +0 -125
- package/coverage/report/coverage/index.html +0 -93
- package/coverage/report/coverage-final.json +0 -2
- package/coverage/report/index.html +0 -93
- package/coverage/report/lcov-report/base.css +0 -213
- package/coverage/report/lcov-report/coverage/Foo.sol.html +0 -125
- package/coverage/report/lcov-report/coverage/index.html +0 -93
- package/coverage/report/lcov-report/index.html +0 -93
- package/coverage/report/lcov-report/prettify.css +0 -1
- package/coverage/report/lcov-report/prettify.js +0 -1
- package/coverage/report/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/report/lcov-report/sorter.js +0 -158
- package/coverage/report/lcov.info +0 -23
- package/coverage/report/prettify.css +0 -1
- package/coverage/report/prettify.js +0 -1
- package/coverage/report/sort-arrow-sprite.png +0 -0
- package/coverage/report/sorter.js +0 -158
- package/coverage.json +0 -1
package/hardhat.config.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -1816,12 +1816,23 @@ const HardhatProvider_1 = require("dequanto/hardhat/HardhatProvider");
|
|
|
1816
1816
|
const constants_1 = require("hardhat/internal/constants");
|
|
1817
1817
|
var $coverage;
|
|
1818
1818
|
(function ($coverage) {
|
|
1819
|
+
let viaIR = true;
|
|
1820
|
+
function config(opts) {
|
|
1821
|
+
var _a;
|
|
1822
|
+
viaIR = (_a = opts.viaIR) !== null && _a !== void 0 ? _a : viaIR;
|
|
1823
|
+
}
|
|
1824
|
+
$coverage.config = config;
|
|
1819
1825
|
async function compile(params) {
|
|
1820
1826
|
const hh = new HardhatProvider_1.HardhatProvider();
|
|
1821
|
-
const hardhat = await hh.getHardhat();
|
|
1822
1827
|
// Ensure optimizer is disabled, otherwise instrumented code will be removed as unused.
|
|
1828
|
+
const hardhat = await hh.getHardhat();
|
|
1823
1829
|
hardhat.config.solidity.compilers.forEach(compiler => {
|
|
1824
|
-
|
|
1830
|
+
var _a, _b;
|
|
1831
|
+
// -compiler.settings.optimizer.enabled = false;
|
|
1832
|
+
if ((_b = (_a = compiler.settings) === null || _a === void 0 ? void 0 : _a.optimizer) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
1833
|
+
// Prevent from deep reorder
|
|
1834
|
+
compiler.settings.optimizer.runs = 1;
|
|
1835
|
+
}
|
|
1825
1836
|
});
|
|
1826
1837
|
const client = await hh.client('hardhat');
|
|
1827
1838
|
const result = await hh.compileSolDirectory(params.contracts, {
|
|
@@ -1842,7 +1853,7 @@ var $coverage;
|
|
|
1842
1853
|
}
|
|
1843
1854
|
$coverage.attachToHardhatVM = attachToHardhatVM;
|
|
1844
1855
|
async function instrumentFiles(params) {
|
|
1845
|
-
var _a;
|
|
1856
|
+
var _a, _b;
|
|
1846
1857
|
let source = params.source;
|
|
1847
1858
|
let targetDir = (_a = params.target) !== null && _a !== void 0 ? _a : './coverage/contracts/';
|
|
1848
1859
|
let files;
|
|
@@ -1872,15 +1883,48 @@ var $coverage;
|
|
|
1872
1883
|
};
|
|
1873
1884
|
})
|
|
1874
1885
|
.toArrayAsync({ threads: 5 });
|
|
1886
|
+
const G_ORIG = 'orig';
|
|
1887
|
+
const G_INSTRUMENT = 'instrument';
|
|
1888
|
+
let groups = (0, alot_1.default)(targets).groupBy(x => {
|
|
1889
|
+
if (isIgnored(x.relativePath, params.ignore)) {
|
|
1890
|
+
return G_ORIG;
|
|
1891
|
+
}
|
|
1892
|
+
return G_INSTRUMENT;
|
|
1893
|
+
}).toDictionary(x => x.key, x => x.values);
|
|
1875
1894
|
const api = await ApiUtil.getApi();
|
|
1876
|
-
const result = await api.instrument(
|
|
1877
|
-
await (0, alot_1.default)(result)
|
|
1895
|
+
const result = await api.instrument(groups[G_INSTRUMENT]);
|
|
1896
|
+
await (0, alot_1.default)(result !== null && result !== void 0 ? result : [])
|
|
1878
1897
|
.forEachAsync(async (target) => {
|
|
1879
1898
|
let path = target.relativePath.replace(/^[\/.]*contracts/, '');
|
|
1880
1899
|
let output = _path_1.$path.join(targetDir, path);
|
|
1881
1900
|
await atma_io_1.File.writeAsync(output, target.source);
|
|
1882
1901
|
})
|
|
1883
1902
|
.toArrayAsync({ threads: 5 });
|
|
1903
|
+
await (0, alot_1.default)((_b = groups[G_ORIG]) !== null && _b !== void 0 ? _b : [])
|
|
1904
|
+
.forEachAsync(async (target) => {
|
|
1905
|
+
let path = target.relativePath.replace(/^[\/.]*contracts/, '');
|
|
1906
|
+
let output = _path_1.$path.join(targetDir, path);
|
|
1907
|
+
await atma_io_1.File.writeAsync(output, target.source);
|
|
1908
|
+
})
|
|
1909
|
+
.toArrayAsync({ threads: 5 });
|
|
1910
|
+
function isIgnored(relativePath, ignores) {
|
|
1911
|
+
if (ignores == null || ignores.length === 0) {
|
|
1912
|
+
return false;
|
|
1913
|
+
}
|
|
1914
|
+
for (let ignore of ignores) {
|
|
1915
|
+
if (typeof ignore === 'string') {
|
|
1916
|
+
if (relativePath.includes(ignore)) {
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
else if (ignore instanceof RegExp) {
|
|
1921
|
+
if (ignore.test(relativePath)) {
|
|
1922
|
+
return true;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
return false;
|
|
1927
|
+
}
|
|
1884
1928
|
}
|
|
1885
1929
|
$coverage.instrumentFiles = instrumentFiles;
|
|
1886
1930
|
async function report(params) {
|
|
@@ -1892,7 +1936,7 @@ var $coverage;
|
|
|
1892
1936
|
$coverage.report = report;
|
|
1893
1937
|
class ApiUtil {
|
|
1894
1938
|
static async getApi() {
|
|
1895
|
-
return new Api();
|
|
1939
|
+
return new Api({ viaIR });
|
|
1896
1940
|
}
|
|
1897
1941
|
}
|
|
1898
1942
|
__decorate([
|
package/package.json
CHANGED
package/0xc/hardhat/Foo/Foo.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
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']>;
|
|
@@ -1,65 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|