Skip to content

Commit 0b6dd31

Browse files
authored
Merge pull request #808 from Samuel1-ona/fix/combined-issues-cleanup-v2
Fix/combined issues cleanup v2
2 parents 55a6769 + bc4c8b5 commit 0b6dd31

7 files changed

Lines changed: 298 additions & 273 deletions

File tree

CHANGELOG.md

Lines changed: 264 additions & 264 deletions
Large diffs are not rendered by default.

backend/src/common/dto/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export * from './pagination.dto';
22
export * from './paginated-response.dto';
3+
4+
// Restored exports from users-module
5+
export { UserProfileDto, PaginatedUsersDto } from '../../users-module';

backend/src/creators/creator-dashboard.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class CreatorDashboardService {
7777

7878
// Active subscribers (currently active regardless of window)
7979
const activeCount = creatorSubs.filter(
80-
s => s.status === 'active' && s.expiryUnix > nowSecs,
80+
s => s.status === 'active' && Number(s.expiryUnix) > nowSecs,
8181
).length;
8282

8383
// New in window: created within [from, to]
@@ -88,7 +88,7 @@ export class CreatorDashboardService {
8888

8989
// Churned in window: expired within [from, to]
9090
const churned = creatorSubs.filter(s => {
91-
return s.status === 'expired' && s.expiryUnix >= fromSecs && s.expiryUnix <= toSecs;
91+
return s.status === 'expired' && Number(s.expiryUnix) >= fromSecs && Number(s.expiryUnix) <= toSecs;
9292
}).length;
9393

9494
// Revenue: aggregate per plan for subs created in window
@@ -142,7 +142,7 @@ export class CreatorDashboardService {
142142
amount: parseFloat(p.amount),
143143
intervalDays: p.intervalDays,
144144
activeSubscribers: creatorSubs.filter(
145-
s => s.planId === p.id && s.status === 'active' && s.expiryUnix > nowSecs,
145+
s => s.planId === p.id && s.status === 'active' && Number(s.expiryUnix) > nowSecs,
146146
).length,
147147
})),
148148
};

backend/src/subscriptions/subscriptions.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ export class SubscriptionsController {
5050
@UseInterceptors(new DeprecationInterceptor(new Reflector()))
5151
@ApiOperation({ summary: '[Deprecated] Check if a fan is subscribed to a creator', deprecated: true })
5252
@ApiResponse({ status: 200, description: 'Subscription check result' })
53-
checkSubscription(@Query('fan') fan: string, @Query('creator') creator: string) {
54-
return { isSubscriber: this.subscriptionsService.isSubscriber(fan, creator) };
53+
async checkSubscription(@Query('fan') fan: string, @Query('creator') creator: string) {
54+
const isSubscriber = await this.subscriptionsService.isSubscriber(fan, creator);
55+
return { isSubscriber };
5556
}
5657

5758
@Get('list')

backend/src/users-module/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export * from './user-profile.dto';
2+
export * from './paginated-users-response.dto';
3+
4+
import { PaginatedResponseDto } from '../common/dto';
5+
import { UserProfileDto } from './user-profile.dto';
6+
7+
/** Alias for compatibility with frontend alignment request */
8+
export type PaginatedUsersDto = PaginatedResponseDto<UserProfileDto>;

contract/contracts/creator-registry/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ pub enum DataKey {
1818
LastRegLedger(Address), // last ledger when this caller did a registration
1919
}
2020

21+
impl DataKey {
22+
/// Canonical registration ledger storage key; serializes as [`DataKey::LastRegLedger`].
23+
#[inline]
24+
pub fn registration_ledger(caller: Address) -> Self {
25+
DataKey::LastRegLedger(caller)
26+
}
27+
}
28+
2129
#[contracterror]
2230
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2331
pub enum Error {
@@ -59,7 +67,7 @@ impl CreatorRegistryContract {
5967
}
6068

6169
let current = env.ledger().sequence();
62-
let last_key = DataKey::LastRegLedger(caller.clone());
70+
let last_key = DataKey::registration_ledger(caller.clone());
6371
if let Some(last) = env.storage().persistent().get::<DataKey, u32>(&last_key) {
6472
if current < last.saturating_add(RATE_LIMIT_LEDGERS) {
6573
panic_with_error!(&env, Error::RateLimited);

contract/contracts/subscription/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,16 @@ pub enum DataKey {
4040
}
4141

4242
impl DataKey {
43-
/// Canonical subscription storage key; serializes as [`DataKey::Sub`].
4443
#[inline]
4544
pub fn subscription(fan: Address, creator: Address) -> Self {
4645
DataKey::Sub(fan, creator)
4746
}
47+
48+
/// Canonical token address storage key; serializes as [`DataKey::Token`].
49+
#[inline]
50+
pub fn token_address() -> Self {
51+
DataKey::Token
52+
}
4853
}
4954

5055
#[contracterror]
@@ -122,7 +127,7 @@ impl MyfansContract {
122127
.instance()
123128
.set(&DataKey::FeeRecipient, &fee_recipient);
124129
env.storage().instance().set(&DataKey::PlanCount, &0u32);
125-
env.storage().instance().set(&DataKey::Token, &token);
130+
env.storage().instance().set(&DataKey::token_address(), &token);
126131
env.storage().instance().set(&DataKey::Price, &price);
127132
}
128133

@@ -341,7 +346,7 @@ impl MyfansContract {
341346
.unwrap_or(false);
342347
assert!(!paused, "contract is paused");
343348

344-
let token: Address = env.storage().instance().get(&DataKey::Token).unwrap();
349+
let token: Address = env.storage().instance().get(&DataKey::token_address()).unwrap();
345350
let price: i128 = env.storage().instance().get(&DataKey::Price).unwrap();
346351
let fee_bps: u32 = env.storage().instance().get(&DataKey::FeeBps).unwrap_or(0);
347352
let fee_recipient: Address = env

0 commit comments

Comments
 (0)