Skip to content

Commit

Permalink
feat(activity): Add navigation to tx details
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuteivist committed Feb 20, 2024
1 parent 7dedb22 commit 7bc8e8a
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/app/modules/main/communities/tokens/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ proc init*(self: Controller) =
self.communityTokensModule.onOwnerTokenReceived(args.communityId, args.communityName, args.chainId, args.contractAddress)
self.events.on(SIGNAL_COMMUNITY_TOKEN_RECEIVED) do(e: Args):
let args = CommunityTokenReceivedArgs(e)
self.communityTokensModule.onCommunityTokenReceived(args.name, args.symbol, args.image, args.communityId, args.communityName, $args.amount, args.chainId, args.txHash, args.isFirst, args.tokenType, args.accountName)
self.communityTokensModule.onCommunityTokenReceived(args.name, args.symbol, args.image, args.communityId, args.communityName, $args.amount, args.chainId, args.txHash, args.isFirst, args.tokenType, args.accountName, args.accountAddress)
self.events.on(SIGNAL_SET_SIGNER_STATUS) do(e: Args):
let args = SetSignerArgs(e)
self.communityTokensModule.onSetSignerStateChanged(args.communityId, args.chainId, args.transactionHash, args.status)
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/main/communities/tokens/io_interface.nim
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ method removeCommunityToken*(self: AccessInterface, communityId: string, chainId
method onOwnerTokenReceived*(self: AccessInterface, communityId: string, communityName: string, chainId: int, contractAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onCommunityTokenReceived*(self: AccessInterface, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string) {.base.} =
method onCommunityTokenReceived*(self: AccessInterface, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string, accountAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onSendOwnerTokenStateChanged*(self: AccessInterface, chainId: int, transactionHash: string, tokenName: string, status: ContractTransactionStatus) {.base.} =
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/main/communities/tokens/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ method onAirdropStateChanged*(self: Module, communityId: string, tokenName: stri
method onOwnerTokenReceived*(self: Module, communityId: string, communityName: string, chainId: int, contractAddress: string) =
self.view.emitOwnerTokenReceived(communityId, communityName, chainId, contractAddress)

method onCommunityTokenReceived*(self: Module, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string) =
self.view.emitCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, accountName)
method onCommunityTokenReceived*(self: Module, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string, accountAddress: string) =
self.view.emitCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, accountName, accountAddress)

method onSetSignerStateChanged*(self: Module, communityId: string, chainId: int, transactionHash: string, status: ContractTransactionStatus) =
let communityDto = self.controller.getCommunityById(communityId)
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/main/communities/tokens/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ QtObject:
proc burnFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int, responseId: string) {.signal.}
proc setSignerFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int, responseId: string) {.signal.}
proc ownerTokenReceived*(self: View, communityId: string, communityName: string, chainId: int, contractAddress: string) {.signal.}
proc communityTokenReceived*(self: View, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string) {.signal.}
proc communityTokenReceived*(self: View, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string, accountAddress: string) {.signal.}
proc setSignerStateChanged*(self: View, communityId: string, communityName: string, status: int, url: string) {.signal.}
proc ownershipNodeLost*(self: View, communityId: string, communityName: string) {.signal.}
proc sendOwnerTokenStateChanged*(self: View, tokenName: string, status: int, url: string) {.signal.}
Expand Down Expand Up @@ -117,8 +117,8 @@ QtObject:
proc emitOwnerTokenReceived*(self: View, communityId: string, communityName: string, chainId: int, contractAddress: string) =
self.ownerTokenReceived(communityId, communityName, chainId, contractAddress)

proc emitCommunityTokenReceived*(self: View, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string) =
self.communityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, accountName)
proc emitCommunityTokenReceived*(self: View, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string, accountAddress: string) =
self.communityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, accountName, accountAddress)

proc emitSetSignerStateChanged*(self: View, communityId: string, communityName: string, status: int, url: string) =
self.setSignerStateChanged(communityId, communityName, status, url)
Expand Down
6 changes: 6 additions & 0 deletions src/app/modules/main/wallet_section/activity/model.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ QtObject:
read = getHasMore
notify = hasMoreChanged

proc getIndex*(self: Model, txHash: string): int {.slot.} =
for i, e in self.entries:
if e.getId() == txHash:
return i
return -1

proc refreshItemsContainingAddress*(self: Model, address: string) =
for i in 0..self.entries.high:
if cmpIgnoreCase(self.entries[i].getSender(), address) == 0 or
Expand Down
11 changes: 10 additions & 1 deletion ui/app/AppLayouts/Wallet/WalletLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ Item {
if (leftPanelSelection === WalletLayout.LeftPanelSelection.SavedAddresses) {
d.displaySavedAddresses()
} else {
let address = data.address ?? ""
if (leftPanelSelection === WalletLayout.LeftPanelSelection.AllAddresses) {
d.displayAllAddresses()
} else if (leftPanelSelection === WalletLayout.LeftPanelSelection.Address) {
d.displayAddress(address)
if (!!address) {
d.displayAddress(address)
} else {
d.displayAllAddresses()
}
}

if (rightPanelSelection !== WalletLayout.RightPanelSelection.Collectibles &&
Expand All @@ -105,10 +110,14 @@ Item {
rightPanelStackView.currentItem.resetView()
rightPanelStackView.currentItem.currentTabIndex = rightPanelSelection

let txHash = data.txHash?? ""
let savedAddress = data.savedAddress?? ""
if (!!savedAddress) {
RootStore.currentActivityFiltersStore.resetAllFilters()
RootStore.currentActivityFiltersStore.toggleSavedAddress(savedAddress)
} else if (!!txHash) {
RootStore.currentActivityFiltersStore.resetAllFilters()
RootStore.currentActivityFiltersStore.displayTxDetails(txHash)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Wallet/stores/ActivityFiltersStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ QtObject {
recentsFilters.length !== 0 ||
savedAddressFilters.length !== 0

signal displayTxDetails(string txHash)

readonly property QtObject _d: QtObject {
id: d

Expand Down
18 changes: 10 additions & 8 deletions ui/app/mainui/ToastsManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ QtObject {
}

// Community token received in the user wallet:
function onCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName) {
function onCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAddress, walletAccountName) {

// Some error control:
if(tokenType !== Constants.TokenType.ERC20 && tokenType !== Constants.TokenType.ERC721) {
Expand All @@ -155,7 +155,8 @@ QtObject {
tokenName: name,
tokenSymbol: symbol,
tokenImage: image,
tokenAmount: balance
tokenAmount: balance,
walletAddress: walletAddress
}

if(isFirst) {
Expand Down Expand Up @@ -217,17 +218,18 @@ QtObject {
root.sendModalPopup.open()
return
case ToastsManager.ActionType.ViewTransactionDetails:
var txHash = ""
if(actionData) {
var parsedData = JSON.parse(actionData)
txHash = parsedData.txHash
const txHash = parsedData.txHash
const walletAddress = parsedData.walletAddress
Global.changeAppSectionBySectionType(Constants.appSection.wallet,
WalletLayout.LeftPanelSelection.AllAddresses,
WalletLayout.RightPanelSelection.Activity)
// TODO: Final navigation to the specific transaction entry --> {transaction: txHash}) --> Issue #13249
WalletLayout.LeftPanelSelection.Address,
WalletLayout.RightPanelSelection.Activity,
{address: walletAddress,
txHash: txHash})
return
}
console.warn("Unexpected transaction hash while trying to navigate to the details page: " + txHash)
console.warn("Unexpected transaction hash while trying to navigate to the details page")
return
case ToastsManager.ActionType.OpenFirstCommunityTokenPopup:
if(actionData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ActivityNotificationBase {
property int tokenType: root.tokenData.tokenType

// Wallet related:
property string walletAccountName: !!root.store ? root.store.walletStore.getNameForWalletAddress(root.tokenData.walletAddress) : ""
property string txHash: root.tokenData.txHash

QtObject {
Expand All @@ -57,8 +56,14 @@ ActivityNotificationBase {
readonly property string ctaText: root.isFirstTokenReceived ? qsTr("Learn more") : qsTr("Transaction details")
readonly property string title: root.isFirstTokenReceived ? (root.isAssetType ? qsTr("You received your first community asset") : qsTr("You received your first community collectible")) :
qsTr("Tokens received")
readonly property string info: root.isFirstTokenReceived ? qsTr("%1 %2 was airdropped to you from the %3 community").arg(root.tokenAmount).arg(d.formattedTokenName).arg(root.communityName) :
qsTr("You were airdropped %1 %2 from %3 to %4").arg(root.tokenAmount).arg(root.tokenName).arg(root.communityName).arg(root.walletAccountName)
readonly property string info: {
if (root.isFirstTokenReceived) {
return qsTr("%1 %2 was airdropped to you from the %3 community").arg(root.tokenAmount).arg(d.formattedTokenName).arg(root.communityName)
} else {
const walletAccountName = !!root.store ? root.store.walletStore.getNameForWalletAddress(root.tokenData.walletAddress) : ""
return qsTr("You were airdropped %1 %2 from %3 to %4").arg(root.tokenAmount).arg(root.tokenName).arg(root.communityName).arg(walletAccountName)
}
}
}

bodyComponent: RowLayout {
Expand Down Expand Up @@ -121,9 +126,10 @@ ActivityNotificationBase {
}
else {
Global.changeAppSectionBySectionType(Constants.appSection.wallet,
WalletLayout.LeftPanelSelection.AllAddresses,
WalletLayout.RightPanelSelection.Activity)
// TODO: Final navigation to the specific transaction entry --> {transaction: txHash}) --> Issue #13249
WalletLayout.LeftPanelSelection.Address,
WalletLayout.RightPanelSelection.Activity,
{address: root.tokenData.walletAddress,
txHash: root.txHash})
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions ui/imports/shared/stores/CommunityTokensStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ QtObject {
string communityId, string communityName,
string balance, int chainId,
string txHash, bool isFirst,
int tokenType, string walletAccountName)
int tokenType, string walletAccountName,
string walletAddress)

// Minting tokens:
function deployCollectible(communityId, collectibleItem)
Expand Down Expand Up @@ -136,8 +137,8 @@ QtObject {
root.ownerTokenReceived(communityId, communityName)
}

function onCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName) {
root.communityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName)
function onCommunityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName, walletAccountName, walletAddress) {
root.communityTokenReceived(name, symbol, image, communityId, communityName, balance, chainId, txHash, isFirst, tokenType, walletAccountName, walletAccountName, walletAddress)
}

function onSetSignerStateChanged(communityId, communityName, status, url) {
Expand Down
41 changes: 41 additions & 0 deletions ui/imports/shared/views/HistoryView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ ColumnLayout {
}
}

onVisibleChanged: {
d.openTxDetailsHash = ""
}

Component.onCompleted: {
filterPanelLoader.active = true
if (RootStore.transactionActivityStatus.isFilterDirty) {
Expand All @@ -64,6 +68,16 @@ ColumnLayout {
}
}

Connections {
target: WalletStores.RootStore.currentActivityFiltersStore
enabled: root.visible
function onDisplayTxDetails(txHash) {
if (!d.openTxDetails(txHash)) {
d.openTxDetailsHash = txHash
}
}
}

QtObject {
id: d
readonly property bool isInitialLoading: RootStore.loadingHistoryTransactions && transactionListRoot.count === 0
Expand All @@ -78,6 +92,23 @@ ColumnLayout {
d.lastRefreshTime = Date.now()
newTransactions.visible = false
}

property string openTxDetailsHash

function openTxDetails(txHash) {
// Prevent opening details when loading, that will invalidate the model data
if (RootStore.loadingHistoryTransactions) {
return false
}

const index = WalletStores.RootStore.currentActivityFiltersStore.transactionsList.getIndex(txHash)
if (index < 0)
return false
const entry = transactionListRoot.itemAtIndex(index)
root.selectedTransaction = Qt.binding(() => entry.modelData)
root.launchTransactionDetail(index)
return true
}
}

StyledText {
Expand Down Expand Up @@ -133,6 +164,16 @@ ColumnLayout {
objectName: "walletAccountTransactionList"
anchors.fill: parent

onCountChanged: {
if (!!d.openTxDetailsHash && root.visible) {
if (d.openTxDetails(d.openTxDetailsHash)) {
d.openTxDetailsHash = ""
} else {
RootStore.fetchMoreTransactions()
}
}
}

model: SortFilterProxyModel {
id: txModel

Expand Down
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 95 files
+1 −1 VERSION
+0 −10 account/accounts.go
+11 −0 account/utils.go
+106 −106 appdatabase/migrations/bindata.go
+54 −54 appdatabase/migrationsprevnodecfg/bindata.go
+3 −3 mailserver/migrations/bindata.go
+9 −0 mobile/status.go
+13 −13 multiaccounts/migrations/bindata.go
+4 −3 multiaccounts/settings/columns.go
+31 −0 multiaccounts/settings/columns_test.go
+7 −0 multiaccounts/settings/database.go
+6 −0 multiaccounts/settings/structs.go
+9 −0 multiaccounts/settings/value_handlers.go
+19 −0 protocol/activity_center.go
+45 −3 protocol/activity_center_persistence.go
+3 −3 protocol/anonmetrics/migrations/migrations.go
+41 −0 protocol/communities/manager.go
+25 −0 protocol/communities/persistence.go
+105 −105 protocol/communities_messenger_test.go
+497 −495 protocol/communities_messenger_token_permissions_test.go
+20 −20 protocol/encryption/migrations/migrations.go
+847 −480 protocol/encryption/protocol_message.pb.go
+146 −0 protocol/identity/profile_showcase.go
+20 −1 protocol/messenger.go
+8 −0 protocol/messenger_activity_center.go
+12 −6 protocol/messenger_backup.go
+26 −0 protocol/messenger_backup_test.go
+14 −2 protocol/messenger_communities.go
+6 −3 protocol/messenger_communities_sharding_test.go
+1,623 −1,625 protocol/messenger_contact_requests_test.go
+4 −0 protocol/messenger_handler.go
+26 −0 protocol/messenger_handlers.go
+101 −98 protocol/messenger_offline_test.go
+222 −131 protocol/messenger_profile_showcase.go
+207 −0 protocol/messenger_profile_showcase_proto_conversions.go
+283 −242 protocol/messenger_profile_showcase_test.go
+10 −12 protocol/messenger_response.go
+16 −10 protocol/messenger_saved_address.go
+92 −0 protocol/messenger_storenode_request_test.go
+10 −0 protocol/messenger_sync_raw_messages.go
+161 −107 protocol/messenger_sync_saved_addresses_test.go
+121 −0 protocol/messenger_testing_utils.go
+902 −712 protocol/migrations/migrations.go
+5 −0 protocol/migrations/sqlite/1707749393_add_community_grants.up.sql
+5 −0 protocol/migrations/sqlite/1707841194_add_profile_showcase_preferences.up.sql
+1 −0 protocol/migrations/sqlite/1708062699_activity_data.up.sql
+74 −144 protocol/persistence_profile_showcase.go
+72 −70 protocol/persistence_profile_showcase_test.go
+204 −110 protocol/protobuf/anon_metrics.pb.go
+501 −313 protocol/protobuf/application_metadata_message.pb.go
+1 −0 protocol/protobuf/application_metadata_message.proto
+356 −194 protocol/protobuf/chat_identity.pb.go
+1,882 −1,145 protocol/protobuf/chat_message.pb.go
+478 −283 protocol/protobuf/command.pb.go
+2,045 −1,183 protocol/protobuf/communities.pb.go
+222 −107 protocol/protobuf/community_privileged_user_sync_message.pb.go
+138 −68 protocol/protobuf/community_shard_key.pb.go
+758 −416 protocol/protobuf/community_update.pb.go
+337 −191 protocol/protobuf/contact.pb.go
+298 −163 protocol/protobuf/contact_verification.pb.go
+209 −109 protocol/protobuf/emoji_reaction.pb.go
+203 −93 protocol/protobuf/enums.pb.go
+180 −88 protocol/protobuf/group_chat_invitation.pb.go
+298 −171 protocol/protobuf/membership_update_message.pb.go
+3,925 −2,370 protocol/protobuf/pairing.pb.go
+2 −0 protocol/protobuf/pairing.proto
+139 −69 protocol/protobuf/pin_message.pb.go
+1,379 −363 protocol/protobuf/profile_showcase.pb.go
+58 −0 protocol/protobuf/profile_showcase.proto
+989 −549 protocol/protobuf/push_notifications.pb.go
+132 −65 protocol/protobuf/segment_message.pb.go
+245 −134 protocol/protobuf/shard.pb.go
+180 −89 protocol/protobuf/status_update.pb.go
+267 −167 protocol/protobuf/sync_settings.pb.go
+348 −203 protocol/protobuf/url_data.pb.go
+7 −7 protocol/pushnotificationclient/migrations/migrations.go
+5 −5 protocol/pushnotificationserver/migrations/migrations.go
+6 −6 protocol/transport/migrations/migrations.go
+304 −289 server/pairing/sync_device_test.go
+1 −1 services/accounts/accounts.go
+1 −0 services/accounts/settings.go
+22 −13 services/ext/api.go
+25 −1 services/wallet/collectibles/ownership_db.go
+53 −5 services/wallet/collectibles/service.go
+6 −1 services/wallet/collectibles/types.go
+10 −16 services/wallet/saved_addresses.go
+23 −19 services/wallet/saved_addresses_test.go
+1 −0 services/wallet/thirdparty/collectible_types.go
+12 −8 services/wallet/token/token.go
+10 −5 services/wallet/token/token_test.go
+5 −4 services/wallet/transfer/commands.go
+7 −1 services/wallet/transfer/commands_sequential.go
+21 −21 static/bindata.go
+3 −3 t/bindata.go
+23 −23 walletdatabase/migrations/bindata.go

0 comments on commit 7bc8e8a

Please sign in to comment.