Skip to content

Commit

Permalink
pin and select fork state provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket-Engg committed Dec 20, 2024
1 parent 1ee4248 commit cd9c579
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion apps/remix-dapp/src/locales/en/udapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"udapp.signature": "signature",
"udapp.forkStateTitle": "Fork VM state",
"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.deleteVmStateTitle": "Delete VM state",
"udapp.deleteVmStateDesc1": "Deleting state of the selected environment will delete all your previously saved transaction details for current workspace.",
Expand Down
1 change: 0 additions & 1 deletion apps/remix-ide/src/app/tabs/locales/en/udapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"udapp.signature": "signature",
"udapp.forkStateTitle": "Fork VM state",
"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.deleteVmStateTitle": "Delete VM state",
"udapp.deleteVmStateDesc1": "Deleting state of the selected environment will delete all your previously saved transaction details for current workspace.",
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide/src/app/udapp/run-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class RunTab extends ViewPlugin {

this.on('udapp', 'vmStateForked', async (stateName) => {
await addFVSProvider(`.states/forked_states/${stateName}.json`, 20)
this.emit('providerPinned', stateName)
this.emit('forkStateProviderAdded', stateName)
})

// wallet connect
Expand Down
8 changes: 4 additions & 4 deletions apps/remix-ide/src/blockchain/blockchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,16 @@ export class Blockchain extends Plugin {
_paq.push(['trackEvent', 'blockchain', 'providerPinned', name])
this.emit('providersChanged')
})
// used to pin the provider created from forked state
this.on('udapp', 'providerPinned', (providerName) => {
// used to pin and select newly created forked state provider
this.on('udapp', 'forkStateProviderAdded', (providerName) => {
const name = `vm-fs-${providerName}`
this.emit('shouldAddProvidertoUdapp', name, this.getProviderObjByName(name))
this.pinnedProviders.push(name)
this.call('config', 'setAppParameter', 'settings/pinned-providers', JSON.stringify(this.pinnedProviders))
_paq.push(['trackEvent', 'blockchain', 'providerPinned', name])
this.emit('providersChanged')
this.changeExecutionContext({context: name}, null, null, null)
this.call('notification', 'toast', `VM state ${providerName} forked and selected as current envionment.`)
})

this.on('environmentExplorer', 'providerUnpinned', (name, provider) => {
Expand Down Expand Up @@ -579,8 +581,6 @@ export class Blockchain extends Plugin {

getProviderObjByName(name) {
const allProviders = this.getAllProviders()
console.log('allProviders--->', allProviders)
console.log('allProviders--name->', name)
return allProviders[name]
}

Expand Down
5 changes: 0 additions & 5 deletions libs/remix-ui/run-tab/src/lib/components/environment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export function EnvironmentUI(props: EnvironmentProps) {
className="form-control"
onChange={(e) => vmStateName.current = e.target.value}
/>
<br/>
<div className='text-secondary'>
<b>Tip: </b><FormattedMessage id="udapp.forkStateTip" />
</div>
</div>
)
}
Expand Down Expand Up @@ -77,7 +73,6 @@ export function EnvironmentUI(props: EnvironmentProps) {
currentStateDb.savingTimestamp = Date.now()
await props.runTabPlugin.call('fileManager', 'writeFile', `.states/forked_states/${vmStateName.current}.json`, JSON.stringify(currentStateDb, null, 2))
props.runTabPlugin.emit('vmStateForked', vmStateName.current)
props.runTabPlugin.call('notification', 'toast', `VM state ${vmStateName.current} forked successfully.`)
},
intl.formatMessage({ id: 'udapp.cancel' }),
null
Expand Down

0 comments on commit cd9c579

Please sign in to comment.