native: make management compatible with C# node 3.5.0

It doesn't store id->hash mappings for native contracts. We need blockchain's
GetContractScriptHash to serve both anyway, so it was changed a bit. The only
other direct user of native.GetContractScriptHash is the VM CLI, but I doubt
anyone will use it for native contracts (they have ~zero VM code anyway).
This commit is contained in:
Roman Khimov 2022-12-07 15:13:17 +03:00
parent 90a85259a8
commit 236e633ee4
5 changed files with 17 additions and 4 deletions

View file

@ -2091,6 +2091,14 @@ func (bc *Blockchain) GetContractState(hash util.Uint160) *state.Contract {
// GetContractScriptHash returns contract script hash by its ID.
func (bc *Blockchain) GetContractScriptHash(id int32) (util.Uint160, error) {
if id < 0 {
for _, n := range bc.contracts.Contracts {
nc := n.Metadata().NativeContract
if nc.ID == id {
return nc.Hash, nil
}
}
}
return native.GetContractScriptHash(bc.dao, id)
}