refactor: make instance methods deserializeRegistryEntry, verifyRegistryEntry, serializeRegistryEntry wrappers of the functional ones
This commit is contained in:
parent
cb4f23ed7e
commit
66612e9afc
|
@ -234,6 +234,24 @@ export class RegistryService {
|
|||
}
|
||||
|
||||
public deserializeRegistryEntry(event: Uint8Array): SignedRegistryEntry {
|
||||
return deserializeRegistryEntry(event);
|
||||
}
|
||||
|
||||
public verifyRegistryEntry(sre: SignedRegistryEntry): boolean {
|
||||
return verifyRegistryEntry(sre);
|
||||
}
|
||||
public serializeRegistryEntry(sre: SignedRegistryEntry): Uint8Array {
|
||||
return serializeRegistryEntry(sre);
|
||||
}
|
||||
}
|
||||
|
||||
async function pTimeout(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export function deserializeRegistryEntry(
|
||||
event: Uint8Array,
|
||||
): SignedRegistryEntry {
|
||||
const dataLength = event[42];
|
||||
return {
|
||||
pk: event.slice(1, 34),
|
||||
|
@ -243,7 +261,7 @@ export class RegistryService {
|
|||
};
|
||||
}
|
||||
|
||||
public verifyRegistryEntry(sre: SignedRegistryEntry): boolean {
|
||||
export function verifyRegistryEntry(sre: SignedRegistryEntry): boolean {
|
||||
const list: Uint8Array = Uint8Array.from([
|
||||
recordTypeRegistryEntry,
|
||||
...encodeEndian(sre.revision, 8),
|
||||
|
@ -253,7 +271,7 @@ export class RegistryService {
|
|||
|
||||
return ed25519.verify(sre.signature, list, sre.pk.slice(1));
|
||||
}
|
||||
public serializeRegistryEntry(sre: SignedRegistryEntry): Uint8Array {
|
||||
export function serializeRegistryEntry(sre: SignedRegistryEntry): Uint8Array {
|
||||
return Uint8Array.from([
|
||||
recordTypeRegistryEntry,
|
||||
...sre.pk,
|
||||
|
@ -263,8 +281,3 @@ export class RegistryService {
|
|||
...sre.signature,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
async function pTimeout(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue