2023-10-26 21:11:20 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import StatusQ 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
/* PRIVATE: Modules used to get data from backend */
|
2023-11-15 10:43:53 +00:00
|
|
|
readonly property var _allTokensModule: !!walletSectionAllTokens ? walletSectionAllTokens : null
|
|
|
|
readonly property var _networksModule: !!networksModule ? networksModule : null
|
2023-10-26 21:11:20 +00:00
|
|
|
|
2024-02-01 12:01:07 +00:00
|
|
|
readonly property double tokenListUpdatedAt: root._allTokensModule.tokenListUpdatedAt
|
|
|
|
|
2023-10-26 21:11:20 +00:00
|
|
|
/* This contains the different sources for the tokens list
|
|
|
|
ex. uniswap list, status tokens list */
|
|
|
|
readonly property var sourcesOfTokensModel: SortFilterProxyModel {
|
2023-11-15 10:43:53 +00:00
|
|
|
sourceModel: !!root._allTokensModule ? root._allTokensModule.sourcesOfTokensModel : null
|
2023-10-26 21:11:20 +00:00
|
|
|
proxyRoles: ExpressionRole {
|
|
|
|
function sourceImage(sourceKey) {
|
|
|
|
return Constants.getSupportedTokenSourceImage(sourceKey)
|
|
|
|
}
|
|
|
|
name: "image"
|
|
|
|
expression: sourceImage(model.key)
|
|
|
|
}
|
2023-10-20 08:19:48 +00:00
|
|
|
filters: AnyOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "key"
|
|
|
|
value: Constants.supportedTokenSources.uniswap
|
|
|
|
}
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "key"
|
|
|
|
value: Constants.supportedTokenSources.status
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 21:11:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This list contains the complete list of tokens with separate
|
|
|
|
entry per token which has a unique [address + network] pair */
|
2023-11-15 10:43:53 +00:00
|
|
|
readonly property var flatTokensModel: !!root._allTokensModule ? root._allTokensModule.flatTokensModel : null
|
2023-10-26 21:11:20 +00:00
|
|
|
|
|
|
|
/* PRIVATE: This model just combines tokens and network information in one */
|
|
|
|
readonly property LeftJoinModel _joinFlatTokensModel : LeftJoinModel {
|
|
|
|
leftModel: root.flatTokensModel
|
2023-10-20 08:19:48 +00:00
|
|
|
rightModel: root._networksModule.flatNetworks
|
2023-10-26 21:11:20 +00:00
|
|
|
|
|
|
|
joinRole: "chainId"
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This list contains the complete list of tokens with separate
|
|
|
|
entry per token which has a unique [address + network] pair including extended information
|
|
|
|
about the specific network per entry */
|
|
|
|
readonly property var extendedFlatTokensModel: SortFilterProxyModel {
|
|
|
|
sourceModel: root._joinFlatTokensModel
|
|
|
|
|
|
|
|
proxyRoles: [
|
|
|
|
ExpressionRole {
|
|
|
|
name: "explorerUrl"
|
2023-10-20 08:19:48 +00:00
|
|
|
expression: model.blockExplorerURL + "/token/" + model.address
|
2023-10-26 21:11:20 +00:00
|
|
|
},
|
|
|
|
ExpressionRole {
|
|
|
|
function tokenIcon(symbol) {
|
|
|
|
return Constants.tokenIcon(symbol)
|
|
|
|
}
|
|
|
|
name: "image"
|
|
|
|
expression: tokenIcon(model.symbol)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This list contains list of tokens grouped by symbol
|
|
|
|
EXCEPTION: We may have different entries for the same symbol in case
|
|
|
|
of symbol clash when minting community tokens, so in case of community tokens
|
|
|
|
there will be one entry per address + network pair */
|
|
|
|
// TODO in #12513
|
2023-11-24 12:16:13 +00:00
|
|
|
readonly property var plainTokensBySymbolModel: !!root._allTokensModule ? root._allTokensModule.tokensBySymbolModel : null
|
2023-11-22 13:50:07 +00:00
|
|
|
readonly property var assetsBySymbolModel: SortFilterProxyModel {
|
2023-11-24 12:16:13 +00:00
|
|
|
sourceModel: plainTokensBySymbolModel
|
2023-10-26 21:11:20 +00:00
|
|
|
proxyRoles: [
|
|
|
|
ExpressionRole {
|
|
|
|
function tokenIcon(symbol) {
|
|
|
|
return Constants.tokenIcon(symbol)
|
|
|
|
}
|
|
|
|
name: "iconSource"
|
|
|
|
expression: tokenIcon(model.symbol)
|
|
|
|
},
|
|
|
|
// TODO: Review if it can be removed
|
|
|
|
ExpressionRole {
|
|
|
|
name: "shortName"
|
|
|
|
expression: model.symbol
|
|
|
|
},
|
|
|
|
ExpressionRole {
|
|
|
|
function getCategory(index) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
name: "category"
|
|
|
|
expression: getCategory(model.communityId)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2024-01-30 13:15:58 +00:00
|
|
|
|
|
|
|
// Property and methods below are used to apply advanced token management settings to the SendModal
|
|
|
|
readonly property bool showCommunityAssetsInSend: root._allTokensModule.showCommunityAssetWhenSendingTokens
|
|
|
|
readonly property bool balanceThresholdEnabled: root._allTokensModule.displayAssetsBelowBalance
|
|
|
|
readonly property real balanceThresholdAmount: root._allTokensModule.displayAssetsBelowBalanceThreshold
|
2023-10-26 21:11:20 +00:00
|
|
|
}
|