2022-02-14 14:38:41 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "wallet_accounts/service.h"
|
|
|
|
|
|
|
|
#include "backend/wallet_accounts.h"
|
|
|
|
|
|
|
|
namespace Wallets
|
|
|
|
{
|
|
|
|
|
|
|
|
Service::Service()
|
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void Service::init()
|
|
|
|
{
|
|
|
|
fetchAccounts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Service::fetchAccounts()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
auto response = Backend::Wallet::Accounts::getAccounts();
|
|
|
|
QVector<WalletAccountDto> result;
|
|
|
|
foreach(const QJsonValue& value, response.m_result)
|
|
|
|
{
|
|
|
|
auto account = toWalletAccountDto(value);
|
2022-02-21 18:03:38 +00:00
|
|
|
if(!account.isChat) m_walletAccounts[account.address] = account;
|
2022-02-14 14:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Backend::RpcException& e)
|
|
|
|
{
|
|
|
|
qWarning() << e.what();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<WalletAccountDto> Service::getWalletAccounts()
|
|
|
|
{
|
|
|
|
return m_walletAccounts.values();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Wallets
|