mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-16 08:37:12 +00:00
feat(@wallet): Show community activity (#13627)
This commit is contained in:
parent
3126973cfc
commit
fae86bcb8d
@ -273,3 +273,11 @@ QtObject:
|
|||||||
|
|
||||||
QtProperty[QVariant] amountCurrency:
|
QtProperty[QVariant] amountCurrency:
|
||||||
read = getAmountCurrency
|
read = getAmountCurrency
|
||||||
|
|
||||||
|
proc getCommunityId*(self: ActivityEntry): string {.slot.} =
|
||||||
|
if self.metadata.communityId.isSome():
|
||||||
|
return self.metadata.communityId.unsafeGet()
|
||||||
|
return ""
|
||||||
|
|
||||||
|
QtProperty[string] communityId:
|
||||||
|
read = getCommunityId
|
@ -285,6 +285,8 @@ type
|
|||||||
chainIdIn*: Option[ChainId]
|
chainIdIn*: Option[ChainId]
|
||||||
transferType*: Option[TransferType]
|
transferType*: Option[TransferType]
|
||||||
|
|
||||||
|
communityId*: Option[string]
|
||||||
|
|
||||||
# Mirrors status-go/services/wallet/activity/activity.go EntryData
|
# Mirrors status-go/services/wallet/activity/activity.go EntryData
|
||||||
Data* = object
|
Data* = object
|
||||||
payloadType*: PayloadType
|
payloadType*: PayloadType
|
||||||
@ -313,6 +315,8 @@ type
|
|||||||
nftName*: Option[string]
|
nftName*: Option[string]
|
||||||
nftUrl*: Option[string]
|
nftUrl*: Option[string]
|
||||||
|
|
||||||
|
communityId*: Option[string]
|
||||||
|
|
||||||
# Mirrors services/wallet/activity/service.go ErrorCode
|
# Mirrors services/wallet/activity/service.go ErrorCode
|
||||||
ErrorCode* = enum
|
ErrorCode* = enum
|
||||||
ErrorCodeSuccess = 1,
|
ErrorCodeSuccess = 1,
|
||||||
@ -361,6 +365,7 @@ proc fromJson*(e: JsonNode, T: typedesc[Data]): Data {.inline.} =
|
|||||||
const transferTypeField = "transferType"
|
const transferTypeField = "transferType"
|
||||||
const nftNameField = "nftName"
|
const nftNameField = "nftName"
|
||||||
const nftUrlField = "nftUrl"
|
const nftUrlField = "nftUrl"
|
||||||
|
const communityIdField = "communityId"
|
||||||
result = T(
|
result = T(
|
||||||
payloadType: fromJson(e["payloadType"], PayloadType),
|
payloadType: fromJson(e["payloadType"], PayloadType),
|
||||||
transaction: if e.hasKey(transactionField):
|
transaction: if e.hasKey(transactionField):
|
||||||
@ -398,6 +403,7 @@ proc fromJson*(e: JsonNode, T: typedesc[Data]): Data {.inline.} =
|
|||||||
|
|
||||||
nftName: if e.contains(nftNameField): some(e[nftNameField].getStr()) else: none(string),
|
nftName: if e.contains(nftNameField): some(e[nftNameField].getStr()) else: none(string),
|
||||||
nftUrl: if e.contains(nftUrlField): some(e[nftUrlField].getStr()) else: none(string),
|
nftUrl: if e.contains(nftUrlField): some(e[nftUrlField].getStr()) else: none(string),
|
||||||
|
communityId: if e.contains(communityIdField): some(e[communityIdField].getStr()) else: none(string),
|
||||||
)
|
)
|
||||||
if e.hasKey(senderField) and e[senderField].kind != JNull:
|
if e.hasKey(senderField) and e[senderField].kind != JNull:
|
||||||
var address: eth.Address
|
var address: eth.Address
|
||||||
@ -434,6 +440,7 @@ proc fromJson*(e: JsonNode, T: typedesc[ActivityEntry]): ActivityEntry {.inline.
|
|||||||
chainIdOut: data.chainIdOut,
|
chainIdOut: data.chainIdOut,
|
||||||
chainIdIn: data.chainIdIn,
|
chainIdIn: data.chainIdIn,
|
||||||
transferType: data.transferType,
|
transferType: data.transferType,
|
||||||
|
communityId: data.communityId
|
||||||
)
|
)
|
||||||
|
|
||||||
proc `$`*(self: ActivityEntry): string =
|
proc `$`*(self: ActivityEntry): string =
|
||||||
@ -449,14 +456,15 @@ proc `$`*(self: ActivityEntry): string =
|
|||||||
amountOut* {$self.amountOut},
|
amountOut* {$self.amountOut},
|
||||||
amountIn* {$self.amountIn},
|
amountIn* {$self.amountIn},
|
||||||
tokenOut* {$self.tokenOut},
|
tokenOut* {$self.tokenOut},
|
||||||
tokenIn* {$self.tokenIn}
|
tokenIn* {$self.tokenIn},
|
||||||
symbolOut* {$self.symbolOut}
|
symbolOut* {$self.symbolOut},
|
||||||
symbolIn* {$self.symbolIn}
|
symbolIn* {$self.symbolIn},
|
||||||
sender* {$self.sender}
|
sender* {$self.sender},
|
||||||
recipient* {$self.recipient}
|
recipient* {$self.recipient},
|
||||||
chainIdOut* {$self.chainIdOut}
|
chainIdOut* {$self.chainIdOut},
|
||||||
chainIdIn* {$self.chainIdIn}
|
chainIdIn* {$self.chainIdIn},
|
||||||
transferType* {$self.transferType}
|
transferType* {$self.transferType},
|
||||||
|
communityId* {$self.communityId}
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
proc fromJson*(e: JsonNode, T: typedesc[FilterResponse]): FilterResponse {.inline.} =
|
proc fromJson*(e: JsonNode, T: typedesc[FilterResponse]): FilterResponse {.inline.} =
|
||||||
|
@ -21,6 +21,7 @@ Item {
|
|||||||
property bool hideSignPhraseModal: false
|
property bool hideSignPhraseModal: false
|
||||||
property var store
|
property var store
|
||||||
property var contactsStore
|
property var contactsStore
|
||||||
|
property var communitiesStore
|
||||||
property var emojiPopup: null
|
property var emojiPopup: null
|
||||||
property var sendModalPopup
|
property var sendModalPopup
|
||||||
property var networkConnectionStore
|
property var networkConnectionStore
|
||||||
@ -186,6 +187,7 @@ Item {
|
|||||||
RightTabView {
|
RightTabView {
|
||||||
store: root.store
|
store: root.store
|
||||||
contactsStore: root.contactsStore
|
contactsStore: root.contactsStore
|
||||||
|
communitiesStore: root.communitiesStore
|
||||||
sendModal: root.sendModalPopup
|
sendModal: root.sendModalPopup
|
||||||
networkConnectionStore: root.networkConnectionStore
|
networkConnectionStore: root.networkConnectionStore
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ FocusScope {
|
|||||||
|
|
||||||
property var store
|
property var store
|
||||||
property var contactsStore
|
property var contactsStore
|
||||||
|
property var communitiesStore
|
||||||
property var networkConnectionStore
|
property var networkConnectionStore
|
||||||
|
|
||||||
property var sendModal
|
property var sendModal
|
||||||
|
@ -195,6 +195,7 @@ RightTabBaseView {
|
|||||||
id: historyView
|
id: historyView
|
||||||
HistoryView {
|
HistoryView {
|
||||||
overview: RootStore.overview
|
overview: RootStore.overview
|
||||||
|
communitiesStore: root.communitiesStore
|
||||||
showAllAccounts: RootStore.showAllAccounts
|
showAllAccounts: RootStore.showAllAccounts
|
||||||
sendModal: root.sendModal
|
sendModal: root.sendModal
|
||||||
filterVisible: filterButton.checked
|
filterVisible: filterButton.checked
|
||||||
@ -250,6 +251,7 @@ RightTabBaseView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
showAllAccounts: RootStore.showAllAccounts
|
showAllAccounts: RootStore.showAllAccounts
|
||||||
|
communitiesStore: root.communitiesStore
|
||||||
sendModal: root.sendModal
|
sendModal: root.sendModal
|
||||||
contactsStore: root.contactsStore
|
contactsStore: root.contactsStore
|
||||||
networkConnectionStore: root.networkConnectionStore
|
networkConnectionStore: root.networkConnectionStore
|
||||||
|
@ -27,6 +27,7 @@ Item {
|
|||||||
|
|
||||||
property var overview: WalletStores.RootStore.overview
|
property var overview: WalletStores.RootStore.overview
|
||||||
property var contactsStore
|
property var contactsStore
|
||||||
|
property var communitiesStore
|
||||||
property var networkConnectionStore
|
property var networkConnectionStore
|
||||||
property var transaction
|
property var transaction
|
||||||
property int transactionIndex
|
property int transactionIndex
|
||||||
@ -167,6 +168,7 @@ Item {
|
|||||||
timeStampText: root.isTransactionValid ? qsTr("Signed at %1").arg(LocaleUtils.formatDateTime(transaction.timestamp * 1000, Locale.LongFormat)): ""
|
timeStampText: root.isTransactionValid ? qsTr("Signed at %1").arg(LocaleUtils.formatDateTime(transaction.timestamp * 1000, Locale.LongFormat)): ""
|
||||||
rootStore: RootStore
|
rootStore: RootStore
|
||||||
walletRootStore: WalletStores.RootStore
|
walletRootStore: WalletStores.RootStore
|
||||||
|
community: isModelDataValid && communityId && communitiesStore ? communitiesStore.getCommunityDetailsAsJson(communityId) : null
|
||||||
|
|
||||||
onRetryClicked: d.retryTransaction()
|
onRetryClicked: d.retryTransaction()
|
||||||
}
|
}
|
||||||
|
@ -1269,6 +1269,7 @@ Item {
|
|||||||
objectName: "walletLayoutReal"
|
objectName: "walletLayoutReal"
|
||||||
store: appMain.rootStore
|
store: appMain.rootStore
|
||||||
contactsStore: appMain.rootStore.profileSectionStore.contactsStore
|
contactsStore: appMain.rootStore.profileSectionStore.contactsStore
|
||||||
|
communitiesStore: appMain.communitiesStore
|
||||||
emojiPopup: statusEmojiPopup.item
|
emojiPopup: statusEmojiPopup.item
|
||||||
sendModalPopup: sendModal
|
sendModalPopup: sendModal
|
||||||
networkConnectionStore: appMain.networkConnectionStore
|
networkConnectionStore: appMain.networkConnectionStore
|
||||||
|
@ -61,7 +61,6 @@ StatusListItem {
|
|||||||
readonly property double outFiatValue: isModelDataValid && isMultiTransaction ? rootStore.getFiatValue(outCryptoValue, modelData.outSymbol): 0.0
|
readonly property double outFiatValue: isModelDataValid && isMultiTransaction ? rootStore.getFiatValue(outCryptoValue, modelData.outSymbol): 0.0
|
||||||
readonly property double feeCryptoValue: 0.0 // TODO fill when bridge data is implemented
|
readonly property double feeCryptoValue: 0.0 // TODO fill when bridge data is implemented
|
||||||
readonly property double feeFiatValue: 0.0 // TODO fill when bridge data is implemented
|
readonly property double feeFiatValue: 0.0 // TODO fill when bridge data is implemented
|
||||||
readonly property string communityName: isModelDataValid && modelData.communityName ? modelData.communityName : ""
|
|
||||||
readonly property string networkColor: isModelDataValid ? rootStore.getNetworkColor(modelData.chainId) : ""
|
readonly property string networkColor: isModelDataValid ? rootStore.getNetworkColor(modelData.chainId) : ""
|
||||||
readonly property string networkName: isModelDataValid ? rootStore.getNetworkFullName(modelData.chainId) : ""
|
readonly property string networkName: isModelDataValid ? rootStore.getNetworkFullName(modelData.chainId) : ""
|
||||||
readonly property string networkNameIn: isMultiTransaction ? rootStore.getNetworkFullName(modelData.chainIdIn) : ""
|
readonly property string networkNameIn: isMultiTransaction ? rootStore.getNetworkFullName(modelData.chainIdIn) : ""
|
||||||
@ -69,7 +68,12 @@ StatusListItem {
|
|||||||
readonly property string addressNameTo: isModelDataValid ? walletRootStore.getNameForAddress(modelData.recipient) : ""
|
readonly property string addressNameTo: isModelDataValid ? walletRootStore.getNameForAddress(modelData.recipient) : ""
|
||||||
readonly property string addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : ""
|
readonly property string addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : ""
|
||||||
readonly property bool isNFT: isModelDataValid && modelData.isNFT
|
readonly property bool isNFT: isModelDataValid && modelData.isNFT
|
||||||
readonly property bool isCommunityAssetViaAirdrop: isModelDataValid && modelData.isCommunityAssetViaAirdrop ? modelData.isCommunityAssetViaAirdrop : false
|
readonly property bool isCommunityAssetViaAirdrop: isModelDataValid && !!communityId && modelData.txType === Constants.TransactionType.Mint
|
||||||
|
readonly property string communityId: isModelDataValid && modelData.communityId ? modelData.communityId : ""
|
||||||
|
property var community: null
|
||||||
|
readonly property bool isCommunityToken: !!community && Object.keys(community).length > 0
|
||||||
|
readonly property string communityImage: isCommunityToken ? community.image : ""
|
||||||
|
readonly property string communityName: isCommunityToken ? community.name : ""
|
||||||
|
|
||||||
readonly property string transactionValue: {
|
readonly property string transactionValue: {
|
||||||
if (!isModelDataValid) {
|
if (!isModelDataValid) {
|
||||||
@ -109,14 +113,6 @@ StatusListItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property string communityImage: {
|
|
||||||
if (!isModelDataValid || !root.isCommunityAssetViaAirdrop)
|
|
||||||
return ""
|
|
||||||
if (root.isCommunityAssetViaAirdrop) {
|
|
||||||
return modelData.communityImageUrl ? modelData.communityImageUrl : ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property string inTokenImage: isModelDataValid ? Constants.tokenIcon(modelData.inSymbol) : ""
|
readonly property string inTokenImage: isModelDataValid ? Constants.tokenIcon(modelData.inSymbol) : ""
|
||||||
|
|
||||||
readonly property string toAddress: !!addressNameTo ?
|
readonly property string toAddress: !!addressNameTo ?
|
||||||
@ -236,7 +232,7 @@ StatusListItem {
|
|||||||
case Constants.TransactionType.Bridge:
|
case Constants.TransactionType.Bridge:
|
||||||
case Constants.TransactionType.ContractDeployment:
|
case Constants.TransactionType.ContractDeployment:
|
||||||
case Constants.TransactionType.Mint:
|
case Constants.TransactionType.Mint:
|
||||||
details += getSubtitle(true) + endl2
|
details += getSubtitle(true, true) + endl2
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
details += qsTr("%1 from %2 to %3 via %4").arg(transactionValue).arg(fromAddress).arg(toAddress).arg(networkName) + endl2
|
details += qsTr("%1 from %2 to %3 via %4").arg(transactionValue).arg(fromAddress).arg(toAddress).arg(networkName) + endl2
|
||||||
@ -488,7 +484,17 @@ StatusListItem {
|
|||||||
return details.replace(/[\r\n\s]*$/, '')
|
return details.replace(/[\r\n\s]*$/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubtitle(allAccounts) {
|
function getSubtitle(allAccounts, description) {
|
||||||
|
if (root.isCommunityAssetViaAirdrop) {
|
||||||
|
let communityInfo = ""
|
||||||
|
if (!description) {
|
||||||
|
// Showing image only in delegate. In description url shouldn't be showed
|
||||||
|
communityInfo += "<img src='" + root.communityImage + "' width='18' height='18' </img> "
|
||||||
|
}
|
||||||
|
communityInfo += root.communityName
|
||||||
|
return qsTr("%1 (community asset) from %2 via %3").arg(root.transactionValue).arg(communityInfo).arg(root.networkName)
|
||||||
|
}
|
||||||
|
|
||||||
switch(modelData.txType) {
|
switch(modelData.txType) {
|
||||||
case Constants.TransactionType.Receive:
|
case Constants.TransactionType.Receive:
|
||||||
if (allAccounts)
|
if (allAccounts)
|
||||||
@ -670,9 +676,9 @@ StatusListItem {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return root.isCommunityAssetViaAirdrop ? qsTr("%1 (community asset) from %2 %3 via %4").arg(transactionValue).arg("<img src='" + root.communityImage + "'
|
return getSubtitle(root.showAllAccounts, false)
|
||||||
width='18' height='18' </img>").arg(communityName).arg(networkName) : getSubtitle(root.showAllAccounts)
|
|
||||||
}
|
}
|
||||||
|
statusListItemSubTitle.textFormat: root.isCommunityAssetViaAirdrop ? Text.RichText : Text.AutoText
|
||||||
statusListItemSubTitle.maximumLoadingStateWidth: 400
|
statusListItemSubTitle.maximumLoadingStateWidth: 400
|
||||||
statusListItemSubTitle.customColor: Theme.palette.directColor1
|
statusListItemSubTitle.customColor: Theme.palette.directColor1
|
||||||
statusListItemSubTitle.font.pixelSize: root.loading ? d.loadingPixelSize : d.subtitlePixelSize
|
statusListItemSubTitle.font.pixelSize: root.loading ? d.loadingPixelSize : d.subtitlePixelSize
|
||||||
|
@ -28,6 +28,7 @@ ColumnLayout {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var overview
|
property var overview
|
||||||
|
property var communitiesStore
|
||||||
property bool showAllAccounts: false
|
property bool showAllAccounts: false
|
||||||
property bool displayValues: true
|
property bool displayValues: true
|
||||||
property var sendModal
|
property var sendModal
|
||||||
@ -142,7 +143,7 @@ ColumnLayout {
|
|||||||
Loader {
|
Loader {
|
||||||
id: filterPanelLoader
|
id: filterPanelLoader
|
||||||
active: root.filterVisible && (d.isInitialLoading || transactionListRoot.count > 0 || WalletStores.RootStore.currentActivityFiltersStore.filtersSet)
|
active: root.filterVisible && (d.isInitialLoading || transactionListRoot.count > 0 || WalletStores.RootStore.currentActivityFiltersStore.filtersSet)
|
||||||
visible: active
|
visible: active && !noTxs.visible
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
sourceComponent: ActivityFilterPanel {
|
sourceComponent: ActivityFilterPanel {
|
||||||
@ -490,6 +491,7 @@ ColumnLayout {
|
|||||||
walletRootStore: WalletStores.RootStore
|
walletRootStore: WalletStores.RootStore
|
||||||
showAllAccounts: root.showAllAccounts
|
showAllAccounts: root.showAllAccounts
|
||||||
displayValues: root.displayValues
|
displayValues: root.displayValues
|
||||||
|
community: isModelDataValid && !!communityId && !!root.communitiesStore ? root.communitiesStore.getCommunityDetailsAsJson(communityId) : null
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
delegateMenu.openMenu(this, mouse, modelData)
|
delegateMenu.openMenu(this, mouse, modelData)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user