mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-17 20:39:28 +00:00
Move wallet lifecycle, account-model synchronization, settings, and reachability behind a composition-based WalletController. Keep AmmUiBackend as the QtRO forwarding adapter while retaining direct WalletProvider ownership for program-specific reads and transaction submission. Adopt the thin-consumer direction demonstrated by PR #230 without coupling the shared module to generated QtRO base classes. Refs #227 Refs #230
76 lines
1.9 KiB
C++
76 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "WalletProvider.h"
|
|
|
|
class FakeWalletProvider final : public WalletProvider {
|
|
public:
|
|
WalletSession connectResult;
|
|
WalletCreation createWalletResult;
|
|
WalletSnapshot snapshotResult;
|
|
WalletAccountCreation createAccountResult;
|
|
WalletAccountRead readResult;
|
|
WalletSubmission submissionResult;
|
|
|
|
int connectCalls = 0;
|
|
int createWalletCalls = 0;
|
|
int snapshotCalls = 0;
|
|
int clearCalls = 0;
|
|
int createAccountCalls = 0;
|
|
mutable int readCalls = 0;
|
|
int submitCalls = 0;
|
|
int disconnectCalls = 0;
|
|
bool lastForceRefresh = false;
|
|
bool lastAccountWasPublic = false;
|
|
WalletPaths lastPaths;
|
|
WalletTransaction lastTransaction;
|
|
|
|
WalletSession connect(const WalletPaths& paths) override
|
|
{
|
|
++connectCalls;
|
|
lastPaths = paths;
|
|
return connectResult;
|
|
}
|
|
|
|
WalletCreation createWallet(const WalletPaths& paths,
|
|
const QString&) override
|
|
{
|
|
++createWalletCalls;
|
|
lastPaths = paths;
|
|
return createWalletResult;
|
|
}
|
|
|
|
WalletSnapshot snapshot(bool forceRefresh) override
|
|
{
|
|
++snapshotCalls;
|
|
lastForceRefresh = forceRefresh;
|
|
return snapshotResult;
|
|
}
|
|
|
|
void clearSnapshot() override { ++clearCalls; }
|
|
|
|
WalletAccountCreation createAccount(bool isPublic) override
|
|
{
|
|
++createAccountCalls;
|
|
lastAccountWasPublic = isPublic;
|
|
return createAccountResult;
|
|
}
|
|
|
|
WalletAccountRead readPublicAccount(const QString& accountId) const override
|
|
{
|
|
++readCalls;
|
|
WalletAccountRead result = readResult;
|
|
result.accountId = accountId;
|
|
return result;
|
|
}
|
|
|
|
WalletSubmission submitPublicTransaction(
|
|
const WalletTransaction& transaction) override
|
|
{
|
|
++submitCalls;
|
|
lastTransaction = transaction;
|
|
return submissionResult;
|
|
}
|
|
|
|
void disconnect() override { ++disconnectCalls; }
|
|
};
|