Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add dial constructors for all chainio structs #11

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 24 additions & 0 deletions chainio/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ func NewELChainReader(
}, nil
}

// Dial follows the geth constructor name convention, and is a low level contructor that
// builds a new ELChainReader from config values as opposed to other data types
func Dial(
rpcHttpUrl string,
rpcWsUrl string,
slasherAddr gethcommon.Address,
blsPubKeyCompendiumAddr gethcommon.Address,
logger logging.Logger,
) (*ELChainReader, error) {
ethHttpClient, err := eth.NewClient(rpcHttpUrl)
if err != nil {
panic(err)
}
ethWsClient, err := eth.NewClient(rpcWsUrl)
if err != nil {
panic(err)
}
elContractsClient, err := clients.NewELContractsChainClient(slasherAddr, blsPubKeyCompendiumAddr, ethHttpClient, ethWsClient, logger)
if err != nil {
panic(err)
}
return NewELChainReader(elContractsClient, logger, ethHttpClient)
}

func (r *ELChainReader) IsOperatorRegistered(ctx context.Context, operator types.Operator) (bool, error) {
isOperator, err := r.elContractsClient.IsOperator(
&bind.CallOpts{},
Expand Down
Loading