From 627bc7f7fd75d385e623c3c5177c5aeb639a0e52 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Sun, 29 Nov 2020 14:38:44 -0500 Subject: Address comments --- plugin/evm/static_service.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'plugin/evm/static_service.go') diff --git a/plugin/evm/static_service.go b/plugin/evm/static_service.go index 1b45939..7b0fa8b 100644 --- a/plugin/evm/static_service.go +++ b/plugin/evm/static_service.go @@ -7,15 +7,32 @@ import ( "context" "encoding/json" + "github.com/ava-labs/avalanchego/utils/formatting" "github.com/ava-labs/coreth/core" ) // StaticService defines the static API services exposed by the evm type StaticService struct{} +// BuildGenesisReply is the reply from BuildGenesis +type BuildGenesisReply struct { + Bytes string `json:"bytes"` + Encoding formatting.Encoding `json:"encoding"` +} + // BuildGenesis returns the UTXOs such that at least one address in [args.Addresses] is // referenced in the UTXO. -func (*StaticService) BuildGenesis(_ context.Context, args *core.Genesis) ([]byte, error) { +func (*StaticService) BuildGenesis(_ context.Context, args *core.Genesis) (*BuildGenesisReply, error) { bytes, err := json.Marshal(args) - return bytes, err + if err != nil { + return nil, err + } + bytesStr, err := formatting.Encode(formatting.Hex, bytes) + if err != nil { + return nil, err + } + return &BuildGenesisReply{ + Bytes: bytesStr, + Encoding: formatting.Hex, + }, nil } -- cgit v1.2.3