viem 2.13.8 → 2.13.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/_cjs/actions/index.js +4 -2
  3. package/_cjs/actions/index.js.map +1 -1
  4. package/_cjs/actions/public/getEip712Domain.js +54 -0
  5. package/_cjs/actions/public/getEip712Domain.js.map +1 -0
  6. package/_cjs/celo/formatters.js +1 -2
  7. package/_cjs/celo/formatters.js.map +1 -1
  8. package/_cjs/chains/definitions/ham.js +27 -0
  9. package/_cjs/chains/definitions/ham.js.map +1 -0
  10. package/_cjs/chains/definitions/kakarotSepolia.js +1 -1
  11. package/_cjs/chains/definitions/kakarotSepolia.js.map +1 -1
  12. package/_cjs/chains/definitions/redbellyTestnet.js +27 -0
  13. package/_cjs/chains/definitions/redbellyTestnet.js.map +1 -0
  14. package/_cjs/chains/definitions/xai.js +28 -0
  15. package/_cjs/chains/definitions/xai.js.map +1 -0
  16. package/_cjs/chains/definitions/xaiTestnet.js +22 -0
  17. package/_cjs/chains/definitions/xaiTestnet.js.map +1 -0
  18. package/_cjs/chains/index.js +12 -4
  19. package/_cjs/chains/index.js.map +1 -1
  20. package/_cjs/clients/decorators/public.js +2 -0
  21. package/_cjs/clients/decorators/public.js.map +1 -1
  22. package/_cjs/clients/decorators/wallet.js.map +1 -1
  23. package/_cjs/errors/base.js +1 -1
  24. package/_cjs/errors/base.js.map +1 -1
  25. package/_cjs/errors/eip712.js +24 -0
  26. package/_cjs/errors/eip712.js.map +1 -0
  27. package/_cjs/errors/version.js +1 -1
  28. package/_cjs/errors/version.js.map +1 -1
  29. package/_cjs/index.js.map +1 -1
  30. package/_cjs/op-stack/actions/estimateDepositTransactionGas.js +4 -3
  31. package/_cjs/op-stack/actions/estimateDepositTransactionGas.js.map +1 -1
  32. package/_cjs/op-stack/actions/estimateFinalizeWithdrawalGas.js +4 -3
  33. package/_cjs/op-stack/actions/estimateFinalizeWithdrawalGas.js.map +1 -1
  34. package/_cjs/op-stack/actions/estimateInitiateWithdrawalGas.js +4 -3
  35. package/_cjs/op-stack/actions/estimateInitiateWithdrawalGas.js.map +1 -1
  36. package/_cjs/op-stack/actions/estimateProveWithdrawalGas.js +4 -3
  37. package/_cjs/op-stack/actions/estimateProveWithdrawalGas.js.map +1 -1
  38. package/_cjs/utils/abi/encodeDeployData.js.map +1 -1
  39. package/_cjs/utils/transaction/serializeTransaction.js +8 -5
  40. package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
  41. package/_cjs/zksync/actions/sendEip712Transaction.js +7 -7
  42. package/_cjs/zksync/actions/sendEip712Transaction.js.map +1 -1
  43. package/_cjs/zksync/actions/sendTransaction.js +4 -4
  44. package/_cjs/zksync/actions/sendTransaction.js.map +1 -1
  45. package/_cjs/zksync/decorators/eip712.js.map +1 -1
  46. package/_esm/actions/index.js +1 -0
  47. package/_esm/actions/index.js.map +1 -1
  48. package/_esm/actions/public/getEip712Domain.js +82 -0
  49. package/_esm/actions/public/getEip712Domain.js.map +1 -0
  50. package/_esm/celo/formatters.js +1 -2
  51. package/_esm/celo/formatters.js.map +1 -1
  52. package/_esm/chains/definitions/ham.js +24 -0
  53. package/_esm/chains/definitions/ham.js.map +1 -0
  54. package/_esm/chains/definitions/kakarotSepolia.js +1 -1
  55. package/_esm/chains/definitions/kakarotSepolia.js.map +1 -1
  56. package/_esm/chains/definitions/redbellyTestnet.js +24 -0
  57. package/_esm/chains/definitions/redbellyTestnet.js.map +1 -0
  58. package/_esm/chains/definitions/xai.js +25 -0
  59. package/_esm/chains/definitions/xai.js.map +1 -0
  60. package/_esm/chains/definitions/xaiTestnet.js +19 -0
  61. package/_esm/chains/definitions/xaiTestnet.js.map +1 -0
  62. package/_esm/chains/index.js +4 -0
  63. package/_esm/chains/index.js.map +1 -1
  64. package/_esm/clients/decorators/public.js +2 -0
  65. package/_esm/clients/decorators/public.js.map +1 -1
  66. package/_esm/clients/decorators/wallet.js.map +1 -1
  67. package/_esm/errors/base.js +1 -1
  68. package/_esm/errors/base.js.map +1 -1
  69. package/_esm/errors/eip712.js +20 -0
  70. package/_esm/errors/eip712.js.map +1 -0
  71. package/_esm/errors/version.js +1 -1
  72. package/_esm/errors/version.js.map +1 -1
  73. package/_esm/index.js +1 -0
  74. package/_esm/index.js.map +1 -1
  75. package/_esm/op-stack/actions/estimateDepositTransactionGas.js +7 -3
  76. package/_esm/op-stack/actions/estimateDepositTransactionGas.js.map +1 -1
  77. package/_esm/op-stack/actions/estimateFinalizeWithdrawalGas.js +7 -3
  78. package/_esm/op-stack/actions/estimateFinalizeWithdrawalGas.js.map +1 -1
  79. package/_esm/op-stack/actions/estimateInitiateWithdrawalGas.js +7 -3
  80. package/_esm/op-stack/actions/estimateInitiateWithdrawalGas.js.map +1 -1
  81. package/_esm/op-stack/actions/estimateProveWithdrawalGas.js +7 -3
  82. package/_esm/op-stack/actions/estimateProveWithdrawalGas.js.map +1 -1
  83. package/_esm/utils/abi/encodeDeployData.js.map +1 -1
  84. package/_esm/utils/transaction/serializeTransaction.js +8 -5
  85. package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
  86. package/_esm/zksync/actions/sendEip712Transaction.js +7 -7
  87. package/_esm/zksync/actions/sendEip712Transaction.js.map +1 -1
  88. package/_esm/zksync/actions/sendTransaction.js +6 -6
  89. package/_esm/zksync/actions/sendTransaction.js.map +1 -1
  90. package/_esm/zksync/decorators/eip712.js.map +1 -1
  91. package/_types/actions/index.d.ts +1 -0
  92. package/_types/actions/index.d.ts.map +1 -1
  93. package/_types/actions/public/getEip712Domain.d.ts +50 -0
  94. package/_types/actions/public/getEip712Domain.d.ts.map +1 -0
  95. package/_types/celo/formatters.d.ts.map +1 -1
  96. package/_types/chains/definitions/ham.d.ts +37 -0
  97. package/_types/chains/definitions/ham.d.ts.map +1 -0
  98. package/_types/chains/definitions/kakarotSepolia.d.ts +1 -1
  99. package/_types/chains/definitions/redbellyTestnet.d.ts +36 -0
  100. package/_types/chains/definitions/redbellyTestnet.d.ts.map +1 -0
  101. package/_types/chains/definitions/xai.d.ts +33 -0
  102. package/_types/chains/definitions/xai.d.ts.map +1 -0
  103. package/_types/chains/definitions/xaiTestnet.d.ts +35 -0
  104. package/_types/chains/definitions/xaiTestnet.d.ts.map +1 -0
  105. package/_types/chains/index.d.ts +4 -0
  106. package/_types/chains/index.d.ts.map +1 -1
  107. package/_types/clients/decorators/public.d.ts +34 -0
  108. package/_types/clients/decorators/public.d.ts.map +1 -1
  109. package/_types/errors/base.d.ts +1 -0
  110. package/_types/errors/base.d.ts.map +1 -1
  111. package/_types/errors/eip712.d.ts +12 -0
  112. package/_types/errors/eip712.d.ts.map +1 -0
  113. package/_types/errors/version.d.ts +1 -1
  114. package/_types/errors/version.d.ts.map +1 -1
  115. package/_types/index.d.ts +1 -0
  116. package/_types/index.d.ts.map +1 -1
  117. package/_types/op-stack/actions/estimateDepositTransactionGas.d.ts +2 -2
  118. package/_types/op-stack/actions/estimateDepositTransactionGas.d.ts.map +1 -1
  119. package/_types/op-stack/actions/estimateFinalizeWithdrawalGas.d.ts +1 -1
  120. package/_types/op-stack/actions/estimateFinalizeWithdrawalGas.d.ts.map +1 -1
  121. package/_types/op-stack/actions/estimateInitiateWithdrawalGas.d.ts +1 -1
  122. package/_types/op-stack/actions/estimateInitiateWithdrawalGas.d.ts.map +1 -1
  123. package/_types/op-stack/actions/estimateProveWithdrawalGas.d.ts +1 -1
  124. package/_types/op-stack/actions/estimateProveWithdrawalGas.d.ts.map +1 -1
  125. package/_types/types/chain.d.ts +7 -7
  126. package/_types/types/chain.d.ts.map +1 -1
  127. package/_types/utils/abi/encodeDeployData.d.ts +4 -2
  128. package/_types/utils/abi/encodeDeployData.d.ts.map +1 -1
  129. package/_types/utils/transaction/serializeTransaction.d.ts +1 -1
  130. package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
  131. package/_types/zksync/actions/sendEip712Transaction.d.ts +3 -3
  132. package/_types/zksync/actions/sendEip712Transaction.d.ts.map +1 -1
  133. package/_types/zksync/actions/sendTransaction.d.ts +5 -5
  134. package/_types/zksync/actions/sendTransaction.d.ts.map +1 -1
  135. package/_types/zksync/decorators/eip712.d.ts +2 -1
  136. package/_types/zksync/decorators/eip712.d.ts.map +1 -1
  137. package/_types/zksync/types/chain.d.ts +2 -2
  138. package/_types/zksync/types/chain.d.ts.map +1 -1
  139. package/actions/index.ts +6 -0
  140. package/actions/public/getEip712Domain.ts +124 -0
  141. package/celo/formatters.ts +1 -3
  142. package/chains/definitions/ham.ts +24 -0
  143. package/chains/definitions/kakarotSepolia.ts +1 -1
  144. package/chains/definitions/redbellyTestnet.ts +24 -0
  145. package/chains/definitions/xai.ts +25 -0
  146. package/chains/definitions/xaiTestnet.ts +19 -0
  147. package/chains/index.ts +4 -0
  148. package/clients/decorators/public.ts +42 -1
  149. package/clients/decorators/wallet.ts +1 -1
  150. package/errors/base.ts +2 -1
  151. package/errors/eip712.ts +19 -0
  152. package/errors/version.ts +1 -1
  153. package/index.ts +5 -0
  154. package/op-stack/actions/estimateDepositTransactionGas.ts +18 -7
  155. package/op-stack/actions/estimateFinalizeWithdrawalGas.ts +11 -4
  156. package/op-stack/actions/estimateInitiateWithdrawalGas.ts +11 -4
  157. package/op-stack/actions/estimateProveWithdrawalGas.ts +11 -4
  158. package/package.json +1 -1
  159. package/types/chain.ts +7 -7
  160. package/utils/abi/encodeDeployData.ts +6 -5
  161. package/utils/transaction/serializeTransaction.ts +11 -5
  162. package/zksync/actions/sendEip712Transaction.ts +27 -16
  163. package/zksync/actions/sendTransaction.ts +34 -18
  164. package/zksync/decorators/eip712.ts +7 -2
  165. package/zksync/types/chain.ts +9 -9
@@ -0,0 +1,24 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const ham = /*#__PURE__*/ defineChain({
4
+ id: 5112,
5
+ name: 'Ham',
6
+ nativeCurrency: {
7
+ decimals: 18,
8
+ name: 'Ham',
9
+ symbol: 'ETH',
10
+ },
11
+ rpcUrls: {
12
+ default: {
13
+ http: ['https://rpc.ham.fun'],
14
+ webSocket: ['wss://rpc.ham.fun'],
15
+ },
16
+ },
17
+ blockExplorers: {
18
+ default: {
19
+ name: 'Ham Chain Explorer',
20
+ url: 'https://explorer.ham.fun',
21
+ apiUrl: 'https://explorer.ham.fun/api/v2',
22
+ },
23
+ },
24
+ })
@@ -1,7 +1,7 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
3
  export const kakarotSepolia = /*#__PURE__*/ defineChain({
4
- id: 107107114116,
4
+ id: 1802203764,
5
5
  name: 'Kakarot Sepolia',
6
6
  nativeCurrency: {
7
7
  name: 'Ether',
@@ -0,0 +1,24 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const redbellyTestnet = /*#__PURE__*/ defineChain({
4
+ id: 153,
5
+ name: 'Redbelly Network Testnet',
6
+ nativeCurrency: {
7
+ name: 'Redbelly Native Coin',
8
+ symbol: 'RBNT',
9
+ decimals: 18,
10
+ },
11
+ rpcUrls: {
12
+ default: {
13
+ http: ['https://governors.testnet.redbelly.network'],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ default: {
18
+ name: 'Ethernal',
19
+ url: 'https://explorer.testnet.redbelly.network',
20
+ apiUrl: 'https://ethernal.fly.dev/api',
21
+ },
22
+ },
23
+ testnet: true,
24
+ })
@@ -0,0 +1,25 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const xai = /*#__PURE__*/ defineChain({
4
+ id: 660279,
5
+ name: 'Xai Mainnet',
6
+ nativeCurrency: { name: 'Xai', symbol: 'XAI', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://xai-chain.net/rpc'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Blockscout',
15
+ url: 'https://explorer.xai-chain.net',
16
+ },
17
+ },
18
+ contracts: {
19
+ multicall3: {
20
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
21
+ blockCreated: 222549,
22
+ },
23
+ },
24
+ testnet: false,
25
+ })
@@ -0,0 +1,19 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const xaiTestnet = /*#__PURE__*/ defineChain({
4
+ id: 37714555429,
5
+ name: 'Xai Testnet',
6
+ nativeCurrency: { name: 'sXai', symbol: 'sXAI', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://testnet-v2.xai-chain.net/rpc'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Blockscout',
15
+ url: 'https://testnet-explorer-v2.xai-chain.net',
16
+ },
17
+ },
18
+ testnet: true,
19
+ })
package/chains/index.ts CHANGED
@@ -108,6 +108,7 @@ export { gobi } from './definitions/gobi.js'
108
108
  export { goerli } from './definitions/goerli.js'
109
109
  export { gnosis } from './definitions/gnosis.js'
110
110
  export { gnosisChiado } from './definitions/gnosisChiado.js'
111
+ export { ham } from './definitions/ham.js'
111
112
  export { hardhat } from './definitions/hardhat.js'
112
113
  export { harmonyOne } from './definitions/harmonyOne.js'
113
114
  export { haqqMainnet } from './definitions/haqqMainnet.js'
@@ -202,6 +203,7 @@ export { pulsechain } from './definitions/pulsechain.js'
202
203
  export { pulsechainV4 } from './definitions/pulsechainV4.js'
203
204
  export { qMainnet } from './definitions/qMainnet.js'
204
205
  export { qTestnet } from './definitions/qTestnet.js'
206
+ export { redbellyTestnet } from './definitions/redbellyTestnet.js'
205
207
  export { redstone } from './definitions/redstone.js'
206
208
  export { reyaNetwork } from './definitions/reyaNetwork.js'
207
209
  export { rollux } from './definitions/rollux.js'
@@ -269,6 +271,8 @@ export {
269
271
  x1Testnet,
270
272
  } from './definitions/xLayerTestnet.js'
271
273
  export { xLayer } from './definitions/xLayer.js'
274
+ export { xai } from './definitions/xai.js'
275
+ export { xaiTestnet } from './definitions/xaiTestnet.js'
272
276
  export { xdc } from './definitions/xdc.js'
273
277
  export { xdcTestnet } from './definitions/xdcTestnet.js'
274
278
  export { yooldoVerse } from './definitions/yooldoVerse.js'
@@ -106,6 +106,11 @@ import {
106
106
  type GetContractEventsReturnType,
107
107
  getContractEvents,
108
108
  } from '../../actions/public/getContractEvents.js'
109
+ import {
110
+ type GetEip712DomainParameters,
111
+ type GetEip712DomainReturnType,
112
+ getEip712Domain,
113
+ } from '../../actions/public/getEip712Domain.js'
109
114
  import {
110
115
  type GetFeeHistoryParameters,
111
116
  type GetFeeHistoryReturnType,
@@ -703,6 +708,41 @@ export type PublicActions<
703
708
  ) => Promise<
704
709
  GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>
705
710
  >
711
+ /**
712
+ * Reads the EIP-712 domain from a contract, based on the ERC-5267 specification.
713
+ *
714
+ * @param client - A {@link Client} instance.
715
+ * @param parameters - The parameters of the action. {@link GetEip712DomainParameters}
716
+ * @returns The EIP-712 domain, fields, and extensions. {@link GetEip712DomainReturnType}
717
+ *
718
+ * @example
719
+ * ```ts
720
+ * import { createPublicClient, http } from 'viem'
721
+ * import { mainnet } from 'viem/chains'
722
+ *
723
+ * const client = createPublicClient({
724
+ * chain: mainnet,
725
+ * transport: http(),
726
+ * })
727
+ *
728
+ * const domain = await client.getEip712Domain({
729
+ * address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
730
+ * })
731
+ * // {
732
+ * // domain: {
733
+ * // name: 'ExampleContract',
734
+ * // version: '1',
735
+ * // chainId: 1,
736
+ * // verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
737
+ * // },
738
+ * // fields: '0x0f',
739
+ * // extensions: [],
740
+ * // }
741
+ * ```
742
+ */
743
+ getEip712Domain: (
744
+ args: GetEip712DomainParameters,
745
+ ) => Promise<GetEip712DomainReturnType>
706
746
  /**
707
747
  * Gets address for ENS name.
708
748
  *
@@ -1816,6 +1856,7 @@ export function publicActions<
1816
1856
  getBytecode: (args) => getBytecode(client, args),
1817
1857
  getChainId: () => getChainId(client),
1818
1858
  getContractEvents: (args) => getContractEvents(client, args),
1859
+ getEip712Domain: (args) => getEip712Domain(client, args),
1819
1860
  getEnsAddress: (args) => getEnsAddress(client, args),
1820
1861
  getEnsAvatar: (args) => getEnsAvatar(client, args),
1821
1862
  getEnsName: (args) => getEnsName(client, args),
@@ -1838,7 +1879,7 @@ export function publicActions<
1838
1879
  getTransactionReceipt: (args) => getTransactionReceipt(client, args),
1839
1880
  multicall: (args) => multicall(client, args),
1840
1881
  prepareTransactionRequest: (args) =>
1841
- prepareTransactionRequest(client as any, args as any),
1882
+ prepareTransactionRequest(client as any, args as any) as any,
1842
1883
  readContract: (args) => readContract(client, args),
1843
1884
  sendRawTransaction: (args) => sendRawTransaction(client, args),
1844
1885
  simulateContract: (args) => simulateContract(client, args),
@@ -703,7 +703,7 @@ export function walletActions<
703
703
  getChainId: () => getChainId(client),
704
704
  getPermissions: () => getPermissions(client),
705
705
  prepareTransactionRequest: (args) =>
706
- prepareTransactionRequest(client as any, args as any),
706
+ prepareTransactionRequest(client as any, args as any) as any,
707
707
  requestAddresses: () => requestAddresses(client),
708
708
  requestPermissions: (args) => requestPermissions(client, args),
709
709
  sendRawTransaction: (args) => sendRawTransaction(client, args),
package/errors/base.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getVersion } from './utils.js'
2
2
 
3
3
  type BaseErrorParameters = {
4
+ docsBaseUrl?: string | undefined
4
5
  docsPath?: string | undefined
5
6
  docsSlug?: string | undefined
6
7
  metaMessages?: string[] | undefined
@@ -45,7 +46,7 @@ export class BaseError extends Error {
45
46
  ...(args.metaMessages ? [...args.metaMessages, ''] : []),
46
47
  ...(docsPath
47
48
  ? [
48
- `Docs: https://viem.sh${docsPath}${
49
+ `Docs: ${args.docsBaseUrl ?? 'https://viem.sh'}${docsPath}${
49
50
  args.docsSlug ? `#${args.docsSlug}` : ''
50
51
  }`,
51
52
  ]
@@ -0,0 +1,19 @@
1
+ import type { Address } from 'abitype'
2
+ import { BaseError } from './base.js'
3
+
4
+ export type Eip712DomainNotFoundErrorType = Eip712DomainNotFoundError & {
5
+ name: 'Eip712DomainNotFoundError'
6
+ }
7
+ export class Eip712DomainNotFoundError extends BaseError {
8
+ override name = 'Eip712DomainNotFoundError'
9
+ constructor({ address }: { address: Address }) {
10
+ super(`No EIP-712 domain found on contract "${address}".`, {
11
+ metaMessages: [
12
+ 'Ensure that:',
13
+ `- The contract is deployed at the address "${address}".`,
14
+ '- `eip712Domain()` function exists on the contract.',
15
+ '- `eip712Domain()` function matches signature to ERC-5267 specification.',
16
+ ],
17
+ })
18
+ }
19
+ }
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.13.8'
1
+ export const version = '2.13.10'
package/index.ts CHANGED
@@ -48,6 +48,11 @@ export {
48
48
  type GetContractEventsParameters,
49
49
  type GetContractEventsReturnType,
50
50
  } from './actions/public/getContractEvents.js'
51
+ export {
52
+ type GetEip712DomainErrorType,
53
+ type GetEip712DomainParameters,
54
+ type GetEip712DomainReturnType,
55
+ } from './actions/public/getEip712Domain.js'
51
56
  export {
52
57
  type AddChainErrorType,
53
58
  type AddChainParameters,
@@ -1,4 +1,5 @@
1
1
  import type { Address } from 'abitype'
2
+
2
3
  import {
3
4
  type EstimateContractGasErrorType,
4
5
  type EstimateContractGasParameters,
@@ -24,10 +25,11 @@ export type EstimateDepositTransactionGasParameters<
24
25
  chain extends Chain | undefined = Chain | undefined,
25
26
  account extends Account | undefined = Account | undefined,
26
27
  chainOverride extends Chain | undefined = Chain | undefined,
27
- _derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,
28
+ ///
29
+ derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,
28
30
  > = UnionEvaluate<
29
31
  UnionOmit<
30
- FormattedTransactionRequest<_derivedChain>,
32
+ FormattedTransactionRequest<derivedChain>,
31
33
  | 'accessList'
32
34
  | 'data'
33
35
  | 'from'
@@ -40,13 +42,15 @@ export type EstimateDepositTransactionGasParameters<
40
42
  > &
41
43
  GetAccountParameter<account, Account | Address> &
42
44
  GetChainParameter<chain, chainOverride> &
43
- GetContractAddressParameter<_derivedChain, 'portal'> & {
45
+ GetContractAddressParameter<derivedChain, 'portal'> & {
44
46
  /** L2 transaction request. */
45
47
  request: DepositRequest
46
48
  /** Gas limit for transaction execution on the L1. */
47
- gas?: bigint | null | undefined
49
+ gas?: bigint | undefined
48
50
  }
51
+
49
52
  export type EstimateDepositTransactionGasReturnType = bigint
53
+
50
54
  export type EstimateDepositTransactionGasErrorType =
51
55
  | EstimateContractGasErrorType
52
56
  | ErrorType
@@ -116,11 +120,10 @@ export async function estimateDepositTransactionGas<
116
120
  return Object.values(targetChain!.contracts.portal)[0].address
117
121
  })()
118
122
 
119
- return estimateContractGas(client, {
123
+ const params = {
120
124
  account,
121
125
  abi: portalAbi,
122
126
  address: portalAddress,
123
- chain,
124
127
  functionName: 'depositTransaction',
125
128
  args: [
126
129
  isCreation ? zeroAddress : to,
@@ -134,5 +137,13 @@ export async function estimateDepositTransactionGas<
134
137
  maxPriorityFeePerGas,
135
138
  nonce,
136
139
  value: mint,
137
- } as EstimateContractGasParameters)
140
+ // TODO: Not sure `chain` is necessary since it's not used downstream
141
+ // in `estimateContractGas` or `estimateGas`
142
+ // @ts-ignore
143
+ chain,
144
+ } satisfies EstimateContractGasParameters<
145
+ typeof portalAbi,
146
+ 'depositTransaction'
147
+ >
148
+ return estimateContractGas(client, params as any)
138
149
  }
@@ -41,7 +41,7 @@ export type EstimateFinalizeWithdrawalGasParameters<
41
41
  GetChainParameter<chain, chainOverride> &
42
42
  GetContractAddressParameter<_derivedChain, 'portal'> & {
43
43
  /** Gas limit for transaction execution on the L2. */
44
- gas?: bigint | null | undefined
44
+ gas?: bigint | undefined
45
45
  withdrawal: Withdrawal
46
46
  }
47
47
  export type EstimateFinalizeWithdrawalGasReturnType = bigint
@@ -103,16 +103,23 @@ export async function estimateFinalizeWithdrawalGas<
103
103
  return Object.values(targetChain!.contracts.portal)[0].address
104
104
  })()
105
105
 
106
- return estimateContractGas(client, {
106
+ const params = {
107
107
  account,
108
108
  abi: portalAbi,
109
109
  address: portalAddress,
110
- chain,
111
110
  functionName: 'finalizeWithdrawalTransaction',
112
111
  args: [withdrawal],
113
112
  gas,
114
113
  maxFeePerGas,
115
114
  maxPriorityFeePerGas,
116
115
  nonce,
117
- } as EstimateContractGasParameters)
116
+ // TODO: Not sure `chain` is necessary since it's not used downstream
117
+ // in `estimateContractGas` or `estimateGas`
118
+ // @ts-ignore
119
+ chain,
120
+ } satisfies EstimateContractGasParameters<
121
+ typeof portalAbi,
122
+ 'finalizeWithdrawalTransaction'
123
+ >
124
+ return estimateContractGas(client, params as any)
118
125
  }
@@ -40,7 +40,7 @@ export type EstimateInitiateWithdrawalGasParameters<
40
40
  GetAccountParameter<account, Account | Address> &
41
41
  GetChainParameter<chain, chainOverride> & {
42
42
  /** Gas limit for transaction execution on the L2. */
43
- gas?: bigint | null | undefined
43
+ gas?: bigint | undefined
44
44
  /**
45
45
  * Withdrawal request.
46
46
  * Supplied to the L2ToL1MessagePasser `initiateWithdrawal` method.
@@ -102,11 +102,10 @@ export async function estimateInitiateWithdrawalGas<
102
102
  request: { data = '0x', gas: l1Gas, to, value },
103
103
  } = parameters
104
104
 
105
- return estimateContractGas(client, {
105
+ const params = {
106
106
  account,
107
107
  abi: l2ToL1MessagePasserAbi,
108
108
  address: contracts.l2ToL1MessagePasser.address,
109
- chain,
110
109
  functionName: 'initiateWithdrawal',
111
110
  args: [to, l1Gas, data],
112
111
  gas,
@@ -114,5 +113,13 @@ export async function estimateInitiateWithdrawalGas<
114
113
  maxPriorityFeePerGas,
115
114
  nonce,
116
115
  value,
117
- } as EstimateContractGasParameters)
116
+ // TODO: Not sure `chain` is necessary since it's not used downstream
117
+ // in `estimateContractGas` or `estimateGas`
118
+ // @ts-ignore
119
+ chain,
120
+ } satisfies EstimateContractGasParameters<
121
+ typeof l2ToL1MessagePasserAbi,
122
+ 'initiateWithdrawal'
123
+ >
124
+ return estimateContractGas(client, params as any)
118
125
  }
@@ -41,7 +41,7 @@ export type EstimateProveWithdrawalGasParameters<
41
41
  GetChainParameter<chain, chainOverride> &
42
42
  GetContractAddressParameter<_derivedChain, 'portal'> & {
43
43
  /** Gas limit for transaction execution on the L2. */
44
- gas?: bigint | null | undefined
44
+ gas?: bigint | undefined
45
45
  l2OutputIndex: bigint
46
46
  outputRootProof: {
47
47
  version: Hex
@@ -124,16 +124,23 @@ export async function estimateProveWithdrawalGas<
124
124
  return Object.values(targetChain!.contracts.portal)[0].address
125
125
  })()
126
126
 
127
- return estimateContractGas(client, {
127
+ const params = {
128
128
  account,
129
129
  abi: portalAbi,
130
130
  address: portalAddress,
131
- chain,
132
131
  functionName: 'proveWithdrawalTransaction',
133
132
  args: [withdrawal, l2OutputIndex, outputRootProof, withdrawalProof],
134
133
  gas,
135
134
  maxFeePerGas,
136
135
  maxPriorityFeePerGas,
137
136
  nonce,
138
- } as EstimateContractGasParameters)
137
+ // TODO: Not sure `chain` is necessary since it's not used downstream
138
+ // in `estimateContractGas` or `estimateGas`
139
+ // @ts-ignore
140
+ chain,
141
+ } satisfies EstimateContractGasParameters<
142
+ typeof portalAbi,
143
+ 'proveWithdrawalTransaction'
144
+ >
145
+ return estimateContractGas(client, params as any)
139
146
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.13.8",
4
+ "version": "2.13.10",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/chain.ts CHANGED
@@ -169,7 +169,7 @@ export type ChainEstimateFeesPerGasFnParameters<
169
169
  formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
170
170
  > = {
171
171
  /** A function to multiply the base fee based on the `baseFeeMultiplier` value. */
172
- multiply(x: bigint): bigint
172
+ multiply: (x: bigint) => bigint
173
173
  /** The type of fees to return. */
174
174
  type: FeeValuesType
175
175
  } & ChainFeesFnParameters<formatters>
@@ -180,9 +180,9 @@ export type ChainEstimateFeesPerGasFnParameters<
180
180
  export type ExtractChainFormatterExclude<
181
181
  chain extends Chain | undefined,
182
182
  type extends keyof ChainFormatters,
183
- > = chain extends { formatters?: infer _Formatters extends ChainFormatters }
184
- ? _Formatters[type] extends { exclude: infer Exclude }
185
- ? Extract<Exclude, string[]>[number]
183
+ > = chain extends { formatters?: infer formatters extends ChainFormatters }
184
+ ? formatters[type] extends { exclude: infer exclude }
185
+ ? Extract<exclude, readonly string[]>[number]
186
186
  : ''
187
187
  : ''
188
188
 
@@ -190,9 +190,9 @@ export type ExtractChainFormatterParameters<
190
190
  chain extends Chain | undefined,
191
191
  type extends keyof ChainFormatters,
192
192
  fallback,
193
- > = chain extends { formatters?: infer _Formatters extends ChainFormatters }
194
- ? _Formatters[type] extends ChainFormatter
195
- ? Parameters<_Formatters[type]['format']>[0]
193
+ > = chain extends { formatters?: infer formatters extends ChainFormatters }
194
+ ? formatters[type] extends ChainFormatter
195
+ ? Parameters<formatters[type]['format']>[0]
196
196
  : fallback
197
197
  : fallback
198
198
 
@@ -32,11 +32,12 @@ export type EncodeDeployDataParameters<
32
32
  abi: abi
33
33
  bytecode: Hex
34
34
  } & UnionEvaluate<
35
- readonly [] extends allArgs
36
- ? { args?: allArgs | undefined }
37
- : { args: allArgs }
38
- > &
39
- (hasConstructor extends true ? unknown : never)
35
+ hasConstructor extends false
36
+ ? { args?: undefined }
37
+ : readonly [] extends allArgs
38
+ ? { args?: allArgs | undefined }
39
+ : { args: allArgs }
40
+ >
40
41
 
41
42
  export type EncodeDeployDataReturnType = Hex
42
43
 
@@ -370,13 +370,18 @@ function serializeTransactionLegacy(
370
370
 
371
371
  export function toYParitySignatureArray(
372
372
  transaction: TransactionSerializableGeneric,
373
- signature?: Signature | undefined,
373
+ signature_?: Signature | undefined,
374
374
  ) {
375
- const { r, s, v, yParity } = signature ?? transaction
376
- if (typeof r === 'undefined') return []
377
- if (typeof s === 'undefined') return []
375
+ const signature = signature_ ?? transaction
376
+ const { v, yParity } = signature
377
+
378
+ if (typeof signature.r === 'undefined') return []
379
+ if (typeof signature.s === 'undefined') return []
378
380
  if (typeof v === 'undefined' && typeof yParity === 'undefined') return []
379
381
 
382
+ const r = trim(signature.r)
383
+ const s = trim(signature.s)
384
+
380
385
  const yParity_ = (() => {
381
386
  if (typeof yParity === 'number') return yParity ? toHex(1) : '0x'
382
387
  if (v === 0n) return '0x'
@@ -384,5 +389,6 @@ export function toYParitySignatureArray(
384
389
 
385
390
  return v === 27n ? '0x' : toHex(1)
386
391
  })()
387
- return [yParity_, trim(r), trim(s)]
392
+
393
+ return [yParity_, r === '0x00' ? '0x' : r, s === '0x00' ? '0x' : s]
388
394
  }
@@ -5,7 +5,8 @@ import { prepareTransactionRequest } from '../../actions/wallet/prepareTransacti
5
5
  import { sendRawTransaction } from '../../actions/wallet/sendRawTransaction.js'
6
6
  import type {
7
7
  SendTransactionErrorType,
8
- SendTransactionParameters as SendTransactionParameters_,
8
+ SendTransactionParameters,
9
+ SendTransactionRequest,
9
10
  SendTransactionReturnType,
10
11
  } from '../../actions/wallet/sendTransaction.js'
11
12
  import type { Client } from '../../clients/createClient.js'
@@ -24,10 +25,14 @@ import { assertEip712Request } from '../utils/assertEip712Request.js'
24
25
  import { signTransaction } from './signTransaction.js'
25
26
 
26
27
  export type SendEip712TransactionParameters<
27
- TChain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
28
- TAccount extends Account | undefined = Account | undefined,
29
- TChainOverride extends ChainEIP712 | undefined = ChainEIP712 | undefined,
30
- > = SendTransactionParameters_<TChain, TAccount, TChainOverride>
28
+ chain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
29
+ account extends Account | undefined = Account | undefined,
30
+ chainOverride extends ChainEIP712 | undefined = ChainEIP712 | undefined,
31
+ request extends SendTransactionRequest<
32
+ chain,
33
+ chainOverride
34
+ > = SendTransactionRequest<chain, chainOverride>,
35
+ > = SendTransactionParameters<chain, account, chainOverride, request>
31
36
 
32
37
  export type SendEip712TransactionReturnType = SendTransactionReturnType
33
38
 
@@ -74,27 +79,33 @@ export type SendEip712TransactionErrorType = SendTransactionErrorType
74
79
  * })
75
80
  */
76
81
  export async function sendEip712Transaction<
77
- TChain extends ChainEIP712 | undefined,
78
- TAccount extends Account | undefined,
79
- TChainOverride extends ChainEIP712 | undefined = undefined,
82
+ chain extends ChainEIP712 | undefined,
83
+ account extends Account | undefined,
84
+ const request extends SendTransactionRequest<chain, chainOverride>,
85
+ chainOverride extends ChainEIP712 | undefined = undefined,
80
86
  >(
81
- client: Client<Transport, TChain, TAccount>,
82
- args: SendEip712TransactionParameters<TChain, TAccount, TChainOverride>,
87
+ client: Client<Transport, chain, account>,
88
+ parameters: SendEip712TransactionParameters<
89
+ chain,
90
+ account,
91
+ chainOverride,
92
+ request
93
+ >,
83
94
  ): Promise<SendEip712TransactionReturnType> {
84
- const { chain = client.chain } = args
95
+ const { chain = client.chain } = parameters
85
96
 
86
- if (!args.account)
97
+ if (!parameters.account)
87
98
  throw new AccountNotFoundError({
88
99
  docsPath: '/docs/actions/wallet/sendTransaction',
89
100
  })
90
- const account = parseAccount(args.account)
101
+ const account = parseAccount(parameters.account)
91
102
 
92
103
  try {
93
- assertEip712Request(args)
104
+ assertEip712Request(parameters)
94
105
 
95
106
  // Prepare the request for signing (assign appropriate fees, etc.)
96
107
  const request = await prepareTransactionRequest(client, {
97
- ...args,
108
+ ...parameters,
98
109
  parameters: ['gas', 'nonce', 'fees'],
99
110
  } as any)
100
111
 
@@ -121,7 +132,7 @@ export async function sendEip712Transaction<
121
132
  })
122
133
  } catch (err) {
123
134
  throw getTransactionError(err as BaseError, {
124
- ...(args as GetTransactionErrorParameters),
135
+ ...(parameters as GetTransactionErrorParameters),
125
136
  account,
126
137
  chain: chain as Chain,
127
138
  })