Skip to content

Commit

Permalink
Merge pull request #142 from nervina-labs/add-frontend
Browse files Browse the repository at this point in the history
Add front_end joyid infos
  • Loading branch information
duanyytop authored Jan 9, 2023
2 parents 5601507 + be37cbb commit 54fa572
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cota-aggregator"
version = "0.9.0"
version = "0.9.1"
edition = "2018"

[dependencies]
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,8 @@ echo '{
"jsonrpc":"2.0",
"method":"get_joyid_info",
"params":{
"lock_script":"0x4a000000100000003000000031000000726c205927bf90b3c1c8def979333e5a04f8f82e158e2a35dee85a6750d38cf1011500000001ae75e66699b47d6c178d5d282aee95f33c09057e",
"address": "ckt1q3excgzey7lepv7per00j7fn8edqf78c9c2cu234mm595e6s6wx0zqdwwhnxdxd504kp0r2a9q4wa90n8sys2lse0p2jy"
"lock_script":"0x4b000000100000003000000031000000d23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac011600000000012bddb76a4d23141063cc59c6560b2117e1fff38c",
"address": "ckt1qrfrwcdnvssswdwpn3s9v8fp87emat306ctjwsm3nmlkjg8qyza2cqgqqy4amdm2f533gyrre3vuv4styyt7rlln3sxvqp4s"
}
}' \
| tr -d '\n' \
Expand All @@ -1122,7 +1122,6 @@ avatar - The joyid metadata avatar
name - The joyid metadata name
description - The joyid metadata description
extension - The joyid metadata extension
joyid - The joyid metadata joyid
pub_key - The joyid metadata public key
credential_id - The joyid metadata WebAuthn credential_id
alg - The joyid metadata WebAuthn algorithm
Expand All @@ -1138,24 +1137,27 @@ sub_keys - The joyid metadata sub public keys
"result":{
"alg":"01",
"avatar":"https://i.loli.net/2021/04/29/IigbpOWP8fw9qDn.png",
"block_number":6836259,
"block_number":7948294,
"cota_cell_id":"0000000000000b6b",
"credential_id":"459d12c09a65e58e22a9d8d6fa843c3d",
"description":"Web3 Developer",
"extension":"",
"front_end":"https:://app.joy.id",
"name":"Dylan",
"pub_key":"650e48cf029c8a04788c02d7d88bad7b62918714137d0cd486b5b3aff53d0c2baecabd8d23107933f85fdf13cd814a0ba3d1848329b0504d7134a88962e9bde3",
"sub_keys":[
{
"alg":"01",
"credential_id":"459d12c09a65e58e22a9d8d6fa843c3d",
"front_end":"",
"pub_key":"650e48cf029c8a04788c02d7d88bad7b62918714137d0cd486b5b3aff53d0c2baecabd8d23107933f85fdf13cd814a0ba3d1848329b0504d7134a88962e9bde3"
},
{
"alg":"01",
"credential_id":"369d12c09a65e58e22a9d8d6fa843c3d",
"front_end":"",
"pub_key":"290e48cf029c8a04788c02d7d88bad7b62918714137d0cd486b5b3aff53d0c2baecabd8d23107933f85fdf13cd814a0ba3d1848329b0504d7134a88962e9bde3"
}
},
]
},
"id":2
Expand Down
2 changes: 2 additions & 0 deletions migrations/2022-09-27-152430_joyid_meta_extension/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS joy_id_infos (
credential_id varchar(1500) NOT NULL,
alg char(2) NOT NULL,
cota_cell_id char(16) NOT NULL,
front_end varchar(255) NOT NULL,
created_at datetime(6) NOT NULL,
updated_at datetime(6) NOT NULL,
PRIMARY KEY (id),
Expand All @@ -26,6 +27,7 @@ CREATE TABLE IF NOT EXISTS sub_key_infos (
pub_key char(128) NOT NULL,
credential_id varchar(1500) NOT NULL,
alg char(2) NOT NULL,
front_end varchar(255) NOT NULL,
created_at datetime(6) NOT NULL,
updated_at datetime(6) NOT NULL,
PRIMARY KEY (id),
Expand Down
14 changes: 10 additions & 4 deletions src/models/joyid.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::schema::joy_id_infos::dsl::joy_id_infos;
use crate::schema::joy_id_infos::{
alg, avatar, cota_cell_id, credential_id, description, extension, lock_hash, name, pub_key,
alg, avatar, cota_cell_id, credential_id, description, extension, front_end, lock_hash, name,
pub_key,
};
use crate::schema::sub_key_infos::dsl::sub_key_infos;
use crate::schema::sub_key_infos::{
alg as sub_alg, credential_id as sub_credential_id, lock_hash as sub_lock_hash,
pub_key as sub_pub_key,
alg as sub_alg, credential_id as sub_credential_id, front_end as sub_front_end,
lock_hash as sub_lock_hash, pub_key as sub_pub_key,
};
use crate::utils::error::Error;
use diesel::*;
Expand All @@ -24,6 +25,7 @@ pub struct JoyIDInfo {
pub credential_id: String,
pub alg: String,
pub cota_cell_id: String,
pub front_end: String,
pub sub_keys: Vec<SubKeyDb>,
}

Expand All @@ -37,13 +39,15 @@ pub struct JoyIDInfoDb {
pub credential_id: String,
pub alg: String,
pub cota_cell_id: String,
pub front_end: String,
}

#[derive(Serialize, Deserialize, Queryable, Debug, Clone, Eq, PartialEq)]
pub struct SubKeyDb {
pub pub_key: String,
pub credential_id: String,
pub alg: String,
pub front_end: String,
}

pub fn get_joyid_info_by_lock_hash(lock_hash_: [u8; 32]) -> Result<Option<JoyIDInfo>, Error> {
Expand All @@ -59,6 +63,7 @@ pub fn get_joyid_info_by_lock_hash(lock_hash_: [u8; 32]) -> Result<Option<JoyIDI
credential_id,
alg,
cota_cell_id,
front_end,
))
.filter(lock_hash.eq(lock_hash_hex.clone()))
.limit(1)
Expand All @@ -71,7 +76,7 @@ pub fn get_joyid_info_by_lock_hash(lock_hash_: [u8; 32]) -> Result<Option<JoyIDI
Ok,
)?;
let sub_keys: Vec<SubKeyDb> = sub_key_infos
.select((sub_pub_key, sub_credential_id, sub_alg))
.select((sub_pub_key, sub_credential_id, sub_alg, sub_front_end))
.filter(sub_lock_hash.eq(lock_hash_hex))
.load::<SubKeyDb>(conn)
.map_or_else(
Expand All @@ -90,6 +95,7 @@ pub fn get_joyid_info_by_lock_hash(lock_hash_: [u8; 32]) -> Result<Option<JoyIDI
credential_id: info.credential_id,
alg: info.alg,
cota_cell_id: info.cota_cell_id,
front_end: info.front_end,
sub_keys,
});
Ok(joyid_info)
Expand Down
1 change: 1 addition & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ diesel::table! {
pub_key -> Char,
credential_id -> Varchar,
alg -> Char,
front_end -> Varchar,
created_at -> Datetime,
updated_at -> Datetime,
}
Expand Down

0 comments on commit 54fa572

Please sign in to comment.