fix: code review

This commit is contained in:
Richard Ramos 2020-09-14 15:41:09 -04:00 committed by Iuri Matias
parent 0091fded3a
commit 83b0c8057e
6 changed files with 20 additions and 11 deletions

View File

@ -77,7 +77,7 @@ proc handleChatEvents(self: ChatController) =
self.status.events.on(PendingTransactionType.BuyStickerPack.confirmed) do(e: Args):
var tx = TransactionMinedArgs(e)
self.view.transactionCompleted(tx.success, tx.transactionHash)
self.view.transactionCompleted(tx.success, tx.transactionHash, tx.revertReason)
if tx.success:
self.view.installStickerPack(tx.data.parseInt)

View File

@ -113,7 +113,7 @@ QtObject:
result = 325000
proc transactionWasSent*(self: ChatsView, txResult: string) {.signal.}
proc transactionCompleted*(self: ChatsView, success: bool, txHash: string) {.signal.}
proc transactionCompleted*(self: ChatsView, success: bool, txHash: string, revertReason: string = "") {.signal.}
proc buyStickerPack*(self: ChatsView, packId: int, address: string, price: string, gas: string, gasPrice: string, password: string): string {.slot.} =
try:

View File

@ -85,11 +85,11 @@ proc init*(self: ProfileController, account: Account) =
if tx.success:
self.view.ens.confirm(PendingTransactionType.RegisterENS, tx.data, tx.transactionHash)
else:
self.view.ens.revert(PendingTransactionType.RegisterENS, tx.data, tx.transactionHash)
self.view.ens.revert(PendingTransactionType.RegisterENS, tx.data, tx.transactionHash, tx.revertReason)
self.status.events.on(PendingTransactionType.SetPubKey.confirmed) do(e: Args):
let tx = TransactionMinedArgs(e)
if tx.success:
self.view.ens.confirm(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash)
else:
self.view.ens.revert(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash)
self.view.ens.revert(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash, tx.revertReason)

View File

@ -157,7 +157,7 @@ QtObject:
proc usernameConfirmed(self: EnsManager, username: string) {.signal.}
proc transactionWasSent(self: EnsManager, txResult: string) {.signal.}
proc transactionCompleted(self: EnsManager, success: bool, txHash: string, username: string, trxType: string) {.signal.}
proc transactionCompleted(self: EnsManager, success: bool, txHash: string, username: string, trxType: string, revertReason: string) {.signal.}
proc confirm*(self: EnsManager, trxType: PendingTransactionType, ensUsername: string, transactionHash: string) =
self.connect(ensUsername)
@ -167,7 +167,7 @@ QtObject:
let bottomRight = self.createIndex(msgIdx, 0, nil)
self.dataChanged(topLeft, bottomRight, @[EnsRoles.IsPending.int])
self.usernameConfirmed(ensUsername)
self.transactionCompleted(true, transactionHash, ensUsername, $trxType)
self.transactionCompleted(true, transactionHash, ensUsername, $trxType, "")
proc getPrice(self: EnsManager): string {.slot.} =
@ -192,7 +192,7 @@ QtObject:
self.connect(ensUsername)
proc revert*(self: EnsManager, trxType: PendingTransactionType, ensUsername: string, transactionHash: string) =
proc revert*(self: EnsManager, trxType: PendingTransactionType, ensUsername: string, transactionHash: string, revertReason: string) =
self.pendingUsernames.excl ensUsername
let msgIdx = self.usernames.find(ensUsername)
@ -201,7 +201,7 @@ QtObject:
self.beginResetModel()
self.usernames.del(msgIdx)
self.endResetModel()
self.transactionCompleted(false, transactionHash, ensUsername, $trxType)
self.transactionCompleted(false, transactionHash, ensUsername, $trxType, revertReason)
proc registerENS(self: EnsManager, username: string, password: string) {.slot.} =
let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0")

View File

@ -237,7 +237,10 @@ ModalPopup {
toastMessage.open()
}
onTransactionCompleted: {
toastMessage.title = !success ? qsTr("Could not buy Stickerpack"): qsTr("Stickerpack bought successfully");
toastMessage.title = !success ?
qsTr("Could not buy Stickerpack")
:
qsTr("Stickerpack bought successfully");
if (success) {
toastMessage.source = "../../../img/check-circle.svg"
toastMessage.iconColor = Style.current.success

View File

@ -287,10 +287,16 @@ Item {
onTransactionCompleted: {
switch(trxType){
case "RegisterENS":
toastMessage.title = !success ? qsTr("ENS Registration failed"): qsTr("ENS Registration completed");
toastMessage.title = !success ?
qsTr("ENS Registration failed")
:
qsTr("ENS Registration completed");
break;
case "SetPubKey":
toastMessage.title = !success ? qsTr("Updating ENS pubkey failed"): qsTr("Updating ENS pubkey completed");
toastMessage.title = !success ?
qsTr("Updating ENS pubkey failed")
:
qsTr("Updating ENS pubkey completed");
break;
}