sablier_webhook_program/instructions/
webhook_respond.rs1use crate::constants::{SEED_WEBHOOK, TIMEOUT_THRESHOLD};
2
3use {
4 crate::state::Webhook,
5 anchor_lang::{prelude::*, system_program},
6};
7
8#[derive(Accounts)]
9#[instruction()]
10pub struct WebhookRespond<'info> {
11 #[account(mut)]
12 pub ack_authority: Signer<'info>,
13
14 #[account(
15 mut,
16 seeds = [
17 SEED_WEBHOOK,
18 webhook.authority.as_ref(),
19 ],
20 bump,
21 )]
24 pub webhook: Account<'info, Webhook>,
25
26 #[account(address = system_program::ID)]
27 pub system_program: Program<'info, System>,
28
29 #[account()]
30 pub worker: SystemAccount<'info>,
31}
32
33pub fn handler(ctx: Context<WebhookRespond>) -> Result<()> {
34 let webhook = &mut ctx.accounts.webhook;
37 let worker = &mut ctx.accounts.worker;
38
39 let current_slot = Clock::get().unwrap().slot;
41 let _is_authorized_worker = webhook.workers.contains(&worker.key());
42 let _is_within_execution_window = current_slot < webhook.created_at + TIMEOUT_THRESHOLD;
43 Ok(())
54}