Merge pull request #11260 from davidkelly/dk/transactionHistoryDisplay

display transaction history
This commit is contained in:
David Kelly 2017-08-29 08:46:58 -07:00 committed by GitHub
commit 1eb5b9e75d
6 changed files with 39 additions and 11 deletions

View file

@ -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("<hr>");
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 <b>CANNOT</b> scroll through this." : "you <b>CAN</b> scroll through this";
// Text size
size: 16;
// Anchors
TextArea {
id: transactionHistoryText;
text: "<hr>history unavailable<hr>";
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
//

View file

@ -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<AccountManager>();
@ -107,3 +108,6 @@ void Ledger::inventory(const QStringList& keys) {
keysQuery("inventory", "inventorySuccess", "inventoryFailure");
}
void Ledger::history(const QStringList& keys) {
keysQuery("history", "historySuccess", "historyFailure");
}

View file

@ -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);

View file

@ -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<Wallet>();
ledger->balance(wallet->listPublicKeys());
}
void QmlCommerce::inventory() {
auto ledger = DependencyManager::get<Ledger>();
auto wallet = DependencyManager::get<Wallet>();
ledger->inventory(wallet->listPublicKeys());
}
void QmlCommerce::history() {
auto ledger = DependencyManager::get<Ledger>();
auto wallet = DependencyManager::get<Wallet>();
ledger->history(wallet->listPublicKeys());
}
void QmlCommerce::chooseSecurityImage(const QString& imageFile) {
auto wallet = DependencyManager::get<Wallet>();
wallet->chooseSecurityImage(imageFile);
}
void QmlCommerce::getSecurityImage() {
auto wallet = DependencyManager::get<Wallet>();
wallet->getSecurityImage();
}
void QmlCommerce::getLoginStatus() {
emit loginStatusResult(DependencyManager::get<AccountManager>()->isLoggedIn());
}
void QmlCommerce::setPassphrase(const QString& passphrase) {
emit passphraseSetupStatusResult(true);
}
void QmlCommerce::getPassphraseSetupStatus() {
emit passphraseSetupStatusResult(false);
}

View file

@ -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();

View file

@ -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;
}
}