Skip to content

Commit

Permalink
chore(@desktop/wallet): Chnage the send modal mechanism to follow new…
Browse files Browse the repository at this point in the history
… 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(....)
  • Loading branch information
Khushboo-dev-cpp committed Nov 26, 2024
1 parent c996971 commit d3e043b
Show file tree
Hide file tree
Showing 28 changed files with 302 additions and 297 deletions.
4 changes: 0 additions & 4 deletions ui/app/AppLayouts/Chat/ChatLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,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
Expand Down Expand Up @@ -164,7 +162,6 @@ StackLayout {
communitiesStore: root.communitiesStore
walletAssetsStore: root.walletAssetsStore
currencyStore: root.currencyStore
sendModalPopup: root.sendModalPopup
sectionItemModel: root.sectionItemModel
joinedMembersCount: membersModelAdaptor.joinedMembers.ModelCount.count
amIMember: sectionItem.amIMember
Expand Down Expand Up @@ -257,7 +254,6 @@ StackLayout {
enabledChainIds: WalletStore.RootStore.networkFilters
onEnableNetwork: WalletStore.RootStore.enableNetwork(chainId)
tokensStore: root.tokensStore
sendModalPopup: root.sendModalPopup
transactionStore: root.transactionStore

isPendingOwnershipRequest: root.isPendingOwnershipRequest
Expand Down
2 changes: 0 additions & 2 deletions ui/app/AppLayouts/Chat/views/ChatView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ StatusSectionLayout {
property CommunitiesStores.CommunitiesStore communitiesStore
required property WalletStore.WalletAssetsStore walletAssetsStore
required property SharedStores.CurrenciesStore currencyStore
required property var sendModalPopup
property var sectionItemModel
property int joinedMembersCount

Expand Down Expand Up @@ -353,7 +352,6 @@ StatusSectionLayout {
id: statusStickerPackClickPopup
StatusStickerPackClickPopup{
walletAssetsStore: root.walletAssetsStore
sendModalPopup: root.sendModalPopup
onClosed: {
destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions ui/app/AppLayouts/Communities/panels/OverviewSettingsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 })
}
Expand Down
12 changes: 6 additions & 6 deletions ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import StatusQ.Core.Utils 0.1
import StatusQ.Components 0.1

import shared.popups 1.0
import shared.popups.send 1.0
import AppLayouts.Wallet.stores 1.0 as WalletStores

import utils 1.0
Expand All @@ -26,7 +27,6 @@ StatusDialog {

// Transaction related props:
property var token // Expected roles: accountAddress, key, chainId, name, artworkSource
property var sendModalPopup

signal cancelClicked

Expand Down Expand Up @@ -109,13 +109,13 @@ 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()
Global.launchSendWithParams(Constants.SendType.ERC721Transfer, //sendType
token.accountAddress, //senderAddress
uid, //tokenId
Constants.TokenType.ERC721 //tokenType
)
close()
}
}
Expand Down
3 changes: 0 additions & 3 deletions ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ StatusSectionLayout {
required property var declinedMembers
required property TransactionStore transactionStore
property bool communitySettingsDisabled
property var sendModalPopup

required property string enabledChainIds

Expand Down Expand Up @@ -221,7 +220,6 @@ StatusSectionLayout {
pubsubTopic: root.community.pubsubTopic
pubsubTopicKey: root.community.pubsubTopicKey

sendModalPopup: root.sendModalPopup
ownerToken: tokensModelChangesTracker.ownerToken

isPendingOwnershipRequest: root.isPendingOwnershipRequest
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions ui/app/AppLayouts/Profile/ProfileLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -249,7 +248,6 @@ StatusSectionLayout {
implicitHeight: parent.height
ensUsernamesStore: root.store.ensUsernamesStore
walletAssetsStore: root.walletAssetsStore
sendModalPopup: root.sendModalPopup
contactsStore: root.store.contactsStore
networkConnectionStore: root.networkConnectionStore
profileContentWidth: d.contentWidth
Expand Down Expand Up @@ -289,7 +287,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 = ""
Expand Down
77 changes: 39 additions & 38 deletions ui/app/AppLayouts/Profile/views/EnsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ Item {
property EnsUsernamesStore ensUsernamesStore
property WalletAssetsStore walletAssetsStore

required property var sendModalPopup

property ContactsStore contactsStore
property SharedStores.NetworkConnectionStore networkConnectionStore

Expand Down Expand Up @@ -262,18 +260,19 @@ 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()
Global.launchSendWithParams(Constants.SendType.ENSSetPubKey, //sendType
"", //senderAddress
Constants.ethToken, //tokenId
Constants.TokenType.ERC20, //tokenType
LocaleUtils.numberToLocaleString(0), //tokenAmount
ensView.selectedChainId, //chainId
ensView.ensUsernamesStore.getEnsRegisteredAddress(), //recipientAddress
Helpers.RecipientAddressObjectType.Address, //recipientType
false, //onlyAssets
false, //interactive
ensView.contactsStore.myPublicKey, //publicKey
ensView.selectedUsername //ensName
)
}

Connections {
Expand All @@ -297,17 +296,19 @@ Item {
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()
Global.launchSendWithParams(Constants.SendType.ENSRegister, //sendType
"", //senderAddress
!!d.sntToken && !!d.sntToken.symbol ? d.sntToken.symbol: "", //tokenId
Constants.TokenType.ERC20, //tokenType
LocaleUtils.numberToLocaleString(10), //tokenAmount
ensView.selectedChainId, //chainId
ensView.ensUsernamesStore.getEnsRegisteredAddress(), //recipientAddress
Helpers.RecipientAddressObjectType.Address, //recipientType
false, //onlyAssets
false, //interactive
ensView.contactsStore.myPublicKey, //publicKey
ensView.selectedUsername //ensName
)
}

Connections {
Expand Down Expand Up @@ -385,19 +386,19 @@ Item {
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()
Global.launchSendWithParams(Constants.SendType.ENSRelease, //sendType
senderAddress, //senderAddress
Constants.ethToken, //tokenId
Constants.TokenType.Native, //tokenType
LocaleUtils.numberToLocaleString(0), //tokenAmount
ensView.selectedChainId, //chainId
ensView.ensUsernamesStore.getEnsRegisteredAddress(), //recipientAddress
Helpers.RecipientAddressObjectType.Address, //recipientType
false, //onlyAssets
false, //interactive
ensView.contactsStore.myPublicKey, //publicKey
ensView.selectedUsername //ensName
)
}

Connections {
Expand Down
3 changes: 0 additions & 3 deletions ui/app/AppLayouts/Profile/views/WalletView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -372,7 +370,6 @@ SettingsContentBase {
id: savedAddressesView
contactsStore: root.rootStore.contactsStore
networkConnectionStore: root.networkConnectionStore
sendModal: root.sendModalPopup
}

Component {
Expand Down
2 changes: 0 additions & 2 deletions ui/app/AppLayouts/Profile/views/wallet/SavedAddressesView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ ColumnLayout {

property ContactsStore contactsStore
property SharedStores.NetworkConnectionStore networkConnectionStore
property var sendModal

SavedAddresses {
sendModal: root.sendModal
contactsStore: root.contactsStore
networkConnectionStore: root.networkConnectionStore
}
Expand Down
Loading

0 comments on commit d3e043b

Please sign in to comment.