Skip to content

Commit

Permalink
add feed validations (#7)
Browse files Browse the repository at this point in the history
* add fee validations

* fix declare_id!
  • Loading branch information
jdaviderb authored Aug 6, 2022
1 parent b941666 commit 1a0c107
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions programs/oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod oracle {

pub fn create_oracle(ctx: Context<CreateOracle>, _oracle_id: i64) -> Result<()> {
let timestamp = Clock::get()?.unix_timestamp;

ctx.accounts.oracle_item.authority = ctx.accounts.oracle_authorizer.key();
ctx.accounts.oracle_item.chainlink_feed = ctx.accounts.feed_account.key();
ctx.accounts.oracle_item.started_at = timestamp;
Expand Down Expand Up @@ -127,7 +128,8 @@ pub struct CreateOracle<'info> {
space = 8 + 32 + 32 + 8 + 8 + 8 + 1 + 16 + 1,
seeds = [user.key().as_ref(), format!("id-{}", oracle_id).as_bytes().as_ref()],
bump,
constraint = oracle_authorizer.authority == *user.key
constraint = oracle_authorizer.authority == *user.key,
constraint = chainlink_program.key() == *feed_account.to_account_info().owner
)]
oracle_item: Account<'info, OracleItem>,
#[account(mut)]
Expand All @@ -144,7 +146,8 @@ pub struct CreateOracle<'info> {
pub struct UpdateOracle<'info> {
#[account(
mut,
constraint = oracle_item.authority == *oracle_authorizer.to_account_info().key
constraint = oracle_item.authority == *oracle_authorizer.to_account_info().key,
constraint = chainlink_program.key() == *feed_account.to_account_info().owner
)]
oracle_item: Account<'info, OracleItem>,
#[account(mut)]
Expand Down

0 comments on commit 1a0c107

Please sign in to comment.