From 60ce790d8d05acead494cc31503ceb1d75c33851 Mon Sep 17 00:00:00 2001 From: Rodolfo Miranda Date: Sat, 27 Jul 2024 17:02:09 -0300 Subject: [PATCH] conditionals --- src/keri/app/credentialing.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/keri/app/credentialing.ts b/src/keri/app/credentialing.ts index 1daf89b9..feb4c4ec 100644 --- a/src/keri/app/credentialing.ts +++ b/src/keri/app/credentialing.ts @@ -238,10 +238,10 @@ export class Credentials { // check if last event already has the anchor in it // and avoid creating a new event if it does const lastEvent = events[events.length - 1]; - if (lastEvent.a.length == 1 && - lastEvent.a[0].i == iss.i && - lastEvent.a[0].s == iss.s && - lastEvent.a[0].d == iss.d) + if (lastEvent.a?.length == 1 && + lastEvent.a[0]?.i == iss.i && + lastEvent.a[0]?.s == iss.s && + lastEvent.a[0]?.d == iss.d) { sn = sn - 1; // revert sn dig = hab.state.p!; @@ -352,10 +352,10 @@ export class Credentials { // check if last event already has the anchor in it // and avoid creating a new event if it does const lastEvent = events[events.length - 1]; - if (lastEvent.a.length == 1 && - lastEvent.a[0].i == rev.i && - lastEvent.a[0].s == rev.s && - lastEvent.a[0].d == rev.d) + if (lastEvent.a?.length == 1 && + lastEvent.a[0]?.i == rev.i && + lastEvent.a[0]?.s == rev.s && + lastEvent.a[0]?.d == rev.d) { sn = sn - 1; // revert sn dig = state.p!; @@ -648,10 +648,10 @@ export class Registries { // check if last event already has the anchor in it // and avoid creating a new event if it does const lastEvent = events[events.length - 1]; - if (lastEvent.a.length == 1 && - lastEvent.a[0].i == regser.pre && - lastEvent.a[0].s == '0' && - lastEvent.a[0].d == regser.pre) + if (lastEvent.a?.length == 1 && + lastEvent.a[0]?.i == regser.pre && + lastEvent.a[0]?.s == '0' && + lastEvent.a[0]?.d == regser.pre) { sn = sn - 1; // revert sn dig = state.p!;