Skip to content

Commit

Permalink
Merge pull request #24 from iden3/fix/signature-state-not-published
Browse files Browse the repository at this point in the history
Fix signature state request if identity state not published yet
  • Loading branch information
vmidyllic authored Oct 9, 2024
2 parents 7ec71fc + baa783a commit 26381e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
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

0 comments on commit 26381e0

Please sign in to comment.