checkpoint

This commit is contained in:
howard-stearns 2018-02-22 17:04:27 -08:00
parent acda90577a
commit 1aaae94cc1
9 changed files with 90 additions and 15 deletions

View file

@ -59,11 +59,19 @@ Rectangle {
notSetUpTimer.start();
}
} else if (walletStatus === 2) {
if (root.activeView != "preexisting") {
root.activeView = "preexisting";
}
} else if (walletStatus === 3) {
if (root.activeView != "conflicting") {
root.activeView = "conflicting";
}
} else if (walletStatus === 4) {
if (root.activeView !== "passphraseModal") {
root.activeView = "passphraseModal";
UserActivityLogger.commercePassphraseEntry("marketplace checkout");
}
} else if (walletStatus === 3) {
} else if (walletStatus === 5) {
authSuccessStep();
} else {
console.log("ERROR in Checkout.qml: Unknown wallet status: " + walletStatus);

View file

@ -37,9 +37,9 @@ Item {
onWalletStatusResult: {
if (walletStatus === 0) {
sendToParent({method: "needsLogIn"});
} else if (walletStatus === 3) {
} else if (walletStatus === 5) {
Commerce.getSecurityImage();
} else if (walletStatus > 3) {
} else if (walletStatus > 5) {
console.log("ERROR in EmulatedMarketplaceHeader.qml: Unknown wallet status: " + walletStatus);
}
}

View file

@ -53,11 +53,19 @@ Rectangle {
notSetUpTimer.start();
}
} else if (walletStatus === 2) {
if (root.activeView != "preexisting") {
root.activeView = "preexisting";
}
} else if (walletStatus === 3) {
if (root.activeView != "conflicting") {
root.activeView = "conflicting";
}
} else if (walletStatus === 4) {
if (root.activeView !== "passphraseModal") {
root.activeView = "passphraseModal";
UserActivityLogger.commercePassphraseEntry("marketplace purchases");
}
} else if (walletStatus === 3) {
} else if (walletStatus === 5) {
if ((Settings.getValue("isFirstUseOfPurchases", true) || root.isDebuggingFirstUseTutorial) && root.activeView !== "firstUseTutorial") {
root.activeView = "firstUseTutorial";
} else if (!Settings.getValue("isFirstUseOfPurchases", true) && root.activeView === "initialize") {

View file

@ -56,11 +56,19 @@ Rectangle {
(AddressManager.placename || AddressManager.hostname || '') + (AddressManager.pathname ? AddressManager.pathname.match(/\/[^\/]+/)[0] : ''));
}
} else if (walletStatus === 2) {
if (root.activeView != "preexisting") {
root.activeView = "preexisting";
}
} else if (walletStatus === 3) {
if (root.activeView != "conflicting") {
root.activeView = "conflicting";
}
} else if (walletStatus === 4) {
if (root.activeView !== "passphraseModal") {
root.activeView = "passphraseModal";
UserActivityLogger.commercePassphraseEntry("wallet app");
}
} else if (walletStatus === 3) {
} else if (walletStatus === 5) {
if (root.activeView !== "walletSetup") {
root.activeView = "walletHome";
Commerce.getSecurityImage();
@ -168,6 +176,10 @@ Rectangle {
//
// TITLE BAR END
//
WalletChoice {
visible: (root.activeView === "preexisiting") || (root.activeView === "conflicting");
activeView: root.activeView;
}
WalletSetup {
id: walletSetup;

View file

@ -0,0 +1,23 @@
//
// WalletChoice.qml
// qml/hifi/commerce/wallet
//
// WalletChoice
//
// Created by Howard Stearns
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import Hifi 1.0 as Hifi
import QtQuick 2.5
import "../../../styles-uit"
Rectangle {
property string activeView: "conflict";
RalewayRegular {
text: "You have a wallet elsewhere." + activeView;
}
}

View file

@ -318,8 +318,8 @@ Item {
RalewayRegular {
id: noActivityText;
text: "<b>The Wallet app is in closed Beta.</b><br><br>To request entry and <b>receive free HFC</b>, please contact " +
"<b>info@highfidelity.com</b> with your High Fidelity account username and the email address registered to that account.";
text: "To <b>receive free HFC</b>, please go to " +
'<a href="hifi://BankOfHighFidelity/415.049,5.55924,-254.583/0,0.995213,0,0.0977305">BankOfHighFidelity</a>';
// Text size
size: 24;
// Style

View file

@ -22,6 +22,8 @@
// inventory answers {status: 'success', data: {assets: [{id: "guid", title: "name", preview: "url"}....]}}
// balance answers {status: 'success', data: {balance: integer}}
// buy and receive_at answer {status: 'success'}
// account synthesizes a result {status: 'success', data: {keyStatus: "preexisting"|"conflicting"|"ok"}}
QJsonObject Ledger::apiResponse(const QString& label, QNetworkReply& reply) {
QByteArray response = reply.readAll();
@ -178,7 +180,7 @@ QString transactionString(const QJsonObject& valueObject) {
} else {
result += valueObject["message"].toString();
}
// no matter what we append a smaller date to the bottom of this...
result += QString("<br><font size='-2' color='#1080B8'>%1").arg(createdAt.toLocalTime().toString(Qt::DefaultLocaleShortDate));
return result;
@ -250,13 +252,26 @@ void Ledger::accountSuccess(QNetworkReply& reply) {
wallet->setIv(iv);
wallet->setCKey(ckey);
QString keyStatus = "ok";
QStringList localPublicKeys = wallet->listPublicKeys();
if (remotePublicKey.isEmpty() && !localPublicKeys.isEmpty()) {
receiveAt(localPublicKeys.first(), "");
if (remotePublicKey.isEmpty()) {
if (!localPublicKeys.isEmpty()) {
receiveAt(localPublicKeys.first(), "");
}
} else {
if (localPublicKeys.isEmpty()) {
keyStatus = "preexisting";
} else if (localPublicKeys.first() != remotePublicKey) {
keyStatus = "conflicting";
}
}
// none of the hfc account info should be emitted
emit accountResult(QJsonObject{ {"status", "success"} });
QJsonObject json;
QJsonObject responseData{ { "status", "success"} };
json["keyStatus"] = keyStatus;
responseData["data"] = json;
emit accountResult(responseData);
}
void Ledger::accountFailure(QNetworkReply& reply) {

View file

@ -300,17 +300,24 @@ Wallet::Wallet() {
packetReceiver.registerListener(PacketType::ChallengeOwnership, this, "handleChallengeOwnershipPacket");
packetReceiver.registerListener(PacketType::ChallengeOwnershipRequest, this, "handleChallengeOwnershipPacket");
connect(ledger.data(), &Ledger::accountResult, this, [&]() {
connect(ledger.data(), &Ledger::accountResult, this, [&](QJsonObject result) {
auto wallet = DependencyManager::get<Wallet>();
auto walletScriptingInterface = DependencyManager::get<WalletScriptingInterface>();
uint status;
QString keyStatus = result.contains("data") ? result["data"].toObject()["keyStatus"].toString() : "";
if (wallet->getKeyFilePath() == "" || !wallet->getSecurityImage()) {
status = (uint)WalletStatus::WALLET_STATUS_NOT_SET_UP;
if (keyStatus == "preexisting") {
status = (uint) WalletStatus::WALLET_STATUS_PREEXISTING;
} else{
status = (uint) WalletStatus::WALLET_STATUS_NOT_SET_UP;
}
} else if (!wallet->walletIsAuthenticatedWithPassphrase()) {
status = (uint)WalletStatus::WALLET_STATUS_NOT_AUTHENTICATED;
status = (uint) WalletStatus::WALLET_STATUS_NOT_AUTHENTICATED;
} else if (keyStatus == "conflicting") {
status = (uint) WalletStatus::WALLET_STATUS_CONFLICTING;
} else {
status = (uint)WalletStatus::WALLET_STATUS_READY;
status = (uint) WalletStatus::WALLET_STATUS_READY;
}
walletScriptingInterface->setWalletStatus(status);

View file

@ -53,6 +53,8 @@ public:
enum WalletStatus {
WALLET_STATUS_NOT_LOGGED_IN = 0,
WALLET_STATUS_NOT_SET_UP,
WALLET_STATUS_PREEXISTING,
WALLET_STATUS_CONFLICTING,
WALLET_STATUS_NOT_AUTHENTICATED,
WALLET_STATUS_READY
};