Skip to content

Commit

Permalink
Merge branch 'add-chain-1149' of https://github.com/symplexialabs/Sou…
Browse files Browse the repository at this point in the history
…rcify into add-chain-1149
  • Loading branch information
Symplexia Labs committed Apr 28, 2023
2 parents cd2df6f + 024be67 commit ea16479
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
13 changes: 8 additions & 5 deletions src/server/controllers/VerificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ import {
NotFoundError,
ValidationError,
} from "../../common/errors";
import { checkChainId, sourcifyChainsMap } from "../../sourcify-chains";
import {
checkSupportedChainId,
sourcifyChainsMap,
} from "../../sourcify-chains";
import config from "../../config";
import { StatusCodes } from "http-status-codes";
import RepositoryService from "../services/RepositoryService";
Expand Down Expand Up @@ -662,7 +665,7 @@ export default class VerificationController
body("chain")
.exists()
.bail()
.custom((chain, { req }) => (req.chain = checkChainId(chain))),
.custom((chain, { req }) => (req.chain = checkSupportedChainId(chain))),
/* body("contextVariables.msgSender").optional(),
body("contextVariables.abiEncodedConstructorArguments").optional(), */
// Handle non-json multipart/form-data requests.
Expand Down Expand Up @@ -702,7 +705,7 @@ export default class VerificationController
body("chain")
.exists()
.bail()
.custom((chain, { req }) => (req.chain = checkChainId(chain))),
.custom((chain, { req }) => (req.chain = checkSupportedChainId(chain))),
body("compilerVersion").exists().bail(),
body("contractName").exists().bail(),
// body("contextVariables.msgSender").optional(),
Expand Down Expand Up @@ -787,7 +790,7 @@ export default class VerificationController
body("chain")
.exists()
.bail()
.custom((chain) => checkChainId(chain)),
.custom((chain) => checkSupportedChainId(chain)),
this.safeHandler(this.verifyFromEtherscan)
);

Expand All @@ -809,7 +812,7 @@ export default class VerificationController
body("chainId")
.exists()
.bail()
.custom((chainId) => checkChainId(chainId)),
.custom((chainId) => checkSupportedChainId(chainId)),
this.safeHandler(this.sessionVerifyFromEtherscan)
);

Expand Down
7 changes: 1 addition & 6 deletions src/sourcify-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,7 @@ export function checkSupportedChainId(chain: string): string {
* Note that there might be chains not supported for verification anymore but still exist as a SourcifyChain e.g. Ropsten.
*/
export function checkChainId(chain: string): string {
if (
// if chain is not in sourcify-chains.ts
!(chain in sourcifyChainsMap && sourcifyChainsMap[chain]) ||
// or if chain is not supported
sourcifyChainsMap[chain].supported === false
) {
if (!(chain in sourcifyChainsMap && sourcifyChainsMap[chain])) {
throw new Error(`Chain ${chain} not supported!`);
}

Expand Down
4 changes: 2 additions & 2 deletions test/etherscan.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("Import From Etherscan and Verify", function () {
err,
res,
"chain",
`Chain ${unsupportedChain} not supported!`
`Chain ${unsupportedChain} not supported for verification!`
);
done();
});
Expand Down Expand Up @@ -273,7 +273,7 @@ describe("Import From Etherscan and Verify", function () {
err,
res,
"chainId",
`Chain ${unsupportedChain} not supported!`
`Chain ${unsupportedChain} not supported for verification!`
);
done();
});
Expand Down
9 changes: 8 additions & 1 deletion ui/src/pages/Lookup/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,14 @@ const Found = ({ response }: FoundProp) => {
>
{isCreate2Verified && <>create2</>} verified
<HiOutlineInformationCircle className="inline text-gray-600 text-lg" />
</span>{" "}
</span>
,{" "}
<a
className="underline"
href={generateUrl(URL_TYPE.REPO, "0", response?.address, "perfect")}
>
view in Sourcify Repository
</a>
</p>
{isCreate2Verified && Create2Info(response)}
<p>{chains.length > 0 && <span>on the following networks:</span>}</p>
Expand Down

0 comments on commit ea16479

Please sign in to comment.