@0xweb/hardhat 0.1.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/hardhat.config.sample.js +31 -0
- package/index.ts +49 -0
- package/package.json +33 -0
- package/readme.md +8 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require("@nomiclabs/hardhat-web3");
|
|
2
|
+
require("@nomiclabs/hardhat-waffle");
|
|
3
|
+
require("@nomiclabs/hardhat-etherscan");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
solidity: {
|
|
7
|
+
version: "0.8.2",
|
|
8
|
+
settings: {
|
|
9
|
+
optimizer: {
|
|
10
|
+
enabled: true,
|
|
11
|
+
runs: 200
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
networks: {
|
|
16
|
+
hardhat: {
|
|
17
|
+
chainId: 1337
|
|
18
|
+
},
|
|
19
|
+
localhost: {
|
|
20
|
+
chainId: 1337
|
|
21
|
+
},
|
|
22
|
+
mainnet: {
|
|
23
|
+
url: ``,
|
|
24
|
+
accounts: [``]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
etherscan: {
|
|
28
|
+
// One at https://etherscan.io/
|
|
29
|
+
apiKey: ""
|
|
30
|
+
}
|
|
31
|
+
};
|
package/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import hre from "hardhat";
|
|
2
|
+
import memd from 'memd';
|
|
3
|
+
import type Ethers from 'ethers'
|
|
4
|
+
import { ContractBase } from '@dequanto/contracts/ContractBase';
|
|
5
|
+
import { type Constructor } from 'atma-utils/mixin';
|
|
6
|
+
import { ChainAccount } from '@dequanto/ChainAccounts';
|
|
7
|
+
import { HardhatWeb3Client } from '@dequanto/clients/HardhatWeb3Client';
|
|
8
|
+
|
|
9
|
+
export class HardhatWeb {
|
|
10
|
+
|
|
11
|
+
@memd.deco.memoize()
|
|
12
|
+
static deployer(index: number = 0): ChainAccount {
|
|
13
|
+
const ethers: typeof Ethers = (hre as any).ethers;
|
|
14
|
+
const accounts: any = hre.config.networks.hardhat.accounts;
|
|
15
|
+
const wallet = ethers.Wallet.fromMnemonic(accounts.mnemonic, accounts.path + `/${index}`);
|
|
16
|
+
return {
|
|
17
|
+
key: wallet.privateKey,
|
|
18
|
+
address: wallet.address,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@memd.deco.memoize()
|
|
23
|
+
static async resolve<T extends ContractBase>(Ctor: Constructor<T>): Promise<T> {
|
|
24
|
+
|
|
25
|
+
await ContractProvider.compile();
|
|
26
|
+
|
|
27
|
+
const ethers = (hre as any).ethers;
|
|
28
|
+
|
|
29
|
+
const Factory: Ethers.ContractFactory = await ethers.getContractFactory(Ctor.name);
|
|
30
|
+
const contract = await Factory.deploy();
|
|
31
|
+
const receipt = await contract.deployed();
|
|
32
|
+
|
|
33
|
+
console.log(`Contract ${Ctor.name} deployed to ${contract.address}`);
|
|
34
|
+
|
|
35
|
+
const client = ContractProvider.client();
|
|
36
|
+
return new Ctor(contract.address, client);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static client() {
|
|
40
|
+
const web3 = (hre as any).web3;
|
|
41
|
+
const client = new HardhatWeb3Client({ web3, chainId: 1337 });
|
|
42
|
+
return client;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@memd.deco.memoize()
|
|
46
|
+
private static async compile () {
|
|
47
|
+
await hre.run('compile');
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@0xweb/hardhat",
|
|
3
|
+
"description": "Hardhat addon for 0xweb",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Alex Kit",
|
|
8
|
+
"email": "alex.kit@atmajs.com"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/0xweb-org/hardhat"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"web3",
|
|
16
|
+
"contracts",
|
|
17
|
+
"evm"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"memd": "^0.3.10"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@nomiclabs/hardhat-etherscan": ">=3.0.3",
|
|
25
|
+
"@nomiclabs/hardhat-waffle": ">=2.0.3",
|
|
26
|
+
"@nomiclabs/hardhat-web3": ">=2.0.0",
|
|
27
|
+
"ethers": ">=5.6.4",
|
|
28
|
+
"hardhat": ">=2.9.3"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# [Hardhat](https://hardhat.org/) addon for [`0xWeb`](https://0xweb.org)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Distribution `as-Source-Code`
|
|
5
|
+
|
|
6
|
+
A factory class to initialize and configurate the generated contract class by `0xweb` to be used in `Hardhat` network - `in-process` or `localhost`
|
|
7
|
+
|
|
8
|
+
----
|