Skip to content
This repository was archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from interlay/hardhat
Browse files Browse the repository at this point in the history
migrate to hardhat
  • Loading branch information
gregdhill authored Nov 3, 2020
2 parents ae16914 + ab45598 commit 7c04f44
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 94 deletions.
8 changes: 4 additions & 4 deletions contracts/Relay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ contract Relay is IRelay {
*/
function getBlockHeight(bytes32 digest)
external
override
view
override
returns (uint32)
{
return _headers[digest].height;
Expand All @@ -339,8 +339,8 @@ contract Relay is IRelay {
*/
function getBlockHash(uint32 height)
external
override
view
override
returns (bytes32)
{
bytes32 digest = _chain[height];
Expand All @@ -353,8 +353,8 @@ contract Relay is IRelay {
*/
function getBestBlock()
external
override
view
override
returns (bytes32 digest, uint32 height)
{
return (_bestBlock, _bestHeight);
Expand All @@ -371,7 +371,7 @@ contract Relay is IRelay {
bytes calldata proof,
uint256 confirmations,
bool insecure
) external override view returns (bool) {
) external view override returns (bool) {
// txid must be little endian
require(txid != 0, ERR_INVALID_TXID);

Expand Down
25 changes: 13 additions & 12 deletions buidler.config.ts → hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import {usePlugin} from '@nomiclabs/buidler/config';

usePlugin('@nomiclabs/buidler-ganache');
usePlugin('@nomiclabs/buidler-waffle');
usePlugin('buidler-typechain');
usePlugin('buidler-gas-reporter');
require('@nomiclabs/hardhat-ganache');
require('@nomiclabs/hardhat-waffle');
require('hardhat-typechain');
import '@nomiclabs/hardhat-ethers';
// require('buidler-gas-reporter');

const INFURA_API_KEY = process.env.INFURA_API_KEY || '';
const ROPSTEN_PRIVATE_KEY = process.env.ROPSTEN_PRIVATE_KEY || '';
const ROPSTEN_PRIVATE_KEY =
process.env.ROPSTEN_PRIVATE_KEY ||
'5de75329e619948d55744d85d763790ae3f7643f0a498070558acdb37d6b2057'; // Dummy wallet

const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY;

const config = {
defaultNetwork: 'buidlerevm',
solc: {
defaultNetwork: 'hardhat',
solidity: {
version: '0.6.6',
optimizer: {enabled: true, runs: 500}
},
Expand All @@ -21,11 +22,11 @@ const config = {
tests: './test'
},
typechain: {
outDir: 'typechain',
target: 'ethers'
outDir: './typechain',
target: 'ethers-v5'
},
networks: {
buidlerevm: {},
hardhat: {},
ganache: {
url: 'http://127.0.0.1:8545',
mnemonic:
Expand Down
60 changes: 30 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
{
"name": "@interlay/btc-relay-sol",
"version": "0.3.13",
"version": "0.3.14",
"description": "BTC Relay in Solidity",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"@interlay/bitcoin-spv-sol": "3.2.2",
"@openzeppelin/contracts": "3.1.0",
"@openzeppelin/contracts": "3.2.0",
"bitcoinjs-lib": "^5.1.7",
"ethers": "^4.0.44"
"ethers": "^5.0.19"
},
"files": [
"contracts",
"dist"
],
"devDependencies": {
"@nomiclabs/buidler": "^1.1.2",
"@nomiclabs/buidler-ethers": "^1.1.2",
"@nomiclabs/buidler-etherscan": "^1.1.2",
"@nomiclabs/buidler-ganache": "^1.3.3",
"@nomiclabs/buidler-waffle": "^1.1.2",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^2.0.0",
"@nomiclabs/hardhat-ganache": "^2.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@typechain/ethers-v5": "^2.0.0",
"@types/chai": "^4.2.8",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.0",
"@typescript-eslint/eslint-plugin": "^2.21.0",
"@typescript-eslint/parser": "^2.21.0",
"buidler-typechain": "0.0.5",
"@types/mocha": "^8.0.3",
"@types/node": "^14.14.2",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"buidler-gas-reporter": "^0.1.4",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"ethereum-waffle": "^2.3.2",
"ethereum-waffle": "^3.1.1",
"hardhat": "^2.0.0",
"hardhat-deploy-ethers": "^0.3.0-beta.5",
"hardhat-gas-reporter": "^1.0.0-beta.0",
"hardhat-typechain": "^0.2.5",
"husky": "^4.2.5",
"prettier": "^2.0.5",
"prettier-plugin-solidity": "^1.0.0-alpha.56",
"solhint": "^3.1.0",
"solhint-plugin-prettier": "^0.0.4",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.1",
"ts-generator": "0.0.8",
"ts-node": "^8.6.2",
"typechain": "^1.0.4",
"typechain-target-ethers": "^1.0.4",
"typechain-target-truffle": "^1.0.2",
"typechain-target-web3-v1": "^1.0.4",
"buidler-gas-reporter": "^0.1.3",
"typescript": "^3.7.5"
"ts-generator": "0.1.1",
"ts-node": "^9.0.0",
"typechain": "^3.0.0",
"typescript": "^4.0.3"
},
"scripts": {
"build": "yarn run compile && buidler typechain",
"compile": "buidler compile",
"test": "buidler test",
"deploy": "buidler run scripts/deploy.ts",
"ganache": "buidler run scripts/ganache.ts",
"build": "yarn run compile && hardhat typechain",
"compile": "hardhat compile",
"test": "hardhat test",
"deploy": "hardhat run scripts/deploy.ts",
"ganache": "hardhat run scripts/ganache.ts",
"tsc": "tsc && cp typechain/*.d.ts dist/typechain/",
"clean": "buidler clean && rm -rf dist",
"clean": "hardhat clean && rm -rf dist",
"lint::typescript": "eslint './**/*.ts' --ext .ts",
"prettier::typescript": "prettier --write './**/*.ts'",
"lint::solidity": "solhint 'contracts/**/*.sol'",
Expand Down
30 changes: 15 additions & 15 deletions scripts/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Signer, Contract} from 'ethers';
import {TestRelayFactory} from '../typechain/TestRelayFactory';
import {RelayFactory} from '../typechain/RelayFactory';
import {TypedFunctionDescription} from '../typechain';
import {TransactionReceipt} from 'ethers/providers';
// import {FunctionDescription} from '../typechain'
// import {TransactionReceipt} from 'ethers/providers';
import {Relay} from '../typechain/Relay';
import {TestRelay} from '../typechain/TestRelay';

Expand Down Expand Up @@ -30,16 +30,16 @@ export async function DeployTestRelay(
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function Call<C extends Contract, T extends any[]>(
signer: Signer,
contract: C,
func: TypedFunctionDescription<{encode: (arg0: T) => string}>,
args: T
): Promise<TransactionReceipt> {
const call = contract.interface.functions[func.name].encode(args);
const response = await signer.sendTransaction({
to: contract.address,
data: call
});
return response.wait(0);
}
// export async function Call<C extends Contract, T extends any[]>(
// signer: Signer,
// contract: C,
// func: FunctionDescription<{encode: (arg0: T) => string}>,
// args: T
// ): Promise<TransactionReceipt> {
// const call = contract.interface.functions[func.name].encode(args);
// const response = await signer.sendTransaction({
// to: contract.address,
// data: call
// });
// return response.wait(0);
// }
5 changes: 2 additions & 3 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-console */

import {ethers} from '@nomiclabs/buidler';
import {ethers} from 'hardhat';
import {DeployTestRelay, Genesis} from './contracts';

// const mainnet: Genesis = {
Expand All @@ -20,7 +19,7 @@ const testnet: Genesis = {
// }

async function main(genesis: Genesis): Promise<void> {
const signers = await ethers.signers();
const signers = await ethers.getSigners();
const contract = await DeployTestRelay(signers[0], genesis);
console.log(`Genesis height: ${genesis.height}`);
console.log(`Contract address: ${contract.address}`);
Expand Down
2 changes: 1 addition & 1 deletion scripts/ganache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */

import config from '../buidler.config';
import config from '../hardhat.config';
import * as child from 'child_process';

const ganacheCmd = 'ganache-cli -d';
Expand Down
4 changes: 2 additions & 2 deletions test/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ethers} from '@nomiclabs/buidler';
import {ethers} from 'hardhat';
import chai from 'chai';
import {solidity} from 'ethereum-waffle';
import {genesis, generate} from '../scripts/builder';
Expand All @@ -10,7 +10,7 @@ const {expect} = chai;
describe('Build', () => {
it('should build and store headers', async () => {
let block = genesis();
const signers = await ethers.signers();
const signers = await ethers.getSigners();
const contract = await DeployTestRelay(signers[0], {
header: '0x' + block.toHex(true),
height: 1
Expand Down
6 changes: 3 additions & 3 deletions test/fork.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ethers} from '@nomiclabs/buidler';
import {ethers} from 'hardhat';
import {Signer, Wallet} from 'ethers';
import chai from 'chai';
import {deployContract, solidity} from 'ethereum-waffle';
import RelayArtifact from '../artifacts/Relay.json';
import RelayArtifact from '../artifacts/contracts/Relay.sol/Relay.json';
import {Relay} from '../typechain/Relay';

chai.use(solidity);
Expand All @@ -18,7 +18,7 @@ describe('Forking', () => {
let relay: Relay;

beforeEach(async () => {
signers = await ethers.signers();
signers = await ethers.getSigners();
const genesis =
'0x00000020db62962b5989325f30f357762ae456b2ec340432278e14000000000000000000d1dd4e30908c361dfeabfb1e560281c1a270bde3c8719dbda7c848005317594440bf615c886f2e17bd6b082d';
relay = (await deployContract(signers[0] as Wallet, RelayArtifact, [
Expand Down
8 changes: 4 additions & 4 deletions test/gas.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ethers} from '@nomiclabs/buidler';
import {ethers} from 'hardhat';
import {Signer, Wallet} from 'ethers';
import chai from 'chai';
import {deployContract, solidity} from 'ethereum-waffle';
import RelayArtifact from '../artifacts/Relay.json';
import RelayArtifact from '../artifacts/contracts/Relay.sol/Relay.json';
import {Relay} from '../typechain/Relay';

chai.use(solidity);
Expand All @@ -23,7 +23,7 @@ describe('Gas', () => {
'0x000000204615614beedb06491a82e78b38eb6650e29116cc9cce21000000000000000000b034884fc285ff1acc861af67be0d87f5a610daa459d75a58503a01febcc287a34c0615c886f2e17046e7325';

it('should cost less than amount', async () => {
signers = await ethers.signers();
signers = await ethers.getSigners();
relay = (await deployContract(signers[0] as Wallet, RelayArtifact, [
genesisHeader,
genesisHeight
Expand All @@ -32,7 +32,7 @@ describe('Gas', () => {
await relay.deployTransaction.wait(1)
).gasUsed?.toNumber();
// console.log(`Deploy: ${deployCost}`);
expect(deployCost).to.be.lt(2_000_000);
expect(deployCost).to.be.lt(3_000_000);

const result = await relay.submitBlockHeader(header1);
const updateCost = (await result.wait(1)).gasUsed?.toNumber();
Expand Down
6 changes: 3 additions & 3 deletions test/parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ethers} from '@nomiclabs/buidler';
import {ethers} from 'hardhat';
import {Signer, Wallet} from 'ethers';
import chai from 'chai';
import {deployContract, solidity} from 'ethereum-waffle';
import Artifact from '../artifacts/ParserDelegate.json';
import Artifact from '../artifacts/contracts/ParserDelegate.sol/ParserDelegate.json';
import {ParserDelegate} from '../typechain/ParserDelegate';

chai.use(solidity);
Expand All @@ -17,7 +17,7 @@ describe('Parser', () => {
let parser: ParserDelegate;

beforeEach(async () => {
signers = await ethers.signers();
signers = await ethers.getSigners();
parser = (await deployContract(
signers[0] as Wallet,
Artifact,
Expand Down
8 changes: 4 additions & 4 deletions test/proof.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {ethers} from '@nomiclabs/buidler';
import {ethers} from 'hardhat';
import {Signer} from 'ethers';
import chai from 'chai';
import {solidity} from 'ethereum-waffle';
import {Relay} from '../typechain/Relay';
import {RelayFactory} from '../typechain/RelayFactory';
import {ErrorCode} from './constants';
import {Arrayish} from 'ethers/utils';
import {BytesLike} from 'ethers';

chai.use(solidity);
const {expect} = chai;
Expand All @@ -17,7 +17,7 @@ async function getBestBlockHeight(relay: Relay): Promise<number> {

function deploy(
signer: Signer,
header: Arrayish,
header: BytesLike,
height: number
): Promise<Relay> {
const factory = new RelayFactory(signer);
Expand All @@ -33,7 +33,7 @@ describe('Proofs', () => {
'0x0000c020c238b601308b7297346ab2ed59942d7d7ecea8d23a1001000000000000000000b61ac92842abc82aa93644b190fc18ad46c6738337e78bc0c69ab21c5d5ee2ddd6376d5d3e211a17d8706a84';

beforeEach(async () => {
signers = await ethers.signers();
signers = await ethers.getSigners();
relay = await deploy(signers[0], genesisHeader, 5);
});

Expand Down
Loading

0 comments on commit 7c04f44

Please sign in to comment.