viem 1.16.6 → 1.17.1

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 (196) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/_cjs/actions/ens/getEnsAddress.js +2 -1
  3. package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
  4. package/_cjs/actions/ens/getEnsAvatar.js +2 -1
  5. package/_cjs/actions/ens/getEnsAvatar.js.map +1 -1
  6. package/_cjs/actions/ens/getEnsName.js +2 -1
  7. package/_cjs/actions/ens/getEnsName.js.map +1 -1
  8. package/_cjs/actions/ens/getEnsResolver.js +2 -1
  9. package/_cjs/actions/ens/getEnsResolver.js.map +1 -1
  10. package/_cjs/actions/ens/getEnsText.js +2 -1
  11. package/_cjs/actions/ens/getEnsText.js.map +1 -1
  12. package/_cjs/actions/getContract.js +8 -7
  13. package/_cjs/actions/getContract.js.map +1 -1
  14. package/_cjs/actions/public/estimateContractGas.js +2 -1
  15. package/_cjs/actions/public/estimateContractGas.js.map +1 -1
  16. package/_cjs/actions/public/estimateFeesPerGas.js +3 -2
  17. package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
  18. package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js +4 -3
  19. package/_cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
  20. package/_cjs/actions/public/getContractEvents.js +2 -1
  21. package/_cjs/actions/public/getContractEvents.js.map +1 -1
  22. package/_cjs/actions/public/getTransactionConfirmations.js +3 -2
  23. package/_cjs/actions/public/getTransactionConfirmations.js.map +1 -1
  24. package/_cjs/actions/public/multicall.js +2 -1
  25. package/_cjs/actions/public/multicall.js.map +1 -1
  26. package/_cjs/actions/public/readContract.js +2 -1
  27. package/_cjs/actions/public/readContract.js.map +1 -1
  28. package/_cjs/actions/public/simulateContract.js +2 -1
  29. package/_cjs/actions/public/simulateContract.js.map +1 -1
  30. package/_cjs/actions/public/verifyHash.js +2 -1
  31. package/_cjs/actions/public/verifyHash.js.map +1 -1
  32. package/_cjs/actions/public/waitForTransactionReceipt.js +6 -5
  33. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  34. package/_cjs/actions/public/watchBlockNumber.js +2 -1
  35. package/_cjs/actions/public/watchBlockNumber.js.map +1 -1
  36. package/_cjs/actions/public/watchBlocks.js +4 -3
  37. package/_cjs/actions/public/watchBlocks.js.map +1 -1
  38. package/_cjs/actions/public/watchContractEvent.js +6 -5
  39. package/_cjs/actions/public/watchContractEvent.js.map +1 -1
  40. package/_cjs/actions/public/watchEvent.js +6 -5
  41. package/_cjs/actions/public/watchEvent.js.map +1 -1
  42. package/_cjs/actions/public/watchPendingTransactions.js +4 -3
  43. package/_cjs/actions/public/watchPendingTransactions.js.map +1 -1
  44. package/_cjs/actions/wallet/prepareTransactionRequest.js +4 -3
  45. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  46. package/_cjs/actions/wallet/sendTransaction.js +5 -4
  47. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  48. package/_cjs/actions/wallet/signTransaction.js +2 -1
  49. package/_cjs/actions/wallet/signTransaction.js.map +1 -1
  50. package/_cjs/actions/wallet/writeContract.js +2 -1
  51. package/_cjs/actions/wallet/writeContract.js.map +1 -1
  52. package/_cjs/chains/definitions/astarZkatana.js +36 -0
  53. package/_cjs/chains/definitions/astarZkatana.js.map +1 -0
  54. package/_cjs/chains/definitions/modeTestnet.js +6 -0
  55. package/_cjs/chains/definitions/modeTestnet.js.map +1 -1
  56. package/_cjs/chains/definitions/zoraSepolia.js +41 -0
  57. package/_cjs/chains/definitions/zoraSepolia.js.map +1 -0
  58. package/_cjs/chains/index.js +7 -3
  59. package/_cjs/chains/index.js.map +1 -1
  60. package/_cjs/clients/createClient.js.map +1 -1
  61. package/_cjs/errors/version.js +1 -1
  62. package/_cjs/utils/getAction.js +8 -0
  63. package/_cjs/utils/getAction.js.map +1 -0
  64. package/_esm/actions/ens/getEnsAddress.js +2 -1
  65. package/_esm/actions/ens/getEnsAddress.js.map +1 -1
  66. package/_esm/actions/ens/getEnsAvatar.js +2 -1
  67. package/_esm/actions/ens/getEnsAvatar.js.map +1 -1
  68. package/_esm/actions/ens/getEnsName.js +2 -1
  69. package/_esm/actions/ens/getEnsName.js.map +1 -1
  70. package/_esm/actions/ens/getEnsResolver.js +2 -1
  71. package/_esm/actions/ens/getEnsResolver.js.map +1 -1
  72. package/_esm/actions/ens/getEnsText.js +2 -1
  73. package/_esm/actions/ens/getEnsText.js.map +1 -1
  74. package/_esm/actions/getContract.js +8 -7
  75. package/_esm/actions/getContract.js.map +1 -1
  76. package/_esm/actions/public/estimateContractGas.js +2 -1
  77. package/_esm/actions/public/estimateContractGas.js.map +1 -1
  78. package/_esm/actions/public/estimateFeesPerGas.js +3 -2
  79. package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
  80. package/_esm/actions/public/estimateMaxPriorityFeePerGas.js +4 -3
  81. package/_esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -1
  82. package/_esm/actions/public/getContractEvents.js +2 -1
  83. package/_esm/actions/public/getContractEvents.js.map +1 -1
  84. package/_esm/actions/public/getTransactionConfirmations.js +3 -2
  85. package/_esm/actions/public/getTransactionConfirmations.js.map +1 -1
  86. package/_esm/actions/public/multicall.js +2 -1
  87. package/_esm/actions/public/multicall.js.map +1 -1
  88. package/_esm/actions/public/readContract.js +2 -1
  89. package/_esm/actions/public/readContract.js.map +1 -1
  90. package/_esm/actions/public/simulateContract.js +2 -1
  91. package/_esm/actions/public/simulateContract.js.map +1 -1
  92. package/_esm/actions/public/verifyHash.js +2 -1
  93. package/_esm/actions/public/verifyHash.js.map +1 -1
  94. package/_esm/actions/public/waitForTransactionReceipt.js +6 -5
  95. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  96. package/_esm/actions/public/watchBlockNumber.js +2 -1
  97. package/_esm/actions/public/watchBlockNumber.js.map +1 -1
  98. package/_esm/actions/public/watchBlocks.js +4 -3
  99. package/_esm/actions/public/watchBlocks.js.map +1 -1
  100. package/_esm/actions/public/watchContractEvent.js +6 -5
  101. package/_esm/actions/public/watchContractEvent.js.map +1 -1
  102. package/_esm/actions/public/watchEvent.js +6 -5
  103. package/_esm/actions/public/watchEvent.js.map +1 -1
  104. package/_esm/actions/public/watchPendingTransactions.js +4 -3
  105. package/_esm/actions/public/watchPendingTransactions.js.map +1 -1
  106. package/_esm/actions/wallet/prepareTransactionRequest.js +4 -3
  107. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  108. package/_esm/actions/wallet/sendTransaction.js +5 -4
  109. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  110. package/_esm/actions/wallet/signTransaction.js +2 -1
  111. package/_esm/actions/wallet/signTransaction.js.map +1 -1
  112. package/_esm/actions/wallet/writeContract.js +2 -1
  113. package/_esm/actions/wallet/writeContract.js.map +1 -1
  114. package/_esm/chains/definitions/astarZkatana.js +33 -0
  115. package/_esm/chains/definitions/astarZkatana.js.map +1 -0
  116. package/_esm/chains/definitions/modeTestnet.js +6 -0
  117. package/_esm/chains/definitions/modeTestnet.js.map +1 -1
  118. package/_esm/chains/definitions/zoraSepolia.js +38 -0
  119. package/_esm/chains/definitions/zoraSepolia.js.map +1 -0
  120. package/_esm/chains/index.js +2 -0
  121. package/_esm/chains/index.js.map +1 -1
  122. package/_esm/clients/createClient.js.map +1 -1
  123. package/_esm/errors/version.js +1 -1
  124. package/_esm/utils/getAction.js +4 -0
  125. package/_esm/utils/getAction.js.map +1 -0
  126. package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
  127. package/_types/actions/ens/getEnsAvatar.d.ts.map +1 -1
  128. package/_types/actions/ens/getEnsName.d.ts.map +1 -1
  129. package/_types/actions/ens/getEnsResolver.d.ts.map +1 -1
  130. package/_types/actions/ens/getEnsText.d.ts.map +1 -1
  131. package/_types/actions/getContract.d.ts.map +1 -1
  132. package/_types/actions/public/estimateContractGas.d.ts.map +1 -1
  133. package/_types/actions/public/estimateFeesPerGas.d.ts.map +1 -1
  134. package/_types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -1
  135. package/_types/actions/public/getContractEvents.d.ts.map +1 -1
  136. package/_types/actions/public/getTransactionConfirmations.d.ts.map +1 -1
  137. package/_types/actions/public/multicall.d.ts.map +1 -1
  138. package/_types/actions/public/readContract.d.ts.map +1 -1
  139. package/_types/actions/public/simulateContract.d.ts.map +1 -1
  140. package/_types/actions/public/verifyHash.d.ts.map +1 -1
  141. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  142. package/_types/actions/public/watchBlockNumber.d.ts.map +1 -1
  143. package/_types/actions/public/watchBlocks.d.ts.map +1 -1
  144. package/_types/actions/public/watchContractEvent.d.ts.map +1 -1
  145. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  146. package/_types/actions/public/watchPendingTransactions.d.ts.map +1 -1
  147. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  148. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  149. package/_types/actions/wallet/signTransaction.d.ts.map +1 -1
  150. package/_types/actions/wallet/writeContract.d.ts.map +1 -1
  151. package/_types/chains/definitions/astarZkatana.d.ts +30 -0
  152. package/_types/chains/definitions/astarZkatana.d.ts.map +1 -0
  153. package/_types/chains/definitions/modeTestnet.d.ts +6 -0
  154. package/_types/chains/definitions/modeTestnet.d.ts.map +1 -1
  155. package/_types/chains/definitions/zoraSepolia.d.ts +331 -0
  156. package/_types/chains/definitions/zoraSepolia.d.ts.map +1 -0
  157. package/_types/chains/index.d.ts +2 -0
  158. package/_types/chains/index.d.ts.map +1 -1
  159. package/_types/clients/createClient.d.ts +6 -2
  160. package/_types/clients/createClient.d.ts.map +1 -1
  161. package/_types/errors/version.d.ts +1 -1
  162. package/_types/utils/getAction.d.ts +3 -0
  163. package/_types/utils/getAction.d.ts.map +1 -0
  164. package/actions/ens/getEnsAddress.ts +5 -1
  165. package/actions/ens/getEnsAvatar.ts +5 -1
  166. package/actions/ens/getEnsName.ts +5 -1
  167. package/actions/ens/getEnsResolver.ts +5 -1
  168. package/actions/ens/getEnsText.ts +5 -1
  169. package/actions/getContract.ts +29 -7
  170. package/actions/public/estimateContractGas.ts +5 -1
  171. package/actions/public/estimateFeesPerGas.ts +4 -2
  172. package/actions/public/estimateMaxPriorityFeePerGas.ts +4 -3
  173. package/actions/public/getContractEvents.ts +5 -1
  174. package/actions/public/getTransactionConfirmations.ts +3 -2
  175. package/actions/public/multicall.ts +5 -1
  176. package/actions/public/readContract.ts +5 -1
  177. package/actions/public/simulateContract.ts +5 -1
  178. package/actions/public/verifyHash.ts +5 -1
  179. package/actions/public/waitForTransactionReceipt.ts +19 -6
  180. package/actions/public/watchBlockNumber.ts +5 -1
  181. package/actions/public/watchBlocks.ts +10 -3
  182. package/actions/public/watchContractEvent.ts +12 -5
  183. package/actions/public/watchEvent.ts +12 -5
  184. package/actions/public/watchPendingTransactions.ts +7 -3
  185. package/actions/wallet/prepareTransactionRequest.ts +10 -3
  186. package/actions/wallet/sendTransaction.ts +11 -4
  187. package/actions/wallet/signTransaction.ts +2 -1
  188. package/actions/wallet/writeContract.ts +5 -1
  189. package/chains/definitions/astarZkatana.ts +33 -0
  190. package/chains/definitions/modeTestnet.ts +6 -0
  191. package/chains/definitions/zoraSepolia.ts +41 -0
  192. package/chains/index.ts +2 -0
  193. package/clients/createClient.ts +39 -2
  194. package/errors/version.ts +1 -1
  195. package/package.json +1 -1
  196. package/utils/getAction.ts +13 -0
@@ -20,6 +20,7 @@ import {
20
20
  type GetContractErrorReturnType,
21
21
  getContractError,
22
22
  } from '../../utils/errors/getContractError.js'
23
+ import { getAction } from '../../utils/getAction.js'
23
24
  import {
24
25
  type EstimateGasErrorType,
25
26
  type EstimateGasParameters,
@@ -95,7 +96,10 @@ export async function estimateContractGas<
95
96
  functionName,
96
97
  } as unknown as EncodeFunctionDataParameters<TAbi, TFunctionName>)
97
98
  try {
98
- const gas = await estimateGas(client, {
99
+ const gas = await getAction(
100
+ client,
101
+ estimateGas,
102
+ )({
99
103
  data,
100
104
  to: address,
101
105
  ...request,
@@ -19,6 +19,7 @@ import type {
19
19
  FeeValuesLegacy,
20
20
  FeeValuesType,
21
21
  } from '../../types/fee.js'
22
+ import { getAction } from '../../utils/getAction.js'
22
23
  import type { PrepareTransactionRequestParameters } from '../wallet/prepareTransactionRequest.js'
23
24
  import {
24
25
  type EstimateMaxPriorityFeePerGasErrorType,
@@ -125,7 +126,7 @@ export async function internal_estimateFeesPerGas<
125
126
  (base * BigInt(Math.ceil(baseFeeMultiplier * denominator))) /
126
127
  BigInt(denominator)
127
128
 
128
- const block = block_ ? block_ : await getBlock(client)
129
+ const block = block_ ? block_ : await getAction(client, getBlock)({})
129
130
 
130
131
  if (typeof chain?.fees?.estimateFeesPerGas === 'function')
131
132
  return chain.fees.estimateFeesPerGas({
@@ -161,7 +162,8 @@ export async function internal_estimateFeesPerGas<
161
162
  } as EstimateFeesPerGasReturnType<type>
162
163
  }
163
164
 
164
- const gasPrice = request?.gasPrice ?? multiply(await getGasPrice(client))
165
+ const gasPrice =
166
+ request?.gasPrice ?? multiply(await getAction(client, getGasPrice)({}))
165
167
  return {
166
168
  gasPrice,
167
169
  } as EstimateFeesPerGasReturnType<type>
@@ -14,6 +14,7 @@ import {
14
14
  type HexToBigIntErrorType,
15
15
  hexToBigInt,
16
16
  } from '../../utils/encoding/fromHex.js'
17
+ import { getAction } from '../../utils/getAction.js'
17
18
  import type { PrepareTransactionRequestParameters } from '../wallet/prepareTransactionRequest.js'
18
19
  import { type GetBlockErrorType, getBlock } from './getBlock.js'
19
20
  import { type GetGasPriceErrorType, getGasPrice } from './getGasPrice.js'
@@ -82,7 +83,7 @@ export async function internal_estimateMaxPriorityFeePerGas<
82
83
  ): Promise<EstimateMaxPriorityFeePerGasReturnType> {
83
84
  const { block: block_, chain = client.chain, request } = args || {}
84
85
  if (typeof chain?.fees?.defaultPriorityFee === 'function') {
85
- const block = block_ || (await getBlock(client))
86
+ const block = block_ || (await getAction(client, getBlock)({}))
86
87
  return chain.fees.defaultPriorityFee({
87
88
  block,
88
89
  client,
@@ -101,8 +102,8 @@ export async function internal_estimateMaxPriorityFeePerGas<
101
102
  // fall back to calculating it manually via `gasPrice - baseFeePerGas`.
102
103
  // See: https://github.com/ethereum/pm/issues/328#:~:text=eth_maxPriorityFeePerGas%20after%20London%20will%20effectively%20return%20eth_gasPrice%20%2D%20baseFee
103
104
  const [block, gasPrice] = await Promise.all([
104
- block_ ? Promise.resolve(block_) : getBlock(client),
105
- getGasPrice(client),
105
+ block_ ? Promise.resolve(block_) : getAction(client, getBlock)({}),
106
+ getAction(client, getGasPrice)({}),
106
107
  ])
107
108
 
108
109
  if (typeof block.baseFeePerGas !== 'bigint')
@@ -13,6 +13,7 @@ import {
13
13
  type GetAbiItemParameters,
14
14
  getAbiItem,
15
15
  } from '../../utils/abi/getAbiItem.js'
16
+ import { getAction } from '../../utils/getAction.js'
16
17
  import {
17
18
  type GetLogsErrorType,
18
19
  type GetLogsParameters,
@@ -130,7 +131,10 @@ export async function getContractEvents<
130
131
  const events = !event
131
132
  ? (abi as Abi).filter((x) => x.type === 'event')
132
133
  : undefined
133
- return getLogs(client, {
134
+ return getAction(
135
+ client,
136
+ getLogs,
137
+ )({
134
138
  address,
135
139
  args,
136
140
  blockHash,
@@ -4,6 +4,7 @@ import type { ErrorType } from '../../errors/utils.js'
4
4
  import type { Chain } from '../../types/chain.js'
5
5
  import type { Hash } from '../../types/misc.js'
6
6
  import type { FormattedTransactionReceipt } from '../../utils/formatters/transactionReceipt.js'
7
+ import { getAction } from '../../utils/getAction.js'
7
8
 
8
9
  import {
9
10
  type GetBlockNumberErrorType,
@@ -66,8 +67,8 @@ export async function getTransactionConfirmations<
66
67
  { hash, transactionReceipt }: GetTransactionConfirmationsParameters<TChain>,
67
68
  ): Promise<GetTransactionConfirmationsReturnType> {
68
69
  const [blockNumber, transaction] = await Promise.all([
69
- getBlockNumber(client),
70
- hash ? getTransaction(client, { hash }) : undefined,
70
+ getAction(client, getBlockNumber)({}),
71
+ hash ? getAction(client, getTransaction)({ hash }) : undefined,
71
72
  ])
72
73
  const transactionBlockNumber =
73
74
  transactionReceipt?.blockNumber || transaction?.blockNumber
@@ -32,6 +32,7 @@ import {
32
32
  } from '../../utils/errors/getContractError.js'
33
33
 
34
34
  import type { ErrorType } from '../../errors/utils.js'
35
+ import { getAction } from '../../utils/getAction.js'
35
36
  import type { CallParameters } from './call.js'
36
37
  import { type ReadContractErrorType, readContract } from './readContract.js'
37
38
 
@@ -200,7 +201,10 @@ export async function multicall<
200
201
 
201
202
  const aggregate3Results = await Promise.allSettled(
202
203
  chunkedCalls.map((calls) =>
203
- readContract(client, {
204
+ getAction(
205
+ client,
206
+ readContract,
207
+ )({
204
208
  abi: multicall3Abi,
205
209
  address: multicallAddress!,
206
210
  args: [calls],
@@ -22,6 +22,7 @@ import {
22
22
  type GetContractErrorReturnType,
23
23
  getContractError,
24
24
  } from '../../utils/errors/getContractError.js'
25
+ import { getAction } from '../../utils/getAction.js'
25
26
 
26
27
  import { type CallErrorType, type CallParameters, call } from './call.js'
27
28
 
@@ -91,7 +92,10 @@ export async function readContract<
91
92
  functionName,
92
93
  } as unknown as EncodeFunctionDataParameters<TAbi, TFunctionName>)
93
94
  try {
94
- const { data } = await call(client, {
95
+ const { data } = await getAction(
96
+ client,
97
+ call,
98
+ )({
95
99
  data: calldata,
96
100
  to: address,
97
101
  ...callRequest,
@@ -32,6 +32,7 @@ import {
32
32
  import type { WriteContractParameters } from '../wallet/writeContract.js'
33
33
 
34
34
  import type { ErrorType } from '../../errors/utils.js'
35
+ import { getAction } from '../../utils/getAction.js'
35
36
  import { type CallErrorType, type CallParameters, call } from './call.js'
36
37
 
37
38
  export type SimulateContractParameters<
@@ -142,7 +143,10 @@ export async function simulateContract<
142
143
  functionName,
143
144
  } as unknown as EncodeFunctionDataParameters<TAbi, TFunctionName>)
144
145
  try {
145
- const { data } = await call(client, {
146
+ const { data } = await getAction(
147
+ client,
148
+ call,
149
+ )({
146
150
  batch: false,
147
151
  data: `${calldata}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
148
152
  to: address,
@@ -15,6 +15,7 @@ import {
15
15
  } from '../../utils/data/isBytesEqual.js'
16
16
  import type { IsHexErrorType } from '../../utils/data/isHex.js'
17
17
  import type { ToHexErrorType } from '../../utils/encoding/toHex.js'
18
+ import { getAction } from '../../utils/getAction.js'
18
19
  import { encodeDeployData, isHex, toHex } from '../../utils/index.js'
19
20
  import { type CallErrorType, type CallParameters, call } from './call.js'
20
21
 
@@ -54,7 +55,10 @@ export async function verifyHash<TChain extends Chain | undefined,>(
54
55
  const signatureHex = isHex(signature) ? signature : toHex(signature)
55
56
 
56
57
  try {
57
- const { data } = await call(client, {
58
+ const { data } = await getAction(
59
+ client,
60
+ call,
61
+ )({
58
62
  data: encodeDeployData({
59
63
  abi: universalSignatureValidatorAbi,
60
64
  args: [address, hash, signatureHex],
@@ -9,6 +9,7 @@ import type { ErrorType } from '../../errors/utils.js'
9
9
  import type { Chain } from '../../types/chain.js'
10
10
  import type { Hash } from '../../types/misc.js'
11
11
  import type { Transaction } from '../../types/transaction.js'
12
+ import { getAction } from '../../utils/getAction.js'
12
13
  import { type ObserveErrorType, observe } from '../../utils/observe.js'
13
14
  import { withRetry } from '../../utils/promise/withRetry.js'
14
15
  import { stringify } from '../../utils/stringify.js'
@@ -140,7 +141,10 @@ export async function waitForTransactionReceipt<
140
141
  observerId,
141
142
  { onReplaced, resolve, reject },
142
143
  (emit) => {
143
- const _unwatch = watchBlockNumber(client, {
144
+ const _unwatch = getAction(
145
+ client,
146
+ watchBlockNumber,
147
+ )({
144
148
  emitMissed: true,
145
149
  emitOnBegin: true,
146
150
  poll: true,
@@ -178,7 +182,10 @@ export async function waitForTransactionReceipt<
178
182
  retrying = true
179
183
  await withRetry(
180
184
  async () => {
181
- transaction = await getTransaction(client, { hash })
185
+ transaction = (await getAction(
186
+ client,
187
+ getTransaction,
188
+ )({ hash })) as GetTransactionReturnType<TChain>
182
189
  if (transaction.blockNumber)
183
190
  blockNumber = transaction.blockNumber
184
191
  },
@@ -192,7 +199,7 @@ export async function waitForTransactionReceipt<
192
199
  }
193
200
 
194
201
  // Get the receipt to check if it's been processed.
195
- receipt = await getTransactionReceipt(client, { hash })
202
+ receipt = await getAction(client, getTransactionReceipt)({ hash })
196
203
 
197
204
  // Check if we have enough confirmations. If not, continue polling.
198
205
  if (
@@ -215,13 +222,16 @@ export async function waitForTransactionReceipt<
215
222
  replacedTransaction = transaction
216
223
 
217
224
  // Let's retrieve the transactions from the current block.
218
- const block = await getBlock(client, {
225
+ const block = await getAction(
226
+ client,
227
+ getBlock,
228
+ )({
219
229
  blockNumber,
220
230
  includeTransactions: true,
221
231
  })
222
232
 
223
233
  const replacementTransaction = (
224
- block.transactions as Transaction[]
234
+ block.transactions as {} as Transaction[]
225
235
  ).find(
226
236
  ({ from, nonce }) =>
227
237
  from === replacedTransaction!.from &&
@@ -232,7 +242,10 @@ export async function waitForTransactionReceipt<
232
242
  if (!replacementTransaction) return
233
243
 
234
244
  // If we found a replacement transaction, return it's receipt.
235
- receipt = await getTransactionReceipt(client, {
245
+ receipt = await getAction(
246
+ client,
247
+ getTransactionReceipt,
248
+ )({
236
249
  hash: replacementTransaction.hash,
237
250
  })
238
251
 
@@ -4,6 +4,7 @@ import type { ErrorType } from '../../errors/utils.js'
4
4
  import type { Chain } from '../../types/chain.js'
5
5
  import type { GetTransportConfig } from '../../types/transport.js'
6
6
  import { hexToBigInt } from '../../utils/encoding/fromHex.js'
7
+ import { getAction } from '../../utils/getAction.js'
7
8
  import { observe } from '../../utils/observe.js'
8
9
  import { type PollErrorType, poll } from '../../utils/poll.js'
9
10
  import { stringify } from '../../utils/stringify.js'
@@ -108,7 +109,10 @@ export function watchBlockNumber<
108
109
  poll(
109
110
  async () => {
110
111
  try {
111
- const blockNumber = await getBlockNumber(client, { cacheTime: 0 })
112
+ const blockNumber = await getAction(
113
+ client,
114
+ getBlockNumber,
115
+ )({ cacheTime: 0 })
112
116
 
113
117
  if (prevBlockNumber) {
114
118
  // If the current block number is the same as the previous,
@@ -5,6 +5,7 @@ import type { BlockTag } from '../../types/block.js'
5
5
  import type { Chain } from '../../types/chain.js'
6
6
  import type { GetTransportConfig } from '../../types/transport.js'
7
7
  import { formatBlock } from '../../utils/formatters/block.js'
8
+ import { getAction } from '../../utils/getAction.js'
8
9
  import { observe } from '../../utils/observe.js'
9
10
  import { type PollErrorType, poll } from '../../utils/poll.js'
10
11
  import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
@@ -140,7 +141,10 @@ export function watchBlocks<
140
141
  poll(
141
142
  async () => {
142
143
  try {
143
- const block = await getBlock(client, {
144
+ const block = await getAction(
145
+ client,
146
+ getBlock,
147
+ )({
144
148
  blockTag,
145
149
  includeTransactions,
146
150
  })
@@ -153,10 +157,13 @@ export function watchBlocks<
153
157
  // `emitMissed` flag is truthy, let's emit those blocks.
154
158
  if (block.number - prevBlock.number > 1 && emitMissed) {
155
159
  for (let i = prevBlock?.number + 1n; i < block.number; i++) {
156
- const block = await getBlock(client, {
160
+ const block = (await getAction(
161
+ client,
162
+ getBlock,
163
+ )({
157
164
  blockNumber: i,
158
165
  includeTransactions,
159
- })
166
+ })) as GetBlockReturnType<TChain>
160
167
  emit.onBlock(block as any, prevBlock as any)
161
168
  prevBlock = block
162
169
  }
@@ -25,6 +25,7 @@ import {
25
25
  encodeEventTopics,
26
26
  } from '../../utils/abi/encodeEventTopics.js'
27
27
  import { formatLog } from '../../utils/formatters/log.js'
28
+ import { getAction } from '../../utils/getAction.js'
28
29
  import {
29
30
  type CreateContractEventFilterParameters,
30
31
  createContractEventFilter,
@@ -187,7 +188,10 @@ export function watchContractEvent<
187
188
  async () => {
188
189
  if (!initialized) {
189
190
  try {
190
- filter = (await createContractEventFilter(client, {
191
+ filter = (await getAction(
192
+ client,
193
+ createContractEventFilter,
194
+ )({
191
195
  abi,
192
196
  address,
193
197
  args,
@@ -206,19 +210,22 @@ export function watchContractEvent<
206
210
  try {
207
211
  let logs: Log[]
208
212
  if (filter) {
209
- logs = await getFilterChanges(client, { filter })
213
+ logs = await getAction(client, getFilterChanges)({ filter })
210
214
  } else {
211
215
  // If the filter doesn't exist, we will fall back to use `getLogs`.
212
216
  // The fall back exists because some RPC Providers do not support filters.
213
217
 
214
218
  // Fetch the block number to use for `getLogs`.
215
- const blockNumber = await getBlockNumber(client)
219
+ const blockNumber = await getAction(client, getBlockNumber)({})
216
220
 
217
221
  // If the block number has changed, we will need to fetch the logs.
218
222
  // If the block number doesn't exist, we are yet to reach the first poll interval,
219
223
  // so do not emit any logs.
220
224
  if (previousBlockNumber && previousBlockNumber !== blockNumber) {
221
- logs = await getContractEvents(client, {
225
+ logs = await getAction(
226
+ client,
227
+ getContractEvents,
228
+ )({
222
229
  abi,
223
230
  address,
224
231
  args,
@@ -250,7 +257,7 @@ export function watchContractEvent<
250
257
  )
251
258
 
252
259
  return async () => {
253
- if (filter) await uninstallFilter(client, { filter })
260
+ if (filter) await getAction(client, uninstallFilter)({ filter })
254
261
  unwatch()
255
262
  }
256
263
  })
@@ -22,6 +22,7 @@ import {
22
22
  } from '../../errors/abi.js'
23
23
  import { InvalidInputRpcError } from '../../errors/rpc.js'
24
24
  import type { ErrorType } from '../../errors/utils.js'
25
+ import { getAction } from '../../utils/getAction.js'
25
26
  import {
26
27
  decodeEventLog,
27
28
  encodeEventTopics,
@@ -222,7 +223,10 @@ export function watchEvent<
222
223
  async () => {
223
224
  if (!initialized) {
224
225
  try {
225
- filter = (await createEventFilter(client, {
226
+ filter = (await getAction(
227
+ client,
228
+ createEventFilter as any,
229
+ )({
226
230
  address,
227
231
  args,
228
232
  event: event!,
@@ -241,19 +245,22 @@ export function watchEvent<
241
245
  try {
242
246
  let logs: Log[]
243
247
  if (filter) {
244
- logs = await getFilterChanges(client, { filter })
248
+ logs = await getAction(client, getFilterChanges)({ filter })
245
249
  } else {
246
250
  // If the filter doesn't exist, we will fall back to use `getLogs`.
247
251
  // The fall back exists because some RPC Providers do not support filters.
248
252
 
249
253
  // Fetch the block number to use for `getLogs`.
250
- const blockNumber = await getBlockNumber(client)
254
+ const blockNumber = await getAction(client, getBlockNumber)({})
251
255
 
252
256
  // If the block number has changed, we will need to fetch the logs.
253
257
  // If the block number doesn't exist, we are yet to reach the first poll interval,
254
258
  // so do not emit any logs.
255
259
  if (previousBlockNumber && previousBlockNumber !== blockNumber) {
256
- logs = await getLogs(client, {
260
+ logs = await getAction(
261
+ client,
262
+ getLogs,
263
+ )({
257
264
  address,
258
265
  args,
259
266
  event: event!,
@@ -285,7 +292,7 @@ export function watchEvent<
285
292
  )
286
293
 
287
294
  return async () => {
288
- if (filter) await uninstallFilter(client, { filter })
295
+ if (filter) await getAction(client, uninstallFilter)({ filter })
289
296
  unwatch()
290
297
  }
291
298
  })
@@ -5,6 +5,7 @@ import type { Chain } from '../../types/chain.js'
5
5
  import type { Filter } from '../../types/filter.js'
6
6
  import type { Hash } from '../../types/misc.js'
7
7
  import type { GetTransportConfig } from '../../types/transport.js'
8
+ import { getAction } from '../../utils/getAction.js'
8
9
  import { type ObserveErrorType, observe } from '../../utils/observe.js'
9
10
  import { poll } from '../../utils/poll.js'
10
11
  import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
@@ -125,7 +126,10 @@ export function watchPendingTransactions<
125
126
  try {
126
127
  if (!filter) {
127
128
  try {
128
- filter = await createPendingTransactionFilter(client)
129
+ filter = await getAction(
130
+ client,
131
+ createPendingTransactionFilter,
132
+ )({})
129
133
  return
130
134
  } catch (err) {
131
135
  unwatch()
@@ -133,7 +137,7 @@ export function watchPendingTransactions<
133
137
  }
134
138
  }
135
139
 
136
- const hashes = await getFilterChanges(client, { filter })
140
+ const hashes = await getAction(client, getFilterChanges)({ filter })
137
141
  if (hashes.length === 0) return
138
142
  if (batch) emit.onTransactions(hashes)
139
143
  else hashes.forEach((hash) => emit.onTransactions([hash]))
@@ -148,7 +152,7 @@ export function watchPendingTransactions<
148
152
  )
149
153
 
150
154
  return async () => {
151
- if (filter) await uninstallFilter(client, { filter })
155
+ if (filter) await getAction(client, uninstallFilter)({ filter })
152
156
  unwatch()
153
157
  }
154
158
  })
@@ -36,6 +36,7 @@ import type { GetChain } from '../../types/chain.js'
36
36
  import type { TransactionSerializable } from '../../types/transaction.js'
37
37
  import type { UnionOmit } from '../../types/utils.js'
38
38
  import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
39
+ import { getAction } from '../../utils/getAction.js'
39
40
  import type {
40
41
  AssertRequestErrorType,
41
42
  AssertRequestParameters,
@@ -129,12 +130,15 @@ export async function prepareTransactionRequest<
129
130
  if (!account_) throw new AccountNotFoundError()
130
131
  const account = parseAccount(account_)
131
132
 
132
- const block = await getBlock(client, { blockTag: 'latest' })
133
+ const block = await getAction(client, getBlock)({ blockTag: 'latest' })
133
134
 
134
135
  const request = { ...args, from: account.address }
135
136
 
136
137
  if (typeof nonce === 'undefined')
137
- request.nonce = await getTransactionCount(client, {
138
+ request.nonce = await getAction(
139
+ client,
140
+ getTransactionCount,
141
+ )({
138
142
  address: account.address,
139
143
  blockTag: 'pending',
140
144
  })
@@ -189,7 +193,10 @@ export async function prepareTransactionRequest<
189
193
  }
190
194
 
191
195
  if (typeof gas === 'undefined')
192
- request.gas = await estimateGas(client, {
196
+ request.gas = await getAction(
197
+ client,
198
+ estimateGas,
199
+ )({
193
200
  ...request,
194
201
  account: { address: account.address, type: 'json-rpc' },
195
202
  } as EstimateGasParameters)
@@ -32,6 +32,7 @@ import {
32
32
  type FormattedTransactionRequest,
33
33
  formatTransactionRequest,
34
34
  } from '../../utils/formatters/transactionRequest.js'
35
+ import { getAction } from '../../utils/getAction.js'
35
36
  import {
36
37
  type AssertRequestErrorType,
37
38
  type AssertRequestParameters,
@@ -154,7 +155,7 @@ export async function sendTransaction<
154
155
 
155
156
  let chainId
156
157
  if (chain !== null) {
157
- chainId = await getChainId(client)
158
+ chainId = await getAction(client, getChainId)({})
158
159
  assertCurrentChain({
159
160
  currentChainId: chainId,
160
161
  chain,
@@ -163,7 +164,10 @@ export async function sendTransaction<
163
164
 
164
165
  if (account.type === 'local') {
165
166
  // Prepare the request for signing (assign appropriate fees, etc.)
166
- const request = await prepareTransactionRequest(client, {
167
+ const request = await getAction(
168
+ client,
169
+ prepareTransactionRequest,
170
+ )({
167
171
  account,
168
172
  accessList,
169
173
  chain,
@@ -178,7 +182,7 @@ export async function sendTransaction<
178
182
  ...rest,
179
183
  } as any)
180
184
 
181
- if (!chainId) chainId = await getChainId(client)
185
+ if (!chainId) chainId = await getAction(client, getChainId)({})
182
186
 
183
187
  const serializer = chain?.serializers?.transaction
184
188
  const serializedTransaction = (await account.signTransaction(
@@ -188,7 +192,10 @@ export async function sendTransaction<
188
192
  } as TransactionSerializable,
189
193
  { serializer },
190
194
  )) as Hash
191
- return await sendRawTransaction(client, {
195
+ return await getAction(
196
+ client,
197
+ sendRawTransaction,
198
+ )({
192
199
  serializedTransaction,
193
200
  })
194
201
  }
@@ -27,6 +27,7 @@ import {
27
27
  type FormattedTransactionRequest,
28
28
  formatTransactionRequest,
29
29
  } from '../../utils/formatters/transactionRequest.js'
30
+ import { getAction } from '../../utils/getAction.js'
30
31
  import { numberToHex } from '../../utils/index.js'
31
32
  import {
32
33
  type AssertRequestErrorType,
@@ -127,7 +128,7 @@ export async function signTransaction<
127
128
  ...args,
128
129
  })
129
130
 
130
- const chainId = await getChainId(client)
131
+ const chainId = await getAction(client, getChainId)({})
131
132
  if (chain !== null)
132
133
  assertCurrentChain({
133
134
  currentChainId: chainId,
@@ -16,6 +16,7 @@ import {
16
16
  encodeFunctionData,
17
17
  } from '../../utils/abi/encodeFunctionData.js'
18
18
  import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
19
+ import { getAction } from '../../utils/getAction.js'
19
20
  import {
20
21
  type SendTransactionErrorType,
21
22
  type SendTransactionParameters,
@@ -138,7 +139,10 @@ export async function writeContract<
138
139
  args,
139
140
  functionName,
140
141
  } as unknown as EncodeFunctionDataParameters<TAbi, TFunctionName>)
141
- const hash = await sendTransaction(client, {
142
+ const hash = await getAction(
143
+ client,
144
+ sendTransaction,
145
+ )({
142
146
  data: `${data}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
143
147
  to: address,
144
148
  ...request,
@@ -0,0 +1,33 @@
1
+ import { defineChain } from '../../utils/chain.js'
2
+
3
+ export const astarZkatana = /*#__PURE__*/ defineChain({
4
+ id: 1_261_120,
5
+ name: 'Astar zkEVM Testnet zKatana',
6
+ network: 'zKatana',
7
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: [
11
+ 'https://rpc.zkatana.gelato.digital',
12
+ 'https://rpc.startale.com/zkatana',
13
+ ],
14
+ },
15
+ public: {
16
+ http: [
17
+ 'https://rpc.zkatana.gelato.digital',
18
+ 'https://rpc.startale.com/zkatana',
19
+ ],
20
+ },
21
+ },
22
+ blockExplorers: {
23
+ blockscout: {
24
+ name: 'Blockscout zKatana chain explorer',
25
+ url: 'https://zkatana.blockscout.com',
26
+ },
27
+ default: {
28
+ name: 'zKatana Explorer',
29
+ url: 'https://zkatana.explorer.startale.com',
30
+ },
31
+ },
32
+ testnet: true,
33
+ })
@@ -19,5 +19,11 @@ export const modeTestnet = /*#__PURE__*/ defineChain({
19
19
  url: 'https://sepolia.explorer.mode.network',
20
20
  },
21
21
  },
22
+ contracts: {
23
+ multicall3: {
24
+ address: '0xBAba8373113Fb7a68f195deF18732e01aF8eDfCF',
25
+ blockCreated: 3019007,
26
+ },
27
+ },
22
28
  testnet: true,
23
29
  })