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

Commit

Permalink
Merge pull request #6171 from trufflesuite/open-ended
Browse files Browse the repository at this point in the history
Remove invalid networks check from Sourcify fetcher
  • Loading branch information
haltman-at authored Aug 28, 2023
2 parents cc26d74 + 0a2d081 commit 3a7b057
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
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

0 comments on commit 3a7b057

Please sign in to comment.