fix(@wallet/desktop): No feedback after token approval. Once the approval is confirmed the Swap dialog becomes editable again, with the Swap button enabled
fixes #16569
This commit is contained in:
parent
f7823cd0b7
commit
e8118dcf05
|
@ -459,17 +459,16 @@ proc connectForNotificationsOnly[T](self: Module[T]) =
|
||||||
let args = TransactionSentArgs(e)
|
let args = TransactionSentArgs(e)
|
||||||
self.view.showToastTransactionSent(args.chainId, args.txHash, args.uuid, args.error,
|
self.view.showToastTransactionSent(args.chainId, args.txHash, args.uuid, args.error,
|
||||||
ord(args.txType), args.fromAddress, args.toAddress, args.fromTokenKey, args.fromAmount,
|
ord(args.txType), args.fromAddress, args.toAddress, args.fromTokenKey, args.fromAmount,
|
||||||
args.toTokenKey, args.toAmount)
|
args.toTokenKey, args.toAmount, args.approvalTx)
|
||||||
|
|
||||||
self.events.on(MARK_WALLET_ADDRESSES_AS_SHOWN) do(e:Args):
|
self.events.on(MARK_WALLET_ADDRESSES_AS_SHOWN) do(e:Args):
|
||||||
let args = WalletAddressesArgs(e)
|
let args = WalletAddressesArgs(e)
|
||||||
for address in args.addresses:
|
for address in args.addresses:
|
||||||
self.addressWasShown(address)
|
self.addressWasShown(address)
|
||||||
|
|
||||||
self.events.on(SIGNAL_TRANSACTION_SENDING_COMPLETE) do(e:Args):
|
self.events.on(SIGNAL_TRANSACTION_STATUS_CHANGED) do(e:Args):
|
||||||
let args = TransactionMinedArgs(e)
|
let args = TransactionStatusArgs(e)
|
||||||
self.view.showToastTransactionSendingComplete(args.chainId, args.transactionHash, args.data, args.success,
|
self.view.showToastTransactionSendingComplete(args.data.hash, args.data.status)
|
||||||
ord(args.txType), args.fromAddress, args.toAddress, args.fromTokenKey, args.fromAmount, args.toTokenKey, args.toAmount)
|
|
||||||
|
|
||||||
self.events.on(SIGNAL_PAIRING_FALLBACK_COMPLETED) do(e:Args):
|
self.events.on(SIGNAL_PAIRING_FALLBACK_COMPLETED) do(e:Args):
|
||||||
self.view.showToastPairingFallbackCompleted()
|
self.view.showToastPairingFallbackCompleted()
|
||||||
|
|
|
@ -340,9 +340,8 @@ QtObject:
|
||||||
proc showToastKeypairRemoved*(self: View, keypairName: string) {.signal.}
|
proc showToastKeypairRemoved*(self: View, keypairName: string) {.signal.}
|
||||||
proc showToastKeypairsImported*(self: View, keypairName: string, keypairsCount: int, error: string) {.signal.}
|
proc showToastKeypairsImported*(self: View, keypairName: string, keypairsCount: int, error: string) {.signal.}
|
||||||
proc showToastTransactionSent*(self: View, chainId: int, txHash: string, uuid: string, error: string,
|
proc showToastTransactionSent*(self: View, chainId: int, txHash: string, uuid: string, error: string,
|
||||||
txType: int, fromAddr: string, toAddr: string, fromTokenKey: string, fromAmount: string, toTokenKey: string, toAmount: string) {.signal.}
|
txType: int, fromAddr: string, toAddr: string, fromTokenKey: string, fromAmount: string, toTokenKey: string, toAmount: string, approvalTx: bool) {.signal.}
|
||||||
proc showToastTransactionSendingComplete*(self: View, chainId: int, txHash: string, data: string, success: bool,
|
proc showToastTransactionSendingComplete*(self: View, txHash: string, data: string) {.signal.}
|
||||||
txType: int, fromAddr: string, toAddr: string, fromTokenKey: string, fromAmount: string, toTokenKey: string, toAmount: string) {.signal.}
|
|
||||||
proc showToastPairingFallbackCompleted*(self: View) {.signal.}
|
proc showToastPairingFallbackCompleted*(self: View) {.signal.}
|
||||||
|
|
||||||
## Used in test env only, for testing keycard flows
|
## Used in test env only, for testing keycard flows
|
||||||
|
|
|
@ -55,6 +55,7 @@ type
|
||||||
fromToken*: string
|
fromToken*: string
|
||||||
toToken*: string
|
toToken*: string
|
||||||
amount*: UInt256 # amount of the transaction
|
amount*: UInt256 # amount of the transaction
|
||||||
|
amountOut*: UInt256 # amount of the transaction
|
||||||
hash*: string
|
hash*: string
|
||||||
approvalTx*: bool
|
approvalTx*: bool
|
||||||
|
|
||||||
|
@ -130,6 +131,8 @@ proc toRouterSentTransaction*(jsonObj: JsonNode): RouterSentTransaction =
|
||||||
var tmpObj: JsonNode
|
var tmpObj: JsonNode
|
||||||
if jsonObj.getProp("amount", tmpObj):
|
if jsonObj.getProp("amount", tmpObj):
|
||||||
result.amount = stint.fromHex(UInt256, tmpObj.getStr)
|
result.amount = stint.fromHex(UInt256, tmpObj.getStr)
|
||||||
|
if jsonObj.getProp("amountOut", tmpObj):
|
||||||
|
result.amountOut = stint.fromHex(UInt256, tmpObj.getStr)
|
||||||
|
|
||||||
proc toRouterSentTransactionsDto*(jsonObj: JsonNode): RouterSentTransactionsDto =
|
proc toRouterSentTransactionsDto*(jsonObj: JsonNode): RouterSentTransactionsDto =
|
||||||
result = RouterSentTransactionsDto()
|
result = RouterSentTransactionsDto()
|
||||||
|
|
|
@ -365,9 +365,9 @@ QtObject:
|
||||||
fromAddress: tx.fromAddress,
|
fromAddress: tx.fromAddress,
|
||||||
toAddress: tx.toAddress,
|
toAddress: tx.toAddress,
|
||||||
fromTokenKey: tx.fromToken,
|
fromTokenKey: tx.fromToken,
|
||||||
fromAmount: tx.amount.toString(10),
|
fromAmount: sendDetails.fromAmount.toString(10),
|
||||||
toTokenKey: tx.toToken,
|
toTokenKey: tx.toToken,
|
||||||
toAmount: tx.amount.toString(10),
|
toAmount: tx.amountOut.toString(10),
|
||||||
approvalTx: tx.approvalTx,
|
approvalTx: tx.approvalTx,
|
||||||
username: sendDetails.username,
|
username: sendDetails.username,
|
||||||
publicKey: sendDetails.publicKey,
|
publicKey: sendDetails.publicKey,
|
||||||
|
|
|
@ -237,19 +237,21 @@ Item {
|
||||||
|
|
||||||
function onShowToastTransactionSent(chainId: int, txHash: string, uuid: string, error: string, txType: int,
|
function onShowToastTransactionSent(chainId: int, txHash: string, uuid: string, error: string, txType: int,
|
||||||
fromAddr: string, toAddr: string, fromTokenKey: string, fromAmount: string,
|
fromAddr: string, toAddr: string, fromTokenKey: string, fromAmount: string,
|
||||||
toTokenKey: string, toAmount: string) {
|
toTokenKey: string, toAmount: string, approvalTx: bool) {
|
||||||
switch(txType) {
|
switch(txType) {
|
||||||
case Constants.SendType.Approve: {
|
case Constants.SendType.Swap: {
|
||||||
const fromToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", fromTokenKey)
|
const fromToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", fromTokenKey)
|
||||||
const fromAccountName = SQUtils.ModelUtils.getByKey(appMain.transactionStore.accounts, "address", fromAddr, "name")
|
const fromAccountName = SQUtils.ModelUtils.getByKey(appMain.transactionStore.accounts, "address", fromAddr, "name")
|
||||||
const networkName = SQUtils.ModelUtils.getByKey(WalletStores.RootStore.filteredFlatModel, "chainId", chainId, "chainName")
|
const networkName = SQUtils.ModelUtils.getByKey(WalletStores.RootStore.filteredFlatModel, "chainId", chainId, "chainName")
|
||||||
if(!!fromToken && !!fromAccountName && !!networkName) {
|
let toastTitle = ""
|
||||||
const approvalAmount = currencyStore.formatCurrencyAmountFromBigInt(fromAmount, fromToken.symbol, fromToken.decimals)
|
|
||||||
let toastTitle = qsTr("Setting spending cap: %1 in %2 for %3 on %4").arg(approvalAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
|
||||||
let toastSubtitle = qsTr("View on %1").arg(networkName)
|
let toastSubtitle = qsTr("View on %1").arg(networkName)
|
||||||
let urlLink = "%1/%2".arg(appMain.rootStore.getEtherscanLink(chainId)).arg(txHash)
|
let urlLink = "%1/%2".arg(appMain.rootStore.getEtherscanLink(chainId)).arg(txHash)
|
||||||
let toastType = Constants.ephemeralNotificationType.normal
|
let toastType = Constants.ephemeralNotificationType.normal
|
||||||
let icon = ""
|
let icon = ""
|
||||||
|
if (approvalTx) {
|
||||||
|
if(!!fromToken && !!fromAccountName && !!networkName) {
|
||||||
|
const approvalAmount = currencyStore.formatCurrencyAmountFromBigInt(fromAmount, fromToken.symbol, fromToken.decimals)
|
||||||
|
toastTitle = qsTr("Setting spending cap: %1 in %2 for %3 on %4").arg(approvalAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
||||||
if(error) {
|
if(error) {
|
||||||
toastTitle = qsTr("Failed to set spending cap: %1 in %2 for %3 on %4").arg(approvalAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
toastTitle = qsTr("Failed to set spending cap: %1 in %2 for %3 on %4").arg(approvalAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
||||||
toastSubtitle = ""
|
toastSubtitle = ""
|
||||||
|
@ -257,23 +259,14 @@ Item {
|
||||||
toastType = Constants.ephemeralNotificationType.danger
|
toastType = Constants.ephemeralNotificationType.danger
|
||||||
icon = "warning"
|
icon = "warning"
|
||||||
}
|
}
|
||||||
Global.displayToastMessage(toastTitle, toastSubtitle, icon, !error, toastType, urlLink)
|
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
case Constants.SendType.Swap: {
|
else {
|
||||||
const fromToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", fromTokenKey)
|
|
||||||
const toToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", toTokenKey)
|
const toToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", toTokenKey)
|
||||||
const fromAccountName = SQUtils.ModelUtils.getByKey(appMain.transactionStore.accounts, "address", fromAddr, "name")
|
|
||||||
const networkName = SQUtils.ModelUtils.getByKey(WalletStores.RootStore.filteredFlatModel, "chainId", chainId, "chainName")
|
|
||||||
if(!!fromToken && !!toToken && !!fromAccountName && !!networkName) {
|
if(!!fromToken && !!toToken && !!fromAccountName && !!networkName) {
|
||||||
const fromSwapAmount = currencyStore.formatCurrencyAmountFromBigInt(fromAmount, fromToken.symbol, fromToken.decimals)
|
const fromSwapAmount = currencyStore.formatCurrencyAmountFromBigInt(fromAmount, fromToken.symbol, fromToken.decimals)
|
||||||
const toSwapAmount = currencyStore.formatCurrencyAmountFromBigInt(toAmount, toToken.symbol, toToken.decimals)
|
const toSwapAmount = currencyStore.formatCurrencyAmountFromBigInt(toAmount, toToken.symbol, toToken.decimals)
|
||||||
let toastTitle = qsTr("Swapping %1 to %2 in %3 using %4 on %5").arg(fromSwapAmount).arg(toSwapAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
toastTitle = qsTr("Swapping %1 to %2 in %3 using %4 on %5").arg(fromSwapAmount).arg(toSwapAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
||||||
let toastSubtitle = qsTr("View on %1").arg(networkName)
|
|
||||||
let urlLink = "%1/%2".arg(appMain.rootStore.getEtherscanLink(chainId)).arg(txHash)
|
|
||||||
let toastType = Constants.ephemeralNotificationType.normal
|
|
||||||
let icon = ""
|
|
||||||
if(error) {
|
if(error) {
|
||||||
toastTitle = qsTr("Failed to swap %1 to %2 in %3 using %4 on %5").arg(fromSwapAmount).arg(toSwapAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
toastTitle = qsTr("Failed to swap %1 to %2 in %3 using %4 on %5").arg(fromSwapAmount).arg(toSwapAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
||||||
toastSubtitle = ""
|
toastSubtitle = ""
|
||||||
|
@ -281,8 +274,9 @@ Item {
|
||||||
toastType = Constants.ephemeralNotificationType.danger
|
toastType = Constants.ephemeralNotificationType.danger
|
||||||
icon = "warning"
|
icon = "warning"
|
||||||
}
|
}
|
||||||
Global.displayToastMessage(toastTitle, toastSubtitle, icon, !error, toastType, urlLink)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Global.displayToastMessage(toastTitle, toastSubtitle, icon, !error, toastType, urlLink)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -302,56 +296,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onShowToastTransactionSendingComplete(chainId: int, txHash: string, data: string, success: bool,
|
|
||||||
txType: int, fromAddr: string, toAddr: string, fromTokenKey: string,
|
|
||||||
fromAmount: string, toTokenKey: string, toAmount: string) {
|
|
||||||
switch(txType) {
|
|
||||||
case Constants.SendType.Approve: {
|
|
||||||
const fromToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", fromTokenKey)
|
|
||||||
const fromAccountName = SQUtils.ModelUtils.getByKey(appMain.transactionStore.accounts, "address", fromAddr, "name")
|
|
||||||
const networkName = SQUtils.ModelUtils.getByKey(WalletStores.RootStore.filteredFlatModel, "chainId", chainId, "chainName")
|
|
||||||
if(!!fromToken && !!fromAccountName && !!networkName) {
|
|
||||||
const approvalAmount = currencyStore.formatCurrencyAmountFromBigInt(fromAmount, fromToken.symbol, fromToken.decimals)
|
|
||||||
let toastTitle = qsTr("Spending cap set: %1 in %2 for %3 on %4").arg(approvalAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
|
||||||
const toastSubtitle = qsTr("View on %1").arg(networkName)
|
|
||||||
const urlLink = "%1/%2".arg(appMain.rootStore.getEtherscanLink(chainId)).arg(txHash)
|
|
||||||
let toastType = Constants.ephemeralNotificationType.success
|
|
||||||
let icon = "checkmark-circle"
|
|
||||||
if(!success) {
|
|
||||||
toastTitle = qsTr("Failed to set spending cap: %1 in %2 for %3 on %4").arg(approvalAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
|
||||||
toastType = Constants.ephemeralNotificationType.danger
|
|
||||||
icon = "warning"
|
|
||||||
}
|
|
||||||
Global.displayToastMessage(toastTitle, toastSubtitle, icon, false, toastType, urlLink)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case Constants.SendType.Swap: {
|
|
||||||
const fromToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", fromTokenKey)
|
|
||||||
const toToken = SQUtils.ModelUtils.getByKey(appMain.tokensStore.plainTokensBySymbolModel, "key", toTokenKey)
|
|
||||||
const fromAccountName = SQUtils.ModelUtils.getByKey(appMain.transactionStore.accounts, "address", fromAddr, "name")
|
|
||||||
const networkName = SQUtils.ModelUtils.getByKey(WalletStores.RootStore.filteredFlatModel, "chainId", chainId, "chainName")
|
|
||||||
if(!!fromToken && !!toToken && !!fromAccountName && !!networkName) {
|
|
||||||
const fromSwapAmount = currencyStore.formatCurrencyAmountFromBigInt(fromAmount, fromToken.symbol, fromToken.decimals)
|
|
||||||
const toSwapAmount = currencyStore.formatCurrencyAmountFromBigInt(toAmount, toToken.symbol, toToken.decimals)
|
|
||||||
let toastTitle = qsTr("Swapped %1 to %2 in %3 using %4 on %5").arg(fromSwapAmount).arg(toSwapAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
|
||||||
const toastSubtitle = qsTr("View on %1").arg(networkName)
|
|
||||||
const urlLink = "%1/%2".arg(appMain.rootStore.getEtherscanLink(chainId)).arg(txHash)
|
|
||||||
let toastType = Constants.ephemeralNotificationType.success
|
|
||||||
let icon = "checkmark-circle"
|
|
||||||
if(!success) {
|
|
||||||
toastTitle = qsTr("Failed to swap %1 to %2 in %3 using %4 on %5").arg(fromSwapAmount).arg(toSwapAmount).arg(fromAccountName).arg(Constants.swap.paraswapHostname).arg(networkName)
|
|
||||||
toastType = Constants.ephemeralNotificationType.danger
|
|
||||||
icon = "warning"
|
|
||||||
}
|
|
||||||
Global.displayToastMessage(toastTitle, toastSubtitle, icon, false, toastType, urlLink)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
default: break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCommunityMemberStatusEphemeralNotification(communityName: string, memberName: string, state: CommunityMembershipRequestState) {
|
function onCommunityMemberStatusEphemeralNotification(communityName: string, memberName: string, state: CommunityMembershipRequestState) {
|
||||||
var text = ""
|
var text = ""
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 132ea05fc8735b91922a440009efdbc7f1b8b8ce
|
Subproject commit bc6754192bfb82871aee3c6e96ba2eeac49e4ec2
|
Loading…
Reference in New Issue