2023-09-19 11:39:24 +00:00
|
|
|
|
using GethPlugin;
|
|
|
|
|
using Logging;
|
2023-12-20 08:48:22 +00:00
|
|
|
|
using Utils;
|
2023-09-19 11:39:24 +00:00
|
|
|
|
|
|
|
|
|
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-12-18 12:32:58 +00:00
|
|
|
|
bool IsDeployed();
|
2023-12-15 10:02:06 +00:00
|
|
|
|
string MintTestTokens(IHasEthAddress owner, TestToken testTokens);
|
|
|
|
|
string MintTestTokens(EthAddress ethAddress, TestToken testTokens);
|
2023-10-30 12:30:14 +00:00
|
|
|
|
TestToken GetTestTokenBalance(IHasEthAddress owner);
|
|
|
|
|
TestToken GetTestTokenBalance(EthAddress ethAddress);
|
2023-12-20 08:48:22 +00:00
|
|
|
|
|
|
|
|
|
void GetStorageRequests(TimeRange range);
|
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-10-30 12:30:14 +00:00
|
|
|
|
private readonly IGethNode gethNode;
|
2023-09-19 11:39:24 +00:00
|
|
|
|
|
2023-10-30 12:30:14 +00:00
|
|
|
|
public CodexContractsAccess(ILog log, IGethNode gethNode, CodexContractsDeployment deployment)
|
2023-09-19 08:24:43 +00:00
|
|
|
|
{
|
2023-09-19 11:39:24 +00:00
|
|
|
|
this.log = log;
|
2023-10-30 12:30:14 +00:00
|
|
|
|
this.gethNode = gethNode;
|
2023-09-20 07:16:57 +00:00
|
|
|
|
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-12-18 12:32:58 +00:00
|
|
|
|
public bool IsDeployed()
|
|
|
|
|
{
|
2023-12-20 08:48:22 +00:00
|
|
|
|
return !string.IsNullOrEmpty(StartInteraction().GetTokenName(Deployment.TokenAddress));
|
2023-12-18 12:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-15 10:02:06 +00:00
|
|
|
|
public string MintTestTokens(IHasEthAddress owner, TestToken testTokens)
|
2023-09-19 14:22:07 +00:00
|
|
|
|
{
|
2023-12-15 10:02:06 +00:00
|
|
|
|
return MintTestTokens(owner.EthAddress, testTokens);
|
2023-09-19 14:22:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-15 10:02:06 +00:00
|
|
|
|
public string MintTestTokens(EthAddress ethAddress, TestToken testTokens)
|
2023-09-19 11:39:24 +00:00
|
|
|
|
{
|
2023-12-20 08:48:22 +00:00
|
|
|
|
return StartInteraction().MintTestTokens(ethAddress, testTokens.Amount, Deployment.TokenAddress);
|
2023-09-19 11:39:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-30 12:30:14 +00:00
|
|
|
|
public TestToken GetTestTokenBalance(IHasEthAddress owner)
|
2023-09-19 14:22:07 +00:00
|
|
|
|
{
|
2023-10-30 12:30:14 +00:00
|
|
|
|
return GetTestTokenBalance(owner.EthAddress);
|
2023-09-19 14:22:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-30 12:30:14 +00:00
|
|
|
|
public TestToken GetTestTokenBalance(EthAddress ethAddress)
|
2023-09-19 11:39:24 +00:00
|
|
|
|
{
|
2023-12-20 08:48:22 +00:00
|
|
|
|
var balance = StartInteraction().GetBalance(Deployment.TokenAddress, ethAddress.Address);
|
2023-09-19 11:39:24 +00:00
|
|
|
|
return balance.TestTokens();
|
|
|
|
|
}
|
2023-12-20 08:48:22 +00:00
|
|
|
|
|
|
|
|
|
public void GetStorageRequests(TimeRange timeRange)
|
|
|
|
|
{
|
|
|
|
|
var events = gethNode.GetEvents<Marketplace.StorageRequestedEventDTO>(Deployment.MarketplaceAddress, timeRange);
|
|
|
|
|
var iii = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ContractInteractions StartInteraction()
|
|
|
|
|
{
|
|
|
|
|
return new ContractInteractions(log, gethNode);
|
|
|
|
|
}
|
2023-09-19 08:24:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|