github.com/ava-labs/avalanchego@v1.11.11/vms/example/xsvm/tx/codec.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package tx
     5  
     6  import (
     7  	"errors"
     8  	"math"
     9  
    10  	"github.com/ava-labs/avalanchego/codec"
    11  	"github.com/ava-labs/avalanchego/codec/linearcodec"
    12  )
    13  
    14  const CodecVersion = 0
    15  
    16  var Codec codec.Manager
    17  
    18  func init() {
    19  	c := linearcodec.NewDefault()
    20  	Codec = codec.NewManager(math.MaxInt32)
    21  
    22  	err := errors.Join(
    23  		c.RegisterType(&Transfer{}),
    24  		c.RegisterType(&Export{}),
    25  		c.RegisterType(&Import{}),
    26  		Codec.RegisterCodec(CodecVersion, c),
    27  	)
    28  	if err != nil {
    29  		panic(err)
    30  	}
    31  }