gennet.js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -0
- package/dist/index.cjs +311 -0
- package/dist/index.d.cts +261 -0
- package/dist/index.d.mts +261 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.mjs +301 -0
- package/package.json +60 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
interface JsonRpcRequest {
|
|
2
|
+
jsonrpc: '2.0';
|
|
3
|
+
id: string | number;
|
|
4
|
+
method: string;
|
|
5
|
+
params?: Record<string, unknown> | unknown[];
|
|
6
|
+
}
|
|
7
|
+
interface JsonRpcSuccessResponse {
|
|
8
|
+
jsonrpc: '2.0';
|
|
9
|
+
id: string | number;
|
|
10
|
+
result: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface JsonRpcErrorResponse {
|
|
13
|
+
jsonrpc: '2.0';
|
|
14
|
+
id: string | number;
|
|
15
|
+
error: {
|
|
16
|
+
code: number;
|
|
17
|
+
message: string;
|
|
18
|
+
data?: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
|
22
|
+
interface JsonRpcNotification {
|
|
23
|
+
jsonrpc: '2.0';
|
|
24
|
+
method: string;
|
|
25
|
+
params: {
|
|
26
|
+
subscription: string;
|
|
27
|
+
result: unknown;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
declare class RpcError extends Error {
|
|
31
|
+
readonly code: number;
|
|
32
|
+
readonly data?: unknown;
|
|
33
|
+
constructor(message: string, code: number, data?: unknown);
|
|
34
|
+
}
|
|
35
|
+
type GatewayState = 'INITIALIZING' | 'READY' | 'RUNNING' | 'STOPPED';
|
|
36
|
+
interface ModuleInfo {
|
|
37
|
+
name: string;
|
|
38
|
+
version: string;
|
|
39
|
+
state: string;
|
|
40
|
+
status?: string;
|
|
41
|
+
}
|
|
42
|
+
interface NodeInfo {
|
|
43
|
+
state: GatewayState;
|
|
44
|
+
peerId: string | null;
|
|
45
|
+
address: string;
|
|
46
|
+
peers: number;
|
|
47
|
+
knownPeers: number;
|
|
48
|
+
uptime: number;
|
|
49
|
+
multiaddrs: string[];
|
|
50
|
+
tcpAddrs: string[];
|
|
51
|
+
circuitAddrs: string[];
|
|
52
|
+
relay: boolean;
|
|
53
|
+
listenPort: number;
|
|
54
|
+
datadir: string;
|
|
55
|
+
modules: ModuleInfo[];
|
|
56
|
+
}
|
|
57
|
+
interface PeerInfo {
|
|
58
|
+
peerId: string;
|
|
59
|
+
address: string;
|
|
60
|
+
multiaddr: string;
|
|
61
|
+
connected: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface AgentResult {
|
|
64
|
+
ok: boolean;
|
|
65
|
+
response?: string;
|
|
66
|
+
toolCalls?: Array<{
|
|
67
|
+
name: string;
|
|
68
|
+
}>;
|
|
69
|
+
tokensUsed?: {
|
|
70
|
+
input: number;
|
|
71
|
+
output: number;
|
|
72
|
+
};
|
|
73
|
+
error?: string;
|
|
74
|
+
}
|
|
75
|
+
interface IdentityInfo {
|
|
76
|
+
index: number;
|
|
77
|
+
address: string;
|
|
78
|
+
filename: string;
|
|
79
|
+
}
|
|
80
|
+
type SubscriptionTopic = 'logs' | 'messages' | 'mempool';
|
|
81
|
+
interface Subscription {
|
|
82
|
+
id: string;
|
|
83
|
+
unsubscribe: () => Promise<boolean>;
|
|
84
|
+
}
|
|
85
|
+
interface Provider {
|
|
86
|
+
/** JSON-RPC Request senden und auf Response warten. */
|
|
87
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
88
|
+
/** Listener für Push-Notifications (Subscriptions). */
|
|
89
|
+
on(event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
90
|
+
/** Listener entfernen. */
|
|
91
|
+
off(event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
92
|
+
/** Verbindung schließen. */
|
|
93
|
+
disconnect(): void;
|
|
94
|
+
/** Verbindung herstellen (bei WebSocket). */
|
|
95
|
+
connect?(): Promise<void>;
|
|
96
|
+
/** Ob eine aktive Verbindung besteht. */
|
|
97
|
+
readonly connected: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** admin Namespace — Node-Administration. */
|
|
101
|
+
declare class Admin {
|
|
102
|
+
private readonly provider;
|
|
103
|
+
constructor(provider: Provider);
|
|
104
|
+
/** Node-Info: Status, PeerId, Adresse, Peers, Uptime, Module. */
|
|
105
|
+
nodeInfo(): Promise<NodeInfo>;
|
|
106
|
+
/** Gateway herunterfahren. */
|
|
107
|
+
shutdown(): Promise<{
|
|
108
|
+
ok: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
/** Alle Module und ihren Status auflisten. */
|
|
111
|
+
modules(): Promise<{
|
|
112
|
+
modules: ModuleInfo[];
|
|
113
|
+
}>;
|
|
114
|
+
/** Ein Modul starten. */
|
|
115
|
+
startModule(name: string): Promise<{
|
|
116
|
+
name: string;
|
|
117
|
+
state: string;
|
|
118
|
+
}>;
|
|
119
|
+
/** Ein Modul stoppen. */
|
|
120
|
+
stopModule(name: string): Promise<{
|
|
121
|
+
name: string;
|
|
122
|
+
state: string;
|
|
123
|
+
}>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** net Namespace — P2P-Netzwerk. */
|
|
127
|
+
declare class Net {
|
|
128
|
+
private readonly provider;
|
|
129
|
+
constructor(provider: Provider);
|
|
130
|
+
/** Alle bekannten Peers auflisten. */
|
|
131
|
+
peers(): Promise<{
|
|
132
|
+
peers: PeerInfo[];
|
|
133
|
+
}>;
|
|
134
|
+
/** Mit einem Peer über Multiaddr verbinden. */
|
|
135
|
+
connect(multiaddr: string): Promise<{
|
|
136
|
+
peerId: string;
|
|
137
|
+
connected: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
/** Verschlüsselte Nachricht an einen Peer senden. */
|
|
140
|
+
send(address: string, text: string): Promise<{
|
|
141
|
+
sent: boolean;
|
|
142
|
+
to: string;
|
|
143
|
+
}>;
|
|
144
|
+
/** Agent-Prompt auf einem Remote-Peer ausführen (ECIES-verschlüsselt). */
|
|
145
|
+
peerAgent(address: string, prompt: string): Promise<AgentResult>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** personal Namespace — Identity/Keystore-Management. */
|
|
149
|
+
declare class Personal {
|
|
150
|
+
private readonly provider;
|
|
151
|
+
constructor(provider: Provider);
|
|
152
|
+
/** Neue Identität erstellen und im Keystore speichern. */
|
|
153
|
+
newIdentity(password: string): Promise<{
|
|
154
|
+
address: string;
|
|
155
|
+
path: string;
|
|
156
|
+
}>;
|
|
157
|
+
/** Alle Identitäten im Keystore auflisten. */
|
|
158
|
+
listIdentities(): Promise<{
|
|
159
|
+
identities: IdentityInfo[];
|
|
160
|
+
}>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** agent Namespace — Lokaler AI-Agent. */
|
|
164
|
+
declare class Agent {
|
|
165
|
+
private readonly provider;
|
|
166
|
+
constructor(provider: Provider);
|
|
167
|
+
/** Agent-Loop mit einem Prompt ausführen. */
|
|
168
|
+
run(input: string): Promise<AgentResult>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** mempool Namespace — Transaction Mempool. */
|
|
172
|
+
declare class Mempool {
|
|
173
|
+
private readonly provider;
|
|
174
|
+
constructor(provider: Provider);
|
|
175
|
+
/** Nachricht ans Netzwerk broadcasten (GossipSub). */
|
|
176
|
+
broadcast(message: string): Promise<{
|
|
177
|
+
sent: boolean;
|
|
178
|
+
taskId: string;
|
|
179
|
+
}>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* GenNet Client — Hauptklasse für die Interaktion mit einem GenNet-Node.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const gennet = new GenNet('ws://localhost:18789');
|
|
188
|
+
* await gennet.connect();
|
|
189
|
+
*
|
|
190
|
+
* const info = await gennet.admin.nodeInfo();
|
|
191
|
+
* const peers = await gennet.net.peers();
|
|
192
|
+
* await gennet.net.send('0x...', 'Hello');
|
|
193
|
+
*
|
|
194
|
+
* const sub = await gennet.subscribe('messages', (data) => console.log(data));
|
|
195
|
+
* await sub.unsubscribe();
|
|
196
|
+
*
|
|
197
|
+
* gennet.disconnect();
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
declare class GenNet {
|
|
201
|
+
readonly admin: Admin;
|
|
202
|
+
readonly net: Net;
|
|
203
|
+
readonly personal: Personal;
|
|
204
|
+
readonly agent: Agent;
|
|
205
|
+
readonly mempool: Mempool;
|
|
206
|
+
private readonly provider;
|
|
207
|
+
constructor(providerOrUrl: string | Provider);
|
|
208
|
+
/** Verbindung herstellen (nur bei WebSocket nötig). */
|
|
209
|
+
connect(): Promise<void>;
|
|
210
|
+
/** Verbindung schließen. */
|
|
211
|
+
disconnect(): void;
|
|
212
|
+
/** Ob eine aktive Verbindung besteht. */
|
|
213
|
+
get connected(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Subscription starten (nur WebSocket).
|
|
216
|
+
* Topics: 'logs', 'messages', 'mempool'.
|
|
217
|
+
*/
|
|
218
|
+
subscribe(topic: SubscriptionTopic, callback: (data: unknown) => void): Promise<Subscription>;
|
|
219
|
+
/** Raw JSON-RPC Request (für erweiterte Nutzung). */
|
|
220
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
221
|
+
private static createProvider;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* WebSocket Provider — nutzt native WebSocket API (Browser + Node 22+).
|
|
226
|
+
* Unterstützt Subscriptions via Push-Notifications.
|
|
227
|
+
*/
|
|
228
|
+
declare class WebSocketProvider implements Provider {
|
|
229
|
+
private readonly url;
|
|
230
|
+
private readonly timeout;
|
|
231
|
+
private ws;
|
|
232
|
+
private requestId;
|
|
233
|
+
private pending;
|
|
234
|
+
private listeners;
|
|
235
|
+
private connectPromise;
|
|
236
|
+
constructor(url: string, timeout?: number);
|
|
237
|
+
get connected(): boolean;
|
|
238
|
+
connect(): Promise<void>;
|
|
239
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
240
|
+
on(_event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
241
|
+
off(_event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
242
|
+
disconnect(): void;
|
|
243
|
+
private handleMessage;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* HTTP Provider — fetch-basiert, browser-kompatibel.
|
|
248
|
+
* Unterstützt keine Subscriptions (kein Push-Kanal).
|
|
249
|
+
*/
|
|
250
|
+
declare class HttpProvider implements Provider {
|
|
251
|
+
private readonly url;
|
|
252
|
+
constructor(url: string);
|
|
253
|
+
get connected(): boolean;
|
|
254
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
255
|
+
on(_event: 'notification', _listener: (notification: JsonRpcNotification) => void): void;
|
|
256
|
+
off(_event: 'notification', _listener: (notification: JsonRpcNotification) => void): void;
|
|
257
|
+
disconnect(): void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { Admin, Agent, GenNet, HttpProvider, Mempool, Net, Personal, RpcError, WebSocketProvider };
|
|
261
|
+
export type { AgentResult, GatewayState, IdentityInfo, JsonRpcErrorResponse, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, ModuleInfo, NodeInfo, PeerInfo, Provider, Subscription, SubscriptionTopic };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
interface JsonRpcRequest {
|
|
2
|
+
jsonrpc: '2.0';
|
|
3
|
+
id: string | number;
|
|
4
|
+
method: string;
|
|
5
|
+
params?: Record<string, unknown> | unknown[];
|
|
6
|
+
}
|
|
7
|
+
interface JsonRpcSuccessResponse {
|
|
8
|
+
jsonrpc: '2.0';
|
|
9
|
+
id: string | number;
|
|
10
|
+
result: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface JsonRpcErrorResponse {
|
|
13
|
+
jsonrpc: '2.0';
|
|
14
|
+
id: string | number;
|
|
15
|
+
error: {
|
|
16
|
+
code: number;
|
|
17
|
+
message: string;
|
|
18
|
+
data?: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
|
|
22
|
+
interface JsonRpcNotification {
|
|
23
|
+
jsonrpc: '2.0';
|
|
24
|
+
method: string;
|
|
25
|
+
params: {
|
|
26
|
+
subscription: string;
|
|
27
|
+
result: unknown;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
declare class RpcError extends Error {
|
|
31
|
+
readonly code: number;
|
|
32
|
+
readonly data?: unknown;
|
|
33
|
+
constructor(message: string, code: number, data?: unknown);
|
|
34
|
+
}
|
|
35
|
+
type GatewayState = 'INITIALIZING' | 'READY' | 'RUNNING' | 'STOPPED';
|
|
36
|
+
interface ModuleInfo {
|
|
37
|
+
name: string;
|
|
38
|
+
version: string;
|
|
39
|
+
state: string;
|
|
40
|
+
status?: string;
|
|
41
|
+
}
|
|
42
|
+
interface NodeInfo {
|
|
43
|
+
state: GatewayState;
|
|
44
|
+
peerId: string | null;
|
|
45
|
+
address: string;
|
|
46
|
+
peers: number;
|
|
47
|
+
knownPeers: number;
|
|
48
|
+
uptime: number;
|
|
49
|
+
multiaddrs: string[];
|
|
50
|
+
tcpAddrs: string[];
|
|
51
|
+
circuitAddrs: string[];
|
|
52
|
+
relay: boolean;
|
|
53
|
+
listenPort: number;
|
|
54
|
+
datadir: string;
|
|
55
|
+
modules: ModuleInfo[];
|
|
56
|
+
}
|
|
57
|
+
interface PeerInfo {
|
|
58
|
+
peerId: string;
|
|
59
|
+
address: string;
|
|
60
|
+
multiaddr: string;
|
|
61
|
+
connected: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface AgentResult {
|
|
64
|
+
ok: boolean;
|
|
65
|
+
response?: string;
|
|
66
|
+
toolCalls?: Array<{
|
|
67
|
+
name: string;
|
|
68
|
+
}>;
|
|
69
|
+
tokensUsed?: {
|
|
70
|
+
input: number;
|
|
71
|
+
output: number;
|
|
72
|
+
};
|
|
73
|
+
error?: string;
|
|
74
|
+
}
|
|
75
|
+
interface IdentityInfo {
|
|
76
|
+
index: number;
|
|
77
|
+
address: string;
|
|
78
|
+
filename: string;
|
|
79
|
+
}
|
|
80
|
+
type SubscriptionTopic = 'logs' | 'messages' | 'mempool';
|
|
81
|
+
interface Subscription {
|
|
82
|
+
id: string;
|
|
83
|
+
unsubscribe: () => Promise<boolean>;
|
|
84
|
+
}
|
|
85
|
+
interface Provider {
|
|
86
|
+
/** JSON-RPC Request senden und auf Response warten. */
|
|
87
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
88
|
+
/** Listener für Push-Notifications (Subscriptions). */
|
|
89
|
+
on(event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
90
|
+
/** Listener entfernen. */
|
|
91
|
+
off(event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
92
|
+
/** Verbindung schließen. */
|
|
93
|
+
disconnect(): void;
|
|
94
|
+
/** Verbindung herstellen (bei WebSocket). */
|
|
95
|
+
connect?(): Promise<void>;
|
|
96
|
+
/** Ob eine aktive Verbindung besteht. */
|
|
97
|
+
readonly connected: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** admin Namespace — Node-Administration. */
|
|
101
|
+
declare class Admin {
|
|
102
|
+
private readonly provider;
|
|
103
|
+
constructor(provider: Provider);
|
|
104
|
+
/** Node-Info: Status, PeerId, Adresse, Peers, Uptime, Module. */
|
|
105
|
+
nodeInfo(): Promise<NodeInfo>;
|
|
106
|
+
/** Gateway herunterfahren. */
|
|
107
|
+
shutdown(): Promise<{
|
|
108
|
+
ok: boolean;
|
|
109
|
+
}>;
|
|
110
|
+
/** Alle Module und ihren Status auflisten. */
|
|
111
|
+
modules(): Promise<{
|
|
112
|
+
modules: ModuleInfo[];
|
|
113
|
+
}>;
|
|
114
|
+
/** Ein Modul starten. */
|
|
115
|
+
startModule(name: string): Promise<{
|
|
116
|
+
name: string;
|
|
117
|
+
state: string;
|
|
118
|
+
}>;
|
|
119
|
+
/** Ein Modul stoppen. */
|
|
120
|
+
stopModule(name: string): Promise<{
|
|
121
|
+
name: string;
|
|
122
|
+
state: string;
|
|
123
|
+
}>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** net Namespace — P2P-Netzwerk. */
|
|
127
|
+
declare class Net {
|
|
128
|
+
private readonly provider;
|
|
129
|
+
constructor(provider: Provider);
|
|
130
|
+
/** Alle bekannten Peers auflisten. */
|
|
131
|
+
peers(): Promise<{
|
|
132
|
+
peers: PeerInfo[];
|
|
133
|
+
}>;
|
|
134
|
+
/** Mit einem Peer über Multiaddr verbinden. */
|
|
135
|
+
connect(multiaddr: string): Promise<{
|
|
136
|
+
peerId: string;
|
|
137
|
+
connected: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
/** Verschlüsselte Nachricht an einen Peer senden. */
|
|
140
|
+
send(address: string, text: string): Promise<{
|
|
141
|
+
sent: boolean;
|
|
142
|
+
to: string;
|
|
143
|
+
}>;
|
|
144
|
+
/** Agent-Prompt auf einem Remote-Peer ausführen (ECIES-verschlüsselt). */
|
|
145
|
+
peerAgent(address: string, prompt: string): Promise<AgentResult>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** personal Namespace — Identity/Keystore-Management. */
|
|
149
|
+
declare class Personal {
|
|
150
|
+
private readonly provider;
|
|
151
|
+
constructor(provider: Provider);
|
|
152
|
+
/** Neue Identität erstellen und im Keystore speichern. */
|
|
153
|
+
newIdentity(password: string): Promise<{
|
|
154
|
+
address: string;
|
|
155
|
+
path: string;
|
|
156
|
+
}>;
|
|
157
|
+
/** Alle Identitäten im Keystore auflisten. */
|
|
158
|
+
listIdentities(): Promise<{
|
|
159
|
+
identities: IdentityInfo[];
|
|
160
|
+
}>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** agent Namespace — Lokaler AI-Agent. */
|
|
164
|
+
declare class Agent {
|
|
165
|
+
private readonly provider;
|
|
166
|
+
constructor(provider: Provider);
|
|
167
|
+
/** Agent-Loop mit einem Prompt ausführen. */
|
|
168
|
+
run(input: string): Promise<AgentResult>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** mempool Namespace — Transaction Mempool. */
|
|
172
|
+
declare class Mempool {
|
|
173
|
+
private readonly provider;
|
|
174
|
+
constructor(provider: Provider);
|
|
175
|
+
/** Nachricht ans Netzwerk broadcasten (GossipSub). */
|
|
176
|
+
broadcast(message: string): Promise<{
|
|
177
|
+
sent: boolean;
|
|
178
|
+
taskId: string;
|
|
179
|
+
}>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* GenNet Client — Hauptklasse für die Interaktion mit einem GenNet-Node.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const gennet = new GenNet('ws://localhost:18789');
|
|
188
|
+
* await gennet.connect();
|
|
189
|
+
*
|
|
190
|
+
* const info = await gennet.admin.nodeInfo();
|
|
191
|
+
* const peers = await gennet.net.peers();
|
|
192
|
+
* await gennet.net.send('0x...', 'Hello');
|
|
193
|
+
*
|
|
194
|
+
* const sub = await gennet.subscribe('messages', (data) => console.log(data));
|
|
195
|
+
* await sub.unsubscribe();
|
|
196
|
+
*
|
|
197
|
+
* gennet.disconnect();
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
declare class GenNet {
|
|
201
|
+
readonly admin: Admin;
|
|
202
|
+
readonly net: Net;
|
|
203
|
+
readonly personal: Personal;
|
|
204
|
+
readonly agent: Agent;
|
|
205
|
+
readonly mempool: Mempool;
|
|
206
|
+
private readonly provider;
|
|
207
|
+
constructor(providerOrUrl: string | Provider);
|
|
208
|
+
/** Verbindung herstellen (nur bei WebSocket nötig). */
|
|
209
|
+
connect(): Promise<void>;
|
|
210
|
+
/** Verbindung schließen. */
|
|
211
|
+
disconnect(): void;
|
|
212
|
+
/** Ob eine aktive Verbindung besteht. */
|
|
213
|
+
get connected(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Subscription starten (nur WebSocket).
|
|
216
|
+
* Topics: 'logs', 'messages', 'mempool'.
|
|
217
|
+
*/
|
|
218
|
+
subscribe(topic: SubscriptionTopic, callback: (data: unknown) => void): Promise<Subscription>;
|
|
219
|
+
/** Raw JSON-RPC Request (für erweiterte Nutzung). */
|
|
220
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
221
|
+
private static createProvider;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* WebSocket Provider — nutzt native WebSocket API (Browser + Node 22+).
|
|
226
|
+
* Unterstützt Subscriptions via Push-Notifications.
|
|
227
|
+
*/
|
|
228
|
+
declare class WebSocketProvider implements Provider {
|
|
229
|
+
private readonly url;
|
|
230
|
+
private readonly timeout;
|
|
231
|
+
private ws;
|
|
232
|
+
private requestId;
|
|
233
|
+
private pending;
|
|
234
|
+
private listeners;
|
|
235
|
+
private connectPromise;
|
|
236
|
+
constructor(url: string, timeout?: number);
|
|
237
|
+
get connected(): boolean;
|
|
238
|
+
connect(): Promise<void>;
|
|
239
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
240
|
+
on(_event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
241
|
+
off(_event: 'notification', listener: (notification: JsonRpcNotification) => void): void;
|
|
242
|
+
disconnect(): void;
|
|
243
|
+
private handleMessage;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* HTTP Provider — fetch-basiert, browser-kompatibel.
|
|
248
|
+
* Unterstützt keine Subscriptions (kein Push-Kanal).
|
|
249
|
+
*/
|
|
250
|
+
declare class HttpProvider implements Provider {
|
|
251
|
+
private readonly url;
|
|
252
|
+
constructor(url: string);
|
|
253
|
+
get connected(): boolean;
|
|
254
|
+
request(method: string, params?: Record<string, unknown> | unknown[]): Promise<unknown>;
|
|
255
|
+
on(_event: 'notification', _listener: (notification: JsonRpcNotification) => void): void;
|
|
256
|
+
off(_event: 'notification', _listener: (notification: JsonRpcNotification) => void): void;
|
|
257
|
+
disconnect(): void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { Admin, Agent, GenNet, HttpProvider, Mempool, Net, Personal, RpcError, WebSocketProvider };
|
|
261
|
+
export type { AgentResult, GatewayState, IdentityInfo, JsonRpcErrorResponse, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, ModuleInfo, NodeInfo, PeerInfo, Provider, Subscription, SubscriptionTopic };
|