Skip to content
Open
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
5 changes: 2 additions & 3 deletions contract/contracts/hello-world/src/autoshare_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ pub fn add_group_member(
});

// Validate total percentage after adding
validate_members(&details.members)?;
validate_members(&env, &details.members)?;

// Save updated details
env.storage().persistent().set(&key, &details);
Expand Down Expand Up @@ -901,15 +901,14 @@ pub fn withdraw(
Ok(())
}

fn validate_members(members: &Vec<GroupMember>) -> Result<(), Error> {
fn validate_members(env: &Env, members: &Vec<GroupMember>) -> Result<(), Error> {
if members.is_empty() {
return Err(Error::EmptyMembers);
}
// Validate member count limit
if members.len() > MAX_MEMBERS {
return Err(Error::TooManyMembers);
}
let env = members.env();
let mut total_percentage: u32 = 0;
let mut seen_addresses = Vec::new(env);

Expand Down
24 changes: 13 additions & 11 deletions listener/src/api/events-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export interface EventsServerOptions {
port: number;
corsOrigin?: string;
stellarRpcUrl: string;
stellarNetworkPassphrase: string;
contractAddresses: ContractConfig[];
stellarNetworkPassphrase?: string;
contractAddresses?: ContractConfig[];
discordWebhookUrl?: string;
webhookSecrets?: WebhookSecret[];
notificationAPI?: NotificationAPI | null;
Expand Down Expand Up @@ -214,15 +214,17 @@ async function buildStatusResponse(options: EventsServerOptions): Promise<{
}>;
timestamp: string;
}> {
const contractStatuses = await Promise.all(
options.contractAddresses.map(async (contractConfig) => {
const status = await getContractPauseStatus(contractConfig.address, options.stellarRpcUrl);
return {
address: contractConfig.address,
...status
};
})
);
const contractStatuses = options.contractAddresses
? await Promise.all(
options.contractAddresses.map(async (contractConfig) => {
const status = await getContractPauseStatus(contractConfig.address, options.stellarRpcUrl);
return {
address: contractConfig.address,
...status
};
})
)
: [];

return {
timestamp: new Date().toISOString(),
Expand Down
1 change: 1 addition & 0 deletions listener/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Config, ContractConfig, DiscordConfig, WebhookSecret, AppCleanupConfig, EventQueueConfig, RetrySchedulerOptions } from './types';
import { Config, ContractConfig, DiscordConfig, WebhookSecret, AppCleanupConfig, EventQueueConfig, RetrySchedulerOptions, AnalyticsConfig } from './types';

export class ConfigError extends Error {
Expand Down
3 changes: 3 additions & 0 deletions listener/src/database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ CREATE INDEX IF NOT EXISTS idx_scheduled_notifications_lock_expires
ON scheduled_notifications(lock_expires_at, status)
WHERE status = 'PROCESSING';

-- Migration: add next_retry_at for explicit retry scheduling
ALTER TABLE scheduled_notifications ADD COLUMN next_retry_at DATETIME;

CREATE INDEX IF NOT EXISTS idx_scheduled_notifications_next_retry_at
ON scheduled_notifications(next_retry_at, status)
WHERE status = 'PENDING';
Expand Down
Loading