viem 0.0.1-alpha.21 → 0.0.1-alpha.22

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 (170) 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-46BO7YAQ.mjs → chunk-JMFNAGCD.mjs} +4 -3
  7. package/dist/chunk-JMFNAGCD.mjs.map +1 -0
  8. package/dist/{chunk-KZMJR27B.js → chunk-MVD4Y3AE.js} +67 -63
  9. package/dist/chunk-MVD4Y3AE.js.map +1 -0
  10. package/dist/{chunk-57ZOFERP.mjs → chunk-OZIBQJYR.mjs} +2 -2
  11. package/dist/{chunk-57ZOFERP.mjs.map → chunk-OZIBQJYR.mjs.map} +0 -0
  12. package/dist/{chunk-KEHGSYDO.js → chunk-PMPJGAHY.js} +14 -13
  13. package/dist/chunk-PMPJGAHY.js.map +1 -0
  14. package/dist/{chunk-W7BWWAC4.js → chunk-QA3IE5DU.js} +14 -14
  15. package/dist/{chunk-W7BWWAC4.js.map → chunk-QA3IE5DU.js.map} +0 -0
  16. package/dist/{chunk-DSPMAIDO.mjs → chunk-QN2NCTEN.mjs} +2 -2
  17. package/dist/{chunk-DSPMAIDO.mjs.map → chunk-QN2NCTEN.mjs.map} +1 -1
  18. package/dist/{chunk-EC3NUIJE.js → chunk-S77NLWHO.js} +13 -13
  19. package/dist/{chunk-EC3NUIJE.js.map → chunk-S77NLWHO.js.map} +1 -1
  20. package/dist/{chunk-O2GYLJVD.js → chunk-V5U5S7PQ.js} +403 -165
  21. package/dist/chunk-V5U5S7PQ.js.map +1 -0
  22. package/dist/{chunk-62VTYU2V.mjs → chunk-WWJ5YPTJ.mjs} +404 -166
  23. package/dist/chunk-WWJ5YPTJ.mjs.map +1 -0
  24. package/dist/{chunk-DGO77E2H.mjs → chunk-ZXXEENRD.mjs} +7 -3
  25. package/dist/chunk-ZXXEENRD.mjs.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-74f34ac9.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 +125 -113
  41. package/dist/index.js +14 -6
  42. package/dist/index.mjs +13 -5
  43. package/dist/normalize-ef9240c0.d.ts +33 -0
  44. package/dist/{parseGwei-4308ad80.d.ts → parseGwei-b323fb0a.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-a8688b26.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/index.ts +3 -1
  68. package/src/_test/utils.ts +39 -1
  69. package/src/actions/public/call.bench.ts +5 -5
  70. package/src/actions/public/deployContract.ts +4 -4
  71. package/src/actions/public/estimateGas.bench.ts +6 -6
  72. package/src/actions/public/getBlock.bench.ts +5 -5
  73. package/src/actions/public/getBlockNumber.bench.ts +5 -5
  74. package/src/actions/public/getGasPrice.bench.ts +1 -10
  75. package/src/actions/public/getTransaction.bench.ts +5 -5
  76. package/src/actions/public/getTransactionReceipt.bench.ts +5 -5
  77. package/src/actions/public/multicall.test.ts +452 -0
  78. package/src/actions/public/multicall.ts +103 -0
  79. package/src/actions/public/readContract.test.ts +226 -26
  80. package/src/actions/public/readContract.ts +13 -27
  81. package/src/actions/public/simulateContract.bench.ts +10 -0
  82. package/src/actions/public/simulateContract.test.ts +209 -37
  83. package/src/actions/public/simulateContract.ts +17 -21
  84. package/src/actions/public/watchContractEvent.test.ts +36 -32
  85. package/src/actions/public/watchEvent.test.ts +34 -29
  86. package/src/actions/wallet/signMessage.test.ts +0 -1
  87. package/src/actions/wallet/switchChain.test.ts +1 -2
  88. package/src/actions/wallet/watchAsset.test.ts +1 -2
  89. package/src/actions/wallet/writeContract.test.ts +37 -7
  90. package/src/actions/wallet/writeContract.ts +5 -14
  91. package/src/clients/transports/fallback.test.ts +34 -0
  92. package/src/clients/transports/fallback.ts +3 -1
  93. package/src/clients/transports/http.test.ts +0 -1
  94. package/src/clients/transports/webSocket.test.ts +0 -1
  95. package/src/constants/abis.test.ts +53 -0
  96. package/src/constants/abis.ts +44 -0
  97. package/src/constants/index.test.ts +14 -0
  98. package/src/constants/index.ts +3 -0
  99. package/src/constants/solidity.test.ts +41 -0
  100. package/src/constants/solidity.ts +35 -0
  101. package/src/ens.ts +5 -0
  102. package/src/errors/abi.test.ts +0 -2
  103. package/src/errors/base.test.ts +44 -2
  104. package/src/errors/base.ts +12 -12
  105. package/src/errors/block.test.ts +6 -6
  106. package/src/errors/contract.test.ts +233 -0
  107. package/src/errors/contract.ts +133 -80
  108. package/src/errors/index.ts +4 -2
  109. package/src/errors/request.test.ts +3 -4
  110. package/src/errors/request.ts +17 -17
  111. package/src/errors/rpc.test.ts +1 -2
  112. package/src/errors/transaction.test.ts +12 -12
  113. package/src/errors/transport.test.ts +0 -1
  114. package/src/index.test.ts +46 -0
  115. package/src/index.ts +8 -0
  116. package/src/types/contract.ts +55 -4
  117. package/src/types/index.ts +5 -0
  118. package/src/types/multicall.ts +82 -0
  119. package/src/utils/abi/decodeAbi.test.ts +1 -2
  120. package/src/utils/abi/decodeAbi.ts +11 -7
  121. package/src/utils/abi/decodeDeployData.test.ts +7 -15
  122. package/src/utils/abi/decodeDeployData.ts +10 -7
  123. package/src/utils/abi/decodeErrorResult.test.ts +103 -3
  124. package/src/utils/abi/decodeErrorResult.ts +30 -13
  125. package/src/utils/abi/decodeFunctionData.test.ts +0 -1
  126. package/src/utils/abi/decodeFunctionResult.test.ts +80 -9
  127. package/src/utils/abi/decodeFunctionResult.ts +15 -11
  128. package/src/utils/abi/encodeAbi.test.ts +3 -4
  129. package/src/utils/abi/encodeAbi.ts +19 -10
  130. package/src/utils/abi/encodeDeployData.test.ts +6 -13
  131. package/src/utils/abi/encodeDeployData.ts +10 -7
  132. package/src/utils/abi/encodeErrorResult.test.ts +2 -7
  133. package/src/utils/abi/encodeErrorResult.ts +18 -11
  134. package/src/utils/abi/encodeEventTopics.test.ts +11 -14
  135. package/src/utils/abi/encodeEventTopics.ts +15 -9
  136. package/src/utils/abi/encodeFunctionData.test.ts +5 -7
  137. package/src/utils/abi/encodeFunctionData.ts +16 -9
  138. package/src/utils/abi/encodeFunctionResult.test.ts +10 -15
  139. package/src/utils/abi/encodeFunctionResult.ts +9 -7
  140. package/src/utils/abi/getAbiItem.test.ts +547 -0
  141. package/src/utils/abi/getAbiItem.ts +93 -3
  142. package/src/utils/abi/index.ts +5 -1
  143. package/src/utils/address/getAddress.test.ts +6 -6
  144. package/src/utils/contract/getContractError.test.ts +247 -62
  145. package/src/utils/contract/getContractError.ts +30 -38
  146. package/src/utils/data/pad.bench.ts +0 -9
  147. package/src/utils/data/trim.bench.ts +0 -16
  148. package/src/utils/encoding/encodeBytes.bench.ts +0 -12
  149. package/src/utils/encoding/encodeHex.bench.ts +0 -11
  150. package/src/utils/ens/index.test.ts +13 -0
  151. package/src/utils/ens/index.ts +5 -0
  152. package/src/utils/ens/labelhash.test.ts +55 -0
  153. package/src/utils/ens/labelhash.ts +16 -0
  154. package/src/utils/ens/namehash.test.ts +65 -0
  155. package/src/utils/ens/namehash.ts +28 -0
  156. package/src/utils/ens/normalize.bench.ts +14 -0
  157. package/src/utils/ens/normalize.test.ts +35 -0
  158. package/src/utils/ens/normalize.ts +14 -0
  159. package/src/utils/hash/keccak256.ts +3 -5
  160. package/src/utils/index.test.ts +3 -0
  161. package/src/utils/index.ts +4 -0
  162. package/src/utils/rpc.test.ts +3 -6
  163. package/src/utils/unit/formatUnit.bench.ts +0 -5
  164. package/src/utils/unit/parseUnit.bench.ts +0 -5
  165. package/dist/chunk-46BO7YAQ.mjs.map +0 -1
  166. package/dist/chunk-62VTYU2V.mjs.map +0 -1
  167. package/dist/chunk-DGO77E2H.mjs.map +0 -1
  168. package/dist/chunk-KEHGSYDO.js.map +0 -1
  169. package/dist/chunk-KZMJR27B.js.map +0 -1
  170. 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, d as ExtractResultFromAbi, e as ExtractConstructorArgsFromAbi, F as FormattedBlock, B as BlockFormatter, g as FormattedTransactionReceipt, T as TransactionReceiptFormatter } from './contract-74f34ac9.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.22",
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])
@@ -4,7 +4,7 @@ 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,
@@ -17,6 +17,8 @@ export {
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 */
@@ -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
  })
@@ -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
  })
@@ -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'
@@ -23,11 +23,11 @@ describe('Get Transaction', () => {
23
23
  await ethersProvider.getTransaction(hash)
24
24
  })
25
25
 
26
- bench('web3.js: `getTransaction`', async () => {
27
- await web3Provider.eth.getTransaction(hash)
26
+ bench('ethers@6: `getTransaction`', async () => {
27
+ await ethersV6Provider.getTransaction(hash)
28
28
  })
29
29
 
30
- bench('essential-eth: `getTransaction`', async () => {
31
- await essentialProvider.getTransaction(hash)
30
+ bench('web3.js: `getTransaction`', async () => {
31
+ await web3Provider.eth.getTransaction(hash)
32
32
  })
33
33
  })
@@ -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'
@@ -23,11 +23,11 @@ describe('Get Transaction Receipt', () => {
23
23
  await ethersProvider.getTransactionReceipt(hash)
24
24
  })
25
25
 
26
- bench('web3.js: `getTransactionReceipt`', async () => {
27
- await web3Provider.eth.getTransactionReceipt(hash)
26
+ bench('ethers@6: `getTransactionReceipt`', async () => {
27
+ await ethersV6Provider.getTransactionReceipt(hash)
28
28
  })
29
29
 
30
- bench('essential-eth: `getTransactionReceipt`', async () => {
31
- await essentialProvider.getTransactionReceipt(hash)
30
+ bench('web3.js: `getTransactionReceipt`', async () => {
31
+ await web3Provider.eth.getTransactionReceipt(hash)
32
32
  })
33
33
  })