diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml index 88f939d393..33faacd0ab 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml @@ -39,6 +39,13 @@ Item { onBalanceResult : { balanceText.text = parseFloat(result.data.balance/100).toFixed(2); } + + onHistoryResult : { + if (result.status === 'success') { + var txt = result.data.history.map(function (h) { return h.text; }).join("
"); + transactionHistoryText.text = txt; + } + } } SecurityImageModel { @@ -105,6 +112,7 @@ Item { onVisibleChanged: { if (visible) { commerce.balance(); + commerce.history(); } } } @@ -227,17 +235,14 @@ Item { anchors.right: parent.right; // some placeholder stuff - RalewayRegular { - text: homeMessage.visible ? "you CANNOT scroll through this." : "you CAN scroll through this"; - // Text size - size: 16; - // Anchors + TextArea { + id: transactionHistoryText; + text: "
history unavailable
"; + textFormat: TextEdit.AutoText; + font.pointSize: 10; anchors.fill: parent; - // Style - color: hifi.colors.darkGray; - // Alignment - horizontalAlignment: Text.AlignHCenter; - verticalAlignment: Text.AlignVCenter; + horizontalAlignment: Text.AlignLeft; + verticalAlignment: Text.AlignTop; } } @@ -351,6 +356,7 @@ Item { } } signal sendSignalToWallet(var msg); + // // FUNCTION DEFINITIONS END // diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index 55ee0e16e9..dddfae6455 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -45,6 +45,7 @@ Handler(buy) Handler(receiveAt) Handler(balance) Handler(inventory) +Handler(history) void Ledger::send(const QString& endpoint, const QString& success, const QString& fail, QNetworkAccessManager::Operation method, QJsonObject request) { auto accountManager = DependencyManager::get(); @@ -107,3 +108,6 @@ void Ledger::inventory(const QStringList& keys) { keysQuery("inventory", "inventorySuccess", "inventoryFailure"); } +void Ledger::history(const QStringList& keys) { + keysQuery("history", "historySuccess", "historyFailure"); +} diff --git a/interface/src/commerce/Ledger.h b/interface/src/commerce/Ledger.h index e43b8453b9..7d3fdef0c0 100644 --- a/interface/src/commerce/Ledger.h +++ b/interface/src/commerce/Ledger.h @@ -28,12 +28,14 @@ public: bool receiveAt(const QString& hfc_key, const QString& old_key); void balance(const QStringList& keys); void inventory(const QStringList& keys); + void history(const QStringList& keys); signals: void buyResult(QJsonObject result); void receiveAtResult(QJsonObject result); void balanceResult(QJsonObject result); void inventoryResult(QJsonObject result); + void historyResult(QJsonObject result); public slots: void buySuccess(QNetworkReply& reply); @@ -44,6 +46,8 @@ public slots: void balanceFailure(QNetworkReply& reply); void inventorySuccess(QNetworkReply& reply); void inventoryFailure(QNetworkReply& reply); + void historySuccess(QNetworkReply& reply); + void historyFailure(QNetworkReply& reply); private: QJsonObject apiResponse(const QString& label, QNetworkReply& reply); diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index a5ae008a36..bf6bcc221c 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -25,6 +25,7 @@ QmlCommerce::QmlCommerce(QQuickItem* parent) : OffscreenQmlDialog(parent) { connect(ledger.data(), &Ledger::balanceResult, this, &QmlCommerce::balanceResult); connect(ledger.data(), &Ledger::inventoryResult, this, &QmlCommerce::inventoryResult); connect(wallet.data(), &Wallet::securityImageResult, this, &QmlCommerce::securityImageResult); + connect(ledger.data(), &Ledger::historyResult, this, &QmlCommerce::historyResult); connect(wallet.data(), &Wallet::keyFilePathIfExistsResult, this, &QmlCommerce::keyFilePathIfExistsResult); } @@ -46,26 +47,37 @@ void QmlCommerce::balance() { auto wallet = DependencyManager::get(); ledger->balance(wallet->listPublicKeys()); } + void QmlCommerce::inventory() { auto ledger = DependencyManager::get(); auto wallet = DependencyManager::get(); ledger->inventory(wallet->listPublicKeys()); } +void QmlCommerce::history() { + auto ledger = DependencyManager::get(); + auto wallet = DependencyManager::get(); + ledger->history(wallet->listPublicKeys()); +} + void QmlCommerce::chooseSecurityImage(const QString& imageFile) { auto wallet = DependencyManager::get(); wallet->chooseSecurityImage(imageFile); } + void QmlCommerce::getSecurityImage() { auto wallet = DependencyManager::get(); wallet->getSecurityImage(); } + void QmlCommerce::getLoginStatus() { emit loginStatusResult(DependencyManager::get()->isLoggedIn()); } + void QmlCommerce::setPassphrase(const QString& passphrase) { emit passphraseSetupStatusResult(true); } + void QmlCommerce::getPassphraseSetupStatus() { emit passphraseSetupStatusResult(false); } diff --git a/interface/src/commerce/QmlCommerce.h b/interface/src/commerce/QmlCommerce.h index 0c3ed64c81..fd913ae4b7 100644 --- a/interface/src/commerce/QmlCommerce.h +++ b/interface/src/commerce/QmlCommerce.h @@ -36,12 +36,14 @@ signals: void securityImageResult(bool exists); void loginStatusResult(bool isLoggedIn); void passphraseSetupStatusResult(bool passphraseIsSetup); + void historyResult(QJsonObject result); void keyFilePathIfExistsResult(const QString& path); protected: Q_INVOKABLE void buy(const QString& assetId, int cost, const QString& buyerUsername = ""); Q_INVOKABLE void balance(); Q_INVOKABLE void inventory(); + Q_INVOKABLE void history(); Q_INVOKABLE void chooseSecurityImage(const QString& imageFile); Q_INVOKABLE void getSecurityImage(); Q_INVOKABLE void getLoginStatus(); diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 81a55a0962..9e04694a24 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -347,7 +347,7 @@ bool Wallet::createIfNeeded() { qCDebug(commerce) << "read private key"; RSA_free(key); // K -- add the public key since we have a legit private key associated with it - _publicKeys.push_back(QUrl::toPercentEncoding(publicKey.toBase64())); + _publicKeys.push_back(publicKey.toBase64()); return false; } }