Skip to content

Commit

Permalink
delete instead of reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket-Engg committed Dec 20, 2024
1 parent 61194ab commit 13a80fc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
11 changes: 5 additions & 6 deletions apps/remix-dapp/src/locales/en/udapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
"udapp.forkStateLabel": "State Name",
"udapp.forkStateTip": "VM State, forked for current workspace, can be pinned as an environment using Environment Explorer",
"udapp.fork": "Fork",
"udapp.resetVmStateTitle": "Reset VM state",
"udapp.resetVmStateDesc1": "Resetting state of the selected environment will delete all your previously saved transaction details for current workspace.",
"udapp.resetVmStateDesc2": "It will also delete the data for contracts deployed and pinned for this workspace.",
"udapp.resetVmStateDesc3": "Do you want to continue?",
"udapp.reset": "Reset",
"udapp.deleteVmStateTitle": "Delete VM state",
"udapp.deleteVmStateDesc1": "Deleting state of the selected environment will delete all your previously saved transaction details for current workspace.",
"udapp.deleteVmStateDesc2": "It will also delete the data for contracts deployed and pinned for this workspace.",
"udapp.deleteVmStateDesc3": "Do you want to continue?",
"udapp.delete": "Delete",
"udapp.injectedTitle": "Unfortunately it's not possible to create an account using injected provider. Please create the account directly from your provider (i.e metamask or other of the same type).",
"udapp.createNewAccount": "Create a new account",
"udapp.web3Title": "Creating an account is possible only in Personal mode. Please go to Settings to enable it.",
Expand All @@ -72,7 +72,6 @@
"udapp._comment_environment.tsx": "libs/remix-ui/run-tab/src/lib/components/environment.tsx",
"udapp.environment": "Environment",
"udapp.environmentDocs": "Click for docs about Environment",
"udapp.resetVmStateTooltip": "Reset VM state",
"udapp.tooltipText2": "Open chainlist.org and get the connection specs of the chain you want to interact with.",
"udapp.tooltipText3": "Click to open a bridge for converting L1 mainnet ETH to the selected network currency.",

Expand Down
11 changes: 5 additions & 6 deletions apps/remix-ide/src/app/tabs/locales/en/udapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@
"udapp.forkStateLabel": "State Name",
"udapp.forkStateTip": "VM State, forked for current workspace, can be pinned as an environment using Environment Explorer",
"udapp.fork": "Fork",
"udapp.resetVmStateTitle": "Reset VM state",
"udapp.resetVmStateDesc1": "Resetting state of the selected environment will delete all your previously saved transaction details for current workspace.",
"udapp.resetVmStateDesc2": "It will also delete the data for contracts deployed and pinned for this workspace.",
"udapp.resetVmStateDesc3": "Do you want to continue?",
"udapp.deleteVmStateTitle": "Delete VM state",
"udapp.deleteVmStateDesc1": "Deleting state of the selected environment will delete all your previously saved transaction details for current workspace.",
"udapp.deleteVmStateDesc2": "It will also delete the data for contracts deployed and pinned for this workspace.",
"udapp.deleteVmStateDesc3": "Do you want to continue?",
"udapp.delete": "Delete",
"udapp.injectedTitle": "Unfortunately it's not possible to create an account using injected provider. Please create the account directly from your provider (i.e metamask or other of the same type).",
"udapp.createNewAccount": "Create new account",
"udapp.web3Title": "Creating an account is possible only in Personal mode. Please go to Settings to enable it.",
Expand All @@ -71,8 +72,6 @@
"udapp._comment_environment.tsx": "libs/remix-ui/run-tab/src/lib/components/environment.tsx",
"udapp.environment": "Environment",
"udapp.environmentDocs": "Click for docs about Environment",
"udapp.resetVmStateTooltip": "Reset VM state",
"udapp.reset": "Reset",
"udapp.tooltipText2": "Open chainlist.org and get the connection specs of the chain you want to interact with.",
"udapp.tooltipText3": "Click to open a bridge for converting L1 mainnet ETH to the selected network currency.",

Expand Down
24 changes: 12 additions & 12 deletions libs/remix-ui/run-tab/src/lib/components/environment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export function EnvironmentUI(props: EnvironmentProps) {
)
}

const resetVmStatePrompt = () => {
const deleteVmStatePrompt = () => {
return (
<div>
<ul className='ml-3'>
<li><FormattedMessage id="udapp.resetVmStateDesc1"/></li>
<li><FormattedMessage id="udapp.resetVmStateDesc2"/></li>
<li><FormattedMessage id="udapp.deleteVmStateDesc1"/></li>
<li><FormattedMessage id="udapp.deleteVmStateDesc2"/></li>
</ul>
<FormattedMessage id="udapp.resetVmStateDesc3"/>
<FormattedMessage id="udapp.deleteVmStateDesc3"/>
</div>
)
}
Expand Down Expand Up @@ -85,26 +85,26 @@ export function EnvironmentUI(props: EnvironmentProps) {
} else props.runTabPlugin.call('notification', 'toast', `VM state doesn't exist for selected environment.`)
}

const resetVmState = async() => {
const deleteVmState = async() => {
const context = currentProvider.name
const contextExists = await props.runTabPlugin.call('fileManager', 'exists', `.states/${context}/state.json`)
if (contextExists) {
props.modal(
intl.formatMessage({ id: 'udapp.resetVmStateTitle' }),
resetVmStatePrompt(),
intl.formatMessage({ id: 'udapp.reset' }),
intl.formatMessage({ id: 'udapp.deleteVmStateTitle' }),
deleteVmStatePrompt(),
intl.formatMessage({ id: 'udapp.delete' }),
async () => {
const currentProvider = await props.runTabPlugin.call('blockchain', 'getCurrentProvider')
// Reset environment blocks and account data
await currentProvider.resetEnvironment()
// Remove deployed and pinned contracts from UI
props.runTabPlugin.REACT_API.instances.instanceList = []
await props.runTabPlugin.call('udapp', 'clearAllInstances')
// Delete environment state file
await props.runTabPlugin.call('fileManager', 'remove', `.states/${context}/state.json`)
// If there are pinned contracts, delete pinned contracts folder
const isPinnedContracts = await props.runTabPlugin.call('fileManager', 'exists', `.deploys/pinned-contracts/${context}`)
if (isPinnedContracts) await props.runTabPlugin.call('fileManager', 'remove', `.deploys/pinned-contracts/${context}`)
props.runTabPlugin.call('notification', 'toast', `VM state reset successfully.`)
props.runTabPlugin.call('notification', 'toast', `VM state deleted successfully.`)
},
intl.formatMessage({ id: 'udapp.cancel' }),
null
Expand All @@ -130,8 +130,8 @@ export function EnvironmentUI(props: EnvironmentProps) {
{ currentProvider && currentProvider.isVM && isSaveEvmStateChecked && <CustomTooltip placement={'auto-end'} tooltipClasses="text-wrap" tooltipId="forkStatetooltip" tooltipText={<FormattedMessage id="udapp.forkStateTitle" />}>
<i className="udapp_infoDeployAction ml-2 fas fa-code-branch" style={{ cursor: 'pointer' }} onClick={forkState}></i>
</CustomTooltip> }
{ currentProvider && currentProvider.isVM && isSaveEvmStateChecked && <CustomTooltip placement={'auto-end'} tooltipClasses="text-wrap" tooltipId="resetVMStatetooltip" tooltipText={<FormattedMessage id="udapp.resetVmStateTooltip" />}>
<i className="udapp_infoDeployAction ml-2 fas fa-refresh" style={{ cursor: 'pointer' }} onClick={resetVmState}></i>
{ currentProvider && currentProvider.isVM && isSaveEvmStateChecked && <CustomTooltip placement={'auto-end'} tooltipClasses="text-wrap" tooltipId="deleteVMStatetooltip" tooltipText={<FormattedMessage id="udapp.deleteVmStateTitle" />}>
<i className="udapp_infoDeployAction ml-2 fas fa-trash" style={{ cursor: 'pointer' }} onClick={deleteVmState}></i>
</CustomTooltip> }
</label>
<div className="udapp_environment" data-id={`selected-provider-${currentProvider && currentProvider.name}`}>
Expand Down

0 comments on commit 13a80fc

Please sign in to comment.