Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Remove invalid networks check from Sourcify fetcher #6171

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/fetch-and-compile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export interface FetchAndCompileOptions {

### `getSupportedNetworks`

If you want a list of supported networks, you can call `getSupportedNetworks`:
If you want a (potentially partial) list of supported networks, you can call `getSupportedNetworks`:

```ts
import { getSupportedNetworks } from "@truffle/fetch-and-compile";
Expand All @@ -140,6 +140,8 @@ const networks = getSupportedNetworks();
// }
```

Note that there may be additional unlisted supported networks.

You can also pass in a list of fetchers if you want to restrict the output to the networks
supported by the fetchers you list. (You can also pass in a config and it will use the `sourceFetchers`
property if set, or a `FetchAndCompileOptions` and it will use the `fetch.precedence` field if set.)
Expand Down
10 changes: 3 additions & 7 deletions packages/source-fetcher/lib/sourcify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const debug = debugModule("source-fetcher:sourcify");

import type { Fetcher, FetcherConstructor } from "./types";
import type * as Types from "./types";
import { removeLibraries, InvalidNetworkError } from "./common";
import { removeLibraries } from "./common";
import { networkNamesById, networksByName } from "./networks";
import retry from "async-retry";

Expand Down Expand Up @@ -164,12 +164,8 @@ const SourcifyFetcher: FetcherConstructor = class SourcifyFetcher
constructor(networkId: number) {
this.networkId = networkId;
this.networkName = networkNamesById[networkId];
if (
this.networkName === undefined ||
!SourcifyFetcher.supportedNetworks.has(this.networkName)
) {
throw new InvalidNetworkError(networkId, "sourcify");
}
//we no longer check if the network is supported; the list is now only
//used for if you explicitly ask
}

static getSupportedNetworks(): Types.SupportedNetworks {
Expand Down