Skip to content

Commit

Permalink
ListContracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Sep 7, 2023
1 parent 085c5a8 commit fd5549c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Fairy.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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());
return json;
}

/// <summary>
/// Wait until the transaction is included in blocks
Expand Down

0 comments on commit fd5549c

Please sign in to comment.