native: implement management.getContractById

Follow neo-project/neo#2807. Notice that this data is not cached, our previous
implementation wasn't too and it shouldn't be a problem (not on the hot path).
This commit is contained in:
Roman Khimov 2022-09-19 22:56:33 +03:00
parent 6c68da7a52
commit 970862765d
6 changed files with 143 additions and 19 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/core"
"github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/storage"
"github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
@ -856,8 +857,7 @@ func handleLoadDeployed(c *cli.Context) error {
if err != nil {
return fmt.Errorf("failed to parse contract hash, address or ID: %w", err)
}
bc := getChainFromContext(c.App)
h, err = bc.GetContractScriptHash(int32(i)) // @fixme: can be improved after #2702 to retrieve historic state of destroyed contract by ID.
h, err = native.GetContractScriptHash(ic.DAO, int32(i))
if err != nil {
return fmt.Errorf("failed to retrieve contract hash by ID: %w", err)
}