Applies async/await to getbalance and mint commands

This commit is contained in:
benbierens 2024-04-08 13:36:55 +02:00
parent 9c8151bdb7
commit 9f7e95c515
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
2 changed files with 16 additions and 4 deletions

View File

@ -31,8 +31,14 @@ namespace BiblioTech.Commands
return;
}
var eth = gethNode.GetEthBalance(addr);
var testTokens = contracts.GetTestTokenBalance(addr);
var eth = 0.Eth();
var testTokens = 0.TestTokens();
await Task.Run(() =>
{
eth = gethNode.GetEthBalance(addr);
testTokens = contracts.GetTestTokenBalance(addr);
});
await context.Followup($"{context.Command.User.Username} has {eth} and {testTokens}.");
}

View File

@ -33,8 +33,14 @@ namespace BiblioTech.Commands
var report = new List<string>();
var sentEth = ProcessEth(gethNode, addr, report);
var mintedTokens = ProcessTokens(contracts, addr, report);
Transaction<Ether>? sentEth = null;
Transaction<TestToken>? mintedTokens = null;
await Task.Run(() =>
{
sentEth = ProcessEth(gethNode, addr, report);
mintedTokens = ProcessTokens(contracts, addr, report);
});
Program.UserRepo.AddMintEventForUser(userId, addr, sentEth, mintedTokens);