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
.bootstrap_privkey
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 "hardhat-tracer";
import "@nomiclabs/hardhat-waffle";
import "solidity-coverage";
import "hardhat-gas-reporter";
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);
}
});
import * as secrets from "./secrets.json";
import "./hardhat.tasks";
export default {
solidity: "0.8.3",
networks: {
geth: {
url: `http://localhost:8545`,
accounts: {
mnemonic: "test test test test test test test test test test test junk"
solidity: {
version: "0.8.3",
settings: {
optimizer: {
enabled: false,
runs: 200
}
}
},
networks: secrets.networks,
gasReporter: {
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",
"strict": true,
"esModuleInterop": true,
"outDir": "dist"
"outDir": "dist",
"resolveJsonModule": true
},
"include": ["./scripts", "./test", "./common"],
"files": ["./hardhat.config.ts"]