mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-19 18:18:38 +00:00
wip: Send modal deep link
This commit is contained in:
parent
100389aa8d
commit
558e99c990
@ -1646,6 +1646,8 @@ method activateStatusDeepLink*[T](self: Module[T], statusDeepLink: string) =
|
||||
self.onStatusUrlRequested(StatusUrlAction.DisplayUserProfile, communityId="", channelId="", url="",
|
||||
urlData.contact.publicKey, urlData.community.shard)
|
||||
return
|
||||
if urlData.transaction.txType >= 0:
|
||||
self.view.emitShowTransactionModal(urlData.transaction.txType, urlData.transaction.asset, urlData.transaction.amount, urlData.transaction.address, urlData.transaction.chainId, urlData.transaction.toAsset)
|
||||
|
||||
method onDeactivateChatLoader*[T](self: Module[T], sectionId: string, chatId: string) =
|
||||
if (sectionId.len > 0 and self.chatSectionModules.contains(sectionId)):
|
||||
|
@ -37,3 +37,7 @@ proc parseContactSharedUrl*(self: Controller, url: string): ContactUrlDataDto =
|
||||
|
||||
proc parseSharedUrl*(self: Controller, url: string): UrlDataDto =
|
||||
return self.sharedUrlsService.parseSharedUrl(url)
|
||||
|
||||
proc parseTransactionSharedUrl*(self: Controller, url: string): TransactionUrlDataDto =
|
||||
let data = self.sharedUrlsService.parseSharedUrl(url)
|
||||
return data.transaction
|
@ -27,6 +27,9 @@ method parseContactSharedUrl*(self: AccessInterface, url: string): string {.base
|
||||
method parseSharedUrl*(self: AccessInterface, url: string): UrlDataDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method parseTransactionSharedUrl*(self: AccessInterface, url: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# This way (using concepts) is used only for the modules managed by AppController
|
||||
type
|
||||
DelegateInterface* = concept c
|
||||
|
@ -63,3 +63,7 @@ method parseCommunityChannelSharedUrl*(self: Module, url: string): string =
|
||||
method parseContactSharedUrl*(self: Module, url: string): string =
|
||||
let contactData = self.controller.parseContactSharedUrl(url)
|
||||
return $contactData
|
||||
|
||||
method parseTransactionSharedUrl*(self: Module, url: string): string =
|
||||
let transactionData = self.controller.parseTransactionSharedUrl(url)
|
||||
return $transactionData
|
@ -25,4 +25,7 @@ QtObject:
|
||||
return self.delegate.parseCommunityChannelSharedUrl(url)
|
||||
|
||||
proc parseContactSharedUrl*(self: View, url: string): string {.slot.} =
|
||||
return self.delegate.parseContactSharedUrl(url)
|
||||
return self.delegate.parseContactSharedUrl(url)
|
||||
|
||||
proc parseTransactionSharedUrl*(self: View, url: string): string {.slot.} =
|
||||
return self.delegate.parseTransactionSharedUrl(url)
|
@ -382,3 +382,8 @@ QtObject:
|
||||
|
||||
proc stopTokenHoldersManagement*(self: View) {.slot.} =
|
||||
self.delegate.stopTokenHoldersManagement()
|
||||
|
||||
proc showTransactionModal*(self: View, txType: int, asset: string, amount: string, address: string, chainId: int, toAsset: string) {.signal.}
|
||||
proc emitShowTransactionModal*(self: View, txType: int, asset: string, amount: string, address: string, chainId: int, toAsset: string) =
|
||||
self.showTransactionModal(txType, asset, amount, address, chainId, toAsset)
|
||||
|
||||
|
@ -8,6 +8,7 @@ import app_service/service/currency/service as currency_service
|
||||
import app_service/service/currency/dto as currency_dto
|
||||
import app_service/service/keycard/service as keycard_service
|
||||
import app_service/service/network/network_item
|
||||
import app_service/service/shared_urls/dto/url_data as shared_urls_dto
|
||||
|
||||
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
import app/modules/shared/wallet_utils
|
||||
@ -137,6 +138,9 @@ proc signMessage*(self: Controller, address: string, hashedPassword: string, has
|
||||
proc sendRouterTransactionsWithSignatures*(self: Controller, uuid: string, signatures: TransactionsSignatures): string =
|
||||
return self.transactionService.sendRouterTransactionsWithSignatures(uuid, signatures)
|
||||
|
||||
proc shareTransactionURL*(self: Controller, urlData: shared_urls_dto.TransactionURLDataDto): string =
|
||||
return self.transactionService.shareTransactionURL(urlData)
|
||||
|
||||
proc areTestNetworksEnabled*(self: Controller): bool =
|
||||
return self.walletAccountService.areTestNetworksEnabled()
|
||||
|
||||
|
@ -2,6 +2,7 @@ import Tables
|
||||
import app/modules/shared_models/currency_amount
|
||||
import app_service/service/transaction/dto
|
||||
import app_service/service/transaction/router_transactions_dto
|
||||
import app_service/service/shared_urls/dto/url_data
|
||||
import app_service/service/network/network_item
|
||||
import app/modules/shared_models/collectibles_model as collectibles
|
||||
from app_service/service/keycard/service import KeycardEvent
|
||||
@ -90,4 +91,7 @@ method getNetworkItem*(self: AccessInterface, chainId: int): NetworkItem {.base.
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getNetworkChainId*(self: AccessInterface, shortName: string): int {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method shareTransactionURL*(self: AccessInterface, urlData: TransactionURLDataDto): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
@ -14,6 +14,7 @@ import app_service/service/transaction/service as transaction_service
|
||||
import app_service/service/keycard/service as keycard_service
|
||||
import app_service/service/keycard/constants as keycard_constants
|
||||
import app_service/service/transaction/dto
|
||||
import app_service/service/shared_urls/dto/url_data as shared_urls_dto
|
||||
import app/modules/shared_models/currency_amount
|
||||
import app_service/service/network/network_item as network_service_item
|
||||
|
||||
@ -404,3 +405,6 @@ method splitAndFormatAddressPrefix*(self: Module, text : string, updateInStore:
|
||||
|
||||
method transactionSendingComplete*(self: Module, txHash: string, status: string) =
|
||||
self.view.sendtransactionSendingCompleteSignal(txHash, status)
|
||||
|
||||
method shareTransactionURL*(self: Module, urlData: shared_urls_dto.TransactionURLDataDto): string =
|
||||
return self.controller.shareTransactionURL(urlData)
|
@ -3,6 +3,7 @@ import NimQml, Tables, json, sequtils, strutils, stint, chronicles
|
||||
import ./io_interface, ./network_route_model, ./network_route_item, ./suggested_route_item, ./transaction_routes
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/transaction/dto as transaction_dto
|
||||
import app_service/service/shared_urls/dto/url_data as shared_urls_dto
|
||||
|
||||
import app_service/common/utils as common_utils
|
||||
import app_service/service/eth/utils as eth_utils
|
||||
@ -295,6 +296,16 @@ QtObject:
|
||||
parseChainIds(disabledToChainIDs),
|
||||
lockedInAmountsTable)
|
||||
|
||||
proc shareTransactionURL*(self: View, txType: int, asset: string, amount: string, address: string, chainId: int, toAsset: string): string {.slot.} =
|
||||
return self.delegate.shareTransactionURL(shared_urls_dto.TransactionURLDataDto(
|
||||
txType: txType,
|
||||
asset: asset,
|
||||
amount: amount,
|
||||
address: address,
|
||||
chainId: chainId,
|
||||
toAsset: toAsset
|
||||
))
|
||||
|
||||
proc transactionSendingComplete*(self: View, txHash: string, status: string) {.signal.}
|
||||
proc sendtransactionSendingCompleteSignal*(self: View, txHash: string, status: string) =
|
||||
self.transactionSendingComplete(txHash, status)
|
||||
|
@ -25,10 +25,19 @@ type ContactUrlDataDto* = object
|
||||
description*: string
|
||||
publicKey*: string
|
||||
|
||||
type TransactionURLDataDto* = object
|
||||
txType*: int
|
||||
asset*: string
|
||||
amount*: string
|
||||
address*: string
|
||||
chainId*: int
|
||||
toAsset*: string
|
||||
|
||||
type UrlDataDto* = object
|
||||
community*: CommunityUrlDataDto
|
||||
channel*: CommunityChannelUrlDataDto
|
||||
contact*: ContactUrlDataDto
|
||||
transaction*: TransactionURLDataDto
|
||||
notASupportedStatusLink*: bool # If this is true, it was not a supported status link, so we should open it in a browser
|
||||
|
||||
proc getShard*(jsonObj: JsonNode): Shard =
|
||||
@ -69,8 +78,18 @@ proc toContactUrlDataDto*(jsonObj: JsonNode): ContactUrlDataDto =
|
||||
discard jsonObj.getProp("description", result.description)
|
||||
discard jsonObj.getProp("publicKey", result.publicKey)
|
||||
|
||||
proc toTransactionUrlDataDto*(jsonObj: JsonNode): TransactionURLDataDto =
|
||||
result = TransactionURLDataDto()
|
||||
discard jsonObj.getProp("txType", result.txType)
|
||||
discard jsonObj.getProp("asset", result.asset)
|
||||
discard jsonObj.getProp("amount", result.amount)
|
||||
discard jsonObj.getProp("address", result.address)
|
||||
discard jsonObj.getProp("chainId", result.chainId)
|
||||
discard jsonObj.getProp("toAsset", result.toAsset)
|
||||
|
||||
proc toUrlDataDto*(jsonObj: JsonNode): UrlDataDto =
|
||||
result = UrlDataDto()
|
||||
result.transaction.txType = -1
|
||||
|
||||
var communityObj: JsonNode
|
||||
if (jsonObj.getProp("community", communityObj)):
|
||||
@ -84,6 +103,10 @@ proc toUrlDataDto*(jsonObj: JsonNode): UrlDataDto =
|
||||
if (jsonObj.getProp("contact", contactObj)):
|
||||
result.contact = contactObj.toContactUrlDataDto()
|
||||
|
||||
var txObj: JsonNode
|
||||
if (jsonObj.getProp("tx", txObj)):
|
||||
result.transaction = txObj.toTransactionUrlDataDto()
|
||||
|
||||
proc toJsonNode*(communityUrlDataDto: CommunityUrlDataDto): JsonNode =
|
||||
var jsonObj = newJObject()
|
||||
jsonObj["displayName"] = %* communityUrlDataDto.displayName
|
||||
@ -113,3 +136,11 @@ proc `$`*(contactUrlDataDto: ContactUrlDataDto): string =
|
||||
jsonObj["description"] = %* contactUrlDataDto.description
|
||||
jsonObj["publicKey"] = %* contactUrlDataDto.publicKey
|
||||
return $jsonObj
|
||||
|
||||
proc `$`*(transactionURLData: TransactionURLDataDto): string =
|
||||
var jsonObj = newJObject()
|
||||
jsonObj["txType"] = %* transactionURLData.txType
|
||||
jsonObj["asset"] = %* transactionURLData.asset
|
||||
jsonObj["amount"] = %* transactionURLData.amount
|
||||
jsonObj["address"] = %* transactionURLData.address
|
||||
return $jsonObj
|
@ -19,6 +19,7 @@ import app_service/service/wallet_account/service as wallet_account_service
|
||||
import app_service/service/network/service as network_service
|
||||
import app_service/service/token/service as token_service
|
||||
import app_service/service/settings/service as settings_service
|
||||
import app_service/service/shared_urls/dto/url_data as shared_urls_dto
|
||||
import ./dto as transaction_dto
|
||||
import ./dtoV2
|
||||
import ./dto_conversion
|
||||
@ -501,3 +502,14 @@ proc sendRouterTransactionsWithSignatures*(self: Service, uuid: string, signatur
|
||||
error "unexpected sending transactions response"
|
||||
return "unexpected sending transactions response"
|
||||
return ""
|
||||
|
||||
proc shareTransactionURL*(self: Service, urlData: shared_urls_dto.TransactionURLDataDto): string =
|
||||
try:
|
||||
let response = transactions.shareTransactionURL(%urlData)
|
||||
if response.error != nil:
|
||||
error "Error sharing transaction url. Error: ", message = response.error
|
||||
return ""
|
||||
return response.result.getStr
|
||||
except Exception as e:
|
||||
error "Error sharing transaction url", message = e.msg
|
||||
return ""
|
@ -1,4 +1,5 @@
|
||||
import Tables, json, stint, json_serialization, stew/shims/strformat, logging
|
||||
import ../app_service/common/utils
|
||||
|
||||
import ./core as core
|
||||
|
||||
@ -117,4 +118,7 @@ proc sendRouterTransactionsWithSignatures*(resultOut: var JsonNode, uuid: string
|
||||
return prepareResponse(resultOut, response)
|
||||
except Exception as e:
|
||||
warn e.msg
|
||||
return e.msg
|
||||
return e.msg
|
||||
|
||||
proc shareTransactionURL*(urlData: JsonNode): RpcResponse[JsonNode] =
|
||||
return callPrivateRPC("shareTransactionURL".prefix, urlData)
|
40
ui/app/AppLayouts/Wallet/controls/ShareButton.qml
Normal file
40
ui/app/AppLayouts/Wallet/controls/ShareButton.qml
Normal file
@ -0,0 +1,40 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
StatusButton {
|
||||
id: root
|
||||
|
||||
text: qsTr("Share")
|
||||
type: StatusBaseButton.Type.Normal
|
||||
size: StatusBaseButton.Size.Tiny
|
||||
|
||||
horizontalPadding: 8
|
||||
verticalPadding: 3
|
||||
implicitHeight: 22
|
||||
|
||||
radius: 20
|
||||
font.pixelSize: 12
|
||||
font.weight: Font.Normal
|
||||
|
||||
Timer {
|
||||
id: shareStateTimer
|
||||
interval: 2000
|
||||
repeat: false
|
||||
}
|
||||
|
||||
states: State {
|
||||
name: "success"
|
||||
when: shareStateTimer.running
|
||||
PropertyChanges {
|
||||
target: shareButton
|
||||
text: qsTr("Copied")
|
||||
type: StatusBaseButton.Type.Success
|
||||
icon.name: "tiny/checkmark"
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
shareStateTimer.restart()
|
||||
}
|
||||
}
|
@ -26,3 +26,4 @@ SwapProvidersTermsAndConditionsText 1.0 SwapProvidersTermsAndConditionsText.qml
|
||||
TokenSelector 1.0 TokenSelector.qml
|
||||
TokenSelectorButton 1.0 TokenSelectorButton.qml
|
||||
TokenSelectorCompactButton 1.0 TokenSelectorCompactButton.qml
|
||||
ShareButton 1.0 ShareButton.qml
|
||||
|
@ -4,6 +4,7 @@ import QtQml.Models 2.15
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import StatusQ 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Backpressure 0.1
|
||||
@ -146,6 +147,19 @@ StatusDialog {
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||
text: qsTr("Swap")
|
||||
}
|
||||
ShareButton {
|
||||
id: shareButton
|
||||
|
||||
onClicked: {
|
||||
const url = root.swapAdaptor.getShareTransactionUrl(Constants.SendType.Swap,
|
||||
root.swapInputParamsForm.fromTokensKey,
|
||||
root.swapInputParamsForm.fromTokenAmount,
|
||||
root.swapInputParamsForm.selectedAccountAddress,
|
||||
root.swapInputParamsForm.selectedNetworkChainId,
|
||||
root.swapInputParamsForm.toTokensKey)
|
||||
ClipboardUtils.setText(url)
|
||||
}
|
||||
}
|
||||
StatusBaseText {
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
text: qsTr("On:")
|
||||
|
@ -52,4 +52,8 @@ QtObject {
|
||||
function getWei2Eth(wei, decimals) {
|
||||
return globalUtils.wei2Eth(wei, decimals)
|
||||
}
|
||||
|
||||
function getShareTransactionUrl(txType, asset, amount, address, chainId, toAsset) {
|
||||
return walletSectionSendInst.shareTransactionURL(txType, asset, amount, address, chainId, toAsset)
|
||||
}
|
||||
}
|
||||
|
@ -381,6 +381,41 @@ Item {
|
||||
""
|
||||
)
|
||||
}
|
||||
|
||||
function onShowTransactionModal(txType, asset, amount, address, chainId, toAsset) {
|
||||
console.log("=========== onShowTransactionModal txType:", txType, "asset:", asset, "amount:", amount, "address:", address, "chainId:", chainId, "toAsset:", toAsset)
|
||||
|
||||
if (txType === Constants.SendType.Swap) {
|
||||
// TODO_ES implement
|
||||
return
|
||||
}
|
||||
|
||||
sendModal.preSelectedSendType = txType
|
||||
sendModal.preDefinedAmountToSend = amount
|
||||
sendModal.preSelectedHoldingID = asset
|
||||
switch(txType) {
|
||||
case Constants.SendType.ERC721Transfer:
|
||||
sendModal.preSelectedHoldingType = Constants.TokenType.ERC721
|
||||
break
|
||||
case Constants.SendType.ERC1155Transfer:
|
||||
sendModal.preSelectedHoldingType = Constants.TokenType.ERC1155
|
||||
break
|
||||
case Constants.SendType.Transfer:
|
||||
sendModal.preSelectedHoldingType = Constants.TokenType.ERC20
|
||||
break
|
||||
case Constants.SendType.ENSRegister: // TODO_ES test ens
|
||||
case Constants.SendType.ENSSetPubKey:
|
||||
case Constants.SendType.ENSRelease:
|
||||
sendModal.preSelectedHoldingType = Constants.TokenType.ENS
|
||||
break
|
||||
case Constants.SendType.StickersBuy:
|
||||
// TOOD_ES handle
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
sendModal.open(address)
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
|
@ -486,6 +486,19 @@ StatusDialog {
|
||||
amountToSend.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
ShareButton {
|
||||
id: shareButton
|
||||
|
||||
onClicked: {
|
||||
let asset = ""
|
||||
if (!!d.selectedHolding) {
|
||||
asset = d.isCollectiblesTransfer ? d.selectedHolding.symbol : d.selectedHolding.tokensKey
|
||||
}
|
||||
const url = popup.store.getShareTransactionUrl(store.sendType, asset, amountToSend.asNumber, popup.store.selectedSenderAccountAddress, 0)
|
||||
ClipboardUtils.setText(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
visible: d.isSelectedHoldingValidAsset && !d.isCollectiblesTransfer
|
||||
|
@ -165,6 +165,10 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
function getShareTransactionUrl(txType, asset, amount, address, chainId) {
|
||||
return walletSectionSendInst.shareTransactionURL(txType, asset, amount, address, chainId, "")
|
||||
}
|
||||
|
||||
function getShortChainIds(chainShortNames) {
|
||||
return walletSectionSendInst.getShortChainIds(chainShortNames)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user