adapt to logos-blockchain-module using module-builder

This commit is contained in:
Khushboo Mehta 2026-04-23 03:31:09 +02:00
parent 93e4c38880
commit a7dabebe35
3 changed files with 12124 additions and 612 deletions

12673
flake.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -12,33 +12,5 @@
src = ./.;
configFile = ./metadata.json;
flakeInputs = inputs;
# The blockchain module is a legacy Rust module that does not ship a
# generated *_api.h header. The logos-cpp-generator --general-only step
# produces logos_sdk.h which #include's the missing header. Create an
# empty stub so compilation succeeds — we use the raw LogosAPIClient
# interface directly instead of the generated type-safe wrappers.
preConfigure = ''
mkdir -p ./generated_code/include
# The blockchain module is a legacy Rust module that does not ship a
# generated *_api.h header. Create a minimal stub so logos_sdk.h
# compiles — we use the raw LogosAPIClient interface directly.
for dir in ./generated_code/include ./generated_code; do
if [ ! -f "$dir/liblogos_blockchain_module_api.h" ]; then
cat > "$dir/liblogos_blockchain_module_api.h" << 'STUB'
#pragma once
#include "logos_api.h"
class LiblogosBlockchainModule {
public:
explicit LiblogosBlockchainModule(LogosAPI*) {}
};
STUB
fi
if [ ! -f "$dir/liblogos_blockchain_module_api.cpp" ]; then
echo "// Stub" > "$dir/liblogos_blockchain_module_api.cpp"
fi
done
'';
};
}

View File

@ -11,6 +11,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QSettings>
#include <QSignalBlocker>
#include <QTimer>
#include <QUrl>
#include <QVariant>
@ -18,6 +19,13 @@
const QString BlockchainBackend::BLOCKCHAIN_MODULE_NAME =
QStringLiteral("liblogos_blockchain_module");
static QString toLocalPath(const QString& pathInput)
{
if (pathInput.trimmed().isEmpty())
return pathInput;
return QUrl::fromUserInput(pathInput).toLocalFile();
}
BlockchainBackend::BlockchainBackend(LogosAPI* logosAPI, QObject* parent)
: BlockchainBackendSimpleSource(parent)
, m_logosAPI(logosAPI)
@ -39,19 +47,31 @@ BlockchainBackend::BlockchainBackend(LogosAPI* logosAPI, QObject* parent)
s.value("deploymentConfigPath").toString();
if (!envConfigPath.isEmpty())
setUserConfig(envConfigPath);
setUserConfig(toLocalPath(envConfigPath));
else if (!savedUserConfig.isEmpty())
setUserConfig(savedUserConfig);
setUserConfig(toLocalPath(savedUserConfig));
if (!savedDeploymentConfig.isEmpty())
setDeploymentConfig(savedDeploymentConfig);
setDeploymentConfig(toLocalPath(savedDeploymentConfig));
// Persist config paths on change
// Re-apply pre-.rep behavior: normalize file URLs, then persist (as master did in setters).
connect(this, &BlockchainBackendSimpleSource::userConfigChanged, this, [this]() {
const QString p = userConfig();
const QString n = toLocalPath(p);
if (n != p) {
QSignalBlocker b(this);
setUserConfig(n);
}
QSettings("Logos", "BlockchainUI")
.setValue("userConfigPath", userConfig());
});
connect(this, &BlockchainBackendSimpleSource::deploymentConfigChanged, this, [this]() {
const QString p = deploymentConfig();
const QString n = toLocalPath(p);
if (n != p) {
QSignalBlocker b(this);
setDeploymentConfig(n);
}
QSettings("Logos", "BlockchainUI")
.setValue("deploymentConfigPath", deploymentConfig());
});
@ -197,13 +217,6 @@ QString BlockchainBackend::transferFunds(
: QStringLiteral("Error: Call failed.");
}
static QString toLocalPath(const QString& pathInput)
{
if (pathInput.trimmed().isEmpty())
return pathInput;
return QUrl::fromUserInput(pathInput).toLocalFile();
}
int BlockchainBackend::generateConfig(
QString outputPath, QStringList initialPeers, int netPort, int blendPort,
QString httpAddr, QString externalAddress, bool noPublicIpCheck,