save data in localhost

pull/4538/head
aniket-engg 9 months ago committed by Aniket
parent d6e8046339
commit f6487af5dd
  1. 1
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  2. 21
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  3. 1
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  4. 2
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -50,6 +50,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
runTransactions={props.runTransactions}
sendValue={props.sendValue}
getFuncABIInputs={props.getFuncABIInputs}
plugin={props.plugin}
/>
)
})}

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

@ -312,6 +312,7 @@ export function RunTabUI(props: RunTabProps) {
currentFile={currentfile}
/>
<InstanceContainerUI
plugin={plugin}
instances={runTab.instances}
clearInstances={removeInstances}
removeInstance={removeSingleInstance}

@ -316,6 +316,7 @@ export interface InstanceContainerProps {
mainnetPrompt: (tx: Tx, network: Network, amount: string, gasEstimation: string, gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => 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 {

Loading…
Cancel
Save