cs-codex-dist-tests/ProjectPlugins/CodexContractsPlugin/CodexContractsAccess.cs

52 lines
1.8 KiB
C#
Raw Normal View History

2023-09-19 11:39:24 +00:00
using GethPlugin;
using Logging;
namespace CodexContractsPlugin
2023-09-19 08:24:43 +00:00
{
public interface ICodexContracts
{
2023-09-20 08:13:29 +00:00
CodexContractsDeployment Deployment { get; }
2023-09-19 11:39:24 +00:00
2023-09-19 14:22:07 +00:00
void MintTestTokens(IGethNode gethNode, IHasEthAddress owner, TestToken testTokens);
2023-09-20 08:13:29 +00:00
void MintTestTokens(IGethNode gethNode, EthAddress ethAddress, TestToken testTokens);
2023-09-19 14:22:07 +00:00
TestToken GetTestTokenBalance(IGethNode gethNode, IHasEthAddress owner);
2023-09-20 08:13:29 +00:00
TestToken GetTestTokenBalance(IGethNode gethNode, EthAddress ethAddress);
2023-09-19 08:24:43 +00:00
}
public class CodexContractsAccess : ICodexContracts
{
2023-09-19 11:39:24 +00:00
private readonly ILog log;
2023-09-20 08:13:29 +00:00
public CodexContractsAccess(ILog log, CodexContractsDeployment deployment)
2023-09-19 08:24:43 +00:00
{
2023-09-19 11:39:24 +00:00
this.log = log;
Deployment = deployment;
2023-09-19 08:24:43 +00:00
}
2023-09-20 08:13:29 +00:00
public CodexContractsDeployment Deployment { get; }
2023-09-19 11:39:24 +00:00
2023-09-19 14:22:07 +00:00
public void MintTestTokens(IGethNode gethNode, IHasEthAddress owner, TestToken testTokens)
{
MintTestTokens(gethNode, owner.EthAddress, testTokens);
}
2023-09-20 08:13:29 +00:00
public void MintTestTokens(IGethNode gethNode, EthAddress ethAddress, TestToken testTokens)
2023-09-19 11:39:24 +00:00
{
var interaction = new ContractInteractions(log, gethNode);
interaction.MintTestTokens(ethAddress, testTokens.Amount, Deployment.TokenAddress);
2023-09-19 11:39:24 +00:00
}
2023-09-19 14:22:07 +00:00
public TestToken GetTestTokenBalance(IGethNode gethNode, IHasEthAddress owner)
{
return GetTestTokenBalance(gethNode, owner.EthAddress);
}
2023-09-20 08:13:29 +00:00
public TestToken GetTestTokenBalance(IGethNode gethNode, EthAddress ethAddress)
2023-09-19 11:39:24 +00:00
{
var interaction = new ContractInteractions(log, gethNode);
var balance = interaction.GetBalance(Deployment.TokenAddress, ethAddress.Address);
2023-09-19 11:39:24 +00:00
return balance.TestTokens();
}
2023-09-19 08:24:43 +00:00
}
}