Skip to content

Commit a49aa69

Browse files
Merge branch 'main' into Build-Dispute-Resolution-Escrow-for-Subscriptions
2 parents c9c7362 + 60ec1b3 commit a49aa69

5 files changed

Lines changed: 429 additions & 96 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/substream_contracts/src/lib.rs

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const MAX_BULK_SUBSCRIPTION_IMPORTS: u32 = 50;
2222
/// Domain separation for offline import intents (SEP-10–style structured payload).
2323
pub(crate) const BULK_IMPORT_INTENT_PREFIX: &[u8] = b"SubStream:batch_import:v1:";
2424

25+
2526
// --- SLA Circuit Breaker Constants ---
2627
const SLA_THRESHOLD_BPS: u32 = 9990; // 99.9% uptime threshold (in basis points)
2728
const SEVEN_DAYS: u64 = 7 * 24 * 60 * 60;
@@ -212,6 +213,37 @@ pub struct Plan {
212213
pub is_active: bool,
213214
}
214215

216+
/// Usage-based (pay-as-you-go) price components registered by the merchant for a plan.
217+
#[contracttype]
218+
#[derive(Clone, Debug, Eq, PartialEq)]
219+
pub struct DynamicPlan {
220+
pub base_fee: i128,
221+
pub per_unit_rate: i128,
222+
}
223+
224+
/// Snapshot of dynamic pricing and the subscriber-approved per-pull cap.
225+
#[contracttype]
226+
#[derive(Clone, Debug, Eq, PartialEq)]
227+
pub struct DynamicBillingInfo {
228+
pub base_fee: i128,
229+
pub per_unit_rate: i128,
230+
pub maximum_billing_cap: i128,
231+
pub plan_id: u32,
232+
}
233+
234+
/// Signed payload: `units_consumed` and `usage_timestamp` are covered by `signature`
235+
/// over [`dynamic_usage_attestation_message`].
236+
#[contracttype]
237+
#[derive(Clone, Debug, Eq, PartialEq)]
238+
pub struct DynamicUsageOraclePayload {
239+
pub subscriber: Address,
240+
pub merchant: Address,
241+
pub units_consumed: i128,
242+
pub usage_timestamp: u64,
243+
pub nonce: u64,
244+
pub signature: BytesN<64>,
245+
}
246+
215247
#[contracttype]
216248
#[derive(Clone, Debug, Eq, PartialEq)]
217249
pub enum SubscriptionStatus {
@@ -1234,15 +1266,8 @@ impl SubStreamContract {
12341266
.unwrap_or(0)
12351267
}
12361268

1237-
// -----------------------------------------------------------------------
1238-
// DAO Treasury Streaming — Grant Support
12391269
// -----------------------------------------------------------------------
12401270

1241-
/// Called by a DAO contract to initiate a streaming grant to a creator.
1242-
/// The DAO is the payer; the creator receives tokens second-by-second.
1243-
/// Respects the same 7-day free-trial window and minimum-flow-duration
1244-
/// rules as regular subscriptions so the protocol remains consistent.
1245-
pub fn dao_grant(
12461271
env: Env,
12471272
subscriber: Address,
12481273
merchant: Address,
@@ -1343,6 +1368,7 @@ impl SubStreamContract {
13431368
}
13441369
}
13451370

1371+
13461372
// --- Timelock and Multi-Sig Governance Functions ---
13471373

13481374
/// Propose a registry update with mandatory 48-hour timelock
@@ -1356,15 +1382,13 @@ impl SubStreamContract {
13561382
emergency_bypass: bool,
13571383
) -> u64 {
13581384
proposer.require_auth();
1385+
13591386

13601387
// Verify proposer is authorized (Security Council member or admin)
13611388
if !is_authorized_proposer(&env, &proposer) {
13621389
panic!("unauthorized proposer");
13631390
}
1364-
1365-
// Emergency bypass requires additional authorization
1366-
if emergency_bypass && !is_emergency_authorized(&env, &proposer) {
1367-
panic!("unauthorized emergency bypass");
1391+
13681392
}
13691393

13701394
// Generate unique proposal ID
@@ -2800,10 +2824,7 @@ pub fn is_reentrancy_guard_active(env: &Env) -> bool {
28002824
#[cfg(test)]
28012825
mod test;
28022826
#[cfg(test)]
2803-
mod test_cliff_access;
2804-
#[cfg(test)]
2805-
mod test_dao_treasury;
2806-
#[cfg(test)]
2827+
28072828
mod test_enhanced_subscriptions;
28082829
#[cfg(test)]
28092830
mod test_merchant_registry;

contracts/substream_contracts/src/test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
use super::*;
44
use soroban_sdk::{
5-
testutils::{Address as _, Ledger},
6-
testutils::Events as _,
7-
testutils::{Address as _, Ledger},
5+
86
token, vec, Address, Env,
97
};
108

0 commit comments

Comments
 (0)