allow starting the custom fork with an empty state

pull/5370/head
yann300 2 years ago
parent 9a66d1657e
commit 52a15dbcdc
  1. 10
      apps/remix-ide/src/app/providers/custom-vm-fork-provider.tsx

@ -28,7 +28,7 @@ export class CustomForkVMProvider extends BasicVMProvider {
async init () { async init () {
const body = () => { const body = () => {
return <div> return <div>
<span>Please provide information about the custom fork:</span> <span>Please provide information about the custom fork. If the node URL is not provided, the VM will start with an empty state.</span>
<div> <div>
<label className="mt-3 mb-1">Node URL</label> <label className="mt-3 mb-1">Node URL</label>
<input name="nodeUrl" type="text" className="border form-control border-right-0"></input> <input name="nodeUrl" type="text" className="border form-control border-right-0"></input>
@ -54,7 +54,7 @@ export class CustomForkVMProvider extends BasicVMProvider {
title: this.profile.displayName, title: this.profile.displayName,
message: body(), message: body(),
validationFn: (data: any) => { validationFn: (data: any) => {
if(!data.nodeUrl.startsWith("http")) { if(data.nodeUrl !== '' && !data.nodeUrl.startsWith("http")) {
return { return {
valid: false, valid: false,
message: 'node URL should be a valid URL' message: 'node URL should be a valid URL'
@ -89,8 +89,14 @@ export class CustomForkVMProvider extends BasicVMProvider {
})() })()
this.fork = result.evmType this.fork = result.evmType
this.nodeUrl = result.nodeUrl this.nodeUrl = result.nodeUrl
if (this.nodeUrl) {
const block = result.blockNumber const block = result.blockNumber
this.blockNumber = block === 'latest' ? 'latest' : parseInt(block) this.blockNumber = block === 'latest' ? 'latest' : parseInt(block)
} else {
this.nodeUrl = undefined
this.blockNumber = undefined
}
return { return {
'fork': this.fork, 'fork': this.fork,
'nodeUrl': this.nodeUrl, 'nodeUrl': this.nodeUrl,

Loading…
Cancel
Save