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.
- 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-EC3NUIJE.js → chunk-7Y5QVLX7.js} +13 -13
- package/dist/{chunk-EC3NUIJE.js.map → chunk-7Y5QVLX7.js.map} +1 -1
- package/dist/{chunk-KEHGSYDO.js → chunk-BV5NTHUX.js} +14 -13
- package/dist/chunk-BV5NTHUX.js.map +1 -0
- package/dist/{chunk-46BO7YAQ.mjs → chunk-EGVXCZNJ.mjs} +4 -3
- package/dist/chunk-EGVXCZNJ.mjs.map +1 -0
- package/dist/{chunk-57ZOFERP.mjs → chunk-GX2KDAM3.mjs} +2 -2
- package/dist/{chunk-57ZOFERP.mjs.map → chunk-GX2KDAM3.mjs.map} +0 -0
- package/dist/{chunk-W7BWWAC4.js → chunk-NW6724MI.js} +14 -14
- package/dist/{chunk-W7BWWAC4.js.map → chunk-NW6724MI.js.map} +0 -0
- package/dist/{chunk-DGO77E2H.mjs → chunk-RJLUZTJS.mjs} +86 -3
- package/dist/chunk-RJLUZTJS.mjs.map +1 -0
- package/dist/{chunk-O2GYLJVD.js → chunk-SSPRUPGN.js} +405 -165
- package/dist/chunk-SSPRUPGN.js.map +1 -0
- package/dist/{chunk-DSPMAIDO.mjs → chunk-TXHOG6KU.mjs} +2 -2
- package/dist/{chunk-DSPMAIDO.mjs.map → chunk-TXHOG6KU.mjs.map} +1 -1
- package/dist/{chunk-62VTYU2V.mjs → chunk-XBUH66KN.mjs} +406 -166
- package/dist/chunk-XBUH66KN.mjs.map +1 -0
- package/dist/{chunk-KZMJR27B.js → chunk-ZKYGWITF.js} +147 -64
- package/dist/chunk-ZKYGWITF.js.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-4c3a37b3.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 +174 -113
- package/dist/index.js +16 -6
- package/dist/index.mjs +15 -5
- package/dist/normalize-ef9240c0.d.ts +33 -0
- package/dist/{parseGwei-4308ad80.d.ts → parseGwei-3411cf2d.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-57df1a13.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/constants.ts +4 -3
- package/src/_test/index.ts +4 -2
- package/src/_test/utils.ts +39 -1
- package/src/actions/index.test.ts +1 -0
- package/src/actions/index.ts +2 -0
- 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/getFilterChanges.test.ts +9 -9
- package/src/actions/public/getFilterLogs.test.ts +7 -7
- package/src/actions/public/getGasPrice.bench.ts +1 -10
- package/src/actions/public/getLogs.test.ts +7 -7
- package/src/actions/public/getTransaction.bench.ts +5 -5
- package/src/actions/public/getTransactionReceipt.bench.ts +5 -5
- package/src/actions/public/index.test.ts +1 -0
- package/src/actions/public/index.ts +3 -0
- 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 +61 -57
- package/src/actions/public/watchEvent.test.ts +42 -37
- package/src/actions/test/impersonateAccount.test.ts +4 -6
- package/src/actions/test/sendUnsignedTransaction.test.ts +2 -2
- package/src/actions/test/stopImpersonatingAccount.test.ts +5 -7
- 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 +47 -0
- package/src/index.ts +10 -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-57df1a13.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, 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 =
|
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.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',
|
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/constants.ts
CHANGED
@@ -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'
|
package/src/_test/index.ts
CHANGED
@@ -4,19 +4,21 @@ 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,
|
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,
|
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 */
|
package/src/actions/index.ts
CHANGED
@@ -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('
|
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
|
})
|
@@ -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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
70
|
+
from: address.vitalik,
|
71
71
|
to: usdcContractConfig.address,
|
72
72
|
data: transfer1Data(accounts[1].address),
|
73
73
|
})
|