Skip to content

Commit

Permalink
verbose option for ListContracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Aug 15, 2024
1 parent a0d3430 commit 2fb2ee6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Fairy.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ protected virtual JToken GetContract(JArray _params)
protected virtual JToken ListContracts(JArray _params)
{
string? session = _params[0]?.AsString();
bool verbose = _params.Count >= 2 ? _params[1]!.AsBoolean() : false;
IEnumerable<ContractState> contractStates = NativeContract.ContractManagement.ListContracts(
session == null ? system.StoreView : sessionStringToFairySession[session].engine.Snapshot);
JArray json = new();
foreach (ContractState c in contractStates)
json.Add(c.ToJson());
json.Add(verbose ? c.ToJson() : new JObject { ["id"] = c.Id, ["hash"] = c.Hash.ToString() });
return json;
}

Expand Down

0 comments on commit 2fb2ee6

Please sign in to comment.