-
Notifications
You must be signed in to change notification settings - Fork 118
/
vm.go
58 lines (52 loc) · 1.5 KB
/
vm.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package defaultvm
import (
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/hypersdk/api/indexer"
"github.com/ava-labs/hypersdk/api/jsonrpc"
"github.com/ava-labs/hypersdk/api/ws"
"github.com/ava-labs/hypersdk/chain"
"github.com/ava-labs/hypersdk/codec"
"github.com/ava-labs/hypersdk/extension/externalsubscriber"
"github.com/ava-labs/hypersdk/genesis"
"github.com/ava-labs/hypersdk/vm"
staterpc "github.com/ava-labs/hypersdk/api/state"
)
// DefaultOptions provides the default set of options to include
// when constructing a new VM including the indexer, websocket,
// JSONRPC, and external subscriber options.
func NewDefaultOptions() []vm.Option {
return []vm.Option{
indexer.With(),
ws.With(),
jsonrpc.With(),
externalsubscriber.With(),
staterpc.With(),
}
}
// New returns a VM with DefaultOptions pre-supplied
func New(
v *version.Semantic,
genesisFactory genesis.GenesisAndRuleFactory,
balanceHandler chain.BalanceHandler,
metadataManager chain.MetadataManager,
actionCodec *codec.TypeParser[chain.Action],
authCodec *codec.TypeParser[chain.Auth],
outputCodec *codec.TypeParser[codec.Typed],
authEngine map[uint8]vm.AuthEngine,
options ...vm.Option,
) (*vm.VM, error) {
options = append(options, NewDefaultOptions()...)
return vm.New(
v,
genesisFactory,
balanceHandler,
metadataManager,
actionCodec,
authCodec,
outputCodec,
authEngine,
options...,
)
}