2023-09-19 13:39:24 +02:00

44 lines
1.4 KiB
C#

using GethPlugin;
using Logging;
namespace CodexContractsPlugin
{
public interface ICodexContracts
{
string MarketplaceAddress { get; }
void MintTestTokens(IGethNode gethNode, IEthAddress ethAddress, TestToken testTokens);
TestToken GetTestTokenBalance(IGethNode gethNode, IEthAddress ethAddress);
}
public class CodexContractsAccess : ICodexContracts
{
private readonly ILog log;
public CodexContractsAccess(ILog log, string marketplaceAddress, string abi, string tokenAddress)
{
this.log = log;
MarketplaceAddress = marketplaceAddress;
Abi = abi;
TokenAddress = tokenAddress;
}
public string MarketplaceAddress { get; }
public string Abi { get; }
public string TokenAddress { get; }
public void MintTestTokens(IGethNode gethNode, IEthAddress ethAddress, TestToken testTokens)
{
var interaction = new ContractInteractions(log, gethNode);
interaction.MintTestTokens(ethAddress, testTokens.Amount, TokenAddress);
}
public TestToken GetTestTokenBalance(IGethNode gethNode, IEthAddress ethAddress)
{
var interaction = new ContractInteractions(log, gethNode);
var balance = interaction.GetBalance(TokenAddress, ethAddress.Address);
return balance.TestTokens();
}
}
}