@nomicfoundation/hardhat-viem 3.0.2 → 3.0.4
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 +13 -0
- package/dist/src/internal/chains.d.ts +22 -1
- package/dist/src/internal/chains.d.ts.map +1 -1
- package/dist/src/internal/chains.js +50 -6
- package/dist/src/internal/chains.js.map +1 -1
- package/dist/src/internal/clients.d.ts +6 -5
- package/dist/src/internal/clients.d.ts.map +1 -1
- package/dist/src/internal/clients.js +16 -11
- package/dist/src/internal/clients.js.map +1 -1
- package/dist/src/internal/contracts.d.ts +5 -4
- package/dist/src/internal/contracts.d.ts.map +1 -1
- package/dist/src/internal/contracts.js +16 -11
- package/dist/src/internal/contracts.js.map +1 -1
- package/dist/src/internal/hook-handlers/network.d.ts.map +1 -1
- package/dist/src/internal/hook-handlers/network.js +1 -1
- package/dist/src/internal/hook-handlers/network.js.map +1 -1
- package/dist/src/internal/initialization.d.ts +2 -1
- package/dist/src/internal/initialization.d.ts.map +1 -1
- package/dist/src/internal/initialization.js +8 -8
- package/dist/src/internal/initialization.js.map +1 -1
- package/dist/src/types.d.ts +16 -7
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/internal/chains.ts +69 -8
- package/src/internal/clients.ts +23 -5
- package/src/internal/contracts.ts +36 -13
- package/src/internal/hook-handlers/network.ts +2 -0
- package/src/internal/initialization.ts +38 -4
- package/src/types.ts +25 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @nomicfoundation/hardhat-viem
|
|
2
2
|
|
|
3
|
+
## 3.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bc193be: Use concrete value types for contract names in hardhat-viem and hardhat-ethers
|
|
8
|
+
- 13918b4: Add support for custom chains not in viem's built-in chain list, thanks @daanporon! ([#7763](https://github.com/NomicFoundation/hardhat/issues/7763))
|
|
9
|
+
|
|
10
|
+
## 3.0.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 6674b00: Bump `hardhat-utils` major
|
|
15
|
+
|
|
3
16
|
## 3.0.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import type { TestClientMode } from "../types.js";
|
|
2
|
+
import type { ChainDescriptorConfig, ChainDescriptorsConfig } from "hardhat/types/config";
|
|
2
3
|
import type { ChainType } from "hardhat/types/network";
|
|
3
4
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
4
5
|
import type { Chain as ViemChain } from "viem";
|
|
5
|
-
export declare function getChain<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT): Promise<ViemChain>;
|
|
6
|
+
export declare function getChain<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, chainDescriptors: ChainDescriptorsConfig, networkName: string): Promise<ViemChain>;
|
|
6
7
|
export declare function getChainId(provider: EthereumProvider): Promise<number>;
|
|
7
8
|
export declare function isDevelopmentNetwork(provider: EthereumProvider): Promise<boolean>;
|
|
8
9
|
export declare function isHardhatNetwork(provider: EthereumProvider): Promise<boolean>;
|
|
9
10
|
export declare function isAnvilNetwork(provider: EthereumProvider): Promise<boolean>;
|
|
10
11
|
export declare function getMode(provider: EthereumProvider): Promise<TestClientMode>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves a viem chain for a given chain id using the provided chain
|
|
14
|
+
* descriptors. If a matching descriptor is found, the chain is enriched with
|
|
15
|
+
* the descriptor's name and block explorer. Otherwise, falls back to a minimal
|
|
16
|
+
* chain using the network name.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveChain(chainId: number, networkName: string, chainDescriptors: ChainDescriptorsConfig): ViemChain;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a viem chain with the minimum fields required to satisfy the
|
|
21
|
+
* {@link ViemChain} type.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createMinimalChain(id: number, name: string): ViemChain;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the default block explorer for a chain descriptor, preferring
|
|
26
|
+
* Etherscan over Blockscout. Returns `undefined` if neither is configured.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDefaultBlockExplorer(chainDescriptor: ChainDescriptorConfig): {
|
|
29
|
+
name: string;
|
|
30
|
+
url: string;
|
|
31
|
+
} | undefined;
|
|
11
32
|
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/internal/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAuB/C,wBAAsB,QAAQ,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,EAClE,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../src/internal/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAuB/C,wBAAsB,QAAQ,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,EAClE,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,sBAAsB,EACxC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,CAAC,CAkCpB;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAU5E;AAED,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,OAAO,CAAC,CAsBlB;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED,wBAAsB,OAAO,CAC3B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,cAAc,CAAC,CAUzB;AAmED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,sBAAsB,GACvC,SAAS,CAeX;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAStE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,qBAAqB,GACrC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAY3C"}
|
|
@@ -12,7 +12,7 @@ const hardhatMetadataCache = new WeakMap();
|
|
|
12
12
|
const isAnvilNetworkCache = new WeakMap();
|
|
13
13
|
const HARDHAT_METADATA_METHOD = "hardhat_metadata";
|
|
14
14
|
const ANVIL_NODE_INFO_METHOD = "anvil_nodeInfo";
|
|
15
|
-
export async function getChain(provider, chainType) {
|
|
15
|
+
export async function getChain(provider, chainType, chainDescriptors, networkName) {
|
|
16
16
|
const cachedChain = chainCache.get(provider);
|
|
17
17
|
if (cachedChain !== undefined) {
|
|
18
18
|
return cachedChain;
|
|
@@ -33,11 +33,7 @@ export async function getChain(provider, chainType) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
else if (chain === undefined) {
|
|
36
|
-
|
|
37
|
-
// network we throw an error.
|
|
38
|
-
throw new HardhatError(HardhatError.ERRORS.HARDHAT_VIEM.GENERAL.NETWORK_NOT_FOUND, {
|
|
39
|
-
chainId,
|
|
40
|
-
});
|
|
36
|
+
chain = resolveChain(chainId, networkName, chainDescriptors);
|
|
41
37
|
}
|
|
42
38
|
else {
|
|
43
39
|
assertHardhatInvariant(false, "This should not happen, as we check in isDevelopmentNetwork that it's either hardhat or anvil");
|
|
@@ -143,4 +139,52 @@ function isHardhatMetadata(value) {
|
|
|
143
139
|
(isObject(value.forkedNetwork) &&
|
|
144
140
|
typeof value.forkedNetwork.chainId === "number")));
|
|
145
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolves a viem chain for a given chain id using the provided chain
|
|
144
|
+
* descriptors. If a matching descriptor is found, the chain is enriched with
|
|
145
|
+
* the descriptor's name and block explorer. Otherwise, falls back to a minimal
|
|
146
|
+
* chain using the network name.
|
|
147
|
+
*/
|
|
148
|
+
export function resolveChain(chainId, networkName, chainDescriptors) {
|
|
149
|
+
const chainDescriptor = chainDescriptors.get(BigInt(chainId));
|
|
150
|
+
if (chainDescriptor === undefined) {
|
|
151
|
+
return createMinimalChain(chainId, networkName);
|
|
152
|
+
}
|
|
153
|
+
const chain = createMinimalChain(chainId, chainDescriptor.name);
|
|
154
|
+
const blockExplorer = getDefaultBlockExplorer(chainDescriptor);
|
|
155
|
+
if (blockExplorer !== undefined) {
|
|
156
|
+
chain.blockExplorers = {
|
|
157
|
+
default: blockExplorer,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return chain;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Creates a viem chain with the minimum fields required to satisfy the
|
|
164
|
+
* {@link ViemChain} type.
|
|
165
|
+
*/
|
|
166
|
+
export function createMinimalChain(id, name) {
|
|
167
|
+
return {
|
|
168
|
+
id,
|
|
169
|
+
name,
|
|
170
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
171
|
+
rpcUrls: {
|
|
172
|
+
default: { http: [] },
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns the default block explorer for a chain descriptor, preferring
|
|
178
|
+
* Etherscan over Blockscout. Returns `undefined` if neither is configured.
|
|
179
|
+
*/
|
|
180
|
+
export function getDefaultBlockExplorer(chainDescriptor) {
|
|
181
|
+
const { etherscan, blockscout } = chainDescriptor.blockExplorers;
|
|
182
|
+
if (etherscan !== undefined) {
|
|
183
|
+
return { name: etherscan.name ?? "Etherscan", url: etherscan.url };
|
|
184
|
+
}
|
|
185
|
+
if (blockscout !== undefined) {
|
|
186
|
+
return { name: blockscout.name ?? "Blockscout", url: blockscout.url };
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
146
190
|
//# sourceMappingURL=chains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../../src/internal/chains.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../../src/internal/chains.ts"],"names":[],"mappings":"AASA,OAAO,EACL,sBAAsB,EACtB,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvD;kDACkD;AAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC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AC,CAAC;IAClD,CAAC;IAED,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAChE,MAAM,aAAa,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC;IAC/D,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,KAAK,CAAC,cAAc,GAAG;YACrB,OAAO,EAAE,aAAa;SACvB,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU,EAAE,IAAY;IACzD,OAAO;QACL,EAAE;QACF,IAAI;QACJ,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC9D,OAAO,EAAE;YACP,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;SACtB;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,eAAsC;IAEtC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC,cAAc,CAAC;IAEjE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,WAAW,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC;IACrE,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,YAAY,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC;IACxE,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { GetPublicClientReturnType, GetWalletClientReturnType, TestClient } from "../types.js";
|
|
2
|
+
import type { ChainDescriptorsConfig } from "hardhat/types/config";
|
|
2
3
|
import type { ChainType } from "hardhat/types/network";
|
|
3
4
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
4
5
|
import type { Address as ViemAddress, PublicClientConfig as ViemPublicClientConfig, TestClientConfig as ViemTestClientConfig, WalletClientConfig as ViemWalletClientConfig } from "viem";
|
|
5
|
-
export declare function getPublicClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, publicClientConfig?: Partial<ViemPublicClientConfig>): Promise<GetPublicClientReturnType<ChainTypeT>>;
|
|
6
|
-
export declare function getWalletClients<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, walletClientConfig?: Partial<ViemWalletClientConfig>): Promise<Array<GetWalletClientReturnType<ChainTypeT>>>;
|
|
7
|
-
export declare function getWalletClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, address: ViemAddress, walletClientConfig?: Partial<ViemWalletClientConfig>): Promise<GetWalletClientReturnType<ChainTypeT>>;
|
|
8
|
-
export declare function getDefaultWalletClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, walletClientConfig?: Partial<ViemWalletClientConfig>): Promise<GetWalletClientReturnType<ChainTypeT>>;
|
|
9
|
-
export declare function getTestClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, testClientConfig?: Partial<ViemTestClientConfig>): Promise<TestClient>;
|
|
6
|
+
export declare function getPublicClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, chainDescriptors: ChainDescriptorsConfig, networkName: string, publicClientConfig?: Partial<ViemPublicClientConfig>): Promise<GetPublicClientReturnType<ChainTypeT>>;
|
|
7
|
+
export declare function getWalletClients<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, chainDescriptors: ChainDescriptorsConfig, networkName: string, walletClientConfig?: Partial<ViemWalletClientConfig>): Promise<Array<GetWalletClientReturnType<ChainTypeT>>>;
|
|
8
|
+
export declare function getWalletClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, chainDescriptors: ChainDescriptorsConfig, networkName: string, address: ViemAddress, walletClientConfig?: Partial<ViemWalletClientConfig>): Promise<GetWalletClientReturnType<ChainTypeT>>;
|
|
9
|
+
export declare function getDefaultWalletClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, chainDescriptors: ChainDescriptorsConfig, networkName: string, walletClientConfig?: Partial<ViemWalletClientConfig>): Promise<GetWalletClientReturnType<ChainTypeT>>;
|
|
10
|
+
export declare function getTestClient<ChainTypeT extends ChainType | string>(provider: EthereumProvider, chainType: ChainTypeT, chainDescriptors: ChainDescriptorsConfig, networkName: string, testClientConfig?: Partial<ViemTestClientConfig>): Promise<TestClient>;
|
|
10
11
|
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../../src/internal/clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EACV,OAAO,IAAI,WAAW,EACtB,kBAAkB,IAAI,sBAAsB,EAC5C,gBAAgB,IAAI,oBAAoB,EACxC,kBAAkB,IAAI,sBAAsB,EAC7C,MAAM,MAAM,CAAC;AAcd,wBAAsB,eAAe,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,EACzE,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,UAAU,EACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACnD,OAAO,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../../src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AsB,CAAC,GACnD,OAAO,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAsBhD;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,SAAS,SAAS,GAAG,MAAM,EAErC,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,sBAAsB,EACxC,WAAW,EAAE,MAAM,EACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACnD,OAAO,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAuBhD;AAED,wBAAsB,aAAa,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,EACvE,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,UAAU,EACrB,gBAAgB,EAAE,sBAAsB,EACxC,WAAW,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAC/C,OAAO,CAAC,UAAU,CAAC,CAerB"}
|
|
@@ -3,8 +3,9 @@ import { createPublicClient, createWalletClient, createTestClient, custom as cus
|
|
|
3
3
|
import { publicActionsL2, walletActionsL2 } from "viem/op-stack";
|
|
4
4
|
import { getAccounts } from "./accounts.js";
|
|
5
5
|
import { getChain, getMode, isDevelopmentNetwork } from "./chains.js";
|
|
6
|
-
export async function getPublicClient(provider, chainType, publicClientConfig) {
|
|
7
|
-
const chain = publicClientConfig?.chain ??
|
|
6
|
+
export async function getPublicClient(provider, chainType, chainDescriptors, networkName, publicClientConfig) {
|
|
7
|
+
const chain = publicClientConfig?.chain ??
|
|
8
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
8
9
|
const { defaultClientParams, defaultTransportParams } = await getDefaultParams(provider);
|
|
9
10
|
let publicClient = createPublicClient({
|
|
10
11
|
chain,
|
|
@@ -19,8 +20,9 @@ export async function getPublicClient(provider, chainType, publicClientConfig) {
|
|
|
19
20
|
We need to assert the type because TS gets confused with the conditional type */
|
|
20
21
|
return publicClient;
|
|
21
22
|
}
|
|
22
|
-
export async function getWalletClients(provider, chainType, walletClientConfig) {
|
|
23
|
-
const chain = walletClientConfig?.chain ??
|
|
23
|
+
export async function getWalletClients(provider, chainType, chainDescriptors, networkName, walletClientConfig) {
|
|
24
|
+
const chain = walletClientConfig?.chain ??
|
|
25
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
24
26
|
const accounts = await getAccounts(provider);
|
|
25
27
|
const { defaultClientParams, defaultTransportParams } = await getDefaultParams(provider);
|
|
26
28
|
let walletClients = accounts.map((account) => createWalletClient({
|
|
@@ -37,8 +39,9 @@ export async function getWalletClients(provider, chainType, walletClientConfig)
|
|
|
37
39
|
We need to assert the type because TS gets confused with the conditional type */
|
|
38
40
|
return walletClients;
|
|
39
41
|
}
|
|
40
|
-
export async function getWalletClient(provider, chainType, address, walletClientConfig) {
|
|
41
|
-
const chain = walletClientConfig?.chain ??
|
|
42
|
+
export async function getWalletClient(provider, chainType, chainDescriptors, networkName, address, walletClientConfig) {
|
|
43
|
+
const chain = walletClientConfig?.chain ??
|
|
44
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
42
45
|
const { defaultClientParams, defaultTransportParams } = await getDefaultParams(provider);
|
|
43
46
|
let walletClient = createWalletClient({
|
|
44
47
|
chain,
|
|
@@ -54,18 +57,20 @@ export async function getWalletClient(provider, chainType, address, walletClient
|
|
|
54
57
|
We need to assert the type because TS gets confused with the conditional type */
|
|
55
58
|
return walletClient;
|
|
56
59
|
}
|
|
57
|
-
export async function getDefaultWalletClient(provider, chainType, walletClientConfig) {
|
|
58
|
-
const chain = walletClientConfig?.chain ??
|
|
60
|
+
export async function getDefaultWalletClient(provider, chainType, chainDescriptors, networkName, walletClientConfig) {
|
|
61
|
+
const chain = walletClientConfig?.chain ??
|
|
62
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
59
63
|
const [defaultAccount] = await getAccounts(provider);
|
|
60
64
|
if (defaultAccount === undefined) {
|
|
61
65
|
throw new HardhatError(HardhatError.ERRORS.HARDHAT_VIEM.GENERAL.DEFAULT_WALLET_CLIENT_NOT_FOUND, {
|
|
62
66
|
chainId: chain.id,
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
|
-
return getWalletClient(provider, chainType, defaultAccount, walletClientConfig);
|
|
69
|
+
return getWalletClient(provider, chainType, chainDescriptors, networkName, defaultAccount, walletClientConfig);
|
|
66
70
|
}
|
|
67
|
-
export async function getTestClient(provider, chainType, testClientConfig) {
|
|
68
|
-
const chain = testClientConfig?.chain ??
|
|
71
|
+
export async function getTestClient(provider, chainType, chainDescriptors, networkName, testClientConfig) {
|
|
72
|
+
const chain = testClientConfig?.chain ??
|
|
73
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
69
74
|
const mode = await getMode(provider);
|
|
70
75
|
const testClient = createTestClient({
|
|
71
76
|
chain,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../src/internal/clients.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../src/internal/clients.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,IAAI,eAAe,GAC1B,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAA0B,EAC1B,SAAqB,EACrB,gBAAwC,EACxC,WAAmB,EACnB,kBAAoD;IAEpD,MAAM,KAAK,GACT,kBAAkB,EAAE,KAAK;QACzB,CAAC,MAAM,QAAQ,CAAC,QAA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ractAtConfig, GetTransactionReturnType, SendDeploymentTransactionConfig } from "../types.js";
|
|
2
|
-
import type { ArtifactManager } from "hardhat/types/artifacts";
|
|
2
|
+
import type { ArtifactManager, StringWithArtifactContractNamesAutocompletion } from "hardhat/types/artifacts";
|
|
3
|
+
import type { ChainDescriptorsConfig } from "hardhat/types/config";
|
|
3
4
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
4
5
|
import type { Address as ViemAddress } from "viem";
|
|
5
|
-
export declare function deployContract<ContractName extends
|
|
6
|
-
export declare function sendDeploymentTransaction<ContractName extends
|
|
6
|
+
export declare function deployContract<ContractName extends StringWithArtifactContractNamesAutocompletion>(provider: EthereumProvider, artifactManager: ArtifactManager, chainDescriptors: ChainDescriptorsConfig, networkName: string, contractName: ContractName, constructorArgs?: readonly unknown[], deployContractConfig?: DeployContractConfig): Promise<ContractReturnType<ContractName>>;
|
|
7
|
+
export declare function sendDeploymentTransaction<ContractName extends StringWithArtifactContractNamesAutocompletion>(provider: EthereumProvider, artifactManager: ArtifactManager, chainDescriptors: ChainDescriptorsConfig, networkName: string, contractName: ContractName, constructorArgs?: readonly unknown[], sendDeploymentTransactionConfig?: SendDeploymentTransactionConfig): Promise<{
|
|
7
8
|
contract: ContractReturnType<ContractName>;
|
|
8
9
|
deploymentTransaction: GetTransactionReturnType;
|
|
9
10
|
}>;
|
|
10
|
-
export declare function getContractAt<ContractName extends
|
|
11
|
+
export declare function getContractAt<ContractName extends StringWithArtifactContractNamesAutocompletion>(provider: EthereumProvider, artifactManager: ArtifactManager, chainDescriptors: ChainDescriptorsConfig, networkName: string, contractName: ContractName, address: ViemAddress, getContractAtConfig?: GetContractAtConfig): Promise<ContractReturnType<ContractName>>;
|
|
11
12
|
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/internal/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,E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ED,wBAAsB,aAAa,CACjC,YAAY,SAAS,6CAA6C,EAElE,QAAQ,EAAE,gBAAgB,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,sBAAsB,EACxC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,WAAW,EACpB,mBAAmB,GAAE,mBAAwB,GAC5C,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAgB3C"}
|
|
@@ -4,7 +4,7 @@ import { resolveLinkedBytecode } from "@nomicfoundation/hardhat-utils/bytecode";
|
|
|
4
4
|
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
5
5
|
import { getContractAddress, getContract } from "viem";
|
|
6
6
|
import { getDefaultWalletClient, getPublicClient } from "./clients.js";
|
|
7
|
-
export async function deployContract(provider, artifactManager, contractName, constructorArgs = [], deployContractConfig = {}) {
|
|
7
|
+
export async function deployContract(provider, artifactManager, chainDescriptors, networkName, contractName, constructorArgs = [], deployContractConfig = {}) {
|
|
8
8
|
const { client, confirmations = 1, libraries = {}, ...deployContractParameters } = deployContractConfig;
|
|
9
9
|
if (confirmations < 0) {
|
|
10
10
|
throw new HardhatError(HardhatError.ERRORS.HARDHAT_VIEM.GENERAL.INVALID_CONFIRMATIONS, {
|
|
@@ -17,13 +17,15 @@ export async function deployContract(provider, artifactManager, contractName, co
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
const [publicClient, walletClient, { abi, bytecode }] = await Promise.all([
|
|
20
|
-
client?.public ??
|
|
21
|
-
|
|
20
|
+
client?.public ??
|
|
21
|
+
getPublicClient(provider, "l1", chainDescriptors, networkName),
|
|
22
|
+
client?.wallet ??
|
|
23
|
+
getDefaultWalletClient(provider, "l1", chainDescriptors, networkName),
|
|
22
24
|
getContractAbiAndBytecode(artifactManager, contractName, libraries),
|
|
23
25
|
]);
|
|
24
26
|
let deploymentTxHash;
|
|
25
27
|
// If gasPrice is defined, then maxFeePerGas and maxPriorityFeePerGas
|
|
26
|
-
// must be undefined because it's a
|
|
28
|
+
// must be undefined because it's a legacy tx.
|
|
27
29
|
if (deployContractParameters.gasPrice !== undefined) {
|
|
28
30
|
deploymentTxHash = await walletClient.deployContract({
|
|
29
31
|
abi,
|
|
@@ -59,16 +61,18 @@ export async function deployContract(provider, artifactManager, contractName, co
|
|
|
59
61
|
const contract = createContractInstance(contractName, publicClient, walletClient, abi, contractAddress);
|
|
60
62
|
return contract;
|
|
61
63
|
}
|
|
62
|
-
export async function sendDeploymentTransaction(provider, artifactManager, contractName, constructorArgs = [], sendDeploymentTransactionConfig = {}) {
|
|
64
|
+
export async function sendDeploymentTransaction(provider, artifactManager, chainDescriptors, networkName, contractName, constructorArgs = [], sendDeploymentTransactionConfig = {}) {
|
|
63
65
|
const { client, libraries = {}, ...deployContractParameters } = sendDeploymentTransactionConfig;
|
|
64
66
|
const [publicClient, walletClient, { abi, bytecode }] = await Promise.all([
|
|
65
|
-
client?.public ??
|
|
66
|
-
|
|
67
|
+
client?.public ??
|
|
68
|
+
getPublicClient(provider, "l1", chainDescriptors, networkName),
|
|
69
|
+
client?.wallet ??
|
|
70
|
+
getDefaultWalletClient(provider, "l1", chainDescriptors, networkName),
|
|
67
71
|
getContractAbiAndBytecode(artifactManager, contractName, libraries),
|
|
68
72
|
]);
|
|
69
73
|
let deploymentTxHash;
|
|
70
74
|
// If gasPrice is defined, then maxFeePerGas and maxPriorityFeePerGas
|
|
71
|
-
// must be undefined because it's a
|
|
75
|
+
// must be undefined because it's a legacy tx.
|
|
72
76
|
if (deployContractParameters.gasPrice !== undefined) {
|
|
73
77
|
deploymentTxHash = await walletClient.deployContract({
|
|
74
78
|
abi,
|
|
@@ -98,11 +102,12 @@ export async function sendDeploymentTransaction(provider, artifactManager, contr
|
|
|
98
102
|
const contract = createContractInstance(contractName, publicClient, walletClient, abi, contractAddress);
|
|
99
103
|
return { contract, deploymentTransaction: deploymentTx };
|
|
100
104
|
}
|
|
101
|
-
export async function getContractAt(provider, artifactManager, contractName, address, getContractAtConfig = {}) {
|
|
105
|
+
export async function getContractAt(provider, artifactManager, chainDescriptors, networkName, contractName, address, getContractAtConfig = {}) {
|
|
102
106
|
const [publicClient, walletClient, artifact] = await Promise.all([
|
|
103
|
-
getContractAtConfig.client?.public ??
|
|
107
|
+
getContractAtConfig.client?.public ??
|
|
108
|
+
getPublicClient(provider, "l1", chainDescriptors, networkName),
|
|
104
109
|
getContractAtConfig.client?.wallet ??
|
|
105
|
-
getDefaultWalletClient(provider, "l1"),
|
|
110
|
+
getDefaultWalletClient(provider, "l1", chainDescriptors, networkName),
|
|
106
111
|
artifactManager.readArtifact(contractName),
|
|
107
112
|
]);
|
|
108
113
|
return createContractInstance(contractName, publicClient, walletClient, artifact.abi, address);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/internal/contracts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/internal/contracts.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC,QAA0B,EAC1B,eAAgC,EAChC,gBAAwC,EACxC,WAAmB,EACnB,YAA0B,EAC1B,kBAAsC,EAAE,EACxC,uBAA6C,EAAE;IAE/C,MAAM,EACJ,MAAM,EACN,aAAa,GAAG,CAAC,EACjB,SAAS,GAAG,EAAE,EACd,GAAG,wBAAwB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GAAG;QACjB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../../src/internal/hook-handlers/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;8BAK5C,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAAvD,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../../src/internal/hook-handlers/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;8BAK5C,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAAvD,wBAuBE"}
|
|
@@ -3,7 +3,7 @@ export default async () => {
|
|
|
3
3
|
const handlers = {
|
|
4
4
|
async newConnection(context, next) {
|
|
5
5
|
const connection = await next(context);
|
|
6
|
-
connection.viem = initializeViem(connection.chainType, connection.provider, context.artifacts);
|
|
6
|
+
connection.viem = initializeViem(connection.chainType, connection.provider, context.artifacts, context.config.chainDescriptors, connection.networkName);
|
|
7
7
|
return connection;
|
|
8
8
|
},
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../../src/internal/hook-handlers/network.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,eAAe,KAAK,IAAoC,EAAE;IACxD,MAAM,QAAQ,GAA0B;QACtC,KAAK,CAAC,aAAa,CACjB,OAAoB,EACpB,IAE2C;YAE3C,MAAM,UAAU,GAAkC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAEtE,UAAU,CAAC,IAAI,GAAG,cAAc,CAC9B,UAAU,CAAC,SAAS,EACpB,UAAU,CAAC,QAAQ,EACnB,OAAO,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../../src/internal/hook-handlers/network.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,eAAe,KAAK,IAAoC,EAAE;IACxD,MAAM,QAAQ,GAA0B;QACtC,KAAK,CAAC,aAAa,CACjB,OAAoB,EACpB,IAE2C;YAE3C,MAAM,UAAU,GAAkC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAEtE,UAAU,CAAC,IAAI,GAAG,cAAc,CAC9B,UAAU,CAAC,SAAS,EACpB,UAAU,CAAC,QAAQ,EACnB,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAC/B,UAAU,CAAC,WAAW,CACvB,CAAC;YAEF,OAAO,UAAU,CAAC;QACpB,CAAC;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HardhatViemHelpers } from "../types.js";
|
|
2
2
|
import type { ArtifactManager } from "hardhat/types/artifacts";
|
|
3
|
+
import type { ChainDescriptorsConfig } from "hardhat/types/config";
|
|
3
4
|
import type { ChainType } from "hardhat/types/network";
|
|
4
5
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
5
|
-
export declare function initializeViem<ChainTypeT extends ChainType | string>(chainType: ChainTypeT, provider: EthereumProvider, artifactManager: ArtifactManager): HardhatViemHelpers<ChainTypeT>;
|
|
6
|
+
export declare function initializeViem<ChainTypeT extends ChainType | string>(chainType: ChainTypeT, provider: EthereumProvider, artifactManager: ArtifactManager, chainDescriptors: ChainDescriptorsConfig, networkName: string): HardhatViemHelpers<ChainTypeT>;
|
|
6
7
|
//# sourceMappingURL=initialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialization.d.ts","sourceRoot":"","sources":["../../../src/internal/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAchE,wBAAgB,cAAc,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,EAClE,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,gBAAgB,EAC1B,eAAe,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"initialization.d.ts","sourceRoot":"","sources":["../../../src/internal/initialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAchE,wBAAgB,cAAc,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,EAClE,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,gBAAgB,EAC1B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,sBAAsB,EACxC,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAAC,UAAU,CAAC,CA4EhC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { getPublicClient, getWalletClients, getWalletClient, getTestClient, } from "./clients.js";
|
|
2
2
|
import { deployContract, getContractAt, sendDeploymentTransaction, } from "./contracts.js";
|
|
3
|
-
export function initializeViem(chainType, provider, artifactManager) {
|
|
3
|
+
export function initializeViem(chainType, provider, artifactManager, chainDescriptors, networkName) {
|
|
4
4
|
return {
|
|
5
|
-
getPublicClient: (publicClientConfig) => getPublicClient(provider, chainType, publicClientConfig),
|
|
6
|
-
getWalletClients: (walletClientConfig) => getWalletClients(provider, chainType, walletClientConfig),
|
|
7
|
-
getWalletClient: (address, walletClientConfig) => getWalletClient(provider, chainType, address, walletClientConfig),
|
|
8
|
-
getTestClient: (testClientConfig) => getTestClient(provider, chainType, testClientConfig),
|
|
9
|
-
deployContract: (contractName, constructorArgs, deployContractConfig) => deployContract(provider, artifactManager, contractName, constructorArgs, deployContractConfig),
|
|
10
|
-
sendDeploymentTransaction: (contractName, constructorArgs, sendDeploymentTransactionConfig) => sendDeploymentTransaction(provider, artifactManager, contractName, constructorArgs, sendDeploymentTransactionConfig),
|
|
11
|
-
getContractAt: (contractName, address, getContractAtConfig) => getContractAt(provider, artifactManager, contractName, address, getContractAtConfig),
|
|
5
|
+
getPublicClient: (publicClientConfig) => getPublicClient(provider, chainType, chainDescriptors, networkName, publicClientConfig),
|
|
6
|
+
getWalletClients: (walletClientConfig) => getWalletClients(provider, chainType, chainDescriptors, networkName, walletClientConfig),
|
|
7
|
+
getWalletClient: (address, walletClientConfig) => getWalletClient(provider, chainType, chainDescriptors, networkName, address, walletClientConfig),
|
|
8
|
+
getTestClient: (testClientConfig) => getTestClient(provider, chainType, chainDescriptors, networkName, testClientConfig),
|
|
9
|
+
deployContract: (contractName, constructorArgs, deployContractConfig) => deployContract(provider, artifactManager, chainDescriptors, networkName, contractName, constructorArgs, deployContractConfig),
|
|
10
|
+
sendDeploymentTransaction: (contractName, constructorArgs, sendDeploymentTransactionConfig) => sendDeploymentTransaction(provider, artifactManager, chainDescriptors, networkName, contractName, constructorArgs, sendDeploymentTransactionConfig),
|
|
11
|
+
getContractAt: (contractName, address, getContractAtConfig) => getContractAt(provider, artifactManager, chainDescriptors, networkName, contractName, address, getContractAtConfig),
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=initialization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialization.js","sourceRoot":"","sources":["../../../src/internal/initialization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialization.js","sourceRoot":"","sources":["../../../src/internal/initialization.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,aAAa,EACb,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,cAAc,CAC5B,SAAqB,EACrB,QAA0B,EAC1B,eAAgC,EAChC,gBAAwC,EACxC,WAAmB;IAEnB,OAAO;QACL,eAAe,EAAE,CAAC,kBAAkB,EAAE,EAAE,CACtC,eAAe,CACb,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,kBAAkB,CACnB;QAEH,gBAAgB,EAAE,CAAC,kBAAkB,EAAE,EAAE,CACvC,gBAAgB,CACd,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,kBAAkB,CACnB;QAEH,eAAe,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,CAC/C,eAAe,CACb,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,kBAAkB,CACnB;QAEH,aAAa,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAClC,aAAa,CACX,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,gBAAgB,CACjB;QAEH,cAAc,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,EAAE,CACtE,cAAc,CACZ,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,oBAAoB,CACrB;QAEH,yBAAyB,EAAE,CACzB,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,EAAE,CACF,yBAAyB,CACvB,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,+BAA+B,CAChC;QAEH,aAAa,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,CAC5D,aAAa,CACX,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,OAAO,EACP,mBAAmB,CACpB;KACJ,CAAC;AACJ,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtifactMap } from "hardhat/types/artifacts";
|
|
1
|
+
import type { ArtifactMap, StringWithArtifactContractNamesAutocompletion } from "hardhat/types/artifacts";
|
|
2
2
|
import type { ChainType, DefaultChainType } from "hardhat/types/network";
|
|
3
3
|
import type { Abi as ViemAbi, Account as ViemAccount, Address as ViemAddress, Chain as ViemChain, Client as ViemClient, ContractConstructorArgs as ViemContractConstructorArgs, createTestClient as ViemCreateTestClient, GetContractReturnType as ViemGetContractReturnType, GetTransactionReturnType as ViemGetTransactionReturnType, PublicClient as ViemPublicClient, PublicClientConfig as ViemPublicClientConfig, RpcSchema as ViemRpcSchema, TestClient as ViemTestClient, TestClientConfig as ViemTestClientConfig, Transport as ViemTransport, WalletClient as ViemWalletClient, WalletClientConfig as ViemWalletClientConfig, PublicActions as ViemPublicActions, WalletActions as ViemWalletActions } from "viem";
|
|
4
4
|
import type { PublicActionsL2 as ViemOpStackPublicActionsL2, WalletActionsL2 as ViemOpStackWalletActionsL2 } from "viem/op-stack";
|
|
@@ -47,27 +47,33 @@ export interface HardhatViemHelpers<ChainTypeT extends ChainType | string = Defa
|
|
|
47
47
|
* returns the viem's contract instance.
|
|
48
48
|
*
|
|
49
49
|
* @param contractName The name of the contract to deploy. This is required
|
|
50
|
-
* to return the correct contract type.
|
|
50
|
+
* to return the correct contract type. TypeScript's language server
|
|
51
|
+
* autocompletes the names of the contracts that have already been built. If
|
|
52
|
+
* your contract name isn't in the list, you can still use it, and/or run
|
|
53
|
+
* `hardhat build` to get it in the list.
|
|
51
54
|
* @param constructorArgs The arguments to pass to the contract's constructor.
|
|
52
55
|
* @param deployContractConfig A configuration object. See
|
|
53
56
|
* {@link DeployContractConfig} for more details.
|
|
54
57
|
* @returns The deployed contract instance.
|
|
55
58
|
*/
|
|
56
|
-
deployContract: <ContractName extends
|
|
59
|
+
deployContract: <ContractName extends StringWithArtifactContractNamesAutocompletion>(contractName: ContractName, constructorArgs?: ConstructorArgs<ContractName>, deployContractConfig?: DeployContractConfig) => Promise<ContractReturnType<ContractName>>;
|
|
57
60
|
/**
|
|
58
61
|
* Sends a deployment transaction for the specified contract and returns the
|
|
59
62
|
* contract instance along with the deployment transaction.
|
|
60
63
|
* The function does not wait for the transaction to be mined.
|
|
61
64
|
*
|
|
62
65
|
* @param contractName The name of the contract to deploy. This is required
|
|
63
|
-
* to return the correct contract type.
|
|
66
|
+
* to return the correct contract type. TypeScript's language server
|
|
67
|
+
* autocompletes the names of the contracts that have already been built. If
|
|
68
|
+
* your contract name isn't in the list, you can still use it, and/or run
|
|
69
|
+
* `hardhat build` to get it in the list.
|
|
64
70
|
* @param constructorArgs The arguments to pass to the contract's constructor.
|
|
65
71
|
* @param sendDeploymentTransactionConfig A configuration object. See
|
|
66
72
|
* {@link SendDeploymentTransactionConfig} for more details.
|
|
67
73
|
* @returns An object containing the deployed contract instance and the
|
|
68
74
|
* deployment transaction.
|
|
69
75
|
*/
|
|
70
|
-
sendDeploymentTransaction: <ContractName extends
|
|
76
|
+
sendDeploymentTransaction: <ContractName extends StringWithArtifactContractNamesAutocompletion>(contractName: ContractName, constructorArgs?: ConstructorArgs<ContractName>, sendDeploymentTransactionConfig?: SendDeploymentTransactionConfig) => Promise<{
|
|
71
77
|
contract: ContractReturnType<ContractName>;
|
|
72
78
|
deploymentTransaction: GetTransactionReturnType;
|
|
73
79
|
}>;
|
|
@@ -76,13 +82,16 @@ export interface HardhatViemHelpers<ChainTypeT extends ChainType | string = Defa
|
|
|
76
82
|
* address.
|
|
77
83
|
*
|
|
78
84
|
* @param contractName The name of the contract to get an instance of. This
|
|
79
|
-
* is required to return the correct contract type.
|
|
85
|
+
* is required to return the correct contract type. TypeScript's language
|
|
86
|
+
* server autocompletes the names of the contracts that have already been
|
|
87
|
+
* built. If your contract name isn't in the list, you can still use it,
|
|
88
|
+
* and/or run `hardhat build` to get it in the list.
|
|
80
89
|
* @param address The address of the contract.
|
|
81
90
|
* @param getContractAtConfig A configuration object. See
|
|
82
91
|
* {@link GetContractAtConfig} for more details.
|
|
83
92
|
* @returns The contract instance.
|
|
84
93
|
*/
|
|
85
|
-
getContractAt: <ContractName extends
|
|
94
|
+
getContractAt: <ContractName extends StringWithArtifactContractNamesAutocompletion>(contractName: ContractName, address: ViemAddress, getContractAtConfig?: GetContractAtConfig) => Promise<ContractReturnType<ContractName>>;
|
|
86
95
|
}
|
|
87
96
|
export type GetPublicClientReturnType<ChainTypeT extends ChainType | string> = ChainTypeT extends "op" ? OpPublicClient : PublicClient;
|
|
88
97
|
export type GetWalletClientReturnType<ChainTypeT extends ChainType | string> = ChainTypeT extends "op" ? OpWalletClient : WalletClient;
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,6CAA6C,EAC9C,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EACV,GAAG,IAAI,OAAO,EACd,OAAO,IAAI,WAAW,EACtB,OAAO,IAAI,WAAW,EACtB,KAAK,IAAI,SAAS,EAClB,MAAM,IAAI,UAAU,EACpB,uBAAuB,IAAI,2BAA2B,EACtD,gBAAgB,IAAI,oBAAoB,EACxC,qBAAqB,IAAI,yBAAyB,EAClD,wBAA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,SAAS,OAAO,GAAG,SAAS,OAAO,EAAE,GAAG,OAAO,IACjD,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;AAExE,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,CACjE,SAAS,EACT,QAAQ,CACT,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;KACxB,YAAY,IAAI,MAAM,WAAW,GAAG,WAAW,CAAC,YAAY,CAAC,SAAS,KAAK,GACxE,KAAK,GACL,WAAW,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,YAAY,IACtC,YAAY,SAAS,MAAM,YAAY,GACnC,2BAA2B,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,GACvD,OAAO,EAAE,CAAC;AAEhB,MAAM,MAAM,kBAAkB,CAAC,YAAY,IACzC,YAAY,SAAS,MAAM,YAAY,GACnC,qBAAqB,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,GACjD,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/hardhat-viem",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Hardhat plugin for viem",
|
|
5
5
|
"homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-viem",
|
|
6
6
|
"repository": {
|
|
@@ -41,14 +41,15 @@
|
|
|
41
41
|
"tsx": "^4.19.3",
|
|
42
42
|
"typescript": "~5.8.0",
|
|
43
43
|
"viem": "^2.43.0",
|
|
44
|
-
"
|
|
44
|
+
"hardhat": "^3.1.11",
|
|
45
|
+
"@nomicfoundation/hardhat-test-utils": "^2.0.2"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@nomicfoundation/hardhat-errors": "^3.0.
|
|
48
|
-
"@nomicfoundation/hardhat-utils": "^
|
|
48
|
+
"@nomicfoundation/hardhat-errors": "^3.0.7",
|
|
49
|
+
"@nomicfoundation/hardhat-utils": "^4.0.0"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"hardhat": "^3.
|
|
52
|
+
"hardhat": "^3.1.11",
|
|
52
53
|
"viem": "^2.43.0"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
package/src/internal/chains.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { TestClientMode } from "../types.js";
|
|
2
|
+
import type {
|
|
3
|
+
ChainDescriptorConfig,
|
|
4
|
+
ChainDescriptorsConfig,
|
|
5
|
+
} from "hardhat/types/config";
|
|
2
6
|
import type { ChainType } from "hardhat/types/network";
|
|
3
7
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
4
8
|
import type { Chain as ViemChain } from "viem";
|
|
@@ -27,6 +31,8 @@ const ANVIL_NODE_INFO_METHOD = "anvil_nodeInfo";
|
|
|
27
31
|
export async function getChain<ChainTypeT extends ChainType | string>(
|
|
28
32
|
provider: EthereumProvider,
|
|
29
33
|
chainType: ChainTypeT,
|
|
34
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
35
|
+
networkName: string,
|
|
30
36
|
): Promise<ViemChain> {
|
|
31
37
|
const cachedChain = chainCache.get(provider);
|
|
32
38
|
if (cachedChain !== undefined) {
|
|
@@ -49,14 +55,7 @@ export async function getChain<ChainTypeT extends ChainType | string>(
|
|
|
49
55
|
id: chainId,
|
|
50
56
|
};
|
|
51
57
|
} else if (chain === undefined) {
|
|
52
|
-
|
|
53
|
-
// network we throw an error.
|
|
54
|
-
throw new HardhatError(
|
|
55
|
-
HardhatError.ERRORS.HARDHAT_VIEM.GENERAL.NETWORK_NOT_FOUND,
|
|
56
|
-
{
|
|
57
|
-
chainId,
|
|
58
|
-
},
|
|
59
|
-
);
|
|
58
|
+
chain = resolveChain(chainId, networkName, chainDescriptors);
|
|
60
59
|
} else {
|
|
61
60
|
assertHardhatInvariant(
|
|
62
61
|
false,
|
|
@@ -214,3 +213,65 @@ function isHardhatMetadata(value: unknown): value is HardhatMetadata {
|
|
|
214
213
|
typeof value.forkedNetwork.chainId === "number"))
|
|
215
214
|
);
|
|
216
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Resolves a viem chain for a given chain id using the provided chain
|
|
219
|
+
* descriptors. If a matching descriptor is found, the chain is enriched with
|
|
220
|
+
* the descriptor's name and block explorer. Otherwise, falls back to a minimal
|
|
221
|
+
* chain using the network name.
|
|
222
|
+
*/
|
|
223
|
+
export function resolveChain(
|
|
224
|
+
chainId: number,
|
|
225
|
+
networkName: string,
|
|
226
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
227
|
+
): ViemChain {
|
|
228
|
+
const chainDescriptor = chainDescriptors.get(BigInt(chainId));
|
|
229
|
+
if (chainDescriptor === undefined) {
|
|
230
|
+
return createMinimalChain(chainId, networkName);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const chain = createMinimalChain(chainId, chainDescriptor.name);
|
|
234
|
+
const blockExplorer = getDefaultBlockExplorer(chainDescriptor);
|
|
235
|
+
if (blockExplorer !== undefined) {
|
|
236
|
+
chain.blockExplorers = {
|
|
237
|
+
default: blockExplorer,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return chain;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Creates a viem chain with the minimum fields required to satisfy the
|
|
246
|
+
* {@link ViemChain} type.
|
|
247
|
+
*/
|
|
248
|
+
export function createMinimalChain(id: number, name: string): ViemChain {
|
|
249
|
+
return {
|
|
250
|
+
id,
|
|
251
|
+
name,
|
|
252
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
253
|
+
rpcUrls: {
|
|
254
|
+
default: { http: [] },
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Returns the default block explorer for a chain descriptor, preferring
|
|
261
|
+
* Etherscan over Blockscout. Returns `undefined` if neither is configured.
|
|
262
|
+
*/
|
|
263
|
+
export function getDefaultBlockExplorer(
|
|
264
|
+
chainDescriptor: ChainDescriptorConfig,
|
|
265
|
+
): { name: string; url: string } | undefined {
|
|
266
|
+
const { etherscan, blockscout } = chainDescriptor.blockExplorers;
|
|
267
|
+
|
|
268
|
+
if (etherscan !== undefined) {
|
|
269
|
+
return { name: etherscan.name ?? "Etherscan", url: etherscan.url };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (blockscout !== undefined) {
|
|
273
|
+
return { name: blockscout.name ?? "Blockscout", url: blockscout.url };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
package/src/internal/clients.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
GetWalletClientReturnType,
|
|
4
4
|
TestClient,
|
|
5
5
|
} from "../types.js";
|
|
6
|
+
import type { ChainDescriptorsConfig } from "hardhat/types/config";
|
|
6
7
|
import type { ChainType } from "hardhat/types/network";
|
|
7
8
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
8
9
|
import type {
|
|
@@ -27,10 +28,13 @@ import { getChain, getMode, isDevelopmentNetwork } from "./chains.js";
|
|
|
27
28
|
export async function getPublicClient<ChainTypeT extends ChainType | string>(
|
|
28
29
|
provider: EthereumProvider,
|
|
29
30
|
chainType: ChainTypeT,
|
|
31
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
32
|
+
networkName: string,
|
|
30
33
|
publicClientConfig?: Partial<ViemPublicClientConfig>,
|
|
31
34
|
): Promise<GetPublicClientReturnType<ChainTypeT>> {
|
|
32
35
|
const chain =
|
|
33
|
-
publicClientConfig?.chain ??
|
|
36
|
+
publicClientConfig?.chain ??
|
|
37
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
34
38
|
const { defaultClientParams, defaultTransportParams } =
|
|
35
39
|
await getDefaultParams(provider);
|
|
36
40
|
|
|
@@ -53,10 +57,13 @@ export async function getPublicClient<ChainTypeT extends ChainType | string>(
|
|
|
53
57
|
export async function getWalletClients<ChainTypeT extends ChainType | string>(
|
|
54
58
|
provider: EthereumProvider,
|
|
55
59
|
chainType: ChainTypeT,
|
|
60
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
61
|
+
networkName: string,
|
|
56
62
|
walletClientConfig?: Partial<ViemWalletClientConfig>,
|
|
57
63
|
): Promise<Array<GetWalletClientReturnType<ChainTypeT>>> {
|
|
58
64
|
const chain =
|
|
59
|
-
walletClientConfig?.chain ??
|
|
65
|
+
walletClientConfig?.chain ??
|
|
66
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
60
67
|
const accounts = await getAccounts(provider);
|
|
61
68
|
const { defaultClientParams, defaultTransportParams } =
|
|
62
69
|
await getDefaultParams(provider);
|
|
@@ -85,11 +92,14 @@ export async function getWalletClients<ChainTypeT extends ChainType | string>(
|
|
|
85
92
|
export async function getWalletClient<ChainTypeT extends ChainType | string>(
|
|
86
93
|
provider: EthereumProvider,
|
|
87
94
|
chainType: ChainTypeT,
|
|
95
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
96
|
+
networkName: string,
|
|
88
97
|
address: ViemAddress,
|
|
89
98
|
walletClientConfig?: Partial<ViemWalletClientConfig>,
|
|
90
99
|
): Promise<GetWalletClientReturnType<ChainTypeT>> {
|
|
91
100
|
const chain =
|
|
92
|
-
walletClientConfig?.chain ??
|
|
101
|
+
walletClientConfig?.chain ??
|
|
102
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
93
103
|
const { defaultClientParams, defaultTransportParams } =
|
|
94
104
|
await getDefaultParams(provider);
|
|
95
105
|
|
|
@@ -115,10 +125,13 @@ export async function getDefaultWalletClient<
|
|
|
115
125
|
>(
|
|
116
126
|
provider: EthereumProvider,
|
|
117
127
|
chainType: ChainTypeT,
|
|
128
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
129
|
+
networkName: string,
|
|
118
130
|
walletClientConfig?: Partial<ViemWalletClientConfig>,
|
|
119
131
|
): Promise<GetWalletClientReturnType<ChainTypeT>> {
|
|
120
132
|
const chain =
|
|
121
|
-
walletClientConfig?.chain ??
|
|
133
|
+
walletClientConfig?.chain ??
|
|
134
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
122
135
|
const [defaultAccount] = await getAccounts(provider);
|
|
123
136
|
|
|
124
137
|
if (defaultAccount === undefined) {
|
|
@@ -133,6 +146,8 @@ export async function getDefaultWalletClient<
|
|
|
133
146
|
return getWalletClient(
|
|
134
147
|
provider,
|
|
135
148
|
chainType,
|
|
149
|
+
chainDescriptors,
|
|
150
|
+
networkName,
|
|
136
151
|
defaultAccount,
|
|
137
152
|
walletClientConfig,
|
|
138
153
|
);
|
|
@@ -141,10 +156,13 @@ export async function getDefaultWalletClient<
|
|
|
141
156
|
export async function getTestClient<ChainTypeT extends ChainType | string>(
|
|
142
157
|
provider: EthereumProvider,
|
|
143
158
|
chainType: ChainTypeT,
|
|
159
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
160
|
+
networkName: string,
|
|
144
161
|
testClientConfig?: Partial<ViemTestClientConfig>,
|
|
145
162
|
): Promise<TestClient> {
|
|
146
163
|
const chain =
|
|
147
|
-
testClientConfig?.chain ??
|
|
164
|
+
testClientConfig?.chain ??
|
|
165
|
+
(await getChain(provider, chainType, chainDescriptors, networkName));
|
|
148
166
|
const mode = await getMode(provider);
|
|
149
167
|
|
|
150
168
|
const testClient = createTestClient({
|
|
@@ -9,7 +9,11 @@ import type {
|
|
|
9
9
|
WalletClient,
|
|
10
10
|
} from "../types.js";
|
|
11
11
|
import type { PrefixedHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
12
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
ArtifactManager,
|
|
14
|
+
StringWithArtifactContractNamesAutocompletion,
|
|
15
|
+
} from "hardhat/types/artifacts";
|
|
16
|
+
import type { ChainDescriptorsConfig } from "hardhat/types/config";
|
|
13
17
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
14
18
|
import type { Abi as ViemAbi, Address as ViemAddress } from "viem";
|
|
15
19
|
|
|
@@ -21,9 +25,13 @@ import { getContractAddress, getContract } from "viem";
|
|
|
21
25
|
|
|
22
26
|
import { getDefaultWalletClient, getPublicClient } from "./clients.js";
|
|
23
27
|
|
|
24
|
-
export async function deployContract<
|
|
28
|
+
export async function deployContract<
|
|
29
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
30
|
+
>(
|
|
25
31
|
provider: EthereumProvider,
|
|
26
32
|
artifactManager: ArtifactManager,
|
|
33
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
34
|
+
networkName: string,
|
|
27
35
|
contractName: ContractName,
|
|
28
36
|
constructorArgs: readonly unknown[] = [],
|
|
29
37
|
deployContractConfig: DeployContractConfig = {},
|
|
@@ -54,14 +62,16 @@ export async function deployContract<ContractName extends string>(
|
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
const [publicClient, walletClient, { abi, bytecode }] = await Promise.all([
|
|
57
|
-
client?.public ??
|
|
58
|
-
|
|
65
|
+
client?.public ??
|
|
66
|
+
getPublicClient(provider, "l1", chainDescriptors, networkName),
|
|
67
|
+
client?.wallet ??
|
|
68
|
+
getDefaultWalletClient(provider, "l1", chainDescriptors, networkName),
|
|
59
69
|
getContractAbiAndBytecode(artifactManager, contractName, libraries),
|
|
60
70
|
]);
|
|
61
71
|
|
|
62
72
|
let deploymentTxHash: PrefixedHexString;
|
|
63
73
|
// If gasPrice is defined, then maxFeePerGas and maxPriorityFeePerGas
|
|
64
|
-
// must be undefined because it's a
|
|
74
|
+
// must be undefined because it's a legacy tx.
|
|
65
75
|
if (deployContractParameters.gasPrice !== undefined) {
|
|
66
76
|
deploymentTxHash = await walletClient.deployContract({
|
|
67
77
|
abi,
|
|
@@ -110,9 +120,13 @@ export async function deployContract<ContractName extends string>(
|
|
|
110
120
|
return contract;
|
|
111
121
|
}
|
|
112
122
|
|
|
113
|
-
export async function sendDeploymentTransaction<
|
|
123
|
+
export async function sendDeploymentTransaction<
|
|
124
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
125
|
+
>(
|
|
114
126
|
provider: EthereumProvider,
|
|
115
127
|
artifactManager: ArtifactManager,
|
|
128
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
129
|
+
networkName: string,
|
|
116
130
|
contractName: ContractName,
|
|
117
131
|
constructorArgs: readonly unknown[] = [],
|
|
118
132
|
sendDeploymentTransactionConfig: SendDeploymentTransactionConfig = {},
|
|
@@ -126,14 +140,16 @@ export async function sendDeploymentTransaction<ContractName extends string>(
|
|
|
126
140
|
...deployContractParameters
|
|
127
141
|
} = sendDeploymentTransactionConfig;
|
|
128
142
|
const [publicClient, walletClient, { abi, bytecode }] = await Promise.all([
|
|
129
|
-
client?.public ??
|
|
130
|
-
|
|
143
|
+
client?.public ??
|
|
144
|
+
getPublicClient(provider, "l1", chainDescriptors, networkName),
|
|
145
|
+
client?.wallet ??
|
|
146
|
+
getDefaultWalletClient(provider, "l1", chainDescriptors, networkName),
|
|
131
147
|
getContractAbiAndBytecode(artifactManager, contractName, libraries),
|
|
132
148
|
]);
|
|
133
149
|
|
|
134
150
|
let deploymentTxHash: PrefixedHexString;
|
|
135
151
|
// If gasPrice is defined, then maxFeePerGas and maxPriorityFeePerGas
|
|
136
|
-
// must be undefined because it's a
|
|
152
|
+
// must be undefined because it's a legacy tx.
|
|
137
153
|
if (deployContractParameters.gasPrice !== undefined) {
|
|
138
154
|
deploymentTxHash = await walletClient.deployContract({
|
|
139
155
|
abi,
|
|
@@ -173,17 +189,22 @@ export async function sendDeploymentTransaction<ContractName extends string>(
|
|
|
173
189
|
return { contract, deploymentTransaction: deploymentTx };
|
|
174
190
|
}
|
|
175
191
|
|
|
176
|
-
export async function getContractAt<
|
|
192
|
+
export async function getContractAt<
|
|
193
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
194
|
+
>(
|
|
177
195
|
provider: EthereumProvider,
|
|
178
196
|
artifactManager: ArtifactManager,
|
|
197
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
198
|
+
networkName: string,
|
|
179
199
|
contractName: ContractName,
|
|
180
200
|
address: ViemAddress,
|
|
181
201
|
getContractAtConfig: GetContractAtConfig = {},
|
|
182
202
|
): Promise<ContractReturnType<ContractName>> {
|
|
183
203
|
const [publicClient, walletClient, artifact] = await Promise.all([
|
|
184
|
-
getContractAtConfig.client?.public ??
|
|
204
|
+
getContractAtConfig.client?.public ??
|
|
205
|
+
getPublicClient(provider, "l1", chainDescriptors, networkName),
|
|
185
206
|
getContractAtConfig.client?.wallet ??
|
|
186
|
-
getDefaultWalletClient(provider, "l1"),
|
|
207
|
+
getDefaultWalletClient(provider, "l1", chainDescriptors, networkName),
|
|
187
208
|
artifactManager.readArtifact(contractName),
|
|
188
209
|
]);
|
|
189
210
|
|
|
@@ -196,7 +217,9 @@ export async function getContractAt<ContractName extends string>(
|
|
|
196
217
|
);
|
|
197
218
|
}
|
|
198
219
|
|
|
199
|
-
function createContractInstance<
|
|
220
|
+
function createContractInstance<
|
|
221
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
222
|
+
>(
|
|
200
223
|
_contractName: ContractName,
|
|
201
224
|
publicClient: PublicClient,
|
|
202
225
|
walletClient: WalletClient,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HardhatViemHelpers } from "../types.js";
|
|
2
2
|
import type { ArtifactManager } from "hardhat/types/artifacts";
|
|
3
|
+
import type { ChainDescriptorsConfig } from "hardhat/types/config";
|
|
3
4
|
import type { ChainType } from "hardhat/types/network";
|
|
4
5
|
import type { EthereumProvider } from "hardhat/types/providers";
|
|
5
6
|
|
|
@@ -19,24 +20,53 @@ export function initializeViem<ChainTypeT extends ChainType | string>(
|
|
|
19
20
|
chainType: ChainTypeT,
|
|
20
21
|
provider: EthereumProvider,
|
|
21
22
|
artifactManager: ArtifactManager,
|
|
23
|
+
chainDescriptors: ChainDescriptorsConfig,
|
|
24
|
+
networkName: string,
|
|
22
25
|
): HardhatViemHelpers<ChainTypeT> {
|
|
23
26
|
return {
|
|
24
27
|
getPublicClient: (publicClientConfig) =>
|
|
25
|
-
getPublicClient(
|
|
28
|
+
getPublicClient(
|
|
29
|
+
provider,
|
|
30
|
+
chainType,
|
|
31
|
+
chainDescriptors,
|
|
32
|
+
networkName,
|
|
33
|
+
publicClientConfig,
|
|
34
|
+
),
|
|
26
35
|
|
|
27
36
|
getWalletClients: (walletClientConfig) =>
|
|
28
|
-
getWalletClients(
|
|
37
|
+
getWalletClients(
|
|
38
|
+
provider,
|
|
39
|
+
chainType,
|
|
40
|
+
chainDescriptors,
|
|
41
|
+
networkName,
|
|
42
|
+
walletClientConfig,
|
|
43
|
+
),
|
|
29
44
|
|
|
30
45
|
getWalletClient: (address, walletClientConfig) =>
|
|
31
|
-
getWalletClient(
|
|
46
|
+
getWalletClient(
|
|
47
|
+
provider,
|
|
48
|
+
chainType,
|
|
49
|
+
chainDescriptors,
|
|
50
|
+
networkName,
|
|
51
|
+
address,
|
|
52
|
+
walletClientConfig,
|
|
53
|
+
),
|
|
32
54
|
|
|
33
55
|
getTestClient: (testClientConfig) =>
|
|
34
|
-
getTestClient(
|
|
56
|
+
getTestClient(
|
|
57
|
+
provider,
|
|
58
|
+
chainType,
|
|
59
|
+
chainDescriptors,
|
|
60
|
+
networkName,
|
|
61
|
+
testClientConfig,
|
|
62
|
+
),
|
|
35
63
|
|
|
36
64
|
deployContract: (contractName, constructorArgs, deployContractConfig) =>
|
|
37
65
|
deployContract(
|
|
38
66
|
provider,
|
|
39
67
|
artifactManager,
|
|
68
|
+
chainDescriptors,
|
|
69
|
+
networkName,
|
|
40
70
|
contractName,
|
|
41
71
|
constructorArgs,
|
|
42
72
|
deployContractConfig,
|
|
@@ -50,6 +80,8 @@ export function initializeViem<ChainTypeT extends ChainType | string>(
|
|
|
50
80
|
sendDeploymentTransaction(
|
|
51
81
|
provider,
|
|
52
82
|
artifactManager,
|
|
83
|
+
chainDescriptors,
|
|
84
|
+
networkName,
|
|
53
85
|
contractName,
|
|
54
86
|
constructorArgs,
|
|
55
87
|
sendDeploymentTransactionConfig,
|
|
@@ -59,6 +91,8 @@ export function initializeViem<ChainTypeT extends ChainType | string>(
|
|
|
59
91
|
getContractAt(
|
|
60
92
|
provider,
|
|
61
93
|
artifactManager,
|
|
94
|
+
chainDescriptors,
|
|
95
|
+
networkName,
|
|
62
96
|
contractName,
|
|
63
97
|
address,
|
|
64
98
|
getContractAtConfig,
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ArtifactMap,
|
|
3
|
+
StringWithArtifactContractNamesAutocompletion,
|
|
4
|
+
} from "hardhat/types/artifacts";
|
|
2
5
|
import type { ChainType, DefaultChainType } from "hardhat/types/network";
|
|
3
6
|
import type {
|
|
4
7
|
Abi as ViemAbi,
|
|
@@ -82,13 +85,18 @@ export interface HardhatViemHelpers<
|
|
|
82
85
|
* returns the viem's contract instance.
|
|
83
86
|
*
|
|
84
87
|
* @param contractName The name of the contract to deploy. This is required
|
|
85
|
-
* to return the correct contract type.
|
|
88
|
+
* to return the correct contract type. TypeScript's language server
|
|
89
|
+
* autocompletes the names of the contracts that have already been built. If
|
|
90
|
+
* your contract name isn't in the list, you can still use it, and/or run
|
|
91
|
+
* `hardhat build` to get it in the list.
|
|
86
92
|
* @param constructorArgs The arguments to pass to the contract's constructor.
|
|
87
93
|
* @param deployContractConfig A configuration object. See
|
|
88
94
|
* {@link DeployContractConfig} for more details.
|
|
89
95
|
* @returns The deployed contract instance.
|
|
90
96
|
*/
|
|
91
|
-
deployContract: <
|
|
97
|
+
deployContract: <
|
|
98
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
99
|
+
>(
|
|
92
100
|
contractName: ContractName,
|
|
93
101
|
constructorArgs?: ConstructorArgs<ContractName>,
|
|
94
102
|
deployContractConfig?: DeployContractConfig,
|
|
@@ -99,14 +107,19 @@ export interface HardhatViemHelpers<
|
|
|
99
107
|
* The function does not wait for the transaction to be mined.
|
|
100
108
|
*
|
|
101
109
|
* @param contractName The name of the contract to deploy. This is required
|
|
102
|
-
* to return the correct contract type.
|
|
110
|
+
* to return the correct contract type. TypeScript's language server
|
|
111
|
+
* autocompletes the names of the contracts that have already been built. If
|
|
112
|
+
* your contract name isn't in the list, you can still use it, and/or run
|
|
113
|
+
* `hardhat build` to get it in the list.
|
|
103
114
|
* @param constructorArgs The arguments to pass to the contract's constructor.
|
|
104
115
|
* @param sendDeploymentTransactionConfig A configuration object. See
|
|
105
116
|
* {@link SendDeploymentTransactionConfig} for more details.
|
|
106
117
|
* @returns An object containing the deployed contract instance and the
|
|
107
118
|
* deployment transaction.
|
|
108
119
|
*/
|
|
109
|
-
sendDeploymentTransaction: <
|
|
120
|
+
sendDeploymentTransaction: <
|
|
121
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
122
|
+
>(
|
|
110
123
|
contractName: ContractName,
|
|
111
124
|
constructorArgs?: ConstructorArgs<ContractName>,
|
|
112
125
|
sendDeploymentTransactionConfig?: SendDeploymentTransactionConfig,
|
|
@@ -119,13 +132,18 @@ export interface HardhatViemHelpers<
|
|
|
119
132
|
* address.
|
|
120
133
|
*
|
|
121
134
|
* @param contractName The name of the contract to get an instance of. This
|
|
122
|
-
* is required to return the correct contract type.
|
|
135
|
+
* is required to return the correct contract type. TypeScript's language
|
|
136
|
+
* server autocompletes the names of the contracts that have already been
|
|
137
|
+
* built. If your contract name isn't in the list, you can still use it,
|
|
138
|
+
* and/or run `hardhat build` to get it in the list.
|
|
123
139
|
* @param address The address of the contract.
|
|
124
140
|
* @param getContractAtConfig A configuration object. See
|
|
125
141
|
* {@link GetContractAtConfig} for more details.
|
|
126
142
|
* @returns The contract instance.
|
|
127
143
|
*/
|
|
128
|
-
getContractAt: <
|
|
144
|
+
getContractAt: <
|
|
145
|
+
ContractName extends StringWithArtifactContractNamesAutocompletion,
|
|
146
|
+
>(
|
|
129
147
|
contractName: ContractName,
|
|
130
148
|
address: ViemAddress,
|
|
131
149
|
getContractAtConfig?: GetContractAtConfig,
|