MCPcopy Create free account
hub / github.com/DEROFDN/Engram / getContractHeader

Function getContractHeader

functions.go:2958–3061  ·  view source on GitHub ↗

Get the latest smart contract header data (must follow the standard here: https://github.com/civilware/artificer-nfa-standard/blob/main/Headers/README.md)

(scid crypto.Hash)

Source from the content-addressed store, hash-verified

2956
2957// Get the latest smart contract header data (must follow the standard here: https://github.com/civilware/artificer-nfa-standard/blob/main/Headers/README.md)
2958func getContractHeader(scid crypto.Hash) (name string, desc string, icon string, owner string, code string) {
2959 var headerData []*structures.SCIDVariable
2960 var found bool
2961
2962 switch gnomon.Index.DBType {
2963 case "gravdb":
2964 headerData = gnomon.Index.GravDBBackend.GetAllSCIDVariableDetails(scid.String())
2965 case "boltdb":
2966 headerData = gnomon.Index.BBSBackend.GetAllSCIDVariableDetails(scid.String())
2967 }
2968 if headerData == nil {
2969 addIndex := make(map[string]*structures.FastSyncImport)
2970 addIndex[scid.String()] = &structures.FastSyncImport{}
2971 gnomon.Index.AddSCIDToIndex(addIndex, false, true)
2972 switch gnomon.Index.DBType {
2973 case "gravdb":
2974 headerData = gnomon.Index.GravDBBackend.GetAllSCIDVariableDetails(scid.String())
2975 case "boltdb":
2976 headerData = gnomon.Index.BBSBackend.GetAllSCIDVariableDetails(scid.String())
2977 }
2978 }
2979
2980 for _, h := range headerData {
2981 switch key := h.Key.(type) {
2982 case string:
2983 if key == "var_header_name" {
2984 found = true
2985 name = h.Value.(string)
2986 } else if name == "" && key == "nameHdr" {
2987 found = true
2988 name = h.Value.(string)
2989 }
2990
2991 if key == "var_header_description" {
2992 found = true
2993 desc = h.Value.(string)
2994 } else if desc == "" && key == "descrHdr" {
2995 found = true
2996 desc = h.Value.(string)
2997 }
2998
2999 if key == "var_header_icon" {
3000 found = true
3001 icon = h.Value.(string)
3002 } else if icon == "" && key == "iconURLHdr" {
3003 found = true
3004 icon = h.Value.(string)
3005 }
3006
3007 if key == "owner" {
3008 owner = h.Value.(string)
3009 }
3010
3011 if key == "C" {
3012 code = h.Value.(string)
3013 }
3014 }
3015 }

Callers 6

layoutAssetExplorerFunction · 0.85
layoutMyAssetsFunction · 0.85
layoutAssetManagerFunction · 0.85
layoutXSWDAppManagerFunction · 0.85
layoutTELAFunction · 0.85
layoutTELAManagerFunction · 0.85

Calls 2

AddSCIDToIndexMethod · 0.80

Tested by

no test coverage detected