Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
528 changes: 264 additions & 264 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions backend/src/common/dto/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export * from './pagination.dto';
export * from './paginated-response.dto';

// Restored exports from users-module
export { UserProfileDto, PaginatedUsersDto } from '../../users-module';
6 changes: 3 additions & 3 deletions backend/src/creators/creator-dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CreatorDashboardService {

// Active subscribers (currently active regardless of window)
const activeCount = creatorSubs.filter(
s => s.status === 'active' && s.expiryUnix > nowSecs,
s => s.status === 'active' && Number(s.expiryUnix) > nowSecs,
).length;

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

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

// Revenue: aggregate per plan for subs created in window
Expand Down Expand Up @@ -142,7 +142,7 @@ export class CreatorDashboardService {
amount: parseFloat(p.amount),
intervalDays: p.intervalDays,
activeSubscribers: creatorSubs.filter(
s => s.planId === p.id && s.status === 'active' && s.expiryUnix > nowSecs,
s => s.planId === p.id && s.status === 'active' && Number(s.expiryUnix) > nowSecs,
).length,
})),
};
Expand Down
5 changes: 3 additions & 2 deletions backend/src/subscriptions/subscriptions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ export class SubscriptionsController {
@UseInterceptors(new DeprecationInterceptor(new Reflector()))
@ApiOperation({ summary: '[Deprecated] Check if a fan is subscribed to a creator', deprecated: true })
@ApiResponse({ status: 200, description: 'Subscription check result' })
checkSubscription(@Query('fan') fan: string, @Query('creator') creator: string) {
return { isSubscriber: this.subscriptionsService.isSubscriber(fan, creator) };
async checkSubscription(@Query('fan') fan: string, @Query('creator') creator: string) {
const isSubscriber = await this.subscriptionsService.isSubscriber(fan, creator);
return { isSubscriber };
}

@Get('list')
Expand Down
8 changes: 8 additions & 0 deletions backend/src/users-module/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './user-profile.dto';
export * from './paginated-users-response.dto';

import { PaginatedResponseDto } from '../common/dto';
import { UserProfileDto } from './user-profile.dto';

/** Alias for compatibility with frontend alignment request */
export type PaginatedUsersDto = PaginatedResponseDto<UserProfileDto>;
10 changes: 9 additions & 1 deletion contract/contracts/creator-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ pub enum DataKey {
LastRegLedger(Address), // last ledger when this caller did a registration
}

impl DataKey {
/// Canonical registration ledger storage key; serializes as [`DataKey::LastRegLedger`].
#[inline]
pub fn registration_ledger(caller: Address) -> Self {
DataKey::LastRegLedger(caller)
}
}

#[contracterror]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Error {
Expand Down Expand Up @@ -59,7 +67,7 @@ impl CreatorRegistryContract {
}

let current = env.ledger().sequence();
let last_key = DataKey::LastRegLedger(caller.clone());
let last_key = DataKey::registration_ledger(caller.clone());
if let Some(last) = env.storage().persistent().get::<DataKey, u32>(&last_key) {
if current < last.saturating_add(RATE_LIMIT_LEDGERS) {
panic_with_error!(&env, Error::RateLimited);
Expand Down
11 changes: 8 additions & 3 deletions contract/contracts/subscription/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ pub enum DataKey {
}

impl DataKey {
/// Canonical subscription storage key; serializes as [`DataKey::Sub`].
#[inline]
pub fn subscription(fan: Address, creator: Address) -> Self {
DataKey::Sub(fan, creator)
}

/// Canonical token address storage key; serializes as [`DataKey::Token`].
#[inline]
pub fn token_address() -> Self {
DataKey::Token
}
}

#[contracterror]
Expand Down Expand Up @@ -122,7 +127,7 @@ impl MyfansContract {
.instance()
.set(&DataKey::FeeRecipient, &fee_recipient);
env.storage().instance().set(&DataKey::PlanCount, &0u32);
env.storage().instance().set(&DataKey::Token, &token);
env.storage().instance().set(&DataKey::token_address(), &token);
env.storage().instance().set(&DataKey::Price, &price);
}

Expand Down Expand Up @@ -341,7 +346,7 @@ impl MyfansContract {
.unwrap_or(false);
assert!(!paused, "contract is paused");

let token: Address = env.storage().instance().get(&DataKey::Token).unwrap();
let token: Address = env.storage().instance().get(&DataKey::token_address()).unwrap();
let price: i128 = env.storage().instance().get(&DataKey::Price).unwrap();
let fee_bps: u32 = env.storage().instance().get(&DataKey::FeeBps).unwrap_or(0);
let fee_recipient: Address = env
Expand Down
Loading