@nomicfoundation/hardhat-viem 2.0.6 → 3.0.0-next.1
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/CHANGELOG.md +7 -0
- package/LICENSE +4 -16
- package/README.md +35 -247
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/accounts.d.ts +4 -0
- package/dist/src/internal/accounts.d.ts.map +1 -0
- package/dist/src/internal/accounts.js +15 -0
- package/dist/src/internal/accounts.js.map +1 -0
- package/dist/src/internal/chains.d.ts +11 -0
- package/dist/src/internal/chains.d.ts.map +1 -0
- package/dist/src/internal/chains.js +116 -0
- package/dist/src/internal/chains.js.map +1 -0
- package/dist/src/internal/clients.d.ts +10 -0
- package/dist/src/internal/clients.d.ts.map +1 -0
- package/dist/src/internal/clients.js +91 -0
- package/dist/src/internal/clients.js.map +1 -0
- package/dist/src/internal/contracts.d.ts +11 -0
- package/dist/src/internal/contracts.d.ts.map +1 -0
- package/dist/src/internal/contracts.js +141 -0
- package/dist/src/internal/contracts.js.map +1 -0
- package/dist/src/internal/hook-handlers/network.d.ts +4 -0
- package/dist/src/internal/hook-handlers/network.d.ts.map +1 -0
- package/dist/src/internal/hook-handlers/network.js +12 -0
- package/dist/src/internal/hook-handlers/network.js.map +1 -0
- package/dist/src/internal/initialization.d.ts +6 -0
- package/dist/src/internal/initialization.d.ts.map +1 -0
- package/dist/src/internal/initialization.js +14 -0
- package/dist/src/internal/initialization.js.map +1 -0
- package/dist/src/type-extensions.d.ts +8 -0
- package/dist/src/type-extensions.d.ts.map +1 -0
- package/dist/src/type-extensions.js +2 -0
- package/dist/src/type-extensions.js.map +1 -0
- package/dist/src/types.d.ts +166 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +46 -51
- package/src/index.ts +10 -39
- package/src/internal/accounts.ts +20 -7
- package/src/internal/chains.ts +122 -62
- package/src/internal/clients.ts +135 -141
- package/src/internal/contracts.ts +126 -150
- package/src/internal/hook-handlers/network.ts +27 -0
- package/src/internal/initialization.ts +67 -0
- package/src/type-extensions.ts +10 -0
- package/src/types.ts +237 -72
- package/.eslintrc.js +0 -24
- package/index.d.ts +0 -3
- package/index.d.ts.map +0 -1
- package/index.js +0 -20
- package/index.js.map +0 -1
- package/internal/accounts.d.ts +0 -5
- package/internal/accounts.d.ts.map +0 -1
- package/internal/accounts.js +0 -9
- package/internal/accounts.js.map +0 -1
- package/internal/bytecode.d.ts +0 -13
- package/internal/bytecode.d.ts.map +0 -1
- package/internal/bytecode.js +0 -94
- package/internal/bytecode.js.map +0 -1
- package/internal/chains.d.ts +0 -7
- package/internal/chains.d.ts.map +0 -1
- package/internal/chains.js +0 -80
- package/internal/chains.js.map +0 -1
- package/internal/clients.d.ts +0 -45
- package/internal/clients.d.ts.map +0 -1
- package/internal/clients.js +0 -136
- package/internal/clients.js.map +0 -1
- package/internal/contracts.d.ts +0 -11
- package/internal/contracts.d.ts.map +0 -1
- package/internal/contracts.js +0 -164
- package/internal/contracts.js.map +0 -1
- package/internal/errors.d.ts +0 -36
- package/internal/errors.d.ts.map +0 -1
- package/internal/errors.js +0 -102
- package/internal/errors.js.map +0 -1
- package/internal/tasks.d.ts +0 -2
- package/internal/tasks.d.ts.map +0 -1
- package/internal/tasks.js +0 -240
- package/internal/tasks.js.map +0 -1
- package/internal/type-extensions.d.ts +0 -19
- package/internal/type-extensions.d.ts.map +0 -1
- package/internal/type-extensions.js +0 -5
- package/internal/type-extensions.js.map +0 -1
- package/src/internal/bytecode.ts +0 -138
- package/src/internal/errors.ts +0 -125
- package/src/internal/tasks.ts +0 -341
- package/src/internal/type-extensions.ts +0 -27
- package/src/tsconfig.json +0 -15
- package/types.d.ts +0 -52
- package/types.d.ts.map +0 -1
- package/types.js +0 -3
- package/types.js.map +0 -1
package/src/types.ts
CHANGED
@@ -1,19 +1,199 @@
|
|
1
|
-
import type
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import type { ArtifactMap } from "hardhat/types/artifacts";
|
2
|
+
import type { ChainType, DefaultChainType } from "hardhat/types/network";
|
3
|
+
import type {
|
4
|
+
Abi as ViemAbi,
|
5
|
+
Account as ViemAccount,
|
6
|
+
Address as ViemAddress,
|
7
|
+
Chain as ViemChain,
|
8
|
+
Client as ViemClient,
|
9
|
+
ContractConstructorArgs as ViemContractConstructorArgs,
|
10
|
+
createTestClient as ViemCreateTestClient,
|
11
|
+
GetContractReturnType as ViemGetContractReturnType,
|
12
|
+
GetTransactionReturnType as ViemGetTransactionReturnType,
|
13
|
+
PublicClient as ViemPublicClient,
|
14
|
+
PublicClientConfig as ViemPublicClientConfig,
|
15
|
+
RpcSchema as ViemRpcSchema,
|
16
|
+
TestClient as ViemTestClient,
|
17
|
+
TestClientConfig as ViemTestClientConfig,
|
18
|
+
Transport as ViemTransport,
|
19
|
+
WalletClient as ViemWalletClient,
|
20
|
+
WalletClientConfig as ViemWalletClientConfig,
|
21
|
+
PublicActions as ViemPublicActions,
|
22
|
+
WalletActions as ViemWalletActions,
|
23
|
+
} from "viem";
|
24
|
+
import type {
|
25
|
+
PublicActionsL2 as ViemOpStackPublicActionsL2,
|
26
|
+
WalletActionsL2 as ViemOpStackWalletActionsL2,
|
27
|
+
} from "viem/op-stack";
|
28
|
+
|
29
|
+
export interface HardhatViemHelpers<
|
30
|
+
ChainTypeT extends ChainType | string = DefaultChainType,
|
31
|
+
> {
|
32
|
+
/**
|
33
|
+
* Creates a public client configured with the provided settings.
|
34
|
+
*
|
35
|
+
* @param publicClientConfig A viem's PublicClientConfig object with the
|
36
|
+
* desired configuration.
|
37
|
+
* @returns The configured public client. If the connection's chainType is
|
38
|
+
* "optimism", the client will be extended with L2 actions.
|
39
|
+
*/
|
40
|
+
getPublicClient: (
|
41
|
+
publicClientConfig?: Partial<ViemPublicClientConfig>,
|
42
|
+
) => Promise<GetPublicClientReturnType<ChainTypeT>>;
|
43
|
+
/**
|
44
|
+
* Creates a wallet client configured with the provided settings for each
|
45
|
+
* account in the provider.
|
46
|
+
*
|
47
|
+
* @param walletClientConfig A viem's WalletClientConfig object with the
|
48
|
+
* desired configuration.
|
49
|
+
* @returns An array with the configured wallet clients. If the connection's
|
50
|
+
* chainType is "optimism", the clients will be extended with L2 actions.
|
51
|
+
*/
|
52
|
+
getWalletClients: (
|
53
|
+
walletClientConfig?: Partial<ViemWalletClientConfig>,
|
54
|
+
) => Promise<Array<GetWalletClientReturnType<ChainTypeT>>>;
|
55
|
+
/**
|
56
|
+
* Creates a wallet client configured with the provided settings for the
|
57
|
+
* specified address.
|
58
|
+
*
|
59
|
+
* @param address The address of the account to create the wallet client for.
|
60
|
+
* @param walletClientConfig A viem's WalletClientConfig object with the
|
61
|
+
* desired configuration.
|
62
|
+
* @returns The configured wallet client for the specified address. If the
|
63
|
+
* connection's chainType is "optimism", the client will be extended with L2
|
64
|
+
* actions.
|
65
|
+
*/
|
66
|
+
getWalletClient: (
|
67
|
+
address: ViemAddress,
|
68
|
+
walletClientConfig?: Partial<ViemWalletClientConfig>,
|
69
|
+
) => Promise<GetWalletClientReturnType<ChainTypeT>>;
|
70
|
+
/**
|
71
|
+
* Creates a test client configured with the provided settings.
|
72
|
+
*
|
73
|
+
* @param testClientConfig A viem's TestClientConfig object with the desired
|
74
|
+
* configuration.
|
75
|
+
* @returns The configured test client.
|
76
|
+
*/
|
77
|
+
getTestClient: (
|
78
|
+
testClientConfig?: Partial<ViemTestClientConfig>,
|
79
|
+
) => Promise<TestClient>;
|
80
|
+
/**
|
81
|
+
* Deploys a contract with the provided name and constructor arguments and
|
82
|
+
* returns the viem's contract instance.
|
83
|
+
*
|
84
|
+
* @param contractName The name of the contract to deploy. This is required
|
85
|
+
* to return the correct contract type.
|
86
|
+
* @param constructorArgs The arguments to pass to the contract's constructor.
|
87
|
+
* @param deployContractConfig A configuration object. See
|
88
|
+
* {@link DeployContractConfig} for more details.
|
89
|
+
* @returns The deployed contract instance.
|
90
|
+
*/
|
91
|
+
deployContract: <ContractName extends string>(
|
92
|
+
contractName: ContractName,
|
93
|
+
constructorArgs?: ConstructorArgs<ContractName>,
|
94
|
+
deployContractConfig?: DeployContractConfig,
|
95
|
+
) => Promise<ContractReturnType<ContractName>>;
|
96
|
+
/**
|
97
|
+
* Sends a deployment transaction for the specified contract and returns the
|
98
|
+
* contract instance along with the deployment transaction.
|
99
|
+
* The function does not wait for the transaction to be mined.
|
100
|
+
*
|
101
|
+
* @param contractName The name of the contract to deploy. This is required
|
102
|
+
* to return the correct contract type.
|
103
|
+
* @param constructorArgs The arguments to pass to the contract's constructor.
|
104
|
+
* @param sendDeploymentTransactionConfig A configuration object. See
|
105
|
+
* {@link SendDeploymentTransactionConfig} for more details.
|
106
|
+
* @returns An object containing the deployed contract instance and the
|
107
|
+
* deployment transaction.
|
108
|
+
*/
|
109
|
+
sendDeploymentTransaction: <ContractName extends string>(
|
110
|
+
contractName: ContractName,
|
111
|
+
constructorArgs?: ConstructorArgs<ContractName>,
|
112
|
+
sendDeploymentTransactionConfig?: SendDeploymentTransactionConfig,
|
113
|
+
) => Promise<{
|
114
|
+
contract: ContractReturnType<ContractName>;
|
115
|
+
deploymentTransaction: GetTransactionReturnType;
|
116
|
+
}>;
|
117
|
+
/**
|
118
|
+
* Returns a contract instance for the specified contract at the provided
|
119
|
+
* address.
|
120
|
+
*
|
121
|
+
* @param contractName The name of the contract to get an instance of. This
|
122
|
+
* is required to return the correct contract type.
|
123
|
+
* @param address The address of the contract.
|
124
|
+
* @param getContractAtConfig A configuration object. See
|
125
|
+
* {@link GetContractAtConfig} for more details.
|
126
|
+
* @returns The contract instance.
|
127
|
+
*/
|
128
|
+
getContractAt: <ContractName extends string>(
|
129
|
+
contractName: ContractName,
|
130
|
+
address: ViemAddress,
|
131
|
+
getContractAtConfig?: GetContractAtConfig,
|
132
|
+
) => Promise<ContractReturnType<ContractName>>;
|
133
|
+
}
|
134
|
+
|
135
|
+
export type GetPublicClientReturnType<ChainTypeT extends ChainType | string> =
|
136
|
+
ChainTypeT extends "optimism" ? OpPublicClient : PublicClient;
|
137
|
+
|
138
|
+
export type GetWalletClientReturnType<ChainTypeT extends ChainType | string> =
|
139
|
+
ChainTypeT extends "optimism" ? OpWalletClient : WalletClient;
|
140
|
+
|
141
|
+
export type PublicClient = ViemPublicClient<ViemTransport, ViemChain>;
|
142
|
+
|
143
|
+
export type OpPublicClient = ViemClient<
|
144
|
+
ViemTransport,
|
145
|
+
ViemChain,
|
146
|
+
undefined,
|
147
|
+
ViemRpcSchema,
|
148
|
+
ViemPublicActions<ViemTransport, ViemChain, ViemAccount> &
|
149
|
+
ViemOpStackPublicActionsL2<ViemChain, ViemAccount>
|
150
|
+
>;
|
151
|
+
|
152
|
+
export type WalletClient = ViemWalletClient<
|
153
|
+
ViemTransport,
|
154
|
+
ViemChain,
|
155
|
+
ViemAccount
|
10
156
|
>;
|
11
|
-
|
157
|
+
|
158
|
+
export type OpWalletClient = ViemClient<
|
159
|
+
ViemTransport,
|
160
|
+
ViemChain,
|
161
|
+
ViemAccount,
|
162
|
+
ViemRpcSchema,
|
163
|
+
ViemWalletActions<ViemChain, ViemAccount> &
|
164
|
+
ViemOpStackWalletActionsL2<ViemChain, ViemAccount>
|
165
|
+
>;
|
166
|
+
|
167
|
+
export type TestClient = ViemTestClient<
|
12
168
|
TestClientMode,
|
13
|
-
|
14
|
-
|
169
|
+
ViemTransport,
|
170
|
+
ViemChain
|
15
171
|
>;
|
16
172
|
|
173
|
+
export type TestClientMode = Parameters<typeof ViemCreateTestClient>[0]["mode"];
|
174
|
+
|
175
|
+
/**
|
176
|
+
* Configuration options for sending a transaction.
|
177
|
+
*
|
178
|
+
* - `client`: A KeyedClient object with the public and wallet clients to use.
|
179
|
+
* If some of them are not provided, the default clients will be used. The
|
180
|
+
* default wallet client is the first one returned by `getWalletClients`.
|
181
|
+
* - `gas`: The gas limit for the deployment transaction.
|
182
|
+
* - `gasPrice`: The gas price for the deployment transaction.
|
183
|
+
* - `maxFeePerGas`: The maximum fee per gas for the deployment transaction.
|
184
|
+
* - `maxPriorityFeePerGas`: The maximum priority fee per gas for the deployment
|
185
|
+
* transaction.
|
186
|
+
* - `value`: The value to send with the deployment transaction.
|
187
|
+
*/
|
188
|
+
export interface SendTransactionConfig {
|
189
|
+
client?: KeyedClient;
|
190
|
+
gas?: bigint;
|
191
|
+
gasPrice?: bigint;
|
192
|
+
maxFeePerGas?: bigint;
|
193
|
+
maxPriorityFeePerGas?: bigint;
|
194
|
+
value?: bigint;
|
195
|
+
}
|
196
|
+
|
17
197
|
export type KeyedClient =
|
18
198
|
| {
|
19
199
|
public?: PublicClient;
|
@@ -24,82 +204,67 @@ export type KeyedClient =
|
|
24
204
|
wallet?: WalletClient;
|
25
205
|
};
|
26
206
|
|
27
|
-
export
|
28
|
-
|
29
|
-
>[0]["mode"];
|
30
|
-
|
31
|
-
export interface SendTransactionConfig {
|
32
|
-
client?: KeyedClient;
|
33
|
-
gas?: bigint;
|
34
|
-
gasPrice?: bigint;
|
35
|
-
maxFeePerGas?: bigint;
|
36
|
-
maxPriorityFeePerGas?: bigint;
|
37
|
-
value?: bigint;
|
207
|
+
export interface Libraries {
|
208
|
+
[libraryName: string]: ViemAddress;
|
38
209
|
}
|
39
210
|
|
211
|
+
/**
|
212
|
+
* Configuration options for deploying a contract.
|
213
|
+
*
|
214
|
+
* - `confirmations`: The number of confirmations to wait for the deployment
|
215
|
+
* transaction. Default is 1.
|
216
|
+
*
|
217
|
+
* - `libraries`: An object with the contract's library names as keys and their
|
218
|
+
* addresses as values. This is required if the contract uses libraries,
|
219
|
+
* to enable linking.
|
220
|
+
*
|
221
|
+
* This interface extends {@link SendTransactionConfig}, which includes
|
222
|
+
* additional properties such as `client`, `gas`, `gasPrice`, `maxFeePerGas`,
|
223
|
+
* `maxPriorityFeePerGas` and `value`.
|
224
|
+
*/
|
40
225
|
export interface DeployContractConfig extends SendTransactionConfig {
|
41
226
|
confirmations?: number;
|
42
|
-
libraries?: Libraries
|
227
|
+
libraries?: Libraries;
|
43
228
|
}
|
44
229
|
|
45
230
|
export interface SendDeploymentTransactionConfig extends SendTransactionConfig {
|
46
|
-
libraries?: Libraries
|
231
|
+
libraries?: Libraries;
|
47
232
|
}
|
48
233
|
|
234
|
+
/**
|
235
|
+
* Configuration options for getting a contract instance.
|
236
|
+
*
|
237
|
+
* - `client`: A KeyedClient object with the public and wallet clients to use.
|
238
|
+
* If some of them are not provided, the default clients will be used. The
|
239
|
+
* default wallet client is the first one returned by `getWalletClients`. It is
|
240
|
+
* mandatory to provide a wallet client if there are no accounts in the
|
241
|
+
* provider.
|
242
|
+
*/
|
49
243
|
export interface GetContractAtConfig {
|
50
244
|
client?: KeyedClient;
|
51
245
|
}
|
52
246
|
|
53
247
|
export type GetContractReturnType<
|
54
|
-
TAbi extends
|
55
|
-
> =
|
248
|
+
TAbi extends ViemAbi | readonly unknown[] = ViemAbi,
|
249
|
+
> = ViemGetContractReturnType<TAbi, Required<KeyedClient>, ViemAddress>;
|
56
250
|
|
57
|
-
export type GetTransactionReturnType =
|
58
|
-
|
251
|
+
export type GetTransactionReturnType = ViemGetTransactionReturnType<
|
252
|
+
ViemChain,
|
59
253
|
"latest"
|
60
254
|
>;
|
61
255
|
|
62
|
-
export type
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
contractName: ContractName<CN>,
|
73
|
-
constructorArgs?: any[],
|
74
|
-
config?: SendDeploymentTransactionConfig
|
75
|
-
): Promise<{
|
76
|
-
contract: GetContractReturnType;
|
77
|
-
deploymentTransaction: GetTransactionReturnType;
|
78
|
-
}>;
|
79
|
-
|
80
|
-
export declare function getContractAt<CN extends string>(
|
81
|
-
contractName: ContractName<CN>,
|
82
|
-
address: viemT.Address,
|
83
|
-
config?: GetContractAtConfig
|
84
|
-
): Promise<GetContractReturnType>;
|
85
|
-
|
86
|
-
export interface HardhatViemHelpers {
|
87
|
-
getPublicClient(
|
88
|
-
publicClientConfig?: Partial<viemT.PublicClientConfig>
|
89
|
-
): Promise<PublicClient>;
|
90
|
-
getWalletClients(
|
91
|
-
walletClientConfig?: Partial<viemT.WalletClientConfig>
|
92
|
-
): Promise<WalletClient[]>;
|
93
|
-
getWalletClient(
|
94
|
-
address: viemT.Address,
|
95
|
-
walletClientConfig?: Partial<viemT.WalletClientConfig>
|
96
|
-
): Promise<WalletClient>;
|
97
|
-
getTestClient(
|
98
|
-
testClientConfig?: Partial<viemT.TestClientConfig>
|
99
|
-
): Promise<TestClient>;
|
100
|
-
deployContract: typeof deployContract;
|
101
|
-
sendDeploymentTransaction: typeof sendDeploymentTransaction;
|
102
|
-
getContractAt: typeof getContractAt;
|
103
|
-
}
|
256
|
+
export type ContractAbis = {
|
257
|
+
[ContractName in keyof ArtifactMap]: ArtifactMap[ContractName] extends never
|
258
|
+
? never
|
259
|
+
: ArtifactMap[ContractName]["abi"];
|
260
|
+
};
|
261
|
+
|
262
|
+
export type ConstructorArgs<ContractName> =
|
263
|
+
ContractName extends keyof ContractAbis
|
264
|
+
? ViemContractConstructorArgs<ContractAbis[ContractName]>
|
265
|
+
: unknown[];
|
104
266
|
|
105
|
-
export type
|
267
|
+
export type ContractReturnType<ContractName> =
|
268
|
+
ContractName extends keyof ContractAbis
|
269
|
+
? GetContractReturnType<ContractAbis[ContractName]>
|
270
|
+
: GetContractReturnType;
|
package/.eslintrc.js
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
const {
|
2
|
-
slowImportsCommonIgnoredModules,
|
3
|
-
} = require("../../config/eslint/constants");
|
4
|
-
|
5
|
-
module.exports = {
|
6
|
-
extends: [`${__dirname}/../../config/eslint/eslintrc.js`],
|
7
|
-
parserOptions: {
|
8
|
-
project: `${__dirname}/src/tsconfig.json`,
|
9
|
-
sourceType: "module",
|
10
|
-
},
|
11
|
-
overrides: [
|
12
|
-
{
|
13
|
-
files: ["src/index.ts"],
|
14
|
-
rules: {
|
15
|
-
"@nomicfoundation/slow-imports/no-top-level-external-import": [
|
16
|
-
"error",
|
17
|
-
{
|
18
|
-
ignoreModules: [...slowImportsCommonIgnoredModules],
|
19
|
-
},
|
20
|
-
],
|
21
|
-
},
|
22
|
-
},
|
23
|
-
],
|
24
|
-
};
|
package/index.d.ts
DELETED
package/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAaA,OAAO,4BAA4B,CAAC;AACpC,OAAO,kBAAkB,CAAC"}
|
package/index.js
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const config_1 = require("hardhat/config");
|
4
|
-
const clients_1 = require("./internal/clients");
|
5
|
-
const contracts_1 = require("./internal/contracts");
|
6
|
-
require("./internal/type-extensions");
|
7
|
-
require("./internal/tasks");
|
8
|
-
(0, config_1.extendEnvironment)((hre) => {
|
9
|
-
const { provider } = hre.network;
|
10
|
-
hre.viem = {
|
11
|
-
getPublicClient: (publicClientConfig) => (0, clients_1.getPublicClient)(provider, publicClientConfig),
|
12
|
-
getWalletClients: (walletClientConfig) => (0, clients_1.getWalletClients)(provider, walletClientConfig),
|
13
|
-
getWalletClient: (address, walletClientConfig) => (0, clients_1.getWalletClient)(provider, address, walletClientConfig),
|
14
|
-
getTestClient: (testClientConfig) => (0, clients_1.getTestClient)(provider, testClientConfig),
|
15
|
-
deployContract: (contractName, constructorArgs, config) => (0, contracts_1.deployContract)(hre, contractName, constructorArgs, config),
|
16
|
-
sendDeploymentTransaction: (contractName, constructorArgs, config) => (0, contracts_1.sendDeploymentTransaction)(hre, contractName, constructorArgs, config),
|
17
|
-
getContractAt: (contractName, address, config) => (0, contracts_1.getContractAt)(hre, contractName, address, config),
|
18
|
-
};
|
19
|
-
});
|
20
|
-
//# sourceMappingURL=index.js.map
|
package/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;AAAA,2CAAmD;AAEnD,gDAK4B;AAC5B,oDAI8B;AAC9B,sCAAoC;AACpC,4BAA0B;AAE1B,IAAA,0BAAiB,EAAC,CAAC,GAAG,EAAE,EAAE;IACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;IAEjC,GAAG,CAAC,IAAI,GAAG;QACT,eAAe,EAAE,CAAC,kBAAkB,EAAE,EAAE,CACtC,IAAA,yBAAe,EAAC,QAAQ,EAAE,kBAAkB,CAAC;QAE/C,gBAAgB,EAAE,CAAC,kBAAkB,EAAE,EAAE,CACvC,IAAA,0BAAgB,EAAC,QAAQ,EAAE,kBAAkB,CAAC;QAEhD,eAAe,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAC/C,IAAA,yBAAe,EAAC,QAAQ,EAAE,OAAO,EAAE,kBAAkB,CAAC;QAExD,aAAa,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAClC,IAAA,uBAAa,EAAC,QAAQ,EAAE,gBAAgB,CAAC;QAE3C,cAAc,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,CACxD,IAAA,0BAAc,EAAC,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;QAE5D,yBAAyB,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,CACnE,IAAA,qCAAyB,EAAC,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;QAEvE,aAAa,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAC/C,IAAA,yBAAa,EAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;KACpD,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/internal/accounts.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
/// <reference types="lodash" />
|
2
|
-
import type { EthereumProvider } from "hardhat/types";
|
3
|
-
import type { Address } from "viem";
|
4
|
-
export declare const getAccounts: ((provider: EthereumProvider) => Promise<Address[]>) & import("lodash").MemoizedFunction;
|
5
|
-
//# sourceMappingURL=accounts.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../src/internal/accounts.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC,eAAO,MAAM,WAAW,cACL,gBAAgB,KAAG,QAAQ,OAAO,EAAE,CAAC,qCAEvD,CAAC"}
|
package/internal/accounts.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.getAccounts = void 0;
|
7
|
-
const lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
8
|
-
exports.getAccounts = (0, lodash_memoize_1.default)(async (provider) => provider.send("eth_accounts"));
|
9
|
-
//# sourceMappingURL=accounts.js.map
|
package/internal/accounts.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../src/internal/accounts.ts"],"names":[],"mappings":";;;;;;AAGA,oEAAqC;AAExB,QAAA,WAAW,GAAG,IAAA,wBAAO,EAChC,KAAK,EAAE,QAA0B,EAAsB,EAAE,CACvD,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAChC,CAAC"}
|
package/internal/bytecode.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import type * as viemT from "viem";
|
2
|
-
import type { Artifact } from "hardhat/types/artifacts";
|
3
|
-
export interface Libraries<Address = string> {
|
4
|
-
[libraryName: string]: Address;
|
5
|
-
}
|
6
|
-
export interface Link {
|
7
|
-
sourceName: string;
|
8
|
-
libraryName: string;
|
9
|
-
address: string;
|
10
|
-
}
|
11
|
-
export declare function linkBytecode(artifact: Artifact, libraries: Link[]): Promise<viemT.Hex>;
|
12
|
-
export declare function resolveBytecodeWithLinkedLibraries(artifact: Artifact, libraries: Libraries<viemT.Address>): Promise<viemT.Hex>;
|
13
|
-
//# sourceMappingURL=bytecode.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"bytecode.d.ts","sourceRoot":"","sources":["../src/internal/bytecode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AASxD,MAAM,WAAW,SAAS,CAAC,OAAO,GAAG,MAAM;IACzC,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,IAAI,EAAE,GAChB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAgBpB;AA+DD,wBAAsB,kCAAkC,CACtD,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAClC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAgCpB"}
|
package/internal/bytecode.js
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.resolveBytecodeWithLinkedLibraries = exports.linkBytecode = void 0;
|
27
|
-
const errors_1 = require("./errors");
|
28
|
-
async function linkBytecode(artifact, libraries) {
|
29
|
-
const { isHex } = await Promise.resolve().then(() => __importStar(require("viem")));
|
30
|
-
let bytecode = artifact.bytecode;
|
31
|
-
// TODO: measure performance impact
|
32
|
-
for (const { sourceName, libraryName, address } of libraries) {
|
33
|
-
const linkReferences = artifact.linkReferences[sourceName][libraryName];
|
34
|
-
for (const { start, length } of linkReferences) {
|
35
|
-
bytecode =
|
36
|
-
bytecode.substring(0, 2 + start * 2) +
|
37
|
-
address.substring(2) +
|
38
|
-
bytecode.substring(2 + (start + length) * 2);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return isHex(bytecode) ? bytecode : `0x${bytecode}`;
|
42
|
-
}
|
43
|
-
exports.linkBytecode = linkBytecode;
|
44
|
-
async function throwOnAmbigousLibraryNameOrUnnecessaryLink(contractName, libraries, neededLibraries) {
|
45
|
-
for (const linkedLibraryName of Object.keys(libraries)) {
|
46
|
-
const matchingLibraries = neededLibraries.filter(({ sourceName, libraryName }) => libraryName === linkedLibraryName ||
|
47
|
-
`${sourceName}:${libraryName}` === linkedLibraryName);
|
48
|
-
if (matchingLibraries.length > 1) {
|
49
|
-
throw new errors_1.AmbigousLibraryNameError(contractName, linkedLibraryName, matchingLibraries.map(({ sourceName, libraryName }) => `${sourceName}:${libraryName}`));
|
50
|
-
}
|
51
|
-
else if (matchingLibraries.length === 0) {
|
52
|
-
throw new errors_1.UnnecessaryLibraryLinkError(contractName, linkedLibraryName);
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
async function throwOnMissingLibrariesAddress(contractName, libraries, neededLibraries) {
|
57
|
-
const missingLibraries = [];
|
58
|
-
for (const { sourceName, libraryName } of neededLibraries) {
|
59
|
-
const address = libraries[`${sourceName}:${libraryName}`] ?? libraries[libraryName];
|
60
|
-
if (address === undefined) {
|
61
|
-
missingLibraries.push({ sourceName, libraryName });
|
62
|
-
}
|
63
|
-
}
|
64
|
-
if (missingLibraries.length > 0) {
|
65
|
-
throw new errors_1.MissingLibraryAddressError(contractName, missingLibraries);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
async function throwOnOverlappingLibraryNames(contractName, libraries, neededLibraries) {
|
69
|
-
for (const { sourceName, libraryName } of neededLibraries) {
|
70
|
-
if (libraries[`${sourceName}:${libraryName}`] !== undefined &&
|
71
|
-
libraries[libraryName] !== undefined) {
|
72
|
-
throw new errors_1.OverlappingLibraryNamesError(sourceName, libraryName);
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
76
|
-
async function resolveBytecodeWithLinkedLibraries(artifact, libraries) {
|
77
|
-
const { linkReferences } = artifact;
|
78
|
-
const neededLibraries = [];
|
79
|
-
for (const [sourceName, sourceLibraries] of Object.entries(linkReferences)) {
|
80
|
-
for (const libraryName of Object.keys(sourceLibraries)) {
|
81
|
-
neededLibraries.push({
|
82
|
-
sourceName,
|
83
|
-
libraryName,
|
84
|
-
address: libraries[`${sourceName}:${libraryName}`] ?? libraries[libraryName],
|
85
|
-
});
|
86
|
-
}
|
87
|
-
}
|
88
|
-
await throwOnAmbigousLibraryNameOrUnnecessaryLink(artifact.contractName, libraries, neededLibraries);
|
89
|
-
await throwOnOverlappingLibraryNames(artifact.contractName, libraries, neededLibraries);
|
90
|
-
await throwOnMissingLibrariesAddress(artifact.contractName, libraries, neededLibraries);
|
91
|
-
return linkBytecode(artifact, neededLibraries);
|
92
|
-
}
|
93
|
-
exports.resolveBytecodeWithLinkedLibraries = resolveBytecodeWithLinkedLibraries;
|
94
|
-
//# sourceMappingURL=bytecode.js.map
|
package/internal/bytecode.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"bytecode.js","sourceRoot":"","sources":["../src/internal/bytecode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,qCAKkB;AAYX,KAAK,UAAU,YAAY,CAChC,QAAkB,EAClB,SAAiB;IAEjB,MAAM,EAAE,KAAK,EAAE,GAAG,wDAAa,MAAM,GAAC,CAAC;IACvC,IAAI,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAEjC,mCAAmC;IACnC,KAAK,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,SAAS,EAAE;QAC5D,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;QACxE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,cAAc,EAAE;YAC9C,QAAQ;gBACN,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAA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CAClC,QAAQ,CAAC,YAAY,EACrB,SAAS,EACT,eAAe,CAChB,CAAC;IACF,MAAM,8BAA8B,CAClC,QAAQ,CAAC,YAAY,EACrB,SAAS,EACT,eAAe,CAChB,CAAC;IAEF,OAAO,YAAY,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AACjD,CAAC;AAnCD,gFAmCC"}
|
package/internal/chains.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { EthereumProvider } from "hardhat/types";
|
2
|
-
import type { Chain } from "viem";
|
3
|
-
import type { TestClientMode } from "../types";
|
4
|
-
export declare function getChain(provider: EthereumProvider): Promise<Chain>;
|
5
|
-
export declare function isDevelopmentNetwork(chainId: number): boolean;
|
6
|
-
export declare function getMode(provider: EthereumProvider): Promise<TestClientMode>;
|
7
|
-
//# sourceMappingURL=chains.d.ts.map
|
package/internal/chains.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/internal/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU/C,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,CAuCzE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,WAEnD;AAED,wBAAsB,OAAO,CAC3B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,cAAc,CAAC,CAQzB"}
|
package/internal/chains.js
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.getMode = exports.isDevelopmentNetwork = exports.getChain = void 0;
|
7
|
-
const lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
8
|
-
const errors_1 = require("./errors");
|
9
|
-
async function getChain(provider) {
|
10
|
-
const chains = require("viem/chains");
|
11
|
-
const chainId = await getChainId(provider);
|
12
|
-
if (isDevelopmentNetwork(chainId)) {
|
13
|
-
if (await isHardhatNetwork(provider)) {
|
14
|
-
return chains.hardhat;
|
15
|
-
}
|
16
|
-
else if (await isFoundryNetwork(provider)) {
|
17
|
-
return chains.foundry;
|
18
|
-
}
|
19
|
-
else {
|
20
|
-
throw new errors_1.UnknownDevelopmentNetworkError();
|
21
|
-
}
|
22
|
-
}
|
23
|
-
const matchingChains = Object.values(chains).filter(({ id }) => id === chainId);
|
24
|
-
if (matchingChains.length === 0) {
|
25
|
-
if (await isHardhatNetwork(provider)) {
|
26
|
-
return {
|
27
|
-
...chains.hardhat,
|
28
|
-
id: chainId,
|
29
|
-
};
|
30
|
-
}
|
31
|
-
else if (await isFoundryNetwork(provider)) {
|
32
|
-
return {
|
33
|
-
...chains.foundry,
|
34
|
-
id: chainId,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
else {
|
38
|
-
throw new errors_1.NetworkNotFoundError(chainId);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
if (matchingChains.length > 1) {
|
42
|
-
throw new errors_1.MultipleMatchingNetworksError(chainId);
|
43
|
-
}
|
44
|
-
return matchingChains[0];
|
45
|
-
}
|
46
|
-
exports.getChain = getChain;
|
47
|
-
function isDevelopmentNetwork(chainId) {
|
48
|
-
return chainId === 31337;
|
49
|
-
}
|
50
|
-
exports.isDevelopmentNetwork = isDevelopmentNetwork;
|
51
|
-
async function getMode(provider) {
|
52
|
-
if (await isHardhatNetwork(provider)) {
|
53
|
-
return "hardhat";
|
54
|
-
}
|
55
|
-
else if (await isFoundryNetwork(provider)) {
|
56
|
-
return "anvil";
|
57
|
-
}
|
58
|
-
else {
|
59
|
-
throw new errors_1.UnknownDevelopmentNetworkError();
|
60
|
-
}
|
61
|
-
}
|
62
|
-
exports.getMode = getMode;
|
63
|
-
const getChainId = (0, lodash_memoize_1.default)(async (provider) => Number(await provider.send("eth_chainId")));
|
64
|
-
const isHardhatNetwork = (0, lodash_memoize_1.default)(async (provider) => detectNetworkByMethodName(provider, NetworkMethod.HARDHAT_METADATA));
|
65
|
-
const isFoundryNetwork = (0, lodash_memoize_1.default)(async (provider) => detectNetworkByMethodName(provider, NetworkMethod.ANVIL_NODE_INFO));
|
66
|
-
var NetworkMethod;
|
67
|
-
(function (NetworkMethod) {
|
68
|
-
NetworkMethod["HARDHAT_METADATA"] = "hardhat_metadata";
|
69
|
-
NetworkMethod["ANVIL_NODE_INFO"] = "anvil_nodeInfo";
|
70
|
-
})(NetworkMethod || (NetworkMethod = {}));
|
71
|
-
async function detectNetworkByMethodName(provider, methodName) {
|
72
|
-
try {
|
73
|
-
await provider.send(methodName);
|
74
|
-
return true;
|
75
|
-
}
|
76
|
-
catch {
|
77
|
-
return false;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
//# sourceMappingURL=chains.js.map
|
package/internal/chains.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../src/internal/chains.ts"],"names":[],"mappings":";;;;;;AAIA,oEAAqC;AAErC,qCAIkB;AAEX,KAAK,UAAU,QAAQ,CAAC,QAA0B;IACvD,MAAM,MAAM,GAA0B,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE3C,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE;QACjC,IAAI,MAAM,gBAAgB,CAAC,QAAQ,CAAC,EAAE;YACpC,OAAO,MAAM,CAAC,OAAO,CAAC;SACvB;aAAM,IAAI,MAAM,gBAAgB,CAAC,QAAQ,CAAC,EAAE;YAC3C,OAAO,MAAM,CAAC,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