Skip to content

Commit 51a4ce9

Browse files
authored
fix(tc): external address type resolution in trade dialog (#3118)
## Description Fixes incorrect token type detection in `TradeCommunityTokenDialog` when navigation always passes `externalAddress`. The dialog now derives `ExternalAddressType` from Ion entity or token definition, and the token page passes the correct origin `eventReference` for Ion tokens to keep trade behavior consistent. ## Task ID ION-4998 ## Type of Change - [x] Bug fix ## Screenshots <img width="350" alt="image" src="https://github.com/user-attachments/assets/d11f312c-0895-464e-ab7f-093ebc450687" />
1 parent 62e2e71 commit 51a4ce9

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

lib/app/features/tokenized_communities/views/pages/tokenized_community_page.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:ion/app/features/components/bookmarks/bookmark_button.dart';
1515
import 'package:ion/app/features/feed/views/components/community_token_live/components/feed_content_token.dart';
1616
import 'package:ion/app/features/feed/views/components/community_token_live/components/feed_profile_token.dart';
1717
import 'package:ion/app/features/feed/views/components/community_token_live/components/feed_twitter_token.dart';
18+
import 'package:ion/app/features/tokenized_communities/models/entities/community_token_definition.f.dart';
1819
import 'package:ion/app/features/tokenized_communities/models/trading_stats_formatted.dart';
1920
import 'package:ion/app/features/tokenized_communities/providers/community_token_definition_provider.r.dart';
2021
import 'package:ion/app/features/tokenized_communities/providers/token_latest_trades_provider.r.dart';
@@ -83,6 +84,10 @@ class TokenizedCommunityPage extends HookConsumerWidget {
8384
final tokenDefinition = ref
8485
.watch(tokenDefinitionForExternalAddressProvider(externalAddress: externalAddress))
8586
.valueOrNull;
87+
final tradeEventReference = switch (tokenDefinition?.data) {
88+
CommunityTokenDefinitionIon(:final eventReference) => eventReference,
89+
_ => null,
90+
};
8691
final tokenType = ref.watch(tokenTypeForExternalAddressProvider(externalAddress)).valueOrNull;
8792
final activeTab = useState(TokenizedCommunityTabType.chart);
8893
final isCommentInputFocused = useMemoized(() => ValueNotifier<bool>(false), []);
@@ -200,9 +205,9 @@ class TokenizedCommunityPage extends HookConsumerWidget {
200205
builder: (context, isFocused, _) {
201206
return isFocused
202207
? const SizedBox.shrink()
203-
: FloatingTradeIsland(
204-
externalAddress: externalAddress,
205-
);
208+
: tradeEventReference != null
209+
? FloatingTradeIsland(eventReference: tradeEventReference)
210+
: FloatingTradeIsland(externalAddress: externalAddress);
206211
},
207212
),
208213
headerActionsBuilder: (OverlayMenuCloseSignal menuCloseSignal) => [

lib/app/features/tokenized_communities/views/trade_community_token_dialog.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:ion/app/features/ion_connect/model/event_reference.f.dart';
1818
import 'package:ion/app/features/ion_connect/providers/ion_connect_entity_provider.r.dart';
1919
import 'package:ion/app/features/tokenized_communities/enums/community_token_trade_mode.dart';
2020
import 'package:ion/app/features/tokenized_communities/providers/community_token_trade_notifier_provider.r.dart';
21+
import 'package:ion/app/features/tokenized_communities/providers/external_address_type_provider.r.dart';
2122
import 'package:ion/app/features/tokenized_communities/providers/trade_community_token_controller_provider.r.dart';
2223
import 'package:ion/app/features/tokenized_communities/providers/trade_infrastructure_providers.r.dart';
2324
import 'package:ion/app/features/tokenized_communities/utils/constants.dart';
@@ -60,12 +61,12 @@ class TradeCommunityTokenDialog extends HookConsumerWidget {
6061
@override
6162
Widget build(BuildContext context, WidgetRef ref) {
6263
final resolvedExternalAddress = externalAddress ?? eventReference!.toString();
63-
final resolvedExternalAddressType = externalAddress != null
64-
? const ExternalAddressType.x()
65-
: ref
64+
final resolvedExternalAddressType = eventReference != null
65+
? ref
6666
.watch(ionConnectEntityProvider(eventReference: eventReference!))
6767
.valueOrNull
68-
?.externalAddressType;
68+
?.externalAddressType
69+
: ref.watch(externalAddressTypeProvider(externalAddress: externalAddress!)).valueOrNull;
6970
if (resolvedExternalAddressType == null) {
7071
return const SheetContent(body: SizedBox.shrink());
7172
}

0 commit comments

Comments
 (0)