2
0
mirror of synced 2025-01-11 09:06:56 +00:00

Merge branch 'master' into feature/bot-upgrade

This commit is contained in:
benbierens 2023-12-19 14:02:31 +01:00
commit fb57998aa8
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
12 changed files with 84 additions and 17 deletions

28
.github/workflows/docker-discordbot.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Docker - Discord Bot
on:
push:
branches:
- master
tags:
- 'v*.*.*'
paths:
- 'Tools/BiblioTech/**'
- '!Tools/BiblioTech/docker/docker-compose.yaml'
- 'Framework/**'
- 'ProjectPlugins/**'
- .github/workflows/docker-discordbot.yml
- .github/workflows/docker-reusable.yml
workflow_dispatch:
jobs:
build-and-push:
name: Build and Push
uses: ./.github/workflows/docker-reusable.yml
with:
docker_file: Tools/BiblioTech/docker/Dockerfile
docker_repo: codexstorage/codex-discordbot
secrets: inherit

View File

@ -1,4 +1,4 @@
name: Docker
name: Docker - Runner
on:
@ -10,7 +10,7 @@ on:
paths:
- docker/Dockerfile
- docker/docker-entrypoint.sh
- .github/workflows/docker.yml
- .github/workflows/docker-runner.yml
- .github/workflows/docker-reusable.yml
workflow_dispatch:

View File

@ -3,17 +3,17 @@ name: Report - HoldMyBeerTest
on:
schedule:
- cron: '30 * */2 * *'
- cron: '30 1 */2 * *'
workflow_dispatch:
jobs:
run_tests:
name: Call runner
uses: ./.github/workflows/continuous-tests.yaml
uses: ./.github/workflows/run-continuous-tests.yaml
with:
source: ${{ format('{0}/{1}', github.server_url, github.repository) }}
branch: master
nameprefix: c-tests-report-holdmybeertest
nameprefix: c-tests-report-holdmybeertest-48h
tests_target_duration: 48h
tests_filter: HoldMyBeerTest
tests_cleanup: true

View File

@ -3,17 +3,17 @@ name: Report - PeersTest
on:
schedule:
- cron: '30 * */2 * *'
- cron: '30 1 */2 * *'
workflow_dispatch:
jobs:
run_tests:
name: Call runner
uses: ./.github/workflows/continuous-tests.yaml
uses: ./.github/workflows/run-continuous-tests.yaml
with:
source: ${{ format('{0}/{1}', github.server_url, github.repository) }}
branch: master
nameprefix: c-tests-report-peerstest
nameprefix: c-tests-report-peerstest-48h
tests_target_duration: 48h
tests_filter: PeersTest
tests_cleanup: true

View File

@ -7,6 +7,7 @@ namespace CodexContractsPlugin
{
CodexContractsDeployment Deployment { get; }
bool IsDeployed();
string MintTestTokens(IHasEthAddress owner, TestToken testTokens);
string MintTestTokens(EthAddress ethAddress, TestToken testTokens);
TestToken GetTestTokenBalance(IHasEthAddress owner);
@ -27,6 +28,12 @@ namespace CodexContractsPlugin
public CodexContractsDeployment Deployment { get; }
public bool IsDeployed()
{
var interaction = new ContractInteractions(log, gethNode);
return !string.IsNullOrEmpty(interaction.GetTokenName(Deployment.TokenAddress));
}
public string MintTestTokens(IHasEthAddress owner, TestToken testTokens)
{
return MintTestTokens(owner.EthAddress, testTokens);

View File

@ -26,6 +26,22 @@ namespace CodexContractsPlugin
return gethNode.Call<GetTokenFunction, string>(marketplaceAddress, function);
}
public string GetTokenName(string tokenAddress)
{
try
{
log.Debug(tokenAddress);
var function = new GetTokenNameFunction();
return gethNode.Call<GetTokenNameFunction, string>(tokenAddress, function);
}
catch (Exception ex)
{
log.Log("Failed to get token name: " + ex);
return string.Empty;
}
}
public string MintTestTokens(EthAddress address, decimal amount, string tokenAddress)
{
log.Debug($"{amount} -> {address} (token: {tokenAddress})");
@ -87,6 +103,11 @@ namespace CodexContractsPlugin
{
}
[Function("name", "string")]
public class GetTokenNameFunction : FunctionMessage
{
}
[Function("mint")]
public class MintTokensFunction : FunctionMessage
{

View File

@ -59,12 +59,10 @@ namespace BiblioTech
{
protected override async Task Invoke(CommandContext context)
{
var log = new ConsoleLog();
if (!string.IsNullOrEmpty(GethInput.LoadError))
{
var msg = "Geth input incorrect: " + GethInput.LoadError;
log.Error(msg);
Program.Log.Error(msg);
if (IsInAdminChannel(context.Command))
{
await context.Followup(msg);
@ -82,8 +80,14 @@ namespace BiblioTech
tokenAddress: GethInput.TokenAddress
);
var gethNode = new CustomGethNode(log, GethInput.GethHost, GethInput.GethPort, GethInput.PrivateKey);
var contracts = new CodexContractsAccess(log, gethNode, contractsDeployment);
var gethNode = new CustomGethNode(Program.Log, GethInput.GethHost, GethInput.GethPort, GethInput.PrivateKey);
var contracts = new CodexContractsAccess(Program.Log, gethNode, contractsDeployment);
if (!contracts.IsDeployed())
{
await context.Followup("I'm sorry, the Codex SmartContracts are not currently deployed.");
return;
}
await Execute(context, gethNode, contracts);
}

View File

@ -83,7 +83,7 @@ namespace BiblioTech.Commands
private string FormatTransactionLink(string transaction)
{
var url = $"https://explorer.testnet.codex.storage/tx/{transaction}";
return $"- [View on block explorer]({url}){Environment.NewLine}Transaction ID - `{transaction}`";
return $"- [View on block explorer](<{url}>){Environment.NewLine}Transaction ID - `{transaction}`";
}
}
}

View File

@ -19,7 +19,7 @@
public static string Get()
{
return "Hold on: " + messages[random.Next(messages.Length)];
return "(⏳): " + messages[random.Next(messages.Length)];
}
}
}

View File

@ -1,7 +1,14 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0
# Variables
ARG IMAGE=mcr.microsoft.com/dotnet/sdk:7.0
ARG APP_HOME=/app
WORKDIR app
# Create
FROM ${IMAGE}
ARG APP_HOME
WORKDIR ${APP_HOME}
COPY ./Tools/BiblioTech ./Tools/BiblioTech
COPY ./Framework ./Framework
COPY ./ProjectPlugins ./ProjectPlugins
CMD ["dotnet", "run", "--project", "Tools/BiblioTech"]