-
Notifications
You must be signed in to change notification settings - Fork 0
/
_KryxiviaCoinServiceBase.cs
504 lines (391 loc) · 22.1 KB
/
_KryxiviaCoinServiceBase.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Numerics;
using Nethereum.Hex.HexTypes;
using Nethereum.ABI.FunctionEncoding.Attributes;
using Nethereum.Web3;
using Nethereum.RPC.Eth.DTOs;
using Nethereum.Contracts.CQS;
using Nethereum.Contracts.ContractHandlers;
using Nethereum.Contracts;
using System.Threading;
using Kryxivia.Contracts.Definitions.KryxiviaCoin;
namespace Kryxivia.Contracts
{
public partial class _KryxiviaCoinServiceBase
{
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, KryxiviaCoinDeployment kryxiviaCoinDeployment, CancellationTokenSource cancellationTokenSource = null)
{
return web3.Eth.GetContractDeploymentHandler<KryxiviaCoinDeployment>().SendRequestAndWaitForReceiptAsync(kryxiviaCoinDeployment, cancellationTokenSource);
}
public static Task<string> DeployContractAsync(Nethereum.Web3.Web3 web3, KryxiviaCoinDeployment kryxiviaCoinDeployment)
{
return web3.Eth.GetContractDeploymentHandler<KryxiviaCoinDeployment>().SendRequestAsync(kryxiviaCoinDeployment);
}
public static async Task<_KryxiviaCoinServiceBase> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, KryxiviaCoinDeployment kryxiviaCoinDeployment, CancellationTokenSource cancellationTokenSource = null)
{
var receipt = await DeployContractAndWaitForReceiptAsync(web3, kryxiviaCoinDeployment, cancellationTokenSource);
return new _KryxiviaCoinServiceBase(web3, receipt.ContractAddress);
}
protected Nethereum.Web3.Web3 Web3 { get; }
public ContractHandler ContractHandler { get; }
public _KryxiviaCoinServiceBase(Nethereum.Web3.Web3 web3, string contractAddress)
{
Web3 = web3;
ContractHandler = web3.Eth.GetContractHandler(contractAddress);
}
public Task<byte[]> DefaultAdminRoleQueryAsync(DefaultAdminRoleFunction defaultAdminRoleFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<DefaultAdminRoleFunction, byte[]>(defaultAdminRoleFunction, blockParameter);
}
public Task<byte[]> DefaultAdminRoleQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<DefaultAdminRoleFunction, byte[]>(null, blockParameter);
}
public Task<byte> DecimalsQueryAsync(DecimalsFunction decimalsFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<DecimalsFunction, byte>(decimalsFunction, blockParameter);
}
public Task<byte> DecimalsQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<DecimalsFunction, byte>(null, blockParameter);
}
public Task<BigInteger> AllowanceQueryAsync(AllowanceFunction allowanceFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<AllowanceFunction, BigInteger>(allowanceFunction, blockParameter);
}
public Task<BigInteger> AllowanceQueryAsync(string owner, string spender, BlockParameter blockParameter = null)
{
var allowanceFunction = new AllowanceFunction();
allowanceFunction.Owner = owner;
allowanceFunction.Spender = spender;
return ContractHandler.QueryAsync<AllowanceFunction, BigInteger>(allowanceFunction, blockParameter);
}
public Task<string> ApproveRequestAsync(ApproveFunction approveFunction)
{
return ContractHandler.SendRequestAsync(approveFunction);
}
public Task<TransactionReceipt> ApproveRequestAndWaitForReceiptAsync(ApproveFunction approveFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(approveFunction, cancellationToken);
}
public Task<string> ApproveRequestAsync(string spender, BigInteger amount)
{
var approveFunction = new ApproveFunction();
approveFunction.Spender = spender;
approveFunction.Amount = amount;
return ContractHandler.SendRequestAsync(approveFunction);
}
public Task<TransactionReceipt> ApproveRequestAndWaitForReceiptAsync(string spender, BigInteger amount, CancellationTokenSource cancellationToken = null)
{
var approveFunction = new ApproveFunction();
approveFunction.Spender = spender;
approveFunction.Amount = amount;
return ContractHandler.SendRequestAndWaitForReceiptAsync(approveFunction, cancellationToken);
}
public Task<BigInteger> BalanceOfQueryAsync(BalanceOfFunction balanceOfFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<BalanceOfFunction, BigInteger>(balanceOfFunction, blockParameter);
}
public Task<BigInteger> BalanceOfQueryAsync(string account, BlockParameter blockParameter = null)
{
var balanceOfFunction = new BalanceOfFunction();
balanceOfFunction.Account = account;
return ContractHandler.QueryAsync<BalanceOfFunction, BigInteger>(balanceOfFunction, blockParameter);
}
public Task<string> BurnRequestAsync(BurnFunction burnFunction)
{
return ContractHandler.SendRequestAsync(burnFunction);
}
public Task<TransactionReceipt> BurnRequestAndWaitForReceiptAsync(BurnFunction burnFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnFunction, cancellationToken);
}
public Task<string> BurnRequestAsync(BigInteger amount)
{
var burnFunction = new BurnFunction();
burnFunction.Amount = amount;
return ContractHandler.SendRequestAsync(burnFunction);
}
public Task<TransactionReceipt> BurnRequestAndWaitForReceiptAsync(BigInteger amount, CancellationTokenSource cancellationToken = null)
{
var burnFunction = new BurnFunction();
burnFunction.Amount = amount;
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnFunction, cancellationToken);
}
public Task<string> BurnFromRequestAsync(BurnFromFunction burnFromFunction)
{
return ContractHandler.SendRequestAsync(burnFromFunction);
}
public Task<TransactionReceipt> BurnFromRequestAndWaitForReceiptAsync(BurnFromFunction burnFromFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnFromFunction, cancellationToken);
}
public Task<string> BurnFromRequestAsync(string account, BigInteger amount)
{
var burnFromFunction = new BurnFromFunction();
burnFromFunction.Account = account;
burnFromFunction.Amount = amount;
return ContractHandler.SendRequestAsync(burnFromFunction);
}
public Task<TransactionReceipt> BurnFromRequestAndWaitForReceiptAsync(string account, BigInteger amount, CancellationTokenSource cancellationToken = null)
{
var burnFromFunction = new BurnFromFunction();
burnFromFunction.Account = account;
burnFromFunction.Amount = amount;
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnFromFunction, cancellationToken);
}
public Task<string> BurnKXARequestAsync(BurnKXAFunction burnKXAFunction)
{
return ContractHandler.SendRequestAsync(burnKXAFunction);
}
public Task<TransactionReceipt> BurnKXARequestAndWaitForReceiptAsync(BurnKXAFunction burnKXAFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnKXAFunction, cancellationToken);
}
public Task<string> BurnKXARequestAsync(BigInteger amount)
{
var burnKXAFunction = new BurnKXAFunction();
burnKXAFunction.Amount = amount;
return ContractHandler.SendRequestAsync(burnKXAFunction);
}
public Task<TransactionReceipt> BurnKXARequestAndWaitForReceiptAsync(BigInteger amount, CancellationTokenSource cancellationToken = null)
{
var burnKXAFunction = new BurnKXAFunction();
burnKXAFunction.Amount = amount;
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnKXAFunction, cancellationToken);
}
public Task<string> DecreaseAllowanceRequestAsync(DecreaseAllowanceFunction decreaseAllowanceFunction)
{
return ContractHandler.SendRequestAsync(decreaseAllowanceFunction);
}
public Task<TransactionReceipt> DecreaseAllowanceRequestAndWaitForReceiptAsync(DecreaseAllowanceFunction decreaseAllowanceFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(decreaseAllowanceFunction, cancellationToken);
}
public Task<string> DecreaseAllowanceRequestAsync(string spender, BigInteger subtractedValue)
{
var decreaseAllowanceFunction = new DecreaseAllowanceFunction();
decreaseAllowanceFunction.Spender = spender;
decreaseAllowanceFunction.SubtractedValue = subtractedValue;
return ContractHandler.SendRequestAsync(decreaseAllowanceFunction);
}
public Task<TransactionReceipt> DecreaseAllowanceRequestAndWaitForReceiptAsync(string spender, BigInteger subtractedValue, CancellationTokenSource cancellationToken = null)
{
var decreaseAllowanceFunction = new DecreaseAllowanceFunction();
decreaseAllowanceFunction.Spender = spender;
decreaseAllowanceFunction.SubtractedValue = subtractedValue;
return ContractHandler.SendRequestAndWaitForReceiptAsync(decreaseAllowanceFunction, cancellationToken);
}
public Task<byte[]> GetRoleAdminQueryAsync(GetRoleAdminFunction getRoleAdminFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<GetRoleAdminFunction, byte[]>(getRoleAdminFunction, blockParameter);
}
public Task<byte[]> GetRoleAdminQueryAsync(byte[] role, BlockParameter blockParameter = null)
{
var getRoleAdminFunction = new GetRoleAdminFunction();
getRoleAdminFunction.Role = role;
return ContractHandler.QueryAsync<GetRoleAdminFunction, byte[]>(getRoleAdminFunction, blockParameter);
}
public Task<string> GrantRoleRequestAsync(GrantRoleFunction grantRoleFunction)
{
return ContractHandler.SendRequestAsync(grantRoleFunction);
}
public Task<TransactionReceipt> GrantRoleRequestAndWaitForReceiptAsync(GrantRoleFunction grantRoleFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(grantRoleFunction, cancellationToken);
}
public Task<string> GrantRoleRequestAsync(byte[] role, string account)
{
var grantRoleFunction = new GrantRoleFunction();
grantRoleFunction.Role = role;
grantRoleFunction.Account = account;
return ContractHandler.SendRequestAsync(grantRoleFunction);
}
public Task<TransactionReceipt> GrantRoleRequestAndWaitForReceiptAsync(byte[] role, string account, CancellationTokenSource cancellationToken = null)
{
var grantRoleFunction = new GrantRoleFunction();
grantRoleFunction.Role = role;
grantRoleFunction.Account = account;
return ContractHandler.SendRequestAndWaitForReceiptAsync(grantRoleFunction, cancellationToken);
}
public Task<bool> HasRoleQueryAsync(HasRoleFunction hasRoleFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<HasRoleFunction, bool>(hasRoleFunction, blockParameter);
}
public Task<bool> HasRoleQueryAsync(byte[] role, string account, BlockParameter blockParameter = null)
{
var hasRoleFunction = new HasRoleFunction();
hasRoleFunction.Role = role;
hasRoleFunction.Account = account;
return ContractHandler.QueryAsync<HasRoleFunction, bool>(hasRoleFunction, blockParameter);
}
public Task<string> IncreaseAllowanceRequestAsync(IncreaseAllowanceFunction increaseAllowanceFunction)
{
return ContractHandler.SendRequestAsync(increaseAllowanceFunction);
}
public Task<TransactionReceipt> IncreaseAllowanceRequestAndWaitForReceiptAsync(IncreaseAllowanceFunction increaseAllowanceFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(increaseAllowanceFunction, cancellationToken);
}
public Task<string> IncreaseAllowanceRequestAsync(string spender, BigInteger addedValue)
{
var increaseAllowanceFunction = new IncreaseAllowanceFunction();
increaseAllowanceFunction.Spender = spender;
increaseAllowanceFunction.AddedValue = addedValue;
return ContractHandler.SendRequestAsync(increaseAllowanceFunction);
}
public Task<TransactionReceipt> IncreaseAllowanceRequestAndWaitForReceiptAsync(string spender, BigInteger addedValue, CancellationTokenSource cancellationToken = null)
{
var increaseAllowanceFunction = new IncreaseAllowanceFunction();
increaseAllowanceFunction.Spender = spender;
increaseAllowanceFunction.AddedValue = addedValue;
return ContractHandler.SendRequestAndWaitForReceiptAsync(increaseAllowanceFunction, cancellationToken);
}
public Task<string> NameQueryAsync(NameFunction nameFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<NameFunction, string>(nameFunction, blockParameter);
}
public Task<string> NameQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<NameFunction, string>(null, blockParameter);
}
public Task<string> RenounceRoleRequestAsync(RenounceRoleFunction renounceRoleFunction)
{
return ContractHandler.SendRequestAsync(renounceRoleFunction);
}
public Task<TransactionReceipt> RenounceRoleRequestAndWaitForReceiptAsync(RenounceRoleFunction renounceRoleFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(renounceRoleFunction, cancellationToken);
}
public Task<string> RenounceRoleRequestAsync(byte[] role, string account)
{
var renounceRoleFunction = new RenounceRoleFunction();
renounceRoleFunction.Role = role;
renounceRoleFunction.Account = account;
return ContractHandler.SendRequestAsync(renounceRoleFunction);
}
public Task<TransactionReceipt> RenounceRoleRequestAndWaitForReceiptAsync(byte[] role, string account, CancellationTokenSource cancellationToken = null)
{
var renounceRoleFunction = new RenounceRoleFunction();
renounceRoleFunction.Role = role;
renounceRoleFunction.Account = account;
return ContractHandler.SendRequestAndWaitForReceiptAsync(renounceRoleFunction, cancellationToken);
}
public Task<string> RevokeRoleRequestAsync(RevokeRoleFunction revokeRoleFunction)
{
return ContractHandler.SendRequestAsync(revokeRoleFunction);
}
public Task<TransactionReceipt> RevokeRoleRequestAndWaitForReceiptAsync(RevokeRoleFunction revokeRoleFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(revokeRoleFunction, cancellationToken);
}
public Task<string> RevokeRoleRequestAsync(byte[] role, string account)
{
var revokeRoleFunction = new RevokeRoleFunction();
revokeRoleFunction.Role = role;
revokeRoleFunction.Account = account;
return ContractHandler.SendRequestAsync(revokeRoleFunction);
}
public Task<TransactionReceipt> RevokeRoleRequestAndWaitForReceiptAsync(byte[] role, string account, CancellationTokenSource cancellationToken = null)
{
var revokeRoleFunction = new RevokeRoleFunction();
revokeRoleFunction.Role = role;
revokeRoleFunction.Account = account;
return ContractHandler.SendRequestAndWaitForReceiptAsync(revokeRoleFunction, cancellationToken);
}
public Task<string> SetBurnStateRequestAsync(SetBurnStateFunction setBurnStateFunction)
{
return ContractHandler.SendRequestAsync(setBurnStateFunction);
}
public Task<TransactionReceipt> SetBurnStateRequestAndWaitForReceiptAsync(SetBurnStateFunction setBurnStateFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(setBurnStateFunction, cancellationToken);
}
public Task<string> SetBurnStateRequestAsync(bool state)
{
var setBurnStateFunction = new SetBurnStateFunction();
setBurnStateFunction.State = state;
return ContractHandler.SendRequestAsync(setBurnStateFunction);
}
public Task<TransactionReceipt> SetBurnStateRequestAndWaitForReceiptAsync(bool state, CancellationTokenSource cancellationToken = null)
{
var setBurnStateFunction = new SetBurnStateFunction();
setBurnStateFunction.State = state;
return ContractHandler.SendRequestAndWaitForReceiptAsync(setBurnStateFunction, cancellationToken);
}
public Task<bool> SupportsInterfaceQueryAsync(SupportsInterfaceFunction supportsInterfaceFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<SupportsInterfaceFunction, bool>(supportsInterfaceFunction, blockParameter);
}
public Task<bool> SupportsInterfaceQueryAsync(byte[] interfaceId, BlockParameter blockParameter = null)
{
var supportsInterfaceFunction = new SupportsInterfaceFunction();
supportsInterfaceFunction.InterfaceId = interfaceId;
return ContractHandler.QueryAsync<SupportsInterfaceFunction, bool>(supportsInterfaceFunction, blockParameter);
}
public Task<string> SymbolQueryAsync(SymbolFunction symbolFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<SymbolFunction, string>(symbolFunction, blockParameter);
}
public Task<string> SymbolQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<SymbolFunction, string>(null, blockParameter);
}
public Task<BigInteger> TotalSupplyQueryAsync(TotalSupplyFunction totalSupplyFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<TotalSupplyFunction, BigInteger>(totalSupplyFunction, blockParameter);
}
public Task<BigInteger> TotalSupplyQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<TotalSupplyFunction, BigInteger>(null, blockParameter);
}
public Task<string> TransferRequestAsync(TransferFunction transferFunction)
{
return ContractHandler.SendRequestAsync(transferFunction);
}
public Task<TransactionReceipt> TransferRequestAndWaitForReceiptAsync(TransferFunction transferFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(transferFunction, cancellationToken);
}
public Task<string> TransferRequestAsync(string to, BigInteger amount)
{
var transferFunction = new TransferFunction();
transferFunction.To = to;
transferFunction.Amount = amount;
return ContractHandler.SendRequestAsync(transferFunction);
}
public Task<TransactionReceipt> TransferRequestAndWaitForReceiptAsync(string to, BigInteger amount, CancellationTokenSource cancellationToken = null)
{
var transferFunction = new TransferFunction();
transferFunction.To = to;
transferFunction.Amount = amount;
return ContractHandler.SendRequestAndWaitForReceiptAsync(transferFunction, cancellationToken);
}
public Task<string> TransferFromRequestAsync(TransferFromFunction transferFromFunction)
{
return ContractHandler.SendRequestAsync(transferFromFunction);
}
public Task<TransactionReceipt> TransferFromRequestAndWaitForReceiptAsync(TransferFromFunction transferFromFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(transferFromFunction, cancellationToken);
}
public Task<string> TransferFromRequestAsync(string from, string to, BigInteger amount)
{
var transferFromFunction = new TransferFromFunction();
transferFromFunction.From = from;
transferFromFunction.To = to;
transferFromFunction.Amount = amount;
return ContractHandler.SendRequestAsync(transferFromFunction);
}
public Task<TransactionReceipt> TransferFromRequestAndWaitForReceiptAsync(string from, string to, BigInteger amount, CancellationTokenSource cancellationToken = null)
{
var transferFromFunction = new TransferFromFunction();
transferFromFunction.From = from;
transferFromFunction.To = to;
transferFromFunction.Amount = amount;
return ContractHandler.SendRequestAndWaitForReceiptAsync(transferFromFunction, cancellationToken);
}
}
}