Skip to content

Commit

Permalink
More testnests support (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
rin-st authored Oct 16, 2024
1 parent 539078b commit 99bdaa3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ app.post("/challenges", withAddress, async (request, response) => {

const challengeIndex = getChallengeIndexFromChallengeId(challengeId);
const contractUrlObject = new URL(contractUrl);
const network = contractUrlObject.host.split(".")[0];
const blockExplorer = contractUrlObject.host;
const contractAddress = contractUrlObject.pathname.replace("/address/", "");

axios
.post(process.env.AUTOGRADING_SERVER, {
challenge: challengeIndex,
network,
blockExplorer,
address: contractAddress,
})
.then(async gradingResponse => {
Expand Down
7 changes: 4 additions & 3 deletions packages/react-app/src/helpers/strings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Update after merge.
export const ALLOWED_TESTNETS = ["rinkeby", "kovan", "ropsten", "goerli", "sepolia"];
export const VALID_BLOCK_EXPLORER_HOSTS = ["sepolia.etherscan.io", "sepolia-optimism.etherscan.io"];

export const ellipsizedAddress = longAddress =>
longAddress ? `${longAddress.slice(0, 6)}...${longAddress.slice(-4)}` : "";
Expand Down Expand Up @@ -31,8 +31,9 @@ export const isValidEtherscanTestnetUrl = urlText => {
return false;
}

const network = url.host.split(".")[0];
return network && ALLOWED_TESTNETS.includes(network);
const { host } = url;

return host && VALID_BLOCK_EXPLORER_HOSTS.includes(host);
};

export const isBoolean = val => typeof val === "boolean";

0 comments on commit 99bdaa3

Please sign in to comment.