diff --git a/examples/morpheusvm/cmd/morpheusvm/version/version.go b/examples/morpheusvm/cmd/morpheusvm/version/version.go index 36020b2cd5..eab898ebd8 100644 --- a/examples/morpheusvm/cmd/morpheusvm/version/version.go +++ b/examples/morpheusvm/cmd/morpheusvm/version/version.go @@ -9,7 +9,6 @@ import ( "github.com/spf13/cobra" "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/version" ) func init() { @@ -27,6 +26,6 @@ func NewCommand() *cobra.Command { } func versionFunc(*cobra.Command, []string) error { - fmt.Printf("%s@%s (%s)\n", consts.Name, version.Version, consts.ID) + fmt.Printf("%s@%s (%s)\n", consts.Name, consts.Version, consts.ID) return nil } diff --git a/examples/morpheusvm/consts/consts.go b/examples/morpheusvm/consts/consts.go index 2b04afa517..f7d57f1c06 100644 --- a/examples/morpheusvm/consts/consts.go +++ b/examples/morpheusvm/consts/consts.go @@ -5,6 +5,10 @@ package consts import ( "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/version" + + "github.com/ava-labs/hypersdk/chain" + "github.com/ava-labs/hypersdk/codec" ) const ( @@ -25,3 +29,16 @@ func init() { } ID = vmID } + +// Instantiate registry here so it can be imported by any package. We set these +// values in [controller/registry]. +var ( + ActionRegistry *codec.TypeParser[chain.Action] + AuthRegistry *codec.TypeParser[chain.Auth] +) + +var Version = &version.Semantic{ + Major: 0, + Minor: 0, + Patch: 1, +} diff --git a/examples/morpheusvm/config/config.go b/examples/morpheusvm/controller/config.go similarity index 85% rename from examples/morpheusvm/config/config.go rename to examples/morpheusvm/controller/config.go index 775184f569..5a639745f9 100644 --- a/examples/morpheusvm/config/config.go +++ b/examples/morpheusvm/controller/config.go @@ -1,7 +1,7 @@ // Copyright (C) 2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package config +package controller import ( "encoding/json" @@ -11,7 +11,7 @@ type Config struct { StoreTransactions bool `json:"storeTransactions"` } -func New(b []byte) (*Config, error) { +func newConfig(b []byte) (*Config, error) { c := &Config{ StoreTransactions: true, } diff --git a/examples/morpheusvm/controller/controller.go b/examples/morpheusvm/controller/controller.go index 1bc55645b7..7a029d42df 100644 --- a/examples/morpheusvm/controller/controller.go +++ b/examples/morpheusvm/controller/controller.go @@ -15,13 +15,11 @@ import ( "github.com/ava-labs/hypersdk/auth" "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/examples/morpheusvm/config" "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" "github.com/ava-labs/hypersdk/examples/morpheusvm/registry" "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" - "github.com/ava-labs/hypersdk/examples/morpheusvm/version" "github.com/ava-labs/hypersdk/extension/indexer" "github.com/ava-labs/hypersdk/pebble" "github.com/ava-labs/hypersdk/vm" @@ -39,7 +37,7 @@ var ( func New(options ...vm.Option) (*vm.VM, error) { return vm.New( &factory{}, - version.Version, + consts.Version, registry.Action, registry.Auth, auth.Engines(), @@ -80,7 +78,7 @@ func (*factory) New( } // Load config and genesis - c.config, err = config.New(configBytes) + c.config, err = newConfig(configBytes) if err != nil { return nil, nil, nil, err } @@ -135,7 +133,7 @@ type Controller struct { chainID ids.ID genesis *genesis.Genesis - config *config.Config + config *Config stateManager *storage.StateManager metrics *metrics diff --git a/examples/morpheusvm/version/version.go b/examples/morpheusvm/version/version.go deleted file mode 100644 index 2a4e9c3d58..0000000000 --- a/examples/morpheusvm/version/version.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2023, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package version - -import "github.com/ava-labs/avalanchego/version" - -var Version = &version.Semantic{ - Major: 0, - Minor: 0, - Patch: 1, -}