Skip to content

Commit

Permalink
Added verified column to quotes table
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrug committed Nov 21, 2024
1 parent e9026a4 commit 6671767
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions crates/database/src/quotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct Quote {
pub quote_kind: QuoteKind,
pub solver: Address,
pub call_data: Option<Vec<u8>>,
pub verified: bool,
}

/// Stores the quote and returns the id. The id of the quote parameter is not
Expand All @@ -53,9 +54,10 @@ INSERT INTO quotes (
expiration_timestamp,
quote_kind,
solver,
call_data
call_data,
verified
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
RETURNING id
"#;
let (id,) = sqlx::query_as(QUERY)
Expand All @@ -71,6 +73,7 @@ RETURNING id
.bind(&quote.quote_kind)
.bind(quote.solver)
.bind(&quote.call_data)
.bind(quote.verified)
.fetch_one(ex)
.await?;
Ok(id)
Expand Down Expand Up @@ -185,6 +188,7 @@ mod tests {
quote_kind: QuoteKind::Standard,
solver: ByteArray([1; 20]),
call_data: None,
verified: false,
};
let id = save(&mut db, &quote).await.unwrap();
quote.id = id;
Expand Down Expand Up @@ -219,6 +223,7 @@ mod tests {
quote_kind: QuoteKind::Standard,
solver: ByteArray([1; 20]),
call_data: None,
verified: false,
};

let token_b = ByteArray([2; 20]);
Expand All @@ -236,6 +241,7 @@ mod tests {
quote_kind: QuoteKind::Standard,
solver: ByteArray([2; 20]),
call_data: None,
verified: false,
};

// Save two measurements for token_a
Expand Down Expand Up @@ -408,6 +414,7 @@ mod tests {
quote_kind: QuoteKind::Eip1271OnchainOrder,
solver: ByteArray([1; 20]),
call_data: None,
verified: false,
};
let id = save(&mut db, &quote).await.unwrap();
quote.id = id;
Expand Down
1 change: 1 addition & 0 deletions crates/shared/src/event_storing_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub fn create_quote_row(data: QuoteData) -> DbQuote {
quote_kind: data.quote_kind,
solver: ByteArray(data.solver.0),
call_data: data.call_data,
verified: data.verified,
}
}

Expand Down
1 change: 1 addition & 0 deletions database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ Stores quotes in order to determine whether it makes sense to allow a user to cr
quote\_kind | [enum](#quotekind) | not null | quotekind for which this quote is considered valid
solver | bytea | not null | public address of the solver that provided this quote
call\_data | bytea | | call\_data provided by solver in response to the /quote request
verified | boolean | | information if quote was verified

Indexes:
- PRIMARY KEY: btree(`id`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Step 1: Add a new column to the quotes table
ALTER TABLE quotes
ADD COLUMN call_data bytea;
ADD COLUMN call_data bytea,
ADD COLUMN verified boolean;

-- Step 2: Add two new columns to the order_quotes table
ALTER TABLE order_quotes
Expand Down

0 comments on commit 6671767

Please sign in to comment.