state: add more convenient method to get native contract hashes

This commit is contained in:
Roman Khimov 2022-08-15 10:54:29 +03:00
parent bc9b5d6976
commit a1a5db8fcd
2 changed files with 7 additions and 1 deletions

View file

@ -176,7 +176,7 @@ func NewContractMD(name string, id int32) *ContractMD {
c.NEF.Header.Compiler = "neo-core-v3.0"
c.NEF.Header.Magic = nef.Magic
c.NEF.Tokens = []nef.MethodToken{} // avoid `nil` result during JSON marshalling
c.Hash = state.CreateContractHash(util.Uint160{}, 0, c.Name)
c.Hash = state.CreateNativeContractHash(c.Name)
c.Manifest = *manifest.DefaultManifest(name)
return c

View file

@ -115,3 +115,9 @@ func CreateContractHash(sender util.Uint160, checksum uint32, name string) util.
}
return hash.Hash160(w.Bytes())
}
// CreateNativeContractHash calculates the hash for the native contract with the
// given name.
func CreateNativeContractHash(name string) util.Uint160 {
return CreateContractHash(util.Uint160{}, 0, name)
}