mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
state: add more convenient method to get native contract hashes
This commit is contained in:
parent
bc9b5d6976
commit
a1a5db8fcd
2 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue