Skip to content

Commit

Permalink
Merge branch 'main' into refactor_registry_const
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz committed Aug 8, 2024
2 parents 0571af6 + f661b2b commit 0ae60a5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
3 changes: 1 addition & 2 deletions examples/morpheusvm/cmd/morpheusvm/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
}
17 changes: 17 additions & 0 deletions examples/morpheusvm/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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,
}
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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,
}
Expand Down
8 changes: 3 additions & 5 deletions examples/morpheusvm/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(),
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -135,7 +133,7 @@ type Controller struct {
chainID ids.ID

genesis *genesis.Genesis
config *config.Config
config *Config
stateManager *storage.StateManager

metrics *metrics
Expand Down
12 changes: 0 additions & 12 deletions examples/morpheusvm/version/version.go

This file was deleted.

0 comments on commit 0ae60a5

Please sign in to comment.