Skip to content

Commit 079b102

Browse files
committed
feat: added support for multiple chains
1 parent d67e039 commit 079b102

File tree

16 files changed

+1073
-65
lines changed

16 files changed

+1073
-65
lines changed

.eslintrc.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,14 @@
3434
"commonjs": true
3535
}
3636
]
37-
}
37+
},
38+
"overrides": [
39+
{
40+
"files": "*.json",
41+
"extends": "plugin:json/recommended",
42+
"plugins": [
43+
"json"
44+
]
45+
}
46+
]
3847
}

contracts/bin/flatten.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# npx hardhat flatten src/MerkleRedeem.sol 2> /dev/null | awk '/SPDX-License-Identifier/&&c++>0 {next} 1' | awk '/pragma experimental ABIEncoderV2;/&&c++>0 {next} 1'
3+
npx hardhat flatten src/MerkleRedeem.sol 2> /dev/null

contracts/deploy/01-merkleRedeem.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const paramsByChainId = {
55
1: {
66
pnkAddress: "0x93ED3FBe21207Ec2E8f2d3c3de6e058Cb73Bc04d",
77
},
8+
100: {
9+
pnkAddress: "0xcb3231aBA3b451343e0Fddfc45883c842f223846",
10+
},
811
};
912

1013
module.exports = async function deployMerkleRedeem({ deployments, getNamedAccounts, getChainId }) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
100

contracts/deployments/xdai/MerkleRedeem.json

Lines changed: 522 additions & 0 deletions
Large diffs are not rendered by default.

contracts/hardhat.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ module.exports = {
3434
mainnet: {
3535
chainId: 1,
3636
url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
37-
accounts: [process.env.MAINNET_DEPLOYER_PRIVATE_KEY],
37+
accounts: [process.env.PRODUCTION_DEPLOYER_PRIVATE_KEY],
38+
live: true,
39+
saveDeployments: true,
40+
tags: ["production"],
41+
},
42+
xdai: {
43+
chainId: 100,
44+
url: "https://rpc.xdaichain.com",
45+
accounts: [process.env.PRODUCTION_DEPLOYER_PRIVATE_KEY],
3846
live: true,
3947
saveDeployments: true,
4048
tags: ["production"],

contracts/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build": "hardhat compile",
1010
"deploy": "hardhat deploy",
1111
"deploy:kovan": "hardhat deploy --network kovan",
12-
"deploy:mainnet": "hardhat deploy --network mainnet"
12+
"deploy:mainnet": "hardhat deploy --network mainnet",
13+
"deploy:xdai": "hardhat deploy --network xdai"
1314
},
1415
"dependencies": {
1516
"@openzeppelin/contracts": "^3.4.0"
@@ -20,7 +21,7 @@
2021
"dotenv-safe": "^8.2.0",
2122
"ethereum-waffle": "^3.2.2",
2223
"ethers": "^5.0.29",
23-
"hardhat": "^2.0.9",
24+
"hardhat": "^2.6.2",
2425
"hardhat-deploy": "^0.7.0-beta.44",
2526
"hardhat-deploy-ethers": "^0.3.0-beta.7"
2627
}

snapshots/.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
PNK_DROP_CHAIN_ID='<number>'
22
PNK_DROP_KLEROS_LIQUID_ADDRESS='<address>'
3-
# Ideally the block which KlerosLiquid contract was deployed to
4-
PNK_DROP_FROM_BLOCK='<block number>'
53
PNK_DROP_AMOUNT='<amount of tokens to distibute>'
64
PNK_DROP_PERIOD='<number>'
5+
6+
# Either provide this
7+
PNK_DROP_JSON_RPC_URL='<string>'
8+
# Or these
79
PNK_DROP_INFURA_API_KEY='<API key>'
810
PNK_DROP_ETHERSCAN_API_KEY='<API key>'
911
PNK_DROP_ALCHEMY_API_KEY='<API key>'

snapshots/cli.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ dotenv.config();
1212

1313
dayjs.extend(utc);
1414

15-
const etherscanApiKey = process.env.PNK_DROP_ETHERSCAN_API_KEY;
16-
const alchemyApiKey = process.env.PNK_DROP_ALCHEMY_API_KEY;
17-
1815
const argv = yargs(hideBin(process.argv))
1916
.env("PNK_DROP")
2017
.strict(true)
@@ -59,6 +56,9 @@ const argv = yargs(hideBin(process.argv))
5956
.option("to-block", {
6057
description: "The block to end the query for events",
6158
})
59+
.option("json-rpc-url", {
60+
description: "The JSON RPC URL to connect to",
61+
})
6262
.option("infura-api-key", {
6363
description: "The Infura API key",
6464
})
@@ -76,7 +76,8 @@ const argv = yargs(hideBin(process.argv))
7676
})
7777
.demand(["kleros-liquid-address", "period", "amount", "chain-id", "start-date", "end-date"])
7878
.boolean(["save-s3", "save-local", "save-ipfs"])
79-
.string(["kleros-liquid-address", "infura-api-key", "etherscan-api-key", "alchemy-api-key"])
79+
.string(["kleros-liquid-address", "json-rpc-url", "infura-api-key", "etherscan-api-key", "alchemy-api-key"])
80+
.conflicts("json-rpc-url", ["infura-api-key", "etherscan-api-key", "alchemy-api-key"])
8081
.number(["chain-id", "from-block", "to-block", "period"])
8182
.coerce(["amount"], (value) => utils.parseEther(String(value)))
8283
.coerce(["start-date"], (value) => dayjs.utc(value).startOf("day"))
@@ -104,16 +105,21 @@ const {
104105
startDate,
105106
endDate,
106107
fromBlock,
108+
jsonRpcUrl,
107109
infuraApiKey,
110+
etherscanApiKey,
111+
alchemyApiKey,
108112
} = normalizeArgs(argv);
109113

110114
endDate.isBefore(startDate) && throwError(new Error("End date cannot be before start date"));
111115

112-
const provider = getDefaultProvider(chainId, {
113-
etherscan: etherscanApiKey,
114-
alchemy: alchemyApiKey,
115-
infura: infuraApiKey,
116-
});
116+
const provider = jsonRpcUrl
117+
? getDefaultProvider(jsonRpcUrl)
118+
: getDefaultProvider(chainId, {
119+
etherscan: etherscanApiKey,
120+
alchemy: alchemyApiKey,
121+
infura: infuraApiKey,
122+
});
117123

118124
(async () => {
119125
try {

snapshots/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"ramda": "^0.27.1",
2525
"yargs": "^16.2.0"
2626
},
27-
"devDependencies": {},
27+
"devDependencies": {
28+
"eslint-plugin-json": "^3.1.0"
29+
},
2830
"volta": {
2931
"node": "14.16.0"
3032
}

0 commit comments

Comments
 (0)