Skip to content

Conversation

@vkjr
Copy link
Contributor

@vkjr vkjr commented Nov 3, 2025

Description

This PR fixes an issue where ERC20 tokens discovered in wallet activity transactions were not having their metadata fetched, causing incorrect values to be displayed

Notes for reviewers

When fetching wallet activity from Alchemy, ERC20 token transfers would be detected, but if the token metadata wasn't already known to the system, the token would display without info (no symbol, name, or decimals).

In this PR:

  • Fixed crash on receiving malformed Alchemy responses (they do not always send proper hexadecimals for values like "0" or "1"
  • Fixed the initial block parameter for activity fetching (wrong constant was used before which lead to Alchemy error)
  • pub/mechanism added to token manager, so fetching token data can be made as async request
  • TokenListsUpdated signal emited when new token data is fetched to ensure UI refresh

Closes #7036

@vkjr vkjr self-assigned this Nov 3, 2025
@status-im-auto
Copy link
Member

status-im-auto commented Nov 3, 2025

Jenkins Builds

Click to see older builds (24)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a93fbf7 #1 2025-11-03 10:20:01 ~3 min macos/status-go 📦zip
✖️ a93fbf7 #1 2025-11-03 10:20:21 ~4 min tests 📄log
✔️ a93fbf7 #1 2025-11-03 10:20:25 ~4 min linux/status-go 📦zip
✔️ a93fbf7 #1 2025-11-03 10:22:51 ~6 min windows/status-go 📦zip
✔️ a93fbf7 #1 2025-11-03 10:27:27 ~11 min linux/nwaku 📦zip
✔️ a93fbf7 #1 2025-11-03 10:28:46 ~12 min tests-rpc 📄log
✔️ 0ed2f22 #2 2025-11-03 10:26:09 ~3 min linux/status-go 📦zip
✔️ 0ed2f22 #2 2025-11-03 10:26:14 ~3 min macos/status-go 📦zip
✖️ 0ed2f22 #2 2025-11-03 10:26:19 ~3 min tests 📄log
✔️ 0ed2f22 #2 2025-11-03 10:28:24 ~5 min windows/status-go 📦zip
✔️ 0ed2f22 #2 2025-11-03 10:38:30 ~10 min linux/nwaku 📦zip
✔️ 0ed2f22 #2 2025-11-03 10:41:17 ~12 min tests-rpc 📄log
✔️ 674dbb7 #3 2025-11-03 11:25:39 ~3 min linux/status-go 📦zip
✔️ 674dbb7 #3 2025-11-03 11:25:46 ~3 min macos/status-go 📦zip
✔️ 674dbb7 #3 2025-11-03 11:28:05 ~5 min windows/status-go 📦zip
✖️ 674dbb7 #3 2025-11-03 11:28:32 ~6 min tests 📄log
✔️ 674dbb7 #3 2025-11-03 11:34:52 ~12 min linux/nwaku 📦zip
✔️ 674dbb7 #3 2025-11-03 11:35:07 ~12 min tests-rpc 📄log
✔️ ff1d4d6 #4 2025-11-03 12:00:04 ~3 min macos/status-go 📦zip
✔️ ff1d4d6 #4 2025-11-03 12:00:05 ~3 min linux/status-go 📦zip
✔️ ff1d4d6 #4 2025-11-03 12:01:54 ~5 min windows/status-go 📦zip
✖️ ff1d4d6 #4 2025-11-03 12:02:25 ~5 min tests 📄log
✔️ ff1d4d6 #4 2025-11-03 12:07:02 ~10 min linux/nwaku 📦zip
✔️ ff1d4d6 #4 2025-11-03 12:08:49 ~12 min tests-rpc 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 50f6c03 #5 2025-11-04 14:56:35 ~3 min linux/status-go 📦zip
✔️ 50f6c03 #5 2025-11-04 14:56:43 ~3 min macos/status-go 📦zip
✖️ 50f6c03 #5 2025-11-04 14:59:04 ~5 min tests 📄log
✔️ 50f6c03 #5 2025-11-04 14:59:12 ~6 min windows/status-go 📦zip
✔️ 50f6c03 #5 2025-11-04 15:03:44 ~10 min linux/nwaku 📦zip
✔️ 50f6c03 #5 2025-11-04 15:05:39 ~12 min tests-rpc 📄log
✖️ 50f6c03 #6 2025-11-05 12:20:59 ~5 min tests 📄log
✔️ 9d704cb #6 2025-11-05 14:04:32 ~3 min linux/status-go 📦zip
✔️ 9d704cb #6 2025-11-05 14:04:38 ~3 min macos/status-go 📦zip
✔️ 9d704cb #6 2025-11-05 14:06:45 ~5 min windows/status-go 📦zip
✔️ 9d704cb #6 2025-11-05 14:11:42 ~10 min linux/nwaku 📦zip
✔️ 9d704cb #6 2025-11-05 14:13:29 ~12 min tests-rpc 📄log
✔️ 9d704cb #7 2025-11-05 14:30:00 ~28 min tests 📄log

@vkjr vkjr force-pushed the fix/erc20-token-displaying branch from a93fbf7 to 0ed2f22 Compare November 3, 2025 10:22
@vkjr vkjr changed the title [WIP] Fix/erc20 token displaying [WIP] Display ERC20 token metadata correctly for recently fetched tokens Nov 3, 2025
@vkjr vkjr requested review from alaibe, dlipicar, igor-sirotin and saledjenic and removed request for dlipicar November 3, 2025 10:30
}

// Request async token discovery for ERC20 transfers to make sure we have their metadata
if deps.tokenPublisher != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, the way we normally do it, modules publish events in their "domain" (alchemy knows deals with transfers, so it publishes events like "hey I've just fetched these transfers".

It is the subscriber's responsibility to interpret those events and react in accordance (that is, tokenManager should subscribe to "here's some new transfers" signal and know it needs to potentially fetch metadata for some new token). The benefit of this becomes clearer when there's multiple subscribers for a given publisher, it doesn't make sense for the publisher to have knowledge of every subscriber.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, requesting the token metadata every time the client fetches activity entries seems like a bit of an overkill. Can't we detect tokens for which for some reason the metadata is not available and only request those? You can do that request directly (ie call some method from an interface) instead of using the pubsub mechanism for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlipicar, thanks for clarification, that of course makes much more sense 👍

Yes, I also thought about checking if metadata exists but didn't want to introduce relation to TokenManager and use only publisher, but I will change this

}

// Request async token discovery for ERC20 transfers to make sure we have their metadata
if m.tokenPublisher != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first part of the previous comment belongs here, we probably want to publish something like a "transfersFetched" event here, which potentially many other modules will want to subscribe to (to refresh balances, collectibles ownership, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlipicar,
Fixed pub/sub pattern. Events now describe "what happened" (ERC20ActivityFetched) not "what to do" (TokenDiscoveryRequest).
Publisher moved from TokenManager to ActivityFetcher abstraction level.
Alchemy emits events -> ActivityFetcher publishes -> TokenManager subscribes and reacts.


if lastFetchedBlock == nil {
fromBlock := gethrpc.EarliestBlockNumber
fromBlock := gethrpc.BlockNumber(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have my doubts about this :D
#7035 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlipicar, wondering if we are referring to the same gethrpc)
My lsp server jumps to this:

EarliestBlockNumber = BlockNumber(-5)

Screenshot 2025-11-03 at 11 26 48

@vkjr vkjr changed the title [WIP] Display ERC20 token metadata correctly for recently fetched tokens fix: Display ERC20 token metadata correctly for recently fetched tokens Nov 4, 2025
@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 61.44578% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.98%. Comparing base (d082425) to head (9d704cb).
⚠️ Report is 34 commits behind head on develop.

Files with missing lines Patch % Lines
...rvices/wallet/thirdparty/activity/alchemy/types.go 31.25% 9 Missing and 2 partials ⚠️
services/wallet/token/token.go 64.51% 11 Missing ⚠️
services/wallet/activityfetcher/alchemy/manager.go 20.00% 8 Missing ⚠️
services/wallet/activity/fetched_entries.go 0.00% 1 Missing ⚠️
services/wallet/activityfetcher/manager.go 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7063      +/-   ##
===========================================
- Coverage    60.05%   59.98%   -0.08%     
===========================================
  Files          808      808              
  Lines       114203   114277      +74     
===========================================
- Hits         68582    68544      -38     
- Misses       38651    38727      +76     
- Partials      6970     7006      +36     
Flag Coverage Δ
functional 36.37% <43.37%> (-0.12%) ⬇️
unit 55.32% <61.44%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
services/wallet/service.go 76.65% <100.00%> (+0.27%) ⬆️
.../wallet/thirdparty/activity/alchemy/conversions.go 73.14% <100.00%> (+0.89%) ⬆️
services/wallet/thirdparty/activity_types.go 0.00% <ø> (ø)
services/wallet/activity/fetched_entries.go 6.43% <0.00%> (-0.59%) ⬇️
services/wallet/activityfetcher/manager.go 20.28% <90.00%> (+8.99%) ⬆️
services/wallet/activityfetcher/alchemy/manager.go 22.50% <20.00%> (-0.09%) ⬇️
...rvices/wallet/thirdparty/activity/alchemy/types.go 50.00% <31.25%> (-50.00%) ⬇️
services/wallet/token/token.go 53.61% <64.51%> (+1.57%) ⬆️

... and 42 files with indirect coverage changes

@saledjenic
Copy link
Contributor

@vkjr have to ask you if not a problem to postpone merging of this PR until this one gets merged #6912 ?

Even changes you did here are not too complex I see that some code has been removed in my PR and there will be conflicts for sure and I would like to avoid them.

My giant PR brings a lot of changes, basically it changes a fundamental approach on how we deal with tokens/token lists and basically affects many parts of the app. It's planned to have it merged by the end of the month. Until then, I will have a hard time keeping it in shape (it's not statusgo rebase only, but the desktop pr also). Having all that in mind and since this change is not that urgent, it would be really nice to postpone it. In the meantime, if you want, you can rebase it on top of my work.

@vkjr vkjr added the blocked label Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: login crash on fetching activities

4 participants