neo-modules icon indicating copy to clipboard operation
neo-modules copied to clipboard

deployed contract name support in getContractState

Open devhawk opened this issue 5 years ago • 3 comments

Summary or problem description getcontractstate supports retrieving contract state by invocation hash (i.e. the new script hash that doesn't change when the contract is updated), or by native contract name or native contract id. There is no way to retrieve the contract state of a non-native deployed contract except by invocation hash.

Do you have any solution you want to propose? Update GetContractState to support query of deployed contracts by name. Note, since it's possible for multiple contracts to have the same name, this means returning an array of contract states when querying by name.

Neo-express is creating a custom express-specific RPC endpoint with this behavior (https://github.com/neo-project/neo-express/pull/92). But it would be best for neo visual devtracker for this behavior to be standard on all RPC nodes.

Where in the software does this update applies to?

  • RPC (HTTP)

devhawk avatar Dec 14 '20 21:12 devhawk

Update GetContractState to support query of deployed contracts by name.

It seems we can not do that, as there is no name -> contractstate table in neo-core.

Tommo-L avatar Dec 22 '20 02:12 Tommo-L

Update GetContractState to support query of deployed contracts by name.

It seems we can not do that, as there is no name -> contractstate table in neo-core.

we have list all contracts function, can filter the result by name.

        public IEnumerable<ContractState> ListContracts(StoreView snapshot)
        {
            byte[] listContractsPrefix = CreateStorageKey(Prefix_Contract).ToArray();
            return snapshot.Storages.Find(listContractsPrefix).Select(kvp => kvp.Value.GetInteroperable<ContractState>());
        }

cloud8little avatar Dec 22 '20 03:12 cloud8little

Sorry, clicked the close button by accident

devhawk avatar Dec 22 '20 18:12 devhawk