replaceable-events (#1)
This commit is contained in:
parent
fc6e1c59a5
commit
7dbb4a522f
3 changed files with 187 additions and 22 deletions
32
utils.ts
32
utils.ts
|
@ -67,3 +67,35 @@ export async function getCCNPrivateKey(): Promise<Uint8Array> {
|
|||
);
|
||||
return decryptUint8Array(decodeBase64(encryptedPrivateKey), encryptionKey);
|
||||
}
|
||||
|
||||
export function isReplaceableEvent(kind: number): boolean {
|
||||
return (kind >= 10000 && kind < 20000) || kind === 0 || kind === 3;
|
||||
}
|
||||
|
||||
export function isAddressableEvent(kind: number): boolean {
|
||||
return kind >= 30000 && kind < 40000;
|
||||
}
|
||||
|
||||
export function isRegularEvent(kind: number): boolean {
|
||||
return (kind >= 1000 && kind < 10000) ||
|
||||
(kind >= 4 && kind < 45) ||
|
||||
kind === 1 ||
|
||||
kind === 2;
|
||||
}
|
||||
|
||||
export function isCCNReplaceableEvent(kind: number): boolean {
|
||||
return (kind >= 60000 && kind < 65536) || kind === 0;
|
||||
}
|
||||
|
||||
export function parseATagQuery(
|
||||
aTagValue: string,
|
||||
): { kind: number; pubkey: string; dTag?: string } {
|
||||
const parts = aTagValue.split(":");
|
||||
if (parts.length < 2) return { kind: 0, pubkey: "" };
|
||||
|
||||
return {
|
||||
kind: Number.parseInt(parts[0], 10),
|
||||
pubkey: parts[1],
|
||||
dTag: parts.length > 2 ? parts[2] : undefined,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue