Skip to content

Commit 41d6925

Browse files
committed
fix: resolve pre-existing CI failures affecting all PRs
Prettier (TypeScript Lint & Format): - src/screens/CancellationFlowScreen.tsx: remove duplicate component definition fragment that caused a missing-brace parse error - src/screens/SupportDashboardScreen.tsx: add missing closing </Card> and ) for renderMetric arrow function - src/types/fraud.ts: remove dangling "| device-mismatch" line that was a leftover from a bad merge TypeScript Type Check (contracts:codegen:check): - Regenerate src/contracts/types/ with ethers-v5 typechain target so the committed output matches what npm run contracts:codegen produces Rust Format Check: - contracts/batch/src/batch.rs: create missing module file (declared via "mod batch;" in lib.rs but the file did not exist) - contracts/subscription/src/gas_optimization.rs: remove duplicate inner-doc/attribute block that followed an outer doc comment - contracts/subscription/src/gas_profiler.rs: same fix - contracts/subscription/src/gas_storage.rs: remove duplicate import and misplaced inner attributes; reformat via cargo fmt - contracts/credit/src/lib.rs: reformat via cargo fmt - Run cargo fmt across all contracts Merge conflict fix: - backend/services/notification/alerting.ts: resolve unresolved conflict markers that blocked TypeScript compilation
1 parent 7e88cad commit 41d6925

12 files changed

Lines changed: 261 additions & 234 deletions

File tree

backend/services/notification/alerting.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
* Channels are pluggable; add as many as needed.
44
*/
55

6-
<<<<<<< HEAD:backend/services/alerting.ts
7-
import { logger } from './logging';
8-
import type { Alert, AlertChannelConfig } from './types';
9-
=======
6+
import { logger } from '../services/logging';
107
import type { Alert, AlertChannelConfig } from '../shared/types';
11-
>>>>>>> main:backend/services/notification/alerting.ts
128

139
export interface AlertDispatcher {
1410
send(alert: Alert): Promise<void>;

contracts/batch/src/batch.rs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/// Batch module – shared types for the SubTrackr batch operations contract.
2+
use soroban_sdk::{contracttype, String, Vec};
3+
use subtrackr_types::SubscriptionId;
4+
5+
// ── Subscription status ───────────────────────────────────────────────────────
6+
7+
#[contracttype]
8+
#[derive(Clone, Debug, PartialEq, Eq)]
9+
pub enum SubStatus {
10+
Active,
11+
Paused,
12+
Cancelled,
13+
}
14+
15+
// ── Subscription record (lightweight on-chain representation) ─────────────────
16+
17+
#[contracttype]
18+
#[derive(Clone)]
19+
pub struct SubRecord {
20+
pub exists: bool,
21+
pub status: SubStatus,
22+
pub charged: i128,
23+
}
24+
25+
// ── Operation types ───────────────────────────────────────────────────────────
26+
27+
#[contracttype]
28+
#[derive(Clone, Debug, PartialEq, Eq)]
29+
pub enum OperationType {
30+
Create,
31+
Charge,
32+
Update,
33+
Cancel,
34+
Noop,
35+
}
36+
37+
// ── Cancellation reasons ──────────────────────────────────────────────────────
38+
39+
#[contracttype]
40+
#[derive(Clone, Debug, PartialEq, Eq)]
41+
pub enum CancelReason {
42+
UserRequested,
43+
PaymentFailed,
44+
Expired,
45+
Custom,
46+
}
47+
48+
// ── Batch operation input ─────────────────────────────────────────────────────
49+
50+
#[contracttype]
51+
#[derive(Clone)]
52+
pub struct BatchOperation {
53+
/// Ordered list of subscription IDs to process.
54+
pub subscription_ids: Vec<SubscriptionId>,
55+
/// Parallel i128 parameter per subscription (e.g. charge amount).
56+
pub params: Vec<i128>,
57+
/// Cancellation reasons aligned with subscription_ids for Cancel ops.
58+
pub cancel_reasons: Vec<CancelReason>,
59+
pub operation_type: OperationType,
60+
}
61+
62+
// ── Per-operation result ──────────────────────────────────────────────────────
63+
64+
#[contracttype]
65+
#[derive(Clone)]
66+
pub struct OperationResult {
67+
pub subscription_id: SubscriptionId,
68+
pub success: bool,
69+
/// Non-zero error code on failure.
70+
pub code: u32,
71+
/// Optional human-readable reason.
72+
pub reason: Option<String>,
73+
}
74+
75+
// ── Batch-wide result ─────────────────────────────────────────────────────────
76+
77+
#[contracttype]
78+
#[derive(Clone)]
79+
pub struct BatchResult {
80+
pub results: Vec<OperationResult>,
81+
pub state: BatchState,
82+
pub total_operations: u32,
83+
pub successful_operations: u32,
84+
pub failed_operations: u32,
85+
pub skipped_operations: u32,
86+
/// Whether all operations must succeed or all roll back.
87+
pub atomic: bool,
88+
/// True when an atomic batch was rolled back due to failure.
89+
pub rolled_back: bool,
90+
}
91+
92+
// ── Batch execution state ─────────────────────────────────────────────────────
93+
94+
#[contracttype]
95+
#[derive(Clone, Debug, PartialEq, Eq)]
96+
pub enum BatchState {
97+
Pending,
98+
Executing,
99+
Completed,
100+
PartiallyCompleted,
101+
Failed,
102+
RolledBack,
103+
}
104+
105+
// ── Status summary returned to callers ───────────────────────────────────────
106+
107+
#[contracttype]
108+
#[derive(Clone)]
109+
pub struct BatchStatus {
110+
pub batch_id: u64,
111+
pub state: BatchState,
112+
pub total: u32,
113+
pub succeeded: u32,
114+
pub failed: u32,
115+
}
116+
117+
// ── Optional filter for history queries ──────────────────────────────────────
118+
119+
#[contracttype]
120+
#[derive(Clone)]
121+
pub struct BatchFilter {
122+
pub operation_type: Option<OperationType>,
123+
pub state: Option<BatchState>,
124+
}

contracts/credit/src/lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use soroban_sdk::{
2424
contract, contracterror, contractimpl, contracttype, symbol_short, Address, Env, String, Vec,
2525
};
26-
use subtrackr_types::{SubscriptionId, CoreError};
26+
use subtrackr_types::{CoreError, SubscriptionId};
2727

2828
/// Maximum retained transaction-history and lot entries per account.
2929
const MAX_HISTORY: u32 = 128;
@@ -391,7 +391,9 @@ impl SubTrackrCredit {
391391
created_at: now,
392392
updated_at: now,
393393
};
394-
env.storage().persistent().set(&DataKey::Wallet(wallet_id), &wallet);
394+
env.storage()
395+
.persistent()
396+
.set(&DataKey::Wallet(wallet_id), &wallet);
395397
env.events()
396398
.publish((symbol_short!("wallet"), subscriber), wallet_id);
397399
wallet_id
@@ -420,7 +422,9 @@ impl SubTrackrCredit {
420422
wallet.balance += amount;
421423
wallet.total_deposited += amount;
422424
wallet.updated_at = now;
423-
env.storage().persistent().set(&DataKey::Wallet(wallet_id), &wallet);
425+
env.storage()
426+
.persistent()
427+
.set(&DataKey::Wallet(wallet_id), &wallet);
424428
Ok(PrepaymentSnapshot {
425429
wallet_id,
426430
balance: wallet.balance,
@@ -454,7 +458,9 @@ impl SubTrackrCredit {
454458
wallet.balance -= amount;
455459
wallet.total_withdrawn += amount;
456460
wallet.updated_at = now;
457-
env.storage().persistent().set(&DataKey::Wallet(wallet_id), &wallet);
461+
env.storage()
462+
.persistent()
463+
.set(&DataKey::Wallet(wallet_id), &wallet);
458464
Ok(PrepaymentSnapshot {
459465
wallet_id,
460466
balance: wallet.balance,
@@ -533,7 +539,11 @@ impl SubTrackrCredit {
533539
}
534540

535541
fn next_wallet_id(env: &Env) -> u64 {
536-
let base: u64 = env.storage().instance().get(&symbol_short!("NWID")).unwrap_or(0);
542+
let base: u64 = env
543+
.storage()
544+
.instance()
545+
.get(&symbol_short!("NWID"))
546+
.unwrap_or(0);
537547
env.storage()
538548
.instance()
539549
.set(&symbol_short!("NWID"), &(base + 1));

contracts/subscription/src/gas_optimization.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
/// Gas Optimization and Targeting Module
22
/// Provides optimization recommendations and tracks gas targets
3-
#![allow(dead_code)]
4-
//! Gas Optimization and Targeting Module
5-
//! Provides optimization recommendations and tracks gas targets.
6-
73
use soroban_sdk::{Env, String, Vec};
84

95
/// Optimization level

contracts/subscription/src/gas_profiler.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
/// Gas Profiling Module for SubTrackr Subscription Contract
22
/// Tracks gas consumption for each contract function and provides optimization insights
3-
use soroban_sdk::{Address, Env, String, Symbol, Vec};
4-
#![allow(dead_code)]
5-
#![allow(unused_variables)]
6-
//! Gas Profiling Module for SubTrackr Subscription Contract
7-
//! Tracks gas consumption for each contract function and provides optimization insights.
83
use soroban_sdk::{Address, Env, String, Vec};
94

105
/// Gas profile entry for a function call

contracts/subscription/src/gas_storage.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
use crate::gas_profiler::GasProfile;
22
/// Gas Storage Module
33
/// Manages storage and retrieval of gas profiling metrics
4-
use soroban_sdk::{Address, Env, IntoVal, String as SorobanString, TryFromVal, Val, Vec};
5-
#![allow(dead_code)]
6-
#![allow(unused_variables)]
7-
//! Gas Storage Module
8-
//! Manages storage and retrieval of gas profiling metrics.
9-
use soroban_sdk::{Address, Env, String as SorobanString};
10-
use crate::gas_profiler::{GasProfile};
114
125
/// Storage keys for gas metrics
136
#[derive(Clone)]
@@ -152,9 +145,7 @@ impl GasMetricsStorage {
152145
pub fn get_metrics_summary(env: &Env, storage: &Address) -> (u64, u64, u64) {
153146
let total_gas = Self::get_total_gas_used(env, storage);
154147
let total_calls = Self::get_total_call_count(env, storage);
155-
let avg_gas = total_gas
156-
.checked_div(total_calls)
157-
.unwrap_or(0);
148+
let avg_gas = total_gas.checked_div(total_calls).unwrap_or(0);
158149
(total_gas, total_calls, avg_gas)
159150
}
160151
}

0 commit comments

Comments
 (0)