Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit db1c1c6

Browse files
committed
Hardhat WIP
1 parent 566e0f6 commit db1c1c6

9 files changed

+1559
-8024
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ chains/dev/*
4444
*.gateway_history
4545

4646
# Backups
47-
*.bak
47+
*.bak
48+
49+
ethereum/artifacts
50+
ethereum/cache

ethereum/hardhat.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require('@nomiclabs/hardhat-ethers');
2+
3+
/**
4+
* @type import('hardhat/config').HardhatUserConfig
5+
*/
6+
module.exports = {
7+
solidity: "0.8.1",
8+
};

ethereum/jest.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ module.exports = {
141141
// testLocationInResults: false,
142142

143143
// The glob patterns Jest uses to detect test files
144-
// testMatch: [
145-
// "**/__tests__/**/*.[jt]s?(x)",
146-
// "**/?(*.)+(spec|test).[tj]s?(x)"
147-
// ],
144+
testMatch: [
145+
"**/tests/**/*test.[jt]s?(x)",
146+
"**/?(*.)+(spec|test).[tj]s?(x)"
147+
],
148148

149149
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
150150
// testPathIgnorePatterns: [

ethereum/package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@
33
"version": "1.0.0",
44
"main": "index.js",
55
"license": "GPL-3.0",
6-
"dependencies": {
7-
"@ethersproject/wallet": "^5.0.9",
8-
"eth-saddle": "^0.1.23"
9-
},
6+
"dependencies": {},
107
"scripts": {
11-
"postinstall": "cd node_modules/solidity-parser-antlr && yarn install && yarn build",
128
"compile": "npx saddle compile",
139
"test": "npx saddle compile && npx saddle test",
1410
"coverage": "npx saddle compile --trace && npx saddle coverage && npx istanbul report --root=./coverage lcov json",
1511
"console": "NODE_OPTIONS='--experimental-repl-await' npx saddle console",
1612
"script": "npx saddle script"
1713
},
18-
"resolutions": {
19-
"solidity-parser-antlr": "https://github.com/solidity-parser/parser.git",
20-
"ganache-core": "=2.13.2"
21-
},
2214
"devDependencies": {
15+
"@ethersproject/wallet": "^5.1.0",
16+
"@nomiclabs/hardhat-ethers": "^2.0.2",
17+
"bignumber.js": "^9.0.1",
18+
"chai": "^4.3.4",
2319
"chalk": "^4.1.0",
24-
"istanbul": "^0.4.5"
20+
"ethers": "^5.1.0",
21+
"hardhat": "^2.1.2",
22+
"web3-eth-abi": "^1.3.5",
23+
"web3-utils": "^1.3.5"
2524
}
2625
}

ethereum/tests/cash_token_test.js ethereum/test/cash_token_test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
const { expect } = require("chai");
12
const {
23
e18,
34
fromNow,
45
sendRPC,
56
ETH_ZERO_ADDRESS
67
} = require('./utils');
78

8-
describe('CashToken', () => {
9+
describe.skip('CashToken', () => {
910
let proxyAdmin;
1011
let cashImpl;
1112
let proxy;
1213
let cash;
13-
let [root, admin, account1, account2, account3] = saddle.accounts;
14+
let root, admin, account1, account2, account3;
1415

1516
let startCashIndex = e18(1);
1617
let start = fromNow(0);
@@ -26,6 +27,7 @@ describe('CashToken', () => {
2627
}
2728

2829
beforeEach(async () => {
30+
[root, admin, account1, account2, account3] = await ethers.getSigners();
2931
proxyAdmin = await deploy('ProxyAdmin', [], { from: root });
3032
cashImpl = await deploy('CashToken', [admin], { from: root });
3133
proxy = await deploy('TransparentUpgradeableProxy', [

ethereum/tests/matchers_ext.js ethereum/test/matchers_ext.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1+
const chai = require("chai");
12
const BigNumber = require("bignumber.js");
23

3-
expect.extend({
4+
function extend(object) {
5+
Object.entries(object).forEach(([name, matcher]) => {
6+
function wrap(fn) {
7+
return function (right) {
8+
var left = this._obj;
9+
let res = fn(left, right);
10+
if (res.pass) {
11+
return new chai.Assertion(true).to.be.equal(true);
12+
} else {
13+
return new chai.Assertion("").to.be.equal(res.message);
14+
}
15+
}
16+
}
17+
console.log("Extending", name);
18+
chai.Assertion.addMethod(name, wrap(matcher));
19+
});
20+
}
21+
22+
extend({
423
toMatchAddress(actual, expected) {
24+
actual = actual.hasOwnProperty('address') ? actual.address : actual;
25+
expected = expected.hasOwnProperty('address') ? expected.address : expected;
26+
527
return {
628
pass: actual.toLowerCase() == expected.toLowerCase(),
729
message: () => `expected (${actual}) == (${expected})`
@@ -16,7 +38,7 @@ expect.extend({
1638
}
1739
});
1840

19-
expect.extend({
41+
extend({
2042
greaterThan(actual, expected) {
2143
return {
2244
pass: (new BigNumber(actual)).gt(new BigNumber(expected)),
@@ -25,7 +47,7 @@ expect.extend({
2547
}
2648
});
2749

28-
expect.extend({
50+
extend({
2951
toRevert(actual, msg='revert') {
3052
return {
3153
pass: !!actual['message'] && actual.message === `VM Exception while processing transaction: ${msg}`,
@@ -34,7 +56,7 @@ expect.extend({
3456
}
3557
});
3658

37-
expect.extend({
59+
extend({
3860
toBeWithinRange(received, floor, ceiling) {
3961
const pass = received >= floor && received <= ceiling;
4062
if (pass) {

0 commit comments

Comments
 (0)