TypeScript Types
PartyLayer is built with TypeScript strict mode and exports comprehensive types for all APIs. This page documents the core types you'll work with most frequently.
💡 Tip
All types are exported from
@partylayer/core and re-exported from
@partylayer/sdk. You can import from either package.
Branded Types
PartyLayer uses branded types to prevent accidental mixing of string identifiers:
// These are all strings at runtime, but TypeScript treats them as distinct types
type WalletId = string & { __brand: 'WalletId' };
type PartyId = string & { __brand: 'PartyId' };
type SessionId = string & { __brand: 'SessionId' };
type TransactionHash = string & { __brand: 'TransactionHash' };
type Signature = string & { __brand: 'Signature' };
// NetworkId is a union + string for custom networks
type NetworkId = 'devnet' | 'testnet' | 'mainnet' | (string & {});
In practice, you can cast regular strings to these types:
import type { WalletId, PartyId } from '@partylayer/core';
const walletId = 'console' as WalletId;
const partyId = 'party::abc123' as PartyId;
Session
interface Session {
sessionId: SessionId;
walletId: WalletId;
partyId: PartyId;
network: NetworkId;
createdAt: number; // Unix timestamp (ms)
expiresAt?: number; // Optional expiration timestamp
origin: string; // dApp origin URL
capabilitiesSnapshot: CapabilityKey[]; // Wallet capabilities at connect time
metadata?: Record<string, string>; // Optional key-value metadata
}
WalletInfo
Wallet metadata from the registry or adapter:
interface WalletInfo {
walletId: WalletId;
name: string;
website: string;
icons: {
sm?: string; // Small icon URL (32px)
md?: string; // Medium icon URL (64px)
lg?: string; // Large icon URL (128px)
};
category?: string; // e.g., 'browser', 'mobile', 'enterprise'
capabilities: CapabilityKey[];
installHints?: InstallHints;
adapter: {
packageName: string;
versionRange: string;
};
docs: string[]; // Documentation URLs
minSdkVersion?: string; // Minimum SDK version required
networks: NetworkId[]; // Supported networks
channel: 'stable' | 'beta';
metadata?: Record<string, string>;
}
Signing Types
SignedMessage
interface SignedMessage {
signature: Signature;
partyId: PartyId;
message: string;
nonce?: string;
domain?: string;
}
SignedTransaction
interface SignedTransaction {
signedTx: unknown; // Wallet-specific signed payload
transactionHash: TransactionHash;
partyId: PartyId;
}
TxReceipt
interface TxReceipt {
transactionHash: TransactionHash;
submittedAt: number; // Unix timestamp (ms)
commandId?: string; // Daml command ID
updateId?: string; // Daml update ID
}
RegistryStatus
interface RegistryStatus {
source: 'network' | 'cache'; // Where the data came from
verified: boolean; // Signature verification passed
channel: 'stable' | 'beta';
sequence: number; // Registry version sequence
stale: boolean; // Whether data may be outdated
fetchedAt: number; // Timestamp of last fetch
etag?: string; // HTTP ETag for caching
error?: Error; // Error if fetch failed
}
Capability Keys
Capabilities describe what a wallet adapter can do:
type CapabilityKey =
| 'connect' // Can establish connection
| 'disconnect' // Can cleanly disconnect
| 'restore' // Can restore persisted sessions
| 'signMessage' // Can sign arbitrary messages
| 'signTransaction' // Can sign transactions
| 'submitTransaction' // Can sign and submit transactions
| 'ledgerApi' // Can proxy ledger API requests
| 'events' // Supports event subscriptions
| 'deeplink' // Supports deep link transport
| 'popup' // Supports popup/QR code transport
| 'injected' // Supports injected provider transport
| 'remoteSigner'; // Supports remote signing
TransactionStatus
type TransactionStatus =
| 'pending' // Transaction submitted, waiting for confirmation
| 'submitted' // Transaction accepted by the ledger
| 'committed' // Transaction committed to the ledger
| 'rejected' // Transaction rejected by the ledger
| 'failed'; // Transaction failed (error)
ErrorCode
type ErrorCode =
| 'WALLET_NOT_FOUND'
| 'WALLET_NOT_INSTALLED'
| 'USER_REJECTED'
| 'ORIGIN_NOT_ALLOWED'
| 'SESSION_EXPIRED'
| 'CAPABILITY_NOT_SUPPORTED'
| 'TRANSPORT_ERROR'
| 'REGISTRY_FETCH_FAILED'
| 'REGISTRY_VERIFICATION_FAILED'
| 'REGISTRY_SCHEMA_INVALID'
| 'INTERNAL_ERROR'
| 'TIMEOUT';
Event Types
// Session events
interface SessionConnectedEvent {
type: 'session:connected';
session: Session;
}
interface SessionDisconnectedEvent {
type: 'session:disconnected';
sessionId: SessionId;
reason?: string;
}
interface SessionExpiredEvent {
type: 'session:expired';
sessionId: SessionId;
}
// Transaction events
interface TxStatusEvent {
type: 'tx:status';
sessionId: SessionId;
txId: TransactionHash;
status: TransactionStatus;
raw?: unknown;
}
// Registry events
interface RegistryStatusEvent {
type: 'registry:status';
status: RegistryStatus;
}
// Error events
interface ErrorEvent {
type: 'error';
error: Error;
}
CIP-0103 Types
For the full CIP-0103 type definitions (27 types including CIP0103Provider, CIP0103Account, CIP0103StatusEvent, CIP0103TxChangedEvent, etc.), see the CIP-0103 Provider documentation.
All CIP-0103 types are exported from @partylayer/core:
import type {
CIP0103Provider,
CIP0103ConnectResult,
CIP0103Account,
CIP0103Network,
CIP0103StatusEvent,
CIP0103TxChangedEvent,
CIP0103LedgerApiResponse,
CIP0103ProviderRpcError,
} from '@partylayer/core';