mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-18 17:49:00 +00:00
fix: code review
This commit is contained in:
parent
0091fded3a
commit
83b0c8057e
@ -77,7 +77,7 @@ proc handleChatEvents(self: ChatController) =
|
|||||||
|
|
||||||
self.status.events.on(PendingTransactionType.BuyStickerPack.confirmed) do(e: Args):
|
self.status.events.on(PendingTransactionType.BuyStickerPack.confirmed) do(e: Args):
|
||||||
var tx = TransactionMinedArgs(e)
|
var tx = TransactionMinedArgs(e)
|
||||||
self.view.transactionCompleted(tx.success, tx.transactionHash)
|
self.view.transactionCompleted(tx.success, tx.transactionHash, tx.revertReason)
|
||||||
if tx.success:
|
if tx.success:
|
||||||
self.view.installStickerPack(tx.data.parseInt)
|
self.view.installStickerPack(tx.data.parseInt)
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ QtObject:
|
|||||||
result = 325000
|
result = 325000
|
||||||
|
|
||||||
proc transactionWasSent*(self: ChatsView, txResult: string) {.signal.}
|
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.} =
|
proc buyStickerPack*(self: ChatsView, packId: int, address: string, price: string, gas: string, gasPrice: string, password: string): string {.slot.} =
|
||||||
try:
|
try:
|
||||||
|
@ -85,11 +85,11 @@ proc init*(self: ProfileController, account: Account) =
|
|||||||
if tx.success:
|
if tx.success:
|
||||||
self.view.ens.confirm(PendingTransactionType.RegisterENS, tx.data, tx.transactionHash)
|
self.view.ens.confirm(PendingTransactionType.RegisterENS, tx.data, tx.transactionHash)
|
||||||
else:
|
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):
|
self.status.events.on(PendingTransactionType.SetPubKey.confirmed) do(e: Args):
|
||||||
let tx = TransactionMinedArgs(e)
|
let tx = TransactionMinedArgs(e)
|
||||||
if tx.success:
|
if tx.success:
|
||||||
self.view.ens.confirm(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash)
|
self.view.ens.confirm(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash)
|
||||||
else:
|
else:
|
||||||
self.view.ens.revert(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash)
|
self.view.ens.revert(PendingTransactionType.SetPubKey, tx.data, tx.transactionHash, tx.revertReason)
|
||||||
|
@ -157,7 +157,7 @@ QtObject:
|
|||||||
|
|
||||||
proc usernameConfirmed(self: EnsManager, username: string) {.signal.}
|
proc usernameConfirmed(self: EnsManager, username: string) {.signal.}
|
||||||
proc transactionWasSent(self: EnsManager, txResult: 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) =
|
proc confirm*(self: EnsManager, trxType: PendingTransactionType, ensUsername: string, transactionHash: string) =
|
||||||
self.connect(ensUsername)
|
self.connect(ensUsername)
|
||||||
@ -167,7 +167,7 @@ QtObject:
|
|||||||
let bottomRight = self.createIndex(msgIdx, 0, nil)
|
let bottomRight = self.createIndex(msgIdx, 0, nil)
|
||||||
self.dataChanged(topLeft, bottomRight, @[EnsRoles.IsPending.int])
|
self.dataChanged(topLeft, bottomRight, @[EnsRoles.IsPending.int])
|
||||||
self.usernameConfirmed(ensUsername)
|
self.usernameConfirmed(ensUsername)
|
||||||
self.transactionCompleted(true, transactionHash, ensUsername, $trxType)
|
self.transactionCompleted(true, transactionHash, ensUsername, $trxType, "")
|
||||||
|
|
||||||
|
|
||||||
proc getPrice(self: EnsManager): string {.slot.} =
|
proc getPrice(self: EnsManager): string {.slot.} =
|
||||||
@ -192,7 +192,7 @@ QtObject:
|
|||||||
|
|
||||||
self.connect(ensUsername)
|
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
|
self.pendingUsernames.excl ensUsername
|
||||||
let msgIdx = self.usernames.find(ensUsername)
|
let msgIdx = self.usernames.find(ensUsername)
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ QtObject:
|
|||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
self.usernames.del(msgIdx)
|
self.usernames.del(msgIdx)
|
||||||
self.endResetModel()
|
self.endResetModel()
|
||||||
self.transactionCompleted(false, transactionHash, ensUsername, $trxType)
|
self.transactionCompleted(false, transactionHash, ensUsername, $trxType, revertReason)
|
||||||
|
|
||||||
proc registerENS(self: EnsManager, username: string, password: string) {.slot.} =
|
proc registerENS(self: EnsManager, username: string, password: string) {.slot.} =
|
||||||
let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0")
|
let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0")
|
||||||
|
@ -237,7 +237,10 @@ ModalPopup {
|
|||||||
toastMessage.open()
|
toastMessage.open()
|
||||||
}
|
}
|
||||||
onTransactionCompleted: {
|
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) {
|
if (success) {
|
||||||
toastMessage.source = "../../../img/check-circle.svg"
|
toastMessage.source = "../../../img/check-circle.svg"
|
||||||
toastMessage.iconColor = Style.current.success
|
toastMessage.iconColor = Style.current.success
|
||||||
|
@ -287,10 +287,16 @@ Item {
|
|||||||
onTransactionCompleted: {
|
onTransactionCompleted: {
|
||||||
switch(trxType){
|
switch(trxType){
|
||||||
case "RegisterENS":
|
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;
|
break;
|
||||||
case "SetPubKey":
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user