Skip to content

Commit 56af4f5

Browse files
authored
feat: add ethers6 templates (#113)
1 parent 033b105 commit 56af4f5

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed

src/commands/create/groups/contracts.ts

+36-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import inquirer from "inquirer";
44
import Logger from "../../../utils/logger.js";
55
import { packageManagers } from "../../../utils/packageManager.js";
66
import { isPrivateKey } from "../../../utils/validators.js";
7-
import { askForTemplate, setupTemplate, askForPackageManager, successfulMessage } from "../utils.js";
7+
import { askForTemplate, setupTemplate, askForPackageManager, successfulMessage, getUniqueValues } from "../utils.js";
88

99
import type { GenericTemplate } from "../index.js";
1010

1111
type Template = GenericTemplate & {
1212
framework: "Hardhat";
13+
ethereumFramework: "Ethers v5" | "Ethers v6";
1314
language: "Solidity" | "Vyper";
1415
};
1516

@@ -18,6 +19,7 @@ export const templates: Template[] = [
1819
name: "Hardhat + Solidity",
1920
value: "hardhat_solidity",
2021
framework: "Hardhat",
22+
ethereumFramework: "Ethers v6",
2123
language: "Solidity",
2224
path: "templates/hardhat/solidity",
2325
git: "https://github.com/matter-labs/zksync-contract-templates/",
@@ -26,16 +28,47 @@ export const templates: Template[] = [
2628
name: "Hardhat + Vyper",
2729
value: "hardhat_vyper",
2830
framework: "Hardhat",
31+
ethereumFramework: "Ethers v6",
2932
language: "Vyper",
3033
path: "templates/hardhat/vyper",
3134
git: "https://github.com/matter-labs/zksync-contract-templates/",
3235
},
36+
{
37+
name: "Hardhat + Solidity",
38+
value: "hardhat_solidity",
39+
framework: "Hardhat",
40+
ethereumFramework: "Ethers v5",
41+
language: "Solidity",
42+
path: "templates/hardhat_ethers5/solidity",
43+
git: "https://github.com/matter-labs/zksync-contract-templates/",
44+
},
45+
{
46+
name: "Hardhat + Vyper",
47+
value: "hardhat_vyper",
48+
framework: "Hardhat",
49+
ethereumFramework: "Ethers v5",
50+
language: "Vyper",
51+
path: "templates/hardhat_ethers5/vyper",
52+
git: "https://github.com/matter-labs/zksync-contract-templates/",
53+
},
3354
];
3455

3556
export default async (folderLocation: string, folderRelativePath: string, templateKey?: string) => {
3657
let env: Record<string, string> = {};
37-
const template = templateKey ? templates.find((e) => e.value === templateKey)! : await askForTemplate(templates);
38-
if (templateKey) {
58+
let template: Template;
59+
if (!templateKey) {
60+
const { ethereumFramework }: { ethereumFramework: Template["ethereumFramework"] } = await inquirer.prompt([
61+
{
62+
message: "Ethereum framework",
63+
name: "ethereumFramework",
64+
type: "list",
65+
choices: getUniqueValues(templates.map((template) => template.ethereumFramework)),
66+
required: true,
67+
},
68+
]);
69+
template = await askForTemplate(templates.filter((template) => template.ethereumFramework === ethereumFramework));
70+
} else {
71+
template = templates.find((e) => e.value === templateKey)!;
3972
Logger.info(`Using ${chalk.magentaBright(template.name)} template`);
4073
}
4174
const { privateKey }: { privateKey: string } = await inquirer.prompt([

src/commands/create/groups/frontend.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { GenericTemplate } from "../index.js";
99

1010
type Template = GenericTemplate & {
1111
framework: "Vue - Nuxt 3" | "Vue - Vite" | "React - Next.js" | "React - Vite";
12-
ethereumFramework: "Ethers v5" | "viem";
12+
ethereumFramework: "Ethers v5" | "Ethers v6" | "viem";
1313
requiresWalletConnectProjectId?: boolean;
1414
};
1515

@@ -32,6 +32,14 @@ export const templates: Template[] = [
3232
path: "templates/vue/nuxt3-wagmi-web3modal",
3333
git: "https://github.com/matter-labs/zksync-frontend-templates",
3434
},
35+
{
36+
name: "Ethers v6",
37+
value: "vue_nuxt3_ethers6",
38+
framework: "Vue - Nuxt 3",
39+
ethereumFramework: "Ethers v6",
40+
path: "templates/vue/nuxt3-ethers",
41+
git: "https://github.com/matter-labs/zksync-frontend-templates",
42+
},
3543
{
3644
name: "Ethers v5",
3745
value: "vue_nuxt3_ethers5",
@@ -59,6 +67,14 @@ export const templates: Template[] = [
5967
path: "templates/vue/vite-wagmi-web3modal",
6068
git: "https://github.com/matter-labs/zksync-frontend-templates",
6169
},
70+
{
71+
name: "Ethers v6",
72+
value: "vue_vite_ethers6",
73+
framework: "Vue - Vite",
74+
ethereumFramework: "Ethers v6",
75+
path: "templates/vue/vite-ethers",
76+
git: "https://github.com/matter-labs/zksync-frontend-templates",
77+
},
6278
{
6379
name: "Ethers v5",
6480
value: "vue_vite_ethers5",
@@ -95,6 +111,14 @@ export const templates: Template[] = [
95111
path: "templates/react/next-wagmi-rainbowkit",
96112
git: "https://github.com/matter-labs/zksync-frontend-templates",
97113
},
114+
{
115+
name: "Ethers v6",
116+
value: "react_next_ethers6",
117+
framework: "React - Next.js",
118+
ethereumFramework: "Ethers v6",
119+
path: "templates/react/next-ethers",
120+
git: "https://github.com/matter-labs/zksync-frontend-templates",
121+
},
98122
{
99123
name: "Ethers v5",
100124
value: "react_next_ethers5",
@@ -122,6 +146,14 @@ export const templates: Template[] = [
122146
path: "templates/react/vite-wagmi-web3modal",
123147
git: "https://github.com/matter-labs/zksync-frontend-templates",
124148
},
149+
{
150+
name: "Ethers v6",
151+
value: "react_vite_ethers6",
152+
framework: "React - Vite",
153+
ethereumFramework: "Ethers v6",
154+
path: "templates/react/vite-ethers",
155+
git: "https://github.com/matter-labs/zksync-frontend-templates",
156+
},
125157
{
126158
name: "Ethers v5",
127159
value: "react_vite_ethers5",

src/commands/create/groups/scripting.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { GenericTemplate } from "../index.js";
88

99
type Template = GenericTemplate & {
1010
framework: "Node.js";
11-
ethereumFramework: "Ethers v5" | "viem";
11+
ethereumFramework: "Ethers v5" | "Ethers v6" | "viem";
1212
};
1313

1414
export const templates: Template[] = [
@@ -20,6 +20,14 @@ export const templates: Template[] = [
2020
path: "templates/nodejs/viem",
2121
git: "https://github.com/matter-labs/zksync-scripting-templates",
2222
},
23+
{
24+
name: "Ethers v6 - Node.js",
25+
value: "node_ethers6",
26+
framework: "Node.js",
27+
ethereumFramework: "Ethers v6",
28+
path: "templates/nodejs/ethers",
29+
git: "https://github.com/matter-labs/zksync-scripting-templates",
30+
},
2331
{
2432
name: "Ethers v5 - Node.js",
2533
value: "node_ethers5",

0 commit comments

Comments
 (0)