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 4296867c67..ae680cb876 100644 --- a/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx @@ -50,6 +50,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) { runTransactions={props.runTransactions} sendValue={props.sendValue} getFuncABIInputs={props.getFuncABIInputs} + plugin={props.plugin} /> ) })} 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 b89a8adb5b..2cdb1f3ef9 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -115,8 +115,25 @@ export function UniversalDappUI(props: UdappProps) { props.removeInstance(props.index) } - const saveContract = () => { - console.log('save is clicked') + const saveContract = async() => { + const address = ethJSUtil.toChecksumAddress(props.instance.address) + const env = await props.plugin.call('blockchain', 'getProvider') + const {network} = await props.plugin.call('blockchain', 'getCurrentNetworkStatus') + const contractToSave = {name: props.instance.contractData.name, address, abi: props.instance.contractData.abi, networkName: network.name} + let savedContracts = localStorage.getItem('savedContracts') + let objToSave = JSON.parse(savedContracts) + if (!objToSave) { + objToSave = {} + objToSave[env] = {} + objToSave[env][network.id] = [] + } else if (!objToSave[env]) { + objToSave[env] = {} + objToSave[env][network.id] = [] + } else if (!objToSave[env][network.id]) { + objToSave[env][network.id] = [] + } + objToSave[env][network.id].push(contractToSave) + localStorage.setItem('savedContracts', JSON.stringify(objToSave)) } const runTransaction = (lookupOnly, funcABI: FuncABI, valArr, inputsValues, funcIndex?: number) => { diff --git a/libs/remix-ui/run-tab/src/lib/run-tab.tsx b/libs/remix-ui/run-tab/src/lib/run-tab.tsx index 9f68cc9944..00c159c6f5 100644 --- a/libs/remix-ui/run-tab/src/lib/run-tab.tsx +++ b/libs/remix-ui/run-tab/src/lib/run-tab.tsx @@ -312,6 +312,7 @@ export function RunTabUI(props: RunTabProps) { currentFile={currentfile} /> void) => void, determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void) => JSX.Element, sendValue: string, getFuncABIInputs: (funcABI: FuncABI) => string + plugin: RunTab } export interface Modal { @@ -418,6 +419,7 @@ export interface UdappProps { funcIndex?: number) => void, sendValue: string, getFuncABIInputs: (funcABI: FuncABI) => string + plugin: RunTab } export interface DeployButtonProps {