Skip to content

Commit d1bd9d1

Browse files
committed
Merge branch 'dev' into feat(web)/notification-system
2 parents 657bb22 + 999377e commit d1bd9d1

File tree

188 files changed

+14605
-5087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+14605
-5087
lines changed

.github/workflows/codeql.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Harden Runner
41-
uses: step-security/harden-runner@128a63446a954579617e875aaab7d2978154e969 # v2.4.0
41+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
4242
with:
4343
egress-policy: audit
4444

@@ -47,7 +47,7 @@ jobs:
4747

4848
# Initializes the CodeQL tools for scanning.
4949
- name: Initialize CodeQL
50-
uses: github/codeql-action/init@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2.3.3
50+
uses: github/codeql-action/init@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
5151
with:
5252
languages: ${{ matrix.language }}
5353
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -61,7 +61,7 @@ jobs:
6161
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
6262
# If this step fails, then you should remove it and run the build manually (see below)
6363
- name: Autobuild
64-
uses: github/codeql-action/autobuild@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2.3.3
64+
uses: github/codeql-action/autobuild@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
6565

6666
# ℹ️ Command-line programs to run using the OS shell.
6767
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -74,6 +74,6 @@ jobs:
7474
# ./location_of_script_within_repo/buildscript.sh
7575

7676
- name: Perform CodeQL Analysis
77-
uses: github/codeql-action/analyze@29b1f65c5e92e24fe6b6647da1eaabe529cec70f # v2.3.3
77+
uses: github/codeql-action/analyze@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
7878
with:
7979
category: "/language:${{matrix.language}}"

.github/workflows/contracts-testing.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ on:
1515
pull_request:
1616
branches:
1717
- "*"
18-
paths-ignore:
19-
- "kleros-sdk/**"
20-
- "services/**"
21-
- "subgraph/**"
22-
- "web/**"
2318

2419
permissions: # added using https://github.com/step-security/secure-workflows
2520
contents: read
@@ -29,7 +24,7 @@ jobs:
2924
runs-on: ubuntu-latest
3025
steps:
3126
- name: Harden Runner
32-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.0
27+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
3328
with:
3429
disable-sudo: true
3530
egress-policy: block
@@ -52,7 +47,7 @@ jobs:
5247
- uses: actions/checkout@7739b9ba2efcda9dde65ad1e3c2dbe65b41dfba7
5348

5449
- name: Cache node modules
55-
uses: actions/cache@f7ebb81a3f195b4fb88dab7c14e2f7aff52045aa
50+
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
5651
env:
5752
cache-name: cache-node-modules
5853
with:

.github/workflows/dependabot-automerge.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Harden Runner
16-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.0
16+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
1717
with:
1818
disable-sudo: true
1919
egress-policy: block

.github/workflows/dependency-review.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Harden Runner
22-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
22+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
2323
with:
2424
disable-sudo: true
2525
egress-policy: block

.github/workflows/deploy-bots.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Harden Runner
11-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09
11+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423
1212
with:
1313
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
1414

1515
- uses: actions/checkout@7739b9ba2efcda9dde65ad1e3c2dbe65b41dfba7
16-
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
16+
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236
1717
- uses: aws-actions/setup-sam@12a6719db503425e98edcc798b6779590a450e8f
18-
- uses: aws-actions/configure-aws-credentials@131c7b6fd10c0d7f36e1e49650b241d91ee327b9
18+
- uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a
1919
with:
2020
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY }}
2121
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_KEY }}

.github/workflows/deploy-subgraph.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ jobs:
2626
environment: kleros-org-subgraph
2727
steps:
2828
- name: Harden Runner
29-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.0
29+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
3030
with:
3131
egress-policy: audit
3232

3333
- name: Checkout code
3434
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
3535

3636
- name: Set up Node.js
37-
uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2.5.2
37+
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
3838
with:
3939
node-version: 16
4040

.github/workflows/scorecards.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
steps:
3434
- name: Harden Runner
35-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.0
35+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
3636
with:
3737
disable-sudo: true
3838
egress-policy: block
@@ -56,7 +56,7 @@ jobs:
5656
persist-credentials: false
5757

5858
- name: "Run analysis"
59-
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0
59+
uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # v2.3.0
6060
with:
6161
results_file: results.sarif
6262
results_format: sarif
@@ -86,6 +86,6 @@ jobs:
8686

8787
# Upload the results to GitHub's code scanning dashboard.
8888
- name: "Upload to code-scanning"
89-
uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4
89+
uses: github/codeql-action/upload-sarif@2cb752a87e96af96708ab57187ab6372ee1973ab # v2.22.0
9090
with:
9191
sarif_file: results.sarif

.github/workflows/sentry-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
version: ${{ steps.set-version.outputs.version }}
1818
steps:
1919
- name: Harden Runner
20-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.0
20+
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.5.0
2121
with:
2222
disable-sudo: true
2323
egress-policy: block
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/checkout@7739b9ba2efcda9dde65ad1e3c2dbe65b41dfba7
3333

3434
- name: Cache node modules
35-
uses: actions/cache@f7ebb81a3f195b4fb88dab7c14e2f7aff52045aa
35+
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
3636
env:
3737
cache-name: cache-node-modules
3838
with:

contracts/README.md

+9-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
5353
- [ArbitrableExample](https://gnosis-chiado.blockscout.com/address/0xB56A23b396E0eae85414Ce5815da448ba529Cb4A)
5454
- [DisputeResolver](https://gnosis-chiado.blockscout.com/address/0x16f20604a51Ac1e68c9aAd1C0E53e951B62CC1Cb)
5555
- [DisputeTemplateRegistry](https://gnosis-chiado.blockscout.com/address/0x96E49552669ea81B8E9cE8694F7E4A55D8bFb957)
56-
- [ForeignGatewayOnGnosis](https://gnosis-chiado.blockscout.com/address/0x83F393F2aE68FA6A6701D7c65CBbFf3225f3fDf9)
56+
- [ForeignGatewayOnGnosis: proxy](https://gnosis-chiado.blockscout.com/address/0x078dAd05373d19d7fd6829735b765F12242a4300), [implementation](https://gnosis-chiado.blockscout.com/address/0xA4096fDA5291D5bbDD5Ed0D6CF2AF98229168Ace)
5757
- [WETH](https://gnosis-chiado.blockscout.com/address/0x2DFC9c3141268e6eac04a7D6d98Fbf64BDe836a8)
5858
- [WETHFaucet](https://gnosis-chiado.blockscout.com/address/0x22CB016c4b57413ca4DF5F1AC44a0E0d3c69811F)
5959
- [WPNKFaucet](https://gnosis-chiado.blockscout.com/address/0x5898aeE045A25B276369914c3448B72a41758B2c)
@@ -66,19 +66,18 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
6666
#### Arbitrum Goerli
6767

6868
- [PNK](https://goerli.arbiscan.io/token/0x3483FA1b87792cd5BE4100822C4eCEC8D3E531ee)
69-
- [ArbitrableExample](https://goerli.arbiscan.io/address/0x9B958EBe8057DCe5b9c1a30c935b790826bb511e)
69+
- [ArbitrableExample](https://goerli.arbiscan.io/address/0x5d96ede4D4Dd4c245d6879A4D790fF0AB1F476cC)
7070
- [DAI](https://goerli.arbiscan.io/address/0xB755843e26F2cD1c6A46659cEBb67CcFAE0f2EeE)
7171
- [DAIFaucet](https://goerli.arbiscan.io/address/0xCEBF1e0A5921767dd97b999ed14801A3770afAfd)
72-
- [DisputeKitClassic](https://goerli.arbiscan.io/address/0x89807AeD661954080dB0ca7e8AcA72Af96E344e5)
73-
- [DisputeResolver](https://goerli.arbiscan.io/address/0x36DabdE2b4Fe2C50775835B703687193D09DF8E0)
74-
- [DisputeTemplateRegistry](https://goerli.arbiscan.io/address/0xB01eC32bB0ba461ebEA9A61A6172Aba0DDE2B640)
75-
- [HomeGatewayToGnosis](https://goerli.arbiscan.io/address/0x12633ad7bd757858ada24738a94aeeba08727f1b)
76-
- [KlerosCore](https://goerli.arbiscan.io/address/0x5a2bC1477ABE705dB4955Cda7DE064eA79D563d1)
72+
- [DisputeKitClassic: proxy](https://goerli.arbiscan.io/address/0x6394A70cADD1376FdE5C38bA331761256DDd03E2), [implementation](https://goerli.arbiscan.io/address/0x9755b94c2c8AB04dDc7d102A6F8c974f538481fb)
73+
- [DisputeResolver](https://goerli.arbiscan.io/address/0xE4af4D800Ce12149199FA6f8870cD650cD8f3164)
74+
- [DisputeTemplateRegistry: proxy](https://goerli.arbiscan.io/address/0xBf5AF2c2938B3EE689d9A4f5324F144d9a617a2A), [implementation](https://goerli.arbiscan.io/address/0x93bf43132b6805E215d3c8305232ec3A174Ef146)
75+
- [KlerosCore: proxy](https://goerli.arbiscan.io/address/0x813DCc76dbA91DD9f6bDD038aea0877FC95656bE), [implementation](https://goerli.arbiscan.io/address/0xEE08d6427F4f23E602C4114B8F2B7f6d6D3F4206)
7776
- [PNKFaucet](https://goerli.arbiscan.io/address/0x05648Ee14941630a649082e0dA5cb80D29cC9002)
7877
- [PinakionV2](https://goerli.arbiscan.io/address/0x3483FA1b87792cd5BE4100822C4eCEC8D3E531ee)
79-
- [PolicyRegistry](https://goerli.arbiscan.io/address/0xa3556bF00c4f9ea235D6D4Bcb1B1c32121C0e935)
80-
- [RandomizerRNG](https://goerli.arbiscan.io/address/0x0FE3869EA01Febb895Bc76DaB143858F84C67024)
81-
- [SortitionModule](https://goerli.arbiscan.io/address/0xc3A8621DA59B35dDCD3e01504F182D9AC9F36b5B)
78+
- [PolicyRegistry: proxy](https://goerli.arbiscan.io/address/0x0d7EeA661C1f9cB1AD389c9Df90B3beDE86a1529), [implementation](https://goerli.arbiscan.io/address/0xF9128Ae440A9d4BABc6B66f9385C5Ba6ADf11D89)
79+
- [RandomizerRNG: proxy](https://goerli.arbiscan.io/address/0xF67D956988cb11449db7aeA80E6339b95b160593), [implementation](https://goerli.arbiscan.io/address/0xc1C85d303B4995Cb543C2b449C1b3dF490d49ebE)
80+
- [SortitionModule: proxy](https://goerli.arbiscan.io/address/0xA7e5D4C3E6C593cF6A367C3A415BB8E4A065E62E), [implementation](https://goerli.arbiscan.io/address/0xA472Dfb104696E5CE82E46148c33Cd5FeE2C3b7d)
8281
- [WETH](https://goerli.arbiscan.io/address/0xbB5839497dE7e6d4ddaFde093F69abA9be782E07)
8382
- [WETHFaucet](https://goerli.arbiscan.io/address/0xD2d862B060986b25996aaeDB54813002AB791013)
8483

contracts/deploy/00-ethereum-pnk.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import disputeTemplate from "../test/fixtures/DisputeTemplate.simple.json";
4+
import { isSkipped } from "./utils";
45

56
enum Chains {
67
GOERLI = 5,
@@ -24,9 +25,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2425
};
2526

2627
deployArbitration.tags = ["Pinakion"];
27-
deployArbitration.skip = async ({ getChainId }) => {
28-
const chainId = Number(await getChainId());
29-
return !Chains[chainId];
28+
deployArbitration.skip = async ({ network }) => {
29+
return isSkipped(network, !Chains[network.config.chainId ?? 0]);
3030
};
3131

3232
export default deployArbitration;

contracts/deploy/00-home-chain-arbitrable.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import disputeTemplate from "../test/fixtures/DisputeTemplate.simple.json";
4-
5-
enum HomeChains {
6-
ARBITRUM_ONE = 42161,
7-
ARBITRUM_GOERLI = 421613,
8-
HARDHAT = 31337,
9-
}
4+
import { HomeChains, isSkipped } from "./utils";
5+
import { deployUpgradable } from "./utils/deployUpgradable";
106

117
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
128
const { deployments, getNamedAccounts, getChainId } = hre;
@@ -22,9 +18,9 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2218
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
2319
const weth = await deployments.get("WETH");
2420

25-
const disputeTemplateRegistry = await deploy("DisputeTemplateRegistry", {
21+
const disputeTemplateRegistry = await deployUpgradable(hre, "DisputeTemplateRegistry", {
2622
from: deployer,
27-
args: [],
23+
args: [deployer],
2824
log: true,
2925
});
3026

@@ -50,9 +46,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5046

5147
deployArbitration.tags = ["HomeArbitrable"];
5248
deployArbitration.dependencies = ["Arbitration"];
53-
deployArbitration.skip = async ({ getChainId }) => {
54-
const chainId = Number(await getChainId());
55-
return !HomeChains[chainId];
49+
deployArbitration.skip = async ({ network }) => {
50+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
5651
};
5752

5853
export default deployArbitration;

contracts/deploy/00-home-chain-arbitration.ts

+38-39
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import { BigNumber } from "ethers";
4-
import getContractAddress from "../deploy-helpers/getContractAddress";
5-
6-
enum HomeChains {
7-
ARBITRUM_ONE = 42161,
8-
ARBITRUM_GOERLI = 421613,
9-
HARDHAT = 31337,
10-
}
4+
import getContractAddress from "./utils/getContractAddress";
5+
import { deployUpgradable } from "./utils/deployUpgradable";
6+
import { HomeChains, isSkipped } from "./utils";
117

128
const pnkByChain = new Map<HomeChains, string>([
139
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
@@ -56,43 +52,44 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5652
randomizerByChain.set(HomeChains[HomeChains[chainId]], randomizerMock.address);
5753
}
5854

59-
await deploy("PolicyRegistry", {
60-
from: deployer,
61-
args: [deployer],
62-
log: true,
63-
});
55+
await deployUpgradable(hre, "PolicyRegistry", { from: deployer, args: [deployer], log: true });
6456

6557
const randomizer = randomizerByChain.get(Number(await getChainId())) ?? AddressZero;
66-
const rng = await deploy("RandomizerRNG", {
67-
skipIfAlreadyDeployed: true,
68-
from: deployer,
69-
args: [randomizer, deployer],
70-
log: true,
71-
});
58+
const rng = await deployUpgradable(hre, "RandomizerRNG", { from: deployer, args: [randomizer, deployer], log: true });
7259

73-
const disputeKit = await deploy("DisputeKitClassic", {
60+
const disputeKit = await deployUpgradable(hre, "DisputeKitClassic", {
7461
from: deployer,
7562
args: [deployer, AddressZero],
7663
log: true,
7764
});
7865

79-
const nonce = await ethers.provider.getTransactionCount(deployer);
80-
const KlerosCoreAddress = getContractAddress(deployer, nonce + 1);
81-
console.log("calculated future KlerosCore address for nonce %d: %s", nonce, KlerosCoreAddress);
66+
let klerosCoreAddress = await deployments.getOrNull("KlerosCore").then((deployment) => deployment?.address);
67+
if (!klerosCoreAddress) {
68+
const nonce = await ethers.provider.getTransactionCount(deployer);
69+
klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
70+
console.log("calculated future KlerosCore address for nonce %d: %s", nonce + 3, klerosCoreAddress);
71+
}
8272

83-
const sortitionModule = await deploy("SortitionModule", {
73+
const sortitionModule = await deployUpgradable(hre, "SortitionModule", {
8474
from: deployer,
85-
args: [deployer, KlerosCoreAddress, 1800, 1800, rng.address, RNG_LOOKAHEAD], // minStakingTime, maxFreezingTime
75+
args: [
76+
deployer,
77+
klerosCoreAddress,
78+
1800, // minStakingTime
79+
1800, // maxFreezingTime
80+
rng.address,
81+
RNG_LOOKAHEAD,
82+
],
8683
log: true,
87-
});
84+
}); // nonce (implementation), nonce+1 (proxy)
8885

8986
const pnk = pnkByChain.get(chainId) ?? AddressZero;
9087
const dai = daiByChain.get(chainId) ?? AddressZero;
9188
const weth = wethByChain.get(chainId) ?? AddressZero;
9289
const minStake = BigNumber.from(10).pow(20).mul(2);
9390
const alpha = 10000;
9491
const feeForJuror = BigNumber.from(10).pow(17);
95-
const klerosCore = await deploy("KlerosCore", {
92+
const klerosCore = await deployUpgradable(hre, "KlerosCore", {
9693
from: deployer,
9794
args: [
9895
deployer,
@@ -106,7 +103,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
106103
sortitionModule.address,
107104
],
108105
log: true,
109-
});
106+
}); // nonce+2 (implementation), nonce+3 (proxy)
110107

111108
// execute DisputeKitClassic.changeCore() only if necessary
112109
const currentCore = await hre.ethers.getContractAt("DisputeKitClassic", disputeKit.address).then((dk) => dk.core());
@@ -124,12 +121,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
124121
};
125122

126123
deployArbitration.tags = ["Arbitration"];
127-
deployArbitration.skip = async ({ getChainId }) => {
128-
const chainId = Number(await getChainId());
129-
return !HomeChains[chainId];
124+
deployArbitration.skip = async ({ network }) => {
125+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
130126
};
131127

132-
const deployERC20AndFaucet = async (hre: HardhatRuntimeEnvironment, deployer: string, ticker: string) => {
128+
const deployERC20AndFaucet = async (
129+
hre: HardhatRuntimeEnvironment,
130+
deployer: string,
131+
ticker: string
132+
): Promise<string> => {
133133
const { deploy } = hre.deployments;
134134
const erc20 = await deploy(ticker, {
135135
from: deployer,
@@ -143,15 +143,14 @@ const deployERC20AndFaucet = async (hre: HardhatRuntimeEnvironment, deployer: st
143143
args: [erc20.address],
144144
log: true,
145145
});
146-
const funding = hre.ethers.utils.parseUnits("100000", "ether");
146+
const funding = hre.ethers.utils.parseUnits("100000");
147147
const erc20Instance = await hre.ethers.getContract(ticker);
148-
// TODO: skip if already funded
149-
await erc20Instance.balanceOf(deployer).then((balance) => {
150-
if (balance.gte(funding)) {
151-
console.log("Funding %sFaucet with %d", ticker, funding);
152-
return erc20Instance.transfer(faucet.address, funding);
153-
}
154-
});
148+
const faucetBalance = await erc20Instance.balanceOf(faucet.address);
149+
const deployerBalance = await erc20Instance.balanceOf(deployer);
150+
if (deployerBalance.gte(funding) && faucetBalance.isZero()) {
151+
console.log("Funding %sFaucet with %d", ticker, funding);
152+
await erc20Instance.transfer(faucet.address, funding);
153+
}
155154
return erc20.address;
156155
};
157156

0 commit comments

Comments
 (0)