refactor: Update public key column type from String
to PublicKey
#29
No reviewers
Labels
No labels
Good First Issue
Help wanted
Kind/Breaking
Kind/Bug
Kind/Bug Fix
Kind/CI-CD
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Question
Kind/Security
Kind/Testing
Reviewed
Accepted
Reviewed
Confirmed
Reviewed
Declined
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Approved
Status
Blocked
Status
Inactive
Status
Need More Info
Status
Waiting On Author
Status
Waiting On Review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: OxideTalis/oxidetalis#29
Loading…
Reference in a new issue
No description provided.
Delete branch "awiteb/refactor-entities-public-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pull request refactors the public_key column type in the relevant database entities, changing it from String to PublicKey.
refactor: Update public key column type from toto refactor: Update public key column type fromString
toPublicKey
bb76ec8d8d
to0cd317435f
0cd317435f
to79ef0d2448
Sorry, just rebasing the master, to be clean
@ -0,0 +38,4 @@
impl From<PublicKey> for Value {
fn from(public_key: PublicKey) -> Self {
Self::String(Some(Box::new(public_key.to_string())))
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 efficientYes I think so, it is actually a good idea.
@ -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| {
replace
map
byand_then
and you won't needand_then(|res| res)
@ -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))
same as above,
and_then
instead ofmap
@ -22,6 +22,7 @@
//! Entity for `in_chat_requests` table
use chrono::Utc;
use oxidetalis_core::types::PublicKey as CorePublicKey;
Why is it here
CorePublicKey
? while inoxidetails
crate is justPublicKey
, I think it might be confusing as we would think its 2 types.Because
oxidetalis
only work with onePublicKey
from the core, whilethe core work with two
PublicKey
, the first one fromk256
crate andthe second one it its own.
Ah right, didn't notice that
You're right, I was mean if we use it in the core not entities.
I didn't realize that was in entities.
and_then
instead ofmap
35a7354de1PublicKey
as it is