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.
- package/dist/{chain-32f56cfa.d.ts → chain-4b39613a.d.ts} +2 -2
- package/dist/{chain-f12cdc7f.d.ts → chain-aa4898d0.d.ts} +1 -1
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-46BO7YAQ.mjs → chunk-JMFNAGCD.mjs} +4 -3
- package/dist/chunk-JMFNAGCD.mjs.map +1 -0
- package/dist/{chunk-KZMJR27B.js → chunk-MVD4Y3AE.js} +67 -63
- package/dist/chunk-MVD4Y3AE.js.map +1 -0
- package/dist/{chunk-57ZOFERP.mjs → chunk-OZIBQJYR.mjs} +2 -2
- package/dist/{chunk-57ZOFERP.mjs.map → chunk-OZIBQJYR.mjs.map} +0 -0
- package/dist/{chunk-KEHGSYDO.js → chunk-PMPJGAHY.js} +14 -13
- package/dist/chunk-PMPJGAHY.js.map +1 -0
- package/dist/{chunk-W7BWWAC4.js → chunk-QA3IE5DU.js} +14 -14
- package/dist/{chunk-W7BWWAC4.js.map → chunk-QA3IE5DU.js.map} +0 -0
- package/dist/{chunk-DSPMAIDO.mjs → chunk-QN2NCTEN.mjs} +2 -2
- package/dist/{chunk-DSPMAIDO.mjs.map → chunk-QN2NCTEN.mjs.map} +1 -1
- package/dist/{chunk-EC3NUIJE.js → chunk-S77NLWHO.js} +13 -13
- package/dist/{chunk-EC3NUIJE.js.map → chunk-S77NLWHO.js.map} +1 -1
- package/dist/{chunk-O2GYLJVD.js → chunk-V5U5S7PQ.js} +403 -165
- package/dist/chunk-V5U5S7PQ.js.map +1 -0
- package/dist/{chunk-62VTYU2V.mjs → chunk-WWJ5YPTJ.mjs} +404 -166
- package/dist/chunk-WWJ5YPTJ.mjs.map +1 -0
- package/dist/{chunk-DGO77E2H.mjs → chunk-ZXXEENRD.mjs} +7 -3
- package/dist/chunk-ZXXEENRD.mjs.map +1 -0
- package/dist/clients/index.d.ts +7 -7
- package/dist/clients/index.js +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/{contract-9af4608b.d.ts → contract-74f34ac9.d.ts} +14 -3
- package/dist/{createClient-5d316c7e.d.ts → createClient-55a04188.d.ts} +2 -2
- package/dist/{createPublicClient-9d2b42e1.d.ts → createPublicClient-3b27b282.d.ts} +3 -3
- package/dist/{createTestClient-79498dab.d.ts → createTestClient-93f9eac6.d.ts} +3 -3
- package/dist/{createWalletClient-f69a5230.d.ts → createWalletClient-c10df94d.d.ts} +3 -3
- package/dist/{eip1193-6c485d63.d.ts → eip1193-4c24765a.d.ts} +1 -1
- package/dist/ens.d.ts +1 -0
- package/dist/ens.js +11 -0
- package/dist/ens.js.map +1 -0
- package/dist/ens.mjs +11 -0
- package/dist/ens.mjs.map +1 -0
- package/dist/index.d.ts +125 -113
- package/dist/index.js +14 -6
- package/dist/index.mjs +13 -5
- package/dist/normalize-ef9240c0.d.ts +33 -0
- package/dist/{parseGwei-4308ad80.d.ts → parseGwei-b323fb0a.d.ts} +101 -37
- package/dist/public.d.ts +9 -9
- package/dist/public.js +4 -4
- package/dist/public.mjs +3 -3
- package/dist/{sendTransaction-1c8290a9.d.ts → sendTransaction-f17a2389.d.ts} +3 -3
- package/dist/{stopImpersonatingAccount-7781842a.d.ts → stopImpersonatingAccount-afb26486.d.ts} +2 -2
- package/dist/test.d.ts +5 -5
- package/dist/test.js +3 -3
- package/dist/test.mjs +2 -2
- package/dist/{transactionRequest-341b6ed2.d.ts → transactionRequest-93e9f001.d.ts} +2 -2
- package/dist/utils/index.d.ts +14 -16
- package/dist/utils/index.js +8 -2
- package/dist/utils/index.mjs +7 -1
- package/dist/wallet.d.ts +7 -7
- package/dist/wallet.js +3 -3
- package/dist/wallet.mjs +2 -2
- package/dist/{watchAsset-afaad3c7.d.ts → watchAsset-efd3dd05.d.ts} +3 -3
- package/dist/{watchPendingTransactions-3b722547.d.ts → watchPendingTransactions-a8688b26.d.ts} +17 -27
- package/dist/{webSocket-b180e679.d.ts → webSocket-d2e7bd0e.d.ts} +2 -2
- package/dist/window.d.ts +2 -2
- package/package.json +8 -2
- package/src/_test/abis.ts +7 -0
- package/src/_test/bench.ts +4 -4
- package/src/_test/index.ts +3 -1
- package/src/_test/utils.ts +39 -1
- package/src/actions/public/call.bench.ts +5 -5
- package/src/actions/public/deployContract.ts +4 -4
- package/src/actions/public/estimateGas.bench.ts +6 -6
- package/src/actions/public/getBlock.bench.ts +5 -5
- package/src/actions/public/getBlockNumber.bench.ts +5 -5
- package/src/actions/public/getGasPrice.bench.ts +1 -10
- package/src/actions/public/getTransaction.bench.ts +5 -5
- package/src/actions/public/getTransactionReceipt.bench.ts +5 -5
- package/src/actions/public/multicall.test.ts +452 -0
- package/src/actions/public/multicall.ts +103 -0
- package/src/actions/public/readContract.test.ts +226 -26
- package/src/actions/public/readContract.ts +13 -27
- package/src/actions/public/simulateContract.bench.ts +10 -0
- package/src/actions/public/simulateContract.test.ts +209 -37
- package/src/actions/public/simulateContract.ts +17 -21
- package/src/actions/public/watchContractEvent.test.ts +36 -32
- package/src/actions/public/watchEvent.test.ts +34 -29
- package/src/actions/wallet/signMessage.test.ts +0 -1
- package/src/actions/wallet/switchChain.test.ts +1 -2
- package/src/actions/wallet/watchAsset.test.ts +1 -2
- package/src/actions/wallet/writeContract.test.ts +37 -7
- package/src/actions/wallet/writeContract.ts +5 -14
- package/src/clients/transports/fallback.test.ts +34 -0
- package/src/clients/transports/fallback.ts +3 -1
- package/src/clients/transports/http.test.ts +0 -1
- package/src/clients/transports/webSocket.test.ts +0 -1
- package/src/constants/abis.test.ts +53 -0
- package/src/constants/abis.ts +44 -0
- package/src/constants/index.test.ts +14 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/solidity.test.ts +41 -0
- package/src/constants/solidity.ts +35 -0
- package/src/ens.ts +5 -0
- package/src/errors/abi.test.ts +0 -2
- package/src/errors/base.test.ts +44 -2
- package/src/errors/base.ts +12 -12
- package/src/errors/block.test.ts +6 -6
- package/src/errors/contract.test.ts +233 -0
- package/src/errors/contract.ts +133 -80
- package/src/errors/index.ts +4 -2
- package/src/errors/request.test.ts +3 -4
- package/src/errors/request.ts +17 -17
- package/src/errors/rpc.test.ts +1 -2
- package/src/errors/transaction.test.ts +12 -12
- package/src/errors/transport.test.ts +0 -1
- package/src/index.test.ts +46 -0
- package/src/index.ts +8 -0
- package/src/types/contract.ts +55 -4
- package/src/types/index.ts +5 -0
- package/src/types/multicall.ts +82 -0
- package/src/utils/abi/decodeAbi.test.ts +1 -2
- package/src/utils/abi/decodeAbi.ts +11 -7
- package/src/utils/abi/decodeDeployData.test.ts +7 -15
- package/src/utils/abi/decodeDeployData.ts +10 -7
- package/src/utils/abi/decodeErrorResult.test.ts +103 -3
- package/src/utils/abi/decodeErrorResult.ts +30 -13
- package/src/utils/abi/decodeFunctionData.test.ts +0 -1
- package/src/utils/abi/decodeFunctionResult.test.ts +80 -9
- package/src/utils/abi/decodeFunctionResult.ts +15 -11
- package/src/utils/abi/encodeAbi.test.ts +3 -4
- package/src/utils/abi/encodeAbi.ts +19 -10
- package/src/utils/abi/encodeDeployData.test.ts +6 -13
- package/src/utils/abi/encodeDeployData.ts +10 -7
- package/src/utils/abi/encodeErrorResult.test.ts +2 -7
- package/src/utils/abi/encodeErrorResult.ts +18 -11
- package/src/utils/abi/encodeEventTopics.test.ts +11 -14
- package/src/utils/abi/encodeEventTopics.ts +15 -9
- package/src/utils/abi/encodeFunctionData.test.ts +5 -7
- package/src/utils/abi/encodeFunctionData.ts +16 -9
- package/src/utils/abi/encodeFunctionResult.test.ts +10 -15
- package/src/utils/abi/encodeFunctionResult.ts +9 -7
- package/src/utils/abi/getAbiItem.test.ts +547 -0
- package/src/utils/abi/getAbiItem.ts +93 -3
- package/src/utils/abi/index.ts +5 -1
- package/src/utils/address/getAddress.test.ts +6 -6
- package/src/utils/contract/getContractError.test.ts +247 -62
- package/src/utils/contract/getContractError.ts +30 -38
- package/src/utils/data/pad.bench.ts +0 -9
- package/src/utils/data/trim.bench.ts +0 -16
- package/src/utils/encoding/encodeBytes.bench.ts +0 -12
- package/src/utils/encoding/encodeHex.bench.ts +0 -11
- package/src/utils/ens/index.test.ts +13 -0
- package/src/utils/ens/index.ts +5 -0
- package/src/utils/ens/labelhash.test.ts +55 -0
- package/src/utils/ens/labelhash.ts +16 -0
- package/src/utils/ens/namehash.test.ts +65 -0
- package/src/utils/ens/namehash.ts +28 -0
- package/src/utils/ens/normalize.bench.ts +14 -0
- package/src/utils/ens/normalize.test.ts +35 -0
- package/src/utils/ens/normalize.ts +14 -0
- package/src/utils/hash/keccak256.ts +3 -5
- package/src/utils/index.test.ts +3 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/rpc.test.ts +3 -6
- package/src/utils/unit/formatUnit.bench.ts +0 -5
- package/src/utils/unit/parseUnit.bench.ts +0 -5
- package/dist/chunk-46BO7YAQ.mjs.map +0 -1
- package/dist/chunk-62VTYU2V.mjs.map +0 -1
- package/dist/chunk-DGO77E2H.mjs.map +0 -1
- package/dist/chunk-KEHGSYDO.js.map +0 -1
- package/dist/chunk-KZMJR27B.js.map +0 -1
- package/dist/chunk-O2GYLJVD.js.map +0 -1
package/dist/{watchPendingTransactions-3b722547.d.ts → watchPendingTransactions-a8688b26.d.ts}
RENAMED
@@ -1,10 +1,10 @@
|
|
1
|
-
import { Abi } from 'abitype';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { P as PublicClient } from './createPublicClient-
|
5
|
-
import { W as WalletClient } from './createWalletClient-
|
6
|
-
import { S as SendTransactionArgs, a as SendTransactionResponse } from './sendTransaction-
|
7
|
-
import { T as TransactionRequestFormatter } from './transactionRequest-
|
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 =
|
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
|
-
} &
|
35
|
+
} & ContractConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>;
|
39
36
|
type WriteContractResponse = SendTransactionResponse;
|
40
|
-
declare function writeContract<TChain extends Chain, TAbi extends Abi
|
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
|
-
}
|
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
|
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
|
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-
|
2
|
-
import {
|
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-
|
2
|
-
import './chain-
|
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.
|
7
|
+
"abitype": "~0.3.0",
|
8
|
+
"idna-uts46-hx": "^4.1.2"
|
8
9
|
},
|
9
|
-
"version": "0.0.1-alpha.
|
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',
|
package/src/_test/bench.ts
CHANGED
@@ -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
|
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])
|
package/src/_test/index.ts
CHANGED
@@ -4,7 +4,7 @@ export {
|
|
4
4
|
usdcContractConfig,
|
5
5
|
} from './abis'
|
6
6
|
|
7
|
-
export {
|
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,
|
package/src/_test/utils.ts
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
/* c8 ignore start */
|
2
|
-
import {
|
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('
|
34
|
-
await
|
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('
|
42
|
-
await
|
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
|
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('
|
32
|
-
await
|
31
|
+
bench('ethers@6: `estimateGas`', async () => {
|
32
|
+
await ethersV6Provider.estimateGas({
|
33
33
|
from: accounts[0].address,
|
34
34
|
to: accounts[1].address,
|
35
|
-
value: '
|
35
|
+
value: parseEther('1'),
|
36
36
|
})
|
37
37
|
})
|
38
38
|
|
39
|
-
bench('
|
40
|
-
await
|
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('
|
22
|
-
await
|
21
|
+
bench('ethers@6: `getBlock`', async () => {
|
22
|
+
await ethersV6Provider.getBlock('latest')
|
23
23
|
})
|
24
24
|
|
25
|
-
bench('
|
26
|
-
await
|
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('
|
22
|
-
await
|
21
|
+
bench('ethers@6: `getBlockNumber`', async () => {
|
22
|
+
await ethersV6Provider.getBlockNumber()
|
23
23
|
})
|
24
24
|
|
25
|
-
bench('
|
26
|
-
await
|
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('
|
27
|
-
await
|
26
|
+
bench('ethers@6: `getTransaction`', async () => {
|
27
|
+
await ethersV6Provider.getTransaction(hash)
|
28
28
|
})
|
29
29
|
|
30
|
-
bench('
|
31
|
-
await
|
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('
|
27
|
-
await
|
26
|
+
bench('ethers@6: `getTransactionReceipt`', async () => {
|
27
|
+
await ethersV6Provider.getTransactionReceipt(hash)
|
28
28
|
})
|
29
29
|
|
30
|
-
bench('
|
31
|
-
await
|
30
|
+
bench('web3.js: `getTransactionReceipt`', async () => {
|
31
|
+
await web3Provider.eth.getTransactionReceipt(hash)
|
32
32
|
})
|
33
33
|
})
|