-
Notifications
You must be signed in to change notification settings - Fork 651
/
static_client.go
44 lines (36 loc) · 1.11 KB
/
static_client.go
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
39
40
41
42
43
44
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package api
import (
"context"
"github.com/ava-labs/avalanchego/utils/rpc"
)
var _ StaticClient = (*staticClient)(nil)
// StaticClient for interacting with the platformvm static api
type StaticClient interface {
BuildGenesis(
ctx context.Context,
args *BuildGenesisArgs,
options ...rpc.Option,
) (*BuildGenesisReply, error)
}
// staticClient is an implementation of a platformvm client for interacting with
// the platformvm static api
type staticClient struct {
requester rpc.EndpointRequester
}
// NewClient returns a platformvm client for interacting with the platformvm static api
func NewStaticClient(uri string) StaticClient {
return &staticClient{requester: rpc.NewEndpointRequester(
uri + "/ext/vm/platform",
)}
}
func (c *staticClient) BuildGenesis(
ctx context.Context,
args *BuildGenesisArgs,
options ...rpc.Option,
) (resp *BuildGenesisReply, err error) {
resp = &BuildGenesisReply{}
err = c.requester.SendRequest(ctx, "platform.buildGenesis", args, resp, options...)
return resp, err
}