feat(@desktop/wallet): Using chain of heirarchy to propogate laun ch send signals instead of Global signal
This commit is contained in:
parent
d3e043b2e8
commit
0638cf03ab
|
@ -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
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
@ -1081,6 +1073,7 @@ QtObject {
|
|||
id: transferOwnershipPopup
|
||||
TransferOwnershipPopup {
|
||||
onClosed: destroy()
|
||||
onSendRequested: root.openSendModal(sendType, senderAddress, tokenId, tokenType)
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue