diff --git a/Fairy.Utils.cs b/Fairy.Utils.cs index 9a01169..b180d29 100644 --- a/Fairy.Utils.cs +++ b/Fairy.Utils.cs @@ -73,6 +73,17 @@ protected virtual JToken GetContract(JArray _params) return contractState.ToJson(); } + [RpcMethod] + protected virtual JToken ListContracts(JArray _params) + { + string? session = _params[0]?.AsString(); + IEnumerable contractStates = NativeContract.ContractManagement.ListContracts( + session == null ? system.StoreView : sessionStringToFairySession[session].engine.Snapshot); + JArray json = new(); + foreach (ContractState c in contractStates) + json.Add(c.ToJson()); + return json; + } /// /// Wait until the transaction is included in blocks