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(credentials): default for credentials in exchange record #816

Merged
merged 7 commits into from
May 31, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class CredentialExchangeRecord extends BaseRecord<
public revocationNotification?: RevocationNotification
public errorMessage?: string
public protocolVersion!: CredentialProtocolVersion
public credentials!: CredentialRecordBinding[]
public credentials: CredentialRecordBinding[] = [] // default in case constructor not used (as can happen in tests)
TimoGlastra marked this conversation as resolved.
Show resolved Hide resolved

@Type(() => CredentialPreviewAttribute)
public credentialAttributes?: CredentialPreviewAttribute[]
Expand All @@ -75,7 +75,6 @@ export class CredentialExchangeRecord extends BaseRecord<

public constructor(props: CredentialExchangeRecordProps) {
super()

if (props) {
this.id = props.id ?? uuid()
this.createdAt = props.createdAt ?? new Date()
Expand All @@ -96,10 +95,8 @@ export class CredentialExchangeRecord extends BaseRecord<

public getTags() {
const metadata = this.metadata.get(CredentialMetadataKeys.IndyCredential)
let ids: string[] = []
if (this.credentials) {
ids = this.credentials.map((c) => c.credentialRecordId)
}
const ids = this.credentials.map((c) => c.credentialRecordId)

return {
...this._tags,
threadId: this.threadId,
Expand Down