Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ManagementContract.ListContracts #2134

Merged
merged 9 commits into from
Dec 11, 2020
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/neo/SmartContract/Native/ManagementContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Neo.Persistence;
using Neo.SmartContract.Manifest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace Neo.SmartContract.Native
Expand Down Expand Up @@ -44,6 +46,12 @@ internal override void OnPersist(ApplicationEngine engine)
}
}

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

[ContractMethod(0_01000000, CallFlags.ReadStates)]
public ContractState GetContract(StoreView snapshot, UInt160 hash)
{
Expand Down