viem 2.0.0-rc.2 → 2.0.0-rc.4

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 (175) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/_cjs/_test/generated.js +313 -0
  3. package/_cjs/_test/generated.js.map +1 -0
  4. package/_cjs/accounts/generateMnemonic.js +2 -2
  5. package/_cjs/accounts/generateMnemonic.js.map +1 -1
  6. package/_cjs/chains/definitions/acala.js +32 -0
  7. package/_cjs/chains/definitions/acala.js.map +1 -0
  8. package/_cjs/chains/definitions/arbitrumSepolia.js +2 -4
  9. package/_cjs/chains/definitions/arbitrumSepolia.js.map +1 -1
  10. package/_cjs/chains/definitions/bahamut.js +43 -0
  11. package/_cjs/chains/definitions/bahamut.js.map +1 -0
  12. package/_cjs/chains/definitions/bitTorrent.js +19 -0
  13. package/_cjs/chains/definitions/bitTorrent.js.map +1 -0
  14. package/_cjs/chains/definitions/bitTorrentTestnet.js +20 -0
  15. package/_cjs/chains/definitions/bitTorrentTestnet.js.map +1 -0
  16. package/_cjs/chains/definitions/jbc.js +32 -0
  17. package/_cjs/chains/definitions/jbc.js.map +1 -0
  18. package/_cjs/chains/definitions/karura.js +32 -0
  19. package/_cjs/chains/definitions/karura.js.map +1 -0
  20. package/_cjs/chains/definitions/klaytn.js +1 -1
  21. package/_cjs/chains/definitions/klaytn.js.map +1 -1
  22. package/_cjs/chains/definitions/mandala.js +32 -0
  23. package/_cjs/chains/definitions/mandala.js.map +1 -0
  24. package/_cjs/chains/definitions/oasisTestnet.js +22 -0
  25. package/_cjs/chains/definitions/oasisTestnet.js.map +1 -0
  26. package/_cjs/chains/definitions/opBNBTestnet.js +1 -1
  27. package/_cjs/chains/definitions/opBNBTestnet.js.map +1 -1
  28. package/_cjs/chains/definitions/wemix.js +19 -0
  29. package/_cjs/chains/definitions/wemix.js.map +1 -0
  30. package/_cjs/chains/definitions/wemixTestnet.js +20 -0
  31. package/_cjs/chains/definitions/wemixTestnet.js.map +1 -0
  32. package/_cjs/chains/definitions/zkFair.js +30 -0
  33. package/_cjs/chains/definitions/zkFair.js.map +1 -0
  34. package/_cjs/chains/definitions/zkFairTestnet.js +30 -0
  35. package/_cjs/chains/definitions/zkFairTestnet.js.map +1 -0
  36. package/_cjs/chains/index.js +28 -4
  37. package/_cjs/chains/index.js.map +1 -1
  38. package/_cjs/chains/opStack/abis.js.map +1 -1
  39. package/_cjs/chains/opStack/contracts.js.map +1 -1
  40. package/_cjs/chains/opStack/decorators/publicL1.js.map +1 -1
  41. package/_cjs/chains/opStack/decorators/publicL2.js.map +1 -1
  42. package/_cjs/chains/opStack/decorators/walletL1.js.map +1 -1
  43. package/_cjs/chains/opStack/decorators/walletL2.js.map +1 -1
  44. package/_cjs/errors/version.js +1 -1
  45. package/_esm/_test/generated.js +335 -0
  46. package/_esm/_test/generated.js.map +1 -0
  47. package/_esm/accounts/generateMnemonic.js +3 -2
  48. package/_esm/accounts/generateMnemonic.js.map +1 -1
  49. package/_esm/chains/definitions/acala.js +29 -0
  50. package/_esm/chains/definitions/acala.js.map +1 -0
  51. package/_esm/chains/definitions/arbitrumSepolia.js +2 -4
  52. package/_esm/chains/definitions/arbitrumSepolia.js.map +1 -1
  53. package/_esm/chains/definitions/bahamut.js +40 -0
  54. package/_esm/chains/definitions/bahamut.js.map +1 -0
  55. package/_esm/chains/definitions/bitTorrent.js +16 -0
  56. package/_esm/chains/definitions/bitTorrent.js.map +1 -0
  57. package/_esm/chains/definitions/bitTorrentTestnet.js +17 -0
  58. package/_esm/chains/definitions/bitTorrentTestnet.js.map +1 -0
  59. package/_esm/chains/definitions/jbc.js +29 -0
  60. package/_esm/chains/definitions/jbc.js.map +1 -0
  61. package/_esm/chains/definitions/karura.js +29 -0
  62. package/_esm/chains/definitions/karura.js.map +1 -0
  63. package/_esm/chains/definitions/klaytn.js +1 -1
  64. package/_esm/chains/definitions/klaytn.js.map +1 -1
  65. package/_esm/chains/definitions/mandala.js +29 -0
  66. package/_esm/chains/definitions/mandala.js.map +1 -0
  67. package/_esm/chains/definitions/oasisTestnet.js +19 -0
  68. package/_esm/chains/definitions/oasisTestnet.js.map +1 -0
  69. package/_esm/chains/definitions/opBNBTestnet.js +1 -1
  70. package/_esm/chains/definitions/opBNBTestnet.js.map +1 -1
  71. package/_esm/chains/definitions/wemix.js +16 -0
  72. package/_esm/chains/definitions/wemix.js.map +1 -0
  73. package/_esm/chains/definitions/wemixTestnet.js +17 -0
  74. package/_esm/chains/definitions/wemixTestnet.js.map +1 -0
  75. package/_esm/chains/definitions/zkFair.js +27 -0
  76. package/_esm/chains/definitions/zkFair.js.map +1 -0
  77. package/_esm/chains/definitions/zkFairTestnet.js +27 -0
  78. package/_esm/chains/definitions/zkFairTestnet.js.map +1 -0
  79. package/_esm/chains/index.js +12 -0
  80. package/_esm/chains/index.js.map +1 -1
  81. package/_esm/chains/opStack/abis.js +4 -0
  82. package/_esm/chains/opStack/abis.js.map +1 -1
  83. package/_esm/chains/opStack/contracts.js +4 -0
  84. package/_esm/chains/opStack/contracts.js.map +1 -1
  85. package/_esm/chains/opStack/decorators/publicL1.js +15 -0
  86. package/_esm/chains/opStack/decorators/publicL1.js.map +1 -1
  87. package/_esm/chains/opStack/decorators/publicL2.js +15 -0
  88. package/_esm/chains/opStack/decorators/publicL2.js.map +1 -1
  89. package/_esm/chains/opStack/decorators/walletL1.js +17 -0
  90. package/_esm/chains/opStack/decorators/walletL1.js.map +1 -1
  91. package/_esm/chains/opStack/decorators/walletL2.js +17 -0
  92. package/_esm/chains/opStack/decorators/walletL2.js.map +1 -1
  93. package/_esm/errors/version.js +1 -1
  94. package/_test/generated.ts +350 -0
  95. package/_types/_test/generated.d.ts +428 -0
  96. package/_types/_test/generated.d.ts.map +1 -0
  97. package/_types/accounts/generateMnemonic.d.ts +2 -1
  98. package/_types/accounts/generateMnemonic.d.ts.map +1 -1
  99. package/_types/actions/public/simulateContract.d.ts +2 -2
  100. package/_types/actions/public/simulateContract.d.ts.map +1 -1
  101. package/_types/chains/definitions/acala.d.ts +40 -0
  102. package/_types/chains/definitions/acala.d.ts.map +1 -0
  103. package/_types/chains/definitions/arbitrumSepolia.d.ts +6 -2
  104. package/_types/chains/definitions/arbitrumSepolia.d.ts.map +1 -1
  105. package/_types/chains/definitions/bahamut.d.ts +40 -0
  106. package/_types/chains/definitions/bahamut.d.ts.map +1 -0
  107. package/_types/chains/definitions/bitTorrent.d.ts +42 -0
  108. package/_types/chains/definitions/bitTorrent.d.ts.map +1 -0
  109. package/_types/chains/definitions/bitTorrentTestnet.d.ts +42 -0
  110. package/_types/chains/definitions/bitTorrentTestnet.d.ts.map +1 -0
  111. package/_types/chains/definitions/jbc.d.ts +36 -0
  112. package/_types/chains/definitions/jbc.d.ts.map +1 -0
  113. package/_types/chains/definitions/karura.d.ts +40 -0
  114. package/_types/chains/definitions/karura.d.ts.map +1 -0
  115. package/_types/chains/definitions/klaytn.d.ts +1 -1
  116. package/_types/chains/definitions/mandala.d.ts +40 -0
  117. package/_types/chains/definitions/mandala.d.ts.map +1 -0
  118. package/_types/chains/definitions/oasisTestnet.d.ts +38 -0
  119. package/_types/chains/definitions/oasisTestnet.d.ts.map +1 -0
  120. package/_types/chains/definitions/opBNBTestnet.d.ts +1 -1
  121. package/_types/chains/definitions/wemix.d.ts +42 -0
  122. package/_types/chains/definitions/wemix.d.ts.map +1 -0
  123. package/_types/chains/definitions/wemixTestnet.d.ts +42 -0
  124. package/_types/chains/definitions/wemixTestnet.d.ts.map +1 -0
  125. package/_types/chains/definitions/zkFair.d.ts +38 -0
  126. package/_types/chains/definitions/zkFair.d.ts.map +1 -0
  127. package/_types/chains/definitions/zkFairTestnet.d.ts +38 -0
  128. package/_types/chains/definitions/zkFairTestnet.d.ts.map +1 -0
  129. package/_types/chains/index.d.ts +12 -0
  130. package/_types/chains/index.d.ts.map +1 -1
  131. package/_types/chains/opStack/abis.d.ts +4 -0
  132. package/_types/chains/opStack/abis.d.ts.map +1 -1
  133. package/_types/chains/opStack/contracts.d.ts +4 -0
  134. package/_types/chains/opStack/contracts.d.ts.map +1 -1
  135. package/_types/chains/opStack/decorators/publicL1.d.ts +15 -0
  136. package/_types/chains/opStack/decorators/publicL1.d.ts.map +1 -1
  137. package/_types/chains/opStack/decorators/publicL2.d.ts +15 -0
  138. package/_types/chains/opStack/decorators/publicL2.d.ts.map +1 -1
  139. package/_types/chains/opStack/decorators/walletL1.d.ts +17 -0
  140. package/_types/chains/opStack/decorators/walletL1.d.ts.map +1 -1
  141. package/_types/chains/opStack/decorators/walletL2.d.ts +17 -0
  142. package/_types/chains/opStack/decorators/walletL2.d.ts.map +1 -1
  143. package/_types/chains/opStack/types/contract.d.ts +8 -7
  144. package/_types/chains/opStack/types/contract.d.ts.map +1 -1
  145. package/_types/clients/decorators/wallet.d.ts +2 -2
  146. package/_types/clients/decorators/wallet.d.ts.map +1 -1
  147. package/_types/errors/version.d.ts +1 -1
  148. package/accounts/generateMnemonic.ts +6 -2
  149. package/actions/public/simulateContract.ts +2 -2
  150. package/chains/definitions/acala.ts +29 -0
  151. package/chains/definitions/arbitrumSepolia.ts +2 -4
  152. package/chains/definitions/bahamut.ts +40 -0
  153. package/chains/definitions/bitTorrent.ts +16 -0
  154. package/chains/definitions/bitTorrentTestnet.ts +17 -0
  155. package/chains/definitions/jbc.ts +29 -0
  156. package/chains/definitions/karura.ts +29 -0
  157. package/chains/definitions/klaytn.ts +1 -1
  158. package/chains/definitions/mandala.ts +29 -0
  159. package/chains/definitions/oasisTestnet.ts +19 -0
  160. package/chains/definitions/opBNBTestnet.ts +1 -1
  161. package/chains/definitions/wemix.ts +16 -0
  162. package/chains/definitions/wemixTestnet.ts +17 -0
  163. package/chains/definitions/zkFair.ts +27 -0
  164. package/chains/definitions/zkFairTestnet.ts +27 -0
  165. package/chains/index.ts +12 -0
  166. package/chains/opStack/abis.ts +4 -0
  167. package/chains/opStack/contracts.ts +4 -0
  168. package/chains/opStack/decorators/publicL1.ts +15 -0
  169. package/chains/opStack/decorators/publicL2.ts +15 -0
  170. package/chains/opStack/decorators/walletL1.ts +17 -0
  171. package/chains/opStack/decorators/walletL2.ts +17 -0
  172. package/chains/opStack/types/contract.ts +15 -6
  173. package/clients/decorators/wallet.ts +2 -2
  174. package/errors/version.ts +1 -1
  175. package/package.json +12 -34
@@ -485,6 +485,21 @@ export type PublicActionsL1<
485
485
  ) => Promise<WaitToProveReturnType>
486
486
  }
487
487
 
488
+ /**
489
+ * A suite of Public Actions for suited for development with Layer 2 (OP Stack) chains.
490
+ *
491
+ * - Docs: https://viem.sh/op-stack/client.html
492
+ *
493
+ * @example
494
+ * import { publicActionsL1 } from 'viem/op-stack'
495
+ * import { mainnet } from 'viem/chains'
496
+ * import { buildDepositTransaction } from 'viem/wallet'
497
+ *
498
+ * export const opStackPublicClientL1 = createWalletClient({
499
+ * chain: mainnet,
500
+ * transport: http(),
501
+ * }).extend(publicActionsL1())
502
+ */
488
503
  export function publicActionsL1() {
489
504
  return <
490
505
  TTransport extends Transport,
@@ -444,6 +444,21 @@ export type PublicActionsL2<
444
444
  ) => Promise<EstimateTotalGasReturnType>
445
445
  }
446
446
 
447
+ /**
448
+ * A suite of Public Actions for suited for development with Layer 2 (OP Stack) chains.
449
+ *
450
+ * - Docs: https://viem.sh/op-stack/client.html
451
+ *
452
+ * @example
453
+ * import { publicActionsL2 } from 'viem/op-stack'
454
+ * import { optimism } from 'viem/chains'
455
+ * import { buildDepositTransaction } from 'viem/wallet'
456
+ *
457
+ * export const opStackPublicClientL1 = createWalletClient({
458
+ * chain: optimism,
459
+ * transport: http(),
460
+ * }).extend(publicActionsL1())
461
+ */
447
462
  export function publicActionsL2() {
448
463
  return <
449
464
  TTransport extends Transport,
@@ -138,6 +138,23 @@ export type WalletActionsL1<
138
138
  ) => Promise<ProveWithdrawalReturnType>
139
139
  }
140
140
 
141
+ /**
142
+ * A suite of Wallet Actions for suited for development with Layer 2 (OP Stack) chains.
143
+ *
144
+ * - Docs: https://viem.sh/op-stack/client.html
145
+ *
146
+ * @example
147
+ * import { createPublicClient, createWalletClient, http } from 'viem'
148
+ * import { mainnet } from 'viem/chains'
149
+ * import { walletActionsL1 } from 'viem/op-stack'
150
+ *
151
+ * const walletClient = createWalletClient({
152
+ * chain: mainnet,
153
+ * transport: http(),
154
+ * }).extend(walletActionsL1())
155
+ *
156
+ * const hash = await walletClient.depositTransaction({...})
157
+ */
141
158
  export function walletActionsL1() {
142
159
  return <
143
160
  TTransport extends Transport,
@@ -69,6 +69,23 @@ export type WalletActionsL2<
69
69
  ) => Promise<InitiateWithdrawalReturnType>
70
70
  }
71
71
 
72
+ /**
73
+ * A suite of Wallet Actions for suited for development with Layer 2 (OP Stack) chains.
74
+ *
75
+ * - Docs: https://viem.sh/op-stack/client.html
76
+ *
77
+ * @example
78
+ * import { createPublicClient, createWalletClient, http } from 'viem'
79
+ * import { mainnet } from 'viem/chains'
80
+ * import { walletActionsL1 } from 'viem/op-stack'
81
+ *
82
+ * const walletClient = createWalletClient({
83
+ * chain: mainnet,
84
+ * transport: http(),
85
+ * }).extend(walletActionsL1())
86
+ *
87
+ * const hash = await walletClient.depositTransaction({...})
88
+ */
72
89
  export function walletActionsL2() {
73
90
  return <
74
91
  TTransport extends Transport,
@@ -1,6 +1,7 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
3
  import type { Chain } from '../../../types/chain.js'
4
+ import type { Prettify } from '../../../types/utils.js'
4
5
  import type { TargetChain } from './chain.js'
5
6
 
6
7
  export type GetContractAddressParameter<
@@ -8,10 +9,18 @@ export type GetContractAddressParameter<
8
9
  contractName extends string,
9
10
  > =
10
11
  | (chain extends Chain
11
- ? {
12
- [_key in `${contractName}Address`]?: undefined
13
- } & { targetChain: TargetChain<chain, contractName> }
12
+ ? Prettify<
13
+ {
14
+ targetChain: Prettify<TargetChain<chain, contractName>>
15
+ } & {
16
+ [_ in `${contractName}Address`]?: undefined
17
+ }
18
+ >
14
19
  : never)
15
- | ({
16
- [_key in `${contractName}Address`]: Address
17
- } & { targetChain?: undefined })
20
+ | Prettify<
21
+ {
22
+ targetChain?: undefined
23
+ } & {
24
+ [_ in `${contractName}Address`]: Address
25
+ }
26
+ >
@@ -370,7 +370,7 @@ export type WalletActions<
370
370
  * value: 1000000000000000000n,
371
371
  * })
372
372
  */
373
- sendTransaction: <TChainOverride extends Chain | undefined>(
373
+ sendTransaction: <TChainOverride extends Chain | undefined = undefined>(
374
374
  args: SendTransactionParameters<TChain, TAccount, TChainOverride>,
375
375
  ) => Promise<SendTransactionReturnType>
376
376
  /**
@@ -664,7 +664,7 @@ export type WalletActions<
664
664
  const abi extends Abi | readonly unknown[],
665
665
  functionName extends ContractFunctionName<abi, 'payable' | 'nonpayable'>,
666
666
  args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
667
- TChainOverride extends Chain | undefined,
667
+ TChainOverride extends Chain | undefined = undefined,
668
668
  >(
669
669
  args: WriteContractParameters<
670
670
  abi,
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.0.0-rc.2'
1
+ export const version = '2.0.0-rc.4'
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.0.0-rc.2",
4
+ "version": "2.0.0-rc.4",
5
+ "type": "module",
5
6
  "main": "./_cjs/index.js",
6
7
  "module": "./_esm/index.js",
7
8
  "types": "./_types/index.d.ts",
@@ -76,27 +77,13 @@
76
77
  },
77
78
  "typesVersions": {
78
79
  "*": {
79
- "accounts": [
80
- "./_types/accounts/index.d.ts"
81
- ],
82
- "actions": [
83
- "./_types/actions/index.d.ts"
84
- ],
85
- "chains": [
86
- "./_types/chains/index.d.ts"
87
- ],
88
- "chains/utils": [
89
- "./_types/chains/utils.d.ts"
90
- ],
91
- "ens": [
92
- "./_types/ens/index.d.ts"
93
- ],
94
- "utils": [
95
- "./_types/utils/index.d.ts"
96
- ],
97
- "window": [
98
- "./_types/window/index.d.ts"
99
- ]
80
+ "accounts": ["./_types/accounts/index.d.ts"],
81
+ "actions": ["./_types/actions/index.d.ts"],
82
+ "chains": ["./_types/chains/index.d.ts"],
83
+ "chains/utils": ["./_types/chains/utils.d.ts"],
84
+ "ens": ["./_types/ens/index.d.ts"],
85
+ "utils": ["./_types/utils/index.d.ts"],
86
+ "window": ["./_types/window/index.d.ts"]
100
87
  }
101
88
  },
102
89
  "peerDependencies": {
@@ -120,21 +107,12 @@
120
107
  "license": "MIT",
121
108
  "homepage": "https://viem.sh",
122
109
  "repository": "wevm/viem",
123
- "authors": [
124
- "awkweb.eth",
125
- "jxom.eth"
126
- ],
110
+ "authors": ["awkweb.eth", "jxom.eth"],
127
111
  "funding": [
128
112
  {
129
113
  "type": "github",
130
114
  "url": "https://github.com/sponsors/wevm"
131
115
  }
132
116
  ],
133
- "keywords": [
134
- "eth",
135
- "ethereum",
136
- "dapps",
137
- "wallet",
138
- "web3"
139
- ]
140
- }
117
+ "keywords": ["eth", "ethereum", "dapps", "wallet", "web3"]
118
+ }