load dirName from state

pull/5370/head
aniket-engg 7 months ago committed by Aniket
parent c8a44841d1
commit 87a5ada979
  1. 3
      libs/remix-ui/run-tab/src/lib/actions/events.ts
  2. 18
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

@ -167,10 +167,7 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => {
} }
const loadPinnedContracts = async (plugin, dispatch, dirName) => { const loadPinnedContracts = async (plugin, dispatch, dirName) => {
console.log('loadPinnedContracts---->')
await plugin.call('udapp', 'clearAllPinnedInstances') await plugin.call('udapp', 'clearAllPinnedInstances')
// const { network } = await plugin.call('blockchain', 'getCurrentNetworkStatus')
// const dirName = plugin.REACT_API.networkName === 'VM' ? plugin.REACT_API.selectExEnv : network.id
const isPinnedAvailable = await plugin.call('fileManager', 'exists', `.deploys/pinned-contracts/${dirName}`) const isPinnedAvailable = await plugin.call('fileManager', 'exists', `.deploys/pinned-contracts/${dirName}`)
if (isPinnedAvailable) { if (isPinnedAvailable) {
try { try {

@ -113,13 +113,7 @@ export function UniversalDappUI(props: UdappProps) {
} }
const unsavePinnedContract = async () => { const unsavePinnedContract = async () => {
let dirName await props.plugin.call('fileManager', 'remove', `.deploys/pinned-contracts/${props.plugin.REACT_API.chainId}/${props.instance.address}.json`)
if (props.plugin.REACT_API.networkName === 'VM') dirName = props.plugin.REACT_API.selectExEnv
else {
const {network} = await props.plugin.call('blockchain', 'getCurrentNetworkStatus')
dirName = network.id
}
await props.plugin.call('fileManager', 'remove', `.deploys/pinned-contracts/${dirName}/${props.instance.address}.json`)
} }
const remove = async() => { const remove = async() => {
@ -145,16 +139,10 @@ export function UniversalDappUI(props: UdappProps) {
filePath: props.instance.filePath || `${workspace.name}/${props.instance.contractData.contract.file}`, filePath: props.instance.filePath || `${workspace.name}/${props.instance.contractData.contract.file}`,
pinnedAt: Date.now() pinnedAt: Date.now()
} }
let dirName await props.plugin.call('fileManager', 'writeFile', `.deploys/pinned-contracts/${props.plugin.REACT_API.chainId}/${props.instance.address}.json`, JSON.stringify(objToSave, null, 2))
if (props.plugin.REACT_API.networkName === 'VM') dirName = props.plugin.REACT_API.selectExEnv
else {
const {network} = await props.plugin.call('blockchain', 'getCurrentNetworkStatus')
dirName = network.id
}
await props.plugin.call('fileManager', 'writeFile', `.deploys/pinned-contracts/${dirName}/${props.instance.address}.json`, JSON.stringify(objToSave, null, 2))
// Add contract to saved contracts list on UI // Add contract to saved contracts list on UI
await props.plugin.call('udapp', 'addPinnedInstance', objToSave.address, objToSave.abi, objToSave.name, objToSave.pinnedAt, objToSave.filePath) await props.plugin.call('udapp', 'addPinnedInstance', objToSave.address, objToSave.abi, objToSave.name, objToSave.pinnedAt, objToSave.filePath)
_paq.push(['trackEvent', 'udapp', 'pinContracts', `pinned at ${dirName}`]) _paq.push(['trackEvent', 'udapp', 'pinContracts', `pinned at ${props.plugin.REACT_API.chainId}`])
// Remove contract from deployed contracts list on UI // Remove contract from deployed contracts list on UI
props.removeInstance(props.index, false, false) props.removeInstance(props.index, false, false)
} }

Loading…
Cancel
Save