Skip to content

Commit cc4dcb1

Browse files
author
Sergey Kudryashov
committed
PR fix
1 parent 57f2282 commit cc4dcb1

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

core/src/credential.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use serde_json::Value;
77
type VCContext = [String];
88

99
pub(crate) const JSON_LD_CONTEXT: VCContext = ["https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1"];
10-
pub(crate) const CRED_TYPE_PASSPORT: str = "Passport";
11-
pub(crate) const CRED_TYPE_DRIVER_LICENSE: str = "DriverLicense";
10+
pub(crate) const CRED_TYPE_PERMANENT_RESIDENT_CARD: str = "PermanentResidentCard";
11+
pub(crate) const CRED_TYPE_BANK_CARD: str = "BankCard";
1212

1313
type CredentialSubject = serde_json::Value;
1414

1515
enum CredType {
16-
Passport(String),
17-
DriverLicense(String)
16+
PermanentResidentCard(String),
17+
BankCard(String)
1818
}
1919

2020
pub trait VCCredential {
@@ -28,7 +28,7 @@ impl VCCredential for VerifiableCredential<'_> {
2828
self.cred_type = ""
2929
}
3030
fn getSubject (&self) -> String {
31-
self.cred_type = ""
31+
self.subject = ""
3232
}
3333
fn getContext (&self) ->[String] {
3434
return crate::credential::JSON_LD_CONTEXT
@@ -51,18 +51,18 @@ pub struct VerifiableCredential <'a> {
5151
impl <'a> VerifiableCredential <'a> {
5252
pub fn init(cred_type: String, cred_subject: serde_json::Value, issuer: &'a str, id: &'a str) -> Self {
5353
let ctype = match cred_type {
54-
CRED_TYPE_PASSPORT => {
55-
Some(CredType::Passport(cred_type))
54+
CRED_TYPE_PERMANENT_RESIDENT_CARD => {
55+
Some(CredType::PermanentResidentCard(cred_type))
5656
},
57-
CRED_TYPE_DRIVER_LICENSE => {
58-
Some(CredType::DriverLicense(cred_type))
57+
CRED_TYPE_BANK_CARD => {
58+
Some(CredType::BankCard(cred_type))
5959
},
6060
_ => {
6161
None
6262
}
6363
};
6464
let s = Self {
65-
context: JSON_LD_CONTEXT,
65+
context: [],
6666
id: String::from(id),
6767
cred_type: ctype,
6868
issuer: String::from(issuer),
@@ -77,9 +77,7 @@ impl <'a> VerifiableCredential <'a> {
7777
proof_value:String::default(),
7878
},
7979
};
80-
s.cred_type = s.getCredType();
8180
s.context = s.getContext();
82-
s.subject = s.getSubject();
8381

8482
return s;
8583
}

0 commit comments

Comments
 (0)