viem 2.39.2 → 2.40.0

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 (91) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/_cjs/accounts/mnemonicToAccount.js +3 -3
  3. package/_cjs/accounts/mnemonicToAccount.js.map +1 -1
  4. package/_cjs/actions/index.js +5 -3
  5. package/_cjs/actions/index.js.map +1 -1
  6. package/_cjs/actions/public/fillTransaction.js +118 -0
  7. package/_cjs/actions/public/fillTransaction.js.map +1 -0
  8. package/_cjs/actions/wallet/prepareTransactionRequest.js +45 -11
  9. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  10. package/_cjs/chains/definitions/etherlinkShadownetTestnet.js +24 -0
  11. package/_cjs/chains/definitions/etherlinkShadownetTestnet.js.map +1 -0
  12. package/_cjs/chains/definitions/monad.js +39 -0
  13. package/_cjs/chains/definitions/monad.js.map +1 -0
  14. package/_cjs/chains/index.js +15 -11
  15. package/_cjs/chains/index.js.map +1 -1
  16. package/_cjs/clients/decorators/public.js +2 -0
  17. package/_cjs/clients/decorators/public.js.map +1 -1
  18. package/_cjs/clients/decorators/wallet.js +2 -0
  19. package/_cjs/clients/decorators/wallet.js.map +1 -1
  20. package/_cjs/errors/request.js +28 -0
  21. package/_cjs/errors/request.js.map +1 -1
  22. package/_cjs/errors/version.js +1 -1
  23. package/_cjs/index.js.map +1 -1
  24. package/_cjs/utils/transaction/assertRequest.js +1 -6
  25. package/_cjs/utils/transaction/assertRequest.js.map +1 -1
  26. package/_esm/accounts/mnemonicToAccount.js +3 -3
  27. package/_esm/accounts/mnemonicToAccount.js.map +1 -1
  28. package/_esm/actions/index.js +1 -0
  29. package/_esm/actions/index.js.map +1 -1
  30. package/_esm/actions/public/fillTransaction.js +145 -0
  31. package/_esm/actions/public/fillTransaction.js.map +1 -0
  32. package/_esm/actions/wallet/prepareTransactionRequest.js +49 -11
  33. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  34. package/_esm/chains/definitions/etherlinkShadownetTestnet.js +21 -0
  35. package/_esm/chains/definitions/etherlinkShadownetTestnet.js.map +1 -0
  36. package/_esm/chains/definitions/monad.js +36 -0
  37. package/_esm/chains/definitions/monad.js.map +1 -0
  38. package/_esm/chains/index.js +2 -0
  39. package/_esm/chains/index.js.map +1 -1
  40. package/_esm/clients/decorators/public.js +2 -0
  41. package/_esm/clients/decorators/public.js.map +1 -1
  42. package/_esm/clients/decorators/wallet.js +2 -0
  43. package/_esm/clients/decorators/wallet.js.map +1 -1
  44. package/_esm/errors/request.js +28 -0
  45. package/_esm/errors/request.js.map +1 -1
  46. package/_esm/errors/version.js +1 -1
  47. package/_esm/index.js.map +1 -1
  48. package/_esm/utils/transaction/assertRequest.js +1 -6
  49. package/_esm/utils/transaction/assertRequest.js.map +1 -1
  50. package/_types/accounts/mnemonicToAccount.d.ts +4 -2
  51. package/_types/accounts/mnemonicToAccount.d.ts.map +1 -1
  52. package/_types/actions/index.d.ts +1 -0
  53. package/_types/actions/index.d.ts.map +1 -1
  54. package/_types/actions/public/fillTransaction.d.ts +49 -0
  55. package/_types/actions/public/fillTransaction.d.ts.map +1 -0
  56. package/_types/actions/wallet/prepareTransactionRequest.d.ts +1 -1
  57. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  58. package/_types/chains/definitions/etherlinkShadownetTestnet.d.ts +39 -0
  59. package/_types/chains/definitions/etherlinkShadownetTestnet.d.ts.map +1 -0
  60. package/_types/chains/definitions/monad.d.ts +42 -0
  61. package/_types/chains/definitions/monad.d.ts.map +1 -0
  62. package/_types/chains/index.d.ts +2 -0
  63. package/_types/chains/index.d.ts.map +1 -1
  64. package/_types/clients/decorators/public.d.ts +25 -0
  65. package/_types/clients/decorators/public.d.ts.map +1 -1
  66. package/_types/clients/decorators/wallet.d.ts +25 -0
  67. package/_types/clients/decorators/wallet.d.ts.map +1 -1
  68. package/_types/errors/request.d.ts +4 -0
  69. package/_types/errors/request.d.ts.map +1 -1
  70. package/_types/errors/version.d.ts +1 -1
  71. package/_types/index.d.ts +1 -0
  72. package/_types/index.d.ts.map +1 -1
  73. package/_types/types/eip1193.d.ts +30 -0
  74. package/_types/types/eip1193.d.ts.map +1 -1
  75. package/_types/utils/transaction/assertRequest.d.ts +1 -1
  76. package/_types/utils/transaction/assertRequest.d.ts.map +1 -1
  77. package/accounts/mnemonicToAccount.ts +6 -4
  78. package/actions/index.ts +6 -0
  79. package/actions/public/fillTransaction.ts +250 -0
  80. package/actions/wallet/prepareTransactionRequest.ts +76 -10
  81. package/chains/definitions/etherlinkShadownetTestnet.ts +21 -0
  82. package/chains/definitions/monad.ts +36 -0
  83. package/chains/index.ts +2 -0
  84. package/clients/decorators/public.ts +40 -0
  85. package/clients/decorators/wallet.ts +40 -0
  86. package/errors/request.ts +8 -1
  87. package/errors/version.ts +1 -1
  88. package/index.ts +5 -0
  89. package/package.json +1 -1
  90. package/types/eip1193.ts +30 -0
  91. package/utils/transaction/assertRequest.ts +2 -17
package/types/eip1193.ts CHANGED
@@ -753,6 +753,21 @@ export type PublicRpcSchema = [
753
753
  ]
754
754
  ReturnType: Quantity
755
755
  },
756
+ /**
757
+ * @description Fills a transaction with the necessary data to be signed.
758
+ *
759
+ * @example
760
+ * provider.request({ method: 'eth_fillTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
761
+ * // => '0x...'
762
+ */
763
+ {
764
+ Method: 'eth_fillTransaction'
765
+ Parameters: [transaction: TransactionRequest]
766
+ ReturnType: {
767
+ raw: Hex
768
+ tx: Transaction
769
+ }
770
+ },
756
771
  /**
757
772
  * @description Returns a collection of historical gas information
758
773
  *
@@ -1701,6 +1716,21 @@ export type WalletRpcSchema = [
1701
1716
  ]
1702
1717
  ReturnType: Quantity
1703
1718
  },
1719
+ /**
1720
+ * @description Fills a transaction with the necessary data to be signed.
1721
+ *
1722
+ * @example
1723
+ * provider.request({ method: 'eth_fillTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
1724
+ * // => '0x...'
1725
+ */
1726
+ {
1727
+ Method: 'eth_fillTransaction'
1728
+ Parameters: [transaction: TransactionRequest]
1729
+ ReturnType: {
1730
+ raw: Hex
1731
+ tx: Transaction
1732
+ }
1733
+ },
1704
1734
  /**
1705
1735
  * @description Requests that the user provides an Ethereum address to be identified by. Typically causes a browser extension popup to appear.
1706
1736
  * @link https://eips.ethereum.org/EIPS/eip-1102
@@ -14,10 +14,7 @@ import {
14
14
  TipAboveFeeCapError,
15
15
  type TipAboveFeeCapErrorType,
16
16
  } from '../../errors/node.js'
17
- import {
18
- FeeConflictError,
19
- type FeeConflictErrorType,
20
- } from '../../errors/transaction.js'
17
+ import type { FeeConflictErrorType } from '../../errors/transaction.js'
21
18
  import type { ErrorType } from '../../errors/utils.js'
22
19
  import type { Chain } from '../../types/chain.js'
23
20
  import type { ExactPartial } from '../../types/utils.js'
@@ -36,23 +33,11 @@ export type AssertRequestErrorType =
36
33
  | ErrorType
37
34
 
38
35
  export function assertRequest(args: AssertRequestParameters) {
39
- const {
40
- account: account_,
41
- gasPrice,
42
- maxFeePerGas,
43
- maxPriorityFeePerGas,
44
- to,
45
- } = args
36
+ const { account: account_, maxFeePerGas, maxPriorityFeePerGas, to } = args
46
37
  const account = account_ ? parseAccount(account_) : undefined
47
38
  if (account && !isAddress(account.address))
48
39
  throw new InvalidAddressError({ address: account.address })
49
40
  if (to && !isAddress(to)) throw new InvalidAddressError({ address: to })
50
- if (
51
- typeof gasPrice !== 'undefined' &&
52
- (typeof maxFeePerGas !== 'undefined' ||
53
- typeof maxPriorityFeePerGas !== 'undefined')
54
- )
55
- throw new FeeConflictError()
56
41
 
57
42
  if (maxFeePerGas && maxFeePerGas > maxUint256)
58
43
  throw new FeeCapTooHighError({ maxFeePerGas })