Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit dd1da0c

Browse files
committed
chore: Don't add empty anchor origin to sidetree requests
Currently sidetree client adds anchorOrigin even when it is empty. Only add anchor origin to create/recover requests if anchor origin is not empty. Closes #294 Signed-off-by: Sandra Vrtikapa <[email protected]>
1 parent 0c41ff0 commit dd1da0c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

component/vdr/sidetree/client.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func (c *Client) CreateDID(opts ...create.Option) (*docdid.DocResolution, error)
103103
return nil, fmt.Errorf("failed to parse did document: %w", err)
104104
}
105105

106-
// TODO: Talk to Firas about not including document metadata in create
107106
return &docdid.DocResolution{DIDDocument: didDoc}, nil
108107
}
109108

@@ -283,7 +282,10 @@ func buildCreateRequest(multiHashAlgorithm uint, createDIDOpts *create.Opts) ([]
283282
RecoveryCommitment: recoveryCommitment,
284283
UpdateCommitment: updateCommitment,
285284
MultihashCode: multiHashAlgorithm,
286-
AnchorOrigin: createDIDOpts.AnchorOrigin,
285+
}
286+
287+
if createDIDOpts.AnchorOrigin != "" {
288+
createRequestInfo.AnchorOrigin = createDIDOpts.AnchorOrigin
287289
}
288290

289291
req, err := client.NewCreateRequest(createRequestInfo)
@@ -371,12 +373,18 @@ func buildRecoverRequest(did string, multiHashAlgorithm uint, recoverDIDOpts *re
371373
return nil, err
372374
}
373375

374-
req, err := client.NewRecoverRequest(&client.RecoverRequestInfo{
376+
recoverRequestInfo := &client.RecoverRequestInfo{
375377
DidSuffix: didSuffix, RevealValue: rv, OpaqueDocument: string(docBytes),
376378
RecoveryCommitment: nextRecoveryCommitment, UpdateCommitment: nextUpdateCommitment,
377379
MultihashCode: multiHashAlgorithm, Signer: recoverDIDOpts.Signer,
378-
RecoveryKey: recoverDIDOpts.Signer.PublicKeyJWK(), AnchorOrigin: recoverDIDOpts.AnchorOrigin,
379-
})
380+
RecoveryKey: recoverDIDOpts.Signer.PublicKeyJWK(),
381+
}
382+
383+
if recoverDIDOpts.AnchorOrigin != "" {
384+
recoverRequestInfo.AnchorOrigin = recoverDIDOpts.AnchorOrigin
385+
}
386+
387+
req, err := client.NewRecoverRequest(recoverRequestInfo)
380388
if err != nil {
381389
return nil, fmt.Errorf("failed to create sidetree request: %w", err)
382390
}

0 commit comments

Comments
 (0)