diff --git a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx index 8c5b8420f6..a13e0efe5d 100644 --- a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx @@ -19,7 +19,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) { if (savedContracts[env] && savedContracts[env][network.id]) { const instances = savedContracts[env][network.id] for (const inst of instances) - await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name) + if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name) } } } diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 6824036baa..214ed40ca4 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -117,9 +117,8 @@ export function UniversalDappUI(props: UdappProps) { const {network} = await props.plugin.call('blockchain', 'getCurrentNetworkStatus') const savedContracts = localStorage.getItem('savedContracts') const savedContractsJson = JSON.parse(savedContracts) - const instanceIndex = savedContractsJson[env][network.id].findIndex(instance => instance.address === props.instance.address) + const instanceIndex = savedContractsJson[env][network.id].findIndex(instance => instance && instance.address === props.instance.address) delete savedContractsJson[env][network.id][instanceIndex] - savedContractsJson[env][network.id].filter(Boolean) // To remove null entries localStorage.setItem('savedContracts', JSON.stringify(savedContractsJson)) } props.removeInstance(props.index, props.isSavedContract) @@ -145,6 +144,10 @@ export function UniversalDappUI(props: UdappProps) { } objToSave[env][network.id].push(props.instance) localStorage.setItem('savedContracts', JSON.stringify(objToSave)) + // Add contract to saved contracts list on UI + await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.contractData.abi, props.instance.name) + // Remove contract from deployed contracts list on UI + props.removeInstance(props.index, false) } const runTransaction = (lookupOnly, funcABI: FuncABI, valArr, inputsValues, funcIndex?: number) => {