Skip to content

Commit

Permalink
feat(@desktop/wallet): Adapt invocations to New Simple Send Modal
Browse files Browse the repository at this point in the history
fixes #17023
  • Loading branch information
Khushboo-dev-cpp committed Jan 27, 2025
1 parent 5793204 commit 8806f13
Show file tree
Hide file tree
Showing 11 changed files with 580 additions and 223 deletions.
114 changes: 92 additions & 22 deletions storybook/pages/SimpleSendModalPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SortFilterProxyModel 0.2
import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Backpressure 0.1

import Models 1.0
Expand Down Expand Up @@ -120,9 +121,12 @@ SplitView {
closePolicy: Popup.CloseOnEscape

interactive: interactiveCheckbox.checked
displayOnlyAssets: displayOnlyAssetsCheckbox.checked
transferOwnership: transferOwnershipCheckbox.checked

accountsModel: accountsSelectorAdaptor.processedWalletAccounts
assetsModel: assetsSelectorViewAdaptor.outputAssetsModel
flatCollectiblesModel: collectiblesSelectionAdaptor.filteredFlatModel
collectiblesModel: collectiblesSelectionAdaptor.model
networksModel: d.filteredNetworksModel

Expand Down Expand Up @@ -548,6 +552,17 @@ SplitView {
checked: true
}

CheckBox {
id: transferOwnershipCheckbox
text: "transfer ownership"
checked: false
}

CheckBox {
id: displayOnlyAssetsCheckbox
text: "displayOnlyAssets"
}

Text {
text: "Select an accounts"
}
Expand Down Expand Up @@ -586,23 +601,93 @@ SplitView {
}
ComboBox {
id: tokensCombobox
Layout.preferredWidth: 200
model: ConcatModel {
sources: [
SourceModel {
model: assetsSelectorViewAdaptor.outputAssetsModel
model: ObjectProxyModel {
sourceModel: d.walletAssetStore.walletTokensStore.plainTokensBySymbolModel
delegate: SortFilterProxyModel {
readonly property var addressPerChain: this
sourceModel: LeftJoinModel {
leftModel: model.addressPerChain
rightModel: d.filteredNetworksModel

joinRole: "chainId"
}

filters: ValueFilter {
roleName: "isTest"
value: testNetworksCheckbox.checked
}
}
expectedRoles: "addressPerChain"
exposedRoles: "addressPerChain"
}
markerRoleValue: "first_model"
},
SourceModel {
model: collectiblesKeyModel
model: RolesRenamingModel {
sourceModel: collectiblesBySymbolModel
mapping: [
RoleRename {
from: "symbol"
to: "key"
}
]
}
markerRoleValue: "second_model"
}
]

markerRoleName: "which_model"
expectedRoles: ["tokensKey", "name"]
expectedRoles: ["key", "name", "addressPerChain", "chainId", "ownership", "type", "tokenType", "addressPerChain"]
}
delegate: ItemDelegate {
contentItem: RowLayout {
Text {
text: model.name
}
StatusIcon {
icon: {
const iconUrl = ModelUtils.getByKey(NetworksModel.flatNetworks, "chainId", model.chainId, "iconUrl")
if(!!iconUrl)
return Theme.svg(iconUrl)
else return ""
}
}
}
onClicked: {
let tokenType = model.type ?? model.tokenType
if (tokenType === Constants.TokenType.ERC721) {
simpleSend.sendType = Constants.SendType.ERC721Transfer
simpleSend.selectedChainId = model.chainId
const firstAccountOwningSelectedCollectible = ModelUtils.get(model.ownership, 0, "accountAddress")
if(!!firstAccountOwningSelectedCollectible)
simpleSend.selectedAccountAddress = firstAccountOwningSelectedCollectible
}
else if (tokenType === Constants.TokenType.ERC1155) {
simpleSend.sendType = Constants.SendType.ERC1155Transfer
simpleSend.selectedChainId = model.chainId
const firstAccountOwningSelectedCollectible = ModelUtils.get(model.ownership, 0, "accountAddress")
if(!!firstAccountOwningSelectedCollectible)
simpleSend.selectedAccountAddress = firstAccountOwningSelectedCollectible
}
else {
let selectedChainId = ModelUtils.getByKey(model.addressPerChain, "layer", "1", "chainId")
if (!selectedChainId) {
selectedChainId = ModelUtils.get(model.addressPerChain, 0, "chainId")
}
simpleSend.selectedChainId = selectedChainId
simpleSend.sendType = Constants.SendType.Transfer
}
}

highlighted: tokensCombobox.highlightedIndex === index
}

textRole: "name"
valueRole: "tokensKey"
valueRole: "key"
}

RowLayout {
Expand All @@ -616,13 +701,10 @@ SplitView {
}
}
Button {
text: "update in modal"
onClicked: simpleSend.selectedAmount = amountInput.text
text: "update raw value in modal"
onClicked: simpleSend.selectedRawAmount = amountInput.text
}
}
Text {
text: "amount selected in base unit: " + simpleSend.selectedAmountInBaseUnit
}

Text {
text: "Select a recipient"
Expand Down Expand Up @@ -651,23 +733,11 @@ SplitView {
text: "token selected is: " + simpleSend.selectedTokenKey
}
Text {
text: "amount entered is: " + simpleSend.selectedAmount
text: "raw amount entered is: " + simpleSend.selectedRawAmount
}
Text {
text: "selected recipient is: \n" + simpleSend.selectedRecipientAddress
}

RolesRenamingModel {
id: collectiblesKeyModel
sourceModel: collectiblesSelectionAdaptor.model

mapping: [
RoleRename {
from: "symbol"
to: "tokensKey"
}
]
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion ui/app/AppLayouts/Wallet/WalletUtils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ QtObject {
return value
}

return value - Math.max(0.0001, Math.min(0.01, value * 0.1))
const estFee = Math.max(0.0001, Math.min(0.01, value * 0.1))
const result = value - estFee

// Ensure the result is not negative
return Math.max(result, 0)
}

function getLabelForEstimatedTxTime(estimatedFlag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ QObject {
**/
readonly property alias model: communityGroupsGrouppedByCollection

/** output model which follows same structure as the input collectiblesModel
The only add on here is that this model is not grouped and is filtered
based on account and chainId
**/
readonly property alias filteredFlatModel: initiallyFilteredAndSorted

// In case collectibles are to be shown only on specific networks
property var enabledChainIds: []

Expand Down
4 changes: 4 additions & 0 deletions ui/app/AppLayouts/Wallet/panels/RecipientSelectorPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Rectangle {
property alias selectedRecipientAddress: recipientInputLoader.selectedRecipientAddress
property alias selectedRecipientType: recipientInputLoader.selectedRecipientType

property bool interactive: true

signal resolveENS(string ensName, string uuid)

function ensNameResolved(resolvedPubKey, resolvedAddress, uuid) {
Expand All @@ -48,6 +50,8 @@ Rectangle {

Layout.fillWidth: true

interactive: root.interactive

savedAddressesModel: root.savedAddressesModel
myAccountsModel: root.myAccountsModel

Expand Down
11 changes: 10 additions & 1 deletion ui/app/AppLayouts/Wallet/panels/SendModalHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ RowLayout {
/** input property holds if the header is the sticky header **/
property bool isStickyHeader

/** input property to show only ERC20 assets and no collectibles **/
property bool displayOnlyAssets

/** input property to decide if the header can be interacted with **/
property bool interactive: true

/** input property for programatic selection of network **/
property int selectedChainId

Expand Down Expand Up @@ -106,8 +112,10 @@ RowLayout {
TokenSelectorButton.Size.Small:
TokenSelectorButton.Size.Normal

enabled: root.interactive

assetsModel: root.assetsModel
collectiblesModel: root.collectiblesModel
collectiblesModel: root.displayOnlyAssets ? null: root.collectiblesModel

onCollectibleSelected: root.collectibleSelected(key)
onCollectionSelected: root.collectionSelected(key)
Expand Down Expand Up @@ -142,6 +150,7 @@ RowLayout {
multiSelection: false
showSelectionIndicator: false
showTitle: false
selectionAllowed: root.interactive

Binding on selection {
value: [root.selectedChainId]
Expand Down
8 changes: 8 additions & 0 deletions ui/app/AppLayouts/Wallet/panels/StickySendModalHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Control {
/** input property for programatic selection of network **/
property int selectedChainId

/** input property to decide if the header can be interacted with **/
property bool interactive: true

/** input property to show only ERC20 assets and no collectibles **/
property bool displayOnlyAssets

/** signal to propagate that an asset was selected **/
signal assetSelected(string key)
/** signal to propagate that a collection was selected **/
Expand Down Expand Up @@ -119,6 +125,8 @@ Control {

isStickyHeader: true
isScrolling: root.stickyHeaderVisible
interactive: root.interactive
displayOnlyAssets: root.displayOnlyAssets

networksModel: root.networksModel
assetsModel: root.assetsModel
Expand Down
Loading

0 comments on commit 8806f13

Please sign in to comment.