viem 0.0.1-alpha.21 → 0.0.1-alpha.23

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 (181) hide show
  1. package/dist/{chain-32f56cfa.d.ts → chain-4b39613a.d.ts} +2 -2
  2. package/dist/{chain-f12cdc7f.d.ts → chain-aa4898d0.d.ts} +1 -1
  3. package/dist/chains.d.ts +3 -3
  4. package/dist/chains.js +46 -46
  5. package/dist/chains.mjs +1 -1
  6. package/dist/{chunk-EC3NUIJE.js → chunk-7Y5QVLX7.js} +13 -13
  7. package/dist/{chunk-EC3NUIJE.js.map → chunk-7Y5QVLX7.js.map} +1 -1
  8. package/dist/{chunk-KEHGSYDO.js → chunk-BV5NTHUX.js} +14 -13
  9. package/dist/chunk-BV5NTHUX.js.map +1 -0
  10. package/dist/{chunk-46BO7YAQ.mjs → chunk-EGVXCZNJ.mjs} +4 -3
  11. package/dist/chunk-EGVXCZNJ.mjs.map +1 -0
  12. package/dist/{chunk-57ZOFERP.mjs → chunk-GX2KDAM3.mjs} +2 -2
  13. package/dist/{chunk-57ZOFERP.mjs.map → chunk-GX2KDAM3.mjs.map} +0 -0
  14. package/dist/{chunk-W7BWWAC4.js → chunk-NW6724MI.js} +14 -14
  15. package/dist/{chunk-W7BWWAC4.js.map → chunk-NW6724MI.js.map} +0 -0
  16. package/dist/{chunk-DGO77E2H.mjs → chunk-RJLUZTJS.mjs} +86 -3
  17. package/dist/chunk-RJLUZTJS.mjs.map +1 -0
  18. package/dist/{chunk-O2GYLJVD.js → chunk-SSPRUPGN.js} +405 -165
  19. package/dist/chunk-SSPRUPGN.js.map +1 -0
  20. package/dist/{chunk-DSPMAIDO.mjs → chunk-TXHOG6KU.mjs} +2 -2
  21. package/dist/{chunk-DSPMAIDO.mjs.map → chunk-TXHOG6KU.mjs.map} +1 -1
  22. package/dist/{chunk-62VTYU2V.mjs → chunk-XBUH66KN.mjs} +406 -166
  23. package/dist/chunk-XBUH66KN.mjs.map +1 -0
  24. package/dist/{chunk-KZMJR27B.js → chunk-ZKYGWITF.js} +147 -64
  25. package/dist/chunk-ZKYGWITF.js.map +1 -0
  26. package/dist/clients/index.d.ts +7 -7
  27. package/dist/clients/index.js +3 -3
  28. package/dist/clients/index.mjs +2 -2
  29. package/dist/{contract-9af4608b.d.ts → contract-4c3a37b3.d.ts} +14 -3
  30. package/dist/{createClient-5d316c7e.d.ts → createClient-55a04188.d.ts} +2 -2
  31. package/dist/{createPublicClient-9d2b42e1.d.ts → createPublicClient-3b27b282.d.ts} +3 -3
  32. package/dist/{createTestClient-79498dab.d.ts → createTestClient-93f9eac6.d.ts} +3 -3
  33. package/dist/{createWalletClient-f69a5230.d.ts → createWalletClient-c10df94d.d.ts} +3 -3
  34. package/dist/{eip1193-6c485d63.d.ts → eip1193-4c24765a.d.ts} +1 -1
  35. package/dist/ens.d.ts +1 -0
  36. package/dist/ens.js +11 -0
  37. package/dist/ens.js.map +1 -0
  38. package/dist/ens.mjs +11 -0
  39. package/dist/ens.mjs.map +1 -0
  40. package/dist/index.d.ts +174 -113
  41. package/dist/index.js +16 -6
  42. package/dist/index.mjs +15 -5
  43. package/dist/normalize-ef9240c0.d.ts +33 -0
  44. package/dist/{parseGwei-4308ad80.d.ts → parseGwei-3411cf2d.d.ts} +101 -37
  45. package/dist/public.d.ts +9 -9
  46. package/dist/public.js +4 -4
  47. package/dist/public.mjs +3 -3
  48. package/dist/{sendTransaction-1c8290a9.d.ts → sendTransaction-f17a2389.d.ts} +3 -3
  49. package/dist/{stopImpersonatingAccount-7781842a.d.ts → stopImpersonatingAccount-afb26486.d.ts} +2 -2
  50. package/dist/test.d.ts +5 -5
  51. package/dist/test.js +3 -3
  52. package/dist/test.mjs +2 -2
  53. package/dist/{transactionRequest-341b6ed2.d.ts → transactionRequest-93e9f001.d.ts} +2 -2
  54. package/dist/utils/index.d.ts +14 -16
  55. package/dist/utils/index.js +8 -2
  56. package/dist/utils/index.mjs +7 -1
  57. package/dist/wallet.d.ts +7 -7
  58. package/dist/wallet.js +3 -3
  59. package/dist/wallet.mjs +2 -2
  60. package/dist/{watchAsset-afaad3c7.d.ts → watchAsset-efd3dd05.d.ts} +3 -3
  61. package/dist/{watchPendingTransactions-3b722547.d.ts → watchPendingTransactions-57df1a13.d.ts} +17 -27
  62. package/dist/{webSocket-b180e679.d.ts → webSocket-d2e7bd0e.d.ts} +2 -2
  63. package/dist/window.d.ts +2 -2
  64. package/package.json +8 -2
  65. package/src/_test/abis.ts +7 -0
  66. package/src/_test/bench.ts +4 -4
  67. package/src/_test/constants.ts +4 -3
  68. package/src/_test/index.ts +4 -2
  69. package/src/_test/utils.ts +39 -1
  70. package/src/actions/index.test.ts +1 -0
  71. package/src/actions/index.ts +2 -0
  72. package/src/actions/public/call.bench.ts +5 -5
  73. package/src/actions/public/deployContract.ts +4 -4
  74. package/src/actions/public/estimateGas.bench.ts +6 -6
  75. package/src/actions/public/getBlock.bench.ts +5 -5
  76. package/src/actions/public/getBlockNumber.bench.ts +5 -5
  77. package/src/actions/public/getFilterChanges.test.ts +9 -9
  78. package/src/actions/public/getFilterLogs.test.ts +7 -7
  79. package/src/actions/public/getGasPrice.bench.ts +1 -10
  80. package/src/actions/public/getLogs.test.ts +7 -7
  81. package/src/actions/public/getTransaction.bench.ts +5 -5
  82. package/src/actions/public/getTransactionReceipt.bench.ts +5 -5
  83. package/src/actions/public/index.test.ts +1 -0
  84. package/src/actions/public/index.ts +3 -0
  85. package/src/actions/public/multicall.test.ts +452 -0
  86. package/src/actions/public/multicall.ts +103 -0
  87. package/src/actions/public/readContract.test.ts +226 -26
  88. package/src/actions/public/readContract.ts +13 -27
  89. package/src/actions/public/simulateContract.bench.ts +10 -0
  90. package/src/actions/public/simulateContract.test.ts +209 -37
  91. package/src/actions/public/simulateContract.ts +17 -21
  92. package/src/actions/public/watchContractEvent.test.ts +61 -57
  93. package/src/actions/public/watchEvent.test.ts +42 -37
  94. package/src/actions/test/impersonateAccount.test.ts +4 -6
  95. package/src/actions/test/sendUnsignedTransaction.test.ts +2 -2
  96. package/src/actions/test/stopImpersonatingAccount.test.ts +5 -7
  97. package/src/actions/wallet/signMessage.test.ts +0 -1
  98. package/src/actions/wallet/switchChain.test.ts +1 -2
  99. package/src/actions/wallet/watchAsset.test.ts +1 -2
  100. package/src/actions/wallet/writeContract.test.ts +37 -7
  101. package/src/actions/wallet/writeContract.ts +5 -14
  102. package/src/clients/transports/fallback.test.ts +34 -0
  103. package/src/clients/transports/fallback.ts +3 -1
  104. package/src/clients/transports/http.test.ts +0 -1
  105. package/src/clients/transports/webSocket.test.ts +0 -1
  106. package/src/constants/abis.test.ts +53 -0
  107. package/src/constants/abis.ts +44 -0
  108. package/src/constants/index.test.ts +14 -0
  109. package/src/constants/index.ts +3 -0
  110. package/src/constants/solidity.test.ts +41 -0
  111. package/src/constants/solidity.ts +35 -0
  112. package/src/ens.ts +5 -0
  113. package/src/errors/abi.test.ts +0 -2
  114. package/src/errors/base.test.ts +44 -2
  115. package/src/errors/base.ts +12 -12
  116. package/src/errors/block.test.ts +6 -6
  117. package/src/errors/contract.test.ts +233 -0
  118. package/src/errors/contract.ts +133 -80
  119. package/src/errors/index.ts +4 -2
  120. package/src/errors/request.test.ts +3 -4
  121. package/src/errors/request.ts +17 -17
  122. package/src/errors/rpc.test.ts +1 -2
  123. package/src/errors/transaction.test.ts +12 -12
  124. package/src/errors/transport.test.ts +0 -1
  125. package/src/index.test.ts +47 -0
  126. package/src/index.ts +10 -0
  127. package/src/types/contract.ts +55 -4
  128. package/src/types/index.ts +5 -0
  129. package/src/types/multicall.ts +82 -0
  130. package/src/utils/abi/decodeAbi.test.ts +1 -2
  131. package/src/utils/abi/decodeAbi.ts +11 -7
  132. package/src/utils/abi/decodeDeployData.test.ts +7 -15
  133. package/src/utils/abi/decodeDeployData.ts +10 -7
  134. package/src/utils/abi/decodeErrorResult.test.ts +103 -3
  135. package/src/utils/abi/decodeErrorResult.ts +30 -13
  136. package/src/utils/abi/decodeFunctionData.test.ts +0 -1
  137. package/src/utils/abi/decodeFunctionResult.test.ts +80 -9
  138. package/src/utils/abi/decodeFunctionResult.ts +15 -11
  139. package/src/utils/abi/encodeAbi.test.ts +3 -4
  140. package/src/utils/abi/encodeAbi.ts +19 -10
  141. package/src/utils/abi/encodeDeployData.test.ts +6 -13
  142. package/src/utils/abi/encodeDeployData.ts +10 -7
  143. package/src/utils/abi/encodeErrorResult.test.ts +2 -7
  144. package/src/utils/abi/encodeErrorResult.ts +18 -11
  145. package/src/utils/abi/encodeEventTopics.test.ts +11 -14
  146. package/src/utils/abi/encodeEventTopics.ts +15 -9
  147. package/src/utils/abi/encodeFunctionData.test.ts +5 -7
  148. package/src/utils/abi/encodeFunctionData.ts +16 -9
  149. package/src/utils/abi/encodeFunctionResult.test.ts +10 -15
  150. package/src/utils/abi/encodeFunctionResult.ts +9 -7
  151. package/src/utils/abi/getAbiItem.test.ts +547 -0
  152. package/src/utils/abi/getAbiItem.ts +93 -3
  153. package/src/utils/abi/index.ts +5 -1
  154. package/src/utils/address/getAddress.test.ts +6 -6
  155. package/src/utils/contract/getContractError.test.ts +247 -62
  156. package/src/utils/contract/getContractError.ts +30 -38
  157. package/src/utils/data/pad.bench.ts +0 -9
  158. package/src/utils/data/trim.bench.ts +0 -16
  159. package/src/utils/encoding/encodeBytes.bench.ts +0 -12
  160. package/src/utils/encoding/encodeHex.bench.ts +0 -11
  161. package/src/utils/ens/index.test.ts +13 -0
  162. package/src/utils/ens/index.ts +5 -0
  163. package/src/utils/ens/labelhash.test.ts +55 -0
  164. package/src/utils/ens/labelhash.ts +16 -0
  165. package/src/utils/ens/namehash.test.ts +65 -0
  166. package/src/utils/ens/namehash.ts +28 -0
  167. package/src/utils/ens/normalize.bench.ts +14 -0
  168. package/src/utils/ens/normalize.test.ts +35 -0
  169. package/src/utils/ens/normalize.ts +14 -0
  170. package/src/utils/hash/keccak256.ts +3 -5
  171. package/src/utils/index.test.ts +3 -0
  172. package/src/utils/index.ts +4 -0
  173. package/src/utils/rpc.test.ts +3 -6
  174. package/src/utils/unit/formatUnit.bench.ts +0 -5
  175. package/src/utils/unit/parseUnit.bench.ts +0 -5
  176. package/dist/chunk-46BO7YAQ.mjs.map +0 -1
  177. package/dist/chunk-62VTYU2V.mjs.map +0 -1
  178. package/dist/chunk-DGO77E2H.mjs.map +0 -1
  179. package/dist/chunk-KEHGSYDO.js.map +0 -1
  180. package/dist/chunk-KZMJR27B.js.map +0 -1
  181. package/dist/chunk-O2GYLJVD.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { Abi } from 'abitype';
2
- import { b as Hex, J as Chain, A as Address, a as BlockTag, K as Formatter, M as MergeIntersectionProperties, N as Formatted, s as TransactionRequest, O as EstimateGasParameters, H as Hash, F as FeeHistory, L as Log, E as FormattedTransaction, P as TransactionFormatter, Q as ExtractFormatter, p as RpcTransactionReceipt, T as TransactionReceipt, S as TransactionType, x as Transaction } from './chain-32f56cfa.js';
3
- import { d as ExtractFunctionNameFromAbi, G as GetValue, e as ExtractArgsFromAbi, f as ExtractResultFromAbi, h as ExtractConstructorArgsFromAbi, F as FormattedBlock, B as BlockFormatter, i as FormattedTransactionReceipt, T as TransactionReceiptFormatter } from './contract-9af4608b.js';
4
- import { P as PublicClient } from './createPublicClient-9d2b42e1.js';
5
- import { W as WalletClient } from './createWalletClient-f69a5230.js';
6
- import { S as SendTransactionArgs, a as SendTransactionResponse } from './sendTransaction-1c8290a9.js';
7
- import { T as TransactionRequestFormatter } from './transactionRequest-341b6ed2.js';
1
+ import { Abi, Narrow } from 'abitype';
2
+ import { H as Hex, C as Chain, A as Address, b as BlockTag, K as Formatter, M as MergeIntersectionProperties, N as Formatted, s as TransactionRequest, O as EstimateGasParameters, a as Hash, F as FeeHistory, L as Log, G as FormattedTransaction, P as TransactionFormatter, Q as ExtractFormatter, p as RpcTransactionReceipt, T as TransactionReceipt, S as TransactionType, x as Transaction } from './chain-4b39613a.js';
3
+ import { G as GetValue, C as ContractConfig, E as ExtractResultFromAbi, e as ExtractConstructorArgsFromAbi, F as FormattedBlock, B as BlockFormatter, g as FormattedTransactionReceipt, T as TransactionReceiptFormatter } from './contract-4c3a37b3.js';
4
+ import { P as PublicClient } from './createPublicClient-3b27b282.js';
5
+ import { W as WalletClient } from './createWalletClient-c10df94d.js';
6
+ import { S as SendTransactionArgs, a as SendTransactionResponse } from './sendTransaction-f17a2389.js';
7
+ import { T as TransactionRequestFormatter } from './transactionRequest-93e9f001.js';
8
8
 
9
9
  type FilterType = 'transaction' | 'block' | 'event';
10
10
  type Filter<TFilterType extends FilterType = 'event'> = {
@@ -30,30 +30,20 @@ type CallResponse = {
30
30
  };
31
31
  declare function call<TChain extends Chain>(client: PublicClient, { blockNumber, blockTag, chain, from, accessList, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, ...rest }: CallArgs<TChain>): Promise<CallResponse>;
32
32
 
33
- type WriteContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = Omit<SendTransactionArgs<TChain>, 'to' | 'data' | 'value'> & {
34
- address: Address;
35
- abi: TAbi;
36
- functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>;
33
+ type WriteContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = Omit<SendTransactionArgs<TChain>, 'to' | 'data' | 'value'> & {
37
34
  value?: GetValue<TAbi, TFunctionName, SendTransactionArgs<TChain>['value']>;
38
- } & ExtractArgsFromAbi<TAbi, TFunctionName>;
35
+ } & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
39
36
  type WriteContractResponse = SendTransactionResponse;
40
- declare function writeContract<TChain extends Chain, TAbi extends Abi = Abi, TFunctionName extends string = any>(client: WalletClient, { abi, address, args, functionName, ...request }: WriteContractArgs<TChain, TAbi, TFunctionName>): Promise<WriteContractResponse>;
37
+ declare function writeContract<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: WalletClient, { abi, address, args, functionName, ...request }: WriteContractArgs<TChain, TAbi, TFunctionName>): Promise<WriteContractResponse>;
41
38
 
42
- type SimulateContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = Omit<CallArgs<TChain>, 'to' | 'data' | 'value'> & {
43
- address: Address;
44
- abi: TAbi;
45
- functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
39
+ type SimulateContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = any> = Omit<CallArgs<TChain>, 'to' | 'data' | 'value'> & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> & {
46
40
  value?: GetValue<TAbi, TFunctionName, CallArgs<TChain>['value']>;
47
- } & ExtractArgsFromAbi<TAbi, TFunctionName>;
41
+ };
48
42
  type SimulateContractResponse<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi, TFunctionName extends string = string> = {
49
43
  result: ExtractResultFromAbi<TAbi, TFunctionName>;
50
- request: WriteContractArgs<TChain, TAbi, TFunctionName> & {
51
- address: Address;
52
- abi: TAbi;
53
- functionName: ExtractFunctionNameFromAbi<TAbi, TFunctionName>;
54
- } & ExtractArgsFromAbi<TAbi, TFunctionName>;
44
+ request: WriteContractArgs<TChain, TAbi, TFunctionName> & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
55
45
  };
56
- declare function simulateContract<TChain extends Chain, TAbi extends Abi = Abi, TFunctionName extends string = any>(client: PublicClient, { abi, address, args, functionName, ...callRequest }: SimulateContractArgs<TChain, TAbi, TFunctionName>): Promise<SimulateContractResponse<TChain, TAbi, TFunctionName>>;
46
+ declare function simulateContract<TChain extends Chain, TAbi extends Abi | readonly unknown[], TFunctionName extends string>(client: PublicClient, { abi, address, args, functionName, ...callRequest }: SimulateContractArgs<TChain, TAbi, TFunctionName>): Promise<SimulateContractResponse<TChain, TAbi, TFunctionName>>;
57
47
 
58
48
  type CreatePendingTransactionFilterResponse = Filter<'transaction'>;
59
49
  declare function createPendingTransactionFilter(client: PublicClient): Promise<CreatePendingTransactionFilterResponse>;
@@ -61,12 +51,12 @@ declare function createPendingTransactionFilter(client: PublicClient): Promise<C
61
51
  type CreateBlockFilterResponse = Filter<'block'>;
62
52
  declare function createBlockFilter(client: PublicClient): Promise<CreateBlockFilterResponse>;
63
53
 
64
- type DeployContractArgs<TChain extends Chain = Chain, TAbi extends Abi = Abi> = Omit<SendTransactionArgs<TChain>, 'accessList' | 'to' | 'data' | 'value'> & {
65
- abi: TAbi;
54
+ type DeployContractArgs<TChain extends Chain = Chain, TAbi extends Abi | readonly unknown[] = Abi> = Omit<SendTransactionArgs<TChain>, 'accessList' | 'to' | 'data' | 'value'> & {
55
+ abi: Narrow<TAbi>;
66
56
  bytecode: Hex;
67
57
  } & ExtractConstructorArgsFromAbi<TAbi>;
68
58
  type DeployContractResponse = SendTransactionResponse;
69
- declare function deployContract<TChain extends Chain, TAbi extends Abi = Abi>(walletClient: WalletClient, { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>): Promise<DeployContractResponse>;
59
+ declare function deployContract<TChain extends Chain, TAbi extends Abi>(walletClient: WalletClient, { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>): Promise<DeployContractResponse>;
70
60
 
71
61
  type EstimateGasArgs = EstimateGasParameters & ({
72
62
  /** The balance of the account at a block number. */
@@ -1,5 +1,5 @@
1
- import { b as TransportConfig, T as Transport, B as BaseRpcRequests } from './createClient-5d316c7e.js';
2
- import { H as Hash } from './chain-32f56cfa.js';
1
+ import { b as TransportConfig, T as Transport, B as BaseRpcRequests } from './createClient-55a04188.js';
2
+ import { a as Hash } from './chain-4b39613a.js';
3
3
  import { R as RpcResponse } from './rpc-26932bae.js';
4
4
 
5
5
  type EthereumProvider = {
package/dist/window.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as Requests, E as Events } from './eip1193-6c485d63.js';
2
- import './chain-32f56cfa.js';
1
+ import { R as Requests, E as Events } from './eip1193-4c24765a.js';
2
+ import './chain-4b39613a.js';
3
3
  import '@wagmi/chains';
4
4
 
5
5
  type WindowProvider = Requests & Events;
package/package.json CHANGED
@@ -4,9 +4,10 @@
4
4
  "dependencies": {
5
5
  "@noble/hashes": "^1.1.2",
6
6
  "@wagmi/chains": "~0.2.6",
7
- "abitype": "~0.2.5"
7
+ "abitype": "~0.3.0",
8
+ "idna-uts46-hx": "^4.1.2"
8
9
  },
9
- "version": "0.0.1-alpha.21",
10
+ "version": "0.0.1-alpha.23",
10
11
  "files": [
11
12
  "/actions",
12
13
  "/chains",
@@ -33,6 +34,11 @@
33
34
  "module": "./dist/clients/index.mjs",
34
35
  "default": "./dist/clients/index.js"
35
36
  },
37
+ "./ens": {
38
+ "types": "./dist/ens.d.ts",
39
+ "module": "./dist/ens.mjs",
40
+ "default": "./dist/ens.js"
41
+ },
36
42
  "./public": {
37
43
  "types": "./dist/public.d.ts",
38
44
  "module": "./dist/public.mjs",
package/src/_test/abis.ts CHANGED
@@ -1128,6 +1128,13 @@ export const wagmiContractConfig = {
1128
1128
  stateMutability: 'view',
1129
1129
  type: 'function',
1130
1130
  },
1131
+ {
1132
+ inputs: [],
1133
+ name: 'mint',
1134
+ outputs: [],
1135
+ stateMutability: 'nonpayable',
1136
+ type: 'function',
1137
+ },
1131
1138
  {
1132
1139
  inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
1133
1140
  name: 'mint',
@@ -1,6 +1,6 @@
1
1
  import { providers } from 'ethers'
2
+ import { JsonRpcProvider } from 'ethers@6'
2
3
  import Web3 from 'web3'
3
- import { JsonRpcProvider } from 'essential-eth'
4
4
 
5
5
  import { localhost } from '../chains'
6
6
 
@@ -8,8 +8,8 @@ export const ethersProvider = new providers.JsonRpcProvider(
8
8
  localhost.rpcUrls.default.http[0],
9
9
  )
10
10
 
11
- export const web3Provider = new Web3(localhost.rpcUrls.default.http[0])
12
-
13
- export const essentialProvider = new JsonRpcProvider(
11
+ export const ethersV6Provider = new JsonRpcProvider(
14
12
  localhost.rpcUrls.default.http[0],
15
13
  )
14
+
15
+ export const web3Provider = new Web3(localhost.rpcUrls.default.http[0])
@@ -43,6 +43,10 @@ export const accounts = [
43
43
  },
44
44
  ] as const
45
45
 
46
+ export const address = {
47
+ vitalik: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
48
+ } as const
49
+
46
50
  export const initialBlockNumber = BigInt(
47
51
  Number(process.env.VITE_ANVIL_BLOCK_NUMBER),
48
52
  )
@@ -55,6 +59,3 @@ export const transfer1Data = (address: string): Hex =>
55
59
  `0xa9059cbb000000000000000000000000${address
56
60
  .slice(2)
57
61
  .toLowerCase()}0000000000000000000000000000000000000000000000000000000000000001`
58
-
59
- // vitalik.eth
60
- export const vitalikAddress = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'
@@ -4,19 +4,21 @@ export {
4
4
  usdcContractConfig,
5
5
  } from './abis'
6
6
 
7
- export { essentialProvider, ethersProvider, web3Provider } from './bench'
7
+ export { ethersProvider, ethersV6Provider, web3Provider } from './bench'
8
8
 
9
9
  export {
10
10
  accounts,
11
+ address,
11
12
  initialBlockNumber,
12
13
  localHttpUrl,
13
14
  localWsUrl,
14
15
  transfer1Data,
15
- vitalikAddress,
16
16
  } from './constants'
17
17
 
18
18
  export {
19
19
  createHttpServer,
20
+ deploy,
21
+ deployBAYC,
20
22
  publicClient,
21
23
  testClient,
22
24
  walletClient,
@@ -1,5 +1,13 @@
1
1
  /* c8 ignore start */
2
- import { localhost } from '../chains'
2
+ import { Abi } from 'abitype'
3
+ import errorsExample from '../../contracts/out/ErrorsExample.sol/ErrorsExample.json'
4
+ import {
5
+ deployContract,
6
+ DeployContractArgs,
7
+ getTransactionReceipt,
8
+ mine,
9
+ } from '../actions'
10
+ import { Chain, localhost } from '../chains'
3
11
  import {
4
12
  createPublicClient,
5
13
  createTestClient,
@@ -11,10 +19,13 @@ import {
11
19
  import { rpc } from '../utils'
12
20
  import { RpcError } from '../types/eip1193'
13
21
  import { accounts, localWsUrl } from './constants'
22
+ import { errorsExampleABI } from './generated'
14
23
 
15
24
  import type { RequestListener } from 'http'
16
25
  import { createServer } from 'http'
17
26
  import type { AddressInfo } from 'net'
27
+ import { baycContractConfig } from './abis'
28
+ import { Hex } from '../types'
18
29
 
19
30
  export const publicClient =
20
31
  process.env.VITE_NETWORK_TRANSPORT_MODE === 'webSocket'
@@ -109,4 +120,31 @@ export function createHttpServer(
109
120
  })
110
121
  })
111
122
  }
123
+
124
+ export async function deploy<TAbi extends Abi = Abi>(
125
+ args: DeployContractArgs<Chain, TAbi>,
126
+ ) {
127
+ const hash = await deployContract(walletClient, args)
128
+ await mine(testClient, { blocks: 1 })
129
+ const { contractAddress } = await getTransactionReceipt(publicClient, {
130
+ hash,
131
+ })
132
+ return { contractAddress }
133
+ }
134
+
135
+ export async function deployBAYC() {
136
+ return deploy({
137
+ ...baycContractConfig,
138
+ args: ['Bored Ape Wagmi Club', 'BAYC', 69420n, 0n],
139
+ from: accounts[0].address,
140
+ })
141
+ }
142
+
143
+ export async function deployErrorExample() {
144
+ return deploy({
145
+ abi: errorsExampleABI,
146
+ bytecode: errorsExample.bytecode.object as Hex,
147
+ from: accounts[0].address,
148
+ })
149
+ }
112
150
  /* c8 ignore stop */
@@ -40,6 +40,7 @@ test('exports actions', () => {
40
40
  "increaseTime": [Function],
41
41
  "inspectTxpool": [Function],
42
42
  "mine": [Function],
43
+ "multicall": [Function],
43
44
  "readContract": [Function],
44
45
  "removeBlockTimestampInterval": [Function],
45
46
  "requestAccounts": [Function],
@@ -23,6 +23,7 @@ export {
23
23
  getTransactionConfirmations,
24
24
  getTransactionCount,
25
25
  getTransactionReceipt,
26
+ multicall,
26
27
  readContract,
27
28
  simulateContract,
28
29
  uninstallFilter,
@@ -73,6 +74,7 @@ export type {
73
74
  GetTransactionReceiptArgs,
74
75
  GetTransactionReceiptResponse,
75
76
  GetTransactionResponse,
77
+ MulticallArgs,
76
78
  OnBlock,
77
79
  OnBlockNumber,
78
80
  OnBlockNumberResponse,
@@ -2,8 +2,8 @@ import { bench, describe } from 'vitest'
2
2
 
3
3
  import {
4
4
  accounts,
5
- essentialProvider,
6
5
  ethersProvider,
6
+ ethersV6Provider,
7
7
  publicClient,
8
8
  web3Provider,
9
9
  } from '../../_test'
@@ -30,16 +30,16 @@ describe('Call', () => {
30
30
  })
31
31
  })
32
32
 
33
- bench('web3.js: `call`', async () => {
34
- await web3Provider.eth.call({
33
+ bench('ethers@6: `call`', async () => {
34
+ await ethersV6Provider.call({
35
35
  data: name4bytes,
36
36
  from: accounts[0].address,
37
37
  to: wagmiContractAddress,
38
38
  })
39
39
  })
40
40
 
41
- bench('essential-eth: `call`', async () => {
42
- await essentialProvider.call({
41
+ bench('web3.js: `call`', async () => {
42
+ await web3Provider.eth.call({
43
43
  data: name4bytes,
44
44
  from: accounts[0].address,
45
45
  to: wagmiContractAddress,
@@ -1,4 +1,4 @@
1
- import { Abi } from 'abitype'
1
+ import { Abi, Narrow } from 'abitype'
2
2
  import { WalletClient } from '../../clients'
3
3
 
4
4
  import { Chain, ExtractConstructorArgsFromAbi, Hex } from '../../types'
@@ -11,18 +11,18 @@ import {
11
11
 
12
12
  export type DeployContractArgs<
13
13
  TChain extends Chain = Chain,
14
- TAbi extends Abi = Abi,
14
+ TAbi extends Abi | readonly unknown[] = Abi,
15
15
  > = Omit<
16
16
  SendTransactionArgs<TChain>,
17
17
  'accessList' | 'to' | 'data' | 'value'
18
18
  > & {
19
- abi: TAbi
19
+ abi: Narrow<TAbi>
20
20
  bytecode: Hex
21
21
  } & ExtractConstructorArgsFromAbi<TAbi>
22
22
 
23
23
  export type DeployContractResponse = SendTransactionResponse
24
24
 
25
- export function deployContract<TChain extends Chain, TAbi extends Abi = Abi>(
25
+ export function deployContract<TChain extends Chain, TAbi extends Abi>(
26
26
  walletClient: WalletClient,
27
27
  { abi, args, bytecode, ...request }: DeployContractArgs<TChain, TAbi>,
28
28
  ): Promise<DeployContractResponse> {
@@ -2,8 +2,8 @@ import { bench, describe } from 'vitest'
2
2
 
3
3
  import {
4
4
  accounts,
5
- essentialProvider,
6
5
  ethersProvider,
6
+ ethersV6Provider,
7
7
  publicClient,
8
8
  web3Provider,
9
9
  } from '../../_test'
@@ -28,16 +28,16 @@ describe('Estimate Gas', () => {
28
28
  })
29
29
  })
30
30
 
31
- bench('web3.js: `estimateGas`', async () => {
32
- await web3Provider.eth.estimateGas({
31
+ bench('ethers@6: `estimateGas`', async () => {
32
+ await ethersV6Provider.estimateGas({
33
33
  from: accounts[0].address,
34
34
  to: accounts[1].address,
35
- value: '1000000000000',
35
+ value: parseEther('1'),
36
36
  })
37
37
  })
38
38
 
39
- bench('essential-eth: `call`', async () => {
40
- await essentialProvider.estimateGas({
39
+ bench('web3.js: `estimateGas`', async () => {
40
+ await web3Provider.eth.estimateGas({
41
41
  from: accounts[0].address,
42
42
  to: accounts[1].address,
43
43
  value: '1000000000000',
@@ -1,8 +1,8 @@
1
1
  import { bench, describe } from 'vitest'
2
2
 
3
3
  import {
4
- essentialProvider,
5
4
  ethersProvider,
5
+ ethersV6Provider,
6
6
  publicClient,
7
7
  web3Provider,
8
8
  } from '../../_test'
@@ -18,11 +18,11 @@ describe('Get Block', () => {
18
18
  await ethersProvider.getBlock('latest')
19
19
  })
20
20
 
21
- bench('web3.js: `getBlock`', async () => {
22
- await web3Provider.eth.getBlock('latest')
21
+ bench('ethers@6: `getBlock`', async () => {
22
+ await ethersV6Provider.getBlock('latest')
23
23
  })
24
24
 
25
- bench('essential-eth: `getBlock`', async () => {
26
- await essentialProvider.getBlock('latest')
25
+ bench('web3.js: `getBlock`', async () => {
26
+ await web3Provider.eth.getBlock('latest')
27
27
  })
28
28
  })
@@ -1,8 +1,8 @@
1
1
  import { bench, describe } from 'vitest'
2
2
 
3
3
  import {
4
- essentialProvider,
5
4
  ethersProvider,
5
+ ethersV6Provider,
6
6
  publicClient,
7
7
  web3Provider,
8
8
  } from '../../_test'
@@ -18,11 +18,11 @@ describe('Get Block Number', () => {
18
18
  await ethersProvider.getBlockNumber()
19
19
  })
20
20
 
21
- bench('web3.js: `getBlockNumber`', async () => {
22
- await web3Provider.eth.getBlockNumber()
21
+ bench('ethers@6: `getBlockNumber`', async () => {
22
+ await ethersV6Provider.getBlockNumber()
23
23
  })
24
24
 
25
- bench('essential-eth: `getBlockNumber`', async () => {
26
- await essentialProvider.getBlockNumber()
25
+ bench('web3.js: `getBlockNumber`', async () => {
26
+ await web3Provider.eth.getBlockNumber()
27
27
  })
28
28
  })
@@ -2,11 +2,11 @@ import { afterAll, assertType, beforeAll, describe, expect, test } from 'vitest'
2
2
 
3
3
  import {
4
4
  accounts,
5
+ address,
5
6
  initialBlockNumber,
6
7
  publicClient,
7
8
  testClient,
8
9
  transfer1Data,
9
- vitalikAddress,
10
10
  walletClient,
11
11
  usdcContractConfig,
12
12
  } from '../../_test'
@@ -28,14 +28,14 @@ import { getFilterChanges } from './getFilterChanges'
28
28
  beforeAll(async () => {
29
29
  await setIntervalMining(testClient, { interval: 0 })
30
30
  await impersonateAccount(testClient, {
31
- address: vitalikAddress,
31
+ address: address.vitalik,
32
32
  })
33
33
  })
34
34
 
35
35
  afterAll(async () => {
36
36
  await setIntervalMining(testClient, { interval: 1 })
37
37
  await stopImpersonatingAccount(testClient, {
38
- address: vitalikAddress,
38
+ address: address.vitalik,
39
39
  })
40
40
  })
41
41
 
@@ -102,12 +102,12 @@ describe('events', () => {
102
102
  const filter = await createEventFilter(publicClient)
103
103
 
104
104
  await sendTransaction(walletClient, {
105
- from: vitalikAddress,
105
+ from: address.vitalik,
106
106
  to: usdcContractConfig.address,
107
107
  data: transfer1Data(accounts[0].address),
108
108
  })
109
109
  await sendTransaction(walletClient, {
110
- from: vitalikAddress,
110
+ from: address.vitalik,
111
111
  to: usdcContractConfig.address,
112
112
  data: transfer1Data(accounts[1].address),
113
113
  })
@@ -122,7 +122,7 @@ describe('events', () => {
122
122
  expect(logs.length).toBe(0)
123
123
 
124
124
  await sendTransaction(walletClient, {
125
- from: vitalikAddress,
125
+ from: address.vitalik,
126
126
  to: usdcContractConfig.address,
127
127
  data: transfer1Data(accounts[2].address),
128
128
  })
@@ -139,12 +139,12 @@ describe('events', () => {
139
139
  })
140
140
 
141
141
  await sendTransaction(walletClient, {
142
- from: vitalikAddress,
142
+ from: address.vitalik,
143
143
  to: usdcContractConfig.address,
144
144
  data: transfer1Data(accounts[0].address),
145
145
  })
146
146
  await sendTransaction(walletClient, {
147
- from: vitalikAddress,
147
+ from: address.vitalik,
148
148
  to: usdcContractConfig.address,
149
149
  data: transfer1Data(accounts[1].address),
150
150
  })
@@ -159,7 +159,7 @@ describe('events', () => {
159
159
  expect(logs.length).toBe(0)
160
160
 
161
161
  await sendTransaction(walletClient, {
162
- from: vitalikAddress,
162
+ from: address.vitalik,
163
163
  to: usdcContractConfig.address,
164
164
  data: transfer1Data(accounts[2].address),
165
165
  })
@@ -2,12 +2,12 @@ import { afterAll, assertType, beforeAll, describe, expect, test } from 'vitest'
2
2
 
3
3
  import {
4
4
  accounts,
5
+ address,
5
6
  initialBlockNumber,
6
7
  publicClient,
7
8
  testClient,
8
9
  transfer1Data,
9
10
  usdcContractConfig,
10
- vitalikAddress,
11
11
  walletClient,
12
12
  } from '../../_test'
13
13
 
@@ -25,14 +25,14 @@ import { getFilterLogs } from './getFilterLogs'
25
25
  beforeAll(async () => {
26
26
  await setIntervalMining(testClient, { interval: 0 })
27
27
  await impersonateAccount(testClient, {
28
- address: vitalikAddress,
28
+ address: address.vitalik,
29
29
  })
30
30
  })
31
31
 
32
32
  afterAll(async () => {
33
33
  await setIntervalMining(testClient, { interval: 1 })
34
34
  await stopImpersonatingAccount(testClient, {
35
- address: vitalikAddress,
35
+ address: address.vitalik,
36
36
  })
37
37
  })
38
38
 
@@ -48,12 +48,12 @@ describe('events', () => {
48
48
  const filter = await createEventFilter(publicClient)
49
49
 
50
50
  await sendTransaction(walletClient, {
51
- from: vitalikAddress,
51
+ from: address.vitalik,
52
52
  to: usdcContractConfig.address,
53
53
  data: transfer1Data(accounts[0].address),
54
54
  })
55
55
  await sendTransaction(walletClient, {
56
- from: vitalikAddress,
56
+ from: address.vitalik,
57
57
  to: usdcContractConfig.address,
58
58
  data: transfer1Data(accounts[1].address),
59
59
  })
@@ -71,12 +71,12 @@ describe('events', () => {
71
71
  })
72
72
 
73
73
  await sendTransaction(walletClient, {
74
- from: vitalikAddress,
74
+ from: address.vitalik,
75
75
  to: usdcContractConfig.address,
76
76
  data: transfer1Data(accounts[0].address),
77
77
  })
78
78
  await sendTransaction(walletClient, {
79
- from: vitalikAddress,
79
+ from: address.vitalik,
80
80
  to: usdcContractConfig.address,
81
81
  data: transfer1Data(accounts[1].address),
82
82
  })
@@ -1,11 +1,6 @@
1
1
  import { bench, describe } from 'vitest'
2
2
 
3
- import {
4
- essentialProvider,
5
- ethersProvider,
6
- publicClient,
7
- web3Provider,
8
- } from '../../_test'
3
+ import { ethersProvider, publicClient, web3Provider } from '../../_test'
9
4
 
10
5
  import { getGasPrice } from './getGasPrice'
11
6
 
@@ -21,8 +16,4 @@ describe('Get Gas Price', () => {
21
16
  bench('web3.js: `getGasPrice`', async () => {
22
17
  await web3Provider.eth.getGasPrice()
23
18
  })
24
-
25
- bench('essential-eth: `getGasPrice`', async () => {
26
- await essentialProvider.getGasPrice()
27
- })
28
19
  })
@@ -2,11 +2,11 @@ import { afterAll, assertType, beforeAll, describe, expect, test } from 'vitest'
2
2
 
3
3
  import {
4
4
  accounts,
5
+ address,
5
6
  initialBlockNumber,
6
7
  publicClient,
7
8
  testClient,
8
9
  transfer1Data,
9
- vitalikAddress,
10
10
  usdcContractConfig,
11
11
  walletClient,
12
12
  } from '../../_test'
@@ -25,14 +25,14 @@ import { getBlock } from './getBlock'
25
25
  beforeAll(async () => {
26
26
  await setIntervalMining(testClient, { interval: 0 })
27
27
  await impersonateAccount(testClient, {
28
- address: vitalikAddress,
28
+ address: address.vitalik,
29
29
  })
30
30
  })
31
31
 
32
32
  afterAll(async () => {
33
33
  await setIntervalMining(testClient, { interval: 1 })
34
34
  await stopImpersonatingAccount(testClient, {
35
- address: vitalikAddress,
35
+ address: address.vitalik,
36
36
  })
37
37
  })
38
38
 
@@ -44,12 +44,12 @@ test('default', async () => {
44
44
  describe('events', () => {
45
45
  test('no args', async () => {
46
46
  await sendTransaction(walletClient, {
47
- from: vitalikAddress,
47
+ from: address.vitalik,
48
48
  to: usdcContractConfig.address,
49
49
  data: transfer1Data(accounts[0].address),
50
50
  })
51
51
  await sendTransaction(walletClient, {
52
- from: vitalikAddress,
52
+ from: address.vitalik,
53
53
  to: usdcContractConfig.address,
54
54
  data: transfer1Data(accounts[1].address),
55
55
  })
@@ -62,12 +62,12 @@ describe('events', () => {
62
62
 
63
63
  test('args: event', async () => {
64
64
  await sendTransaction(walletClient, {
65
- from: vitalikAddress,
65
+ from: address.vitalik,
66
66
  to: usdcContractConfig.address,
67
67
  data: transfer1Data(accounts[0].address),
68
68
  })
69
69
  await sendTransaction(walletClient, {
70
- from: vitalikAddress,
70
+ from: address.vitalik,
71
71
  to: usdcContractConfig.address,
72
72
  data: transfer1Data(accounts[1].address),
73
73
  })