aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/static_service.go
blob: 7b0fa8bde5d349796521a5070f7d3ce97cb0ba26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package evm

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) (*BuildGenesisReply, error) {
	bytes, err := json.Marshal(args)
	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
}