@moon-x/core 0.10.1 → 0.12.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,6 +1,6 @@
1
1
  export { C as CachedAssertion, g as generatePasskeyUserId } from '../passkey-cache-WnDFQ-v4.mjs';
2
2
  export { a as PasskeyFormFactor, P as PasskeyMetadata, b as PasskeyMetadataInput, f as formatPasskeyLabel, r as resolvePasskeyMetadata } from '../passkey-metadata-QqFF2SWQ.mjs';
3
- import { Chain, WalletChain } from '../types/index.mjs';
3
+ import { ChainEntry, ChainConfigItem, Chain, EvmChainEntry, SolanaChainEntry, WalletChain } from '../types/index.mjs';
4
4
  import { SiweMessage } from 'siwe';
5
5
  import { Connection, PublicKey } from '@solana/web3.js';
6
6
 
@@ -45,13 +45,6 @@ declare const toB64url: (bytes: Uint8Array) => string;
45
45
  * Chain utilities for MoonKey
46
46
  */
47
47
 
48
- /**
49
- * Set a custom RPC URL for a chain
50
- * @param chain - The chain to configure
51
- * @param rpcUrl - The custom RPC URL
52
- * @returns A new chain object with the custom RPC URL
53
- */
54
- declare function setChainRpcUrl(chain: Chain, rpcUrl: string): Chain;
55
48
  /**
56
49
  * Get the RPC URL for a chain
57
50
  * @param chain - The chain to get the RPC URL for
@@ -122,35 +115,105 @@ declare function estimateEvmGasReserve(rpcUrl: string, chainId: number, opts?: {
122
115
  bufferBps?: number;
123
116
  }): Promise<number>;
124
117
  /**
125
- * Find a chain by its ID
126
- * @param chains - Array of chains to search
127
- * @param chainId - The chain ID to find
128
- * @returns The matching chain or undefined
118
+ * Find a viem `Chain` by its numeric chain ID.
119
+ *
120
+ * Accepts the unified `ChainConfigItem[]` shape: each element may be a bare
121
+ * viem `Chain`, an `{ chain, rpcUrl? }` EVM entry, or a Solana entry. The id
122
+ * lives on `chain.id` for entry-form items, so we normalize before comparing
123
+ * — a plain `item.id` check would miss every `{ chain }` entry (the documented
124
+ * override shape). Solana entries (string id) never match a numeric chainId.
129
125
  */
130
- declare function getChainById(chains: Chain[], chainId: number): Chain | undefined;
126
+ declare function getChainById(chains: ChainConfigItem[], chainId: number): Chain | undefined;
131
127
  /**
132
- * Check if a chain is supported
133
- * @param chains - Array of supported chains
134
- * @param chainId - The chain ID to check
135
- * @returns True if the chain is supported
128
+ * Check if a numeric chain ID is configured. Handles the unified
129
+ * `ChainConfigItem[]` shape (see `getChainById`).
136
130
  */
137
- declare function isChainSupported(chains: Chain[], chainId: number): boolean;
131
+ declare function isChainSupported(chains: ChainConfigItem[], chainId: number): boolean;
132
+ /** Type guard: is this normalized entry an EVM entry (carries a viem Chain)? */
133
+ declare function isEvmEntry(entry: ChainEntry): entry is EvmChainEntry;
138
134
  /**
139
- * Validate chain configuration
140
- * Throws an error if configuration is invalid
135
+ * Coerce a `ChainConfigItem` to its normalized form. A bare viem `Chain`
136
+ * (numeric `id`) becomes an `EvmChainEntry`; `{ chain, … }` is already one;
137
+ * anything else (string `id`) is a `SolanaChainEntry`.
141
138
  */
142
- declare function validateChainConfig(config: {
143
- defaultChain?: Chain;
144
- supportedChains?: Chain[];
145
- }): void;
139
+ declare function normalizeChainItem(item: ChainConfigItem): ChainEntry;
140
+ /** Canonical CAIP-2 id for a normalized entry. */
141
+ declare function entryCaip2(entry: ChainEntry): string;
142
+ interface ChainIndex {
143
+ /** Normalized entries in declaration order. */
144
+ entries: ChainEntry[];
145
+ /** Normalized alias key -> entry (first declaration wins on collision). */
146
+ byAlias: Map<string, ChainEntry>;
147
+ }
148
+ /**
149
+ * Normalize a chain reference to its alias-lookup key. Numbers → `eip155:<id>`.
150
+ *
151
+ * Throws a clear error on anything that isn't a string or number — most often
152
+ * an old-shape viem `Chain` object passed where a reference is now expected
153
+ * (e.g. `defaultChain: mainnet`). Without this guard the bare `.trim()` below
154
+ * would surface an opaque `TypeError`.
155
+ */
156
+ declare function normalizeChainKey(key: string | number): string;
157
+ /** Normalize every element and build the alias→entry index. */
158
+ declare function buildChainIndex(chains?: ChainConfigItem[]): ChainIndex;
159
+ /**
160
+ * Resolve a chain entry from the config by selector (alias | CAIP-2 | numeric
161
+ * chainId | Solana id). With no selector, falls back to `defaultSelector`, then
162
+ * to the first configured chain. Returns undefined when nothing matches.
163
+ */
164
+ declare function resolveChainEntry(chains: ChainConfigItem[] | undefined, selector?: string | number, defaultSelector?: string | number): ChainEntry | undefined;
165
+ /**
166
+ * Resolve a SOLANA entry, honoring (highest priority first): per-call
167
+ * `selector` → `defaultSelector` (`config.defaultChain`, when it points at a
168
+ * Solana cluster) → first configured Solana entry. This mirrors the EVM hooks
169
+ * and the documented precedence — rather than hardcoding `solana:mainnet`.
170
+ *
171
+ * Constrained to non-EVM entries so a Solana operation can never resolve an
172
+ * Ethereum chain: any selector (per-call or default) that matches an EVM alias
173
+ * (e.g. `8453` / `"eip155:8453"` / `"eth:base"`) is ignored rather than handing
174
+ * back an EVM HTTP RPC. An explicit `selector` that doesn't resolve to a Solana
175
+ * entry returns `undefined` (no fall-through) — fails closed, so the Solana
176
+ * hooks throw a clear "no RPC URL" error.
177
+ */
178
+ declare function resolveSolanaChainEntry(chains: ChainConfigItem[] | undefined, selector?: string | number, defaultSelector?: string | number): SolanaChainEntry | undefined;
146
179
  /**
147
- * Get the default chain from config
148
- * If no defaultChain is set but supportedChains is set, returns the first supported chain
180
+ * Resolve the EVM entry to use, honoring (highest priority first):
181
+ * per-call `selector` tx `requestedChainId` `walletChainId`
182
+ * `defaultSelector` → first EVM entry.
183
+ *
184
+ * Crucially, an EXPLICIT input (`selector` or `requestedChainId`) must resolve
185
+ * to a configured EVM chain — if one is provided but doesn't match, this
186
+ * returns `undefined` WITHOUT silently falling back to the wallet chain /
187
+ * default / first entry. A caller that named a network it didn't configure
188
+ * must hear about it (the hooks turn this into a clear error), rather than
189
+ * having the send/read quietly run on a different chain. Implicit sources
190
+ * (`walletChainId`, `defaultSelector`, first entry) are consulted only when no
191
+ * explicit input is given.
149
192
  */
150
- declare function getDefaultChain(config: {
151
- defaultChain?: Chain;
152
- supportedChains?: Chain[];
153
- }): Chain | undefined;
193
+ declare function resolveEvmChainEntry(opts: {
194
+ chains?: ChainConfigItem[];
195
+ selector?: string | number;
196
+ requestedChainId?: number;
197
+ walletChainId?: number;
198
+ defaultSelector?: string | number;
199
+ }): EvmChainEntry | undefined;
200
+ /**
201
+ * Resolve the HTTP RPC URL for an entry. An explicit `override` (per-call
202
+ * `rpcUrl`) always wins; otherwise the entry's `rpcUrl`, then the viem chain's
203
+ * built-in default (EVM only).
204
+ */
205
+ declare function resolveRpcUrl(entry: ChainEntry, override?: string): string;
206
+ /** Resolve the WebSocket URL for an entry, with the same override precedence. */
207
+ declare function resolveWsUrl(entry: ChainEntry, override?: string): string | undefined;
208
+ /**
209
+ * Validate the unified chain config. Throws on an empty `chains` array,
210
+ * duplicate canonical ids, a Solana entry missing its `rpcUrl`, or a
211
+ * `defaultChain` that doesn't reference a configured chain.
212
+ */
213
+ declare function validateChainConfig(config: {
214
+ chains?: ChainConfigItem[];
215
+ defaultChain?: string | number;
216
+ }): void;
154
217
 
155
218
  interface EthereumSiweMessageProps {
156
219
  nonce: string;
@@ -205,34 +268,50 @@ interface EvmTxPrepWallet {
205
268
  chainId?: number;
206
269
  }
207
270
  interface ChainResolutionInput {
271
+ /** Unified chain config (`config.chains`). */
272
+ chains?: ChainConfigItem[];
273
+ /** Per-call chain selector (`params.chain`): alias | CAIP-2 | numeric id. */
274
+ chainSelector?: string | number;
208
275
  /** Pull from the input transaction's `chainId` if the caller was explicit. */
209
276
  requestedChainId?: number;
210
277
  /** Wallet's bound chain, if any. */
211
278
  walletChainId?: number;
212
- supportedChains?: Chain[];
213
- defaultChain?: Chain;
279
+ /** Provider-level default chain reference (`config.defaultChain`). */
280
+ defaultChain?: string | number;
281
+ /** Per-call inline `rpcUrl` override. */
282
+ rpcUrlOverride?: string;
214
283
  /**
215
- * When true, reject if requestedChainId is not in supportedChains.
284
+ * When true, reject if an explicit requested chain isn't configured.
216
285
  * Sign-only paths leave this false (best-effort fallback to default).
217
286
  * Send paths set it true so a Base tx never silently broadcasts to mainnet.
218
287
  */
219
288
  strict?: boolean;
220
289
  }
221
290
  /**
222
- * Resolve which chain to use for the operation.
291
+ * Resolve which chain (and RPC URL) to use for the operation.
223
292
  *
224
- * Priority:
225
- * 1. `requestedChainId` from the transaction (caller is explicit).
226
- * 2. `walletChainId` from the wallet's bound chain.
227
- * 3. `defaultChain` from provider config.
293
+ * Priority: per-call `chainSelector` → tx `requestedChainId` →
294
+ * `walletChainId` `defaultChain` first configured EVM chain.
228
295
  *
229
- * Under `strict: true`, an explicit `requestedChainId` outside the
230
- * configured `supportedChains` throws — sending a Base tx through a
231
- * mainnet RPC would otherwise silently land on the wrong chain. Sign-
232
- * only flows (where there's no broadcast) leave strict off so the
233
- * fallback to defaultChain is allowed.
296
+ * Explicit selections are honored exactly they never silently degrade to a
297
+ * different chain:
298
+ * - An explicit `chainSelector` that isn't configured ALWAYS throws (the
299
+ * caller named a network that doesn't exist), even if an `rpcUrlOverride`
300
+ * is present a one-off override is addressed by `requestedChainId`, not
301
+ * by a chain alias.
302
+ * - An explicit `requestedChainId` that isn't configured does NOT fall back
303
+ * to the wallet / default chain. With an `rpcUrlOverride` it becomes a
304
+ * one-off: the tx serializes against `requestedChainId` and broadcasts via
305
+ * the override (so a Polygon tx never gets rewritten to mainnet's id).
306
+ * Without an override it throws under `strict`, or falls through to
307
+ * implicit resolution on the sign path (`strict: false`).
308
+ *
309
+ * An `rpcUrlOverride` overrides the transport for whichever chain is resolved.
234
310
  */
235
- declare function resolveEvmChain({ requestedChainId, walletChainId, supportedChains, defaultChain, strict, }: ChainResolutionInput): Chain;
311
+ declare function resolveEvmChain({ chains, chainSelector, requestedChainId, walletChainId, defaultChain, rpcUrlOverride, strict, }: ChainResolutionInput): {
312
+ chain: Chain;
313
+ rpcUrl: string;
314
+ };
236
315
  /**
237
316
  * Sign-path prep. Converts an input transaction (string or object) into
238
317
  * the serialized RLP string the iframe-side signer expects. Handles
@@ -241,11 +320,12 @@ declare function resolveEvmChain({ requestedChainId, walletChainId, supportedCha
241
320
  * No RPC calls — caller can sign now and broadcast later. Returns the
242
321
  * resolved chain too so the hook can stash it if needed.
243
322
  */
244
- declare function prepareEvmSignTransaction({ transaction, wallet, supportedChains, defaultChain, }: {
323
+ declare function prepareEvmSignTransaction({ transaction, wallet, chains, defaultChain, chainSelector, }: {
245
324
  transaction: string | EvmTransactionInput;
246
325
  wallet: EvmTxPrepWallet;
247
- supportedChains?: Chain[];
248
- defaultChain?: Chain;
326
+ chains?: ChainConfigItem[];
327
+ defaultChain?: string | number;
328
+ chainSelector?: string | number;
249
329
  }): Promise<{
250
330
  serializedTransaction: string;
251
331
  chain: Chain | undefined;
@@ -275,11 +355,13 @@ declare function prepareEvmSignTransaction({ transaction, wallet, supportedChain
275
355
  * let the downstream serializer handle it. The caller gets a clearer
276
356
  * error from the chain than a silent stuck tx.
277
357
  */
278
- declare function prepareEvmSendTransaction({ transaction, wallet, supportedChains, defaultChain, }: {
358
+ declare function prepareEvmSendTransaction({ transaction, wallet, chains, defaultChain, chainSelector, rpcUrlOverride, }: {
279
359
  transaction: EvmTransactionInput;
280
360
  wallet: EvmTxPrepWallet;
281
- supportedChains?: Chain[];
282
- defaultChain?: Chain;
361
+ chains?: ChainConfigItem[];
362
+ defaultChain?: string | number;
363
+ chainSelector?: string | number;
364
+ rpcUrlOverride?: string;
283
365
  }): Promise<{
284
366
  transaction: EvmTransactionInput;
285
367
  rpcUrl: string;
@@ -437,4 +519,4 @@ declare const arrayLikeToBytes: (value: unknown) => Uint8Array;
437
519
  */
438
520
  declare const bs58ToBytes: (value: unknown) => Promise<Uint8Array>;
439
521
 
440
- export { type BuildUrlConfig, DEFAULT_AUTH_URL, EthereumSiweMessage, type EthereumSiweMessageProps, type EvmTransactionInput, type EvmTxPrepWallet, type ManualSiweMessageProps, SiwsMessage, SolanaTransactionParser, type VerifyIdTokenResponse, arrayLikeToBytes, authState, broadcastEthereumRaw, broadcastSolanaSigned, bs58ToBytes, buildUrl, canonicalAlgorithmFor, createManualSiweMessage, estimateEvmGas, estimateEvmGasReserve, fromB64url, getChainById, getDefaultChain, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getInstructionsForHTML, getRpcUrl, getSOLTransfersFromInstructions, getTransferInfoFromInstructions, isChainSupported, parseDerivationPath, prepareEvmSendTransaction, prepareEvmSignTransaction, resolveEvmChain, sanitizeUserData, serializeEthereumTransaction, setChainRpcUrl, toB64url, validateChainConfig, verifyIdToken };
522
+ export { type BuildUrlConfig, type ChainIndex, DEFAULT_AUTH_URL, EthereumSiweMessage, type EthereumSiweMessageProps, type EvmTransactionInput, type EvmTxPrepWallet, type ManualSiweMessageProps, SiwsMessage, SolanaTransactionParser, type VerifyIdTokenResponse, arrayLikeToBytes, authState, broadcastEthereumRaw, broadcastSolanaSigned, bs58ToBytes, buildChainIndex, buildUrl, canonicalAlgorithmFor, createManualSiweMessage, entryCaip2, estimateEvmGas, estimateEvmGasReserve, fromB64url, getChainById, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getInstructionsForHTML, getRpcUrl, getSOLTransfersFromInstructions, getTransferInfoFromInstructions, isChainSupported, isEvmEntry, normalizeChainItem, normalizeChainKey, parseDerivationPath, prepareEvmSendTransaction, prepareEvmSignTransaction, resolveChainEntry, resolveEvmChain, resolveEvmChainEntry, resolveRpcUrl, resolveSolanaChainEntry, resolveWsUrl, sanitizeUserData, serializeEthereumTransaction, toB64url, validateChainConfig, verifyIdToken };
@@ -1,6 +1,6 @@
1
1
  export { C as CachedAssertion, g as generatePasskeyUserId } from '../passkey-cache-WnDFQ-v4.js';
2
2
  export { a as PasskeyFormFactor, P as PasskeyMetadata, b as PasskeyMetadataInput, f as formatPasskeyLabel, r as resolvePasskeyMetadata } from '../passkey-metadata-QqFF2SWQ.js';
3
- import { Chain, WalletChain } from '../types/index.js';
3
+ import { ChainEntry, ChainConfigItem, Chain, EvmChainEntry, SolanaChainEntry, WalletChain } from '../types/index.js';
4
4
  import { SiweMessage } from 'siwe';
5
5
  import { Connection, PublicKey } from '@solana/web3.js';
6
6
 
@@ -45,13 +45,6 @@ declare const toB64url: (bytes: Uint8Array) => string;
45
45
  * Chain utilities for MoonKey
46
46
  */
47
47
 
48
- /**
49
- * Set a custom RPC URL for a chain
50
- * @param chain - The chain to configure
51
- * @param rpcUrl - The custom RPC URL
52
- * @returns A new chain object with the custom RPC URL
53
- */
54
- declare function setChainRpcUrl(chain: Chain, rpcUrl: string): Chain;
55
48
  /**
56
49
  * Get the RPC URL for a chain
57
50
  * @param chain - The chain to get the RPC URL for
@@ -122,35 +115,105 @@ declare function estimateEvmGasReserve(rpcUrl: string, chainId: number, opts?: {
122
115
  bufferBps?: number;
123
116
  }): Promise<number>;
124
117
  /**
125
- * Find a chain by its ID
126
- * @param chains - Array of chains to search
127
- * @param chainId - The chain ID to find
128
- * @returns The matching chain or undefined
118
+ * Find a viem `Chain` by its numeric chain ID.
119
+ *
120
+ * Accepts the unified `ChainConfigItem[]` shape: each element may be a bare
121
+ * viem `Chain`, an `{ chain, rpcUrl? }` EVM entry, or a Solana entry. The id
122
+ * lives on `chain.id` for entry-form items, so we normalize before comparing
123
+ * — a plain `item.id` check would miss every `{ chain }` entry (the documented
124
+ * override shape). Solana entries (string id) never match a numeric chainId.
129
125
  */
130
- declare function getChainById(chains: Chain[], chainId: number): Chain | undefined;
126
+ declare function getChainById(chains: ChainConfigItem[], chainId: number): Chain | undefined;
131
127
  /**
132
- * Check if a chain is supported
133
- * @param chains - Array of supported chains
134
- * @param chainId - The chain ID to check
135
- * @returns True if the chain is supported
128
+ * Check if a numeric chain ID is configured. Handles the unified
129
+ * `ChainConfigItem[]` shape (see `getChainById`).
136
130
  */
137
- declare function isChainSupported(chains: Chain[], chainId: number): boolean;
131
+ declare function isChainSupported(chains: ChainConfigItem[], chainId: number): boolean;
132
+ /** Type guard: is this normalized entry an EVM entry (carries a viem Chain)? */
133
+ declare function isEvmEntry(entry: ChainEntry): entry is EvmChainEntry;
138
134
  /**
139
- * Validate chain configuration
140
- * Throws an error if configuration is invalid
135
+ * Coerce a `ChainConfigItem` to its normalized form. A bare viem `Chain`
136
+ * (numeric `id`) becomes an `EvmChainEntry`; `{ chain, … }` is already one;
137
+ * anything else (string `id`) is a `SolanaChainEntry`.
141
138
  */
142
- declare function validateChainConfig(config: {
143
- defaultChain?: Chain;
144
- supportedChains?: Chain[];
145
- }): void;
139
+ declare function normalizeChainItem(item: ChainConfigItem): ChainEntry;
140
+ /** Canonical CAIP-2 id for a normalized entry. */
141
+ declare function entryCaip2(entry: ChainEntry): string;
142
+ interface ChainIndex {
143
+ /** Normalized entries in declaration order. */
144
+ entries: ChainEntry[];
145
+ /** Normalized alias key -> entry (first declaration wins on collision). */
146
+ byAlias: Map<string, ChainEntry>;
147
+ }
148
+ /**
149
+ * Normalize a chain reference to its alias-lookup key. Numbers → `eip155:<id>`.
150
+ *
151
+ * Throws a clear error on anything that isn't a string or number — most often
152
+ * an old-shape viem `Chain` object passed where a reference is now expected
153
+ * (e.g. `defaultChain: mainnet`). Without this guard the bare `.trim()` below
154
+ * would surface an opaque `TypeError`.
155
+ */
156
+ declare function normalizeChainKey(key: string | number): string;
157
+ /** Normalize every element and build the alias→entry index. */
158
+ declare function buildChainIndex(chains?: ChainConfigItem[]): ChainIndex;
159
+ /**
160
+ * Resolve a chain entry from the config by selector (alias | CAIP-2 | numeric
161
+ * chainId | Solana id). With no selector, falls back to `defaultSelector`, then
162
+ * to the first configured chain. Returns undefined when nothing matches.
163
+ */
164
+ declare function resolveChainEntry(chains: ChainConfigItem[] | undefined, selector?: string | number, defaultSelector?: string | number): ChainEntry | undefined;
165
+ /**
166
+ * Resolve a SOLANA entry, honoring (highest priority first): per-call
167
+ * `selector` → `defaultSelector` (`config.defaultChain`, when it points at a
168
+ * Solana cluster) → first configured Solana entry. This mirrors the EVM hooks
169
+ * and the documented precedence — rather than hardcoding `solana:mainnet`.
170
+ *
171
+ * Constrained to non-EVM entries so a Solana operation can never resolve an
172
+ * Ethereum chain: any selector (per-call or default) that matches an EVM alias
173
+ * (e.g. `8453` / `"eip155:8453"` / `"eth:base"`) is ignored rather than handing
174
+ * back an EVM HTTP RPC. An explicit `selector` that doesn't resolve to a Solana
175
+ * entry returns `undefined` (no fall-through) — fails closed, so the Solana
176
+ * hooks throw a clear "no RPC URL" error.
177
+ */
178
+ declare function resolveSolanaChainEntry(chains: ChainConfigItem[] | undefined, selector?: string | number, defaultSelector?: string | number): SolanaChainEntry | undefined;
146
179
  /**
147
- * Get the default chain from config
148
- * If no defaultChain is set but supportedChains is set, returns the first supported chain
180
+ * Resolve the EVM entry to use, honoring (highest priority first):
181
+ * per-call `selector` tx `requestedChainId` `walletChainId`
182
+ * `defaultSelector` → first EVM entry.
183
+ *
184
+ * Crucially, an EXPLICIT input (`selector` or `requestedChainId`) must resolve
185
+ * to a configured EVM chain — if one is provided but doesn't match, this
186
+ * returns `undefined` WITHOUT silently falling back to the wallet chain /
187
+ * default / first entry. A caller that named a network it didn't configure
188
+ * must hear about it (the hooks turn this into a clear error), rather than
189
+ * having the send/read quietly run on a different chain. Implicit sources
190
+ * (`walletChainId`, `defaultSelector`, first entry) are consulted only when no
191
+ * explicit input is given.
149
192
  */
150
- declare function getDefaultChain(config: {
151
- defaultChain?: Chain;
152
- supportedChains?: Chain[];
153
- }): Chain | undefined;
193
+ declare function resolveEvmChainEntry(opts: {
194
+ chains?: ChainConfigItem[];
195
+ selector?: string | number;
196
+ requestedChainId?: number;
197
+ walletChainId?: number;
198
+ defaultSelector?: string | number;
199
+ }): EvmChainEntry | undefined;
200
+ /**
201
+ * Resolve the HTTP RPC URL for an entry. An explicit `override` (per-call
202
+ * `rpcUrl`) always wins; otherwise the entry's `rpcUrl`, then the viem chain's
203
+ * built-in default (EVM only).
204
+ */
205
+ declare function resolveRpcUrl(entry: ChainEntry, override?: string): string;
206
+ /** Resolve the WebSocket URL for an entry, with the same override precedence. */
207
+ declare function resolveWsUrl(entry: ChainEntry, override?: string): string | undefined;
208
+ /**
209
+ * Validate the unified chain config. Throws on an empty `chains` array,
210
+ * duplicate canonical ids, a Solana entry missing its `rpcUrl`, or a
211
+ * `defaultChain` that doesn't reference a configured chain.
212
+ */
213
+ declare function validateChainConfig(config: {
214
+ chains?: ChainConfigItem[];
215
+ defaultChain?: string | number;
216
+ }): void;
154
217
 
155
218
  interface EthereumSiweMessageProps {
156
219
  nonce: string;
@@ -205,34 +268,50 @@ interface EvmTxPrepWallet {
205
268
  chainId?: number;
206
269
  }
207
270
  interface ChainResolutionInput {
271
+ /** Unified chain config (`config.chains`). */
272
+ chains?: ChainConfigItem[];
273
+ /** Per-call chain selector (`params.chain`): alias | CAIP-2 | numeric id. */
274
+ chainSelector?: string | number;
208
275
  /** Pull from the input transaction's `chainId` if the caller was explicit. */
209
276
  requestedChainId?: number;
210
277
  /** Wallet's bound chain, if any. */
211
278
  walletChainId?: number;
212
- supportedChains?: Chain[];
213
- defaultChain?: Chain;
279
+ /** Provider-level default chain reference (`config.defaultChain`). */
280
+ defaultChain?: string | number;
281
+ /** Per-call inline `rpcUrl` override. */
282
+ rpcUrlOverride?: string;
214
283
  /**
215
- * When true, reject if requestedChainId is not in supportedChains.
284
+ * When true, reject if an explicit requested chain isn't configured.
216
285
  * Sign-only paths leave this false (best-effort fallback to default).
217
286
  * Send paths set it true so a Base tx never silently broadcasts to mainnet.
218
287
  */
219
288
  strict?: boolean;
220
289
  }
221
290
  /**
222
- * Resolve which chain to use for the operation.
291
+ * Resolve which chain (and RPC URL) to use for the operation.
223
292
  *
224
- * Priority:
225
- * 1. `requestedChainId` from the transaction (caller is explicit).
226
- * 2. `walletChainId` from the wallet's bound chain.
227
- * 3. `defaultChain` from provider config.
293
+ * Priority: per-call `chainSelector` → tx `requestedChainId` →
294
+ * `walletChainId` `defaultChain` first configured EVM chain.
228
295
  *
229
- * Under `strict: true`, an explicit `requestedChainId` outside the
230
- * configured `supportedChains` throws — sending a Base tx through a
231
- * mainnet RPC would otherwise silently land on the wrong chain. Sign-
232
- * only flows (where there's no broadcast) leave strict off so the
233
- * fallback to defaultChain is allowed.
296
+ * Explicit selections are honored exactly they never silently degrade to a
297
+ * different chain:
298
+ * - An explicit `chainSelector` that isn't configured ALWAYS throws (the
299
+ * caller named a network that doesn't exist), even if an `rpcUrlOverride`
300
+ * is present a one-off override is addressed by `requestedChainId`, not
301
+ * by a chain alias.
302
+ * - An explicit `requestedChainId` that isn't configured does NOT fall back
303
+ * to the wallet / default chain. With an `rpcUrlOverride` it becomes a
304
+ * one-off: the tx serializes against `requestedChainId` and broadcasts via
305
+ * the override (so a Polygon tx never gets rewritten to mainnet's id).
306
+ * Without an override it throws under `strict`, or falls through to
307
+ * implicit resolution on the sign path (`strict: false`).
308
+ *
309
+ * An `rpcUrlOverride` overrides the transport for whichever chain is resolved.
234
310
  */
235
- declare function resolveEvmChain({ requestedChainId, walletChainId, supportedChains, defaultChain, strict, }: ChainResolutionInput): Chain;
311
+ declare function resolveEvmChain({ chains, chainSelector, requestedChainId, walletChainId, defaultChain, rpcUrlOverride, strict, }: ChainResolutionInput): {
312
+ chain: Chain;
313
+ rpcUrl: string;
314
+ };
236
315
  /**
237
316
  * Sign-path prep. Converts an input transaction (string or object) into
238
317
  * the serialized RLP string the iframe-side signer expects. Handles
@@ -241,11 +320,12 @@ declare function resolveEvmChain({ requestedChainId, walletChainId, supportedCha
241
320
  * No RPC calls — caller can sign now and broadcast later. Returns the
242
321
  * resolved chain too so the hook can stash it if needed.
243
322
  */
244
- declare function prepareEvmSignTransaction({ transaction, wallet, supportedChains, defaultChain, }: {
323
+ declare function prepareEvmSignTransaction({ transaction, wallet, chains, defaultChain, chainSelector, }: {
245
324
  transaction: string | EvmTransactionInput;
246
325
  wallet: EvmTxPrepWallet;
247
- supportedChains?: Chain[];
248
- defaultChain?: Chain;
326
+ chains?: ChainConfigItem[];
327
+ defaultChain?: string | number;
328
+ chainSelector?: string | number;
249
329
  }): Promise<{
250
330
  serializedTransaction: string;
251
331
  chain: Chain | undefined;
@@ -275,11 +355,13 @@ declare function prepareEvmSignTransaction({ transaction, wallet, supportedChain
275
355
  * let the downstream serializer handle it. The caller gets a clearer
276
356
  * error from the chain than a silent stuck tx.
277
357
  */
278
- declare function prepareEvmSendTransaction({ transaction, wallet, supportedChains, defaultChain, }: {
358
+ declare function prepareEvmSendTransaction({ transaction, wallet, chains, defaultChain, chainSelector, rpcUrlOverride, }: {
279
359
  transaction: EvmTransactionInput;
280
360
  wallet: EvmTxPrepWallet;
281
- supportedChains?: Chain[];
282
- defaultChain?: Chain;
361
+ chains?: ChainConfigItem[];
362
+ defaultChain?: string | number;
363
+ chainSelector?: string | number;
364
+ rpcUrlOverride?: string;
283
365
  }): Promise<{
284
366
  transaction: EvmTransactionInput;
285
367
  rpcUrl: string;
@@ -437,4 +519,4 @@ declare const arrayLikeToBytes: (value: unknown) => Uint8Array;
437
519
  */
438
520
  declare const bs58ToBytes: (value: unknown) => Promise<Uint8Array>;
439
521
 
440
- export { type BuildUrlConfig, DEFAULT_AUTH_URL, EthereumSiweMessage, type EthereumSiweMessageProps, type EvmTransactionInput, type EvmTxPrepWallet, type ManualSiweMessageProps, SiwsMessage, SolanaTransactionParser, type VerifyIdTokenResponse, arrayLikeToBytes, authState, broadcastEthereumRaw, broadcastSolanaSigned, bs58ToBytes, buildUrl, canonicalAlgorithmFor, createManualSiweMessage, estimateEvmGas, estimateEvmGasReserve, fromB64url, getChainById, getDefaultChain, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getInstructionsForHTML, getRpcUrl, getSOLTransfersFromInstructions, getTransferInfoFromInstructions, isChainSupported, parseDerivationPath, prepareEvmSendTransaction, prepareEvmSignTransaction, resolveEvmChain, sanitizeUserData, serializeEthereumTransaction, setChainRpcUrl, toB64url, validateChainConfig, verifyIdToken };
522
+ export { type BuildUrlConfig, type ChainIndex, DEFAULT_AUTH_URL, EthereumSiweMessage, type EthereumSiweMessageProps, type EvmTransactionInput, type EvmTxPrepWallet, type ManualSiweMessageProps, SiwsMessage, SolanaTransactionParser, type VerifyIdTokenResponse, arrayLikeToBytes, authState, broadcastEthereumRaw, broadcastSolanaSigned, bs58ToBytes, buildChainIndex, buildUrl, canonicalAlgorithmFor, createManualSiweMessage, entryCaip2, estimateEvmGas, estimateEvmGasReserve, fromB64url, getChainById, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getInstructionsForHTML, getRpcUrl, getSOLTransfersFromInstructions, getTransferInfoFromInstructions, isChainSupported, isEvmEntry, normalizeChainItem, normalizeChainKey, parseDerivationPath, prepareEvmSendTransaction, prepareEvmSignTransaction, resolveChainEntry, resolveEvmChain, resolveEvmChainEntry, resolveRpcUrl, resolveSolanaChainEntry, resolveWsUrl, sanitizeUserData, serializeEthereumTransaction, toB64url, validateChainConfig, verifyIdToken };