Skip to content

Commit aa27484

Browse files
authored
Merge pull request #7104 from NomicFoundation/rename-optimism-chaintype-to-op
Rename `optimism` chaintype to `op`
2 parents ced2371 + ef89be2 commit aa27484

File tree

23 files changed

+51
-45
lines changed

23 files changed

+51
-45
lines changed

.changeset/gorgeous-knives-yawn.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@nomicfoundation/hardhat-viem": patch
3+
"hardhat": patch
4+
---
5+
6+
Rename `optimism` chain type to `op` ([#7085](https://github.com/NomicFoundation/hardhat/issues/7085))

v-next/example-project/hardhat.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,27 @@ const config: HardhatUserConfig = {
116116
networks: {
117117
op: {
118118
type: "http",
119-
chainType: "optimism",
119+
chainType: "op",
120120
url: "https://mainnet.optimism.io/",
121121
accounts: [configVariable("OP_SENDER")],
122122
},
123123
edrOp: {
124124
type: "edr",
125-
chainType: "optimism",
125+
chainType: "op",
126126
chainId: 10,
127127
forking: {
128128
url: "https://mainnet.optimism.io",
129129
},
130130
},
131131
opSepolia: {
132132
type: "http",
133-
chainType: "optimism",
133+
chainType: "op",
134134
url: "https://sepolia.optimism.io",
135135
accounts: [configVariable("OP_SEPOLIA_SENDER")],
136136
},
137137
edrOpSepolia: {
138138
type: "edr",
139-
chainType: "optimism",
139+
chainType: "op",
140140
forking: {
141141
url: "https://sepolia.optimism.io",
142142
},

v-next/example-project/scripts/send-op-tx-viem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async function sendL2Transaction(networkConfigName: string) {
55

66
const { viem, networkConfig } = await network.connect({
77
network: networkConfigName,
8-
chainType: "optimism",
8+
chainType: "op",
99
});
1010

1111
if (networkConfig.type === "edr") {

v-next/example-project/scripts/send-op-tx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { network } from "hardhat";
22

33
const { provider } = await network.connect({
44
network: "op",
5-
chainType: "optimism",
5+
chainType: "op",
66
});
77

88
const accounts = (await provider.request({

v-next/example-project/scripts/viem-plugin-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async function testL2Extensions() {
55
// This network connection has access to an optimism-specific viem api
66
const optimism = await hre.network.connect({
77
network: "localhost",
8-
chainType: "optimism",
8+
chainType: "op",
99
});
1010
const opPublicClient = await optimism.viem.getPublicClient();
1111
const l1BaseFee = await opPublicClient.getL1BaseFee();

v-next/hardhat-viem/src/internal/chains.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function createHardhatChain<ChainTypeT extends ChainType | string>(
190190
id: chainId,
191191
};
192192

193-
if (chainType === "optimism") {
193+
if (chainType === "op") {
194194
// we add the optimism contracts to enable viem's L2 actions
195195
chain.contracts = {
196196
...optimism.contracts,

v-next/hardhat-viem/src/internal/clients.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function getPublicClient<ChainTypeT extends ChainType | string>(
4141
...publicClientConfig,
4242
});
4343

44-
if (chainType === "optimism") {
44+
if (chainType === "op") {
4545
publicClient = publicClient.extend(publicActionsL2());
4646
}
4747

@@ -71,7 +71,7 @@ export async function getWalletClients<ChainTypeT extends ChainType | string>(
7171
}),
7272
);
7373

74-
if (chainType === "optimism") {
74+
if (chainType === "op") {
7575
walletClients = walletClients.map((walletClient) =>
7676
walletClient.extend(walletActionsL2()),
7777
);
@@ -101,7 +101,7 @@ export async function getWalletClient<ChainTypeT extends ChainType | string>(
101101
...walletClientConfig,
102102
});
103103

104-
if (chainType === "optimism") {
104+
if (chainType === "op") {
105105
walletClient = walletClient.extend(walletActionsL2());
106106
}
107107

v-next/hardhat-viem/src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface HardhatViemHelpers<
3535
* @param publicClientConfig A viem's PublicClientConfig object with the
3636
* desired configuration.
3737
* @returns The configured public client. If the connection's chainType is
38-
* "optimism", the client will be extended with L2 actions.
38+
* "op", the client will be extended with L2 actions.
3939
*/
4040
getPublicClient: (
4141
publicClientConfig?: Partial<ViemPublicClientConfig>,
@@ -47,7 +47,7 @@ export interface HardhatViemHelpers<
4747
* @param walletClientConfig A viem's WalletClientConfig object with the
4848
* desired configuration.
4949
* @returns An array with the configured wallet clients. If the connection's
50-
* chainType is "optimism", the clients will be extended with L2 actions.
50+
* chainType is "op", the clients will be extended with L2 actions.
5151
*/
5252
getWalletClients: (
5353
walletClientConfig?: Partial<ViemWalletClientConfig>,
@@ -60,7 +60,7 @@ export interface HardhatViemHelpers<
6060
* @param walletClientConfig A viem's WalletClientConfig object with the
6161
* desired configuration.
6262
* @returns The configured wallet client for the specified address. If the
63-
* connection's chainType is "optimism", the client will be extended with L2
63+
* connection's chainType is "op", the client will be extended with L2
6464
* actions.
6565
*/
6666
getWalletClient: (
@@ -133,10 +133,10 @@ export interface HardhatViemHelpers<
133133
}
134134

135135
export type GetPublicClientReturnType<ChainTypeT extends ChainType | string> =
136-
ChainTypeT extends "optimism" ? OpPublicClient : PublicClient;
136+
ChainTypeT extends "op" ? OpPublicClient : PublicClient;
137137

138138
export type GetWalletClientReturnType<ChainTypeT extends ChainType | string> =
139-
ChainTypeT extends "optimism" ? OpWalletClient : WalletClient;
139+
ChainTypeT extends "op" ? OpWalletClient : WalletClient;
140140

141141
export type PublicClient = ViemPublicClient<ViemTransport, ViemChain>;
142142

v-next/hardhat-viem/test/clients.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("clients", () => {
4646

4747
it("should return a public client extended with L2 actions for Optimism", async () => {
4848
const provider = new MockEthereumProvider({ eth_chainId: "0xa" }); // optimism
49-
const client = await getPublicClient(provider, "optimism");
49+
const client = await getPublicClient(provider, "op");
5050

5151
assert.equal(client.type, "publicClient");
5252
assert.equal(client.chain.id, 10);
@@ -126,7 +126,7 @@ describe("clients", () => {
126126
eth_chainId: "0xa", // optimism
127127
eth_accounts: ["0x123", "0x456"],
128128
});
129-
const clients = await getWalletClients(provider, "optimism");
129+
const clients = await getWalletClients(provider, "op");
130130

131131
assert.ok(Array.isArray(clients), "should return an array of clients");
132132
assert.equal(
@@ -248,7 +248,7 @@ describe("clients", () => {
248248
const provider = new MockEthereumProvider({
249249
eth_chainId: "0xa", // optimism
250250
});
251-
const client = await getWalletClient(provider, "optimism", "0x123");
251+
const client = await getWalletClient(provider, "op", "0x123");
252252

253253
assert.equal(client.type, "walletClient");
254254
assert.equal(client.chain.id, 10);
@@ -317,7 +317,7 @@ describe("clients", () => {
317317
eth_chainId: "0xa", // optimism
318318
eth_accounts: ["0x123", "0x456"],
319319
});
320-
const client = await getDefaultWalletClient(provider, "optimism");
320+
const client = await getDefaultWalletClient(provider, "op");
321321

322322
assert.equal(client.type, "walletClient");
323323
assert.equal(client.chain.id, 10);
@@ -503,14 +503,14 @@ describe("clients", () => {
503503
networks: {
504504
edrOptimism: {
505505
type: "edr",
506-
chainType: "optimism",
506+
chainType: "op",
507507
},
508508
},
509509
});
510510

511511
const { viem } = await hre.network.connect({
512512
network: "edrOptimism",
513-
chainType: "optimism",
513+
chainType: "op",
514514
});
515515
const publicClient = await viem.getPublicClient();
516516
const [senderClient] = await viem.getWalletClients();

v-next/hardhat-viem/test/contracts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe("contracts", () => {
186186
edrOptimism: {
187187
type: "edr",
188188
chainId: 10,
189-
chainType: "optimism",
189+
chainType: "op",
190190
forking: {
191191
url: "https://mainnet.optimism.io",
192192
},
@@ -199,7 +199,7 @@ describe("contracts", () => {
199199

200200
const networkConnection = await hre.network.connect({
201201
network: "edrOptimism",
202-
chainType: "optimism",
202+
chainType: "op",
203203
});
204204
const contract = await networkConnection.viem.deployContract(
205205
"WithoutConstructorArgs",

0 commit comments

Comments
 (0)