@erc7824/nitrolite
Version:
The Nitrolite SDK empowers developers to build high-performance, scalable web3 applications using state channels. It's designed to provide near-instant transactions and significantly improved user experiences by minimizing direct blockchain interactions.
165 lines (164 loc) • 3.76 kB
TypeScript
import { Hex, Address, Hash } from 'viem';
export declare enum RPCChannelStatus {
Open = "open",
Closed = "closed",
Resizing = "resizing",
Challenged = "challenged"
}
export declare enum RPCTxType {
Transfer = "transfer",
Deposit = "deposit",
Withdrawal = "withdrawal",
AppDeposit = "app_deposit",
AppWithdrawal = "app_withdrawal",
EscrowLock = "escrow_lock",
EscrowUnlock = "escrow_unlock"
}
export declare enum RPCProtocolVersion {
NitroRPC_0_2 = "NitroRPC/0.2",
NitroRPC_0_4 = "NitroRPC/0.4"
}
export interface RPCAppDefinition {
application: string;
protocol: RPCProtocolVersion;
participants: Hex[];
weights: number[];
quorum: number;
challenge: number;
nonce?: number;
}
export interface RPCChannelUpdate {
channelId: Hex;
participant: Address;
status: RPCChannelStatus;
token: Address;
amount: BigInt;
chainId: number;
adjudicator: Address;
challenge: number;
nonce: number;
version: number;
createdAt: Date;
updatedAt: Date;
}
export interface RPCChannelUpdateWithWallet extends RPCChannelUpdate {
wallet: Address;
}
export interface RPCNetworkInfo {
chainId: number;
name: string;
custodyAddress: Address;
adjudicatorAddress: Address;
}
export declare enum RPCAppStateIntent {
Operate = "operate",
Deposit = "deposit",
Withdraw = "withdraw"
}
export interface RPCAppSession {
appSessionId: Hex;
application: string;
status: RPCChannelStatus;
participants: Address[];
protocol: RPCProtocolVersion;
challenge: number;
weights: number[];
quorum: number;
version: number;
nonce: number;
createdAt: Date;
updatedAt: Date;
sessionData?: string;
}
export interface RPCHistoryEntry {
id: number;
sender: Address;
reqId: number;
method: string;
params: string;
timestamp: number;
reqSig: Hex[];
resSig: Hex[];
response: string;
}
export interface RPCAsset {
token: Address;
chainId: number;
symbol: string;
decimals: number;
}
export interface RPCBalance {
asset: string;
amount: string;
}
export type LedgerAccountType = Address | Hash;
export interface RPCLedgerEntry {
id: number;
accountId: LedgerAccountType;
accountType: number;
asset: string;
participant: Address;
credit: string;
debit: string;
createdAt: Date;
}
export interface RPCTransaction {
id: number;
txType: RPCTxType;
fromAccount: LedgerAccountType;
fromAccountTag?: string;
toAccount: LedgerAccountType;
toAccountTag?: string;
asset: string;
amount: string;
createdAt: Date;
}
export interface RPCAllowance {
asset: string;
amount: string;
}
export interface RPCAllowanceUsage {
asset: string;
allowance: string;
used: string;
}
export interface RPCSessionKey {
id: number;
sessionKey: Address;
application: string;
allowances: RPCAllowanceUsage[];
scope?: string;
expiresAt: Date;
createdAt: Date;
}
export interface RPCAppSessionAllocation {
asset: string;
amount: string;
participant: Address;
}
export interface RPCChannelAllocation {
destination: Address;
token: Address;
amount: bigint;
}
export interface RPCTransferAllocation {
asset: string;
amount: string;
}
export interface RPCChannelOperationState {
intent: number;
version: number;
stateData: Hex;
allocations: RPCChannelAllocation[];
}
export interface RPCChannelOperation {
channelId: Hex;
state: RPCChannelOperationState;
serverSignature: Hex;
}
export interface RPCChannel {
participants: Address[];
adjudicator: Address;
challenge: number;
nonce: number;
}