Skip to content

Commit 09f7a3d

Browse files
committed
feat: add openzeppelin example code
1 parent 587eeaa commit 09f7a3d

File tree

3 files changed

+72
-22
lines changed

3 files changed

+72
-22
lines changed

src/components/project/index.tsx

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -337,19 +337,29 @@ const NewProject = () => {
337337
};
338338

339339
const Template = () => {
340-
const { client, template, setTemplate, templates, fetchProjects, compileLoading, deployLoading, activateLoading } =
341-
useStore(
342-
useShallow((state) => ({
343-
client: state.global.client,
344-
template: state.project.template.data,
345-
setTemplate: state.project.setTemplate,
346-
templates: state.project.templates.data,
347-
fetchProjects: state.project.fetchProjects,
348-
compileLoading: state.compile.loading,
349-
deployLoading: state.deploy.loading,
350-
activateLoading: state.activate.loading,
351-
}))
352-
);
340+
const {
341+
client,
342+
template,
343+
setTemplate,
344+
templates,
345+
openzeppelinTemplates,
346+
fetchProjects,
347+
compileLoading,
348+
deployLoading,
349+
activateLoading,
350+
} = useStore(
351+
useShallow((state) => ({
352+
client: state.global.client,
353+
template: state.project.template.data,
354+
setTemplate: state.project.setTemplate,
355+
templates: state.project.templates.data,
356+
openzeppelinTemplates: state.project.openzeppelinTemplates.data,
357+
fetchProjects: state.project.fetchProjects,
358+
compileLoading: state.compile.loading,
359+
deployLoading: state.deploy.loading,
360+
activateLoading: state.activate.loading,
361+
}))
362+
);
353363
const isLoading = compileLoading || deployLoading || activateLoading;
354364

355365
const createTemplate = async () => {
@@ -419,14 +429,26 @@ const Template = () => {
419429
<Form.Label>Select a Template</Form.Label>
420430
<InputGroup>
421431
<Form.Control className="custom-select" as="select" value={template ?? ""} onChange={handleTemplateOnChange}>
422-
{templates &&
423-
templates.map((temp, idx) => {
424-
return (
425-
<option value={temp} key={idx}>
426-
{temp}
427-
</option>
428-
);
429-
})}
432+
<optgroup label="OpenZeppelin Templates">
433+
{openzeppelinTemplates &&
434+
openzeppelinTemplates.map((temp: string, idx: number) => {
435+
return (
436+
<option value={temp} key={`oz-${idx}`}>
437+
{temp}
438+
</option>
439+
);
440+
})}
441+
</optgroup>
442+
<optgroup label="Basic Templates">
443+
{templates &&
444+
templates.map((temp, idx) => {
445+
return (
446+
<option value={temp} key={idx}>
447+
{temp}
448+
</option>
449+
);
450+
})}
451+
</optgroup>
430452
</Form.Control>
431453
<Button
432454
className="relative border-0"

src/zustand/project.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,40 @@ const initial = {
1414
template: {
1515
loading: false,
1616
error: false,
17-
data: "hello-world",
17+
data: "erc20",
1818
},
1919
templates: {
2020
loading: false,
2121
error: false,
2222
data: ["hello-world", "single_call", "vending_machine"],
2323
},
24+
openzeppelinTemplates: {
25+
loading: false,
26+
error: false,
27+
data: [
28+
"erc4626",
29+
"safe-erc20",
30+
"erc721",
31+
"erc1155",
32+
"erc20",
33+
"erc1155-supply",
34+
"vesting-wallet",
35+
"erc20-flash-mint",
36+
"erc721-wrapper",
37+
"erc20-wrapper",
38+
"access-control",
39+
"ownable-two-step",
40+
"erc721-metadata",
41+
"erc721-consecutive",
42+
"erc20-permit",
43+
"ownable",
44+
"ecdsa",
45+
"poseidon",
46+
"erc1155-metadata-uri",
47+
"pedersen",
48+
"merkle-proofs",
49+
],
50+
},
2451
network: {
2552
loading: false,
2653
error: false,

src/zustand/project.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface ProjectState {
66
errorMsg: string | null;
77
name: DataType<string>;
88
templates: DataType<string[]>;
9+
openzeppelinTemplates: DataType<string[]>;
910
template: DataType<string>;
1011
project: DataType<string>;
1112
projects: DataType<string[]>;

0 commit comments

Comments
 (0)