#pragma once #include #include #include #include #include #include #include "WalletProvider.h" struct TokenDefinitionCacheKey { QString networkId; QString networkFingerprint; QString sequencerAddress; QStringList tokenIds; bool isReusable() const; bool operator==(const TokenDefinitionCacheKey& other) const; }; class TokenDefinitionCache final { public: using Callback = std::function)>; explicit TokenDefinitionCache(WalletProvider& provider); ~TokenDefinitionCache(); void read(const TokenDefinitionCacheKey& key, Callback callback); bool contains(const TokenDefinitionCacheKey& key) const; void cancelPending(); void clear(); private: struct InFlight { TokenDefinitionCacheKey key; QVector callbacks; bool cancelled = false; }; struct State { std::optional cachedKey; QVector cachedReads; std::shared_ptr inFlight; }; static bool isComplete(const TokenDefinitionCacheKey& key, const QVector& reads); WalletProvider& m_provider; std::shared_ptr m_state; };