Skip to content

Commit

Permalink
Merge pull request #633 from SmithSamuelM/dev
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
SmithSamuelM authored Dec 17, 2023
2 parents 5b6cb28 + d698c3b commit 67eece0
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 101 deletions.
4 changes: 2 additions & 2 deletions src/keri/app/cli/commands/multisig/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def rotateDo(self, tymth, tock=0.0, **opts):
raise kering.ConfigurationError(f"unknown rotation member {mid}")

mkever = self.hby.kevers[mid] # get key state for given member
migers.append(mkever.digers[0])
migers.append(mkever.ndigers[0])
rmids.append(mid)

case [mid, sn]:
Expand All @@ -192,7 +192,7 @@ def rotateDo(self, tymth, tock=0.0, **opts):
if not serder.estive:
raise kering.ConfigurationError(f"invalid event {sn} for rotation member {mid}")

migers.append(serder.digers[0])
migers.append(serder.ndigers[0])
rmids.append(mid)

case _:
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/cli/commands/vc/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def export_credentials(args):
"""
tels = args.tels
kels = args.kels
chains = args.edge
chains = args.edge if args.edge is not None else {}

if args.full:
tels = kels = chains = True
Expand Down Expand Up @@ -108,7 +108,7 @@ def outputCred(self, said):
self.outputTEL(creder.said)

if self.chains:
chains = creder.edge
chains = creder.edge if creder.edge is not None else {}
saids = []
for key, source in chains.items():
if key == 'd':
Expand Down
8 changes: 4 additions & 4 deletions src/keri/app/habbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def extractMerfersMigers(self, smids, rmids=None):

for mid in rmids:
kever = self.kevers[mid]
digers = kever.digers
digers = kever.ndigers
if digers: # abandoned id may have empty next digers
migers.append(digers[0])
if len(digers) > 1:
Expand Down Expand Up @@ -1231,7 +1231,7 @@ def rotate(self, *, verfers=None, digers=None, isith=None, nsith=None, toad=None
keys = [verfer.qb64 for verfer in verfers]

indices = []
for idx, diger in enumerate(kever.digers):
for idx, diger in enumerate(kever.ndigers):
pdigs = [coring.Diger(ser=verfer.qb64b, code=diger.code).qb64 for verfer in verfers]
if diger.qb64 in pdigs:
indices.append(idx)
Expand Down Expand Up @@ -2329,7 +2329,7 @@ def rotate(self, *, isith=None, nsith=None, ncount=None, toad=None, cuts=None, a
kever = self.kever # before rotation kever is prior next

if ncount is None:
ncount = len(kever.digers) # use len of prior next digers as default
ncount = len(kever.ndigers) # use len of prior next digers as default

try:
verfers, digers = self.mgr.replay(pre=self.pre)
Expand Down Expand Up @@ -2804,7 +2804,7 @@ def sign(self, ser, verfers=None, indexed=True, rotated=False, indices=None, ond
migers = self.mhab.kever.fetchPriorDigers(sn=sn - 1)
if migers: # not None or not empty
mig = migers[0].qb64 # always use first prior dig of mhab
digs = [diger.qb64 for diger in self.kever.digers] # group habs prior digs
digs = [diger.qb64 for diger in self.kever.ndigers] # group habs prior digs
try:
pni = digs.index(mig) # find mhab dig index in group hab digs
except ValueError: # not found
Expand Down
26 changes: 13 additions & 13 deletions src/keri/core/eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ class Kever:
ilk (str): from Ilks for current event type
tholder (Tholder): instance for event signing threshold
verfers (list): of Verfer instances for current event state set of signing keys
digers (list): of Diger instances for current event state set of
ndigers (list): of Diger instances for current event state set of
next (rotation) key digests
ntholder (Tholder): instance for next (rotation) threshold
from serder.ntholder
Expand All @@ -1602,7 +1602,7 @@ class Kever:
Properties:
sn (int): sequence number property that returns .sner.num
fn (int): first seen ordinal number property the returns .fner.num
digs (list): of digests qb64 of .digers
ndigs (list): of digests qb64 of .digers
kevers (dict): reference to self.db.kevers
transferable (bool): True if .digers is not empty and pre is transferable
Expand Down Expand Up @@ -1745,12 +1745,12 @@ def fn(self):


@property
def digs(self):
def ndigs(self):
"""
Returns:
(list): digs of digers
"""
return [diger.qb64 for diger in self.digers]
return [diger.qb64 for diger in self.ndigers]


@property
Expand All @@ -1769,7 +1769,7 @@ def transferable(self):
and .nextor is not None
False otherwise
"""
return True if self.digers and self.prefixer.transferable else False
return True if self.ndigers and self.prefixer.transferable else False


def reload(self, state):
Expand All @@ -1789,7 +1789,7 @@ def reload(self, state):
self.tholder = Tholder(sith=state.kt)
self.ntholder = Tholder(sith=state.nt)
self.verfers = [Verfer(qb64=key) for key in state.k]
self.digers = [Diger(qb64=dig) for dig in state.n]
self.ndigers = [Diger(qb64=dig) for dig in state.n]
self.toader = Number(numh=state.bt) # auto converts from hex num
self.wits = state.b
self.cuts = state.ee.br
Expand Down Expand Up @@ -1856,7 +1856,7 @@ def incept(self, serder, estOnly=None):
raise ValidationError("Invalid inception nxt not empty for "
"non-transferable prefix = {} for evt = {}."
"".format(self.prefixer.qb64, ked))
self.digers = serder.digers
self.ndigers = serder.ndigers
self.ntholder = serder.ntholder

self.cuts = [] # always empty at inception since no prev event
Expand Down Expand Up @@ -2020,7 +2020,7 @@ def update(self, serder, sigers, wigers=None, delseqner=None, delsaider=None,
self.ilk = ilk
self.tholder = tholder
self.verfers = serder.verfers
self.digers = serder.digers
self.ndigers = serder.ndigers
self.ntholder = serder.ntholder

self.toader = toader
Expand Down Expand Up @@ -2156,7 +2156,7 @@ def rotate(self, serder, sner):
"".format(dig, self.serder.said, ked))

# check derivation code of pre for non-transferable
if not self.digers: # prior next list is empty so rotations not allowed
if not self.ndigers: # prior next list is empty so rotations not allowed
raise ValidationError("Attempted rotation for nontransferable"
" prefix = {} for evt = {}."
"".format(self.prefixer.qb64, ked))
Expand Down Expand Up @@ -2342,7 +2342,7 @@ def exposeds(self, sigers):
odxs = []
for siger in sigers:
try:
diger = self.digers[siger.ondex]
diger = self.ndigers[siger.ondex]
except TypeError as ex: # ondex may be None
continue
except IndexError as ex:
Expand Down Expand Up @@ -2500,7 +2500,7 @@ def logEvent(self, serder, sigers=None, wigers=None, wits=None, first=False,
val = (coring.Prefixer(qb64b=serder.preb), coring.Seqner(sn=serder.sn))
for verfer in (serder.verfers if serder.verfers is not None else []):
self.db.pubs.add(keys=(verfer.qb64,), val=val)
for diger in (serder.digers if serder.digers is not None else []):
for diger in (serder.ndigers if serder.ndigers is not None else []):
self.db.digs.add(keys=(diger.qb64,), val=val)
if first: # append event dig to first seen database in order
if seqner and saider: # authorized delegated or issued event
Expand Down Expand Up @@ -2622,7 +2622,7 @@ def state(self):
eevt=eevt,
sith=self.tholder.sith,
nsith=self.ntholder.sith if self.ntholder else '0',
ndigs=[diger.qb64 for diger in self.digers],
ndigs=[diger.qb64 for diger in self.ndigers],
toad=self.toader.num,
wits=self.wits,
cnfg=cnfg,
Expand Down Expand Up @@ -2661,7 +2661,7 @@ def fetchPriorDigers(self, sn: int | None = None) -> list | None:
raw = self.db.getEvt(dgkey)
serder = serdering.SerderKERI(raw=bytes(raw))
if serder.estive: # establishment event
return serder.digers
return serder.ndigers

return None

Expand Down
55 changes: 18 additions & 37 deletions src/keri/core/serdering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,16 +1267,6 @@ def ndigs(self):

return self._sad.get("n")


@property
def digs(self):
"""
Returns:
(list): digs
"""
return self.ndigs


@property
def ndigers(self):
"""NDigers property getter
Expand All @@ -1292,18 +1282,6 @@ def ndigers(self):
return [Diger(qb64=dig) for dig in digs] if digs is not None else None


@property
def digers(self):
"""Digers property getter, alias of .ndigers
Returns:
digers (list[Diger]): instance as converted from ._sad['n'].
One for each next key digests.
"""
return self.ndigers



@property
def bner(self):
"""
Expand Down Expand Up @@ -1542,7 +1520,7 @@ def _verify(self, **kwa):
@property
def uuid(self):
"""uuid property getter
Optional fields return None when not present
Returns:
uuid (str | None): qb64 of .sad["u"] salty nonce
"""
Expand All @@ -1552,7 +1530,7 @@ def uuid(self):
@property
def uuidb(self):
"""uuid property getter (uuid bytes)
Optional fields return None when not present
Returns:
uuidb (bytes | None): qb64b of .sad["u"] salty nonce as bytes
"""
Expand All @@ -1562,7 +1540,7 @@ def uuidb(self):
@property
def issuer(self):
"""issuer property getter (issuer AID)
Optional fields return None when not present
Returns:
issuer (str | None): qb64 of .sad["i"] issuer AID
"""
Expand All @@ -1572,7 +1550,7 @@ def issuer(self):
@property
def issuerb(self):
"""issuerb property getter (issuer AID bytes)
Optional fields return None when not present
Returns:
issuerb (bytes | None): qb64b of .issuer AID as bytes
"""
Expand All @@ -1582,7 +1560,7 @@ def issuerb(self):
@property
def regi(self):
"""regi property getter (registry identifier SAID)
Optional fields return None when not present
Returns:
regi (str | None): qb64 of .sad["ri"] registry SAID
"""
Expand All @@ -1592,6 +1570,7 @@ def regi(self):
@property
def regib(self):
"""regib property getter (registry identifier SAID bytes)
Optional fields return None when not present
Returns:
regib (bytes | None): qb64b of .issuer AID as bytes
"""
Expand All @@ -1601,7 +1580,7 @@ def regib(self):
@property
def schema(self):
"""schema block or SAID property getter
Optional fields return None when not present
Returns:
schema (dict | str | None): from ._sad["s"]
"""
Expand All @@ -1611,7 +1590,7 @@ def schema(self):
@property
def attrib(self):
"""attrib block or SAID property getter (attribute)
Optional fields return None when not present
Returns:
attrib (dict | str | None): from ._sad["a"]
"""
Expand All @@ -1621,7 +1600,7 @@ def attrib(self):
@property
def issuee(self):
"""ise property getter (issuee AID)
Optional fields return None when not present
Returns:
issuee (str | None): qb64 of .sad["a"]["i"] issuee AID
"""
Expand All @@ -1634,6 +1613,7 @@ def issuee(self):
@property
def issueeb(self):
"""isrb property getter (issuee AID bytes)
Optional fields return None when not present
Returns:
issueeb (bytes | None): qb64b of .issuee AID as bytes
"""
Expand All @@ -1642,8 +1622,8 @@ def issueeb(self):

@property
def attagg(self):
"""attagg block property getter (attribute aggregate)
"""Attagg block property getter (attribute aggregate)
Optional fields return None when not present
Returns:
attagg (dict | str): from ._sad["A"]
"""
Expand All @@ -1652,21 +1632,22 @@ def attagg(self):

@property
def edge(self):
"""edge block property getter
"""Edge block property getter
Optional fields return None when not present
Returns:
edge (dict | str): from ._sad["e"]
"""
return self._sad.get("e") or {}
return self._sad.get("e")


@property
def rule(self):
"""rule block property getter
"""Rule block property getter
Optional fields return None when not present
Returns:
rule (dict | str): from ._sad["r"]
"""
return self._sad.get("r") or {}
return self._sad.get("r") # or {} # need to fix logic so can remove or since optional

# ToDo Schemer property getter. Schemer object
2 changes: 1 addition & 1 deletion src/keri/db/basing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ def rotationMembers(self, pre: str):
return members

kever = self.kevers[pre]
for diger in kever.digers:
for diger in kever.ndigers:
if (couples := self.digs.get(keys=(diger.qb64,))) is None:
continue

Expand Down
2 changes: 1 addition & 1 deletion src/keri/vdr/verifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def processCredential(self, creder, prefixer, seqner, saider):
regk = creder.regi
vcid = creder.said
schema = creder.schema
prov = creder.edge
prov = creder.edge if creder.edge is not None else {}

if regk not in self.tevers: # registry event not found yet
if self.escrowMRE(creder, prefixer, seqner, saider):
Expand Down
4 changes: 2 additions & 2 deletions src/keri/vdr/viring.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def cloneCreds(self, saids, db):
del iss[0:iserder.size]

chainSaids = []
for k, p in creder.edge.items():
for k, p in (creder.edge.items() if creder.edge is not None else {}):
if k == "d":
continue

Expand Down Expand Up @@ -558,7 +558,7 @@ def sources(self, db, creder):
list: credential sources as resolved from `e` in creder.crd
"""
chains = creder.edge
chains = creder.edge if creder.edge is not None else {}
saids = []
for key, source in chains.items():
if key == 'd':
Expand Down
Loading

0 comments on commit 67eece0

Please sign in to comment.