-
Notifications
You must be signed in to change notification settings - Fork 646
/
codec.go
63 lines (55 loc) · 1.75 KB
/
codec.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
59
60
61
62
63
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package x
import (
"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/ava-labs/avalanchego/vms/avm"
"github.com/ava-labs/avalanchego/vms/nftfx"
"github.com/ava-labs/avalanchego/vms/propertyfx"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
)
const (
// CodecVersion is the current default codec version
CodecVersion = 0
// TODO: verify that these are correct
SECP256K1FxIndex = 0
NFTFxIndex = 1
PropertyFxIndex = 2
)
// Codecs do serialization and deserialization
var (
Codec codec.Manager
)
func init() {
c := linearcodec.NewDefault()
Codec = codec.NewDefaultManager()
errs := wrappers.Errs{}
errs.Add(
c.RegisterType(&avm.BaseTx{}),
c.RegisterType(&avm.CreateAssetTx{}),
c.RegisterType(&avm.OperationTx{}),
c.RegisterType(&avm.ImportTx{}),
c.RegisterType(&avm.ExportTx{}),
c.RegisterType(&secp256k1fx.TransferInput{}),
c.RegisterType(&secp256k1fx.MintOutput{}),
c.RegisterType(&secp256k1fx.TransferOutput{}),
c.RegisterType(&secp256k1fx.MintOperation{}),
c.RegisterType(&secp256k1fx.Credential{}),
c.RegisterType(&nftfx.MintOutput{}),
c.RegisterType(&nftfx.TransferOutput{}),
c.RegisterType(&nftfx.MintOperation{}),
c.RegisterType(&nftfx.TransferOperation{}),
c.RegisterType(&nftfx.Credential{}),
c.RegisterType(&propertyfx.MintOutput{}),
c.RegisterType(&propertyfx.OwnedOutput{}),
c.RegisterType(&propertyfx.MintOperation{}),
c.RegisterType(&propertyfx.BurnOperation{}),
c.RegisterType(&propertyfx.Credential{}),
Codec.RegisterCodec(CodecVersion, c),
)
if errs.Errored() {
panic(errs.Err)
}
}