Skip to content

Commit

Permalink
fix the issue of not auto-fill the content of service endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
heropan committed Feb 24, 2020
1 parent ace975a commit 0f40a5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions SDK/Plugin/Transaction/Payload/DIDInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ namespace Elastos {
return _serviceEndpoint;
}

void ServiceEndpoint::AutoFill(const std::string &did) {
if (_id[0] == '#') {
_id = did + _id;
}
}

void ServiceEndpoint::ToOrderedJson(JsonGenerator *generator) const {
JsonGenerator_WriteStartObject(generator);

Expand Down Expand Up @@ -434,11 +440,12 @@ namespace Elastos {
}

_credentialSubject.AutoFill(did);
_proof.AutoFill(did);

if (_issuer.empty()) {
_issuer = did;
_issuer = _credentialSubject.ID();
}

_proof.AutoFill(_issuer);
}

void VerifiableCredential::ToOrderedJson(JsonGenerator *generator) const {
Expand Down Expand Up @@ -861,6 +868,7 @@ namespace Elastos {
for (nlohmann::json::iterator it = jservices.begin(); it != jservices.end(); ++it) {
ServiceEndpoint serviceEndpoint;
serviceEndpoint.FromJson(*it, version);
serviceEndpoint.AutoFill(_id);
_services.push_back(serviceEndpoint);
}
}
Expand Down
2 changes: 2 additions & 0 deletions SDK/Plugin/Transaction/Payload/DIDInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@
void SetService(const std::string &service);

const std::string &GetService() const;

void AutoFill(const std::string &did);
public:

virtual nlohmann::json ToJson(uint8_t version) const;
Expand Down

0 comments on commit 0f40a5e

Please sign in to comment.