Separate secrets to another file, add some Dione-related tasks to hardhat project

This commit is contained in:
ChronosX88 2021-07-28 21:13:30 +03:00
parent 225c84e8a8
commit 7e8e4ccc41
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
4 changed files with 48 additions and 18 deletions

3
.gitignore vendored
View File

@ -25,4 +25,5 @@ eth-contracts/node_modules
/.dione-config-4.toml /.dione-config-4.toml
.bootstrap_privkey .bootstrap_privkey
eth-contracts/build eth-contracts/build
/.db .db
eth-contracts/secrets.json

View File

@ -1,30 +1,24 @@
import { task } from "hardhat/config";
import "@nomiclabs/hardhat-ethers"; import "@nomiclabs/hardhat-ethers";
import "hardhat-tracer"; import "hardhat-tracer";
import "@nomiclabs/hardhat-waffle"; import "@nomiclabs/hardhat-waffle";
import "solidity-coverage"; import "solidity-coverage";
import "hardhat-gas-reporter"; import "hardhat-gas-reporter";
import * as secrets from "./secrets.json";
task("accounts", "Prints the list of accounts", async (args, hre) => { import "./hardhat.tasks";
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(await account.address);
}
});
export default { export default {
solidity: "0.8.3", solidity: {
networks: { version: "0.8.3",
geth: { settings: {
url: `http://localhost:8545`, optimizer: {
accounts: { enabled: false,
mnemonic: "test test test test test test test test test test test junk" runs: 200
} }
} }
}, },
networks: secrets.networks,
gasReporter: { gasReporter: {
currency: 'USD', currency: 'USD',
enabled: (process.env.REPORT_GAS) ? true : false enabled: process.env.REPORT_GAS
} }
}; };

View File

@ -0,0 +1,34 @@
import { task } from "hardhat/config";
import "@nomiclabs/hardhat-ethers";
task("stake", "Prints an account's stake amount in DioneStaking contract")
.addParam("contract", "DioneStaking contract address")
.addParam("account", "The account's address")
.setAction(async (args, hre) => {
const DioneStaking = await hre.ethers.getContractFactory("DioneStaking");
const contract = DioneStaking.attach(args.contract);
const a = await contract.minerStake(args.account);
console.log("Stake amount:", a.div(hre.ethers.constants.WeiPerEther).toString());
});
task("accounts", "Prints the list of accounts", async (args, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(await account.address);
}
});
task("oracleRequest", "Makes oracle request to Mediator contract")
.addParam("contract", "Mediator contract address")
.addParam("chainid", "Chain ID from which need to request info")
.addParam("method", "Method name of requesting chain RPC")
.addParam("param", "Value of parameter for specified method")
.setAction(async (args, hre) => {
const Mediator = await hre.ethers.getContractFactory("Mediator");
const contract = Mediator.attach(args.contract);
const res = await contract.request(args.chainid, args.method, args.param)
console.log("Request has successfully been sent.")
console.log("Transaction info:")
console.log(res)
})

View File

@ -4,7 +4,8 @@
"module": "commonjs", "module": "commonjs",
"strict": true, "strict": true,
"esModuleInterop": true, "esModuleInterop": true,
"outDir": "dist" "outDir": "dist",
"resolveJsonModule": true
}, },
"include": ["./scripts", "./test", "./common"], "include": ["./scripts", "./test", "./common"],
"files": ["./hardhat.config.ts"] "files": ["./hardhat.config.ts"]