scalecodec

package module
v1.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 23

README

Scale Codec in Golang

Scale Codec written by golang, reference from polkascan/py-scale-codec.

Features

  • Decode
  • Encode
  • Metadata decode(V11,V12,V13,V14)
  • Extrinsic decode
  • EventRecord decode
  • Custom type reg
  • Reg special version type

Installation

go get -u github.com/itering/scale.go

Test

go test ./... --cover -v 

Docker

docker build -t scale_go .
docker run -it scale_go

Resources

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/itering/scale.go

License

The package is available as open source under the terms of the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventParam

type EventParam struct {
	Type     string      `json:"type"`
	Name     string      `json:"name,omitempty"`
	TypeName string      `json:"type_name"`
	Value    interface{} `json:"value"`
}

type EventRecord

type EventRecord struct {
	scaleType.ScaleDecoder
	Metadata     *scaleType.MetadataStruct
	Phase        int                      `json:"phase"`
	ExtrinsicIdx int                      `json:"extrinsic_idx"`
	Type         string                   `json:"type"`
	Params       []EventParam             `json:"params"`
	Event        scaleType.MetadataEvents `json:"event"`
	Topic        []string                 `json:"topic"`
	ParamsRaw    string                   `json:"params_raw"`
}

func (*EventRecord) Process

func (e *EventRecord) Process() map[string]interface{}

type EventsDecoder

type EventsDecoder struct {
	scaleType.Vec
	Metadata *scaleType.MetadataStruct
}

func (*EventsDecoder) Init

func (*EventsDecoder) Process

func (e *EventsDecoder) Process()

type ExtrinsicDecoder

type ExtrinsicDecoder struct {
	scaleType.ScaleDecoder
	ExtrinsicLength     int              `json:"extrinsic_length"`
	ExtrinsicHash       string           `json:"extrinsic_hash"`
	VersionInfo         string           `json:"version_info"`
	ContainsTransaction bool             `json:"contains_transaction"`
	Address             interface{}      `json:"address"`
	Signature           string           `json:"signature"`
	Nonce               int              `json:"nonce"`
	Era                 string           `json:"era"`
	CallIndex           string           `json:"call_index"`
	Params              []ExtrinsicParam `json:"params"`
	ParamsRaw           string           `json:"params_raw"`
	Metadata            *scaleType.MetadataStruct
	SignedExtensions    []scaleType.SignedExtension `json:"signed_extensions"`
	AdditionalCheck     []string
}

func (*ExtrinsicDecoder) Init

func (*ExtrinsicDecoder) Process

func (e *ExtrinsicDecoder) Process()

type ExtrinsicParam

type ExtrinsicParam struct {
	Name     string      `json:"name"`
	Type     string      `json:"type"`
	TypeName string      `json:"type_name"`
	Value    interface{} `json:"value"`
}

type GenericExtrinsic added in v1.6.0

type GenericExtrinsic struct {
	VersionInfo        string                 `json:"version_info"`
	ExtrinsicLength    int                    `json:"extrinsic_length"`
	AddressType        string                 `json:"address_type"`
	Tip                decimal.Decimal        `json:"tip"`
	SignedExtensions   map[string]interface{} `json:"signed_extensions"`
	AccountId          interface{}            `json:"account_id"`
	Signer             interface{}            `json:"signer"` // map[string]interface or string
	Signature          string                 `json:"signature"`
	SignatureRaw       interface{}            `json:"signature_raw"` // map[string]interface or string
	Nonce              int                    `json:"nonce"`
	Era                string                 `json:"era"`
	ExtrinsicHash      string                 `json:"extrinsic_hash"`
	CallModuleFunction string                 `json:"call_module_function"`
	CallCode           string                 `json:"call_code"`
	CallModule         string                 `json:"call_module"`
	Params             []ExtrinsicParam       `json:"params"`
	ParamsRaw          string                 `json:"params_raw"`
}

func (*GenericExtrinsic) Encode added in v1.6.0

func (*GenericExtrinsic) ToMap added in v1.6.0

func (g *GenericExtrinsic) ToMap() map[string]interface{}

ToMap GenericExtrinsic convert to map[string]interface

type MetadataDecoder

type MetadataDecoder struct {
	types.ScaleDecoder
	Version  string               `json:"version"`
	Metadata types.MetadataStruct `json:"metadata"`
}

func (*MetadataDecoder) Init

func (m *MetadataDecoder) Init(data []byte)

func (*MetadataDecoder) Process

func (m *MetadataDecoder) Process() error

Directories

Path Synopsis
pkg
go-ethereum/crypto/sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
crypto/ethereum/common/math
Package math provides integer math utilities.
Package math provides integer math utilities.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL