// VerifiableCredentialFromAnchorEvent validates the AnchorEvent and returns the embedded verifiable credential.
VerifiableCredentialFromAnchorEvent validates the AnchorEvent and returns the embedded verifiable credential.
// VerifiableCredentialFromAnchorEvent validates the AnchorEvent and returns the embedded verifiable credential .
func VerifiableCredentialFromAnchorEvent(anchorEvent *vocab.AnchorEventType,
	opts ...verifiable.CredentialOpt) (*verifiable.Credential, error) {
	if err := anchorEvent.Validate(); err != nil {
		return nil, fmt.Errorf("invalid anchor event: %w", err)
	}
	witnessDoc, err := GetWitnessDoc(anchorEvent)
	if err != nil {
		return nil, fmt.Errorf("get witness from anchor event: %w", err)
	}
	vcBytes, err := json.Marshal(witnessDoc)
	if err != nil {
		return nil, fmt.Errorf("marshal witness: %w", err)
	}
	vc, err := verifiable.ParseCredential(vcBytes, opts...)
	if err != nil {
		if strings.Contains(err.Error(), "http request unsuccessful") {
			return nil, errors.NewTransient(fmt.Errorf("http error during parse credential: %w", err))
		}
		return nil, fmt.Errorf("parse credential: %w", err)
	}
	return vc, nil
}
func VerifiableCredentialFromAnchorEvent ( anchorEvent * vocab . AnchorEventType , opts ... verifiable . CredentialOpt ) ( * verifiable . Credential , error ) { if err := anchorEvent . Validate ( ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } witnessDoc , err := GetWitnessDoc ( anchorEvent ) if err != nil { return nil , fmt . Errorf ( " " , err ) } vcBytes , err := json . Marshal ( witnessDoc ) if err != nil { return nil , fmt . Errorf ( " " , err ) } vc , err := verifiable . ParseCredential ( vcBytes , opts ... ) if err != nil { if strings . Contains ( err . Error ( ) , " " ) { return nil , errors . NewTransient ( fmt . Errorf ( " " , err ) ) } return nil , fmt . Errorf ( " " , err ) } return vc , nil }
VerifiableCredentialFromAnchorEvent validates the AnchorEvent and returns the embedded verifiable credential.
VerifiableCredentialFromAnchorEvent validates the AnchorEvent and returns the embedded verifiable credential .
// The server is probably down. Return a transient error so that it may be retried.