add saved instantly

pull/5370/head
aniket-engg 9 months ago committed by Aniket
parent 8e4b1f12be
commit f0ce1b703e
  1. 2
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  2. 7
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.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)
}
}
}

@ -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) => {

Loading…
Cancel
Save