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