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

feat: add filecoin chains #2177

Merged
merged 4 commits into from
Feb 27, 2023
Merged
Changes from 2 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
23 changes: 18 additions & 5 deletions ethers-core/src/types/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ pub enum Chain {
Emerald = 42262,
EmeraldTestnet = 42261,

FilecoinMainnet = 314,
FilecoinHyperspaceTestnet = 3141,

Avalanche = 43114,
#[strum(serialize = "fuji", serialize = "avalanche-fuji")]
AvalancheFuji = 43113,
Expand Down Expand Up @@ -230,6 +233,7 @@ impl Chain {
Emerald => 6_000,
Dev | AnvilHardhat => 200,
Celo | CeloAlfajores | CeloBaklava => 5_000,
FilecoinHyperspaceTestnet | FilecoinMainnet => 30_000,
// Explictly handle all network to make it easier not to forget this match when new
// networks are added.
Morden | Ropsten | Rinkeby | Goerli | Kovan | XDai | Chiado | Sepolia | Moonbase |
Expand Down Expand Up @@ -299,6 +303,9 @@ impl Chain {
Chiado => {
("https://blockscout.chiadochain.net/api", "https://blockscout.chiadochain.net")
}
FilecoinHyperspaceTestnet => {
("https://api.hyperspace.node.glif.io/rpc/v1", "https://hyperspace.filfox.info")
}
Comment on lines +392 to +394
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these compatible with etherscan API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not

Copy link
Owner

@gakonst gakonst Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm then we cannot use them. We could make verification just not work on foundry but doubt we'll want to add special handling here

Where can we read more about the filecoin evm spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gakonst Here are some resources regarding docs/specs:

Sokol => ("https://blockscout.com/poa/sokol/api", "https://blockscout.com/poa/sokol"),
Poa => ("https://blockscout.com/poa/core/api", "https://blockscout.com/poa/core"),
Rsk => ("https://blockscout.com/rsk/mainnet/api", "https://blockscout.com/rsk/mainnet"),
Expand Down Expand Up @@ -328,7 +335,7 @@ impl Chain {
"https://testnet-explorer.canto.neobase.one/",
"https://testnet-explorer.canto.neobase.one/api",
),
AnvilHardhat | Dev | Morden | MoonbeamDev => {
AnvilHardhat | Dev | Morden | MoonbeamDev | FilecoinMainnet => {
// this is explicitly exhaustive so we don't forget to add new urls when adding a
// new chain
return None
Expand Down Expand Up @@ -364,14 +371,20 @@ impl Chain {
CeloBaklava => true,

// Known EIP-1559 chains
Mainnet | Goerli | Sepolia | Polygon | PolygonMumbai | Avalanche | AvalancheFuji => {
false
}
Mainnet |
Goerli |
Sepolia |
Polygon |
PolygonMumbai |
Avalanche |
AvalancheFuji |
FilecoinHyperspaceTestnet => false,

// Unknown / not applicable, default to false for backwards compatibility
Dev | AnvilHardhat | Morden | Ropsten | Rinkeby | Cronos | CronosTestnet | Kovan |
Sokol | Poa | XDai | Moonbeam | MoonbeamDev | Moonriver | Moonbase | Evmos |
EvmosTestnet | Chiado | Aurora | AuroraTestnet | Canto | CantoTestnet => false,
EvmosTestnet | Chiado | Aurora | AuroraTestnet | Canto | CantoTestnet |
FilecoinMainnet => false,
}
}
}
Expand Down