Skip to main content

Shared Types

Common types used across the SDK.

Thread

interface Thread {
address: PublicKey;
id: number;
from: PublicKey;
to: PublicKey;
inboxId?: BN;
totalMsgs: number;
lastMsgSeq: number;
lastUpdated: number;
lastSenderSide: number; // 0 = from sent last, 1 = to sent last
lastReadSeqFrom: number;
lastReadSeqTo: number;
escrowPayment: ThreadEscrowInfo | null;
}

Inbox

interface Inbox {
address: PublicKey;
kind: InboxKind;
owner: PublicKey;
id: BN;
index: BN; // current body page index
len: BN; // total threads received
lastUpdated: number;
paymentRule: PaymentRule | null;
}

InboxKind

enum InboxKind {
Standard = 0, // stores thread list in paginated bodies
Ephemeral = 1, // no body; threads are tracked off-chain
}

InboxMetadata

interface InboxMetadata {
name: string;
uri: string;
}

Payment

interface Payment {
amount: BN;
mint: PublicKey;
to: PublicKey; // token account address (not the owner)
}

PaymentRule

Defines the requirement a sender must meet to open a thread into an inbox.

interface PaymentRule {
inner: Payment;
escrow: Escrow | null;
tokenProgram: TokenProgramType;
}

Escrow

interface Escrow {
releaseSeconds: BN; // lock duration in seconds
}

TokenProgramType

enum TokenProgramType {
TokenProgram = "TokenProgram",
Token2022Program = "Token2022Program",
}

TxReceiptWithClient<T>

Returned by all create operations.

interface TxReceiptWithClient<T> {
receipt: string[]; // confirmed transaction signatures
client: T; // loaded client instance
}