diff --git a/Fairy.Utils.cs b/Fairy.Utils.cs
index b180d29..4708d36 100644
--- a/Fairy.Utils.cs
+++ b/Fairy.Utils.cs
@@ -85,38 +85,6 @@ protected virtual JToken ListContracts(JArray _params)
return json;
}
- ///
- /// Wait until the transaction is included in blocks
- ///
- /// UInt256String; bool(verbose); waitBlockCount
- ///
- ///
- [RpcMethod]
- protected virtual JToken AwaitConfirmedTransaction(JArray _params)
- {
- UInt256 hash = UInt256.Parse(_params[0]!.AsString());
- bool verbose = _params.Count >= 2 && _params[1]!.AsBoolean();
- uint waitBlockCount = _params.Count >= 2 ? uint.Parse(_params[2]!.AsString()) : 2;
- JToken? json = GetConfirmedTransaction(hash, verbose);
- if (json != null)
- return json;
- SemaphoreSlim signal = new SemaphoreSlim(0, 1);
- uint count = 0;
- CommittedHandler getConfirmedTransactionAfterCommitted = delegate(NeoSystem @system, Block @block){ json = GetConfirmedTransaction(hash, verbose); count += 1; signal.Release(); };
- Blockchain.Committed += getConfirmedTransactionAfterCommitted;
- while (count < waitBlockCount)
- {
- signal.Wait();
- if (json != null)
- {
- Blockchain.Committed -= getConfirmedTransactionAfterCommitted;
- return json;
- }
- }
- Blockchain.Committed -= getConfirmedTransactionAfterCommitted;
- throw new RpcException(-100, $"Transaction not found in {waitBlockCount} blocks");
- }
-
[RpcMethod]
protected virtual JObject PutStorageWithSession(JArray _params)
{
@@ -283,6 +251,53 @@ protected JObject SetTokenBalance(string session, UInt160 contract, UInt160 acco
}
}
+ [RpcMethod]
+ protected virtual JToken GetManyUnclaimedGas(JArray _params)
+ {
+ string? session = _params[0]?.AsString();
+ DataCache snapshot = session == null ? system.StoreView : sessionStringToFairySession[session].engine.Snapshot;
+ uint nextBlockIndex = NativeContract.Ledger.CurrentIndex(snapshot) + 1;
+ JObject json = new JObject();
+ for (int i = 1; i < _params.Count; ++i)
+ {
+ UInt160 account = UInt160.Parse(_params[i]!.AsString());
+ json[account.ToString()] = NativeContract.NEO.UnclaimedGas(snapshot, account, nextBlockIndex).ToString();
+ }
+ return json;
+ }
+
+ ///
+ /// Wait until the transaction is included in blocks
+ ///
+ /// UInt256String; bool(verbose); waitBlockCount
+ ///
+ ///
+ [RpcMethod]
+ protected virtual JToken AwaitConfirmedTransaction(JArray _params)
+ {
+ UInt256 hash = UInt256.Parse(_params[0]!.AsString());
+ bool verbose = _params.Count >= 2 && _params[1]!.AsBoolean();
+ uint waitBlockCount = _params.Count >= 2 ? uint.Parse(_params[2]!.AsString()) : 2;
+ JToken? json = GetConfirmedTransaction(hash, verbose);
+ if (json != null)
+ return json;
+ SemaphoreSlim signal = new SemaphoreSlim(0, 1);
+ uint count = 0;
+ CommittedHandler getConfirmedTransactionAfterCommitted = delegate (NeoSystem @system, Block @block) { json = GetConfirmedTransaction(hash, verbose); count += 1; signal.Release(); };
+ Blockchain.Committed += getConfirmedTransactionAfterCommitted;
+ while (count < waitBlockCount)
+ {
+ signal.Wait();
+ if (json != null)
+ {
+ Blockchain.Committed -= getConfirmedTransactionAfterCommitted;
+ return json;
+ }
+ }
+ Blockchain.Committed -= getConfirmedTransactionAfterCommitted;
+ throw new RpcException(-100, $"Transaction not found in {waitBlockCount} blocks");
+ }
+
protected JToken? GetConfirmedTransaction(UInt256 hash, bool verbose)
{
// Do not consider anything in MemPool, because they have not been confirmed