UNPKG

lotus-sdk

Version:

Central repository for several classes of tools for integrating with, and building for, the Lotusia ecosystem

124 lines 5.34 kB
import OpCode from './opcode.js'; export type ScriptChunkLokadUTF8 = 'RANK' | 'RNKC'; export type ScriptChunkPlatformUTF8 = 'lotusia' | 'twitter'; export type ScriptChunkSentimentUTF8 = 'positive' | 'negative' | 'neutral'; export type ScriptChunkLokadMap = Map<number, ScriptChunkLokadUTF8>; export type ScriptChunkPlatformMap = Map<number, ScriptChunkPlatformUTF8>; export type ScriptChunkSentimentMap = Map<number, ScriptChunkSentimentUTF8>; export type ScriptChunkField = 'sentiment' | 'platform' | 'profileId' | 'postId' | 'comment' | 'postHash' | 'instanceId'; export type ScriptChunk = { offset: number | null; len: number | null; map?: ScriptChunkLokadMap | ScriptChunkPlatformMap | ScriptChunkSentimentMap; }; export type ScriptChunksRNKC = { [name in Exclude<ScriptChunkField, 'sentiment' | 'postHash' | 'instanceId'>]: ScriptChunk; }; export type ScriptChunksRANK = { [name in Exclude<ScriptChunkField, 'comment' | 'postId' | 'postHash' | 'instanceId'>]: ScriptChunk; }; export type ScriptChunksOptionalRANK = { [name in Extract<ScriptChunkField, 'postId' | 'postHash' | 'instanceId'>]: ScriptChunk; }; export type TransactionOutputRANK = { sentiment: ScriptChunkSentimentUTF8; platform: ScriptChunkPlatformUTF8; profileId: string; postId?: string; }; export type TransactionOutputRNKC = { data: Uint8Array; feeRate: number; inReplyToPlatform: ScriptChunkPlatformUTF8; inReplyToProfileId?: string; inReplyToPostId?: string; }; export type Transaction = { txid: string; outIdx: number; sats: bigint; firstSeen: bigint; scriptPayload: string; instanceId?: string; height?: number; timestamp?: bigint; }; export type TransactionRANK = TransactionOutputRANK & Transaction; export type TransactionRNKC = TransactionOutputRNKC & Transaction; export type TargetEntity = { id: string; platform: string; ranking: bigint; ranks: Omit<TransactionRANK, 'profileId' | 'platform'>[]; comments: Omit<TransactionRNKC, 'inReplyToProfileId' | 'inReplyToPlatform'>[]; satsPositive: bigint; satsNegative: bigint; votesPositive: number; votesNegative: number; }; export type ProfileMap = Map<string, Profile>; export type PostMap = Map<string, Post>; export type Profile = TargetEntity & { posts?: PostMap; }; export type Post = TargetEntity & { profileId: string; data?: Uint8Array; }; export type PlatformParameters = { profileId: { len: number; regex: RegExp; }; postId: { len: number; regex: RegExp; type: 'BigInt' | 'Number' | 'String'; }; }; export declare const LOKAD_PREFIX_RANK = 1380011595; export declare const LOKAD_PREFIX_RNKC = 1380862787; export declare const SCRIPT_CHUNK_LOKAD: ScriptChunkLokadMap; export declare const RANK_SENTIMENT_NEUTRAL = OpCode.OP_16; export declare const RANK_SENTIMENT_POSITIVE = OpCode.OP_1; export declare const RANK_SENTIMENT_NEGATIVE = OpCode.OP_0; export declare const SCRIPT_CHUNK_SENTIMENT: ScriptChunkSentimentMap; export declare const RANK_SENTIMENT_OP_CODES: Map<ScriptChunkSentimentUTF8, string>; export declare const SCRIPT_CHUNK_PLATFORM: ScriptChunkPlatformMap; export declare const ScriptChunksRNKCMap: Map<keyof ScriptChunksRNKC, ScriptChunk>; export declare const RANK_SCRIPT_REQUIRED_LENGTH = 10; export declare const ScriptChunksRANKMap: Map<keyof ScriptChunksRANK, ScriptChunk>; export declare const ScriptChunksOptionalRANKMap: Map<keyof ScriptChunksOptionalRANK, ScriptChunk>; export declare const PlatformConfiguration: Map<ScriptChunkPlatformUTF8, PlatformParameters>; export declare function toProfileIdBuf(platform: ScriptChunkPlatformUTF8, profileId: string): Buffer | null; export declare function toProfileIdUTF8(profileIdBuf: Buffer): string; export declare function toPostIdBuf(platform: ScriptChunkPlatformUTF8, postId: string): Buffer | undefined; export declare function toPlatformBuf(platform: ScriptChunkPlatformUTF8): Buffer | undefined; export declare function toPlatformUTF8(platformBuf: Buffer): ScriptChunkPlatformUTF8 | undefined; export declare function toSentimentOpCode(sentiment: ScriptChunkSentimentUTF8): string | undefined; export declare function toSentimentUTF8(sentimentBuf: Buffer): ScriptChunkSentimentUTF8 | undefined; export declare function toCommentUTF8(commentBuf: Buffer | Uint8Array): string | undefined; export declare function toScriptRANK(sentiment: ScriptChunkSentimentUTF8, platform: ScriptChunkPlatformUTF8, profileId: string, postId?: string): Buffer; export declare function toScriptRNKC({ platform, profileId, postId, comment, }: { platform: ScriptChunkPlatformUTF8; profileId: string; postId?: string; comment: string; }): Buffer[]; export declare class ScriptProcessor { private chunks; private script; private supplementalScripts; constructor(script: Buffer); addScript(script: string | Buffer): boolean; get lokadType(): ScriptChunkLokadUTF8 | undefined; private processLokad; private processSentiment; private processPlatform; private processProfileId; private processPostId; private processComment; processScriptRANK(): TransactionOutputRANK | null; processScriptRNKC(burnedSats: number | bigint): TransactionOutputRNKC | null; } //# sourceMappingURL=index.d.ts.map