Adds transaction links to mint output
This commit is contained in:
parent
d67ddab290
commit
beaa67c280
@ -17,11 +17,12 @@ namespace NethereumWorkflow
|
|||||||
this.web3 = web3;
|
this.web3 = web3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendEth(string toAddress, decimal ethAmount)
|
public string SendEth(string toAddress, decimal ethAmount)
|
||||||
{
|
{
|
||||||
log.Debug();
|
log.Debug();
|
||||||
var receipt = Time.Wait(web3.Eth.GetEtherTransferService().TransferEtherAndWaitForReceiptAsync(toAddress, ethAmount));
|
var receipt = Time.Wait(web3.Eth.GetEtherTransferService().TransferEtherAndWaitForReceiptAsync(toAddress, ethAmount));
|
||||||
if (!receipt.Succeeded()) throw new Exception("Unable to send Eth");
|
if (!receipt.Succeeded()) throw new Exception("Unable to send Eth");
|
||||||
|
return receipt.TransactionHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal GetEthBalance()
|
public decimal GetEthBalance()
|
||||||
@ -44,12 +45,13 @@ namespace NethereumWorkflow
|
|||||||
return Time.Wait(handler.QueryAsync<TResult>(contractAddress, function));
|
return Time.Wait(handler.QueryAsync<TResult>(contractAddress, function));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendTransaction<TFunction>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new()
|
public string SendTransaction<TFunction>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new()
|
||||||
{
|
{
|
||||||
log.Debug();
|
log.Debug();
|
||||||
var handler = web3.Eth.GetContractTransactionHandler<TFunction>();
|
var handler = web3.Eth.GetContractTransactionHandler<TFunction>();
|
||||||
var receipt = Time.Wait(handler.SendRequestAndWaitForReceiptAsync(contractAddress, function));
|
var receipt = Time.Wait(handler.SendRequestAndWaitForReceiptAsync(contractAddress, function));
|
||||||
if (!receipt.Succeeded()) throw new Exception("Unable to perform contract transaction.");
|
if (!receipt.Succeeded()) throw new Exception("Unable to perform contract transaction.");
|
||||||
|
return receipt.TransactionHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal? GetSyncedBlockNumber()
|
public decimal? GetSyncedBlockNumber()
|
||||||
|
@ -7,8 +7,8 @@ namespace CodexContractsPlugin
|
|||||||
{
|
{
|
||||||
CodexContractsDeployment Deployment { get; }
|
CodexContractsDeployment Deployment { get; }
|
||||||
|
|
||||||
void MintTestTokens(IHasEthAddress owner, TestToken testTokens);
|
string MintTestTokens(IHasEthAddress owner, TestToken testTokens);
|
||||||
void MintTestTokens(EthAddress ethAddress, TestToken testTokens);
|
string MintTestTokens(EthAddress ethAddress, TestToken testTokens);
|
||||||
TestToken GetTestTokenBalance(IHasEthAddress owner);
|
TestToken GetTestTokenBalance(IHasEthAddress owner);
|
||||||
TestToken GetTestTokenBalance(EthAddress ethAddress);
|
TestToken GetTestTokenBalance(EthAddress ethAddress);
|
||||||
}
|
}
|
||||||
@ -27,15 +27,15 @@ namespace CodexContractsPlugin
|
|||||||
|
|
||||||
public CodexContractsDeployment Deployment { get; }
|
public CodexContractsDeployment Deployment { get; }
|
||||||
|
|
||||||
public void MintTestTokens(IHasEthAddress owner, TestToken testTokens)
|
public string MintTestTokens(IHasEthAddress owner, TestToken testTokens)
|
||||||
{
|
{
|
||||||
MintTestTokens(owner.EthAddress, testTokens);
|
return MintTestTokens(owner.EthAddress, testTokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MintTestTokens(EthAddress ethAddress, TestToken testTokens)
|
public string MintTestTokens(EthAddress ethAddress, TestToken testTokens)
|
||||||
{
|
{
|
||||||
var interaction = new ContractInteractions(log, gethNode);
|
var interaction = new ContractInteractions(log, gethNode);
|
||||||
interaction.MintTestTokens(ethAddress, testTokens.Amount, Deployment.TokenAddress);
|
return interaction.MintTestTokens(ethAddress, testTokens.Amount, Deployment.TokenAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestToken GetTestTokenBalance(IHasEthAddress owner)
|
public TestToken GetTestTokenBalance(IHasEthAddress owner)
|
||||||
|
@ -26,10 +26,10 @@ namespace CodexContractsPlugin
|
|||||||
return gethNode.Call<GetTokenFunction, string>(marketplaceAddress, function);
|
return gethNode.Call<GetTokenFunction, string>(marketplaceAddress, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MintTestTokens(EthAddress address, decimal amount, string tokenAddress)
|
public string MintTestTokens(EthAddress address, decimal amount, string tokenAddress)
|
||||||
{
|
{
|
||||||
log.Debug($"{amount} -> {address} (token: {tokenAddress})");
|
log.Debug($"{amount} -> {address} (token: {tokenAddress})");
|
||||||
MintTokens(address.Address, amount, tokenAddress);
|
return MintTokens(address.Address, amount, tokenAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal GetBalance(string tokenAddress, string account)
|
public decimal GetBalance(string tokenAddress, string account)
|
||||||
@ -56,7 +56,7 @@ namespace CodexContractsPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MintTokens(string account, decimal amount, string tokenAddress)
|
private string MintTokens(string account, decimal amount, string tokenAddress)
|
||||||
{
|
{
|
||||||
log.Debug($"({tokenAddress}) {amount} --> {account}");
|
log.Debug($"({tokenAddress}) {amount} --> {account}");
|
||||||
if (string.IsNullOrEmpty(account)) throw new ArgumentException("Invalid arguments for MintTestTokens");
|
if (string.IsNullOrEmpty(account)) throw new ArgumentException("Invalid arguments for MintTestTokens");
|
||||||
@ -67,7 +67,7 @@ namespace CodexContractsPlugin
|
|||||||
Amount = amount.ToBig()
|
Amount = amount.ToBig()
|
||||||
};
|
};
|
||||||
|
|
||||||
gethNode.SendTransaction(tokenAddress, function);
|
return gethNode.SendTransaction(tokenAddress, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsBlockNumberOK()
|
private bool IsBlockNumberOK()
|
||||||
|
@ -13,10 +13,10 @@ namespace GethPlugin
|
|||||||
Ether GetEthBalance();
|
Ether GetEthBalance();
|
||||||
Ether GetEthBalance(IHasEthAddress address);
|
Ether GetEthBalance(IHasEthAddress address);
|
||||||
Ether GetEthBalance(EthAddress address);
|
Ether GetEthBalance(EthAddress address);
|
||||||
void SendEth(IHasEthAddress account, Ether eth);
|
string SendEth(IHasEthAddress account, Ether eth);
|
||||||
void SendEth(EthAddress account, Ether eth);
|
string SendEth(EthAddress account, Ether eth);
|
||||||
TResult Call<TFunction, TResult>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new();
|
TResult Call<TFunction, TResult>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new();
|
||||||
void SendTransaction<TFunction>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new();
|
string SendTransaction<TFunction>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new();
|
||||||
decimal? GetSyncedBlockNumber();
|
decimal? GetSyncedBlockNumber();
|
||||||
bool IsContractAvailable(string abi, string contractAddress);
|
bool IsContractAvailable(string abi, string contractAddress);
|
||||||
GethBootstrapNode GetBootstrapRecord();
|
GethBootstrapNode GetBootstrapRecord();
|
||||||
@ -103,14 +103,14 @@ namespace GethPlugin
|
|||||||
return StartInteraction().GetEthBalance(address.Address).Eth();
|
return StartInteraction().GetEthBalance(address.Address).Eth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendEth(IHasEthAddress owner, Ether eth)
|
public string SendEth(IHasEthAddress owner, Ether eth)
|
||||||
{
|
{
|
||||||
SendEth(owner.EthAddress, eth);
|
return SendEth(owner.EthAddress, eth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendEth(EthAddress account, Ether eth)
|
public string SendEth(EthAddress account, Ether eth)
|
||||||
{
|
{
|
||||||
StartInteraction().SendEth(account.Address, eth.Eth);
|
return StartInteraction().SendEth(account.Address, eth.Eth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TResult Call<TFunction, TResult>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new()
|
public TResult Call<TFunction, TResult>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new()
|
||||||
@ -118,9 +118,9 @@ namespace GethPlugin
|
|||||||
return StartInteraction().Call<TFunction, TResult>(contractAddress, function);
|
return StartInteraction().Call<TFunction, TResult>(contractAddress, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendTransaction<TFunction>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new()
|
public string SendTransaction<TFunction>(string contractAddress, TFunction function) where TFunction : FunctionMessage, new()
|
||||||
{
|
{
|
||||||
StartInteraction().SendTransaction(contractAddress, function);
|
return StartInteraction().SendTransaction(contractAddress, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal? GetSyncedBlockNumber()
|
public decimal? GetSyncedBlockNumber()
|
||||||
|
@ -47,12 +47,12 @@ namespace BiblioTech.Commands
|
|||||||
{
|
{
|
||||||
if (ShouldMintTestTokens(contracts, addr))
|
if (ShouldMintTestTokens(contracts, addr))
|
||||||
{
|
{
|
||||||
contracts.MintTestTokens(addr, defaultTestTokensToMint);
|
var transaction = contracts.MintTestTokens(addr, defaultTestTokensToMint);
|
||||||
report.Add($"Minted {defaultTestTokensToMint}.");
|
report.Add($"Minted {defaultTestTokensToMint}. ({FormatTransactionLink(transaction)})");
|
||||||
return defaultTestTokensToMint;
|
return defaultTestTokensToMint;
|
||||||
}
|
}
|
||||||
|
|
||||||
report.Add("TestToken balance over threshold.");
|
report.Add("TestToken balance over threshold. (No TestTokens minted.)");
|
||||||
return 0.TestTokens();
|
return 0.TestTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ namespace BiblioTech.Commands
|
|||||||
{
|
{
|
||||||
if (ShouldSendEth(gethNode, addr))
|
if (ShouldSendEth(gethNode, addr))
|
||||||
{
|
{
|
||||||
gethNode.SendEth(addr, defaultEthToSend);
|
var transaction = gethNode.SendEth(addr, defaultEthToSend);
|
||||||
report.Add($"Sent {defaultEthToSend}.");
|
report.Add($"Sent {defaultEthToSend}. ({FormatTransactionLink(transaction)})");
|
||||||
return defaultEthToSend;
|
return defaultEthToSend;
|
||||||
}
|
}
|
||||||
report.Add("Eth balance is over threshold.");
|
report.Add("Eth balance is over threshold. (No Eth sent.)");
|
||||||
return 0.Eth();
|
return 0.Eth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,5 +79,10 @@ namespace BiblioTech.Commands
|
|||||||
var eth = gethNode.GetEthBalance(addr);
|
var eth = gethNode.GetEthBalance(addr);
|
||||||
return eth.Eth < 1.0m;
|
return eth.Eth < 1.0m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string FormatTransactionLink(string transaction)
|
||||||
|
{
|
||||||
|
return $"https://explorer.testnet.codex.storage/tx/{transaction}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user