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 {
|
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];
|
const dataLength = event[42];
|
||||||
return {
|
return {
|
||||||
pk: event.slice(1, 34),
|
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([
|
const list: Uint8Array = Uint8Array.from([
|
||||||
recordTypeRegistryEntry,
|
recordTypeRegistryEntry,
|
||||||
...encodeEndian(sre.revision, 8),
|
...encodeEndian(sre.revision, 8),
|
||||||
|
@ -253,7 +271,7 @@ export class RegistryService {
|
||||||
|
|
||||||
return ed25519.verify(sre.signature, list, sre.pk.slice(1));
|
return ed25519.verify(sre.signature, list, sre.pk.slice(1));
|
||||||
}
|
}
|
||||||
public serializeRegistryEntry(sre: SignedRegistryEntry): Uint8Array {
|
export function serializeRegistryEntry(sre: SignedRegistryEntry): Uint8Array {
|
||||||
return Uint8Array.from([
|
return Uint8Array.from([
|
||||||
recordTypeRegistryEntry,
|
recordTypeRegistryEntry,
|
||||||
...sre.pk,
|
...sre.pk,
|
||||||
|
@ -263,8 +281,3 @@ export class RegistryService {
|
||||||
...sre.signature,
|
...sre.signature,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function pTimeout(ms: number) {
|
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue