viem 0.0.0-w-20230822145918 → 0.0.0-w-20230828183856

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 (241) hide show
  1. package/README.md +6 -0
  2. package/dist/cjs/actions/ens/getEnsAddress.js +2 -2
  3. package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
  4. package/dist/cjs/actions/index.js +8 -2
  5. package/dist/cjs/actions/index.js.map +1 -1
  6. package/dist/cjs/actions/public/estimateFeesPerGas.js +60 -0
  7. package/dist/cjs/actions/public/estimateFeesPerGas.js.map +1 -0
  8. package/dist/cjs/actions/public/estimateGas.js +2 -2
  9. package/dist/cjs/actions/public/estimateGas.js.map +1 -1
  10. package/dist/cjs/actions/public/estimateMaxPriorityFeePerGas.js +44 -0
  11. package/dist/cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
  12. package/dist/cjs/actions/public/verifyHash.js.map +1 -1
  13. package/dist/cjs/actions/public/verifyMessage.js.map +1 -1
  14. package/dist/cjs/actions/public/verifyTypedData.js.map +1 -1
  15. package/dist/cjs/actions/public/waitForTransactionReceipt.js +35 -30
  16. package/dist/cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  17. package/dist/cjs/actions/public/watchContractEvent.js +10 -7
  18. package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
  19. package/dist/cjs/actions/wallet/deployContract.js.map +1 -1
  20. package/dist/cjs/actions/wallet/prepareTransactionRequest.js +70 -0
  21. package/dist/cjs/actions/wallet/prepareTransactionRequest.js.map +1 -0
  22. package/dist/cjs/actions/wallet/sendRawTransaction.js +11 -0
  23. package/dist/cjs/actions/wallet/sendRawTransaction.js.map +1 -0
  24. package/dist/cjs/actions/wallet/sendTransaction.js +6 -6
  25. package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
  26. package/dist/cjs/actions/wallet/signTransaction.js +47 -0
  27. package/dist/cjs/actions/wallet/signTransaction.js.map +1 -0
  28. package/dist/cjs/chains/celo/formatters.js +4 -1
  29. package/dist/cjs/chains/celo/formatters.js.map +1 -1
  30. package/dist/cjs/chains/celo/parsers.js +76 -0
  31. package/dist/cjs/chains/celo/parsers.js.map +1 -0
  32. package/dist/cjs/chains/celo/serializers.js +2 -1
  33. package/dist/cjs/chains/celo/serializers.js.map +1 -1
  34. package/dist/cjs/chains/index.js +3 -2
  35. package/dist/cjs/chains/index.js.map +1 -1
  36. package/dist/cjs/chains/utils.js +3 -1
  37. package/dist/cjs/chains/utils.js.map +1 -1
  38. package/dist/cjs/clients/createTestClient.js.map +1 -1
  39. package/dist/cjs/clients/decorators/public.js +8 -0
  40. package/dist/cjs/clients/decorators/public.js.map +1 -1
  41. package/dist/cjs/clients/decorators/wallet.js +6 -0
  42. package/dist/cjs/clients/decorators/wallet.js.map +1 -1
  43. package/dist/cjs/errors/fee.js +42 -0
  44. package/dist/cjs/errors/fee.js.map +1 -0
  45. package/dist/cjs/index.js +9 -6
  46. package/dist/cjs/index.js.map +1 -1
  47. package/dist/cjs/public.js +5 -1
  48. package/dist/cjs/public.js.map +1 -1
  49. package/dist/cjs/utils/data/isBytesEqual.js +4 -3
  50. package/dist/cjs/utils/data/isBytesEqual.js.map +1 -1
  51. package/dist/cjs/utils/ens/encodedLabelToLabelhash.js +2 -2
  52. package/dist/cjs/utils/ens/encodedLabelToLabelhash.js.map +1 -1
  53. package/dist/cjs/utils/formatters/transactionRequest.js +9 -1
  54. package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
  55. package/dist/cjs/utils/index.js +3 -3
  56. package/dist/cjs/utils/index.js.map +1 -1
  57. package/dist/cjs/utils/rpc.js +5 -7
  58. package/dist/cjs/utils/rpc.js.map +1 -1
  59. package/dist/cjs/utils/transaction/parseTransaction.js +8 -3
  60. package/dist/cjs/utils/transaction/parseTransaction.js.map +1 -1
  61. package/dist/cjs/version.js +1 -1
  62. package/dist/esm/actions/ens/getEnsAddress.js +2 -2
  63. package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
  64. package/dist/esm/actions/index.js +3 -0
  65. package/dist/esm/actions/index.js.map +1 -1
  66. package/dist/esm/actions/public/estimateFeesPerGas.js +78 -0
  67. package/dist/esm/actions/public/estimateFeesPerGas.js.map +1 -0
  68. package/dist/esm/actions/public/estimateGas.js +2 -2
  69. package/dist/esm/actions/public/estimateGas.js.map +1 -1
  70. package/dist/esm/actions/public/estimateMaxPriorityFeePerGas.js +64 -0
  71. package/dist/esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
  72. package/dist/esm/actions/public/verifyHash.js.map +1 -1
  73. package/dist/esm/actions/public/verifyMessage.js.map +1 -1
  74. package/dist/esm/actions/public/verifyTypedData.js.map +1 -1
  75. package/dist/esm/actions/public/waitForTransactionReceipt.js +39 -34
  76. package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  77. package/dist/esm/actions/public/watchContractEvent.js +5 -2
  78. package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
  79. package/dist/esm/actions/wallet/deployContract.js.map +1 -1
  80. package/dist/esm/actions/wallet/prepareTransactionRequest.js +109 -0
  81. package/dist/esm/actions/wallet/prepareTransactionRequest.js.map +1 -0
  82. package/dist/esm/actions/wallet/sendRawTransaction.js +31 -0
  83. package/dist/esm/actions/wallet/sendRawTransaction.js.map +1 -0
  84. package/dist/esm/actions/wallet/sendTransaction.js +6 -6
  85. package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
  86. package/dist/esm/actions/wallet/signTransaction.js +87 -0
  87. package/dist/esm/actions/wallet/signTransaction.js.map +1 -0
  88. package/dist/esm/chains/celo/formatters.js +4 -1
  89. package/dist/esm/chains/celo/formatters.js.map +1 -1
  90. package/dist/esm/chains/celo/parsers.js +72 -0
  91. package/dist/esm/chains/celo/parsers.js.map +1 -0
  92. package/dist/esm/chains/celo/serializers.js +1 -3
  93. package/dist/esm/chains/celo/serializers.js.map +1 -1
  94. package/dist/esm/chains/index.js +1 -0
  95. package/dist/esm/chains/index.js.map +1 -1
  96. package/dist/esm/chains/utils.js +1 -0
  97. package/dist/esm/chains/utils.js.map +1 -1
  98. package/dist/esm/clients/createTestClient.js.map +1 -1
  99. package/dist/esm/clients/decorators/public.js +8 -0
  100. package/dist/esm/clients/decorators/public.js.map +1 -1
  101. package/dist/esm/clients/decorators/wallet.js +6 -0
  102. package/dist/esm/clients/decorators/wallet.js.map +1 -1
  103. package/dist/esm/errors/fee.js +36 -0
  104. package/dist/esm/errors/fee.js.map +1 -0
  105. package/dist/esm/index.js +2 -2
  106. package/dist/esm/index.js.map +1 -1
  107. package/dist/esm/public.js +2 -0
  108. package/dist/esm/public.js.map +1 -1
  109. package/dist/esm/utils/data/isBytesEqual.js +2 -1
  110. package/dist/esm/utils/data/isBytesEqual.js.map +1 -1
  111. package/dist/esm/utils/ens/encodedLabelToLabelhash.js +1 -1
  112. package/dist/esm/utils/ens/encodedLabelToLabelhash.js.map +1 -1
  113. package/dist/esm/utils/formatters/transactionRequest.js +8 -0
  114. package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
  115. package/dist/esm/utils/index.js +3 -1
  116. package/dist/esm/utils/index.js.map +1 -1
  117. package/dist/esm/utils/rpc.js +5 -7
  118. package/dist/esm/utils/rpc.js.map +1 -1
  119. package/dist/esm/utils/transaction/parseTransaction.js +6 -3
  120. package/dist/esm/utils/transaction/parseTransaction.js.map +1 -1
  121. package/dist/esm/version.js +1 -1
  122. package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
  123. package/dist/types/actions/index.d.ts +3 -0
  124. package/dist/types/actions/index.d.ts.map +1 -1
  125. package/dist/types/actions/public/estimateFeesPerGas.d.ts +48 -0
  126. package/dist/types/actions/public/estimateFeesPerGas.d.ts.map +1 -0
  127. package/dist/types/actions/public/estimateMaxPriorityFeePerGas.d.ts +37 -0
  128. package/dist/types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -0
  129. package/dist/types/actions/public/verifyHash.d.ts +1 -1
  130. package/dist/types/actions/public/verifyHash.d.ts.map +1 -1
  131. package/dist/types/actions/public/verifyMessage.d.ts +2 -2
  132. package/dist/types/actions/public/verifyMessage.d.ts.map +1 -1
  133. package/dist/types/actions/public/verifyTypedData.d.ts +2 -2
  134. package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
  135. package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  136. package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
  137. package/dist/types/actions/wallet/deployContract.d.ts +2 -1
  138. package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
  139. package/dist/types/actions/wallet/prepareTransactionRequest.d.ts +52 -0
  140. package/dist/types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -0
  141. package/dist/types/actions/wallet/sendRawTransaction.d.ts +38 -0
  142. package/dist/types/actions/wallet/sendRawTransaction.d.ts.map +1 -0
  143. package/dist/types/actions/wallet/sendTransaction.d.ts +2 -1
  144. package/dist/types/actions/wallet/sendTransaction.d.ts.map +1 -1
  145. package/dist/types/actions/wallet/signTransaction.d.ts +55 -0
  146. package/dist/types/actions/wallet/signTransaction.d.ts.map +1 -0
  147. package/dist/types/chains/celo/formatters.d.ts +503 -5
  148. package/dist/types/chains/celo/formatters.d.ts.map +1 -1
  149. package/dist/types/chains/celo/parsers.d.ts +6 -0
  150. package/dist/types/chains/celo/parsers.d.ts.map +1 -0
  151. package/dist/types/chains/celo/serializers.d.ts +3 -14
  152. package/dist/types/chains/celo/serializers.d.ts.map +1 -1
  153. package/dist/types/chains/celo/types.d.ts +54 -14
  154. package/dist/types/chains/celo/types.d.ts.map +1 -1
  155. package/dist/types/chains/index.d.ts +5485 -955
  156. package/dist/types/chains/index.d.ts.map +1 -1
  157. package/dist/types/chains/utils.d.ts +3 -2
  158. package/dist/types/chains/utils.d.ts.map +1 -1
  159. package/dist/types/clients/createTestClient.d.ts +1 -1
  160. package/dist/types/clients/createTestClient.d.ts.map +1 -1
  161. package/dist/types/clients/decorators/public.d.ts +112 -0
  162. package/dist/types/clients/decorators/public.d.ts.map +1 -1
  163. package/dist/types/clients/decorators/wallet.d.ts +111 -0
  164. package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
  165. package/dist/types/errors/fee.d.ts +16 -0
  166. package/dist/types/errors/fee.d.ts.map +1 -0
  167. package/dist/types/index.d.ts +23 -17
  168. package/dist/types/index.d.ts.map +1 -1
  169. package/dist/types/public.d.ts +2 -0
  170. package/dist/types/public.d.ts.map +1 -1
  171. package/dist/types/types/chain.d.ts +64 -11
  172. package/dist/types/types/chain.d.ts.map +1 -1
  173. package/dist/types/types/contract.d.ts +2 -2
  174. package/dist/types/types/contract.d.ts.map +1 -1
  175. package/dist/types/types/eip1193.d.ts +14 -2
  176. package/dist/types/types/eip1193.d.ts.map +1 -1
  177. package/dist/types/types/fee.d.ts +1 -0
  178. package/dist/types/types/fee.d.ts.map +1 -1
  179. package/dist/types/utils/data/isBytesEqual.d.ts +1 -1
  180. package/dist/types/utils/data/isBytesEqual.d.ts.map +1 -1
  181. package/dist/types/utils/ens/encodeLabelhash.d.ts +1 -1
  182. package/dist/types/utils/ens/encodeLabelhash.d.ts.map +1 -1
  183. package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts +1 -1
  184. package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts.map +1 -1
  185. package/dist/types/utils/formatters/transactionRequest.d.ts +5 -0
  186. package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
  187. package/dist/types/utils/index.d.ts +3 -1
  188. package/dist/types/utils/index.d.ts.map +1 -1
  189. package/dist/types/utils/rpc.d.ts +1 -1
  190. package/dist/types/utils/rpc.d.ts.map +1 -1
  191. package/dist/types/utils/transaction/parseTransaction.d.ts +5 -1
  192. package/dist/types/utils/transaction/parseTransaction.d.ts.map +1 -1
  193. package/dist/types/version.d.ts +1 -1
  194. package/package.json +1 -1
  195. package/src/actions/ens/getEnsAddress.ts +6 -8
  196. package/src/actions/index.ts +15 -0
  197. package/src/actions/public/estimateFeesPerGas.ts +154 -0
  198. package/src/actions/public/estimateGas.ts +5 -5
  199. package/src/actions/public/estimateMaxPriorityFeePerGas.ts +98 -0
  200. package/src/actions/public/verifyHash.ts +1 -1
  201. package/src/actions/public/verifyMessage.ts +3 -2
  202. package/src/actions/public/verifyTypedData.ts +3 -2
  203. package/src/actions/public/waitForTransactionReceipt.ts +48 -44
  204. package/src/actions/public/watchContractEvent.ts +9 -6
  205. package/src/actions/wallet/deployContract.ts +2 -1
  206. package/src/actions/wallet/prepareTransactionRequest.ts +179 -0
  207. package/src/actions/wallet/sendRawTransaction.ts +48 -0
  208. package/src/actions/wallet/sendTransaction.ts +8 -7
  209. package/src/actions/wallet/signTransaction.ts +137 -0
  210. package/src/chains/celo/formatters.ts +11 -12
  211. package/src/chains/celo/parsers.ts +123 -0
  212. package/src/chains/celo/serializers.ts +13 -34
  213. package/src/chains/celo/types.ts +114 -26
  214. package/src/chains/index.ts +1 -0
  215. package/src/chains/utils.ts +10 -6
  216. package/src/clients/createTestClient.ts +2 -1
  217. package/src/clients/decorators/public.ts +145 -0
  218. package/src/clients/decorators/wallet.ts +133 -0
  219. package/src/errors/fee.ts +27 -0
  220. package/src/errors/rpc.ts +1 -1
  221. package/src/index.ts +46 -25
  222. package/src/public.ts +10 -0
  223. package/src/types/chain.ts +80 -12
  224. package/src/types/contract.ts +2 -2
  225. package/src/types/eip1193.ts +14 -2
  226. package/src/types/fee.ts +2 -0
  227. package/src/utils/data/isBytesEqual.ts +4 -1
  228. package/src/utils/ens/encodeLabelhash.ts +1 -1
  229. package/src/utils/ens/encodedLabelToLabelhash.ts +2 -2
  230. package/src/utils/formatters/transactionRequest.ts +10 -0
  231. package/src/utils/index.ts +4 -1
  232. package/src/utils/rpc.ts +5 -8
  233. package/src/utils/transaction/parseTransaction.ts +7 -9
  234. package/src/version.ts +1 -1
  235. package/dist/cjs/utils/transaction/prepareRequest.js +0 -64
  236. package/dist/cjs/utils/transaction/prepareRequest.js.map +0 -1
  237. package/dist/esm/utils/transaction/prepareRequest.js +0 -64
  238. package/dist/esm/utils/transaction/prepareRequest.js.map +0 -1
  239. package/dist/types/utils/transaction/prepareRequest.d.ts +0 -20
  240. package/dist/types/utils/transaction/prepareRequest.d.ts.map +0 -1
  241. package/src/utils/transaction/prepareRequest.ts +0 -143
@@ -1,17 +1,10 @@
1
- import type { Address } from 'abitype'
2
-
3
1
  import { InvalidAddressError } from '../../errors/address.js'
4
2
  import { BaseError } from '../../errors/base.js'
5
3
  import { InvalidChainIdError } from '../../errors/chain.js'
6
4
  import { FeeCapTooHighError, TipAboveFeeCapError } from '../../errors/node.js'
7
5
  import type { ChainSerializers } from '../../types/chain.js'
8
- import type { FeeValuesEIP1559 } from '../../types/fee.js'
9
6
  import type { Signature } from '../../types/misc.js'
10
- import type {
11
- AccessList,
12
- TransactionSerializable,
13
- TransactionSerializableBase,
14
- } from '../../types/transaction.js'
7
+ import type { TransactionSerializable } from '../../types/transaction.js'
15
8
  import { isAddress } from '../../utils/address/isAddress.js'
16
9
  import { concatHex } from '../../utils/data/concat.js'
17
10
  import { trim } from '../../utils/data/trim.js'
@@ -22,6 +15,11 @@ import {
22
15
  type SerializeTransactionFn,
23
16
  serializeTransaction,
24
17
  } from '../../utils/transaction/serializeTransaction.js'
18
+ import type {
19
+ CeloTransactionSerializable,
20
+ TransactionSerializableCIP42,
21
+ TransactionSerializedCIP42,
22
+ } from './types.js'
25
23
 
26
24
  export const serializeTransactionCelo: SerializeTransactionFn<
27
25
  CeloTransactionSerializable
@@ -41,39 +39,18 @@ export const serializersCelo = {
41
39
  transaction: serializeTransactionCelo,
42
40
  } as const satisfies ChainSerializers
43
41
 
44
- //////////////////////////////////////////////////////////////////////////////
45
- // Types
46
-
47
- export type TransactionSerializableCIP42<
48
- TQuantity = bigint,
49
- TIndex = number,
50
- > = TransactionSerializableBase<TQuantity, TIndex> &
51
- FeeValuesEIP1559<TQuantity> & {
52
- accessList?: AccessList
53
- gasPrice?: never
54
- feeCurrency?: Address
55
- gatewayFeeRecipient?: Address
56
- gatewayFee?: TQuantity
57
- chainId: number
58
- type?: 'cip42'
59
- }
60
-
61
- export type CeloTransactionSerializable =
62
- | TransactionSerializableCIP42
63
- | TransactionSerializable
64
-
65
- export type SerializedCIP42TransactionReturnType = `0x7c${string}`
66
-
67
42
  //////////////////////////////////////////////////////////////////////////////
68
43
  // Serializers
69
44
 
45
+ export type SerializeTransactionCIP42ReturnType = TransactionSerializedCIP42
46
+
70
47
  // There shall be a typed transaction with the code 0x7c that has the following format:
71
48
  // 0x7c || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, feecurrency, gatewayFeeRecipient, gatewayfee, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s]).
72
49
  // This will be in addition to the type 0x02 transaction as specified in EIP-1559.
73
50
  function serializeTransactionCIP42(
74
51
  transaction: TransactionSerializableCIP42,
75
52
  signature?: Signature,
76
- ): SerializedCIP42TransactionReturnType {
53
+ ): SerializeTransactionCIP42ReturnType {
77
54
  assertTransactionCIP42(transaction)
78
55
  const {
79
56
  chainId,
@@ -116,7 +93,7 @@ function serializeTransactionCIP42(
116
93
  return concatHex([
117
94
  '0x7c',
118
95
  toRlp(serializedTransaction),
119
- ]) as SerializedCIP42TransactionReturnType
96
+ ]) as SerializeTransactionCIP42ReturnType
120
97
  }
121
98
 
122
99
  //////////////////////////////////////////////////////////////////////////////
@@ -139,7 +116,9 @@ function isCIP42(transaction: CeloTransactionSerializable) {
139
116
  const MAX_MAX_FEE_PER_GAS =
140
117
  115792089237316195423570985008687907853269984665640564039457584007913129639935n
141
118
 
142
- function assertTransactionCIP42(transaction: TransactionSerializableCIP42) {
119
+ export function assertTransactionCIP42(
120
+ transaction: TransactionSerializableCIP42,
121
+ ) {
143
122
  const {
144
123
  chainId,
145
124
  maxPriorityFeePerGas,
@@ -1,17 +1,27 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
3
  import type { Block, BlockTag } from '../../types/block.js'
4
+ import type { FeeValuesEIP1559 } from '../../types/fee.js'
4
5
  import type { Hex } from '../../types/misc.js'
5
6
  import type {
7
+ Index,
8
+ Quantity,
6
9
  RpcBlock,
7
- RpcTransaction,
10
+ RpcTransaction as RpcTransaction_,
8
11
  RpcTransactionReceipt,
9
- RpcTransactionRequest,
12
+ RpcTransactionRequest as RpcTransactionRequest_,
13
+ TransactionType,
10
14
  } from '../../types/rpc.js'
11
15
  import type {
12
- Transaction,
16
+ AccessList,
17
+ Transaction as Transaction_,
18
+ TransactionBase,
13
19
  TransactionReceipt,
14
- TransactionRequest,
20
+ TransactionRequest as TransactionRequest_,
21
+ TransactionRequestBase,
22
+ TransactionSerializable,
23
+ TransactionSerializableBase,
24
+ TransactionSerialized,
15
25
  } from '../../types/transaction.js'
16
26
  import type { NeverBy } from '../../types/utils.js'
17
27
  import type { OptimismRpcTransaction } from '../optimism/types.js'
@@ -62,13 +72,9 @@ export type CeloRpcBlock<
62
72
  > &
63
73
  CeloRpcBlockOverrides
64
74
 
65
- export type CeloRpcTransactionOverrides = {
66
- feeCurrency: Address | null
67
- gatewayFee: Hex | null
68
- gatewayFeeRecipient: Address | null
69
- }
70
75
  export type CeloRpcTransaction<TPending extends boolean = boolean> =
71
- RpcTransaction<TPending> & CeloRpcTransactionOverrides
76
+ | RpcTransaction<TPending>
77
+ | RpcTransactionCIP42<TPending>
72
78
 
73
79
  export type CeloRpcTransactionReceiptOverrides = {
74
80
  feeCurrency: Address | null
@@ -78,21 +84,13 @@ export type CeloRpcTransactionReceiptOverrides = {
78
84
  export type CeloRpcTransactionReceipt = RpcTransactionReceipt &
79
85
  CeloRpcTransactionReceiptOverrides
80
86
 
81
- export type CeloRpcTransactionRequestOverrides = {
82
- feeCurrency?: Address
83
- gatewayFee?: Hex
84
- gatewayFeeRecipient?: Address
85
- }
86
- export type CeloRpcTransactionRequest = RpcTransactionRequest &
87
- CeloRpcTransactionRequestOverrides
87
+ export type CeloRpcTransactionRequest =
88
+ | RpcTransactionRequest
89
+ | RpcTransactionRequestCIP42
88
90
 
89
- export type CeloTransactionOverrides = {
90
- feeCurrency: Address | null
91
- gatewayFee: bigint | null
92
- gatewayFeeRecipient: Address | null
93
- }
94
91
  export type CeloTransaction<TPending extends boolean = boolean> =
95
- Transaction<TPending> & CeloTransactionOverrides
92
+ | Transaction<TPending>
93
+ | TransactionCIP42<TPending>
96
94
 
97
95
  export type CeloTransactionReceiptOverrides = {
98
96
  feeCurrency: Address | null
@@ -102,10 +100,100 @@ export type CeloTransactionReceiptOverrides = {
102
100
  export type CeloTransactionReceipt = TransactionReceipt &
103
101
  CeloTransactionReceiptOverrides
104
102
 
105
- export type CeloTransactionRequestOverrides = {
103
+ export type CeloTransactionRequest =
104
+ | TransactionRequest
105
+ | TransactionRequestCIP42
106
+
107
+ export type CeloTransactionSerializable =
108
+ | TransactionSerializableCIP42
109
+ | TransactionSerializable
110
+
111
+ export type CeloTransactionSerialized<
112
+ TType extends CeloTransactionType = 'legacy',
113
+ > = TransactionSerialized<TType> | TransactionSerializedCIP42
114
+
115
+ export type CeloTransactionType = TransactionType | 'cip42'
116
+
117
+ type RpcTransaction<TPending extends boolean = boolean> =
118
+ RpcTransaction_<TPending> & {
119
+ feeCurrency: Address | null
120
+ gatewayFee: Hex | null
121
+ gatewayFeeRecipient: Address | null
122
+ }
123
+
124
+ type RpcTransactionRequest = RpcTransactionRequest_ & {
125
+ feeCurrency?: Address
126
+ gatewayFee?: Hex
127
+ gatewayFeeRecipient?: Address
128
+ }
129
+
130
+ export type RpcTransactionCIP42<TPending extends boolean = boolean> =
131
+ TransactionBase<Quantity, Index, TPending> &
132
+ FeeValuesEIP1559<Quantity> & {
133
+ feeCurrency: Address | null
134
+ gatewayFee: Hex | null
135
+ gatewayFeeRecipient: Address | null
136
+ type: '0x7c'
137
+ }
138
+
139
+ export type RpcTransactionRequestCIP42 = TransactionRequestBase<
140
+ Quantity,
141
+ Index
142
+ > &
143
+ Partial<FeeValuesEIP1559<Quantity>> & {
144
+ accessList?: AccessList
145
+ feeCurrency?: Address
146
+ gatewayFee?: Hex
147
+ gatewayFeeRecipient?: Address
148
+ type?: '0x7c'
149
+ }
150
+
151
+ type Transaction<TPending extends boolean = boolean> = Transaction_<
152
+ bigint,
153
+ number,
154
+ TPending
155
+ > & {
156
+ feeCurrency: Address | null
157
+ gatewayFee: bigint | null
158
+ gatewayFeeRecipient: Address | null
159
+ }
160
+
161
+ export type TransactionCIP42<TPending extends boolean = boolean> =
162
+ TransactionBase<bigint, number, TPending> &
163
+ FeeValuesEIP1559 & {
164
+ feeCurrency: Address | null
165
+ gatewayFee: bigint | null
166
+ gatewayFeeRecipient: Address | null
167
+ type: 'cip42'
168
+ }
169
+
170
+ type TransactionRequest = TransactionRequest_ & {
106
171
  feeCurrency?: Address
107
172
  gatewayFee?: bigint
108
173
  gatewayFeeRecipient?: Address
109
174
  }
110
- export type CeloTransactionRequest = TransactionRequest &
111
- CeloTransactionRequestOverrides
175
+
176
+ export type TransactionRequestCIP42 = TransactionRequestBase &
177
+ Partial<FeeValuesEIP1559> & {
178
+ accessList?: AccessList
179
+ feeCurrency?: Address
180
+ gatewayFee?: bigint
181
+ gatewayFeeRecipient?: Address
182
+ type?: 'cip42'
183
+ }
184
+
185
+ export type TransactionSerializableCIP42<
186
+ TQuantity = bigint,
187
+ TIndex = number,
188
+ > = TransactionSerializableBase<TQuantity, TIndex> &
189
+ FeeValuesEIP1559<TQuantity> & {
190
+ accessList?: AccessList
191
+ gasPrice?: never
192
+ feeCurrency?: Address
193
+ gatewayFeeRecipient?: Address
194
+ gatewayFee?: TQuantity
195
+ chainId: number
196
+ type?: 'cip42'
197
+ }
198
+
199
+ export type TransactionSerializedCIP42 = `0x7c${string}`
@@ -66,6 +66,7 @@ export const haqqTestedge2 = /*#__PURE__*/ defineChain(chains.haqqTestedge2)
66
66
  export const hardhat = /*#__PURE__*/ defineChain(chains.hardhat)
67
67
  export const harmonyOne = /*#__PURE__*/ defineChain(chains.harmonyOne)
68
68
  export const klaytn = /*#__PURE__*/ defineChain(chains.klaytn)
69
+ export const linea = /*#__PURE__*/ defineChain(chains.linea)
69
70
  export const lineaTestnet = /*#__PURE__*/ defineChain(chains.lineaTestnet)
70
71
  export const localhost = /*#__PURE__*/ defineChain(chains.localhost)
71
72
  export const mainnet = /*#__PURE__*/ defineChain(chains.mainnet)
@@ -1,27 +1,31 @@
1
1
  export { formattersCelo } from './celo/formatters.js'
2
2
  export {
3
- type CeloTransactionSerializable,
4
- type TransactionSerializableCIP42,
5
3
  serializeTransactionCelo,
6
4
  serializersCelo,
7
5
  } from './celo/serializers.js'
6
+ export { parseTransactionCelo } from './celo/parsers.js'
8
7
  export type {
9
8
  CeloBlock,
10
9
  CeloBlockOverrides,
11
10
  CeloRpcBlock,
12
11
  CeloRpcBlockOverrides,
13
12
  CeloRpcTransaction,
14
- CeloRpcTransactionOverrides,
15
13
  CeloRpcTransactionReceipt,
16
14
  CeloRpcTransactionReceiptOverrides,
17
15
  CeloRpcTransactionRequest,
18
- CeloRpcTransactionRequestOverrides,
19
16
  CeloTransaction,
20
- CeloTransactionOverrides,
21
17
  CeloTransactionReceipt,
22
18
  CeloTransactionReceiptOverrides,
23
19
  CeloTransactionRequest,
24
- CeloTransactionRequestOverrides,
20
+ CeloTransactionSerializable,
21
+ CeloTransactionSerialized,
22
+ CeloTransactionType,
23
+ RpcTransactionCIP42,
24
+ RpcTransactionRequestCIP42,
25
+ TransactionCIP42,
26
+ TransactionRequestCIP42,
27
+ TransactionSerializableCIP42,
28
+ TransactionSerializedCIP42,
25
29
  } from './celo/types.js'
26
30
 
27
31
  export { formattersOptimism } from './optimism/formatters.js'
@@ -1,3 +1,5 @@
1
+ import type { Address } from 'abitype'
2
+
1
3
  import type { Account } from '../accounts/types.js'
2
4
  import type { ParseAccount } from '../types/account.js'
3
5
  import type { Chain } from '../types/chain.js'
@@ -6,7 +8,6 @@ import type { Prettify } from '../types/utils.js'
6
8
  import { type Client, type ClientConfig, createClient } from './createClient.js'
7
9
  import { type TestActions, testActions } from './decorators/test.js'
8
10
  import type { Transport } from './transports/createTransport.js'
9
- import type { Address } from 'abitype'
10
11
 
11
12
  export type TestClientMode = 'anvil' | 'hardhat' | 'ganache'
12
13
 
@@ -53,11 +53,21 @@ import {
53
53
  type EstimateContractGasReturnType,
54
54
  estimateContractGas,
55
55
  } from '../../actions/public/estimateContractGas.js'
56
+ import {
57
+ type EstimateFeesPerGasParameters,
58
+ type EstimateFeesPerGasReturnType,
59
+ estimateFeesPerGas,
60
+ } from '../../actions/public/estimateFeesPerGas.js'
56
61
  import {
57
62
  type EstimateGasParameters,
58
63
  type EstimateGasReturnType,
59
64
  estimateGas,
60
65
  } from '../../actions/public/estimateGas.js'
66
+ import {
67
+ type EstimateMaxPriorityFeePerGasParameters,
68
+ type EstimateMaxPriorityFeePerGasReturnType,
69
+ estimateMaxPriorityFeePerGas,
70
+ } from '../../actions/public/estimateMaxPriorityFeePerGas.js'
61
71
  import {
62
72
  type GetBalanceParameters,
63
73
  type GetBalanceReturnType,
@@ -196,6 +206,16 @@ import {
196
206
  type WatchPendingTransactionsReturnType,
197
207
  watchPendingTransactions,
198
208
  } from '../../actions/public/watchPendingTransactions.js'
209
+ import {
210
+ type PrepareTransactionRequestParameters,
211
+ type PrepareTransactionRequestReturnType,
212
+ prepareTransactionRequest,
213
+ } from '../../actions/wallet/prepareTransactionRequest.js'
214
+ import {
215
+ type SendRawTransactionParameters,
216
+ type SendRawTransactionReturnType,
217
+ sendRawTransaction,
218
+ } from '../../actions/wallet/sendRawTransaction.js'
199
219
  import type { Account } from '../../types/account.js'
200
220
  import type { BlockNumber, BlockTag } from '../../types/block.js'
201
221
  import type { Chain } from '../../types/chain.js'
@@ -205,6 +225,7 @@ import type {
205
225
  MaybeAbiEventName,
206
226
  MaybeExtractEventArgsFromAbi,
207
227
  } from '../../types/contract.js'
228
+ import type { FeeValuesType } from '../../types/fee.js'
208
229
  import type { FilterType } from '../../types/filter.js'
209
230
  import type { Client } from '../createClient.js'
210
231
  import type { Transport } from '../transports/createTransport.js'
@@ -776,6 +797,33 @@ export type PublicActions<
776
797
  getFeeHistory: (
777
798
  args: GetFeeHistoryParameters,
778
799
  ) => Promise<GetFeeHistoryReturnType>
800
+ /**
801
+ * Returns an estimate for the fees per gas for a transaction to be included
802
+ * in the next block.
803
+ *
804
+ * - Docs: https://viem.sh/docs/actions/public/estimateFeesPerGas.html
805
+ *
806
+ * @param client - Client to use
807
+ * @param parameters - {@link EstimateFeesPerGasParameters}
808
+ * @returns An estimate (in wei) for the fees per gas. {@link EstimateFeesPerGasReturnType}
809
+ *
810
+ * @example
811
+ * import { createPublicClient, http } from 'viem'
812
+ * import { mainnet } from 'viem/chains'
813
+ *
814
+ * const client = createPublicClient({
815
+ * chain: mainnet,
816
+ * transport: http(),
817
+ * })
818
+ * const maxPriorityFeePerGas = await client.estimateFeesPerGas()
819
+ * // { maxFeePerGas: ..., maxPriorityFeePerGas: ... }
820
+ */
821
+ estimateFeesPerGas: <
822
+ TChainOverride extends Chain | undefined,
823
+ TType extends FeeValuesType = 'eip1559',
824
+ >(
825
+ args?: EstimateFeesPerGasParameters<TChain, TChainOverride, TType>,
826
+ ) => Promise<EstimateFeesPerGasReturnType>
779
827
  /**
780
828
  * Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.
781
829
  *
@@ -982,6 +1030,29 @@ export type PublicActions<
982
1030
  ) => Promise<
983
1031
  GetLogsReturnType<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>
984
1032
  >
1033
+ /**
1034
+ * Returns an estimate for the max priority fee per gas (in wei) for a transaction
1035
+ * to be included in the next block.
1036
+ *
1037
+ * - Docs: https://viem.sh/docs/actions/public/estimateMaxPriorityFeePerGas.html
1038
+ *
1039
+ * @param client - Client to use
1040
+ * @returns An estimate (in wei) for the max priority fee per gas. {@link EstimateMaxPriorityFeePerGasReturnType}
1041
+ *
1042
+ * @example
1043
+ * import { createPublicClient, http } from 'viem'
1044
+ * import { mainnet } from 'viem/chains'
1045
+ *
1046
+ * const client = createPublicClient({
1047
+ * chain: mainnet,
1048
+ * transport: http(),
1049
+ * })
1050
+ * const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas()
1051
+ * // 10000000n
1052
+ */
1053
+ estimateMaxPriorityFeePerGas: <TChainOverride extends Chain | undefined,>(
1054
+ args?: EstimateMaxPriorityFeePerGasParameters<TChain, TChainOverride>,
1055
+ ) => Promise<EstimateMaxPriorityFeePerGasReturnType>
985
1056
  /**
986
1057
  * Returns the value from a storage slot at a given address.
987
1058
  *
@@ -1150,6 +1221,47 @@ export type PublicActions<
1150
1221
  >(
1151
1222
  args: MulticallParameters<contracts, allowFailure>,
1152
1223
  ) => Promise<MulticallReturnType<contracts, allowFailure>>
1224
+ /**
1225
+ * Prepares a transaction request for signing.
1226
+ *
1227
+ * - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html
1228
+ *
1229
+ * @param args - {@link PrepareTransactionRequestParameters}
1230
+ * @returns The transaction request. {@link PrepareTransactionRequestReturnType}
1231
+ *
1232
+ * @example
1233
+ * import { createWalletClient, custom } from 'viem'
1234
+ * import { mainnet } from 'viem/chains'
1235
+ *
1236
+ * const client = createWalletClient({
1237
+ * chain: mainnet,
1238
+ * transport: custom(window.ethereum),
1239
+ * })
1240
+ * const request = await client.prepareTransactionRequest({
1241
+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
1242
+ * to: '0x0000000000000000000000000000000000000000',
1243
+ * value: 1n,
1244
+ * })
1245
+ *
1246
+ * @example
1247
+ * // Account Hoisting
1248
+ * import { createWalletClient, http } from 'viem'
1249
+ * import { privateKeyToAccount } from 'viem/accounts'
1250
+ * import { mainnet } from 'viem/chains'
1251
+ *
1252
+ * const client = createWalletClient({
1253
+ * account: privateKeyToAccount('0x…'),
1254
+ * chain: mainnet,
1255
+ * transport: custom(window.ethereum),
1256
+ * })
1257
+ * const request = await client.prepareTransactionRequest({
1258
+ * to: '0x0000000000000000000000000000000000000000',
1259
+ * value: 1n,
1260
+ * })
1261
+ */
1262
+ prepareTransactionRequest: <TChainOverride extends Chain | undefined,>(
1263
+ args: PrepareTransactionRequestParameters<TChain, TAccount, TChainOverride>,
1264
+ ) => Promise<PrepareTransactionRequestReturnType>
1153
1265
  /**
1154
1266
  * Calls a read-only function on a contract, and returns the response.
1155
1267
  *
@@ -1188,6 +1300,33 @@ export type PublicActions<
1188
1300
  >(
1189
1301
  args: ReadContractParameters<abi, functionName, args>,
1190
1302
  ) => Promise<ReadContractReturnType<abi, functionName, args>>
1303
+ /**
1304
+ * Sends a **signed** transaction to the network
1305
+ *
1306
+ * - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html
1307
+ * - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
1308
+ *
1309
+ * @param client - Client to use
1310
+ * @param parameters - {@link SendRawTransactionParameters}
1311
+ * @returns The transaction hash. {@link SendRawTransactionReturnType}
1312
+ *
1313
+ * @example
1314
+ * import { createWalletClient, custom } from 'viem'
1315
+ * import { mainnet } from 'viem/chains'
1316
+ * import { sendRawTransaction } from 'viem/wallet'
1317
+ *
1318
+ * const client = createWalletClient({
1319
+ * chain: mainnet,
1320
+ * transport: custom(window.ethereum),
1321
+ * })
1322
+ *
1323
+ * const hash = await client.sendRawTransaction({
1324
+ * serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
1325
+ * })
1326
+ */
1327
+ sendRawTransaction: (
1328
+ args: SendRawTransactionParameters,
1329
+ ) => Promise<SendRawTransactionReturnType>
1191
1330
  /**
1192
1331
  * Simulates/validates a contract interaction. This is useful for retrieving **return data** and **revert reasons** of contract write functions.
1193
1332
  *
@@ -1511,10 +1650,13 @@ export function publicActions<
1511
1650
  getEnsResolver: (args) => getEnsResolver(client, args),
1512
1651
  getEnsText: (args) => getEnsText(client, args),
1513
1652
  getFeeHistory: (args) => getFeeHistory(client, args),
1653
+ estimateFeesPerGas: (args) => estimateFeesPerGas(client, args),
1514
1654
  getFilterChanges: (args) => getFilterChanges(client, args),
1515
1655
  getFilterLogs: (args) => getFilterLogs(client, args),
1516
1656
  getGasPrice: () => getGasPrice(client),
1517
1657
  getLogs: (args) => getLogs(client, args as any),
1658
+ estimateMaxPriorityFeePerGas: (args) =>
1659
+ estimateMaxPriorityFeePerGas(client, args),
1518
1660
  getStorageAt: (args) => getStorageAt(client, args),
1519
1661
  getTransaction: (args) => getTransaction(client, args),
1520
1662
  getTransactionConfirmations: (args) =>
@@ -1522,7 +1664,10 @@ export function publicActions<
1522
1664
  getTransactionCount: (args) => getTransactionCount(client, args),
1523
1665
  getTransactionReceipt: (args) => getTransactionReceipt(client, args),
1524
1666
  multicall: (args) => multicall(client, args),
1667
+ prepareTransactionRequest: (args) =>
1668
+ prepareTransactionRequest(client as any, args as any),
1525
1669
  readContract: (args) => readContract(client, args),
1670
+ sendRawTransaction: (args) => sendRawTransaction(client, args),
1526
1671
  simulateContract: (args) => simulateContract(client, args),
1527
1672
  verifyMessage: (args) => verifyMessage(client, args),
1528
1673
  verifyTypedData: (args) => verifyTypedData(client, args),