@monolythium/core-sdk 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/LICENSE +204 -0
- package/README.md +200 -0
- package/dist/client-CpnpVkrR.d.cts +2237 -0
- package/dist/client-CpnpVkrR.d.ts +2237 -0
- package/dist/crypto/index.cjs +593 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +166 -0
- package/dist/crypto/index.d.ts +166 -0
- package/dist/crypto/index.js +542 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/index.cjs +2285 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +949 -0
- package/dist/index.d.ts +949 -0
- package/dist/index.js +2214 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,949 @@
|
|
|
1
|
+
import { O as OperatorCapabilitiesResponse, R as RuntimeBuildProvenance, a as RuntimeUpgradeStatus, S as SearchResponse, C as ChainStatsResponse, B as BlockSelector, T as TxFeedResponse, A as AddressProfileResponse, b as AddressFlowResponse, c as ServiceProbeResponse, d as ClobMarketsResponse, e as ClobMarketResponse, f as ClobTradesResponse, g as ClobOhlcResponse, h as ClobOrderBookResponse, i as RpcClient, j as RpcClientOptions, k as TransactionReceipt, l as CallRequest } from './client-CpnpVkrR.js';
|
|
2
|
+
export { m as AccountPolicy, n as AccountProofResponse, o as Address, p as AddressActivityArchiveRedirect, q as AddressActivityEntry, r as AddressActivityKind, s as AddressActivityKindResponse, t as AddressActivityKindRetention, u as AddressLabelRecord, v as AssetPolicy, w as AttestationWindow, x as BlockHeader, y as BlockTag, z as BlsCertificateResponse, D as CHAIN_REGISTRY, E as CHAIN_REGISTRY_RAW_BASE, F as CapabilitiesResponse, G as CapabilityDescriptor, H as ChainInfo, I as ChainRegistry, J as CheckpointRecord, K as ClobMarketRecord, L as ClobMarketSummary, M as ClobTrade, N as ClusterDelegatorsResponse, P as ClusterDirectoryEntryResponse, Q as ClusterDirectoryPageResponse, U as ClusterEntityResponse, V as ClusterMemberResponse, W as ClusterResignationRow, X as ClusterResignationsResponse, Y as ClusterStatusResponse, Z as DagParent, _ as DagParentsResponse, $ as DagSyncStatus, a0 as DecodeTxLog, a1 as DecodeTxPqAttestation, a2 as DecodeTxResponse, a3 as DelegationCapResponse, a4 as DelegationHistoryRecord, a5 as DelegationRow, a6 as DelegationsResponse, a7 as DutyAbsence, a8 as EncryptionKeyResponse, a9 as EntityRatchetResponse, aa as ExplorerEndpoint, ab as FeeHistoryResponse, ac as GapRange, ad as GapRecord, ae as GapRecordsResponse, af as Hash, ag as Hex, ah as IndexerStatus, ai as JailStatusWindow, aj as KeyRotationWindow, ak as LythUpgradePlanStatus, al as LythUpgradeStatusResponse, am as MempoolSnapshot, an as MeshDecodedTx, ao as MeshSignedTxResponse, ap as MeshTxIntent, aq as MeshUnsignedTxResponse, ar as MetricsRangeResponse, as as MetricsRangeSample, at as MetricsRangeSeries, au as MetricsRangeStatus, av as NetworkClientOptions, aw as NetworkSlug, ax as OperatorAuthorityResponse, ay as OperatorInfoResponse, az as OperatorRiskResponse, aA as OperatorSigningActivityResponse, aB as OperatorSigningEntry, aC as OperatorSurfaceCapability, aD as OperatorSurfaceStatus, aE as P2pSeed, aF as PeerSummary, aG as PeerSummaryAggregate, aH as PendingTxSummary, aI as PrecompileCatalogueResponse, aJ as PrecompileDescriptor, aK as Quantity, aL as RegistryRecord, aM as ReportServiceProbeRequest, aN as ReportServiceProbeResponse, aO as RichListHolder, aP as RichListResponse, aQ as RoundInfo, aR as RpcEndpoint, aS as RuntimeProvenanceResponse, aT as SearchHit, aU as ServiceProbeStatusLabel, aV as SigningEntryStatus, aW as StorageProofBatch, aX as SyncStatus, aY as TESTNET_69420, aZ as TokenBalanceRecord, a_ as TpmAttestationResponse, a$ as TransactionView, b0 as TxFeedReceipt, b1 as TxFeedTransaction, b2 as TxStatusFoundResponse, b3 as TxStatusNotFoundResponse, b4 as TxStatusResponse, b5 as UpcomingDutiesResponse, b6 as UpcomingDutyMap, b7 as VertexAtRound, b8 as VerticesAtRoundResponse, b9 as encodeBlockSelector, ba as fetchChainInfoLatest, bb as fetchChainRegistryLatest, bc as getChainInfo, bd as getP2pSeeds, be as getRpcEndpoints, bf as parseChainRegistryToml, bg as parseQuantity, bh as parseQuantityBig } from './client-CpnpVkrR.js';
|
|
3
|
+
import { JsonRpcApiProvider, JsonRpcPayload, JsonRpcResult, JsonRpcError, AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField, BaseWallet, Signer } from 'ethers';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Typed HTTP client for the explorer-facing `/api/v1` surface served by
|
|
7
|
+
* `mono-core`.
|
|
8
|
+
*
|
|
9
|
+
* JSON-RPC stays on `RpcClient`; this class is for REST-shaped node API
|
|
10
|
+
* routes used by explorers, wallets, and status pages.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface ApiClientOptions {
|
|
14
|
+
/** Override `fetch`. Useful for tests or non-browser runtimes. */
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
/** Extra headers to attach to every request. */
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
/** Explicit `/api/v1` base URL. Defaults to deriving it from the RPC URL. */
|
|
19
|
+
apiBaseUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
interface ApiErrorEnvelope {
|
|
22
|
+
schemaVersion?: number;
|
|
23
|
+
error: {
|
|
24
|
+
code: number;
|
|
25
|
+
message: string;
|
|
26
|
+
data?: unknown;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface ApiLatestAnchor {
|
|
30
|
+
available: boolean;
|
|
31
|
+
height?: number;
|
|
32
|
+
blockHash?: string | null;
|
|
33
|
+
stateRoot?: string;
|
|
34
|
+
timestamp?: number;
|
|
35
|
+
error?: {
|
|
36
|
+
code: number;
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface ApiEnvelope<T> {
|
|
41
|
+
schemaVersion: number;
|
|
42
|
+
chainId: number;
|
|
43
|
+
genesisHash: string | null;
|
|
44
|
+
latest: ApiLatestAnchor;
|
|
45
|
+
data: T;
|
|
46
|
+
}
|
|
47
|
+
interface ApiHealthResponse {
|
|
48
|
+
schemaVersion: number;
|
|
49
|
+
status: "ok" | "syncing" | string;
|
|
50
|
+
chainId: number;
|
|
51
|
+
latest: ApiLatestAnchor;
|
|
52
|
+
api: {
|
|
53
|
+
enabled: boolean;
|
|
54
|
+
version: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
interface ApiIndexerStatus {
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
currentHeight?: number;
|
|
60
|
+
latestHeight?: number | null;
|
|
61
|
+
schemaVersion?: number;
|
|
62
|
+
retention?: unknown;
|
|
63
|
+
error?: {
|
|
64
|
+
code: number;
|
|
65
|
+
message: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
interface ApiCapabilitiesResponse {
|
|
69
|
+
schemaVersion: number;
|
|
70
|
+
chainId: number;
|
|
71
|
+
genesisHash: string | null;
|
|
72
|
+
clientVersion: string;
|
|
73
|
+
latest: ApiLatestAnchor;
|
|
74
|
+
api: {
|
|
75
|
+
enabled: boolean;
|
|
76
|
+
version: string;
|
|
77
|
+
docs: string;
|
|
78
|
+
openapi: string;
|
|
79
|
+
};
|
|
80
|
+
jsonRpc: {
|
|
81
|
+
endpoint: string;
|
|
82
|
+
webSocket: string;
|
|
83
|
+
protocolVersion: string;
|
|
84
|
+
debugEnabled: boolean;
|
|
85
|
+
};
|
|
86
|
+
streams: {
|
|
87
|
+
transport: "sse" | string;
|
|
88
|
+
index: string;
|
|
89
|
+
topicEndpoint: string;
|
|
90
|
+
keepAliveSeconds: number;
|
|
91
|
+
};
|
|
92
|
+
indexer: ApiIndexerStatus;
|
|
93
|
+
rateLimit: {
|
|
94
|
+
perIp: {
|
|
95
|
+
ratePerSec: number;
|
|
96
|
+
burst: number;
|
|
97
|
+
};
|
|
98
|
+
apiKeysConfigured: boolean;
|
|
99
|
+
apiKeyOverrideCount: number;
|
|
100
|
+
budgetIdentity: "api_key_or_resolved_client_ip" | string;
|
|
101
|
+
defaultCostBudgetPerMin: number;
|
|
102
|
+
retryAfterHeader: boolean;
|
|
103
|
+
costWeights: {
|
|
104
|
+
api: Record<string, number>;
|
|
105
|
+
jsonRpc: Record<string, number>;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
operatorCapabilities: {
|
|
109
|
+
jsonRpcMethod: "lyth_operatorCapabilities" | string;
|
|
110
|
+
schemaVersion: number | null;
|
|
111
|
+
surfaces: OperatorCapabilitiesResponse["surfaces"];
|
|
112
|
+
};
|
|
113
|
+
accessPolicy: {
|
|
114
|
+
trustedProxy: {
|
|
115
|
+
configured: boolean;
|
|
116
|
+
cidrCount: number;
|
|
117
|
+
};
|
|
118
|
+
clientCidr: {
|
|
119
|
+
unrestricted: boolean;
|
|
120
|
+
allowCidrCount: number;
|
|
121
|
+
denyCidrCount: number;
|
|
122
|
+
};
|
|
123
|
+
paidServiceEligibility: {
|
|
124
|
+
source: "external_probe" | string;
|
|
125
|
+
selfDeclaration: boolean;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
interface ApiBlockHeader {
|
|
130
|
+
height: number;
|
|
131
|
+
blockHash: string;
|
|
132
|
+
parentHash: string;
|
|
133
|
+
stateRoot: string;
|
|
134
|
+
timestamp: number;
|
|
135
|
+
gasUsed: number;
|
|
136
|
+
gasLimit: number;
|
|
137
|
+
baseFeePerGas: string;
|
|
138
|
+
}
|
|
139
|
+
interface ApiLogEntry {
|
|
140
|
+
address: string;
|
|
141
|
+
topics: string[];
|
|
142
|
+
data: string;
|
|
143
|
+
}
|
|
144
|
+
interface ApiTransactionView {
|
|
145
|
+
txHash: string;
|
|
146
|
+
blockHash: string;
|
|
147
|
+
blockHeight: number;
|
|
148
|
+
txIndex: number;
|
|
149
|
+
from: string;
|
|
150
|
+
to: string | null;
|
|
151
|
+
nonce: number;
|
|
152
|
+
value: string;
|
|
153
|
+
maxFeePerGas: string;
|
|
154
|
+
maxPriorityFeePerGas: string;
|
|
155
|
+
gasLimit: number;
|
|
156
|
+
input: string;
|
|
157
|
+
signedEnvelope: string;
|
|
158
|
+
}
|
|
159
|
+
interface ApiTransactionReceipt {
|
|
160
|
+
txHash: string;
|
|
161
|
+
blockHash: string;
|
|
162
|
+
blockHeight: number;
|
|
163
|
+
txIndex: number;
|
|
164
|
+
status: number;
|
|
165
|
+
gasUsed: number;
|
|
166
|
+
logs: ApiLogEntry[];
|
|
167
|
+
}
|
|
168
|
+
interface ApiAddressActivityEntry {
|
|
169
|
+
blockHeight: number;
|
|
170
|
+
txIndex: number;
|
|
171
|
+
logIndex: number;
|
|
172
|
+
kind: "transfer" | "swap" | "staking" | "delegation" | string;
|
|
173
|
+
direction: "in" | "out" | string | null;
|
|
174
|
+
counterparty: string | null;
|
|
175
|
+
tokenId: string | null;
|
|
176
|
+
amount: string | null;
|
|
177
|
+
cluster: number | null;
|
|
178
|
+
weightBps: number | null;
|
|
179
|
+
subKind: string | null;
|
|
180
|
+
}
|
|
181
|
+
interface ApiBlockData {
|
|
182
|
+
block: ApiBlockHeader;
|
|
183
|
+
transactionCount: number;
|
|
184
|
+
transactionHashes: string[];
|
|
185
|
+
source: {
|
|
186
|
+
chainProvider: string;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
interface ApiBlockTransactionsData {
|
|
190
|
+
block: ApiBlockHeader;
|
|
191
|
+
page: number;
|
|
192
|
+
limit: number;
|
|
193
|
+
totalTransactions: number;
|
|
194
|
+
transactions: ApiTransactionView[];
|
|
195
|
+
source: {
|
|
196
|
+
chainProvider: string;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
interface ApiTransactionData {
|
|
200
|
+
transaction: ApiTransactionView;
|
|
201
|
+
receipt: ApiTransactionReceipt | null;
|
|
202
|
+
source: {
|
|
203
|
+
chainProvider: string;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
interface ApiTransactionReceiptData {
|
|
207
|
+
receipt: ApiTransactionReceipt;
|
|
208
|
+
source: {
|
|
209
|
+
chainProvider: string;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
interface ApiAddressActivityData {
|
|
213
|
+
address: string;
|
|
214
|
+
limit: number;
|
|
215
|
+
entries: ApiAddressActivityEntry[];
|
|
216
|
+
indexer: ApiIndexerStatus;
|
|
217
|
+
}
|
|
218
|
+
type ApiAddressActivityKind = "found" | "not_found" | "indexer_disabled" | "pruned" | "private" | string;
|
|
219
|
+
interface ApiAddressActivityKindSummary {
|
|
220
|
+
kind: ApiAddressActivityKind;
|
|
221
|
+
retention?: unknown;
|
|
222
|
+
}
|
|
223
|
+
interface ApiAddressActivityKindData {
|
|
224
|
+
address: string;
|
|
225
|
+
activity: ApiAddressActivityKindSummary;
|
|
226
|
+
indexer: ApiIndexerStatus;
|
|
227
|
+
}
|
|
228
|
+
interface ApiClusterDirectoryEntry {
|
|
229
|
+
clusterId: number;
|
|
230
|
+
size: number;
|
|
231
|
+
threshold: number;
|
|
232
|
+
aggregateHealth: string;
|
|
233
|
+
regionDiversity: string[] | null;
|
|
234
|
+
active: boolean;
|
|
235
|
+
}
|
|
236
|
+
interface ApiClusterDirectoryPage {
|
|
237
|
+
page: number;
|
|
238
|
+
limit: number;
|
|
239
|
+
totalClusters: number;
|
|
240
|
+
clusters: ApiClusterDirectoryEntry[];
|
|
241
|
+
}
|
|
242
|
+
interface ApiClusterMember {
|
|
243
|
+
operatorId: string;
|
|
244
|
+
blsPubkey: string;
|
|
245
|
+
state: string;
|
|
246
|
+
}
|
|
247
|
+
interface ApiClusterStatus {
|
|
248
|
+
clusterId: number;
|
|
249
|
+
threshold: number;
|
|
250
|
+
size: number;
|
|
251
|
+
live: number;
|
|
252
|
+
lagging: number;
|
|
253
|
+
offline: number;
|
|
254
|
+
maintenance: number;
|
|
255
|
+
members: ApiClusterMember[];
|
|
256
|
+
epoch: number | null;
|
|
257
|
+
round: number | null;
|
|
258
|
+
quorum: string;
|
|
259
|
+
reputationScore: number | null;
|
|
260
|
+
livenessScore: number | null;
|
|
261
|
+
lastUpdateHeight: number;
|
|
262
|
+
}
|
|
263
|
+
interface ApiClustersData {
|
|
264
|
+
clusters: ApiClusterDirectoryPage;
|
|
265
|
+
source: {
|
|
266
|
+
registryProvider: string;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
interface ApiClusterData {
|
|
270
|
+
cluster: ApiClusterStatus;
|
|
271
|
+
source: {
|
|
272
|
+
registryProvider: string;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
interface ApiOperatorInfo {
|
|
276
|
+
operatorId: string;
|
|
277
|
+
moniker: string | null;
|
|
278
|
+
alias: string | null;
|
|
279
|
+
chainAddress: string;
|
|
280
|
+
bonded: boolean;
|
|
281
|
+
commissionBps: number | null;
|
|
282
|
+
delegationCount: number | null;
|
|
283
|
+
bondedAmount: string;
|
|
284
|
+
activeClusterIds: number[];
|
|
285
|
+
operatorKeyFingerprint: string | null;
|
|
286
|
+
blsKeyFingerprint: string | null;
|
|
287
|
+
lifecycleState: string;
|
|
288
|
+
capability: Record<string, unknown>;
|
|
289
|
+
}
|
|
290
|
+
interface ApiOperatorData {
|
|
291
|
+
operator: ApiOperatorInfo;
|
|
292
|
+
source: {
|
|
293
|
+
registryProvider: string;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
interface ApiServiceProbeData {
|
|
297
|
+
peerId: string;
|
|
298
|
+
serviceMask: number;
|
|
299
|
+
probe: ServiceProbeResponse | null;
|
|
300
|
+
source: {
|
|
301
|
+
registryProvider: string;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
interface ApiUpgradePlanStatus {
|
|
305
|
+
upgradeId: string;
|
|
306
|
+
activationHeight: number;
|
|
307
|
+
activationRound: number | null;
|
|
308
|
+
requiredBinaryVersion: string;
|
|
309
|
+
expectedBinaryDigest: string;
|
|
310
|
+
p2pProtocolVersion: number;
|
|
311
|
+
requiredFeatures: string[];
|
|
312
|
+
milestoneFileDigest: string | null;
|
|
313
|
+
stateMigrationId: string | null;
|
|
314
|
+
stateMigrationHash: string | null;
|
|
315
|
+
}
|
|
316
|
+
interface ApiUpgradeStatus {
|
|
317
|
+
blockHeight: number;
|
|
318
|
+
configured: boolean;
|
|
319
|
+
planCount: number;
|
|
320
|
+
active: ApiUpgradePlanStatus | null;
|
|
321
|
+
pending: ApiUpgradePlanStatus[];
|
|
322
|
+
}
|
|
323
|
+
interface ApiUpgradeStatusData {
|
|
324
|
+
upgrade: ApiUpgradeStatus;
|
|
325
|
+
source: {
|
|
326
|
+
chainProvider: string;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
interface ApiRuntimeProvenanceData {
|
|
330
|
+
runtime: RuntimeBuildProvenance;
|
|
331
|
+
upgrade: RuntimeUpgradeStatus | null;
|
|
332
|
+
source: {
|
|
333
|
+
chainProvider: string;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
type ApiQueryValue = string | number | bigint | boolean | null | undefined;
|
|
337
|
+
declare function apiEndpointFromRpcEndpoint(endpoint: string): string;
|
|
338
|
+
declare class ApiClient {
|
|
339
|
+
#private;
|
|
340
|
+
readonly baseUrl: string;
|
|
341
|
+
constructor(endpoint: string, options?: ApiClientOptions);
|
|
342
|
+
get<T>(path: string, query?: Record<string, ApiQueryValue>): Promise<T>;
|
|
343
|
+
health(): Promise<ApiHealthResponse>;
|
|
344
|
+
capabilities(): Promise<ApiCapabilitiesResponse>;
|
|
345
|
+
provenance(): Promise<ApiEnvelope<ApiRuntimeProvenanceData>>;
|
|
346
|
+
search(query: string, limit?: number): Promise<ApiEnvelope<SearchResponse>>;
|
|
347
|
+
stats(): Promise<ApiEnvelope<ChainStatsResponse>>;
|
|
348
|
+
block(block?: BlockSelector): Promise<ApiEnvelope<ApiBlockData>>;
|
|
349
|
+
blockTransactions(block?: BlockSelector, page?: number, limit?: number): Promise<ApiEnvelope<ApiBlockTransactionsData>>;
|
|
350
|
+
transactions(limit?: number, cursor?: string | null): Promise<ApiEnvelope<TxFeedResponse>>;
|
|
351
|
+
transaction(hash: string): Promise<ApiEnvelope<ApiTransactionData>>;
|
|
352
|
+
transactionReceipt(hash: string): Promise<ApiEnvelope<ApiTransactionReceiptData>>;
|
|
353
|
+
addressProfile(address: string): Promise<ApiEnvelope<AddressProfileResponse>>;
|
|
354
|
+
addressFlow(address: string, limit?: number): Promise<ApiEnvelope<AddressFlowResponse>>;
|
|
355
|
+
addressActivity(address: string, limit?: number, cursor?: string | null): Promise<ApiEnvelope<ApiAddressActivityData>>;
|
|
356
|
+
addressActivityKind(address: string): Promise<ApiEnvelope<ApiAddressActivityKindData>>;
|
|
357
|
+
clusters(page?: number, limit?: number): Promise<ApiEnvelope<ApiClustersData>>;
|
|
358
|
+
cluster(clusterId: number): Promise<ApiEnvelope<ApiClusterData>>;
|
|
359
|
+
operator(operatorId: string): Promise<ApiEnvelope<ApiOperatorData>>;
|
|
360
|
+
serviceProbe(peerId: string, serviceMask: number | string): Promise<ApiEnvelope<ApiServiceProbeData>>;
|
|
361
|
+
markets(limit?: number): Promise<ApiEnvelope<ClobMarketsResponse>>;
|
|
362
|
+
market(marketId: string): Promise<ApiEnvelope<ClobMarketResponse>>;
|
|
363
|
+
marketTrades(marketId: string, limit?: number, cursor?: string | null): Promise<ApiEnvelope<ClobTradesResponse>>;
|
|
364
|
+
marketOhlc(marketId: string, fromBlock?: number | bigint | null, toBlock?: number | bigint | null, bucketBlocks?: number | bigint | null): Promise<ApiEnvelope<ClobOhlcResponse>>;
|
|
365
|
+
marketOrderBook(marketId: string, levels?: number): Promise<ApiEnvelope<ClobOrderBookResponse>>;
|
|
366
|
+
upgradeStatus(height?: BlockSelector | null): Promise<ApiEnvelope<ApiUpgradeStatusData>>;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Error surfaced by `RpcClient`. Distinguishes transport failures
|
|
371
|
+
* (HTTP errors, network), protocol errors (JSON-RPC `error` envelopes),
|
|
372
|
+
* and shape mismatches.
|
|
373
|
+
*/
|
|
374
|
+
declare class SdkError extends Error {
|
|
375
|
+
readonly kind: "transport" | "rpc" | "malformed" | "endpoint";
|
|
376
|
+
readonly code?: number;
|
|
377
|
+
readonly data?: unknown;
|
|
378
|
+
constructor(kind: "transport" | "rpc" | "malformed" | "endpoint", message: string, opts?: {
|
|
379
|
+
code?: number;
|
|
380
|
+
data?: unknown;
|
|
381
|
+
cause?: unknown;
|
|
382
|
+
});
|
|
383
|
+
static transport(message: string, cause?: unknown): SdkError;
|
|
384
|
+
static rpc(code: number, message: string, data?: unknown): SdkError;
|
|
385
|
+
static malformed(message: string): SdkError;
|
|
386
|
+
static endpoint(message: string): SdkError;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Canonical chain constants exported from `@monolythium/core-sdk`.
|
|
391
|
+
*
|
|
392
|
+
* These values are sourced from the mono-core runtime — never hand-pick
|
|
393
|
+
* a different address or pretend the burn destination lives elsewhere.
|
|
394
|
+
* Cross-references below cite the runtime files that own each value.
|
|
395
|
+
*/
|
|
396
|
+
/**
|
|
397
|
+
* EIP-1559 base-fee burn destination (Law §5.2).
|
|
398
|
+
*
|
|
399
|
+
* Every base-fee unit consumed by a transaction is sent to this address
|
|
400
|
+
* and removed from circulating supply. The address is the canonical
|
|
401
|
+
* zero address — there is no private key for it on any chain, so funds
|
|
402
|
+
* routed here are unrecoverable by construction.
|
|
403
|
+
*
|
|
404
|
+
* Surfaces (wallets, explorers, dashboards) display burn balances by
|
|
405
|
+
* reading the balance of `BURN_ADDR` directly; do not roll a separate
|
|
406
|
+
* "treasury" representation for burnt fees.
|
|
407
|
+
*/
|
|
408
|
+
declare const BURN_ADDR: "0x0000000000000000000000000000000000000000";
|
|
409
|
+
/**
|
|
410
|
+
* SDK-exposed precompile address map (whitepaper v4.0).
|
|
411
|
+
*
|
|
412
|
+
* Sourced from `mono-core` runtime/precompile constants and pinned here
|
|
413
|
+
* so surfaces can render precompile traffic by name without
|
|
414
|
+
* re-defining low-band address literals.
|
|
415
|
+
*
|
|
416
|
+
* `0x1002` and `0x1006` are intentionally absent from the SDK surface
|
|
417
|
+
* because whitepaper v4.0 does not define those application surfaces.
|
|
418
|
+
*/
|
|
419
|
+
declare const PRECOMPILE_ADDRESSES: {
|
|
420
|
+
/** Native fungible-token factory — non-gateable, foundational. */
|
|
421
|
+
readonly TOKEN_FACTORY: "0x0000000000000000000000000000000000001000";
|
|
422
|
+
/** Native central-limit order book — gateable. */
|
|
423
|
+
readonly CLOB: "0x0000000000000000000000000000000000001001";
|
|
424
|
+
/** Agent execution surface (zkML-gated, ADR-0011/ADR-0020) — gateable. */
|
|
425
|
+
readonly AGENT: "0x0000000000000000000000000000000000001003";
|
|
426
|
+
/** Account privacy policy + stealth/confidential ops — gateable. */
|
|
427
|
+
readonly PRIVACY: "0x0000000000000000000000000000000000001004";
|
|
428
|
+
/** Operator + RPC node registry — non-gateable consensus invariant. */
|
|
429
|
+
readonly NODE_REGISTRY: "0x0000000000000000000000000000000000001005";
|
|
430
|
+
/** IBC light-client + packet routing — gateable. */
|
|
431
|
+
readonly IBC: "0x0000000000000000000000000000000000001007";
|
|
432
|
+
/** Native zk-light-client bridge — gateable. */
|
|
433
|
+
readonly BRIDGE: "0x0000000000000000000000000000000000001008";
|
|
434
|
+
/** Decentralized multi-signer oracle (OI-0036) — non-gateable. */
|
|
435
|
+
readonly ORACLE: "0x0000000000000000000000000000000000001009";
|
|
436
|
+
/** Distributed delegation primitive (Stage E.5a, Law §7.6) — gateable. */
|
|
437
|
+
readonly DELEGATION: "0x000000000000000000000000000000000000100A";
|
|
438
|
+
/** One-time emergency-key registry (Law §5.4 / §2.9) — non-gateable. */
|
|
439
|
+
readonly EMERGENCY_KEY: "0x0000000000000000000000000000000000001100";
|
|
440
|
+
/** VRF precompile (Law §5.4 / §5.6). */
|
|
441
|
+
readonly VRF: "0x0000000000000000000000000000000000001101";
|
|
442
|
+
/** Streaming-payments primitive (Law §5.4 / §5.7) — gateable. */
|
|
443
|
+
readonly STREAMING_PAYMENTS: "0x0000000000000000000000000000000000001102";
|
|
444
|
+
/** Human-readable name registry (Law §5.4 / §5.8) — gateable. */
|
|
445
|
+
readonly NAME_REGISTRY: "0x0000000000000000000000000000000000001103";
|
|
446
|
+
/** Cluster-name registry. */
|
|
447
|
+
readonly CLUSTER_NAME_REGISTRY: "0x0000000000000000000000000000000000001104";
|
|
448
|
+
/** Agent-commerce attestation precompile. */
|
|
449
|
+
readonly ATTESTATION: "0x0000000000000000000000000000000000001105";
|
|
450
|
+
/** Agent-commerce consent precompile. */
|
|
451
|
+
readonly CONSENT: "0x0000000000000000000000000000000000001106";
|
|
452
|
+
/** Agent-commerce issuer registry. */
|
|
453
|
+
readonly ISSUER_REGISTRY: "0x0000000000000000000000000000000000001107";
|
|
454
|
+
/** Agent-commerce discovery precompile. */
|
|
455
|
+
readonly DISCOVERY: "0x0000000000000000000000000000000000001108";
|
|
456
|
+
/** Agent-commerce availability precompile. */
|
|
457
|
+
readonly AVAILABILITY: "0x0000000000000000000000000000000000001109";
|
|
458
|
+
/** Agent-commerce escrow precompile. */
|
|
459
|
+
readonly ESCROW: "0x000000000000000000000000000000000000110A";
|
|
460
|
+
/** Agent-commerce arbiter registry. */
|
|
461
|
+
readonly ARBITER_REGISTRY: "0x000000000000000000000000000000000000110B";
|
|
462
|
+
/** Agent spending policy — gateable, activated by Stage 7 milestones. */
|
|
463
|
+
readonly SPENDING_POLICY: "0x000000000000000000000000000000000000110C";
|
|
464
|
+
/** Primary ML-DSA-65 pubkey registry — gateable, ADR-0034. */
|
|
465
|
+
readonly PUBKEY_REGISTRY: "0x000000000000000000000000000000000000110D";
|
|
466
|
+
};
|
|
467
|
+
/** Precompile address-key type — useful for typed maps over the surface. */
|
|
468
|
+
type PrecompileName = keyof typeof PRECOMPILE_ADDRESSES;
|
|
469
|
+
/** Precompile address value type. */
|
|
470
|
+
type PrecompileAddress = (typeof PRECOMPILE_ADDRESSES)[PrecompileName];
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Node-registry precompile ABI helpers and service capability constants.
|
|
474
|
+
*
|
|
475
|
+
* These constants mirror `protocore-node-registry::capabilities` and
|
|
476
|
+
* `protocore-node-registry::abi`. They are exported for wallets,
|
|
477
|
+
* service probers, faucets, and operator dashboards that need to build
|
|
478
|
+
* canonical registry transactions without retyping low-level values.
|
|
479
|
+
*/
|
|
480
|
+
declare const NODE_REGISTRY_CAPABILITIES: {
|
|
481
|
+
readonly SERVES_RPC: 1;
|
|
482
|
+
readonly SERVES_INDEXER: 2;
|
|
483
|
+
readonly SERVES_BROADCASTER: 4;
|
|
484
|
+
readonly SERVES_ARCHIVE: 8;
|
|
485
|
+
readonly SERVES_WEBSOCKET: 16;
|
|
486
|
+
readonly SERVES_LIGHT_CLIENT: 32;
|
|
487
|
+
readonly SERVES_ORACLE_WRITER: 64;
|
|
488
|
+
readonly SERVES_BRIDGE_RELAY: 128;
|
|
489
|
+
readonly SERVES_PUBLIC_API: 256;
|
|
490
|
+
};
|
|
491
|
+
declare const NODE_REGISTRY_CAPABILITY_MASK = 65535;
|
|
492
|
+
declare const NODE_REGISTRY_PUBLIC_SERVICE_MASK: number;
|
|
493
|
+
declare const SERVICE_PROBE_STATUS: {
|
|
494
|
+
readonly UNKNOWN: 0;
|
|
495
|
+
readonly REACHABLE: 1;
|
|
496
|
+
readonly DEGRADED: 2;
|
|
497
|
+
readonly UNREACHABLE: 3;
|
|
498
|
+
};
|
|
499
|
+
declare const NODE_REGISTRY_SELECTORS: {
|
|
500
|
+
readonly reportServiceProbe: "0xeee31bba";
|
|
501
|
+
readonly getServiceProbe: "0x1fcbfbce";
|
|
502
|
+
};
|
|
503
|
+
interface ReportServiceProbeCalldataArgs {
|
|
504
|
+
peerId: string | Uint8Array | readonly number[];
|
|
505
|
+
serviceMask: number;
|
|
506
|
+
status: number;
|
|
507
|
+
latencyMs: number;
|
|
508
|
+
probeDigest: string | Uint8Array | readonly number[];
|
|
509
|
+
}
|
|
510
|
+
declare class NodeRegistryError extends Error {
|
|
511
|
+
constructor(message: string);
|
|
512
|
+
}
|
|
513
|
+
declare function nodeRegistryAddressHex(): string;
|
|
514
|
+
declare function isValidNodeRegistryCapabilities(flags: number): boolean;
|
|
515
|
+
declare function isValidPublicServiceProbeMask(mask: number): boolean;
|
|
516
|
+
declare function isSinglePublicServiceProbeMask(mask: number): boolean;
|
|
517
|
+
declare function isConcreteServiceProbeStatus(status: number): boolean;
|
|
518
|
+
declare function serviceProbeStatusLabel(status: number): string;
|
|
519
|
+
declare function encodeReportServiceProbeCalldata(args: ReportServiceProbeCalldataArgs): string;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Address display helpers.
|
|
523
|
+
*
|
|
524
|
+
* Monolythium keeps 20-byte EVM-compatible addresses on the wire, but
|
|
525
|
+
* user-facing surfaces display them as `mono1...` bech32m strings.
|
|
526
|
+
*/
|
|
527
|
+
declare const ADDRESS_HRP: "mono";
|
|
528
|
+
declare class AddressError extends Error {
|
|
529
|
+
constructor(message: string);
|
|
530
|
+
}
|
|
531
|
+
declare function hexToAddressBytes(address: string): Uint8Array;
|
|
532
|
+
declare function addressBytesToHex(address: Uint8Array | readonly number[]): string;
|
|
533
|
+
declare function addressToBech32(address: string | Uint8Array | readonly number[]): string;
|
|
534
|
+
declare function bech32ToAddressBytes(address: string): Uint8Array;
|
|
535
|
+
declare function bech32ToAddress(address: string): string;
|
|
536
|
+
declare function parseAddress(address: string): Uint8Array;
|
|
537
|
+
declare function normalizeAddressHex(address: string): string;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Spending-policy precompile ABI helpers.
|
|
541
|
+
*
|
|
542
|
+
* These helpers build calldata and claim messages for the live
|
|
543
|
+
* `mono-core` spending-policy precompile. Fresh sub-account claims
|
|
544
|
+
* must use `setPolicyClaim` or `claimPolicyByAddress`; legacy
|
|
545
|
+
* `setPolicy` is only for re-claims where the principal is already
|
|
546
|
+
* recorded on-chain.
|
|
547
|
+
*/
|
|
548
|
+
|
|
549
|
+
declare const SET_POLICY_CLAIM_DOMAIN_TAG: "lyth.spending-policy.claim.v1";
|
|
550
|
+
declare const ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
551
|
+
declare const ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
552
|
+
declare const SPENDING_POLICY_SELECTORS: {
|
|
553
|
+
readonly setPolicy: "0xd6a518b2";
|
|
554
|
+
readonly setPolicyClaim: "0x08d78f9c";
|
|
555
|
+
readonly claimPolicyByAddress: "0xc2397fe9";
|
|
556
|
+
readonly enable: "0x5bfa1b68";
|
|
557
|
+
readonly disable: "0xe6c09edf";
|
|
558
|
+
readonly recordSpend: "0xdca04292";
|
|
559
|
+
};
|
|
560
|
+
interface SpendingPolicyArgs {
|
|
561
|
+
subAccount: string | Uint8Array | readonly number[];
|
|
562
|
+
principal: string | Uint8Array | readonly number[];
|
|
563
|
+
dailyCapWei: bigint | number | string;
|
|
564
|
+
perTxCapWei: bigint | number | string;
|
|
565
|
+
allowRoot: string | Uint8Array | readonly number[];
|
|
566
|
+
denyRoot: string | Uint8Array | readonly number[];
|
|
567
|
+
}
|
|
568
|
+
declare class SpendingPolicyError extends Error {
|
|
569
|
+
constructor(message: string);
|
|
570
|
+
}
|
|
571
|
+
declare function spendingPolicyAddressHex(): string;
|
|
572
|
+
declare function composeClaimBoundMessage(chainId: bigint | number | string, args: SpendingPolicyArgs, opts?: {
|
|
573
|
+
precompileAddress?: string | Uint8Array | readonly number[];
|
|
574
|
+
expectedPolicyVersion?: bigint | number | string;
|
|
575
|
+
}): Uint8Array;
|
|
576
|
+
declare function encodeSetPolicyCalldata(args: SpendingPolicyArgs): string;
|
|
577
|
+
declare function encodeSetPolicyClaimCalldata(args: SpendingPolicyArgs, subAccountPubkey: Uint8Array | readonly number[] | string, subAccountSig: Uint8Array | readonly number[] | string): string;
|
|
578
|
+
declare function encodeClaimPolicyByAddressCalldata(args: SpendingPolicyArgs, subAccountSig: Uint8Array | readonly number[] | string): string;
|
|
579
|
+
declare function encodeEnableCalldata(subAccount: string | Uint8Array | readonly number[]): string;
|
|
580
|
+
declare function encodeDisableCalldata(subAccount: string | Uint8Array | readonly number[]): string;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Pubkey-registry precompile ABI helpers.
|
|
584
|
+
*
|
|
585
|
+
* The pubkey-registry at `0x110D` lets an account publish its primary
|
|
586
|
+
* ML-DSA-65 public key once, so later contract-context verification can
|
|
587
|
+
* look the key up by address.
|
|
588
|
+
*/
|
|
589
|
+
declare const PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
590
|
+
declare const PUBKEY_REGISTRY_SELECTORS: {
|
|
591
|
+
readonly registerPubkey: "0x5fe984e7";
|
|
592
|
+
readonly lookupPubkey: "0x87c42001";
|
|
593
|
+
readonly hasPubkey: "0x01c0d167";
|
|
594
|
+
};
|
|
595
|
+
interface PubkeyLookup {
|
|
596
|
+
pubkey: Uint8Array;
|
|
597
|
+
setBlock: bigint;
|
|
598
|
+
}
|
|
599
|
+
declare class PubkeyRegistryError extends Error {
|
|
600
|
+
constructor(message: string);
|
|
601
|
+
}
|
|
602
|
+
declare function pubkeyRegistryAddressHex(): string;
|
|
603
|
+
declare function encodeRegisterPubkeyCalldata(pubkey: Uint8Array | readonly number[] | string): string;
|
|
604
|
+
declare function encodeLookupPubkeyCalldata(address: string | Uint8Array | readonly number[]): string;
|
|
605
|
+
declare function encodeHasPubkeyCalldata(address: string | Uint8Array | readonly number[]): string;
|
|
606
|
+
declare function decodeLookupPubkeyReturn(data: Uint8Array | readonly number[] | string): PubkeyLookup;
|
|
607
|
+
declare function decodeHasPubkeyReturn(data: Uint8Array | readonly number[] | string): boolean;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Network identity for the ethers.js compat shim.
|
|
611
|
+
*
|
|
612
|
+
* Per whitepaper v4.0, Monolythium testnet `chain_id` is **`69420`**.
|
|
613
|
+
* Mainnet chain id is reserved for the genesis ceremony and not yet
|
|
614
|
+
* exported.
|
|
615
|
+
*/
|
|
616
|
+
/** Monolythium v4.0 testnet chain id. */
|
|
617
|
+
declare const MONOLYTHIUM_TESTNET_CHAIN_ID = 69420n;
|
|
618
|
+
/** Network name surfaced to ethers `Network` instances. */
|
|
619
|
+
declare const MONOLYTHIUM_TESTNET_NETWORK_NAME = "monolythium-testnet";
|
|
620
|
+
/**
|
|
621
|
+
* Built-in network presets for the ethers shim. Callers that point at a
|
|
622
|
+
* different chain id (e.g. a local dev node) construct `MonolythiumProvider`
|
|
623
|
+
* with an explicit `network` option instead.
|
|
624
|
+
*/
|
|
625
|
+
declare const MONOLYTHIUM_NETWORKS: {
|
|
626
|
+
readonly testnet: {
|
|
627
|
+
readonly chainId: 69420n;
|
|
628
|
+
readonly name: "monolythium-testnet";
|
|
629
|
+
};
|
|
630
|
+
};
|
|
631
|
+
/** Configuration object accepted by the ethers shim factory functions. */
|
|
632
|
+
interface MonolythiumNetworkConfig {
|
|
633
|
+
/** Numeric chain id (e.g. `69420n`). */
|
|
634
|
+
chainId: bigint;
|
|
635
|
+
/** Human-readable network name. */
|
|
636
|
+
name: string;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* `MonolythiumProvider` — ethers v6 `JsonRpcApiProvider` that routes
|
|
641
|
+
* every call through the native `RpcClient`.
|
|
642
|
+
*
|
|
643
|
+
* `JsonRpcApiProvider` already knows how to translate the rich
|
|
644
|
+
* `_perform(req)` surface into the standard `eth_*` JSON-RPC calls,
|
|
645
|
+
* so we only need to override `_send`: instead of opening its own
|
|
646
|
+
* fetch transport, we reuse the SDK's transport and `lyth_*`-aware
|
|
647
|
+
* error handling.
|
|
648
|
+
*
|
|
649
|
+
* That keeps a single transport in the process — no double-counted
|
|
650
|
+
* connection pools, no duplicated retry/backoff logic, and any
|
|
651
|
+
* future SDK-side feature (auth headers, ws upgrade, registry-based
|
|
652
|
+
* routing) lights up for ethers callers automatically.
|
|
653
|
+
*
|
|
654
|
+
* **SDK-only compat.** Per `feedback_no_ethereum_wire_retrofit.md`,
|
|
655
|
+
* this shim never alters the chain's wire — it only wraps the chain's
|
|
656
|
+
* existing `eth_*` namespace in ethers' interface so existing
|
|
657
|
+
* Solidity tooling (Hardhat, Foundry, ethers-based dApps) can target
|
|
658
|
+
* Monolythium without code rewrites.
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
/** Optional configuration for `MonolythiumProvider`. */
|
|
662
|
+
interface MonolythiumProviderOptions extends RpcClientOptions {
|
|
663
|
+
/**
|
|
664
|
+
* Override the chain id / network name surfaced to ethers. Defaults
|
|
665
|
+
* to the Monolythium v4.0 testnet preset (`chain_id` `69420`, name
|
|
666
|
+
* `monolythium-testnet`).
|
|
667
|
+
*/
|
|
668
|
+
network?: MonolythiumNetworkConfig;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* `MonolythiumProvider` adapts `mono-core`'s JSON-RPC surface to
|
|
672
|
+
* ethers v6.
|
|
673
|
+
*
|
|
674
|
+
* Use it the same way you'd use any ethers provider:
|
|
675
|
+
*
|
|
676
|
+
* ```ts
|
|
677
|
+
* import { MonolythiumProvider } from "@monolythium/core-sdk";
|
|
678
|
+
*
|
|
679
|
+
* const provider = new MonolythiumProvider("https://rpc.testnet.monolythium.com");
|
|
680
|
+
* const block = await provider.getBlockNumber();
|
|
681
|
+
* ```
|
|
682
|
+
*
|
|
683
|
+
* Anything ethers normally does — `getBlockNumber`, `getBalance`,
|
|
684
|
+
* `getTransactionReceipt`, `call`, `estimateGas`, `broadcastTransaction`
|
|
685
|
+
* — flows through `RpcClient.call` (which already handles JSON-RPC
|
|
686
|
+
* error envelopes via `SdkError`).
|
|
687
|
+
*/
|
|
688
|
+
declare class MonolythiumProvider extends JsonRpcApiProvider {
|
|
689
|
+
#private;
|
|
690
|
+
/** Underlying SDK client. Exposed for callers that want native types. */
|
|
691
|
+
readonly rpcClient: RpcClient;
|
|
692
|
+
constructor(endpointOrClient: string | RpcClient, options?: MonolythiumProviderOptions);
|
|
693
|
+
/**
|
|
694
|
+
* Forward a single JSON-RPC method through the SDK transport. Ethers'
|
|
695
|
+
* `_perform` calls this and ethers callers can also call `provider.send`
|
|
696
|
+
* directly to access methods the rich provider interface does not wrap
|
|
697
|
+
* (e.g. `lyth_*`).
|
|
698
|
+
*/
|
|
699
|
+
_send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult | JsonRpcError>>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* `MonolythiumSigner` — ethers v6 `AbstractSigner` adapter.
|
|
704
|
+
*
|
|
705
|
+
* Two backend strategies are supported, both via the same external
|
|
706
|
+
* surface — `getAddress`, `signTransaction`, `signMessage`,
|
|
707
|
+
* `signTypedData`:
|
|
708
|
+
*
|
|
709
|
+
* 1. **`fromEthersWallet`** — wraps a normal `ethers.Wallet`
|
|
710
|
+
* (secp256k1). Useful for tests, scripts, and any path where the
|
|
711
|
+
* user already has an Ethereum-style key. The SDK does not store
|
|
712
|
+
* the key — the wallet does.
|
|
713
|
+
*
|
|
714
|
+
* 2. **`MonolythiumSignerBackend`** — generic interface a non-ethers
|
|
715
|
+
* backend (keychain, hardware wallet, future ML-DSA-65 signer)
|
|
716
|
+
* implements to plug into ethers without forcing the SDK to take
|
|
717
|
+
* a hard ethers dependency on either the chain side or the
|
|
718
|
+
* consumer side.
|
|
719
|
+
*
|
|
720
|
+
* The address derivation rule for any backend is **Law §2.6**:
|
|
721
|
+
* `keccak256(canonical_pubkey_bytes)[12..32]`, with algo-tagged domain
|
|
722
|
+
* separation. For secp256k1 (the ethers Wallet path) this collapses
|
|
723
|
+
* to the standard Ethereum derivation that `ethers.computeAddress`
|
|
724
|
+
* already implements — so wallets the user already has work as-is.
|
|
725
|
+
*
|
|
726
|
+
* **What the shim is not.** This is SDK-level compat (per
|
|
727
|
+
* `feedback_no_ethereum_wire_retrofit.md`). The chain's protocol-native
|
|
728
|
+
* signing path is ML-DSA-65 (Law §2.1); ethers cannot produce ML-DSA
|
|
729
|
+
* signatures, and the chain accepts secp256k1 only via the
|
|
730
|
+
* crypto-agile `SignedTransaction` envelope. Use
|
|
731
|
+
* `MonolythiumSignerBackend` to plug a native ML-DSA path in.
|
|
732
|
+
*/
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Backend the `MonolythiumSigner` delegates signing to.
|
|
736
|
+
*
|
|
737
|
+
* The intent is to let consumers wire up any signing source — local
|
|
738
|
+
* keystore, OS keychain, hardware wallet, or a future ML-DSA-65
|
|
739
|
+
* adapter — without the shim forcing a particular implementation.
|
|
740
|
+
*
|
|
741
|
+
* Every method's return shape mirrors what ethers'
|
|
742
|
+
* `AbstractSigner` callers expect, so the backend can compose with
|
|
743
|
+
* any tooling built on ethers.
|
|
744
|
+
*/
|
|
745
|
+
interface MonolythiumSignerBackend {
|
|
746
|
+
/** Resolves to the 20-byte 0x-hex address (Law §2.6 derivation). */
|
|
747
|
+
getAddress(): Promise<string>;
|
|
748
|
+
/**
|
|
749
|
+
* Resolves to a fully-encoded raw signed transaction (a 0x-hex
|
|
750
|
+
* string). For secp256k1 this is the canonical EIP-1559 RLP that
|
|
751
|
+
* `eth_sendRawTransaction` expects.
|
|
752
|
+
*/
|
|
753
|
+
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
754
|
+
/**
|
|
755
|
+
* Resolves to an EIP-191 personal-sign signature (`0x` + 65 bytes
|
|
756
|
+
* for secp256k1 / variable for non-recoverable algorithms).
|
|
757
|
+
*/
|
|
758
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
759
|
+
/** Resolves to an EIP-712 typed-data signature. */
|
|
760
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, unknown>): Promise<string>;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* `MonolythiumSigner` — ethers v6 `Signer` for the Monolythium chain.
|
|
764
|
+
*
|
|
765
|
+
* Construct one of three ways:
|
|
766
|
+
*
|
|
767
|
+
* 1. `MonolythiumSigner.fromEthersWallet(wallet, provider)` — the
|
|
768
|
+
* fastest path; wraps a normal `ethers.Wallet`.
|
|
769
|
+
* 2. `new MonolythiumSigner(backend, provider)` — supply any object
|
|
770
|
+
* implementing `MonolythiumSignerBackend`.
|
|
771
|
+
*
|
|
772
|
+
* The signer is fully spec-compatible with ethers v6 — it can be
|
|
773
|
+
* passed anywhere a `Signer` is accepted (e.g.
|
|
774
|
+
* `new ethers.Contract(address, abi, signer)`), and works with
|
|
775
|
+
* `Contract.deploy`, `Contract.call`, all ContractFactory paths,
|
|
776
|
+
* and `provider.broadcastTransaction(signed)`.
|
|
777
|
+
*/
|
|
778
|
+
declare class MonolythiumSigner extends AbstractSigner<Provider | null> {
|
|
779
|
+
#private;
|
|
780
|
+
constructor(backend: MonolythiumSignerBackend, provider?: Provider | null);
|
|
781
|
+
/**
|
|
782
|
+
* Wrap any ethers v6 `BaseWallet` (the parent class of `Wallet`,
|
|
783
|
+
* `HDNodeWallet`, and friends) so callers don't have to write a
|
|
784
|
+
* `MonolythiumSignerBackend` for the common test / dev path.
|
|
785
|
+
*
|
|
786
|
+
* Both `new Wallet(privateKey)` and `Wallet.createRandom()` /
|
|
787
|
+
* `HDNodeWallet.fromMnemonic(...)` are accepted.
|
|
788
|
+
*/
|
|
789
|
+
static fromEthersWallet(wallet: BaseWallet, provider?: Provider | null): MonolythiumSigner;
|
|
790
|
+
getAddress(): Promise<string>;
|
|
791
|
+
connect(provider: Provider | null): Signer;
|
|
792
|
+
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
793
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
794
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, unknown>): Promise<string>;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Tx wire translation between ethers.js and `mono-core`.
|
|
799
|
+
*
|
|
800
|
+
* The chain natively accepts EIP-1559-shape EVM transactions on the
|
|
801
|
+
* `Tx::Evm` (kind tag `0x01`) wire path — a `SignedTransaction` payload
|
|
802
|
+
* carries the legacy EIP-1559 envelope plus the secp256k1 signature.
|
|
803
|
+
* That makes the round-trip simple: ethers produces the canonical
|
|
804
|
+
* EIP-1559 RLP, the client posts it via `eth_sendRawTransaction`, the
|
|
805
|
+
* chain decodes it, and the receipt comes back through the same
|
|
806
|
+
* `eth_getTransactionReceipt` shape ethers expects.
|
|
807
|
+
*
|
|
808
|
+
* Two notes for any future maintainer:
|
|
809
|
+
*
|
|
810
|
+
* 1. **No chain-level Ethereum retrofit.** This shim is SDK-only — see
|
|
811
|
+
* `feedback_no_ethereum_wire_retrofit.md`. The chain keeps its
|
|
812
|
+
* custom envelope and native tx hash for the protocol-native path
|
|
813
|
+
* (ML-DSA-65 signing, native tx kinds beyond EVM). The shim only
|
|
814
|
+
* spans the **EIP-1559 EVM subset** of the chain's tx surface.
|
|
815
|
+
* 2. **Fields ethers does not see.** Monolythium-specific extension
|
|
816
|
+
* fields (privacy flags, native tx kinds, ML-DSA-65 signatures) are
|
|
817
|
+
* intentionally dropped by these helpers. Callers that need those
|
|
818
|
+
* surfaces use the native SDK signer trait, not the ethers shim.
|
|
819
|
+
*/
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* The EIP-1559 subset of fields ethers' `TransactionRequest` carries
|
|
823
|
+
* across the shim. We don't import ethers' type here so the shim can be
|
|
824
|
+
* compiled (and its types re-exported) even when ethers isn't installed
|
|
825
|
+
* — ethers is a peerDependency, not a hard dependency.
|
|
826
|
+
*/
|
|
827
|
+
interface EthersTxRequestSubset {
|
|
828
|
+
to?: string | null;
|
|
829
|
+
from?: string | null;
|
|
830
|
+
nonce?: number | bigint | null;
|
|
831
|
+
gasLimit?: bigint | string | null;
|
|
832
|
+
gasPrice?: bigint | string | null;
|
|
833
|
+
maxFeePerGas?: bigint | string | null;
|
|
834
|
+
maxPriorityFeePerGas?: bigint | string | null;
|
|
835
|
+
value?: bigint | string | null;
|
|
836
|
+
data?: string | null;
|
|
837
|
+
chainId?: bigint | number | null;
|
|
838
|
+
type?: number | null;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Translate ethers' `TransactionRequest` into the wire shape the
|
|
842
|
+
* `mono-core` JSON-RPC accepts for `eth_call` / `eth_estimateGas`.
|
|
843
|
+
*
|
|
844
|
+
* Returns the SDK's `CallRequest` shape (which mirrors the chain's
|
|
845
|
+
* accepted `eth_call` argument). Round-trips losslessly for the
|
|
846
|
+
* EIP-1559 EVM subset; Monolythium-specific extension fields are
|
|
847
|
+
* intentionally not surfaced here.
|
|
848
|
+
*/
|
|
849
|
+
declare function translateTxIn(req: EthersTxRequestSubset): CallRequest;
|
|
850
|
+
/**
|
|
851
|
+
* The ethers v6 wire shape for `eth_getTransactionReceipt`. We hand-roll
|
|
852
|
+
* this rather than importing ethers' internal types because the shim
|
|
853
|
+
* has to compile without ethers installed (peerDependency).
|
|
854
|
+
*
|
|
855
|
+
* Field naming and casing match what `JsonRpcApiProvider._perform` expects
|
|
856
|
+
* back — the provider then normalises into ethers' rich
|
|
857
|
+
* `TransactionReceipt` for callers.
|
|
858
|
+
*/
|
|
859
|
+
interface EthersReceiptShape {
|
|
860
|
+
transactionHash: string;
|
|
861
|
+
blockHash: string;
|
|
862
|
+
blockNumber: string;
|
|
863
|
+
transactionIndex: string;
|
|
864
|
+
status: string;
|
|
865
|
+
gasUsed: string;
|
|
866
|
+
cumulativeGasUsed: string;
|
|
867
|
+
effectiveGasPrice: string;
|
|
868
|
+
contractAddress: string | null;
|
|
869
|
+
from: string;
|
|
870
|
+
to: string | null;
|
|
871
|
+
type: string;
|
|
872
|
+
logsBloom: string;
|
|
873
|
+
logs: unknown[];
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Translate `mono-core`'s native `TransactionReceipt` into the wire
|
|
877
|
+
* shape ethers expects. Required for `eth_getTransactionReceipt` to
|
|
878
|
+
* surface a usable `TransactionResponse` to ethers callers.
|
|
879
|
+
*
|
|
880
|
+
* The chain's receipt today is intentionally narrow — log emission,
|
|
881
|
+
* cumulative-gas aggregation, and effective-gas-price disclosure are
|
|
882
|
+
* tracked OI items. This translator fills in zero-equivalent values for
|
|
883
|
+
* those gaps; callers that need the full surface (logs, effective gas
|
|
884
|
+
* price) consume the native SDK shape directly.
|
|
885
|
+
*/
|
|
886
|
+
declare function translateReceiptOut(monoReceipt: TransactionReceipt, fromAddress: string | null, toAddress: string | null): EthersReceiptShape;
|
|
887
|
+
/**
|
|
888
|
+
* Translate `mono-core`'s `BlockHeader` into the ethers v6 wire shape
|
|
889
|
+
* for `eth_getBlockByNumber` / `eth_getBlockByHash`.
|
|
890
|
+
*
|
|
891
|
+
* The chain's block header is intentionally narrower than Ethereum's
|
|
892
|
+
* — it omits fields that don't exist in Monolythium (uncles, mix hash,
|
|
893
|
+
* difficulty, nonce, sha3Uncles). This translator emits zero-valued
|
|
894
|
+
* stand-ins so ethers' normaliser does not throw. Callers needing the
|
|
895
|
+
* authoritative shape import the native `BlockHeader` from the SDK.
|
|
896
|
+
*/
|
|
897
|
+
interface EthersBlockShape {
|
|
898
|
+
number: string;
|
|
899
|
+
hash: string;
|
|
900
|
+
parentHash: string;
|
|
901
|
+
timestamp: string;
|
|
902
|
+
gasUsed: string;
|
|
903
|
+
gasLimit: string;
|
|
904
|
+
stateRoot: string;
|
|
905
|
+
miner: string;
|
|
906
|
+
difficulty: string;
|
|
907
|
+
nonce: string;
|
|
908
|
+
baseFeePerGas: string | null;
|
|
909
|
+
extraData: string;
|
|
910
|
+
mixHash: string;
|
|
911
|
+
transactions: string[];
|
|
912
|
+
transactionsRoot: string;
|
|
913
|
+
receiptsRoot: string;
|
|
914
|
+
logsBloom: string;
|
|
915
|
+
sha3Uncles: string;
|
|
916
|
+
uncles: string[];
|
|
917
|
+
size: string;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Translate `mono-core`'s `BlockHeader` to the ethers wire shape.
|
|
921
|
+
* `transactions` defaults to an empty list — the SDK's
|
|
922
|
+
* `eth_getBlockByNumber` does not yet return tx hashes; once Stage 1+
|
|
923
|
+
* surfaces them, callers update this translator.
|
|
924
|
+
*/
|
|
925
|
+
declare function translateBlockOut(header: {
|
|
926
|
+
number: bigint;
|
|
927
|
+
hash: string;
|
|
928
|
+
parent_hash: string;
|
|
929
|
+
state_root: string;
|
|
930
|
+
timestamp: bigint;
|
|
931
|
+
gas_used: bigint;
|
|
932
|
+
gas_limit: bigint;
|
|
933
|
+
}): EthersBlockShape;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Official TypeScript SDK for Monolythium v4.0 / LythiumDAG-BFT.
|
|
937
|
+
*
|
|
938
|
+
* The wire types in `./bindings/` are generated from Rust by
|
|
939
|
+
* `cargo test --features ts-bindings`; never edit them by hand. The
|
|
940
|
+
* `RpcClient` mirrors the Rust SDK 1:1 and sends `lyth_*` / `eth_*` /
|
|
941
|
+
* `debug_*` JSON-RPC methods (Law §13.2).
|
|
942
|
+
*
|
|
943
|
+
* The optional `ethers.js` v6 compat shim lives under `./ethers/`
|
|
944
|
+
* and is re-exported below. `ethers` is a peerDependency — install
|
|
945
|
+
* it alongside this SDK when you use the shim.
|
|
946
|
+
*/
|
|
947
|
+
declare const version = "0.1.0";
|
|
948
|
+
|
|
949
|
+
export { ADDRESS_HRP, AddressError, AddressFlowResponse, AddressProfileResponse, type ApiAddressActivityData, type ApiAddressActivityEntry, type ApiAddressActivityKind, type ApiAddressActivityKindData, type ApiAddressActivityKindSummary, type ApiBlockData, type ApiBlockHeader, type ApiBlockTransactionsData, type ApiCapabilitiesResponse, ApiClient, type ApiClientOptions, type ApiClusterData, type ApiClusterDirectoryEntry, type ApiClusterDirectoryPage, type ApiClusterMember, type ApiClusterStatus, type ApiClustersData, type ApiEnvelope, type ApiErrorEnvelope, type ApiHealthResponse, type ApiIndexerStatus, type ApiLatestAnchor, type ApiLogEntry, type ApiOperatorData, type ApiOperatorInfo, type ApiQueryValue, type ApiRuntimeProvenanceData, type ApiServiceProbeData, type ApiTransactionData, type ApiTransactionReceipt, type ApiTransactionReceiptData, type ApiTransactionView, type ApiUpgradePlanStatus, type ApiUpgradeStatus, type ApiUpgradeStatusData, BURN_ADDR, BlockSelector, CallRequest, ChainStatsResponse, ClobMarketResponse, ClobMarketsResponse, ClobOhlcResponse, ClobOrderBookResponse, ClobTradesResponse, type EthersBlockShape, type EthersReceiptShape, type EthersTxRequestSubset, ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, type MonolythiumNetworkConfig, MonolythiumProvider, type MonolythiumProviderOptions, MonolythiumSigner, type MonolythiumSignerBackend, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NodeRegistryError, OperatorCapabilitiesResponse, PRECOMPILE_ADDRESSES, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, type PrecompileAddress, type PrecompileName, type PubkeyLookup, PubkeyRegistryError, type ReportServiceProbeCalldataArgs, RpcClient, RpcClientOptions, RuntimeBuildProvenance, RuntimeUpgradeStatus, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SearchResponse, ServiceProbeResponse, type SpendingPolicyArgs, SpendingPolicyError, TransactionReceipt, TxFeedResponse, addressBytesToHex, addressToBech32, apiEndpointFromRpcEndpoint, bech32ToAddress, bech32ToAddressBytes, composeClaimBoundMessage, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, encodeClaimPolicyByAddressCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLookupPubkeyCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, hexToAddressBytes, isConcreteServiceProbeStatus, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, nodeRegistryAddressHex, normalizeAddressHex, parseAddress, pubkeyRegistryAddressHex, serviceProbeStatusLabel, spendingPolicyAddressHex, translateBlockOut, translateReceiptOut, translateTxIn, version };
|