Skip to content

Commit 185c365

Browse files
Merge pull request #14 from 0xJurassicPunk/husky-hooks
config: Adjusted husky hooks and eslint config
2 parents 185d9c3 + 65bf6d4 commit 185c365

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

.eslintrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@
66
"node": true
77
},
88
"plugins": ["@typescript-eslint"],
9-
"extends": ["standard", "plugin:prettier/recommended", "plugin:node/recommended"],
9+
"extends": [
10+
"standard",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:prettier/recommended",
13+
"plugin:node/recommended"
14+
],
1015
"parser": "@typescript-eslint/parser",
1116
"parserOptions": {
1217
"ecmaVersion": 12
1318
},
1419
"rules": {
1520
"node/no-unsupported-features/es-syntax": ["error", { "ignores": ["modules"] }]
21+
},
22+
"settings": {
23+
"node": {
24+
"tryExtensions": [".js", ".json", ".ts", ".d.ts"]
25+
}
1626
}
1727
}

.husky/commit-msg

Lines changed: 0 additions & 4 deletions
This file was deleted.

.husky/pre-commit

100644100755
File mode changed.

test/tradingRewardsDistributor.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ describe("TradingRewardsDistributor", () => {
2121
let admin: SignerWithAddress;
2222
let accounts: SignerWithAddress[];
2323

24-
let tree: any;
25-
let hexRoot: any;
24+
let tree: MerkleTree;
25+
let hexRoot: string;
2626

2727
beforeEach(async () => {
2828
accounts = await ethers.getSigners();
@@ -73,7 +73,7 @@ describe("TradingRewardsDistributor", () => {
7373
break;
7474
}
7575
// Compute the proof for the user
76-
const hexProof = tree.getHexProof(computeHash(user, value), index);
76+
const hexProof = tree.getHexProof(computeHash(user, value), Number(index));
7777

7878
// Verify leaf is matched in the tree with the computed root
7979
assert.isTrue(tree.verify(hexProof, computeHash(user, value), hexRoot));
@@ -130,7 +130,7 @@ describe("TradingRewardsDistributor", () => {
130130
}
131131

132132
// Compute the proof for the user
133-
const hexProof = tree.getHexProof(computeHash(user, value), index);
133+
const hexProof = tree.getHexProof(computeHash(user, value), Number(index));
134134

135135
// Verify leaf is matched in the tree with the computed root
136136
assert.isTrue(tree.verify(hexProof, computeHash(user, value), hexRoot));
@@ -164,12 +164,12 @@ describe("TradingRewardsDistributor", () => {
164164
const expectedAmountToReceive = parseEther("3000");
165165

166166
// Compute the proof for the user4
167-
const hexProof = tree.getHexProof(computeHash(lateClaimer.address, expectedAmountToReceive.toString()), "3");
167+
const hexProof = tree.getHexProof(computeHash(lateClaimer.address, expectedAmountToReceive.toString()), 2);
168168

169169
// Verify leaf is matched in the tree with the computed root
170-
assert.equal(
171-
tree.verify(hexProof, computeHash(lateClaimer.address, expectedAmountToReceive.toString()), hexRoot),
172-
true
170+
171+
assert.isTrue(
172+
tree.verify(hexProof, computeHash(lateClaimer.address, expectedAmountToReceive.toString()), hexRoot)
173173
);
174174

175175
tx = await tradingRewardsDistributor.connect(lateClaimer).claim(expectedAmountToReceive, hexProof);
@@ -205,8 +205,8 @@ describe("TradingRewardsDistributor", () => {
205205
const expectedAmountToReceiveForUser2 = parseEther("3000");
206206

207207
// Compute the proof for user1/user2
208-
const hexProof1 = tree.getHexProof(computeHash(user1.address, expectedAmountToReceiveForUser1.toString()), "0");
209-
const hexProof2 = tree.getHexProof(computeHash(user2.address, expectedAmountToReceiveForUser2.toString()), "1");
208+
const hexProof1 = tree.getHexProof(computeHash(user1.address, expectedAmountToReceiveForUser1.toString()), 0);
209+
const hexProof2 = tree.getHexProof(computeHash(user2.address, expectedAmountToReceiveForUser2.toString()), 1);
210210

211211
// Owner adds trading rewards and unpause distribution
212212
await tradingRewardsDistributor.connect(admin).updateTradingRewards(hexRoot, parseEther("5000"));
@@ -293,20 +293,18 @@ describe("TradingRewardsDistributor", () => {
293293
).to.be.revertedWith("Rewards: Invalid proof");
294294

295295
// 7. Non-eligible user cannot claim with proof/amount of user1
296-
assert.equal(
296+
assert.isFalse(
297297
tree.verify(
298298
hexProof2,
299299
computeHash(notEligibleUser.address, expectedAmountToReceiveForUser2.toString()),
300300
hexRoot
301-
),
302-
false
301+
)
303302
);
304303

305-
assert.equal(
304+
assert.isFalse(
306305
(
307306
await tradingRewardsDistributor.canClaim(notEligibleUser.address, expectedAmountToReceiveForUser2, hexProof2)
308-
)[0],
309-
false
307+
)[0]
310308
);
311309

312310
await expect(
@@ -337,7 +335,7 @@ describe("TradingRewardsDistributor", () => {
337335
const expectedAmountToReceiveForUser1 = parseEther("5000");
338336

339337
// Compute the proof for user1/user2
340-
const hexProof1 = tree.getHexProof(computeHash(user1.address, expectedAmountToReceiveForUser1.toString()), "0");
338+
const hexProof1 = tree.getHexProof(computeHash(user1.address, expectedAmountToReceiveForUser1.toString()), 0);
341339

342340
// Owner adds trading rewards and unpause distribution
343341
await tradingRewardsDistributor.connect(admin).updateTradingRewards(hexRoot, parseEther("4999.9999"));

0 commit comments

Comments
 (0)