Skip to content

Commit

Permalink
ADD AdditionalCheck option
Browse files Browse the repository at this point in the history
  • Loading branch information
freehere107 committed Jan 5, 2024
1 parent ca31497 commit 518bdf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion extrinsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ExtrinsicDecoder struct {
Params []ExtrinsicParam `json:"params"`
Metadata *scaleType.MetadataStruct
SignedExtensions []scaleType.SignedExtension `json:"signed_extensions"`
AdditionalCheck []string
}

// https://github.com/polkadot-js/api/blob/master/packages/types/src/extrinsic/signedExtensions/index.ts#L24
Expand All @@ -55,6 +56,7 @@ func (e *ExtrinsicDecoder) Init(data scaleBytes.ScaleBytes, option *scaleType.Sc
e.Params = []ExtrinsicParam{}
e.Metadata = option.Metadata
e.SignedExtensions = option.SignedExtensions
e.AdditionalCheck = option.AdditionalCheck
e.ScaleDecoder.Init(data, option)
}

Expand Down Expand Up @@ -157,7 +159,7 @@ func (e *ExtrinsicDecoder) Process() {
} else {
if e.Metadata.MetadataVersion >= 14 {
for _, ext := range e.Metadata.Extrinsic.SignedExtensions {
if enable, ok := signedExts[ext.Identifier]; ok && enable {
if enable := signedExts[ext.Identifier]; enable || utiles.SliceIndex(ext.Identifier, e.AdditionalCheck) >= 0 {
result.SignedExtensions[ext.Identifier] = e.ProcessAndUpdateData(ext.TypeString)
}
}
Expand Down
1 change: 1 addition & 0 deletions types/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ScaleDecoderOption struct {
Metadata *MetadataStruct
FixedLength int
SignedExtensions []SignedExtension `json:"signed_extensions"`
AdditionalCheck []string
TypeName string
recursiveTime int
}
Expand Down

0 comments on commit 518bdf9

Please sign in to comment.