diff --git a/ftmclient/abft_api.go b/ftmclient/abft_api.go index 173b40f82..e23a7a147 100644 --- a/ftmclient/abft_api.go +++ b/ftmclient/abft_api.go @@ -4,6 +4,7 @@ import ( "context" "math/big" + "github.com/Fantom-foundation/lachesis-base/inter/idx" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common/hexutil" @@ -11,9 +12,9 @@ import ( ) // GetValidators returns Lachesis event by hash or short ID. -func (ec *Client) GetValidators(ctx context.Context, epoch *big.Int) (inter.ValidatorProfiles, error) { +func (ec *Client) GetValidators(ctx context.Context, epoch idx.Epoch) (inter.ValidatorProfiles, error) { var raw map[hexutil.Uint64]interface{} - err := ec.c.CallContext(ctx, &raw, "abft_getValidators", toBlockNumArg(epoch)) + err := ec.c.CallContext(ctx, &raw, "abft_getValidators", toBlockNumArg(big.NewInt(int64(epoch)))) if err != nil { return nil, err } else if len(raw) == 0 { diff --git a/ftmclient/ftm_api.go b/ftmclient/ftm_api.go new file mode 100644 index 000000000..18bfdf484 --- /dev/null +++ b/ftmclient/ftm_api.go @@ -0,0 +1,17 @@ +package ftmclient + +import ( + "context" + "math/big" + + "github.com/Fantom-foundation/lachesis-base/inter/idx" + "github.com/ethereum/go-ethereum/common/hexutil" +) + +// GetEpochBlock returns block height in a beginning of an epoch. +func (ec *Client) GetEpochBlock(ctx context.Context, epoch idx.Epoch) (idx.Block, error) { + var raw hexutil.Uint64 + err := ec.c.CallContext(ctx, &raw, "ftm_getEpochBlock", toBlockNumArg(big.NewInt(int64(epoch)))) + + return idx.Block(raw), err +}