chore: unbreak showing SendModal assets in StoryBook

- unbreak passing the controller into the adaptor; can't be strongly
typed as that hides all the assets (always returns `false` from the
`visible` property)
- fix selecting account address (var account -> string accountAddress)
- fix the mocked account model to contain the needed `canSend` role, fix
the mocked check function
- fix showing community assets and balance threshold
This commit is contained in:
Lukáš Tinkl 2024-07-05 14:49:31 +02:00 committed by Lukáš Tinkl
parent 5d9c5d46fd
commit 9fcb54cb74
7 changed files with 52 additions and 27 deletions

View File

@ -32,7 +32,7 @@ SplitView {
delegateModel: SortFilterProxyModel {
sourceModel: submodel
filters: FastExpressionFilter {
expression: txStore.selectedSenderAccount.address === model.account
expression: txStore.selectedSenderAccountAddress === model.account
expectedRoles: ["account"]
}
}
@ -41,9 +41,9 @@ SplitView {
TransactionStore {
id: txStore
walletAssetStore: root.walletAssetStore
showCommunityAssetsInSend: showCommunityAssetsCheckBox.checked
balanceThresholdEnabled: balanceThresholdCheckbox.checked
balanceThresholdAmount: Number(balanceThresholdValue.text)
tokensStore.showCommunityAssetsInSend: showCommunityAssetsCheckBox.checked
tokensStore.displayAssetsBelowBalance: balanceThresholdCheckbox.checked
tokensStore.getDisplayAssetsBelowBalanceThresholdDisplayAmount: () => Number(balanceThresholdValue.text)
}
QtObject {
@ -129,7 +129,7 @@ SplitView {
Loader {
id: loader
property var preSelectedAccount: txStore.selectedSenderAccount
property var preSelectedAccount: txStore.accounts.get(0)
property string preSelectedHoldingID
property int preSelectedHoldingType: Constants.TokenType.Unknown
property int preSelectedSendType: Constants.SendType.Unknown
@ -143,7 +143,7 @@ SplitView {
visible: true
modal: false
closePolicy: Popup.NoAutoClose
onlyAssets: false
onlyAssets: loader.onlyAssets
store: txStore
preSelectedAccount: loader.preSelectedAccount
preDefinedAmountToSend: loader.preDefinedAmountToSend
@ -171,7 +171,7 @@ SplitView {
width: parent.width
StatusBaseText {
Layout.maximumWidth: parent.width
text: "This button can be used as respons eot the suggestedROutes API called once a token and its amount is selected along with a valid recipient."
text: "This button can be used as response to the suggestedRoutes API called once a token and its amount is selected along with a valid recipient."
color: "orange"
wrapMode: Text.WrapAnywhere
}
@ -217,7 +217,13 @@ SplitView {
}
ComboBox {
textRole: "name"
model: txStore.accounts
model: SortFilterProxyModel {
sourceModel: txStore.accounts
filters: ValueFilter {
roleName: "canSend"
value: true
}
}
onCurrentIndexChanged: loader.preSelectedAccount = txStore.accounts.get(currentIndex)
}
}

View File

@ -10,8 +10,10 @@ ListModel {
colorId: Constants.walletAccountColors.primary,
color: "#2A4AF5",
address: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240",
preferredSharingChainIds: "5:420:421613",
walletType: "",
position: 0,
canSend: true
},
{
name: "Hot wallet (generated)",
@ -19,8 +21,10 @@ ListModel {
colorId: Constants.walletAccountColors.army,
color: "#216266",
address: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8881",
preferredSharingChainIds: "5:420:421613",
walletType: Constants.generatedWalletType,
position: 3,
canSend: true
},
{
name: "Family (seed)",
@ -28,8 +32,10 @@ ListModel {
colorId: Constants.walletAccountColors.magenta,
color: "#EC266C",
address: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8882",
preferredSharingChainIds: "5:420:421613",
walletType: Constants.seedWalletType,
position: 1,
canSend: true
},
{
name: "Tag Heuer (watch)",
@ -37,8 +43,10 @@ ListModel {
colorId: Constants.walletAccountColors.copper,
color: "#CB6256",
address: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8883",
preferredSharingChainIds: "5:420:421613",
walletType: Constants.watchWalletType,
position: 2,
canSend: false
},
{
name: "Fab (key)",
@ -46,8 +54,10 @@ ListModel {
colorId: Constants.walletAccountColors.camel,
color: "#C78F67",
address: "0x7F47C2e98a4BBf5487E6fb082eC2D9Ab0E6d8884",
preferredSharingChainIds: "5:420:421613",
walletType: Constants.keyWalletType,
position: 4,
canSend: true
}
]

View File

@ -4,6 +4,7 @@ QtObject {
id: root
property var plainTokensBySymbolModel
property bool showCommunityAssetsInSend
property bool displayAssetsBelowBalance
property var getDisplayAssetsBelowBalanceThresholdDisplayAmount
property double tokenListUpdatedAt

View File

@ -56,7 +56,7 @@ QtObject {
joinRole: "communityId"
}
property var assetsController: QtObject {
readonly property var assetsController: QtObject {
property int revision
function filterAcceptsSymbol(symbol) {

View File

@ -13,21 +13,26 @@ QtObject {
id: root
readonly property CurrenciesStore currencyStore: CurrenciesStore {}
readonly property TokensStore tokensStore: TokensStore {}
readonly property var accounts: WalletSendAccountsModel {
Component.onCompleted: selectedSenderAccount = accounts.get(0)
Component.onCompleted: selectedSenderAccountAddress = accounts.get(0).address
}
property WalletAssetsStore walletAssetStore
property QtObject tmpActivityController: QtObject {
property QtObject tmpActivityController0: QtObject {
property ListModel model: ListModel{}
}
property QtObject tmpActivityController1: QtObject {
property ListModel model: ListModel{}
}
property var flatNetworksModel: NetworksModel.flatNetworks
property var fromNetworksRouteModel: NetworksModel.sendFromNetworks
property var toNetworksRouteModel: NetworksModel.sendToNetworks
property var selectedSenderAccount: accounts.get(0)
property string selectedSenderAccountAddress
readonly property QtObject collectiblesModel: ManageCollectiblesModel {}
readonly property QtObject nestedCollectiblesModel: WalletNestedCollectiblesModel {}
@ -53,6 +58,12 @@ QtObject {
address: "0x2B748A02e06B159C7C3E98F5064577B96E55A7b4",
chainShortNames: "eth:arb1"
})
append({
name: "some saved ENS name ",
ens: ["me@status.eth"],
address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc4",
chainShortNames: "eth:arb1:opt"
})
}
}
@ -60,8 +71,8 @@ QtObject {
return textAddrss
}
function resolveENS() {
return ""
function resolveENS(value) {
return root.mainModuleInst.resolvedENS("", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc4", "") // return some valid address
}
function getAsset(assetsList, symbol) {
@ -120,8 +131,8 @@ QtObject {
return "OPT"
}
function plainText(text) {
return text
function plainText(htmlFragment) {
return SQUtils.StringUtils.plainText(htmlFragment)
}
function prepareTransactionsForAddress(address) {
@ -150,11 +161,11 @@ QtObject {
}
}
function setSenderAccountByAddress(address) {
function setSenderAccount(address) {
for (let i = 0; i < accounts.count; i++) {
const acc = accounts.get(i)
if (acc.address === address && accounts.canSend) {
selectedSenderAccount = accounts.get(i)
if (acc.address === address && acc.canSend) {
selectedSenderAccountAddress = acc.address
break
}
}
@ -197,6 +208,9 @@ QtObject {
root.showUnPreferredChains = !root.showUnPreferredChains
}
function setAllNetworksAsRoutePreferredChains() {
}
function setRouteEnabledFromChains(chainId) {
}
@ -230,9 +244,4 @@ QtObject {
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
return currencyStore.formatCurrencyAmountFromBigInt(balance, symbol, decimals, options)
}
// Property and methods below are used to apply advanced token management settings to the SendModal
property bool showCommunityAssetsInSend: true
property bool balanceThresholdEnabled: true
property real balanceThresholdAmount
}

View File

@ -222,7 +222,7 @@ StatusDialog {
if(!!popup.preSelectedRecipient) {
recipientLoader.selectedRecipientType = popup.preSelectedRecipientType
if (popup.preSelectedRecipientType == TabAddressSelectorView.Type.Address) {
if (popup.preSelectedRecipientType === TabAddressSelectorView.Type.Address) {
recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient}
} else {
recipientLoader.selectedRecipient = popup.preSelectedRecipient
@ -327,7 +327,6 @@ StatusDialog {
id: holdingSelector
Layout.fillWidth: true
Layout.fillHeight: true
// assetsModel: popup.store.processedAssetsModel
assetsModel: assetsAdaptor.model
collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
networksModel: popup.store.flatNetworksModel

View File

@ -13,7 +13,7 @@ QObject {
// Controller providing information about visibility and order defined
// by a user (token management)
required property ManageTokensController controller
required property /*ManageTokensController*/ var controller
property bool showCommunityAssets: false