save data in localhost

pull/5370/head
aniket-engg 1 year ago committed by Aniket
parent 3230c53bc7
commit 9a6e75acc8
  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} runTransactions={props.runTransactions}
sendValue={props.sendValue} sendValue={props.sendValue}
getFuncABIInputs={props.getFuncABIInputs} getFuncABIInputs={props.getFuncABIInputs}
plugin={props.plugin}
/> />
) )
})} })}

@ -115,8 +115,25 @@ export function UniversalDappUI(props: UdappProps) {
props.removeInstance(props.index) props.removeInstance(props.index)
} }
const saveContract = () => { const saveContract = async() => {
console.log('save is clicked') 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) => { const runTransaction = (lookupOnly, funcABI: FuncABI, valArr, inputsValues, funcIndex?: number) => {

@ -312,6 +312,7 @@ export function RunTabUI(props: RunTabProps) {
currentFile={currentfile} currentFile={currentfile}
/> />
<InstanceContainerUI <InstanceContainerUI
plugin={plugin}
instances={runTab.instances} instances={runTab.instances}
clearInstances={removeInstances} clearInstances={removeInstances}
removeInstance={removeSingleInstance} 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, 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, sendValue: string,
getFuncABIInputs: (funcABI: FuncABI) => string getFuncABIInputs: (funcABI: FuncABI) => string
plugin: RunTab
} }
export interface Modal { export interface Modal {
@ -418,6 +419,7 @@ export interface UdappProps {
funcIndex?: number) => void, funcIndex?: number) => void,
sendValue: string, sendValue: string,
getFuncABIInputs: (funcABI: FuncABI) => string getFuncABIInputs: (funcABI: FuncABI) => string
plugin: RunTab
} }
export interface DeployButtonProps { export interface DeployButtonProps {

Loading…
Cancel
Save