logos-execution-zone-wallet-ui/src/LEZWalletBackend.h

90 lines
3.9 KiB
C
Raw Normal View History

#ifndef LEZ_WALLET_BACKEND_H
#define LEZ_WALLET_BACKEND_H
2026-02-20 14:20:39 +01:00
#include <QObject>
#include <QString>
#include "rep_LEZWalletBackend_source.h"
2026-02-22 02:03:13 +05:30
#include "LEZAccountFilterModel.h"
2026-06-16 21:02:54 -03:00
#include "LEZClaimableAccountFilterModel.h"
2026-02-22 02:03:13 +05:30
#include "LEZWalletAccountModel.h"
2026-02-20 14:20:39 +01:00
class LogosAPI;
struct LogosModules;
2026-02-22 02:03:13 +05:30
// Source-side implementation of the LEZWalletBackend .rep interface.
// Inheriting from LEZWalletBackendSimpleSource gives us the generated PROPs
// and SLOTs from LEZWalletBackend.rep — all the simple ones flow over QtRO.
class LEZWalletBackend : public LEZWalletBackendSimpleSource {
2026-02-20 14:20:39 +01:00
Q_OBJECT
Q_PROPERTY(LEZWalletAccountModel* accountModel READ accountModel CONSTANT)
Q_PROPERTY(LEZAccountFilterModel* filteredAccountModel READ filteredAccountModel CONSTANT)
Q_PROPERTY(LEZAccountFilterModel* privateAccountModel READ privateAccountModel CONSTANT)
2026-06-16 21:02:54 -03:00
Q_PROPERTY(LEZClaimableAccountFilterModel* claimableAccountModel READ claimableAccountModel CONSTANT)
2026-02-20 14:20:39 +01:00
public:
explicit LEZWalletBackend(LogosAPI* logosAPI = nullptr, QObject* parent = nullptr);
~LEZWalletBackend() override;
2026-02-20 14:20:39 +01:00
2026-02-22 02:03:13 +05:30
LEZWalletAccountModel* accountModel() const { return m_accountModel; }
LEZAccountFilterModel* filteredAccountModel() const { return m_filteredAccountModel; }
LEZAccountFilterModel* privateAccountModel() const { return m_privateAccountModel; }
2026-06-16 21:02:54 -03:00
LEZClaimableAccountFilterModel* claimableAccountModel() const { return m_claimableAccountModel; }
2026-02-20 14:20:39 +01:00
public slots:
// Overrides of the pure-virtual slots generated from the .rep.
QString createAccountPublic() override;
QString createAccountPrivate() override;
void refreshAccounts() override;
QString getBalance(QString accountIdHex, bool isPublic) override;
void refreshBalances() override;
QString getPublicAccountKey(QString accountIdHex) override;
QString getPrivateAccountKeys(QString accountIdHex) override;
2026-07-03 23:43:48 -03:00
QString initializeAccount(QString accountIdHex, bool isPublic) override;
bool syncToBlock(quint64 blockId) override;
QString transferPublic(QString fromHex, QString toHex, QString amountStr) override;
QString transferPrivate(QString fromHex, QString toHex, QString amountStr) override;
QString transferPrivateOwned(QString fromHex, QString toHex, QString amountStr) override;
2026-06-04 23:34:11 -03:00
QString transferShielded(QString fromHex, QString toKeysJson, QString amountStr) override;
QString transferShieldedOwned(QString fromHex, QString toHex, QString amountStr) override;
2026-06-05 00:14:43 -03:00
QString transferDeshielded(QString fromHex, QString toHex, QString amountStr) override;
2026-06-16 21:02:54 -03:00
QString bridgeWithdraw(QString fromHex, QString bedrockAccountPkHex, quint64 amount) override;
void refreshVaultBalances() override;
QString vaultClaim(QString fromHex, bool isPublic, QString amountStr) override;
QString createNew(QString configPath, QString storagePath, QString password, QString sequencerAddr) override;
void copyToClipboard(QString text) override;
2026-02-20 14:20:39 +01:00
2026-06-05 04:01:21 -03:00
private slots:
void syncNextChunk();
2026-02-20 14:20:39 +01:00
private:
void persistConfigPath(const QString& path);
void persistStoragePath(const QString& path);
2026-06-05 03:24:03 -03:00
void applySequencerAddrToConfig(const QString& configPath, const QString& sequencerAddr);
2026-06-05 04:01:21 -03:00
void fetchAndUpdateBlockHeights();
void startChunkedSync();
2026-06-16 21:02:54 -03:00
QVariantList buildEnrichedAccountList();
2026-06-05 04:01:21 -03:00
void updateBalances();
2026-06-16 21:02:54 -03:00
QString getVaultBalance(const QString& accountIdHex);
2026-02-20 14:20:39 +01:00
void refreshSequencerAddr();
void saveWallet();
2026-06-16 21:02:54 -03:00
void openIfPathsConfigured(int attempt = 0);
void finishOpeningWallet();
2026-02-20 14:20:39 +01:00
2026-06-05 04:01:21 -03:00
bool m_syncing = false;
quint64 m_syncTarget = 0;
static constexpr quint64 SYNC_CHUNK_SIZE = 100;
2026-02-22 02:03:13 +05:30
LEZWalletAccountModel* m_accountModel;
LEZAccountFilterModel* m_filteredAccountModel;
LEZAccountFilterModel* m_privateAccountModel;
2026-06-16 21:02:54 -03:00
LEZClaimableAccountFilterModel* m_claimableAccountModel;
2026-02-20 14:20:39 +01:00
LogosAPI* m_logosAPI;
LogosModules* m_logos;
2026-02-20 14:20:39 +01:00
};
#endif // LEZ_WALLET_BACKEND_H