From a562d5948c810fc9f8e682a58f1c81fd9f726177 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 22 Aug 2023 15:06:39 +1000 Subject: [PATCH] RPC client: abft API wrapper --- ftmclient/abft_api.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ftmclient/abft_api.go diff --git a/ftmclient/abft_api.go b/ftmclient/abft_api.go new file mode 100644 index 000000000..173b40f82 --- /dev/null +++ b/ftmclient/abft_api.go @@ -0,0 +1,24 @@ +package ftmclient + +import ( + "context" + "math/big" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/common/hexutil" + + "github.com/Fantom-foundation/go-opera/inter" +) + +// GetValidators returns Lachesis event by hash or short ID. +func (ec *Client) GetValidators(ctx context.Context, epoch *big.Int) (inter.ValidatorProfiles, error) { + var raw map[hexutil.Uint64]interface{} + err := ec.c.CallContext(ctx, &raw, "abft_getValidators", toBlockNumArg(epoch)) + if err != nil { + return nil, err + } else if len(raw) == 0 { + return nil, ethereum.NotFound + } + + return inter.RPCUnmarshalValidators(raw) +}