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
3 changes: 0 additions & 3 deletions contracts/batch-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub const MAX_BATCH_SIZE: u32 = 30;
/// Maximum batch limit alias for MAX_BATCH_SIZE (Issue #677).
pub const MAX_BATCH_LIMIT: u32 = MAX_BATCH_SIZE;


/// Behaviour version of this deployment.
///
/// Bump this whenever `process_batch` (or any other entry point) changes
Expand Down Expand Up @@ -88,7 +87,6 @@ pub enum Error {
ReentrancyForbidden = 10,
}


/// Individual execution status for an item in a batch execution (Issue #697).
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -324,7 +322,6 @@ impl BatchTransferProcessor {
///
/// # Returns
/// The total number of tokens transferred on success.

/// Executes a batch transfer and returns per-item execution status codes (Issue #697).
pub fn process_batch_detailed(
env: Env,
Expand Down
1 change: 0 additions & 1 deletion contracts/batch-processor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,4 +621,3 @@ fn test_max_batch_size_limit_is_thirty() {
assert_eq!(crate::MAX_BATCH_LIMIT, 30);
assert_eq!(crate::MAX_BATCH_SIZE, 30);
}

6 changes: 0 additions & 6 deletions contracts/factory/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ pub fn deploy_stream(
stream_id: u64,
init_args: Vec<Val>,
) -> Result<Address, Error> {
// Validate WASM hash registry prior to instantiation (Issue #788).
// Verify that the WASM hash is registered and available before attempting deployment.
// This prevents deploying with a stale or invalid hash that would fail mid-transaction.
let _ = env.ledger().get_wasm(wasm_hash)
.map_err(|_| Error::InvalidWasmHash)?;

// Derive a deterministic salt from the stream ID so each stream gets a
// unique, reproducible contract address.
let salt = compute_salt(env, stream_id);
Expand Down
2 changes: 2 additions & 0 deletions contracts/factory/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,6 @@ pub enum Error {
SaltAlreadyUsed = 32,
/// `cancel_batch_streams` was called with duplicate stream addresses (Issue #787).
DuplicateStreamId = 33,
/// The optional stream description exceeds 128 bytes (#845).
DescriptionTooLong = 34,
}
45 changes: 30 additions & 15 deletions contracts/factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ pub mod ttl;

// Import `token` as `tok` to avoid shadowing by any `token: Address` parameter.
use soroban_sdk::{
contract, contractimpl, panic_with_error, token as tok, Address, BytesN, Env, IntoVal, Map,
Vec,
contract, contractimpl, panic_with_error, token as tok, Address, BytesN, Env, IntoVal, Map, Vec,
};

use drip_common::is_zero_address;

pub use errors::Error;
use storage::DataKey;
pub use storage::{
Aggregate, BatchStreamRequest, FactoryStatus, FeeEstimate, StreamInitParams, StreamOperation, StreamPage,
Aggregate, BatchStreamRequest, FactoryStatus, FeeEstimate, StreamInitParams, StreamOperation,
StreamPage,
};

/// Maximum number of streams accepted by a single `create_batch_streams`
Expand Down Expand Up @@ -105,6 +105,7 @@ impl DripFactory {
start_time: u64,
end_time: u64,
clawback: bool,
description: Option<soroban_sdk::String>,
) -> Result<u64, Error> {
// ── Auth ─────────────────────────────────────────────────────────
sender.require_auth();
Expand All @@ -128,6 +129,12 @@ impl DripFactory {
end_time,
)?;

if let Some(ref desc) = description {
if desc.len() > drip_stream::MAX_DESCRIPTION_LEN {
return Err(Error::DescriptionTooLong);
}
}

// ── Governor-controlled bounds ──────────────────────────────────────
let governor: Address = env
.storage()
Expand All @@ -148,6 +155,7 @@ impl DripFactory {
start_time,
end_time,
clawback,
description,
)
}

Expand Down Expand Up @@ -179,6 +187,9 @@ impl DripFactory {
if end_time > 0 && end_time <= start_time {
return Err(Error::InvalidDuration);
}
if end_time > 0 && end_time - start_time < drip_stream::MIN_STREAM_DURATION {
return Err(Error::DurationTooShort);
}
if deposit <= 0 {
return Err(Error::InvalidDeposit);
}
Expand Down Expand Up @@ -223,6 +234,7 @@ impl DripFactory {
start_time: u64,
end_time: u64,
clawback: bool,
description: Option<soroban_sdk::String>,
) -> Result<u64, Error> {
// ── Governor-controlled bounds ──────────────────────────────────────
governance::enforce_bounds(config, rate_per_sec, start_time, end_time, now)?;
Expand Down Expand Up @@ -318,6 +330,8 @@ impl DripFactory {
end_time.into_val(&env),
clawback.into_val(&env),
config.force_cancel_pause_secs.into_val(&env),
false.into_val(&env), // is_regulated_asset
description.into_val(&env),
];

let stream_addr = match deploy::deploy_stream(&env, &wasm_hash, stream_id, init_args) {
Expand Down Expand Up @@ -468,6 +482,7 @@ impl DripFactory {
cfg.start_time,
cfg.end_time,
cfg.clawback,
None,
)?;
let addr: Address = env
.storage()
Expand Down Expand Up @@ -536,6 +551,7 @@ impl DripFactory {
request.start_time,
request.end_time,
clawback,
None,
)?;
stream_ids.push_back(stream_id);
}
Expand Down Expand Up @@ -732,14 +748,14 @@ impl DripFactory {
ttl::EXTEND_TO,
);

let mut aggregate: Aggregate = env
.storage()
.instance()
.get(&DataKey::Aggregate)
.unwrap_or(Aggregate {
total_supply: 0,
active_streams: 0,
});
let mut aggregate: Aggregate =
env.storage()
.instance()
.get(&DataKey::Aggregate)
.unwrap_or(Aggregate {
total_supply: 0,
active_streams: 0,
});
aggregate.active_streams = aggregate.active_streams.saturating_sub(1);
env.storage()
.instance()
Expand Down Expand Up @@ -800,7 +816,6 @@ impl DripFactory {
Self::get_streams_by_creator(env, creator)
}


/// Paginated list of stream IDs where `recipient` is the beneficiary,
/// paired with the recipient's total stream count.
///
Expand Down Expand Up @@ -854,7 +869,7 @@ impl DripFactory {
}

/// Read-only: returns the number of streams deployed using a specific token (Issue #720).
pub fn get_deployed_streams_count_by_token(env: Env, token: Address) -> u64 {
pub fn deployed_stream_count_by_token(env: Env, token: Address) -> u64 {
let key = DataKey::TokenStreamCount(token);
let count: u64 = env.storage().persistent().get(&key).unwrap_or(0);
if count > 0 {
Expand All @@ -865,9 +880,9 @@ impl DripFactory {
count
}

/// Read-only: alias for get_deployed_streams_count_by_token (Issue #720).
/// Read-only: alias for deployed_stream_count_by_token (Issue #720).
pub fn stream_count_by_token(env: Env, token: Address) -> u64 {
Self::get_deployed_streams_count_by_token(env, token)
Self::deployed_stream_count_by_token(env, token)
}

/// Read-only: current protocol fee in basis points.
Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/src/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn is_paused(env: &Env) -> bool {
/// responsible for verifying caller authorization, checking current pause
/// state transitions, updating TTL, and emitting public events.
pub fn set_paused(env: &Env, paused: bool) {
drip_common::pause::set_paused(env, &DataKey::Paused, paused);
let _ = drip_common::pause::set_paused(env, &DataKey::Paused, paused);
}

/// The pause gate: `Err(ContractPaused)` while the factory is halted.
Expand Down
2 changes: 1 addition & 1 deletion contracts/factory/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn paginate(env: &Env, v: Vec<u64>, offset: u32, limit: u32) -> Vec<u64> {
}

/// Returns a paginated slice of `Address` vector starting at `offset` with at most `limit` elements.
#[allow(dead_code)]
pub fn paginate_addresses(env: &Env, v: Vec<Address>, offset: u32, limit: u32) -> Vec<Address> {
let mut result = Vec::new(env);
let start = offset as usize;
Expand All @@ -44,4 +45,3 @@ pub fn paginate_addresses(env: &Env, v: Vec<Address>, offset: u32, limit: u32) -
}
result
}

Loading
Loading