feat(wallet): add reusable wallet modules

Add program-neutral wallet access, a stable account model, reusable QML controls, transaction confirmation, submitted-transaction presentation, and isolated contract tests.
This commit is contained in:
Ricardo Guilherme Schmidt
2026-07-24 09:21:25 +02:00
committed by r4bbit
parent e03164baf3
commit dfd19a9796
54 changed files with 3899 additions and 1959 deletions
@@ -0,0 +1,61 @@
#include "WalletAccountModel.h"
WalletAccountModel::WalletAccountModel(QObject* parent)
: QAbstractListModel(parent)
{
}
int WalletAccountModel::rowCount(const QModelIndex& parent) const
{
return parent.isValid() ? 0 : m_accounts.size();
}
QVariant WalletAccountModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid() || index.row() < 0 || index.row() >= m_accounts.size())
return {};
const Entry& account = m_accounts.at(index.row());
switch (role) {
case NameRole:
return account.name;
case AddressRole:
return account.address;
case BalanceRole:
return account.balance;
case IsPublicRole:
return account.isPublic;
default:
return {};
}
}
QHash<int, QByteArray> WalletAccountModel::roleNames() const
{
return {
{ NameRole, "name" },
{ AddressRole, "address" },
{ BalanceRole, "balance" },
{ IsPublicRole, "isPublic" },
};
}
void WalletAccountModel::replaceAccounts(const QVector<WalletAccount>& accounts)
{
beginResetModel();
const qsizetype oldCount = m_accounts.size();
m_accounts.clear();
m_accounts.reserve(accounts.size());
for (qsizetype index = 0; index < accounts.size(); ++index) {
const WalletAccount& account = accounts.at(index);
m_accounts.append({
QStringLiteral("Account %1").arg(index + 1),
account.address,
account.balance,
account.isPublic,
});
}
endResetModel();
if (oldCount != m_accounts.size())
emit countChanged();
}