github.com/stafiprotocol/go-substrate-rpc-client@v1.4.7/pkg/stafidecoder/MetadataModuleCall.go (about)

     1  package stafi_decoder
     2  
     3  type MetadataModuleCall struct {
     4  	ScaleDecoder
     5  	Name string                       `json:"name"`
     6  	Args []MetadataModuleCallArgument `json:"args"`
     7  	Docs []string                     `json:"docs"`
     8  }
     9  
    10  func (m *MetadataModuleCall) Process() {
    11  	m.Name = m.ProcessAndUpdateData("String").(string)
    12  	argsValue := m.ProcessAndUpdateData("Vec<MetadataModuleCallArgument>").([]interface{})
    13  	var args []MetadataModuleCallArgument
    14  	for _, v := range argsValue {
    15  		arg := v.(map[string]string)
    16  		args = append(args, MetadataModuleCallArgument{Name: arg["name"], Type: arg["type"]})
    17  	}
    18  	m.Args = args
    19  	docs := m.ProcessAndUpdateData("Vec<String>").([]interface{})
    20  	for _, v := range docs {
    21  		m.Docs = append(m.Docs, v.(string))
    22  	}
    23  	m.Value = MetadataModuleCall{
    24  		Name: m.Name,
    25  		Args: m.Args,
    26  		Docs: m.Docs,
    27  	}
    28  }
    29  
    30  type MetadataModuleCallArgument struct {
    31  	ScaleDecoder
    32  	Name string `json:"name"`
    33  	Type string `json:"type"`
    34  }
    35  
    36  func (m *MetadataModuleCallArgument) Process() {
    37  	m.Name = m.ProcessAndUpdateData("String").(string)
    38  	m.Type = ConvertType(m.ProcessAndUpdateData("String").(string))
    39  	m.Value = map[string]string{
    40  		"name": m.Name,
    41  		"type": m.Type,
    42  	}
    43  }
    44  
    45  type MetadataModuleEvent struct {
    46  	ScaleDecoder
    47  	Name string   `json:"name"`
    48  	Docs []string `json:"docs"`
    49  	Args []string `json:"args"`
    50  }
    51  
    52  func (m *MetadataModuleEvent) Process() {
    53  	m.Name = m.ProcessAndUpdateData("String").(string)
    54  	args := m.ProcessAndUpdateData("Vec<String>").([]interface{})
    55  	for _, v := range args {
    56  		m.Args = append(m.Args, v.(string))
    57  	}
    58  	docs := m.ProcessAndUpdateData("Vec<String>").([]interface{})
    59  	for _, v := range docs {
    60  		m.Docs = append(m.Docs, v.(string))
    61  	}
    62  	m.Value = MetadataEvents{
    63  		Name: m.Name,
    64  		Args: m.Args,
    65  		Docs: m.Docs,
    66  	}
    67  }