Skip to content

Commit

Permalink
chore(cli/lib): revert to await on chain function use (#994)
Browse files Browse the repository at this point in the history
Deprecate `CheckOnChain` and use noop logger for CLI call

task: none
  • Loading branch information
idea404 authored May 6, 2024
1 parent e420db4 commit 538bcaf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/devnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func loadDevnetNetwork(ctx context.Context) (netconf.Network, xchain.RPCEndpoint
return netconf.Network{}, nil, errors.Wrap(err, "make portal registry")
}

network, err := netconf.CheckOnChain(ctx, netID, portalReg, endpoints.Keys())
network, err := netconf.AwaitOnChain(log.WithNoopLogger(ctx), netID, portalReg, endpoints.Keys())
if err != nil {
return netconf.Network{}, nil, &cliError{
Msg: "failed to check on-chain registry",
Expand Down
18 changes: 0 additions & 18 deletions lib/netconf/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,6 @@ func AwaitOnChain(ctx context.Context, netID ID, portalRegistry *bindings.Portal
}
}

// CheckOnChain returns the network configuration if all expected chains are registered in the on-chain registry.
// It returns an error if the context is canceled or if any of the expected chains are missing.
func CheckOnChain(ctx context.Context, netID ID, portalRegistry *bindings.PortalRegistry, expected []string) (Network, error) {
portals, err := portalRegistry.List(&bind.CallOpts{Context: ctx})
if err != nil {
return Network{}, errors.Wrap(err, "failed fetching xchain registry from omni_evm")
}

network := networkFromPortals(netID, portals)
if !containsAll(network, expected) {
return Network{}, errors.New("xchain registry doesn't contain all expected chains")
}

log.Info(ctx, "XChain network configuration initialized from on-chain registry", "chains", network.ChainNamesByIDs())

return network, nil
}

// containsAll returns true if the network contains the all expected chains (by name or ID).
func containsAll(network Network, expected []string) bool {
want := make(map[string]struct{}, len(expected))
Expand Down

0 comments on commit 538bcaf

Please sign in to comment.