Skip to content

Commit

Permalink
feat: add ethers6 templates (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 authored Jan 13, 2024
1 parent 033b105 commit 56af4f5
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
39 changes: 36 additions & 3 deletions src/commands/create/groups/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import inquirer from "inquirer";
import Logger from "../../../utils/logger.js";
import { packageManagers } from "../../../utils/packageManager.js";
import { isPrivateKey } from "../../../utils/validators.js";
import { askForTemplate, setupTemplate, askForPackageManager, successfulMessage } from "../utils.js";
import { askForTemplate, setupTemplate, askForPackageManager, successfulMessage, getUniqueValues } from "../utils.js";

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

type Template = GenericTemplate & {
framework: "Hardhat";
ethereumFramework: "Ethers v5" | "Ethers v6";
language: "Solidity" | "Vyper";
};

Expand All @@ -18,6 +19,7 @@ export const templates: Template[] = [
name: "Hardhat + Solidity",
value: "hardhat_solidity",
framework: "Hardhat",
ethereumFramework: "Ethers v6",
language: "Solidity",
path: "templates/hardhat/solidity",
git: "https://github.com/matter-labs/zksync-contract-templates/",
Expand All @@ -26,16 +28,47 @@ export const templates: Template[] = [
name: "Hardhat + Vyper",
value: "hardhat_vyper",
framework: "Hardhat",
ethereumFramework: "Ethers v6",
language: "Vyper",
path: "templates/hardhat/vyper",
git: "https://github.com/matter-labs/zksync-contract-templates/",
},
{
name: "Hardhat + Solidity",
value: "hardhat_solidity",
framework: "Hardhat",
ethereumFramework: "Ethers v5",
language: "Solidity",
path: "templates/hardhat_ethers5/solidity",
git: "https://github.com/matter-labs/zksync-contract-templates/",
},
{
name: "Hardhat + Vyper",
value: "hardhat_vyper",
framework: "Hardhat",
ethereumFramework: "Ethers v5",
language: "Vyper",
path: "templates/hardhat_ethers5/vyper",
git: "https://github.com/matter-labs/zksync-contract-templates/",
},
];

export default async (folderLocation: string, folderRelativePath: string, templateKey?: string) => {
let env: Record<string, string> = {};
const template = templateKey ? templates.find((e) => e.value === templateKey)! : await askForTemplate(templates);
if (templateKey) {
let template: Template;
if (!templateKey) {
const { ethereumFramework }: { ethereumFramework: Template["ethereumFramework"] } = await inquirer.prompt([
{
message: "Ethereum framework",
name: "ethereumFramework",
type: "list",
choices: getUniqueValues(templates.map((template) => template.ethereumFramework)),
required: true,
},
]);
template = await askForTemplate(templates.filter((template) => template.ethereumFramework === ethereumFramework));
} else {
template = templates.find((e) => e.value === templateKey)!;
Logger.info(`Using ${chalk.magentaBright(template.name)} template`);
}
const { privateKey }: { privateKey: string } = await inquirer.prompt([
Expand Down
34 changes: 33 additions & 1 deletion src/commands/create/groups/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { GenericTemplate } from "../index.js";

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

Expand All @@ -32,6 +32,14 @@ export const templates: Template[] = [
path: "templates/vue/nuxt3-wagmi-web3modal",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v6",
value: "vue_nuxt3_ethers6",
framework: "Vue - Nuxt 3",
ethereumFramework: "Ethers v6",
path: "templates/vue/nuxt3-ethers",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v5",
value: "vue_nuxt3_ethers5",
Expand Down Expand Up @@ -59,6 +67,14 @@ export const templates: Template[] = [
path: "templates/vue/vite-wagmi-web3modal",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v6",
value: "vue_vite_ethers6",
framework: "Vue - Vite",
ethereumFramework: "Ethers v6",
path: "templates/vue/vite-ethers",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v5",
value: "vue_vite_ethers5",
Expand Down Expand Up @@ -95,6 +111,14 @@ export const templates: Template[] = [
path: "templates/react/next-wagmi-rainbowkit",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v6",
value: "react_next_ethers6",
framework: "React - Next.js",
ethereumFramework: "Ethers v6",
path: "templates/react/next-ethers",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v5",
value: "react_next_ethers5",
Expand Down Expand Up @@ -122,6 +146,14 @@ export const templates: Template[] = [
path: "templates/react/vite-wagmi-web3modal",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v6",
value: "react_vite_ethers6",
framework: "React - Vite",
ethereumFramework: "Ethers v6",
path: "templates/react/vite-ethers",
git: "https://github.com/matter-labs/zksync-frontend-templates",
},
{
name: "Ethers v5",
value: "react_vite_ethers5",
Expand Down
10 changes: 9 additions & 1 deletion src/commands/create/groups/scripting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { GenericTemplate } from "../index.js";

type Template = GenericTemplate & {
framework: "Node.js";
ethereumFramework: "Ethers v5" | "viem";
ethereumFramework: "Ethers v5" | "Ethers v6" | "viem";
};

export const templates: Template[] = [
Expand All @@ -20,6 +20,14 @@ export const templates: Template[] = [
path: "templates/nodejs/viem",
git: "https://github.com/matter-labs/zksync-scripting-templates",
},
{
name: "Ethers v6 - Node.js",
value: "node_ethers6",
framework: "Node.js",
ethereumFramework: "Ethers v6",
path: "templates/nodejs/ethers",
git: "https://github.com/matter-labs/zksync-scripting-templates",
},
{
name: "Ethers v5 - Node.js",
value: "node_ethers5",
Expand Down

0 comments on commit 56af4f5

Please sign in to comment.