Skip to content

Commit 58c68c5

Browse files
committed
fix: use bounding curve smart contract address from config to identify bounding curve in holder
1 parent 18ed79b commit 58c68c5

18 files changed

Lines changed: 56 additions & 31 deletions

File tree

lib/app/features/tokenized_communities/providers/trade_infrastructure_providers.r.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ Future<TradeCommunityTokenService> tradeCommunityTokenService(
105105
);
106106
}
107107

108+
@riverpod
109+
Future<String> bondingCurveAddress(Ref ref) async {
110+
final repository = await ref.watch(tradeCommunityTokenRepositoryProvider.future);
111+
return repository.fetchBondingCurveAddress();
112+
}
113+
108114
@riverpod
109115
Future<List<CoinData>> supportedSwapTokens(Ref ref) async {
110116
final api = await ref.watch(tradeCommunityTokenApiProvider.future);

lib/app/features/tokenized_communities/views/pages/holders/components/holder_tile.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BurningHolderTile extends StatelessWidget {
5252
return HolderTile(
5353
rank: holder.position.rank,
5454
amountText: formatAmountCompactFromRaw(holder.position.amount),
55-
displayName: holder.position.holder?.display ?? 'Burned',
55+
displayName: holder.position.holder?.display ?? context.i18n.tokenized_community_burned,
5656
supplyShare: holder.position.supplyShare,
5757
avatarUrl: holder.position.holder?.avatar,
5858
badgeType: RankBadgeType.burning,
@@ -202,7 +202,7 @@ class _RankBadge extends StatelessWidget {
202202
final child = switch (type) {
203203
RankBadgeType.burning => Assets.svg.iconTokenFire.icon(),
204204
RankBadgeType.bondingCurve => Assets.svg.iconMemeBondingcurve.icon(),
205-
RankBadgeType.regular => rank <= 4
205+
RankBadgeType.regular => rank <= 3
206206
? _MedalIcon(rank: rank)
207207
: Text(
208208
'$rank',
@@ -231,10 +231,9 @@ class _MedalIcon extends StatelessWidget {
231231
@override
232232
Widget build(BuildContext context) {
233233
return switch (rank) {
234-
1 => Assets.svg.iconMemeBondingcurve,
235-
2 => Assets.svg.iconMeme1stplace,
236-
3 => Assets.svg.iconMeme2ndtplace,
237-
4 => Assets.svg.iconMeme3rdplace,
234+
1 => Assets.svg.iconMeme1stplace,
235+
2 => Assets.svg.iconMeme2ndtplace,
236+
3 => Assets.svg.iconMeme3rdplace,
238237
_ => throw UnimplementedError(),
239238
}
240239
.icon();

lib/app/features/tokenized_communities/views/pages/holders/components/top_holders/top_holders.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import 'package:flutter/material.dart';
44
import 'package:hooks_riverpod/hooks_riverpod.dart';
55
import 'package:ion/app/extensions/extensions.dart';
6+
import 'package:ion/app/features/tokenized_communities/providers/trade_infrastructure_providers.r.dart';
67
import 'package:ion/app/features/tokenized_communities/views/pages/holders/components/holder_tile.dart';
78
import 'package:ion/app/features/tokenized_communities/views/pages/holders/components/top_holders/components/top_holders_empty.dart';
89
import 'package:ion/app/features/tokenized_communities/views/pages/holders/components/top_holders/components/top_holders_skeleton.dart';
@@ -142,6 +143,7 @@ class _TopHolderList extends ConsumerWidget {
142143
Widget build(BuildContext context, WidgetRef ref) {
143144
final holdersAsync =
144145
ref.watch(tokenTopHoldersProvider(externalAddress, limit: holdersCountLimit));
146+
final boundingCurveAddress = ref.watch(bondingCurveAddressProvider).valueOrNull;
145147
return holdersAsync.when(
146148
data: (holders) {
147149
if (holders.isEmpty) {
@@ -156,7 +158,7 @@ class _TopHolderList extends ConsumerWidget {
156158
itemBuilder: (context, index) {
157159
final holder = holders[index];
158160

159-
if (index == 0) {
161+
if (boundingCurveAddress != null && holder.isBoundingCurve(boundingCurveAddress)) {
160162
return BondingCurveHolderTile(
161163
holder: holder,
162164
);

lib/app/features/tokenized_communities/views/pages/holders/pages/holders_page.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:ion/app/components/scroll_view/load_more_builder.dart';
88
import 'package:ion/app/components/scroll_view/pull_to_refresh_builder.dart';
99
import 'package:ion/app/components/separated/separator.dart';
1010
import 'package:ion/app/extensions/extensions.dart';
11+
import 'package:ion/app/features/tokenized_communities/providers/trade_infrastructure_providers.r.dart';
1112
import 'package:ion/app/features/tokenized_communities/views/pages/holders/components/holder_tile.dart';
1213
import 'package:ion/app/features/tokenized_communities/views/pages/holders/components/top_holders/components/top_holders_skeleton.dart';
1314
import 'package:ion/app/features/tokenized_communities/views/pages/holders/providers/token_top_holders_provider.r.dart';
@@ -28,7 +29,7 @@ class HoldersPage extends HookConsumerWidget {
2829
final topHoldersProvider = tokenTopHoldersProvider(externalAddress, limit: 20);
2930
final topHoldersAsync = ref.watch(topHoldersProvider);
3031
final topHolders = topHoldersAsync.valueOrNull ?? const <TopHolder>[];
31-
32+
final boundingCurveAddress = ref.watch(bondingCurveAddressProvider).valueOrNull;
3233
return Scaffold(
3334
appBar: NavigationAppBar.screen(
3435
title: Text(context.i18n.holders, style: context.theme.appTextThemes.subtitle2),
@@ -53,22 +54,32 @@ class HoldersPage extends HookConsumerWidget {
5354
itemBuilder: (context, index) {
5455
final topPadding = index == 0 ? 12.s : 7.s;
5556
final bottomPadding = 7.s;
57+
final holder = topHolders[index];
5658

57-
if (index == 0) {
59+
if (boundingCurveAddress != null &&
60+
holder.isBoundingCurve(boundingCurveAddress)) {
5861
return _HoldersListPadding(
5962
topPadding: topPadding,
6063
bottomPadding: bottomPadding,
6164
child: BondingCurveHolderTile(
62-
holder: topHolders[index],
65+
holder: holder,
6366
),
6467
);
6568
}
6669

70+
if (holder.isBurning) {
71+
return _HoldersListPadding(
72+
topPadding: topPadding,
73+
bottomPadding: bottomPadding,
74+
child: BurningHolderTile(holder: holder),
75+
);
76+
}
77+
6778
return _HoldersListPadding(
6879
topPadding: topPadding,
6980
bottomPadding: bottomPadding,
7081
child: TopHolderTile(
71-
holder: topHolders[index],
82+
holder: holder,
7283
),
7384
);
7485
},

lib/app/features/tokenized_communities/views/pages/holders/providers/token_top_holders_provider.r.dart

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -223,27 +223,16 @@ class TokenTopHolders extends _$TokenTopHolders {
223223
}
224224

225225
final rank = item.position.rank;
226-
final insertAt = (rank - 1).clamp(0, list.length);
227-
list.insert(insertAt, item);
228226

229-
_normalizeRanks(list);
230-
}
231-
232-
void _normalizeRanks(List<TopHolder> list) {
233-
// Check if burning holder is at index 1 (second position)
234-
final hasBurningAtSecond = list.length > 1 && list[1].isBurning;
235-
236-
for (var i = 0; i < list.length; i++) {
237-
final current = list[i];
238-
239-
// If burning is at second position, use i, otherwise use i + 1
240-
final desiredRank = hasBurningAtSecond ? i : i + 1;
241-
242-
if (current.position.rank != desiredRank) {
243-
list[i] = current.copyWith(
244-
position: current.position.copyWith(rank: desiredRank),
245-
);
246-
}
227+
if (rank == 0) {
228+
// Count existing rank 0 items to insert after them
229+
final rankZeroCount = list.where((h) => h.position.rank == 0).length;
230+
list.insert(rankZeroCount, item);
231+
} else {
232+
// Count rank 0 items, then insert after them using rank - 1
233+
final rankZeroCount = list.where((h) => h.position.rank == 0).length;
234+
final insertAt = (rankZeroCount + rank - 1).clamp(0, list.length);
235+
list.insert(insertAt, item);
247236
}
248237
}
249238

lib/l10n/app_ar.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@
934934
"tokenized_community_comments_empty": "كن أول من ينضم إلى المحادثة",
935935
"tokenized_community_comments_tab": "التعليقات",
936936
"tokenized_community_holders_tab": "الحائزون",
937+
"tokenized_community_burned": "محروق",
937938
"token_comment_holders_only": "التعليقات متاحة فقط لحاملي الرموز.",
938939
"tokenized_community_not_available_description": "إنشاء الرموز غير متاح للمنشورات التي تم إنشاؤها مسبقًا.",
939940
"tokenized_community_not_available_title": "خطأ في المحتوى المرمز",

lib/l10n/app_bg.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@
920920
"tokenized_community_creator_token_live_title": "Токенът на създателя е АКТИВЕН!",
921921
"tokenized_community_creator_token_live_subtitle": "Поздравления, вашият токен на създателя вече е активен и достъпен за търговия от всички",
922922
"tokenized_community_holders_tab": "Притежатели",
923+
"tokenized_community_burned": "Изгорени",
923924
"token_comment_holders_only": "Коментарите са достъпни само за притежатели на токени.",
924925
"tokenized_community_not_available_description": "Създаването на токени не е налично за вече създадени публикации.",
925926
"tokenized_community_not_available_title": "Грешка при токенизирано съдържание",

lib/l10n/app_de.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@
920920
"tokenized_community_creator_token_live_title": "Creator-Token ist LIVE!",
921921
"tokenized_community_creator_token_live_subtitle": "Herzlichen Glückwunsch, Ihr Creator-Token ist jetzt live und für jeden handelbar",
922922
"tokenized_community_holders_tab": "Inhaber",
923+
"tokenized_community_burned": "Verbrannt",
923924
"token_comment_holders_only": "Kommentare sind nur für Token-Inhaber verfügbar.",
924925
"tokenized_community_not_available_description": "Die Tokenerstellung ist für zuvor erstellte Beiträge nicht verfügbar.",
925926
"tokenized_community_not_available_title": "Fehler bei tokenisiertem Inhalt",

lib/l10n/app_en.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,7 @@
918918
"tokenized_community_comments_empty": "Be the first to join the conversation",
919919
"tokenized_community_comments_tab": "Comments",
920920
"tokenized_community_holders_tab": "Holders",
921+
"tokenized_community_burned": "Burned",
921922
"token_comment_holders_only": "Comments are available only to token holders",
922923
"tokenized_community_not_available_description": "Token creation is not available for previously created posts.",
923924
"tokenized_community_not_available_title": "Tokenized content error",

lib/l10n/app_es.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@
920920
"tokenized_community_creator_token_live_title": "¡El token del creador está EN VIVO!",
921921
"tokenized_community_creator_token_live_subtitle": "Felicidades, tu token de creador ya está en vivo y disponible para que todos lo intercambien",
922922
"tokenized_community_holders_tab": "Tenedores",
923+
"tokenized_community_burned": "Quemado",
923924
"token_comment_holders_only": "Los comentarios están disponibles solo para los tenedores de tokens.",
924925
"tokenized_community_not_available_description": "La creación de tokens no está disponible para publicaciones creadas previamente.",
925926
"tokenized_community_not_available_title": "Error de contenido tokenizado",

0 commit comments

Comments
 (0)