diff --git a/.gitignore b/.gitignore index 03dfc01..45d3320 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,5 @@ eth-contracts/node_modules /.dione-config-4.toml .bootstrap_privkey eth-contracts/build -/.db +.db +eth-contracts/secrets.json \ No newline at end of file diff --git a/eth-contracts/hardhat.config.ts b/eth-contracts/hardhat.config.ts index 66a5258..3d6f9c2 100644 --- a/eth-contracts/hardhat.config.ts +++ b/eth-contracts/hardhat.config.ts @@ -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 } }; \ No newline at end of file diff --git a/eth-contracts/hardhat.tasks.ts b/eth-contracts/hardhat.tasks.ts new file mode 100644 index 0000000..b188691 --- /dev/null +++ b/eth-contracts/hardhat.tasks.ts @@ -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) + }) \ No newline at end of file diff --git a/eth-contracts/tsconfig.json b/eth-contracts/tsconfig.json index d8b1055..421550b 100644 --- a/eth-contracts/tsconfig.json +++ b/eth-contracts/tsconfig.json @@ -4,7 +4,8 @@ "module": "commonjs", "strict": true, "esModuleInterop": true, - "outDir": "dist" + "outDir": "dist", + "resolveJsonModule": true }, "include": ["./scripts", "./test", "./common"], "files": ["./hardhat.config.ts"]