-
Notifications
You must be signed in to change notification settings - Fork 8
/
IFlowClient.cs
185 lines (164 loc) · 7.94 KB
/
IFlowClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
using Flow.Net.Sdk.Core.Exceptions;
using Flow.Net.Sdk.Core.Cadence;
using Flow.Net.Sdk.Core.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Flow.Net.Sdk.Core.Client
{
public interface IFlowClient
{
/// <summary>
/// Check if the access node is alive and healthy.
/// </summary>
/// <exception cref="FlowException"></exception>
Task PingAsync();
/// <summary>
/// Gets the latest sealed or unsealed block header.
/// </summary>
/// <param name="isSealed"></param>
/// <returns><see cref="FlowBlockHeader"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowBlockHeader> GetLatestBlockHeaderAsync(bool isSealed = true);
/// <summary>
/// Gets a block header by Id.
/// </summary>
/// <param name="blockId"></param>
/// <returns><see cref="FlowBlockHeader"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowBlockHeader> GetBlockHeaderByIdAsync(string blockId);
/// <summary>
/// Gets a block header by height.
/// </summary>
/// <param name="height"></param>
/// <returns><see cref="FlowBlockHeader"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowBlockHeader> GetBlockHeaderByHeightAsync(ulong height);
/// <summary>
/// Gets the full payload of the latest sealed or unsealed block.
/// </summary>
/// <param name="isSealed"></param>
/// <returns><see cref="FlowBlock"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowBlock> GetLatestBlockAsync(bool isSealed = true);
/// <summary>
/// Gets a full block by Id.
/// </summary>
/// <param name="blockId"></param>
/// <returns><see cref="FlowBlock"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowBlock> GetBlockByIdAsync(string blockId);
/// <summary>
/// Gets a full block by height.
/// </summary>
/// <param name="height"></param>
/// <returns><see cref="FlowBlock"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowBlock> GetBlockByHeightAsync(ulong height);
/// <summary>
/// Gets a collection by Id.
/// </summary>
/// <param name="collectionId"></param>
/// <returns><see cref="FlowCollection"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowCollection> GetCollectionAsync(string collectionId);
/// <summary>
/// Submits a transaction to the network.
/// </summary>
/// <param name="flowTransaction"></param>
/// <returns><see cref="FlowTransactionId"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowTransactionId> SendTransactionAsync(FlowTransaction flowTransaction);
/// <summary>
/// Gets a transaction by Id.
/// </summary>
/// <param name="transactionId"></param>
/// <returns><see cref="FlowTransactionResponse"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowTransactionResponse> GetTransactionAsync(string transactionId);
/// <summary>
/// Gets the result of a transaction.
/// </summary>
/// <param name="transactionId"></param>
/// <returns><see cref="FlowTransactionResult"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowTransactionResult> GetTransactionResultAsync(string transactionId);
/// <summary>
/// Gets an account by address at the latest sealed block.
/// </summary>
/// <param name="address"></param>
/// <returns><see cref="FlowAccount"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowAccount> GetAccountAtLatestBlockAsync(string address);
/// <summary>
/// Gets an account by address at the given block height.
/// </summary>
/// <param name="address"></param>
/// <param name="blockHeight"></param>
/// <returns><see cref="FlowAccount"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowAccount> GetAccountAtBlockHeightAsync(string address, ulong blockHeight);
/// <summary>
/// Executes a read-only Cadence script against the latest sealed execution state.
/// </summary>
/// <param name="flowScript"></param>
/// <returns><see cref="ICadence"/></returns>
/// <exception cref="FlowException"></exception>
Task<ICadence> ExecuteScriptAtLatestBlockAsync(FlowScript flowScript);
/// <summary>
/// Executes a ready-only Cadence script against the execution state at the block with the given Id.
/// </summary>
/// <param name="flowScript"></param>
/// <param name="blockId"></param>
/// <returns><see cref="ICadence"/></returns>
/// <exception cref="FlowException"></exception>
Task<ICadence> ExecuteScriptAtBlockIdAsync(FlowScript flowScript, string blockId);
/// <summary>
/// Executes a ready-only Cadence script against the execution state at the given block height.
/// </summary>
/// <param name="flowScript"></param>
/// <param name="blockHeight"></param>
/// <returns><see cref="ICadence"/></returns>
/// <exception cref="FlowException"></exception>
Task<ICadence> ExecuteScriptAtBlockHeightAsync(FlowScript flowScript, ulong blockHeight);
/// <summary>
/// Retrieves events for all sealed blocks between the start and end block heights (inclusive) with the given type.
/// </summary>
/// <param name="eventType"></param>
/// <param name="startHeight"></param>
/// <param name="endHeight"></param>
/// <returns><see cref="IEnumerable{T}" /> of <see cref="FlowBlockEvent"/></returns>
/// <exception cref="FlowException"></exception>
Task<IEnumerable<FlowBlockEvent>> GetEventsForHeightRangeAsync(string eventType, ulong startHeight, ulong endHeight);
/// <summary>
/// Retrieves events with the given type from the specified block Ids.
/// </summary>
/// <param name="eventType"></param>
/// <param name="blockIds"></param>
/// <returns><see cref="IEnumerable{T}" /> of <see cref="FlowBlockEvent"/></returns>
/// <exception cref="FlowException"></exception>
Task<IEnumerable<FlowBlockEvent>> GetEventsForBlockIdsAsync(string eventType, IEnumerable<string> blockIds);
/// <summary>
/// Retrieves the latest snapshot of the protocol state in serialized form.
/// This is used to generate a root snapshot file used by Flow nodes to bootstrap their local protocol state database.
/// </summary>
/// <returns><see cref="FlowProtocolStateSnapshot"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowProtocolStateSnapshot> GetLatestProtocolStateSnapshotAsync();
/// <summary>
/// Retrieves execution result for the specified block Id.
/// </summary>
/// <param name="blockId"></param>
/// <returns><see cref="FlowExecutionResult"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowExecutionResult> GetExecutionResultForBlockIdAsync(string blockId);
/// <summary>
/// Waits for transaction result status to be sealed.
/// </summary>
/// <param name="transactionId"></param>
/// <param name="delayMs"></param>
/// <param name="timeoutMs"></param>
/// <returns><see cref="FlowTransactionResult"/></returns>
/// <exception cref="FlowException"></exception>
Task<FlowTransactionResult> WaitForSealAsync(string transactionId, int delayMs = 1000, int timeoutMs = 30000);
}
}