Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signature state request if identity state not published yet #24

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/services/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,16 @@ func (d *DidDocumentServices) GetDidDocument(ctx context.Context, did string, op
stateType = GlobalStateType
}

if opts.State != nil && identityState.StateInfo == nil { // this case is genesis state
if stateType == IdentityStateType && ((opts.State != nil && identityState.StateInfo == nil) || !isPublished) { // this case is genesis state
// fill state info for genesis state to be able to prove it

state := opts.State
if state == nil {
state = big.NewInt(0)
}
identityState.StateInfo = &StateInfo{
ID: *userDID,
State: opts.State,
State: state,
ReplacedByState: big.NewInt(0),
CreatedAtTimestamp: big.NewInt(0),
ReplacedAtTimestamp: big.NewInt(0),
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/http_nameservice.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,13 @@
"});",
"",
"pm.test(\"Proof section is NOT empty\", function () {",
" pm.expect(pm.response.json().proof).to.not.eq(undefined);",
" pm.expect(pm.response.json().vc.proof).to.not.eq(undefined);",
"});",
"",
"if (pm.response.json().proof.length == 2 ||",
"if (pm.response.json().vc.proof.length == 2 ||",
" pm.environment.get(\"retry_count\") > pm.globals.get(\"max_retry\")) { // Some condition to decide if retrying the request is needed",
" pm.expect(pm.response.json().proof[1]).not.eq(undefined);",
" pm.expect(pm.response.json().proof[1].issuerData.state.blockTimestamp).not.eq(undefined);",
" pm.expect(pm.response.json().vc.proof[1]).not.eq(undefined);",
" pm.expect(pm.response.json().vc.proof[1].issuerData.state.blockTimestamp).not.eq(undefined);",
" ",
" pm.environment.set(\"retry_count\", 1);",
" pm.collectionVariables.set(\"age_claim_non_merklized_import\", pm.response.text());",
Expand Down
Loading