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

     1  package stafi_decoder
     2  
     3  import "strings"
     4  
     5  func ConvertType(name string, option ...interface{}) string {
     6  	defer func() {
     7  		if len(option) == 0 {
     8  			RuntimeCodecType = append(RuntimeCodecType, name)
     9  		}
    10  	}()
    11  	name = strings.TrimSpace(name)
    12  	name = strings.ReplaceAll(name, "T::", "")
    13  	name = strings.ReplaceAll(name, "VecDeque<", "Vec<")
    14  	name = strings.ReplaceAll(name, "<T>", "")
    15  	name = strings.ReplaceAll(name, "<T as Trait>::", "")
    16  	name = strings.ReplaceAll(name, "<T, I>", "")
    17  	name = strings.ReplaceAll(name, "\n", " ")
    18  	switch name {
    19  	case "()", "<InherentOfflineReport as InherentOfflineReport>::Inherent":
    20  		name = "Null"
    21  	case "Vec<u8>":
    22  		name = "Bytes"
    23  	case "<Lookup as StaticLookup>::Source":
    24  		name = "Address"
    25  	case "<Balance as HasCompact>::Type":
    26  		name = "Compact<Balance>"
    27  	case "<BlockNumber as HasCompact>::Type":
    28  		name = "Compact<BlockNumber>"
    29  	case "<Moment as HasCompact>::Type":
    30  		name = "Compact<Moment>"
    31  	case "<T as Trait<I>>::Proposal":
    32  		name = "Proposal"
    33  	case "wasm::PrefabWasmModule":
    34  		name = "PrefabWasmModule"
    35  	}
    36  	return name
    37  }