From 518bdf9d82b8c9ddfa778e5653ef777bf714d7e9 Mon Sep 17 00:00:00 2001 From: freehere107 Date: Fri, 5 Jan 2024 10:26:10 +0800 Subject: [PATCH] ADD AdditionalCheck option --- extrinsic.go | 4 +++- types/base.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/extrinsic.go b/extrinsic.go index 6785333..3833621 100644 --- a/extrinsic.go +++ b/extrinsic.go @@ -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 @@ -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) } @@ -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) } } diff --git a/types/base.go b/types/base.go index 0bda9e6..62997bc 100644 --- a/types/base.go +++ b/types/base.go @@ -21,6 +21,7 @@ type ScaleDecoderOption struct { Metadata *MetadataStruct FixedLength int SignedExtensions []SignedExtension `json:"signed_extensions"` + AdditionalCheck []string TypeName string recursiveTime int }