chore(@desktop/wallet): Chnage the send modal mechanism to follow new architecture guidelines.

After this change there is not need to pass sendModal instance from AppMain to other parts of app.
Then SendModal should be launched simply by calling Global.openSendModal(....)
This commit is contained in:
Khushboo Mehta 2024-11-05 19:51:17 +01:00
parent 228197e2c4
commit 34ae4aedf3
36 changed files with 372 additions and 348 deletions

View File

@ -45,8 +45,6 @@ StackLayout {
allMembers: !!sectionItemModel ? sectionItemModel.allMembers : null
}
property var sendModalPopup
readonly property bool isOwner: sectionItemModel.memberRole === Constants.memberRole.owner
readonly property bool isAdmin: sectionItemModel.memberRole === Constants.memberRole.admin
readonly property bool isTokenMasterOwner: sectionItemModel.memberRole === Constants.memberRole.tokenMaster
@ -168,7 +166,6 @@ StackLayout {
emojiPopup: root.emojiPopup
stickersPopup: root.stickersPopup
sendModalPopup: root.sendModalPopup
sectionItemModel: root.sectionItemModel
joinedMembersCount: membersModelAdaptor.joinedMembers.ModelCount.count
amIMember: sectionItem.amIMember
@ -261,7 +258,6 @@ StackLayout {
enabledChainIds: WalletStore.RootStore.networkFilters
onEnableNetwork: WalletStore.RootStore.enableNetwork(chainId)
tokensStore: root.tokensStore
sendModalPopup: root.sendModalPopup
transactionStore: root.transactionStore
isPendingOwnershipRequest: root.isPendingOwnershipRequest

View File

@ -369,6 +369,10 @@ Item {
stickersLoaded: root.stickersLoaded
onSendViaPersonalChatRequested: {
Global.sendViaPersonalChatRequested(recipientAddress)
}
onVisibleChanged: {
if(!visible && model.editMode)
messageStore.setEditModeOff(model.id)

View File

@ -51,7 +51,6 @@ StatusSectionLayout {
property var mutualContactsModel
required property var sendModalPopup
property var sectionItemModel
property int joinedMembersCount
@ -358,11 +357,10 @@ StatusSectionLayout {
Component {
id: statusStickerPackClickPopup
StatusStickerPackClickPopup{
walletAssetsStore: root.walletAssetsStore
sendModalPopup: root.sendModalPopup
onClosed: {
destroy();
onBuyClicked: {
Global.buyStickerPackRequested(packId, price)
}
onClosed: destroy()
}
}
}

View File

@ -31,7 +31,6 @@ StackView {
required property string communityName
required property string communityLogo
required property color communityColor
property var sendModalPopup
// User profile props:
required property bool isOwner
@ -786,8 +785,7 @@ StackView {
onSendOwnershipClicked: Global.openTransferOwnershipPopup(root.communityId,
root.communityName,
root.communityLogo,
tokenViewPage.token,
root.sendModalPopup)
tokenViewPage.token)
// helper properties to pass data through popups
property var walletsAndAmounts

View File

@ -40,7 +40,6 @@ StackLayout {
property bool requestToJoinEnabled
property bool pinMessagesEnabled
property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : ""
property var sendModalPopup
property bool archiveSupporVisible: true
property bool editable: false
@ -134,8 +133,15 @@ StackLayout {
Global.openTransferOwnershipPopup(root.communityId,
root.name,
root.logoImageData,
root.ownerToken,
root.sendModalPopup)
{
key: "0",
privilegesLevel: root.ownerToken.privilegesLevel,
chainId: root.ownerToken.chainId,
name: root.ownerToken.name,
artworkSource: root.ownerToken.image,
accountAddress: root.ownerToken.accountAddress.toLowerCase(),
tokenAddress: root.ownerToken.tokenAddress.toLowerCase()
})
} else {
Global.openPopup(transferOwnershipAlertPopup, { mode: TransferOwnershipAlertPopup.Mode.TransferOwnership })
}

View File

@ -26,9 +26,9 @@ StatusDialog {
// Transaction related props:
property var token // Expected roles: accountAddress, key, chainId, name, artworkSource
property var sendModalPopup
signal cancelClicked
signal transferOwnershipRequested(string tokenId, string senderAddress)
width: 640 // by design
padding: Theme.padding
@ -109,13 +109,9 @@ StatusDialog {
onClicked: {
// Pre-populated dialog with the relevant Owner token info:
root.sendModalPopup.preSelectedSendType = Constants.SendType.ERC721Transfer
root.sendModalPopup.preSelectedAccountAddress = token.accountAddress
const store = WalletStores.RootStore.currentActivityFiltersStore
const uid = store.collectiblesList.getUidForData(token.key, token.tokenAddress, token.chainId);
root.sendModalPopup.preSelectedHoldingID = uid
root.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC721
root.sendModalPopup.open()
root.transferOwnershipRequested(uid, token.accountAddress)
close()
}
}

View File

@ -46,7 +46,6 @@ StatusSectionLayout {
required property var declinedMembers
required property TransactionStore transactionStore
property bool communitySettingsDisabled
property var sendModalPopup
required property string enabledChainIds
@ -221,7 +220,6 @@ StatusSectionLayout {
pubsubTopic: root.community.pubsubTopic
pubsubTopicKey: root.community.pubsubTopicKey
sendModalPopup: root.sendModalPopup
ownerToken: tokensModelChangesTracker.ownerToken
isPendingOwnershipRequest: root.isPendingOwnershipRequest
@ -380,7 +378,6 @@ StatusSectionLayout {
communityName: root.community.name
communityLogo: root.community.image
communityColor: root.community.color
sendModalPopup: root.sendModalPopup
// User profile props
isOwner: root.isOwner

View File

@ -45,7 +45,6 @@ StatusSectionLayout {
property ProfileStores.ProfileSectionStore store
property AppLayoutsStores.RootStore globalStore
property CommunitiesStore.CommunitiesStore communitiesStore
required property var sendModalPopup
property var systemPalette
property var emojiPopup
property SharedStores.NetworkConnectionStore networkConnectionStore
@ -259,10 +258,12 @@ StatusSectionLayout {
implicitHeight: parent.height
ensUsernamesStore: root.store.ensUsernamesStore
walletAssetsStore: root.walletAssetsStore
sendModalPopup: root.sendModalPopup
contactsStore: root.store.contactsStore
networkConnectionStore: root.networkConnectionStore
profileContentWidth: d.contentWidth
onConnectUsernameRequested: Global.connectUsernameRequested(ensName)
onRegisterUsernameRequested: Global.registerUsernameRequested(ensName)
onReleaseUsernameRequested: Global.releaseUsernameRequested(ensName, senderAddress, chainId)
}
}
@ -300,7 +301,6 @@ StatusSectionLayout {
myPublicKey: root.store.contactsStore.myPublicKey
currencySymbol: root.sharedRootStore.currencyStore.currentCurrency
emojiPopup: root.emojiPopup
sendModalPopup: root.sendModalPopup
sectionTitle: settingsEntriesModel.getNameForSubsection(Constants.settingsSubsection.wallet)
}
onLoaded: root.store.backButtonName = ""

View File

@ -20,7 +20,7 @@ Item {
id: root
property EnsUsernamesStore ensUsernamesStore
property string username: ""
property string chainId: ""
property int chainId: -1
signal backBtnClicked()
signal releaseUsernameRequested(string senderAddress)

View File

@ -25,7 +25,7 @@ Item {
property int profileContentWidth
signal addBtnClicked()
signal selectEns(string username, string chainId)
signal selectEns(string username, int chainId)
Component.onCompleted: {
d.updateNumberOfPendingEnsUsernames()

View File

@ -24,9 +24,22 @@ Item {
property EnsUsernamesStore ensUsernamesStore
property string username: ""
required property var assetsModel
signal backBtnClicked()
signal registerUsername()
QtObject {
id: d
readonly property var sntToken: statusTokenEntry.item
readonly property SumAggregator aggregator: SumAggregator {
model: !!d.sntToken && !!d.sntToken.balances ? d.sntToken.balances: null
roleName: "balance"
}
property real sntBalance: !!sntToken && !!sntToken.decimals ? aggregator.value/(10 ** sntToken.decimals): 0
}
StatusBaseText {
id: sectionTitle
text: qsTr("ENS usernames")
@ -346,4 +359,11 @@ Item {
enabled: d.sntBalance >= 10 && termsAndConditionsCheckbox.checked
onClicked: root.registerUsername(root.username)
}
ModelEntry {
id: statusTokenEntry
sourceModel: root.assetsModel
key: "tokensKey"
value: root.ensUsernamesStore.getStatusTokenKey()
}
}

View File

@ -24,8 +24,6 @@ Item {
property EnsUsernamesStore ensUsernamesStore
property WalletAssetsStore walletAssetsStore
required property var sendModalPopup
property ContactsStore contactsStore
property SharedStores.NetworkConnectionStore networkConnectionStore
@ -33,7 +31,7 @@ Item {
property bool showSearchScreen: false
property string addedUsername: ""
property string selectedUsername: ""
property string selectedChainId: ""
property int selectedChainId: -1
signal next(output: string)
signal back()
@ -43,6 +41,10 @@ Item {
signal goToWelcome();
signal goToList();
signal connectUsernameRequested(string ensName)
signal registerUsernameRequested(string ensName)
signal releaseUsernameRequested(string ensName, string senderAddress, int chainId)
Layout.fillHeight: true
Layout.fillWidth: true
clip: true
@ -53,13 +55,6 @@ Item {
readonly property string registerENS: "RegisterENS"
readonly property string setPubKey: "SetPubKey"
readonly property string releaseENS: "ReleaseENS"
readonly property var sntToken: ModelUtils.getByKey(ensView.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", ensView.ensUsernamesStore.getStatusTokenKey())
readonly property SumAggregator aggregator: SumAggregator {
model: !!d.sntToken && !!d.sntToken.balances ? d.sntToken.balances: nil
roleName: "balance"
}
property real sntBalance: !!sntToken && !!sntToken.decimals ? aggregator.value/(10 ** sntToken.decimals): 0
}
DSM.StateMachine {
@ -261,19 +256,7 @@ Item {
onConnectUsername: {
ensView.selectedUsername = username
ensView.sendModalPopup.modalHeaderText = qsTr("Connect username with your pubkey")
ensView.sendModalPopup.interactive = false
ensView.sendModalPopup.preSelectedRecipient = ensView.ensUsernamesStore.getEnsRegisteredAddress()
ensView.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
ensView.sendModalPopup.preSelectedHoldingID = Constants.ethToken
ensView.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC20
ensView.sendModalPopup.preSelectedSendType = Constants.SendType.ENSSetPubKey
ensView.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(0)
ensView.sendModalPopup.preSelectedChainId = ensView.selectedChainId
ensView.sendModalPopup.publicKey = ensView.contactsStore.myPublicKey
ensView.sendModalPopup.ensName = ensView.selectedUsername
ensView.sendModalPopup.open()
ensView.connectUsernameRequested(ensView.selectedUsername)
}
Connections {
@ -293,22 +276,11 @@ Item {
EnsTermsAndConditionsView {
ensUsernamesStore: ensView.ensUsernamesStore
username: selectedUsername
assetsModel: ensView.walletAssetsStore.groupedAccountAssetsModel
onBackBtnClicked: back();
onRegisterUsername: {
ensView.sendModalPopup.interactive = false
ensView.sendModalPopup.preSelectedRecipient = ensView.ensUsernamesStore.getEnsRegisteredAddress()
ensView.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
ensView.sendModalPopup.preSelectedHoldingID = !!d.sntToken && !!d.sntToken.symbol ? d.sntToken.symbol: ""
ensView.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC20
ensView.sendModalPopup.preSelectedSendType = Constants.SendType.ENSRegister
ensView.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(10)
ensView.sendModalPopup.preSelectedChainId = ensView.selectedChainId
ensView.sendModalPopup.publicKey = ensView.contactsStore.myPublicKey
ensView.sendModalPopup.ensName = ensView.selectedUsername
ensView.sendModalPopup.open()
}
onRegisterUsername: ensView.registerUsernameRequested(ensView.selectedUsername)
Connections {
target: ensView.ensUsernamesStore.ensUsernamesModule
@ -384,20 +356,7 @@ Item {
Global.openPopup(noAccountPopupComponent)
return
}
ensView.sendModalPopup.modalHeaderText = qsTr("Release your username")
ensView.sendModalPopup.interactive = false
ensView.sendModalPopup.preSelectedAccountAddress = senderAddress
ensView.sendModalPopup.preSelectedRecipient = ensView.ensUsernamesStore.getEnsRegisteredAddress()
ensView.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
ensView.sendModalPopup.preSelectedHoldingID = Constants.ethToken
ensView.sendModalPopup.preSelectedHoldingType = Constants.TokenType.Native
ensView.sendModalPopup.preSelectedSendType = Constants.SendType.ENSRelease
ensView.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(0)
ensView.sendModalPopup.preSelectedChainId = ensView.selectedChainId
ensView.sendModalPopup.publicKey = ensView.contactsStore.myPublicKey
ensView.sendModalPopup.ensName = ensView.selectedUsername
ensView.sendModalPopup.open()
ensView.releaseUsernameRequested(ensView.selectedUsername, senderAddress, ensView.selectedChainId)
}
Connections {

View File

@ -44,8 +44,6 @@ SettingsContentBase {
required property WalletAssetsStore assetsStore
required property CollectiblesStore collectiblesStore
required property var sendModalPopup
readonly property int mainViewIndex: 0
readonly property int networksViewIndex: 1
readonly property int editNetworksViewIndex: 2
@ -372,7 +370,10 @@ SettingsContentBase {
id: savedAddressesView
contactsStore: root.rootStore.contactsStore
networkConnectionStore: root.networkConnectionStore
sendModal: root.sendModalPopup
onSendToAddressRequested: {
Global.sendToSavedAddressRequested(address)
}
}
Component {

View File

@ -12,11 +12,13 @@ ColumnLayout {
property ContactsStore contactsStore
property SharedStores.NetworkConnectionStore networkConnectionStore
property var sendModal
signal sendToAddressRequested(string address)
SavedAddresses {
sendModal: root.sendModal
contactsStore: root.contactsStore
networkConnectionStore: root.networkConnectionStore
onSendToAddressRequested: root.sendToAddressRequested(address)
}
}

View File

@ -37,7 +37,6 @@ Item {
required property TransactionStore transactionStore
property var emojiPopup: null
property var sendModalPopup
property SharedStores.NetworkConnectionStore networkConnectionStore
property bool appMainVisible
@ -211,13 +210,16 @@ Item {
store: root.store
contactsStore: root.contactsStore
networkConnectionStore: root.networkConnectionStore
sendModal: root.sendModalPopup
networkFilter.visible: false
headerButton.text: qsTr("Add new address")
headerButton.onClicked: {
Global.openAddEditSavedAddressesPopup({})
}
onSendToAddressRequested: {
Global.sendToSavedAddressRequested(address)
}
}
}
@ -228,7 +230,6 @@ Item {
store: root.store
contactsStore: root.contactsStore
communitiesStore: root.communitiesStore
sendModal: root.sendModalPopup
networkConnectionStore: root.networkConnectionStore
swapEnabled: root.swapEnabled
@ -331,40 +332,33 @@ Item {
hasFloatingButtons: true
})
onLaunchSendModal: (fromAddress) => {
if(isCommunityOwnershipTransfer) {
const tokenItem = walletStore.currentViewedCollectible
const ownership = StatusQUtils.ModelUtils.get(tokenItem.ownership, 0)
if(isCommunityOwnershipTransfer) {
const tokenItem = walletStore.currentViewedCollectible
const ownership = StatusQUtils.ModelUtils.get(tokenItem.ownership, 0)
Global.openTransferOwnershipPopup(tokenItem.communityId,
footer.communityName,
tokenItem.communityImage,
{
key: tokenItem.tokenId,
privilegesLevel: tokenItem.communityPrivilegesLevel,
chainId: tokenItem.chainId,
name: tokenItem.name,
artworkSource: tokenItem.artworkSource,
accountAddress: fromAddress,
tokenAddress: tokenItem.contractAddress
},
root.sendModalPopup)
return
}
Global.openTransferOwnershipPopup(tokenItem.communityId,
footer.communityName,
tokenItem.communityImage,
{
key: tokenItem.tokenId,
privilegesLevel: tokenItem.communityPrivilegesLevel,
chainId: tokenItem.chainId,
name: tokenItem.name,
artworkSource: tokenItem.artworkSource,
accountAddress: fromAddress,
tokenAddress: tokenItem.contractAddress
})
return
}
// Common send modal popup:
root.sendModalPopup.preSelectedAccountAddress = fromAddress
root.sendModalPopup.preSelectedSendType = Constants.SendType.Transfer
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingTokensKey
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
root.sendModalPopup.onlyAssets = false
root.sendModalPopup.open()
}
// Common send modal popup:
Global.sendTokenRequested(fromAddress,
walletStore.currentViewedHoldingTokensKey,
walletStore.currentViewedHoldingType)
}
onLaunchBridgeModal: {
root.sendModalPopup.preSelectedSendType = Constants.SendType.Bridge
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
root.sendModalPopup.onlyAssets = true
root.sendModalPopup.open()
Global.bridgeTokenRequested(walletStore.currentViewedHoldingID,
walletStore.currentViewedHoldingType)
}
onLaunchSwapModal: {
d.swapFormData.fromTokensKey = ""

View File

@ -122,7 +122,7 @@ Rectangle {
interactive: !d.isCollectibleSoulbound && networkConnectionStore.sendBuyBridgeEnabled
onClicked: {
root.transactionStore.setSenderAccount(root.walletStore.selectedAddress)
root.launchSendModal(d.userOwnedAddressForCollectible)
root.launchSendModal(d.isCollectibleViewed ? d.userOwnedAddressForCollectible: root.walletStore.selectedAddress)
}
tooltip.text: d.isCollectibleSoulbound ? qsTr("Soulbound collectibles cannot be sent to another wallet") : networkConnectionStore.sendBuyBridgeToolTipText
visible: d.sendActionAvailable

View File

@ -14,6 +14,7 @@ import AppLayouts.Wallet.stores 1.0 as WalletStore
import utils 1.0
import shared.views 1.0
import shared.popups.send 1.0
import shared.stores 1.0 as SharedStores
import "../controls"
@ -24,7 +25,8 @@ StatusModal {
property SharedStores.NetworkConnectionStore networkConnectionStore
property ProfileStores.ContactsStore contactsStore
property var sendModalPopup
signal sendToAddressRequested(string address)
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
hasCloseButton: false
@ -162,8 +164,8 @@ StatusModal {
root.close()
}
onOpenSendModal: {
root.close()
root.sendModalPopup.open(recipient)
root.sendToAddressRequested(recipient)
root.close()
}
}
@ -240,8 +242,8 @@ StatusModal {
icon.name: "send"
enabled: root.networkConnectionStore.sendBuyBridgeEnabled
onClicked: {
root.sendToAddressRequested(d.visibleAddress)
root.close()
root.sendModalPopup.open(d.visibleAddress)
}
}

View File

@ -21,8 +21,6 @@ FocusScope {
property bool swapEnabled
property var sendModal
property alias header: header
property alias headerButton: header.headerButton
property alias networkFilter: header.networkFilter

View File

@ -309,13 +309,8 @@ RightTabBaseView {
swapVisible: root.swapEnabled
onSendRequested: {
const modal = root.sendModal
modal.preSelectedSendType = Constants.SendType.Transfer
modal.preSelectedHoldingID = key
modal.preSelectedHoldingType = Constants.TokenType.ERC20
modal.onlyAssets = true
modal.open()
Global.sendTokenRequested(RootStore.overview.mixedcaseAddress.toLowerCase(),
key, Constants.TokenType.ERC20)
}
onSwapRequested: root.launchSwapModal(key)
@ -415,33 +410,27 @@ RightTabBaseView {
stack.currentIndex = 1
}
onSendRequested: (symbol, tokenType, fromAddress) => {
const collectible = ModelUtils.getByKey(controller.sourceModel, "symbol", symbol)
if (!!collectible && collectible.communityPrivilegesLevel === Constants.TokenPrivilegesLevel.Owner) {
Global.openTransferOwnershipPopup(collectible.communityId,
collectible.communityName,
collectible.communityImage,
{
key: collectible.tokenId,
privilegesLevel: collectible.communityPrivilegesLevel,
chainId: collectible.chainId,
name: collectible.name,
artworkSource: collectible.communityImage,
accountAddress: fromAddress,
tokenAddress: collectible.contractAddress
},
root.sendModal)
return
}
root.sendModal.preSelectedAccountAddress = fromAddress
root.sendModal.preSelectedHoldingID = symbol
root.sendModal.preSelectedHoldingType = tokenType
root.sendModal.preSelectedSendType = tokenType === Constants.TokenType.ERC721 ?
Constants.SendType.ERC721Transfer:
Constants.SendType.ERC1155Transfer
root.sendModal.onlyAssets = false
root.sendModal.open()
}
const collectible = ModelUtils.getByKey(controller.sourceModel, "symbol", symbol)
if (!!collectible && collectible.communityPrivilegesLevel === Constants.TokenPrivilegesLevel.Owner) {
Global.openTransferOwnershipPopup(collectible.communityId,
collectible.communityName,
collectible.communityImage,
{
key: collectible.tokenId,
privilegesLevel: collectible.communityPrivilegesLevel,
chainId: collectible.chainId,
name: collectible.name,
artworkSource: collectible.communityImage,
accountAddress: fromAddress,
tokenAddress: collectible.contractAddress
})
return
}
Global.sendTokenRequested(fromAddress ,
symbol,
tokenType)
}
onReceiveRequested: (symbol) => root.launchShareAddressModal()
onSwitchToCommunityRequested: (communityId) => Global.switchToCommunity(communityId)
onManageTokensRequested: Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.wallet,

View File

@ -20,10 +20,11 @@ import "../controls"
ColumnLayout {
id: root
property var sendModal
property ProfileStores.ContactsStore contactsStore
property SharedStores.NetworkConnectionStore networkConnectionStore
signal sendToAddressRequested(string address)
QtObject {
id: d
@ -149,7 +150,7 @@ ColumnLayout {
colorId: model.colorId
networkConnectionStore: root.networkConnectionStore
areTestNetworksEnabled: RootStore.areTestNetworksEnabled
onOpenSendModal: root.sendModal.open(recipient);
onOpenSendModal: root.sendToAddressRequested(recipient)
states: [
State {

View File

@ -3,13 +3,16 @@ import QtQuick 2.13
RightTabBaseView {
id: root
signal sendToAddressRequested(string address)
SavedAddresses {
objectName: "savedAddressesArea"
width: root.width
height: root.height - header.height
sendModal: root.sendModal
contactsStore: root.contactsStore
networkConnectionStore: root.networkConnectionStore
onSendToAddressRequested: root.sendToAddressRequested(address)
}
}

View File

@ -119,8 +119,6 @@ Item {
rootChatStore: appMain.rootChatStore
communityTokensStore: appMain.communityTokensStore
profileStore: appMain.profileStore
sendModalPopup: sendModal
}
Connections {
@ -615,6 +613,24 @@ Item {
}
}
SendModalHandler {
popupParent: appMain
loginType: appMain.rootStore.loginType
transactionStore: appMain.transactionStore
walletCollectiblesStore: appMain.walletCollectiblesStore
// for ens flows
ensRegisteredAddress: appMain.rootStore.profileSectionStore.ensUsernamesStore.getEnsRegisteredAddress()
myPublicKey: appMain.rootStore.contactStore.myPublicKey
getStatusTokenKey: function() {
return appMain.rootStore.profileSectionStore.ensUsernamesStore.getStatusTokenKey()
}
// for sticker flows
stickersMarketAddress: appMain.rootChatStore.stickersStore.getStickersMarketAddress()
stickersNetworkId: appMain.rootChatStore.appNetworkId
}
Connections {
id: globalConns
target: Global
@ -683,10 +699,6 @@ Item {
}
}
function onOpenSendModal(address: string) {
sendModal.open(address)
}
function onSwitchToCommunity(communityId: string) {
appMain.communitiesStore.setActiveCommunity(communityId)
}
@ -828,10 +840,8 @@ Item {
active: appMain.rootStore.mainModuleInst.sectionsLoaded
sourceComponent: StatusStickersPopup {
store: appMain.rootChatStore
walletAssetsStore: appMain.walletAssetsStore
sendModalPopup: sendModal
isWalletEnabled: appMain.profileStore.isWalletEnabled
onBuyClicked: Global.buyStickerPackRequested(packId, price)
}
}
@ -1611,7 +1621,6 @@ Item {
communitiesStore: appMain.communitiesStore
transactionStore: appMain.transactionStore
emojiPopup: statusEmojiPopup.item
sendModalPopup: sendModal
networkConnectionStore: appMain.networkConnectionStore
appMainVisible: appMain.visible
swapEnabled: featureFlagsStore.swapEnabled
@ -1636,7 +1645,6 @@ Item {
store: appMain.rootStore.profileSectionStore
globalStore: appMain.rootStore
communitiesStore: appMain.communitiesStore
sendModalPopup: sendModal
systemPalette: appMain.sysPalette
emojiPopup: statusEmojiPopup.item
networkConnectionStore: appMain.networkConnectionStore
@ -1719,7 +1727,6 @@ Item {
}
}
sendModalPopup: sendModal
emojiPopup: statusEmojiPopup.item
stickersPopup: statusStickersPopupLoader.item
sectionItemModel: model
@ -1819,104 +1826,6 @@ Item {
}
}
// Add SendModal here as it is used by the Wallet as well as the Browser
Loader {
id: sendModal
active: false
function open(address = "") {
if (!!address) {
preSelectedRecipient = address
preSelectedRecipientType = SendPopups.Helpers.RecipientAddressObjectType.Address
}
this.active = true
this.item.open()
}
function closed() {
// this.sourceComponent = undefined // kill an opened instance
this.active = false
}
property string modalHeaderText
property bool interactive: true
property string preSelectedAccountAddress
property var preSelectedRecipient
property int preSelectedRecipientType
property string preSelectedHoldingID
property int preSelectedHoldingType: Constants.TokenType.Unknown
property int preSelectedSendType: Constants.SendType.Unknown
property string preDefinedAmountToSend
property int preSelectedChainId: 0
property bool onlyAssets: false
property string stickersPackId: ""
property string publicKey: ""
property string ensName: ""
sourceComponent: SendPopups.SendModal {
interactive: sendModal.interactive
onlyAssets: sendModal.onlyAssets
loginType: appMain.rootStore.loginType
store: appMain.transactionStore
collectiblesStore: appMain.walletCollectiblesStore
showCustomRoutingMode: !production
onClosed: {
sendModal.closed()
sendModal.modalHeaderText = ""
sendModal.interactive = true
sendModal.preSelectedSendType = Constants.SendType.Unknown
sendModal.preSelectedHoldingID = ""
sendModal.preSelectedHoldingType = Constants.TokenType.Unknown
sendModal.preSelectedAccountAddress = ""
sendModal.preSelectedRecipient = undefined
sendModal.preDefinedAmountToSend = ""
sendModal.preSelectedChainId = 0
sendModal.stickersPackId = ""
sendModal.publicKey = ""
sendModal.ensName = ""
}
}
onLoaded: {
if (!!sendModal.preSelectedAccountAddress) {
item.preSelectedAccountAddress = sendModal.preSelectedAccountAddress
}
if (!!sendModal.preSelectedRecipient) {
// NOTE Should be assigned in that order: type then recipient
item.preSelectedRecipientType = sendModal.preSelectedRecipientType
item.preSelectedRecipient = sendModal.preSelectedRecipient
}
if (sendModal.preSelectedSendType !== Constants.SendType.Unknown) {
item.preSelectedSendType = sendModal.preSelectedSendType
}
if (sendModal.preSelectedHoldingType !== Constants.TokenType.Unknown) {
item.preSelectedHoldingID = sendModal.preSelectedHoldingID
item.preSelectedHoldingType = sendModal.preSelectedHoldingType
}
if (sendModal.preDefinedAmountToSend != "") {
item.preDefinedAmountToSend = sendModal.preDefinedAmountToSend
}
if (!!sendModal.preSelectedChainId) {
item.preSelectedChainId = sendModal.preSelectedChainId
}
if (!!sendModal.stickersPackId) {
item.stickersPackId = sendModal.stickersPackId
}
if (!!sendModal.publicKey) {
item.publicKey = sendModal.publicKey
}
if (!!sendModal.ensName) {
item.ensName = sendModal.ensName
}
}
}
Action {
shortcut: "Ctrl+1"
onTriggered: {
@ -2346,8 +2255,10 @@ Item {
sourceComponent: WalletPopups.SavedAddressActivityPopup {
networkConnectionStore: appMain.networkConnectionStore
contactsStore: appMain.rootStore.contactStore
sendModalPopup: sendModal
onSendToAddressRequested: {
Global.sendToSavedAddressRequested(address)
}
onClosed: {
savedAddressActivity.close()
}

View File

@ -349,8 +349,8 @@ QtObject {
openPopup(importControlNodePopup, { community })
}
function openTransferOwnershipPopup(communityId, communityName, communityLogo, token, sendModalPopup) {
openPopup(transferOwnershipPopup, { communityId, communityName, communityLogo, token, sendModalPopup })
function openTransferOwnershipPopup(communityId, communityName, communityLogo, token) {
openPopup(transferOwnershipPopup, { communityId, communityName, communityLogo, token })
}
function openConfirmExternalLinkPopup(link, domain) {
@ -1043,6 +1043,9 @@ QtObject {
Component {
id: transferOwnershipPopup
TransferOwnershipPopup {
onTransferOwnershipRequested: {
Global.transferOwnershipRequested(tokenId, senderAddress)
}
onClosed: destroy()
}
},

View File

@ -0,0 +1,166 @@
import QtQuick 2.15
import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
import AppLayouts.Wallet.stores 1.0 as WalletStores
import shared.popups.send 1.0
import shared.stores.send 1.0
import utils 1.0
QtObject {
id: root
required property var popupParent
required property int loginType
required property TransactionStore transactionStore
required property WalletStores.CollectiblesStore walletCollectiblesStore
// for ens flows
required property string myPublicKey
required property string ensRegisteredAddress
// TODO: This should probably be a property and not a function. Needs changes on backend side
property var getStatusTokenKey: function() {}
// for sticker flows
required property string stickersMarketAddress
required property string stickersNetworkId
Component.onCompleted: {
Global.launchSendRequested.connect(openSend)
Global.connectUsernameRequested.connect(connectUsernameRequested)
Global.registerUsernameRequested.connect(registerUsernameRequested)
Global.releaseUsernameRequested.connect(releaseUsernameRequested)
Global.buyStickerPackRequested.connect(buyStickerPackRequested)
Global.transferOwnershipRequested.connect(transferOwnershipRequested)
Global.sendViaPersonalChatRequested.connect(sendToRecipient)
Global.sendToAccountViaProfileShowcaseRequested.connect(sendToRecipient)
Global.sendToSavedAddressRequested.connect(sendToRecipient)
Global.bridgeTokenRequested.connect(bridgeTokenRequested)
Global.sendTokenRequested.connect(sendTokenRequested)
}
function openSend(params = {}) {
let sendModalInst = sendModalComponent.createObject(popupParent, params)
if (sendModalInst.opened) {
return
}
sendModalInst.open()
}
function connectUsernameRequested(ensName) {
let params = {
preSelectedSendType: Constants.SendType.ENSSetPubKey,
preSelectedHoldingID: Constants.ethToken ,
preSelectedHoldingType: Constants.TokenType.Native,
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0),
preSelectedRecipient: root.ensRegisteredAddress,
interactive: false,
publicKey: root.myPublicKey,
ensName: ensName
}
openSend(params)
}
function registerUsernameRequested(ensName) {
let params = {
preSelectedSendType: Constants.SendType.ENSRegister,
preSelectedHoldingID: root.getStatusTokenKey(),
preSelectedHoldingType: Constants.TokenType.ERC20,
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10),
preSelectedRecipient: root.ensRegisteredAddress,
interactive: false,
publicKey: root.myPublicKey,
ensName: ensName
}
openSend(params)
}
function releaseUsernameRequested(ensName, senderAddress, chainId) {
let params = {
preSelectedSendType: Constants.SendType.ENSRelease,
preSelectedAccountAddress: senderAddress,
preSelectedHoldingID: Constants.ethToken ,
preSelectedHoldingType: Constants.TokenType.Native,
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0),
preSelectedChainId: chainId,
preSelectedRecipient: root.ensRegisteredAddress,
interactive: false,
publicKey: root.myPublicKey,
ensName: ensName
}
openSend(params)
}
function buyStickerPackRequested(packId, price) {
let params = {
preSelectedSendType: Constants.SendType.StickersBuy,
preSelectedHoldingID: root.getStatusTokenKey(),
preSelectedHoldingType: Constants.TokenType.ERC20,
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(price),
preSelectedChainId: root.stickersNetworkId,
preSelectedRecipient: root.stickersMarketAddress,
interactive: false,
stickersPackId: packId
}
openSend(params)
}
function transferOwnershipRequested(tokenId, senderAddress) {
let params = {
preSelectedSendType: Constants.SendType.ERC721Transfer,
preSelectedAccountAddress: senderAddress,
preSelectedHoldingID: tokenId,
preSelectedHoldingType: Constants.TokenType.ERC721,
}
openSend(params)
}
function sendToRecipient(recipientAddress) {
let params = {
preSelectedRecipient: recipientAddress
}
openSend(params)
}
function bridgeTokenRequested(tokenId, tokenType) {
let params = {
preSelectedSendType: Constants.SendType.Bridge,
preSelectedHoldingID: tokenId ,
preSelectedHoldingType: tokenType,
onlyAssets: true
}
openSend(params)
}
function sendTokenRequested(senderAddress, tokenId, tokenType) {
let sendType = Constants.SendType.Transfer
if (tokenType === Constants.TokenType.ERC721) {
sendType = Constants.SendType.ERC721Transfer
} else if(tokenType === Constants.TokenType.ERC1155) {
sendType = Constants.SendType.ERC1155Transfer
}
let params = {
preSelectedSendType: sendType,
preSelectedAccountAddress: senderAddress,
preSelectedHoldingID: tokenId ,
preSelectedHoldingType: tokenType,
}
openSend(params)
}
readonly property Component sendModalComponent: Component {
SendModal {
loginType: root.loginType
store: root.transactionStore
collectiblesStore: root.walletCollectiblesStore
showCustomRoutingMode: !production
onClosed: destroy()
}
}
}

View File

@ -34,9 +34,6 @@ QtObject {
required property SharedStores.CommunityTokensStore communityTokensStore
required property ProfileStore profileStore
// Properties:
required property var sendModalPopup
// Utils:
readonly property string viewOptimismExplorerText: qsTr("View on Optimism Explorer")
readonly property string checkmarkCircleAssetName: "checkmark-circle"
@ -241,7 +238,7 @@ QtObject {
Global.openFinaliseOwnershipPopup(actionData)
return
case ToastsManager.ActionType.OpenSendModalPopup:
root.sendModalPopup.open()
Global.launchSendRequested()
return
case ToastsManager.ActionType.ViewTransactionDetails:
if(actionData) {

View File

@ -3,3 +3,4 @@ SplashScreen 1.0 SplashScreen.qml
Popups 1.0 Popups.qml
StatusTrayIcon 1.0 StatusTrayIcon.qml
DropAreaPanel 1.0 panels/DropAreaPanel.qml
SendModalHandler 1.0 SendModalHandler.qml

View File

@ -183,6 +183,20 @@ StatusDialog {
d.routerErrorDetails = ""
debounceRecalculateRoutesAndFees()
}
function getTitleText() {
switch (store.sendType) {
case Constants.SendType.Bridge:
return qsTr("Bridge")
case Constants.SendType.ENSRegister:
return qsTr("Register Ens")
case Constants.SendType.ENSSetPubKey:
return qsTr("Connect username")
case Constants.SendType.ENSRelease:
return qsTr("Release username")
default: return qsTr("Send")
}
}
}
LeftJoinModel {
@ -372,7 +386,7 @@ StatusDialog {
objectName: "modalHeader"
Layout.maximumWidth: contentWidth
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
text: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
text: d.getTitleText()
}
TokenSelector {

View File

@ -26,8 +26,6 @@ Item {
property ChatStores.RootStore store
property var stickerPacks: ChatStores.StickerPackData {}
required property WalletAssetsStore walletAssetsStore
required property var sendModalPopup
property string packId
property bool marketVisible
property bool isWalletEnabled
@ -37,27 +35,7 @@ Item {
signal installClicked(var stickers, string packId, int index)
signal cancelClicked(string packId)
signal updateClicked(string packId)
signal buyClicked(string packId)
QtObject {
id: d
function runSendModal(price, packId) {
const token = ModelUtils.getByKey(root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", root.store.stickersStore.getStatusTokenKey())
root.sendModalPopup.interactive = false
root.sendModalPopup.preSelectedRecipient = root.store.stickersStore.getStickersMarketAddress()
root.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
root.sendModalPopup.preSelectedHoldingID = !!token && !!token.symbol ? token.symbol : ""
root.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC20
root.sendModalPopup.preSelectedSendType = Constants.SendType.StickersBuy
root.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(parseFloat(price))
root.sendModalPopup.preSelectedChainId = root.store.appNetworkId
root.sendModalPopup.stickersPackId = packId
root.sendModalPopup.open()
}
}
signal buyClicked(string packId, int price)
StatusGridView {
id: availableStickerPacks
@ -174,10 +152,7 @@ Item {
onUninstallClicked: root.uninstallClicked(packId)
onCancelClicked: root.cancelClicked(packId)
onUpdateClicked: root.updateClicked(packId)
onBuyClicked: {
d.runSendModal(price, packId)
root.buyClicked(packId)
}
onBuyClicked: root.buyClicked(packId, price)
}
}
@ -207,10 +182,7 @@ Item {
onUninstallClicked: root.uninstallClicked(packId)
onCancelClicked: root.cancelClicked(packId)
onUpdateClicked: root.updateClicked(packId)
onBuyClicked: {
d.runSendModal(price, packId)
root.buyClicked(packId)
}
onBuyClicked: root.buyClicked(packId, price)
}
}
}

View File

@ -5,6 +5,7 @@ import QtGraphicalEffects 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
import StatusQ.Core.Theme 0.1
import utils 1.0
import shared 1.0
@ -16,17 +17,14 @@ import shared.stores.send 1.0
//TODO remove this dependency!
import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Wallet.stores 1.0
// TODO: replace with StatusModal
ModalPopup {
id: stickerPackDetailsPopup
id: root
property string packId
property ChatStores.RootStore store
required property WalletAssetsStore walletAssetsStore
required property var sendModalPopup
property string thumbnail: ""
property string name: ""
property string author: ""
@ -35,7 +33,7 @@ ModalPopup {
property bool bought: false
property bool pending: false
property var stickers
signal buyClicked(string packId)
signal buyClicked()
onAboutToShow: {
stickersModule.getInstalledStickerPacks()
@ -71,7 +69,7 @@ ModalPopup {
model: stickers
anchors.fill: parent
anchors.topMargin: Theme.padding
packId: stickerPackDetailsPopup.packId
packId: root.packId
}
footer: StatusStickerButton {
@ -85,29 +83,14 @@ ModalPopup {
tooltip.text: store.networkConnectionStore.stickersNetworkUnavailableText
onInstallClicked: {
stickersModule.install(packId)
stickerPackDetailsPopup.close()
root.close()
}
onUninstallClicked: {
stickersModule.uninstall(packId);
stickerPackDetailsPopup.close();
root.close();
}
onCancelClicked: function(){}
onUpdateClicked: function(){}
onBuyClicked: {
const token = SQUtils.ModelUtils.getByKey(stickerPackDetailsPopup.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", stickerPackDetailsPopup.store.stickersStore.getStatusTokenKey())
stickerPackDetailsPopup.sendModalPopup.interactive = false
stickerPackDetailsPopup.sendModalPopup.preSelectedRecipient = stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
stickerPackDetailsPopup.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
stickerPackDetailsPopup.sendModalPopup.preSelectedHoldingID = !!token && !!token.symbol ? token.symbol : ""
stickerPackDetailsPopup.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC20
stickerPackDetailsPopup.sendModalPopup.preSelectedSendType = Constants.SendType.StickersBuy
stickerPackDetailsPopup.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(parseFloat(stickerPackDetailsPopup.price))
stickerPackDetailsPopup.sendModalPopup.preSelectedChainId = stickerPackDetailsPopup.store.appNetworkId
stickerPackDetailsPopup.sendModalPopup.stickersPackId = stickerPackDetailsPopup.packId
stickerPackDetailsPopup.sendModalPopup.open()
stickerPackDetailsPopup.buyClicked(stickerPackDetailsPopup.packId)
}
onBuyClicked: root.buyClicked()
}
}

View File

@ -13,18 +13,16 @@ import StatusQ.Controls 0.1
import StatusQ.Components 0.1
//TODO improve this!
import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Wallet.stores 1.0
Popup {
id: root
property ChatStores.RootStore store
required property WalletAssetsStore walletAssetsStore
required property var sendModalPopup
property alias isWalletEnabled: stickerMarket.isWalletEnabled
signal stickerSelected(string hashId, string packId, string url)
signal buyClicked(string packId, string price)
QtObject {
id: d
@ -102,8 +100,6 @@ Popup {
Layout.fillWidth: true
Layout.fillHeight: true
store: root.store
walletAssetsStore: root.walletAssetsStore
sendModalPopup: root.sendModalPopup
stickerPacks: d.stickerPackList
packId: stickerPackListView.selectedPackId
marketVisible: d.stickerPacksLoaded && d.online
@ -121,6 +117,7 @@ Popup {
footerContent.visible = true
stickersContainer.visible = true
}
onBuyClicked: root.buyClicked(packId, price)
Connections {
target: root.store.stickersModuleInst

View File

@ -17,7 +17,6 @@ import utils 1.0
import "../panels"
import "../popups"
import "../popups/send"
import "../stores"
import "../controls"

View File

@ -541,6 +541,9 @@ Pane {
onCloseRequested: root.closeRequested()
onCopyToClipboard: ClipboardUtils.setText(text)
onSendToAccountRequested: {
Global.sendToAccountViaProfileShowcaseRequested(recipientAddress)
}
}
}
}

View File

@ -10,6 +10,7 @@ import shared.popups 1.0
import shared.views.chat 1.0
import shared.controls.chat 1.0
import shared.stores 1.0 as SharedStores
import shared.popups.send 1.0
import StatusQ 0.1
import StatusQ.Core 0.1
@ -240,6 +241,7 @@ Loader {
}
signal openStickerPackPopup(string stickerPackId)
signal sendViaPersonalChatRequested(string recipientAddress)
z: (typeof chatLogView === "undefined") ? 1 : (chatLogView.count - index)
@ -759,7 +761,7 @@ Loader {
onLinkActivated: {
if (link.startsWith(Constants.sendViaChatPrefix)) {
const addressOrEns = link.replace(Constants.sendViaChatPrefix, "");
Global.openSendModal(addressOrEns)
root.sendViaPersonalChatRequested(addressOrEns)
return
}
if (link.startsWith('//')) {

View File

@ -25,6 +25,7 @@ Item {
property alias cellHeight: accountsView.cellHeight
signal copyToClipboard(string text)
signal sendToAccountRequested(string recipientAddress)
StatusBaseText {
anchors.centerIn: parent
@ -68,9 +69,7 @@ Item {
icon.name: "send"
icon.color: !hovered ? Theme.palette.baseColor1 : Theme.palette.directColor1
enabled: root.sendToAccountEnabled
onClicked: {
Global.openSendModal(model.address)
}
onClicked: root.sendToAccountRequested(model.address)
onHoveredChanged: accountInfoDelegate.highlight = hovered
}
StatusFlatRoundButton {

View File

@ -41,6 +41,7 @@ Control {
signal closeRequested()
signal copyToClipboard(string text)
signal sendToAccountRequested(string recipientAddress)
horizontalPadding: readOnly ? 20 : 40 // smaller in settings/preview
topPadding: Theme.bigPadding
@ -155,6 +156,7 @@ Control {
cellHeight: d.delegateHeightM
onCopyToClipboard: root.copyToClipboard(text)
onSendToAccountRequested: root.sendToAccountRequested(recipientAddress)
}
ProfileShowcaseCollectiblesView {

View File

@ -50,8 +50,7 @@ QtObject {
signal openTransferOwnershipPopup(string communityId,
string communityName,
string communityLogo,
var token,
var sendModalPopup)
var token)
signal openFinaliseOwnershipPopup(string communityId)
signal openDeclineOwnershipPopup(string communityId, string communityName)
signal openFirstTokenReceivedPopup(string communityId,
@ -72,7 +71,6 @@ QtObject {
signal setNthEnabledSectionActive(int nthSection)
signal appSectionBySectionTypeChanged(int sectionType, int subsection, int subSubsection, var data)
signal openSendModal(string address)
signal switchToCommunity(string communityId)
signal switchToCommunitySettings(string communityId)
signal switchToCommunityChannelsView(string communityId)
@ -108,6 +106,19 @@ QtObject {
signal openSavedAddressActivityPopup(var params)
signal openCommunityMemberMessagesPopupRequested(var store, var chatCommunitySectionModule, var memberPubKey, var displayName)
// Intent based launch send modal signals
signal launchSendRequested()
signal connectUsernameRequested(string ensName)
signal registerUsernameRequested(string ensName)
signal releaseUsernameRequested(string ensName, string senderAddress, int chainId)
signal buyStickerPackRequested(string packId, int price)
signal transferOwnershipRequested(string tokenId, string senderAddress)
signal sendViaPersonalChatRequested(string recipientAddress)
signal sendToAccountViaProfileShowcaseRequested(string recipientAddress)
signal sendToSavedAddressRequested(string address)
signal bridgeTokenRequested(string tokenId, int tokenType)
signal sendTokenRequested(string senderAddress, string tokenId, int tokenType)
function openProfilePopup(publicKey, parentPopup, cb) {
root.openProfilePopupRequested(publicKey, parentPopup, cb)
}