refactor: Update public key column type from String to PublicKey #29

Manually merged
awiteb merged 6 commits from awiteb/refactor-entities-public-key into master 2024-07-24 00:20:10 +02:00 AGit
Owner

This pull request refactors the public_key column type in the relevant database entities, changing it from String to PublicKey.

This pull request refactors the public_key column type in the relevant database entities, changing it from String to PublicKey.
awiteb changed title from refactor: Update public key column type from to to refactor: Update public key column type from `String` to `PublicKey` 2024-07-22 21:51:19 +02:00
awiteb added the
Kind/Enhancement
Status
Waiting On Author
labels 2024-07-22 21:51:53 +02:00
awiteb force-pushed awiteb/refactor-entities-public-key from bb76ec8d8d to 0cd317435f 2024-07-23 00:47:38 +02:00 Compare
awiteb requested review from Amjad50 2024-07-23 01:45:46 +02:00
awiteb added
Status
Waiting On Review
and removed
Status
Waiting On Author
labels 2024-07-23 01:46:00 +02:00
awiteb force-pushed awiteb/refactor-entities-public-key from 0cd317435f to 79ef0d2448 2024-07-23 01:56:14 +02:00 Compare
Author
Owner

Sorry, just rebasing the master, to be clean

Sorry, just rebasing the master, to be clean
Amjad50 requested changes 2024-07-23 05:07:38 +02:00
Dismissed
@ -0,0 +38,4 @@
impl From<PublicKey> for Value {
fn from(public_key: PublicKey) -> Self {
Self::String(Some(Box::new(public_key.to_string())))
Member

Wouldn't it be better to use Bytes type? easier to convert as its just copying bytes and making sure its the length expected and maybe more efficient

Wouldn't it be better to use `Bytes` type? easier to convert as its just copying bytes and making sure its the length expected and maybe more efficient
Author
Owner

Wouldn't it be better to use Bytes type?

Yes I think so, it is actually a good idea.

> Wouldn't it be better to use Bytes type? Yes I think so, it is actually a good idea.
awiteb marked this conversation as resolved
@ -0,0 +45,4 @@
impl TryGetable for PublicKey {
fn try_get_by<I: sea_orm::ColIdx>(res: &QueryResult, idx: I) -> Result<Self, TryGetError> {
<String as TryGetable>::try_get_by(res, idx)
.map(|v| {
Member

replace map by and_then and you won't need and_then(|res| res)

<String as TryGetable>::try_get_by(res, idx).and_then(|v| {
    PublicKey::from_str(&v).map_err(|err| TryGetError::DbErr(DbErr::Type(err.to_string())))
})
replace `map` by `and_then` and you won't need `and_then(|res| res)` ```rust <String as TryGetable>::try_get_by(res, idx).and_then(|v| { PublicKey::from_str(&v).map_err(|err| TryGetError::DbErr(DbErr::Type(err.to_string()))) }) ```
awiteb marked this conversation as resolved
@ -0,0 +56,4 @@
impl ValueType for PublicKey {
fn try_from(v: Value) -> Result<Self, ValueTypeErr> {
<String as ValueType>::try_from(v)
.map(|v| PublicKey::from_str(&v).map_err(|_| ValueTypeErr))
Member

same as above, and_then instead of map

same as above, `and_then` instead of `map`
awiteb marked this conversation as resolved
@ -22,6 +22,7 @@
//! Entity for `in_chat_requests` table
use chrono::Utc;
use oxidetalis_core::types::PublicKey as CorePublicKey;
Member

Why is it here CorePublicKey? while in oxidetails crate is just PublicKey, I think it might be confusing as we would think its 2 types.

Why is it here `CorePublicKey`? while in `oxidetails` crate is just `PublicKey`, I think it might be confusing as we would think its 2 types.
Author
Owner

while in oxidetails crate is just PublicKey

Because oxidetalis only work with one PublicKey from the core, while
the core work with two PublicKey, the first one from k256 crate and
the second one it its own.

> while in `oxidetails` crate is just `PublicKey` Because `oxidetalis` only work with one `PublicKey` from the core, while the core work with two `PublicKey`, the first one from `k256` crate and the second one it its own.
Member

Ah right, didn't notice that

Ah right, didn't notice that
Author
Owner

Amjad50: Why is it here CorePublicKey? while in oxidetails crate is just PublicKey

You're right, I was mean if we use it in the core not entities.

awiteb: while the core work with two PublicKey

I didn't realize that was in entities.

> Amjad50: Why is it here CorePublicKey? while in oxidetails crate is just PublicKey You're right, I was mean if we use it in the core not entities. > awiteb: while the core work with two PublicKey I didn't realize that was in entities.
Amjad50 marked this conversation as resolved
awiteb added
Status
Waiting On Author
and removed
Status
Waiting On Review
labels 2024-07-23 08:35:24 +02:00
awiteb added 3 commits 2024-07-23 18:40:06 +02:00
Signed-off-by: Awiteb <a@4rs.nl>
Signed-off-by: Awiteb <a@4rs.nl>
chore: Use PublicKey as it is
All checks were successful
DCO checker / DCO checker (pull_request) Successful in 15s
Rust CI / Rust CI (pull_request) Successful in 5m22s
eb52c0a030
Signed-off-by: Awiteb <a@4rs.nl>
awiteb requested review from Amjad50 2024-07-23 18:40:15 +02:00
awiteb added
Status
Waiting On Review
and removed
Status
Waiting On Author
labels 2024-07-23 18:40:40 +02:00
Amjad50 approved these changes 2024-07-23 23:50:37 +02:00
awiteb manually merged commit 1d1bb962bb into master 2024-07-24 00:20:10 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: OxideTalis/oxidetalis#29
No description provided.