viem 2.56.2 → 2.56.3

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 +1 @@
1
- {"version":3,"file":"Zone.d.ts","sourceRoot":"","sources":["../../tempo/Zone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAI9C,kCAAkC;AAClC,wBAAgB,IAAI,CAAC,KAAK,CAAC,MAAM,SAAS,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM;;;;;;;;kBAQnC,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAR,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IAAI,CAAC,UAAU,EACvD,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;AAgB3B,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,KAAK,UAAU,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC,GAAG;QACjD,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IAEH,KAAK,WAAW,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,IAAI,MAAM,CAC/D,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,EAClD,MAAM,CACP,CAAA;CACF;AAED,eAAO,MAAM,CAAC;;;;;;;;;EASZ,CAAA;AAEF,eAAO,MAAM,CAAC;;;;;;;;;EASZ,CAAA;AAEF,eAAO,MAAM,QAAQ;;;;EAInB,CAAA;AAEF,eAAO,MAAM,eAAe;;;;EAI1B,CAAA"}
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.56.2'
1
+ export const version = '2.56.3'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.56.2",
4
+ "version": "2.56.3",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/tempo/Multisig.ts CHANGED
@@ -44,14 +44,19 @@ export function handleRequest(
44
44
  message:
45
45
  'Multisig coordination requires a store with atomic `compareAndSet`.',
46
46
  })
47
- const client = createClient({
48
- transport: custom({
49
- request: ({ method, params }, options) =>
50
- next({ method, params }, options),
51
- }),
52
- })
47
+ return async (request, requestOptions_) => {
48
+ const requestOptions = await resolveRequestOptions({
49
+ request,
50
+ requestOptions: requestOptions_,
51
+ store: parameters.store,
52
+ })
53
+ const client = createClient({
54
+ transport: custom({
55
+ request: ({ method, params }, options) =>
56
+ next({ method, params }, { ...requestOptions, ...options }),
57
+ }),
58
+ })
53
59
 
54
- return async (request, requestOptions) => {
55
60
  if (request.method === 'multisig_getConfig') {
56
61
  const value = request.params?.[0]
57
62
  const address =
@@ -200,7 +205,7 @@ export declare namespace handleRequest {
200
205
  /** RPC request handler. */
201
206
  export type Handler = (
202
207
  request: Request,
203
- options?: EIP1193RequestOptions | undefined,
208
+ options?: RequestOptions | undefined,
204
209
  ) => Promise<unknown>
205
210
 
206
211
  /** RPC request passed to a handler. */
@@ -211,6 +216,12 @@ export declare namespace handleRequest {
211
216
  params?: readonly unknown[] | undefined
212
217
  }
213
218
 
219
+ /** Options for one handled request. */
220
+ export type RequestOptions = EIP1193RequestOptions & {
221
+ /** Chain selected by the caller or inferred from the multisig request. */
222
+ chainId?: number | undefined
223
+ }
224
+
214
225
  /** Parameters for {@link handleRequest}. */
215
226
  export type Parameters = {
216
227
  /** Store shared by multisig coordinators. */
@@ -555,7 +566,7 @@ declare namespace submit {
555
566
  /** Original RPC request. */
556
567
  request: handleRequest.Request
557
568
  /** Original request overrides. */
558
- requestOptions?: EIP1193RequestOptions | undefined
569
+ requestOptions?: handleRequest.RequestOptions | undefined
559
570
  /** Serialized Tempo transaction. */
560
571
  serialized: Hex.Hex
561
572
  /** Shared multisig store. */
@@ -1340,6 +1351,136 @@ function getTransactionHash(result: unknown): Hex.Hex {
1340
1351
  throw new Error('Expected transaction hash in multisig broadcast result.')
1341
1352
  }
1342
1353
 
1354
+ /** Resolves and validates the chain used by a handled request. */
1355
+ async function resolveRequestOptions(options: {
1356
+ request: handleRequest.Request
1357
+ requestOptions?: handleRequest.RequestOptions | undefined
1358
+ store: Store.Store
1359
+ }): Promise<handleRequest.RequestOptions | undefined> {
1360
+ const { request, requestOptions, store } = options
1361
+ const chainId_explicit = requestOptions?.chainId
1362
+ if (
1363
+ chainId_explicit !== undefined &&
1364
+ (!Number.isSafeInteger(chainId_explicit) || chainId_explicit <= 0)
1365
+ )
1366
+ throw new RpcResponse.InvalidParamsError({
1367
+ message: 'Expected a valid chain ID.',
1368
+ })
1369
+ const chainId_request = await resolveRequestChainId(request, store)
1370
+ if (
1371
+ chainId_explicit !== undefined &&
1372
+ chainId_request !== undefined &&
1373
+ chainId_explicit !== chainId_request
1374
+ )
1375
+ throw new RpcResponse.InvalidParamsError({
1376
+ message: 'Conflicting chain ids.',
1377
+ })
1378
+ const chainId = chainId_explicit ?? chainId_request
1379
+ if (chainId === undefined) return requestOptions
1380
+ return { ...requestOptions, chainId }
1381
+ }
1382
+
1383
+ /** Resolves a chain from request fields, envelopes, or stored operations. */
1384
+ async function resolveRequestChainId(
1385
+ request: handleRequest.Request,
1386
+ store: Store.Store,
1387
+ ) {
1388
+ const value = request.params?.[0]
1389
+ const chainId_body =
1390
+ value && typeof value === 'object' && 'chainId' in value
1391
+ ? parseChainId(value.chainId)
1392
+ : undefined
1393
+ const chainId_multisig = await (async () => {
1394
+ if (
1395
+ request.method === 'eth_sendRawTransaction' ||
1396
+ request.method === 'eth_sendRawTransactionSync' ||
1397
+ request.method === 'multisig_approveRawTransaction' ||
1398
+ request.method === 'multisig_approveRawTransactionSync'
1399
+ ) {
1400
+ if (!isSerializedTempoTransaction(value)) return undefined
1401
+ try {
1402
+ return parseChainId(Transaction.deserialize(value).chainId)
1403
+ } catch {
1404
+ return undefined
1405
+ }
1406
+ }
1407
+
1408
+ if (
1409
+ request.method === 'multisig_approveKeyAuthorization' &&
1410
+ value &&
1411
+ typeof value === 'object' &&
1412
+ 'keyAuthorization' in value
1413
+ ) {
1414
+ try {
1415
+ return parseChainId(
1416
+ KeyAuthorization.fromRpc(
1417
+ value.keyAuthorization as KeyAuthorization.Rpc,
1418
+ ).chainId,
1419
+ )
1420
+ } catch {
1421
+ return undefined
1422
+ }
1423
+ }
1424
+
1425
+ const hash = (() => {
1426
+ if (
1427
+ request.method === 'eth_getTransactionByHash' ||
1428
+ request.method === 'eth_getTransactionReceipt'
1429
+ )
1430
+ return value
1431
+ if (
1432
+ request.method === 'multisig_approveKeyAuthorization' &&
1433
+ value &&
1434
+ typeof value === 'object' &&
1435
+ 'hash' in value
1436
+ )
1437
+ return value.hash
1438
+ return undefined
1439
+ })()
1440
+ if (typeof hash !== 'string' || !Hash.validate(hash)) return undefined
1441
+ const operation = await OperationStore.read(store, hash)
1442
+ if (!operation) return undefined
1443
+ if (operation.type === 'transaction')
1444
+ return parseChainId(
1445
+ Transaction.deserialize(
1446
+ operation.transaction as Transaction.TransactionSerializedTempo,
1447
+ ).chainId,
1448
+ )
1449
+ return parseChainId(
1450
+ KeyAuthorization.deserialize(operation.keyAuthorization).chainId,
1451
+ )
1452
+ })()
1453
+
1454
+ if (
1455
+ chainId_body !== undefined &&
1456
+ chainId_multisig !== undefined &&
1457
+ chainId_body !== chainId_multisig
1458
+ )
1459
+ throw new RpcResponse.InvalidParamsError({
1460
+ message: 'Conflicting chain ids.',
1461
+ })
1462
+ return chainId_body ?? chainId_multisig
1463
+ }
1464
+
1465
+ /** Parses a supported chain ID representation. */
1466
+ function parseChainId(value: unknown) {
1467
+ const chainId = (() => {
1468
+ if (typeof value === 'number') return value
1469
+ if (typeof value === 'bigint') return Number(value)
1470
+ if (typeof value === 'string' && Hex.validate(value)) {
1471
+ try {
1472
+ return Hex.toNumber(value)
1473
+ } catch {
1474
+ return undefined
1475
+ }
1476
+ }
1477
+ return undefined
1478
+ })()
1479
+ if (chainId === undefined || !Number.isSafeInteger(chainId) || chainId <= 0)
1480
+ return undefined
1481
+ return chainId
1482
+ }
1483
+
1343
1484
  /** Checks whether a value is a serialized Tempo transaction. */
1344
1485
  function isSerializedTempoTransaction(value: unknown): value is Hex.Hex {
1345
1486
  return (
package/tempo/Zone.ts CHANGED
@@ -1,9 +1,30 @@
1
- import type { Chain } from '../types/chain.js'
2
- import { defineChain } from '../utils/chain/defineChain.js'
3
- import { chainConfig } from './chainConfig.js'
1
+ import type { Chain, ChainFormatters } from '../types/chain.js'
2
+ import type { Assign } from '../types/utils.js'
3
+ import {
4
+ type DefineChainReturnType,
5
+ defineChain,
6
+ } from '../utils/chain/defineChain.js'
7
+ import { type ChainConfig, chainConfig } from './chainConfig.js'
8
+
9
+ type Defaults = {
10
+ nativeCurrency: {
11
+ decimals: number
12
+ name: string
13
+ symbol: string
14
+ }
15
+ rpcUrls: { default: { http: string[] } }
16
+ supportsTransactionReplacementDetection: boolean
17
+ }
18
+
19
+ type ZoneChain = Chain<ChainFormatters, ChainConfig['extendSchema']> & {
20
+ formatters: ChainConfig['formatters']
21
+ }
4
22
 
5
23
  /** Defines a Tempo Zone chain. */
6
- export function from<const config extends from.Parameters>(config: config) {
24
+ export function from<const config extends from.Parameters>(
25
+ config: config,
26
+ ): from.ReturnValue<config>
27
+ export function from(config: from.Parameters) {
7
28
  const chain = {
8
29
  ...chainConfig,
9
30
  nativeCurrency: {
@@ -23,6 +44,11 @@ export declare namespace from {
23
44
  Partial<Omit<Chain, 'id' | 'name' | 'sourceId'>> & {
24
45
  sourceId: number
25
46
  }
47
+
48
+ type ReturnValue<config extends Parameters = Parameters> = Assign<
49
+ Assign<DefineChainReturnType<ZoneChain>, Defaults>,
50
+ config
51
+ >
26
52
  }
27
53
 
28
54
  export const a = /*#__PURE__*/ from({