Skip to content

Commit

Permalink
Check address is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
carletex committed Sep 13, 2022
1 parent e8d69e9 commit 5f0f9f5
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"body-parser": "^1.19.1",
"cors": "^2.8.5",
"dotenv": "^11.0.0",
"ethers": "^5.7.0",
"express": "^4.17.2",
"https": "^1.0.0",
"nodemon": "^2.0.15"
Expand Down
5 changes: 5 additions & 0 deletions utils/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { allowedNetworks, ETHERSCAN_API_KEY } = require("./config");
const fs = require("fs");
const util = require("util");
const { MESSAGES } = require("./messages");
const { ethers } = require("ethers");
const exec = util.promisify(require("child_process").exec);

let challenges = JSON.parse(fs.readFileSync("challenges.json").toString());
Expand Down Expand Up @@ -106,6 +107,10 @@ const testChallenge = async ({ challenge, network, address }) => {
};

const downloadAndTestContract = async (challengeId, network, address) => {
if (!ethers.utils.isAddress(address)) {
throw new Error(`${address} is not a valid address.`);
}

if (!challenges[challengeId]) {
throw new Error(`Challenge "${challengeId}" not found.`);
}
Expand Down
Loading

0 comments on commit 5f0f9f5

Please sign in to comment.