Skip to content

Commit

Permalink
use default network, if one we looked for is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Sep 12, 2024
1 parent a52c087 commit 13ade84
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions seth/client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func (c *ClientBuilder) UseNetworkWithName(name string) *ClientBuilder {
}
}

// if the network is not found, we will try to use the default network
for _, network := range c.config.Networks {
if network.Name == DefaultNetworkName {
c.config.Network = network
return c
}
}

c.errors = append(c.errors, fmt.Errorf("network with name '%s' not found", name))
return c
}
Expand All @@ -97,6 +105,14 @@ func (c *ClientBuilder) UseNetworkWithChainId(chainId uint64) *ClientBuilder {
}
}

// if the network is not found, we will try to use the default network
for _, network := range c.config.Networks {
if network.Name == DefaultNetworkName {
c.config.Network = network
return c
}
}

c.errors = append(c.errors, fmt.Errorf("network with chainId '%d' not found", chainId))
return c
}
Expand Down

0 comments on commit 13ade84

Please sign in to comment.