@monolythium/core-sdk 0.2.1 → 0.3.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.
@@ -1,300 +0,0 @@
1
- import { JsonRpcApiProvider, JsonRpcPayload, JsonRpcResult, JsonRpcError, AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField, BaseWallet, Signer } from 'ethers';
2
- import { D as RpcClient, cT as RpcClientOptions, d3 as TransactionReceipt, au as CallRequest } from '../native-events-BEkkGoak.cjs';
3
- import { b as MonolythiumNetworkConfig } from '../network-BK2u9br2.cjs';
4
- export { c as MONOLYTHIUM_NETWORKS, M as MONOLYTHIUM_TESTNET_CHAIN_ID, a as MONOLYTHIUM_TESTNET_NETWORK_NAME } from '../network-BK2u9br2.cjs';
5
-
6
- /**
7
- * `MonolythiumProvider` — ethers v6 `JsonRpcApiProvider` that routes
8
- * every call through the native `RpcClient`.
9
- *
10
- * `JsonRpcApiProvider` already knows how to translate the rich
11
- * `_perform(req)` surface into the standard `eth_*` JSON-RPC calls,
12
- * so we only need to override `_send`: instead of opening its own
13
- * fetch transport, we reuse the SDK's transport and `lyth_*`-aware
14
- * error handling.
15
- *
16
- * That keeps a single transport in the process — no double-counted
17
- * connection pools, no duplicated retry/backoff logic, and any
18
- * future SDK-side feature (auth headers, ws upgrade, registry-based
19
- * routing) lights up for ethers callers automatically.
20
- *
21
- * **SDK-only compat.** This shim never alters the chain's wire. It wraps
22
- * compatibility JSON-RPC methods in ethers' interface for migration scripts;
23
- * current v4.1 app paths should use native MRV/RISC-V builders and `lyth_*`
24
- * read surfaces.
25
- */
26
-
27
- /** Optional configuration for `MonolythiumProvider`. */
28
- interface MonolythiumProviderOptions extends RpcClientOptions {
29
- /**
30
- * Override the chain id / network name surfaced to ethers. Defaults
31
- * to the Monolythium v4.1 testnet preset (`chain_id` `69420`, name
32
- * `monolythium-testnet`).
33
- */
34
- network?: MonolythiumNetworkConfig;
35
- }
36
- /**
37
- * `MonolythiumProvider` adapts `mono-core`'s JSON-RPC surface to
38
- * ethers v6.
39
- *
40
- * Use it the same way you'd use any ethers provider:
41
- *
42
- * ```ts
43
- * import { MonolythiumProvider } from "@monolythium/core-sdk/ethers";
44
- *
45
- * const provider = new MonolythiumProvider("https://rpc.testnet.monolythium.com");
46
- * const block = await provider.getBlockNumber();
47
- * ```
48
- *
49
- * Legacy ethers actions such as `getBlockNumber`, `getBalance`,
50
- * `getTransactionReceipt`, `call`, `estimateGas`, and
51
- * `broadcastTransaction` flow through `RpcClient.call`, so no-EVM profiles
52
- * may reject unsupported compatibility methods server-side.
53
- */
54
- declare class MonolythiumProvider extends JsonRpcApiProvider {
55
- #private;
56
- /** Underlying SDK client. Exposed for callers that want native types. */
57
- readonly rpcClient: RpcClient;
58
- constructor(endpointOrClient: string | RpcClient, options?: MonolythiumProviderOptions);
59
- /**
60
- * Forward a single JSON-RPC method through the SDK transport. Ethers'
61
- * `_perform` calls this and ethers callers can also call `provider.send`
62
- * directly to access methods the rich provider interface does not wrap
63
- * (e.g. `lyth_*`).
64
- */
65
- _send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult | JsonRpcError>>;
66
- }
67
-
68
- /**
69
- * `MonolythiumSigner` — ethers v6 `AbstractSigner` adapter.
70
- *
71
- * Two backend strategies are supported, both via the same external
72
- * surface — `getAddress`, `signTransaction`, `signMessage`,
73
- * `signTypedData`:
74
- *
75
- * 1. **`fromEthersWallet`** — wraps a normal `ethers.Wallet`
76
- * (secp256k1). Useful for tests, scripts, and any path where the
77
- * user already has an Ethereum-style key. The SDK does not store
78
- * the key — the wallet does.
79
- *
80
- * 2. **`MonolythiumSignerBackend`** — generic interface a non-ethers
81
- * backend (keychain, hardware wallet, future ML-DSA-65 signer)
82
- * implements to plug into ethers without forcing the SDK to take
83
- * a hard ethers dependency on either the chain side or the
84
- * consumer side.
85
- *
86
- * Native Mono address derivation is ADR-0038:
87
- * `BLAKE3("MONO_ADDRESS_BLAKE3_20_V1" || algo_id_be_u16 ||
88
- * canonical_pubkey_bytes)[0..20]`. `fromEthersWallet` preserves the
89
- * wrapped ethers address only for the compatibility signer path; native
90
- * ML-DSA-65 callers should use the crypto helpers directly.
91
- *
92
- * **What the shim is not.** This is SDK-level compat (per
93
- * `feedback_no_ethereum_wire_retrofit.md`). The chain's protocol-native
94
- * signing path is ML-DSA-65 (Law §2.1); ethers cannot produce ML-DSA
95
- * signatures, and the chain accepts secp256k1 only via the
96
- * crypto-agile `SignedTransaction` envelope. Use
97
- * `MonolythiumSignerBackend` to plug a native ML-DSA path in.
98
- */
99
-
100
- /**
101
- * Backend the `MonolythiumSigner` delegates signing to.
102
- *
103
- * The intent is to let consumers wire up any signing source — local
104
- * keystore, OS keychain, hardware wallet, or a future ML-DSA-65
105
- * adapter — without the shim forcing a particular implementation.
106
- *
107
- * Every method's return shape mirrors what ethers'
108
- * `AbstractSigner` callers expect, so the backend can compose with
109
- * any tooling built on ethers.
110
- */
111
- interface MonolythiumSignerBackend {
112
- /** Resolves to the 20-byte 0x-hex address (Law §2.6 derivation). */
113
- getAddress(): Promise<string>;
114
- /**
115
- * Resolves to a fully-encoded raw signed transaction (a 0x-hex
116
- * string). For secp256k1 this is the canonical EIP-1559 RLP that
117
- * `eth_sendRawTransaction` expects.
118
- */
119
- signTransaction(tx: TransactionRequest): Promise<string>;
120
- /**
121
- * Resolves to an EIP-191 personal-sign signature (`0x` + 65 bytes
122
- * for secp256k1 / variable for non-recoverable algorithms).
123
- */
124
- signMessage(message: string | Uint8Array): Promise<string>;
125
- /** Resolves to an EIP-712 typed-data signature. */
126
- signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, unknown>): Promise<string>;
127
- }
128
- /**
129
- * `MonolythiumSigner` — ethers v6 `Signer` for the Monolythium chain.
130
- *
131
- * Construct one of three ways:
132
- *
133
- * 1. `MonolythiumSigner.fromEthersWallet(wallet, provider)` — the
134
- * fastest path; wraps a normal `ethers.Wallet`.
135
- * 2. `new MonolythiumSigner(backend, provider)` — supply any object
136
- * implementing `MonolythiumSignerBackend`.
137
- *
138
- * The signer is compatible with ethers v6 migration flows: it can be passed
139
- * anywhere a `Signer` is accepted and supports legacy contract deploy/call
140
- * helpers plus `provider.broadcastTransaction(signed)`. New v4.1 app paths
141
- * should use native MRV/RISC-V builders instead.
142
- */
143
- declare class MonolythiumSigner extends AbstractSigner<Provider | null> {
144
- #private;
145
- constructor(backend: MonolythiumSignerBackend, provider?: Provider | null);
146
- /**
147
- * Wrap any ethers v6 `BaseWallet` (the parent class of `Wallet`,
148
- * `HDNodeWallet`, and friends) so callers don't have to write a
149
- * `MonolythiumSignerBackend` for the common test / dev path.
150
- *
151
- * Both `new Wallet(privateKey)` and `Wallet.createRandom()` /
152
- * `HDNodeWallet.fromMnemonic(...)` are accepted.
153
- */
154
- static fromEthersWallet(wallet: BaseWallet, provider?: Provider | null): MonolythiumSigner;
155
- getAddress(): Promise<string>;
156
- connect(provider: Provider | null): Signer;
157
- signTransaction(tx: TransactionRequest): Promise<string>;
158
- signMessage(message: string | Uint8Array): Promise<string>;
159
- signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, unknown>): Promise<string>;
160
- }
161
-
162
- /**
163
- * Tx wire translation between ethers.js and `mono-core`.
164
- *
165
- * The chain natively accepts EIP-1559-shape EVM transactions on the
166
- * `Tx::Evm` (kind tag `0x01`) wire path — a `SignedTransaction` payload
167
- * carries the legacy EIP-1559 envelope plus the secp256k1 signature.
168
- * That makes the round-trip simple: ethers produces the canonical
169
- * EIP-1559 RLP, the client posts it via `eth_sendRawTransaction`, the
170
- * chain decodes it, and the receipt comes back through the same
171
- * `eth_getTransactionReceipt` shape ethers expects.
172
- *
173
- * Two notes for any future maintainer:
174
- *
175
- * 1. **No chain-level Ethereum retrofit.** This shim is SDK-only — see
176
- * `feedback_no_ethereum_wire_retrofit.md`. The chain keeps its
177
- * custom envelope and native tx hash for the protocol-native path
178
- * (ML-DSA-65 signing, native tx kinds beyond EVM). The shim only
179
- * spans the **EIP-1559 EVM subset** of the chain's tx surface.
180
- * 2. **Fields ethers does not see.** Monolythium-specific extension
181
- * fields (privacy flags, native tx kinds, ML-DSA-65 signatures) are
182
- * intentionally dropped by these helpers. Callers that need those
183
- * surfaces use the native SDK signer trait, not the ethers shim.
184
- */
185
-
186
- /**
187
- * The EIP-1559 subset of fields ethers' `TransactionRequest` carries
188
- * across the shim. We don't import ethers' type here so the shim can be
189
- * compiled (and its types re-exported) even when ethers isn't installed
190
- * — ethers is a peerDependency, not a hard dependency.
191
- */
192
- interface EthersTxRequestSubset {
193
- to?: string | null;
194
- from?: string | null;
195
- nonce?: number | bigint | null;
196
- gasLimit?: bigint | string | null;
197
- gasPrice?: bigint | string | null;
198
- maxFeePerGas?: bigint | string | null;
199
- maxPriorityFeePerGas?: bigint | string | null;
200
- value?: bigint | string | null;
201
- data?: string | null;
202
- chainId?: bigint | number | null;
203
- type?: number | null;
204
- }
205
- /**
206
- * Translate ethers' `TransactionRequest` into the wire shape the
207
- * `mono-core` JSON-RPC accepts for `eth_call` / `eth_estimateGas`.
208
- *
209
- * Returns the SDK's `CallRequest` shape (which mirrors the chain's
210
- * accepted `eth_call` argument). Round-trips losslessly for the
211
- * EIP-1559 EVM subset; Monolythium-specific extension fields are
212
- * intentionally not surfaced here.
213
- */
214
- declare function translateTxIn(req: EthersTxRequestSubset): CallRequest;
215
- /**
216
- * The ethers v6 wire shape for `eth_getTransactionReceipt`. We hand-roll
217
- * this rather than importing ethers' internal types because the shim
218
- * has to compile without ethers installed (peerDependency).
219
- *
220
- * Field naming and casing match what `JsonRpcApiProvider._perform` expects
221
- * back — the provider then normalises into ethers' rich
222
- * `TransactionReceipt` for callers.
223
- */
224
- interface EthersReceiptShape {
225
- transactionHash: string;
226
- blockHash: string;
227
- blockNumber: string;
228
- transactionIndex: string;
229
- status: string;
230
- gasUsed: string;
231
- cumulativeGasUsed: string;
232
- effectiveGasPrice: string;
233
- contractAddress: string | null;
234
- from: string;
235
- to: string | null;
236
- type: string;
237
- logsBloom: string;
238
- logs: unknown[];
239
- }
240
- /**
241
- * Translate `mono-core`'s native `TransactionReceipt` into the wire
242
- * shape ethers expects. Required for `eth_getTransactionReceipt` to
243
- * surface a usable `TransactionResponse` to ethers callers.
244
- *
245
- * The chain's receipt today is intentionally narrow — log emission,
246
- * cumulative execution-unit aggregation, and effective-fee disclosure are
247
- * tracked OI items. This translator fills in zero-equivalent values for
248
- * those gaps; callers that need the full native surface consume the SDK
249
- * receipt shape directly.
250
- */
251
- declare function translateReceiptOut(monoReceipt: TransactionReceipt, fromAddress: string | null, toAddress: string | null): EthersReceiptShape;
252
- /**
253
- * Translate `mono-core`'s `BlockHeader` into the ethers v6 wire shape
254
- * for `eth_getBlockByNumber` / `eth_getBlockByHash`.
255
- *
256
- * The chain's block header is intentionally narrower than Ethereum's
257
- * — it omits fields that don't exist in Monolythium (uncles, mix hash,
258
- * difficulty, nonce, sha3Uncles). This translator emits zero-valued
259
- * stand-ins so ethers' normaliser does not throw. Callers needing the
260
- * authoritative shape import the native `BlockHeader` from the SDK.
261
- */
262
- interface EthersBlockShape {
263
- number: string;
264
- hash: string;
265
- parentHash: string;
266
- timestamp: string;
267
- gasUsed: string;
268
- gasLimit: string;
269
- stateRoot: string;
270
- miner: string;
271
- difficulty: string;
272
- nonce: string;
273
- baseFeePerGas: string | null;
274
- extraData: string;
275
- mixHash: string;
276
- transactions: string[];
277
- transactionsRoot: string;
278
- receiptsRoot: string;
279
- logsBloom: string;
280
- sha3Uncles: string;
281
- uncles: string[];
282
- size: string;
283
- }
284
- /**
285
- * Translate `mono-core`'s `BlockHeader` to the ethers wire shape.
286
- * `transactions` defaults to an empty list — the SDK's
287
- * `eth_getBlockByNumber` does not yet return tx hashes; once Stage 1+
288
- * surfaces them, callers update this translator.
289
- */
290
- declare function translateBlockOut(header: {
291
- number: bigint;
292
- hash: string;
293
- parent_hash: string;
294
- state_root: string;
295
- timestamp: bigint;
296
- executionUnitsUsed: bigint;
297
- executionUnitLimit: bigint;
298
- }): EthersBlockShape;
299
-
300
- export { type EthersBlockShape, type EthersReceiptShape, type EthersTxRequestSubset, MonolythiumNetworkConfig, MonolythiumProvider, type MonolythiumProviderOptions, MonolythiumSigner, type MonolythiumSignerBackend, translateBlockOut, translateReceiptOut, translateTxIn };
@@ -1,300 +0,0 @@
1
- import { JsonRpcApiProvider, JsonRpcPayload, JsonRpcResult, JsonRpcError, AbstractSigner, Provider, TransactionRequest, TypedDataDomain, TypedDataField, BaseWallet, Signer } from 'ethers';
2
- import { D as RpcClient, cT as RpcClientOptions, d3 as TransactionReceipt, au as CallRequest } from '../native-events-BEkkGoak.js';
3
- import { b as MonolythiumNetworkConfig } from '../network-BK2u9br2.js';
4
- export { c as MONOLYTHIUM_NETWORKS, M as MONOLYTHIUM_TESTNET_CHAIN_ID, a as MONOLYTHIUM_TESTNET_NETWORK_NAME } from '../network-BK2u9br2.js';
5
-
6
- /**
7
- * `MonolythiumProvider` — ethers v6 `JsonRpcApiProvider` that routes
8
- * every call through the native `RpcClient`.
9
- *
10
- * `JsonRpcApiProvider` already knows how to translate the rich
11
- * `_perform(req)` surface into the standard `eth_*` JSON-RPC calls,
12
- * so we only need to override `_send`: instead of opening its own
13
- * fetch transport, we reuse the SDK's transport and `lyth_*`-aware
14
- * error handling.
15
- *
16
- * That keeps a single transport in the process — no double-counted
17
- * connection pools, no duplicated retry/backoff logic, and any
18
- * future SDK-side feature (auth headers, ws upgrade, registry-based
19
- * routing) lights up for ethers callers automatically.
20
- *
21
- * **SDK-only compat.** This shim never alters the chain's wire. It wraps
22
- * compatibility JSON-RPC methods in ethers' interface for migration scripts;
23
- * current v4.1 app paths should use native MRV/RISC-V builders and `lyth_*`
24
- * read surfaces.
25
- */
26
-
27
- /** Optional configuration for `MonolythiumProvider`. */
28
- interface MonolythiumProviderOptions extends RpcClientOptions {
29
- /**
30
- * Override the chain id / network name surfaced to ethers. Defaults
31
- * to the Monolythium v4.1 testnet preset (`chain_id` `69420`, name
32
- * `monolythium-testnet`).
33
- */
34
- network?: MonolythiumNetworkConfig;
35
- }
36
- /**
37
- * `MonolythiumProvider` adapts `mono-core`'s JSON-RPC surface to
38
- * ethers v6.
39
- *
40
- * Use it the same way you'd use any ethers provider:
41
- *
42
- * ```ts
43
- * import { MonolythiumProvider } from "@monolythium/core-sdk/ethers";
44
- *
45
- * const provider = new MonolythiumProvider("https://rpc.testnet.monolythium.com");
46
- * const block = await provider.getBlockNumber();
47
- * ```
48
- *
49
- * Legacy ethers actions such as `getBlockNumber`, `getBalance`,
50
- * `getTransactionReceipt`, `call`, `estimateGas`, and
51
- * `broadcastTransaction` flow through `RpcClient.call`, so no-EVM profiles
52
- * may reject unsupported compatibility methods server-side.
53
- */
54
- declare class MonolythiumProvider extends JsonRpcApiProvider {
55
- #private;
56
- /** Underlying SDK client. Exposed for callers that want native types. */
57
- readonly rpcClient: RpcClient;
58
- constructor(endpointOrClient: string | RpcClient, options?: MonolythiumProviderOptions);
59
- /**
60
- * Forward a single JSON-RPC method through the SDK transport. Ethers'
61
- * `_perform` calls this and ethers callers can also call `provider.send`
62
- * directly to access methods the rich provider interface does not wrap
63
- * (e.g. `lyth_*`).
64
- */
65
- _send(payload: JsonRpcPayload | Array<JsonRpcPayload>): Promise<Array<JsonRpcResult | JsonRpcError>>;
66
- }
67
-
68
- /**
69
- * `MonolythiumSigner` — ethers v6 `AbstractSigner` adapter.
70
- *
71
- * Two backend strategies are supported, both via the same external
72
- * surface — `getAddress`, `signTransaction`, `signMessage`,
73
- * `signTypedData`:
74
- *
75
- * 1. **`fromEthersWallet`** — wraps a normal `ethers.Wallet`
76
- * (secp256k1). Useful for tests, scripts, and any path where the
77
- * user already has an Ethereum-style key. The SDK does not store
78
- * the key — the wallet does.
79
- *
80
- * 2. **`MonolythiumSignerBackend`** — generic interface a non-ethers
81
- * backend (keychain, hardware wallet, future ML-DSA-65 signer)
82
- * implements to plug into ethers without forcing the SDK to take
83
- * a hard ethers dependency on either the chain side or the
84
- * consumer side.
85
- *
86
- * Native Mono address derivation is ADR-0038:
87
- * `BLAKE3("MONO_ADDRESS_BLAKE3_20_V1" || algo_id_be_u16 ||
88
- * canonical_pubkey_bytes)[0..20]`. `fromEthersWallet` preserves the
89
- * wrapped ethers address only for the compatibility signer path; native
90
- * ML-DSA-65 callers should use the crypto helpers directly.
91
- *
92
- * **What the shim is not.** This is SDK-level compat (per
93
- * `feedback_no_ethereum_wire_retrofit.md`). The chain's protocol-native
94
- * signing path is ML-DSA-65 (Law §2.1); ethers cannot produce ML-DSA
95
- * signatures, and the chain accepts secp256k1 only via the
96
- * crypto-agile `SignedTransaction` envelope. Use
97
- * `MonolythiumSignerBackend` to plug a native ML-DSA path in.
98
- */
99
-
100
- /**
101
- * Backend the `MonolythiumSigner` delegates signing to.
102
- *
103
- * The intent is to let consumers wire up any signing source — local
104
- * keystore, OS keychain, hardware wallet, or a future ML-DSA-65
105
- * adapter — without the shim forcing a particular implementation.
106
- *
107
- * Every method's return shape mirrors what ethers'
108
- * `AbstractSigner` callers expect, so the backend can compose with
109
- * any tooling built on ethers.
110
- */
111
- interface MonolythiumSignerBackend {
112
- /** Resolves to the 20-byte 0x-hex address (Law §2.6 derivation). */
113
- getAddress(): Promise<string>;
114
- /**
115
- * Resolves to a fully-encoded raw signed transaction (a 0x-hex
116
- * string). For secp256k1 this is the canonical EIP-1559 RLP that
117
- * `eth_sendRawTransaction` expects.
118
- */
119
- signTransaction(tx: TransactionRequest): Promise<string>;
120
- /**
121
- * Resolves to an EIP-191 personal-sign signature (`0x` + 65 bytes
122
- * for secp256k1 / variable for non-recoverable algorithms).
123
- */
124
- signMessage(message: string | Uint8Array): Promise<string>;
125
- /** Resolves to an EIP-712 typed-data signature. */
126
- signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, unknown>): Promise<string>;
127
- }
128
- /**
129
- * `MonolythiumSigner` — ethers v6 `Signer` for the Monolythium chain.
130
- *
131
- * Construct one of three ways:
132
- *
133
- * 1. `MonolythiumSigner.fromEthersWallet(wallet, provider)` — the
134
- * fastest path; wraps a normal `ethers.Wallet`.
135
- * 2. `new MonolythiumSigner(backend, provider)` — supply any object
136
- * implementing `MonolythiumSignerBackend`.
137
- *
138
- * The signer is compatible with ethers v6 migration flows: it can be passed
139
- * anywhere a `Signer` is accepted and supports legacy contract deploy/call
140
- * helpers plus `provider.broadcastTransaction(signed)`. New v4.1 app paths
141
- * should use native MRV/RISC-V builders instead.
142
- */
143
- declare class MonolythiumSigner extends AbstractSigner<Provider | null> {
144
- #private;
145
- constructor(backend: MonolythiumSignerBackend, provider?: Provider | null);
146
- /**
147
- * Wrap any ethers v6 `BaseWallet` (the parent class of `Wallet`,
148
- * `HDNodeWallet`, and friends) so callers don't have to write a
149
- * `MonolythiumSignerBackend` for the common test / dev path.
150
- *
151
- * Both `new Wallet(privateKey)` and `Wallet.createRandom()` /
152
- * `HDNodeWallet.fromMnemonic(...)` are accepted.
153
- */
154
- static fromEthersWallet(wallet: BaseWallet, provider?: Provider | null): MonolythiumSigner;
155
- getAddress(): Promise<string>;
156
- connect(provider: Provider | null): Signer;
157
- signTransaction(tx: TransactionRequest): Promise<string>;
158
- signMessage(message: string | Uint8Array): Promise<string>;
159
- signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, unknown>): Promise<string>;
160
- }
161
-
162
- /**
163
- * Tx wire translation between ethers.js and `mono-core`.
164
- *
165
- * The chain natively accepts EIP-1559-shape EVM transactions on the
166
- * `Tx::Evm` (kind tag `0x01`) wire path — a `SignedTransaction` payload
167
- * carries the legacy EIP-1559 envelope plus the secp256k1 signature.
168
- * That makes the round-trip simple: ethers produces the canonical
169
- * EIP-1559 RLP, the client posts it via `eth_sendRawTransaction`, the
170
- * chain decodes it, and the receipt comes back through the same
171
- * `eth_getTransactionReceipt` shape ethers expects.
172
- *
173
- * Two notes for any future maintainer:
174
- *
175
- * 1. **No chain-level Ethereum retrofit.** This shim is SDK-only — see
176
- * `feedback_no_ethereum_wire_retrofit.md`. The chain keeps its
177
- * custom envelope and native tx hash for the protocol-native path
178
- * (ML-DSA-65 signing, native tx kinds beyond EVM). The shim only
179
- * spans the **EIP-1559 EVM subset** of the chain's tx surface.
180
- * 2. **Fields ethers does not see.** Monolythium-specific extension
181
- * fields (privacy flags, native tx kinds, ML-DSA-65 signatures) are
182
- * intentionally dropped by these helpers. Callers that need those
183
- * surfaces use the native SDK signer trait, not the ethers shim.
184
- */
185
-
186
- /**
187
- * The EIP-1559 subset of fields ethers' `TransactionRequest` carries
188
- * across the shim. We don't import ethers' type here so the shim can be
189
- * compiled (and its types re-exported) even when ethers isn't installed
190
- * — ethers is a peerDependency, not a hard dependency.
191
- */
192
- interface EthersTxRequestSubset {
193
- to?: string | null;
194
- from?: string | null;
195
- nonce?: number | bigint | null;
196
- gasLimit?: bigint | string | null;
197
- gasPrice?: bigint | string | null;
198
- maxFeePerGas?: bigint | string | null;
199
- maxPriorityFeePerGas?: bigint | string | null;
200
- value?: bigint | string | null;
201
- data?: string | null;
202
- chainId?: bigint | number | null;
203
- type?: number | null;
204
- }
205
- /**
206
- * Translate ethers' `TransactionRequest` into the wire shape the
207
- * `mono-core` JSON-RPC accepts for `eth_call` / `eth_estimateGas`.
208
- *
209
- * Returns the SDK's `CallRequest` shape (which mirrors the chain's
210
- * accepted `eth_call` argument). Round-trips losslessly for the
211
- * EIP-1559 EVM subset; Monolythium-specific extension fields are
212
- * intentionally not surfaced here.
213
- */
214
- declare function translateTxIn(req: EthersTxRequestSubset): CallRequest;
215
- /**
216
- * The ethers v6 wire shape for `eth_getTransactionReceipt`. We hand-roll
217
- * this rather than importing ethers' internal types because the shim
218
- * has to compile without ethers installed (peerDependency).
219
- *
220
- * Field naming and casing match what `JsonRpcApiProvider._perform` expects
221
- * back — the provider then normalises into ethers' rich
222
- * `TransactionReceipt` for callers.
223
- */
224
- interface EthersReceiptShape {
225
- transactionHash: string;
226
- blockHash: string;
227
- blockNumber: string;
228
- transactionIndex: string;
229
- status: string;
230
- gasUsed: string;
231
- cumulativeGasUsed: string;
232
- effectiveGasPrice: string;
233
- contractAddress: string | null;
234
- from: string;
235
- to: string | null;
236
- type: string;
237
- logsBloom: string;
238
- logs: unknown[];
239
- }
240
- /**
241
- * Translate `mono-core`'s native `TransactionReceipt` into the wire
242
- * shape ethers expects. Required for `eth_getTransactionReceipt` to
243
- * surface a usable `TransactionResponse` to ethers callers.
244
- *
245
- * The chain's receipt today is intentionally narrow — log emission,
246
- * cumulative execution-unit aggregation, and effective-fee disclosure are
247
- * tracked OI items. This translator fills in zero-equivalent values for
248
- * those gaps; callers that need the full native surface consume the SDK
249
- * receipt shape directly.
250
- */
251
- declare function translateReceiptOut(monoReceipt: TransactionReceipt, fromAddress: string | null, toAddress: string | null): EthersReceiptShape;
252
- /**
253
- * Translate `mono-core`'s `BlockHeader` into the ethers v6 wire shape
254
- * for `eth_getBlockByNumber` / `eth_getBlockByHash`.
255
- *
256
- * The chain's block header is intentionally narrower than Ethereum's
257
- * — it omits fields that don't exist in Monolythium (uncles, mix hash,
258
- * difficulty, nonce, sha3Uncles). This translator emits zero-valued
259
- * stand-ins so ethers' normaliser does not throw. Callers needing the
260
- * authoritative shape import the native `BlockHeader` from the SDK.
261
- */
262
- interface EthersBlockShape {
263
- number: string;
264
- hash: string;
265
- parentHash: string;
266
- timestamp: string;
267
- gasUsed: string;
268
- gasLimit: string;
269
- stateRoot: string;
270
- miner: string;
271
- difficulty: string;
272
- nonce: string;
273
- baseFeePerGas: string | null;
274
- extraData: string;
275
- mixHash: string;
276
- transactions: string[];
277
- transactionsRoot: string;
278
- receiptsRoot: string;
279
- logsBloom: string;
280
- sha3Uncles: string;
281
- uncles: string[];
282
- size: string;
283
- }
284
- /**
285
- * Translate `mono-core`'s `BlockHeader` to the ethers wire shape.
286
- * `transactions` defaults to an empty list — the SDK's
287
- * `eth_getBlockByNumber` does not yet return tx hashes; once Stage 1+
288
- * surfaces them, callers update this translator.
289
- */
290
- declare function translateBlockOut(header: {
291
- number: bigint;
292
- hash: string;
293
- parent_hash: string;
294
- state_root: string;
295
- timestamp: bigint;
296
- executionUnitsUsed: bigint;
297
- executionUnitLimit: bigint;
298
- }): EthersBlockShape;
299
-
300
- export { type EthersBlockShape, type EthersReceiptShape, type EthersTxRequestSubset, MonolythiumNetworkConfig, MonolythiumProvider, type MonolythiumProviderOptions, MonolythiumSigner, type MonolythiumSignerBackend, translateBlockOut, translateReceiptOut, translateTxIn };