@@ -6,11 +6,12 @@ import { packageManagers } from "../../../utils/packageManager.js";
6
6
import { isPrivateKey } from "../../../utils/validators.js" ;
7
7
import { askForTemplate , setupTemplate , askForPackageManager , successfulMessage , getUniqueValues } from "../utils.js" ;
8
8
9
+ import type { PackageManagerType } from "../../../utils/packageManager.js" ;
9
10
import type { GenericTemplate } from "../index.js" ;
10
11
11
- type Template = GenericTemplate & {
12
- framework : "Hardhat" ;
13
- ethereumFramework : "Ethers v5" | "Ethers v6" ;
12
+ export type Template = GenericTemplate & {
13
+ framework : "Hardhat" | "Foundry" ;
14
+ ethereumFramework : "Ethers v5" | "Ethers v6" | "Solidity" ;
14
15
language : "Solidity" | "Vyper" ;
15
16
} ;
16
17
@@ -60,8 +61,69 @@ export const templates: Template[] = [
60
61
path : "templates/quickstart/hardhat/paymaster" ,
61
62
git : "https://github.com/matter-labs/zksync-contract-templates/" ,
62
63
} ,
64
+ {
65
+ name : "Quickstart - Foundry" ,
66
+ value : "qs-fs-hello-zksync" ,
67
+ framework : "Foundry" ,
68
+ ethereumFramework : "Solidity" ,
69
+ language : "Solidity" ,
70
+ path : "templates/quickstart/foundry/hello-zksync" ,
71
+ git : "https://github.com/matter-labs/zksync-contract-templates/" ,
72
+ } ,
73
+ {
74
+ name : "Quickstart - Foundry" ,
75
+ value : "qs-fs-factories" ,
76
+ framework : "Foundry" ,
77
+ ethereumFramework : "Solidity" ,
78
+ language : "Solidity" ,
79
+ path : "templates/quickstart/foundry/factory" ,
80
+ git : "https://github.com/matter-labs/zksync-contract-templates/" ,
81
+ } ,
82
+ {
83
+ name : "Quickstart - Foundry" ,
84
+ value : "qs-fs-testing" ,
85
+ framework : "Foundry" ,
86
+ ethereumFramework : "Solidity" ,
87
+ language : "Solidity" ,
88
+ path : "templates/quickstart/foundry/testing" ,
89
+ git : "https://github.com/matter-labs/zksync-contract-templates/" ,
90
+ } ,
63
91
] ;
64
92
93
+ const logFoundryInfo = ( ) => {
94
+ const contractsDir = "/src" ;
95
+ const deploymentScriptsDir = "/script" ;
96
+ const tipMessage =
97
+ "- Tip: You can use the " + chalk . blueBright ( "--rpc-url" ) + " option to specify the network to deploy to." ;
98
+ const deployCommand = `- Deploy your contract: ${ chalk . blueBright ( "forge script [OPTIONS] <PATH> [ARGS] --zksync" ) } ` ;
99
+ const directoryOverview = `${ chalk . magentaBright ( "Directory Overview:" ) }
100
+ - Contracts: ${ contractsDir }
101
+ - Deployment Scripts: ${ deploymentScriptsDir } ` ;
102
+ const commandsOverview = `${ chalk . magentaBright ( "Commands:" ) }
103
+ - Compile your contracts: ${ chalk . blueBright ( "forge build --zksync" ) }
104
+ ${ deployCommand }
105
+ ${ tipMessage } ` ;
106
+
107
+ Logger . info ( `${ directoryOverview } \n\n${ commandsOverview } ` ) ;
108
+ } ;
109
+
110
+ const logHardhatInfo = ( packageManager : PackageManagerType ) => {
111
+ const contractsDir = "/contracts" ;
112
+ const deploymentScriptsDir = "/deploy" ;
113
+ const tipMessage =
114
+ "- Tip: You can use the " + chalk . blueBright ( "--network" ) + " option to specify the network to deploy to." ;
115
+ const deployCommand = `- Deploy your contract: ${ chalk . blueBright ( packageManagers [ packageManager ] . run ( "deploy" ) ) } ` ;
116
+ const directoryOverview = `${ chalk . magentaBright ( "Directory Overview:" ) }
117
+ - Contracts: ${ contractsDir }
118
+ - Deployment Scripts: ${ deploymentScriptsDir } ` ;
119
+ const commandsOverview = `${ chalk . magentaBright ( "Commands:" ) }
120
+ - Compile your contracts: ${ chalk . blueBright ( packageManagers [ packageManager ] . run ( "compile" ) ) }
121
+ ${ deployCommand }
122
+ ${ tipMessage } ` ;
123
+
124
+ Logger . info ( `${ directoryOverview } \n\n${ commandsOverview } ` ) ;
125
+ } ;
126
+
65
127
export default async ( folderLocation : string , folderRelativePath : string , templateKey ?: string ) => {
66
128
let env : Record < string , string > = { } ;
67
129
let template : Template ;
@@ -99,17 +161,17 @@ export default async (folderLocation: string, folderRelativePath: string, templa
99
161
...env ,
100
162
WALLET_PRIVATE_KEY : privateKey ,
101
163
} ;
102
- const packageManager = await askForPackageManager ( ) ;
103
- await setupTemplate ( template , folderLocation , env , packageManager ) ;
104
-
105
- successfulMessage . start ( folderRelativePath ) ;
106
- Logger . info ( ` ${ chalk . magentaBright ( "Directory Overview:" ) }
107
- - Contracts: /contracts
108
- - Deployment Scripts: /deploy
109
-
110
- ${ chalk . magentaBright ( "Commands:" ) }
111
- - Compile your contracts: ${ chalk . blueBright ( packageManagers [ packageManager ] . run ( "compile" ) ) }
112
- - Deploy your contract: ${ chalk . blueBright ( packageManagers [ packageManager ] . run ( "deploy" ) ) }
113
- - Tip: You can use the ${ chalk . blueBright ( "--network" ) } option to specify the network to deploy to.` ) ;
114
- successfulMessage . end ( folderRelativePath ) ;
164
+ let packageManager : PackageManagerType | undefined ;
165
+ if ( template . framework === "Foundry" ) {
166
+ await setupTemplate ( template , folderLocation , env ) ;
167
+ successfulMessage . start ( folderRelativePath ) ;
168
+ logFoundryInfo ( ) ;
169
+ successfulMessage . end ( folderRelativePath ) ;
170
+ } else {
171
+ packageManager = await askForPackageManager ( ) ;
172
+ await setupTemplate ( template , folderLocation , env , packageManager ) ;
173
+ successfulMessage . start ( folderRelativePath ) ;
174
+ logHardhatInfo ( packageManager ) ;
175
+ successfulMessage . end ( folderRelativePath ) ;
176
+ }
115
177
} ;
0 commit comments