Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"encoding/json"

"github.com/huandu/xstrings"
"github.com/itering/scale.go/types/convert"
"github.com/itering/scale.go/types/scaleBytes"
Expand Down Expand Up @@ -740,6 +739,7 @@ type MetadataModuleError struct {
Name string `json:"name"`
Doc []string `json:"doc"`
Fields []ModuleErrorField `json:"fields,omitempty"`
Index int `json:"index,omitempty"`
}

type ModuleErrorField struct {
Expand Down
16 changes: 16 additions & 0 deletions types/v14.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
"encoding/json"
"fmt"
"github.com/itering/scale.go/types/scaleBytes"
"regexp"
"strings"

Expand All @@ -19,6 +20,19 @@ import (

type MetadataV14Decoder struct {
ScaleDecoder
Errors []MetadataModuleErrorV14 `json:"errors"`
}
type MetadataModuleErrorV14 struct {
ScaleDecoder `json:"-"`
Index int `json:"index"`
}

func (m *MetadataModuleErrorV14) Init(data scaleBytes.ScaleBytes, option *ScaleDecoderOption) {
m.ScaleDecoder.Init(data, option)
}
func (m *MetadataModuleErrorV14) Process() {
cm := MetadataModuleErrorV14{}
cm.Index = m.ProcessAndUpdateData("U8").(int)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not needed because the index is included in the metadata v14 Variants and does not need to be parsed again here.

}

type PalletLookUp struct {
Expand Down Expand Up @@ -110,6 +124,8 @@ func (m *MetadataV14Decoder) Process() {

for _, variant := range variants.Variants {
moduleErr := MetadataModuleError{Name: variant.Name, Doc: variant.Docs}
moduleErrV14 := MetadataModuleErrorV14{Index: variant.Index}
moduleErr.Index = moduleErrV14.Index
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moduleErr.Index = variant.Index

for _, field := range variant.Fields {
moduleErr.Fields = append(moduleErr.Fields, ModuleErrorField{Doc: field.Docs, TypeName: field.TypeName, Type: metadataSiType[field.Type]})
}
Expand Down