Skip to content

Commit

Permalink
Merge pull request #2612 from keep-network/new-project-structure
Browse files Browse the repository at this point in the history
Setting up hardhat for beacon v2

Adding dependency libs and basic configuration for hardhat.
  • Loading branch information
nkuba committed Sep 27, 2021
2 parents 957b0eb + b87fc22 commit 998a1ec
Show file tree
Hide file tree
Showing 12 changed files with 8,543 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ configs
# Private testnet artifacts
*-keep-client-deployment-bundle.tar.gz
keep-client-snapshot.tar

# Yarn
yarn-error.log

# Hardhat
cache/
export.json
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

25 changes: 25 additions & 0 deletions solidity/random-beacon/.hardhat/networks_TEMPLATE.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This is a template file. The file should be renamed to `networks.ts` and updated
// with valid data. The properties will overwrite the ones defined in hardhat
// project config file if hardhat.config.ts file contains `localNetworksConfig` property
// pointing to this file.

import { LocalNetworksConfig } from "@keep-network/hardhat-local-networks-config"

const config: LocalNetworksConfig = {
networks: {
ropsten: {
url: "url not set",
from: "address not set",
accounts: ["private key not set"],
tags: ["tenderly"],
},
mainnet: {
url: "url not set",
from: "address not set",
accounts: ["private key not set"],
tags: ["tenderly"],
},
},
}

module.exports = config
21 changes: 21 additions & 0 deletions solidity/random-beacon/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 keep.network

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions solidity/random-beacon/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= Keep Random Beacon
9 changes: 9 additions & 0 deletions solidity/random-beacon/contracts/test/TestToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.5;

// Stub contract used for initial project setup.
// Should be removed once we have actual contracts.
contract TestToken {
string public name = "Test Token";
}
25 changes: 25 additions & 0 deletions solidity/random-beacon/deploy/00_deploy_test_token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { HardhatRuntimeEnvironment } from "hardhat/types"
import { DeployFunction } from "hardhat-deploy/types"

// This is an example of deployment script.
// Should be removed once we have actual contracts to deploy.
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre
const { deployer } = await getNamedAccounts()

const testToken = await deployments.deploy("TestToken", {
from: deployer,
log: true,
})

if (hre.network.tags.tenderly) {
await hre.tenderly.verify({
name: "TestToken",
address: testToken.address,
})
}
}

export default func

func.tags = ["TestToken"]
56 changes: 56 additions & 0 deletions solidity/random-beacon/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { HardhatUserConfig } from "hardhat/config"

import "@keep-network/hardhat-local-networks-config"
import "hardhat-deploy"
import "@tenderly/hardhat-tenderly"
import "@nomiclabs/hardhat-waffle"
import "hardhat-gas-reporter"

const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.5",
},
],
},
paths: {
artifacts: "./build",
},
networks: {
hardhat: {
forking: {
// forking is enabled only if FORKING_URL env is provided
enabled: !!process.env.FORKING_URL,
// URL should point to a node with archival data (Alchemy recommended)
url: process.env.FORKING_URL || "",
// latest block is taken if FORKING_BLOCK env is not provided
blockNumber: process.env.FORKING_BLOCK
? parseInt(process.env.FORKING_BLOCK)
: undefined,
},
tags: ["local"],
},
ropsten: {
url: process.env.CHAIN_API_URL || "",
chainId: 3,
accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY
? [process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY]
: undefined,
tags: ["tenderly"],
},
},
// // Define local networks configuration file path to load networks from the file.
// localNetworksConfig: "./.hardhat/networks.ts",
tenderly: {
username: "thesis",
project: "",
},
namedAccounts: {
deployer: {
default: 0, // take the first account as deployer
},
},
}

export default config
30 changes: 30 additions & 0 deletions solidity/random-beacon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@keep-network/random-beacon",
"version": "2.0.0-dev",
"description": "Keep Random Beacon",
"scripts": {
"build": "hardhat compile",
"test": "hardhat test",
"deploy": "hardhat deploy --export export.json"
},
"devDependencies": {
"@keep-network/hardhat-local-networks-config": "^0.1.0-pre.0",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@types/node": "^16.9.6",
"@tenderly/hardhat-tenderly": "^1.0.12",
"chai": "^4.3.4",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.4.7",
"hardhat": "^2.6.4",
"hardhat-deploy": "^0.9.1",
"hardhat-gas-reporter": "^1.0.4",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
},
"engines": {
"node": ">= 14.0.0"
}
}
18 changes: 18 additions & 0 deletions solidity/random-beacon/test/TestToken.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ethers } from "hardhat";
import { expect } from "chai";

// This is an example of Typescript test.
// Should be removed once we have actual tests.
describe("Token", function () {
let testToken

beforeEach(async function () {
const TestToken = await ethers.getContractFactory("TestToken")
testToken = await TestToken.deploy()
await testToken.deployed()
});

it("should test token name", async function () {
expect(await testToken.name()).to.equal("Test Token")
});
});
7 changes: 7 additions & 0 deletions solidity/random-beacon/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": [
"./hardhat.config.ts",
"node_modules/@keep-network/hardhat-local-networks-config/src/type-extensions.d.ts"
],
"include": ["./deploy", "./test"]
}

0 comments on commit 998a1ec

Please sign in to comment.