Skip to content

Commit

Permalink
feat(@desktop/wallet): Using chain of heirarchy to propogate laun ch …
Browse files Browse the repository at this point in the history
…send signals instead of Global signal
  • Loading branch information
Khushboo-dev-cpp committed Nov 27, 2024
1 parent d3e043b commit 0638cf0
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 77 deletions.
10 changes: 4 additions & 6 deletions ui/app/AppLayouts/Communities/popups/TransferOwnershipPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ StatusDialog {
property var token // Expected roles: accountAddress, key, chainId, name, artworkSource

signal cancelClicked
signal sendRequested(var sendType, var senderAddress, var tokenId, var tokenType)

width: 640 // by design
padding: Theme.padding
Expand Down Expand Up @@ -110,12 +111,9 @@ StatusDialog {
onClicked: {
// Pre-populated dialog with the relevant Owner token info:
const store = WalletStores.RootStore.currentActivityFiltersStore
const uid = store.collectiblesList.getUidForData(token.key, token.tokenAddress, token.chainId);
Global.launchSendWithParams(Constants.SendType.ERC721Transfer, //sendType
token.accountAddress, //senderAddress
uid, //tokenId
Constants.TokenType.ERC721 //tokenType
)
const uid = store.collectiblesList.getUidForData(token.key, token.tokenAddress, token.chainId)
root.sendRequested(Constants.SendType.ERC721Transfer, token.accountAddress,
uid, Constants.TokenType.ERC721)
close()
}
}
Expand Down
31 changes: 31 additions & 0 deletions ui/app/AppLayouts/Profile/ProfileLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ StatusSectionLayout {

required property bool isCentralizedMetricsEnabled

signal launchSendModal(int sendType, string senderAddress, string tokenId,
int tokenType, string tokenAmount, int chainId, string publicKey, string ensName)

backButtonName: root.store.backButtonName
notificationCount: activityCenterStore.unreadNotificationsCount
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
Expand Down Expand Up @@ -97,6 +100,10 @@ StatusSectionLayout {
// Used to alternatively add an error message to the dirty bubble if ephemeral notification
// can clash at smaller viewports
readonly property bool toastClashesWithDirtyBubble: root.Window.width <= 1650 // design

readonly property var sntToken: SQUtils.ModelUtils.getByKey(
root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey",
root.store.ensUsernamesStore.getStatusTokenKey())
}

SettingsEntriesModel {
Expand Down Expand Up @@ -251,6 +258,30 @@ StatusSectionLayout {
contactsStore: root.store.contactsStore
networkConnectionStore: root.networkConnectionStore
profileContentWidth: d.contentWidth
onConnectUsername: root.launchSendModal(Constants.SendType.ENSSetPubKey /*sendType*/,
"" /*senderAddress*/,
Constants.ethToken /*tokenId*/,
Constants.TokenType.ERC20 /*tokenType*/,
LocaleUtils.numberToLocaleString(0) /*tokenAmount*/,
selectedChainId /*chainId*/,
publicKey,
ensName)
onRegisterUsername: root.launchSendModal(Constants.SendType.ENSRegister /*sendType*/,
"" /*senderAddress*/,
!!d.sntToken && !!d.sntToken.symbol ? d.sntToken.symbol: "" /*tokenId*/,
Constants.TokenType.ERC20 /*tokenType*/,
LocaleUtils.numberToLocaleString(10) /*tokenAmount*/,
selectedChainId /*chainId*/,
publicKey,
ensName)
onReleaseUsernameRequested: root.launchSendModal(Constants.SendType.ENSRelease /*sendType*/,
senderAddress,
Constants.ethToken /*tokenId*/,
Constants.TokenType.Native /*tokenType*/,
LocaleUtils.numberToLocaleString(0) /*tokenAmount*/,
selectedChainId /*chainId*/,
publicKey,
ensName)
}
}

Expand Down
11 changes: 11 additions & 0 deletions ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@ import AppLayouts.Profile.stores 1.0
Item {
id: root

required property var accountAssetsModel
property EnsUsernamesStore ensUsernamesStore
property string username: ""

signal backBtnClicked()
signal registerUsername()

QtObject {
id: d
readonly property var sntToken: ModelUtils.getByKey(root.accountAssetsModel, "tokensKey", root.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
}

StatusBaseText {
id: sectionTitle
text: qsTr("ENS usernames")
Expand Down
57 changes: 7 additions & 50 deletions ui/app/AppLayouts/Profile/views/EnsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Item {
signal changePubKey(ensUsername: string)
signal goToWelcome();
signal goToList();
signal connectUsername(string publicKey, string ensName)
signal registerUsername(string publicKey, string ensName)
signal releaseUsernameRequested(string senderAddress, string publicKey, string ensName)

Layout.fillHeight: true
Layout.fillWidth: true
Expand All @@ -51,13 +54,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 {
Expand Down Expand Up @@ -259,20 +255,7 @@ Item {

onConnectUsername: {
ensView.selectedUsername = username

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
)
ensView.connectUsername(ensView.contactsStore.myPublicKey, ensView.selectedUsername)
}

Connections {
Expand All @@ -292,24 +275,10 @@ Item {
EnsTermsAndConditionsView {
ensUsernamesStore: ensView.ensUsernamesStore
username: selectedUsername
accountAssetsModel: root.walletAssetsStore.groupedAccountAssetsModel

onBackBtnClicked: back();

onRegisterUsername: {
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
)
}
onRegisterUsername: ensView.registerUsername(ensView.contactsStore.myPublicKey, ensView.selectedUsername)

Connections {
target: ensView.ensUsernamesStore.ensUsernamesModule
Expand Down Expand Up @@ -386,19 +355,7 @@ Item {
return
}

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
)
ensView.releaseUsernameRequested(senderAddress, ensView.contactsStore.myPublicKey, ensView.selectedUsername)
}

Connections {
Expand Down
10 changes: 10 additions & 0 deletions ui/app/mainui/AppMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,16 @@ Item {
}

onSettingsSubsectionChanged: profileLoader.settingsSubsection = settingsSubsection

onLaunchSendModal: {
let ensUsernamesStore = appMain.rootStore.profileSectionStore.ensUsernamesStore
popups.openSendModal(sendType, senderAddress, tokenId, tokenType, tokenAmount, chainId,
ensUsernamesStore.getEnsRegisteredAddress() /*recipientAddress*/,
SendPopups.Helpers.RecipientAddressObjectType.Address /*recipientType*/,
false /*onlyAssets*/,
false /*interactive*/,
publicKey, ensName)
}
}
}

Expand Down
35 changes: 14 additions & 21 deletions ui/app/mainui/Popups.qml
Original file line number Diff line number Diff line change
Expand Up @@ -405,27 +405,19 @@ QtObject {
})
}

function openSendModal(sendType, senderAddress,
tokenId, tokenType,
tokenAmount, chainId,
recipientAddress, recipientType,
onlyAssets, interactive,
publicKey, ensName,
stickersPackId) {
console.error("openSendModal >> ", "sendType >> ", sendType,
"senderAddress >> ",senderAddress,
"tokenId >> ",tokenId,
"tokenType >> ",tokenType,
"tokenAmount >> ",tokenAmount,
"chainId >> ",chainId,
"recipientAddress >> ",recipientAddress,
"recipientType >> ",recipientType,
"onlyAssets >> ",onlyAssets,
"interactive >> ",interactive,
"publicKey >> ",publicKey,
"ensName >> ",ensName,
"stickersPackId >> ",stickersPackId)

function openSendModal(sendType = Constants.SendType.Transfer,
senderAddress = "",
tokenId = "",
tokenType = Constants.TokenType.Unknown,
tokenAmount = "",
chainId = 0,
recipientAddress = "",
recipientType = 0,
onlyAssets = false,
interactive = true,
publicKey = "",
ensName = "",
stickersPackId = "") {
openPopup(sendModal, {
preSelectedSendType: sendType,
preSelectedAccountAddress: senderAddress,
Expand Down Expand Up @@ -1081,6 +1073,7 @@ QtObject {
id: transferOwnershipPopup
TransferOwnershipPopup {
onClosed: destroy()
onSendRequested: root.openSendModal(sendType, senderAddress, tokenId, tokenType)
}
},

Expand Down

0 comments on commit 0638cf0

Please sign in to comment.