From b07a608ee5eec2a1461c47dcad296d11ecd58f6a Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 30 Sep 2022 12:48:21 +0530 Subject: [PATCH 1/4] reset workspace options --- .../workspace/src/lib/remix-ui-workspace.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index ef4ac18ad0..2ed762f877 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -18,6 +18,9 @@ export function Workspace () { const displayOzCustomRef = useRef() const ozFeatures = useRef({mintable: false, burnable: false, pausable: false}) const upgradeable = useRef() + const mintableCheckboxRef = useRef() + const burnableCheckboxRef = useRef() + const pausableCheckboxRef = useRef() const global = useContext(FileSystemContext) const workspaceRenameInput = useRef() const workspaceCreateInput = useRef() @@ -157,6 +160,12 @@ export function Workspace () { displayOzCustomRef.current.style.display = 'block' upgradeable.current = undefined ozFeatures.current = {mintable: false, burnable: false, pausable: false} + // @ts-ignore + mintableCheckboxRef.current.checked = false + // @ts-ignore + burnableCheckboxRef.current.checked = false + // @ts-ignore + pausableCheckboxRef.current.checked = false } else displayOzCustomRef.current.style.display = 'none' // @ts-ignore @@ -212,17 +221,17 @@ export function Workspace () { -
handleFeatures(e)}> +
- + handleFeatures(e)} ref={mintableCheckboxRef} />
- + handleFeatures(e)} ref={burnableCheckboxRef} />
- + handleFeatures(e)} ref={pausableCheckboxRef} />
From 7318b71b3b0d04c971abe8be0e816d9d8d399fd8 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 30 Sep 2022 13:05:10 +0530 Subject: [PATCH 2/4] reset upgradeability radio buttons --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 2ed762f877..0d6e7c3023 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -21,6 +21,8 @@ export function Workspace () { const mintableCheckboxRef = useRef() const burnableCheckboxRef = useRef() const pausableCheckboxRef = useRef() + const transparentRadioRef = useRef() + const uupsRadioRef = useRef() const global = useContext(FileSystemContext) const workspaceRenameInput = useRef() const workspaceCreateInput = useRef() @@ -166,6 +168,10 @@ export function Workspace () { burnableCheckboxRef.current.checked = false // @ts-ignore pausableCheckboxRef.current.checked = false + // @ts-ignore + transparentRadioRef.current.checked = false + // @ts-ignore + uupsRadioRef.current.checked = false } else displayOzCustomRef.current.style.display = 'none' // @ts-ignore @@ -239,11 +245,11 @@ export function Workspace () {
handleUpgradeability(e)}>
- +
- +
From cd09b11463f171edb8a617a6e1c65e135c85db0d Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 30 Sep 2022 14:06:45 +0530 Subject: [PATCH 3/4] clean code --- .../workspace/src/lib/remix-ui-workspace.tsx | 28 ++++++++----------- .../src/templates/ozerc1155/index.ts | 8 +++--- .../src/templates/ozerc20/index.ts | 8 +++--- .../src/templates/ozerc721/index.ts | 8 +++--- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 0d6e7c3023..85367d0bc8 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -16,8 +16,6 @@ export function Workspace () { const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean}>(null) const [showDropdown, setShowDropdown] = useState(false) const displayOzCustomRef = useRef() - const ozFeatures = useRef({mintable: false, burnable: false, pausable: false}) - const upgradeable = useRef() const mintableCheckboxRef = useRef() const burnableCheckboxRef = useRef() const pausableCheckboxRef = useRef() @@ -118,10 +116,15 @@ export function Workspace () { // @ts-ignore: Object is possibly 'null'. const workspaceTemplateName = workspaceCreateTemplateInput.current.value || 'remixDefault' const initGitRepo = initGitRepoRef.current.checked - const features = ozFeatures.current const opts = { - upgradeable: upgradeable.current, - features + // @ts-ignore: Object is possibly 'null'. + mintable: mintableCheckboxRef.current.checked, + // @ts-ignore: Object is possibly 'null'. + burnable: burnableCheckboxRef.current.checked, + // @ts-ignore: Object is possibly 'null'. + pausable: pausableCheckboxRef.current.checked, + // @ts-ignore: Object is possibly 'null'. + upgradeable: transparentRadioRef.current.checked ? transparentRadioRef.current.value : ( uupsRadioRef.current.checked ? uupsRadioRef.current.value : false ) } try { @@ -160,8 +163,6 @@ export function Workspace () { // @ts-ignore if (workspaceCreateTemplateInput.current.value.startsWith('oz') && displayOzCustomRef && displayOzCustomRef.current) { displayOzCustomRef.current.style.display = 'block' - upgradeable.current = undefined - ozFeatures.current = {mintable: false, burnable: false, pausable: false} // @ts-ignore mintableCheckboxRef.current.checked = false // @ts-ignore @@ -193,17 +194,10 @@ export function Workspace () { } const handleUpgradeability = (e) => { - // @ts-ignore - upgradeable.current = e.target.value // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value + '_upgradeable'}_${Date.now()}` } - const handleFeatures = (e) => { - // @ts-ignore - ozFeatures.current[e.target.value] = e.target.checked - } - const createModalMessage = () => { return ( <> @@ -229,15 +223,15 @@ export function Workspace () {
- handleFeatures(e)} ref={mintableCheckboxRef} /> +
- handleFeatures(e)} ref={burnableCheckboxRef} /> +
- handleFeatures(e)} ref={pausableCheckboxRef} /> +
diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts index 4164d91e76..df6a349189 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -1,10 +1,10 @@ import { erc1155 } from '@openzeppelin/wizard'; export default async (opts) => { - if (opts.features) { - erc1155.defaults.mintable = opts.features.mintable - erc1155.defaults.burnable = opts.features.burnable - erc1155.defaults.pausable = opts.features.pausable + if (opts) { + erc1155.defaults.mintable = opts.mintable + erc1155.defaults.burnable = opts.burnable + erc1155.defaults.pausable = opts.pausable } const filesObj = { diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 5eca9475f8..529b11fc13 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -1,10 +1,10 @@ import { erc20 } from '@openzeppelin/wizard'; export default async (opts) => { - if (opts.features) { - erc20.defaults.mintable = opts.features.mintable - erc20.defaults.burnable = opts.features.burnable - erc20.defaults.pausable = opts.features.pausable + if (opts) { + erc20.defaults.mintable = opts.mintable + erc20.defaults.burnable = opts.burnable + erc20.defaults.pausable = opts.pausable } const filesObj = { diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts index 5c7f01293d..12d4d2deb3 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -1,10 +1,10 @@ import { erc721 } from '@openzeppelin/wizard'; export default async (opts) => { - if (opts.features) { - erc721.defaults.mintable = opts.features.mintable - erc721.defaults.burnable = opts.features.burnable - erc721.defaults.pausable = opts.features.pausable + if (opts) { + erc721.defaults.mintable = opts.mintable + erc721.defaults.burnable = opts.burnable + erc721.defaults.pausable = opts.pausable } const filesObj = { From fcf47c86202dfaee00788d7505dc3c01211fe2eb Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 30 Sep 2022 14:23:27 +0530 Subject: [PATCH 4/4] linting fix --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 85367d0bc8..2f9d6589ab 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -193,7 +193,7 @@ export function Workspace () { setShowDropdown(isOpen) } - const handleUpgradeability = (e) => { + const handleUpgradeability = () => { // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value + '_upgradeable'}_${Date.now()}` } @@ -237,7 +237,7 @@ export function Workspace () {
-
handleUpgradeability(e)}> +