viem 2.30.5 → 2.30.6

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/actions/public/call.js +2 -2
  3. package/_cjs/actions/public/call.js.map +1 -1
  4. package/_cjs/actions/public/estimateGas.js +1 -1
  5. package/_cjs/actions/public/estimateGas.js.map +1 -1
  6. package/_cjs/actions/public/simulateBlocks.js +1 -1
  7. package/_cjs/actions/public/simulateBlocks.js.map +1 -1
  8. package/_cjs/chains/definitions/omni.js +23 -0
  9. package/_cjs/chains/definitions/omni.js.map +1 -0
  10. package/_cjs/chains/definitions/omniOmega.js +23 -0
  11. package/_cjs/chains/definitions/omniOmega.js.map +1 -0
  12. package/_cjs/chains/index.js +9 -5
  13. package/_cjs/chains/index.js.map +1 -1
  14. package/_cjs/clients/transports/webSocket.js.map +1 -1
  15. package/_cjs/errors/version.js +1 -1
  16. package/_cjs/utils/abi/decodeEventLog.js +13 -9
  17. package/_cjs/utils/abi/decodeEventLog.js.map +1 -1
  18. package/_esm/actions/public/call.js +2 -2
  19. package/_esm/actions/public/call.js.map +1 -1
  20. package/_esm/actions/public/estimateGas.js +1 -1
  21. package/_esm/actions/public/estimateGas.js.map +1 -1
  22. package/_esm/actions/public/simulateBlocks.js +1 -1
  23. package/_esm/actions/public/simulateBlocks.js.map +1 -1
  24. package/_esm/chains/definitions/omni.js +20 -0
  25. package/_esm/chains/definitions/omni.js.map +1 -0
  26. package/_esm/chains/definitions/omniOmega.js +20 -0
  27. package/_esm/chains/definitions/omniOmega.js.map +1 -0
  28. package/_esm/chains/index.js +2 -0
  29. package/_esm/chains/index.js.map +1 -1
  30. package/_esm/clients/transports/webSocket.js.map +1 -1
  31. package/_esm/errors/version.js +1 -1
  32. package/_esm/utils/abi/decodeEventLog.js +13 -9
  33. package/_esm/utils/abi/decodeEventLog.js.map +1 -1
  34. package/_types/actions/public/call.d.ts +1 -1
  35. package/_types/actions/public/estimateGas.d.ts +1 -1
  36. package/_types/chains/definitions/omni.d.ts +38 -0
  37. package/_types/chains/definitions/omni.d.ts.map +1 -0
  38. package/_types/chains/definitions/omniOmega.d.ts +38 -0
  39. package/_types/chains/definitions/omniOmega.d.ts.map +1 -0
  40. package/_types/chains/index.d.ts +2 -0
  41. package/_types/chains/index.d.ts.map +1 -1
  42. package/_types/clients/transports/webSocket.d.ts +16 -7
  43. package/_types/clients/transports/webSocket.d.ts.map +1 -1
  44. package/_types/errors/version.d.ts +1 -1
  45. package/_types/utils/abi/decodeEventLog.d.ts.map +1 -1
  46. package/actions/public/call.ts +3 -3
  47. package/actions/public/estimateGas.ts +2 -2
  48. package/actions/public/simulateBlocks.ts +1 -1
  49. package/chains/definitions/omni.ts +20 -0
  50. package/chains/definitions/omniOmega.ts +20 -0
  51. package/chains/index.ts +2 -0
  52. package/clients/transports/webSocket.ts +23 -8
  53. package/errors/version.ts +1 -1
  54. package/package.json +1 -1
  55. package/utils/abi/decodeEventLog.ts +14 -9
@@ -57,7 +57,7 @@ export type EstimateGasParameters<
57
57
  blockNumber?: undefined
58
58
  /**
59
59
  * The balance of the account at a block tag.
60
- * @default 'pending'
60
+ * @default 'latest'
61
61
  */
62
62
  blockTag?: BlockTag | undefined
63
63
  }
@@ -194,7 +194,7 @@ export async function estimateGas<
194
194
  return client.request({
195
195
  method: 'eth_estimateGas',
196
196
  params: rpcStateOverride
197
- ? [request, block ?? 'pending', rpcStateOverride]
197
+ ? [request, block ?? 'latest', rpcStateOverride]
198
198
  : block
199
199
  ? [request, block]
200
200
  : [request],
@@ -183,7 +183,7 @@ export async function simulateBlocks<
183
183
  ): Promise<SimulateBlocksReturnType<calls>> {
184
184
  const {
185
185
  blockNumber,
186
- blockTag = 'pending',
186
+ blockTag = 'latest',
187
187
  blocks,
188
188
  returnFullTransactions,
189
189
  traceTransfers,
@@ -0,0 +1,20 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const omni = defineChain({
4
+ id: 166,
5
+ name: 'Omni',
6
+ nativeCurrency: { name: 'Omni', symbol: 'OMNI', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://mainnet.omni.network'],
10
+ webSocket: ['wss://mainnet.omni.network'],
11
+ },
12
+ },
13
+ blockExplorers: {
14
+ default: {
15
+ name: 'OmniScan',
16
+ url: 'https://omniscan.network',
17
+ },
18
+ },
19
+ testnet: false,
20
+ })
@@ -0,0 +1,20 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const omniOmega = /*#__PURE__*/ defineChain({
4
+ id: 164,
5
+ name: 'Omni Omega',
6
+ nativeCurrency: { name: 'Omni', symbol: 'OMNI', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://omega.omni.network'],
10
+ webSocket: ['wss://omega.omni.network'],
11
+ },
12
+ },
13
+ blockExplorers: {
14
+ default: {
15
+ name: 'Omega OmniScan',
16
+ url: 'https://omega.omniscan.network/',
17
+ },
18
+ },
19
+ testnet: true,
20
+ })
package/chains/index.ts CHANGED
@@ -373,6 +373,8 @@ export { oasys } from './definitions/oasys.js'
373
373
  export { odysseyTestnet } from './definitions/odysseyTestnet.js'
374
374
  export { okc } from './definitions/okc.js'
375
375
  export { omax } from './definitions/omax.js'
376
+ export { omni } from './definitions/omni.js'
377
+ export { omniOmega } from './definitions/omniOmega.js'
376
378
  export { oneWorld } from './definitions/oneWorld.js'
377
379
  export { oortMainnetDev } from './definitions/oortmainnetDev.js'
378
380
  export { opBNB } from './definitions/opBNB.js'
@@ -1,10 +1,11 @@
1
+ import type { Address } from 'abitype'
1
2
  import { RpcRequestError } from '../../errors/request.js'
2
3
  import {
3
4
  UrlRequiredError,
4
5
  type UrlRequiredErrorType,
5
6
  } from '../../errors/transport.js'
6
7
  import type { ErrorType } from '../../errors/utils.js'
7
- import type { Hash } from '../../types/misc.js'
8
+ import type { Hash, LogTopic } from '../../types/misc.js'
8
9
  import type { RpcResponse } from '../../types/rpc.js'
9
10
  import { getSocket } from '../../utils/rpc/compat.js'
10
11
  import type { SocketRpcClient } from '../../utils/rpc/socket.js'
@@ -31,13 +32,27 @@ type WebSocketTransportSubscribeReturnType = {
31
32
 
32
33
  type WebSocketTransportSubscribe = {
33
34
  subscribe(
34
- args: WebSocketTransportSubscribeParameters & {
35
- /**
36
- * @description Add information about compiled contracts
37
- * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_addcompilationresult
38
- */
39
- params: ['newHeads']
40
- },
35
+ args: WebSocketTransportSubscribeParameters &
36
+ (
37
+ | {
38
+ params: ['newHeads']
39
+ }
40
+ | {
41
+ params: ['newPendingTransactions']
42
+ }
43
+ | {
44
+ params: [
45
+ 'logs',
46
+ {
47
+ address?: Address | Address[]
48
+ topics?: LogTopic[]
49
+ },
50
+ ]
51
+ }
52
+ | {
53
+ params: ['syncing']
54
+ }
55
+ ),
41
56
  ): Promise<WebSocketTransportSubscribeReturnType>
42
57
  }
43
58
 
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.30.5'
1
+ export const version = '2.30.6'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.30.5",
4
+ "version": "2.30.6",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -131,19 +131,24 @@ export function decodeEventLog<
131
131
  const { name, inputs } = abiItem
132
132
  const isUnnamed = inputs?.some((x) => !('name' in x && x.name))
133
133
 
134
- let args: any = isUnnamed ? [] : {}
134
+ const args: any = isUnnamed ? [] : {}
135
135
 
136
136
  // Decode topics (indexed args).
137
- const indexedInputs = inputs.filter((x) => 'indexed' in x && x.indexed)
137
+ const indexedInputs = inputs
138
+ .map((x, i) => [x, i] as const)
139
+ .filter(([x]) => 'indexed' in x && x.indexed)
138
140
  for (let i = 0; i < indexedInputs.length; i++) {
139
- const param = indexedInputs[i]
141
+ const [param, argIndex] = indexedInputs[i]
140
142
  const topic = argTopics[i]
141
143
  if (!topic)
142
144
  throw new DecodeLogTopicsMismatch({
143
145
  abiItem,
144
146
  param: param as AbiParameter & { indexed: boolean },
145
147
  })
146
- args[isUnnamed ? i : param.name || i] = decodeTopic({ param, value: topic })
148
+ args[isUnnamed ? argIndex : param.name || argIndex] = decodeTopic({
149
+ param,
150
+ value: topic,
151
+ })
147
152
  }
148
153
 
149
154
  // Decode data (non-indexed args).
@@ -153,12 +158,12 @@ export function decodeEventLog<
153
158
  try {
154
159
  const decodedData = decodeAbiParameters(nonIndexedInputs, data)
155
160
  if (decodedData) {
156
- if (isUnnamed) args = [...args, ...decodedData]
157
- else {
158
- for (let i = 0; i < nonIndexedInputs.length; i++) {
161
+ if (isUnnamed)
162
+ for (let i = 0; i < inputs.length; i++)
163
+ args[i] = args[i] ?? decodedData.shift()
164
+ else
165
+ for (let i = 0; i < nonIndexedInputs.length; i++)
159
166
  args[nonIndexedInputs[i].name!] = decodedData[i]
160
- }
161
- }
162
167
  }
163
168
  } catch (err) {
164
169
  if (strict) {