state: drop NativeContract, fix #3430

This unifies getnativecontracts RPC API with regular contracts.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2024-05-16 18:46:00 +03:00
parent 13020ccd02
commit b1bb12df48
6 changed files with 14 additions and 18 deletions

View file

@ -2292,18 +2292,19 @@ func (bc *Blockchain) GetNativeContractScriptHash(name string) (util.Uint160, er
}
// GetNatives returns list of native contracts.
func (bc *Blockchain) GetNatives() []state.NativeContract {
res := make([]state.NativeContract, 0, len(bc.contracts.Contracts))
func (bc *Blockchain) GetNatives() []state.Contract {
res := make([]state.Contract, 0, len(bc.contracts.Contracts))
current := bc.getCurrentHF()
for _, c := range bc.contracts.Contracts {
activeIn := c.ActiveIn()
if !(activeIn == nil || activeIn.Cmp(current) <= 0) {
continue
}
md := c.Metadata().HFSpecificContractMD(&current)
res = append(res, state.NativeContract{
ContractBase: md.ContractBase,
})
st := bc.GetContractState(c.Metadata().Hash)
if st != nil { // Should never happen, but better safe than sorry.
res = append(res, *st)
}
}
return res
}

View file

@ -29,11 +29,6 @@ type ContractBase struct {
Manifest manifest.Manifest `json:"manifest"`
}
// NativeContract holds information about the native contract.
type NativeContract struct {
ContractBase
}
// ToStackItem converts state.Contract to stackitem.Item.
func (c *Contract) ToStackItem() (stackitem.Item, error) {
// Do not skip the NEF size check, it won't affect native Management related