draft commit

pull/5370/head
aniket-engg 8 months ago committed by Aniket
parent 0671981056
commit 25482fd95b
  1. 9
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  2. 11
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

@ -36,10 +36,15 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
// Clear existing saved instance state
await props.plugin.call('udapp', 'clearAllSavedInstances')
// Load contracts from FE
const isPinnedAvailable = await props.plugin.call('fileManager', 'exists', `.deploys/pinned-contracts/${chainId.current}`)
const dirName = props.plugin.REACT_API.networkName === 'VM' ? props.plugin.REACT_API.selectExEnv : chainId.current
console.log('dirPath=====>', `.deploys/pinned-contracts/${dirName}`)
const currentWorkspace = await props.plugin.call('filePanel', 'getCurrentWorkspace')
console.log('currentWorkspace=====>', currentWorkspace)
const isPinnedAvailable = await props.plugin.call('fileManager', 'exists', `.workspaces/${currentWorkspace}/.deploys/pinned-contracts/${dirName}`)
console.log('isPinnedAvailable=====>', isPinnedAvailable)
if (isPinnedAvailable) {
try {
const list = await props.plugin.call('fileManager', 'readdir', `.deploys/pinned-contracts/${chainId.current}`)
const list = await props.plugin.call('fileManager', 'readdir', `.workspaces/${currentWorkspace}/.deploys/pinned-contracts/${dirName}`)
const filePaths = Object.keys(list)
for (const file of filePaths) {
const pinnedContract = await props.plugin.call('fileManager', 'readFile', file)

@ -133,7 +133,6 @@ export function UniversalDappUI(props: UdappProps) {
const pinContract = async() => {
const workspace = await props.plugin.call('filePanel', 'getCurrentWorkspace')
const {network} = await props.plugin.call('blockchain', 'getCurrentNetworkStatus')
const objToSave = {
name: props.instance.name,
address: props.instance.address,
@ -141,10 +140,16 @@ export function UniversalDappUI(props: UdappProps) {
filePath: props.instance.filePath || `${workspace.name}/${props.instance.contractData.contract.file}`,
pinnedAt: Date.now()
}
await props.plugin.call('fileManager', 'writeFile', `.deploys/pinned-contracts/${network.id}/${props.instance.address}.json`, JSON.stringify(objToSave, null, 2))
let dirName
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
await props.plugin.call('udapp', 'addSavedInstance', objToSave.address, objToSave.abi, objToSave.name, objToSave.pinnedAt, objToSave.filePath)
_paq.push(['trackEvent', 'udapp', 'pinContracts', `pinned at ${network.id}`])
_paq.push(['trackEvent', 'udapp', 'pinContracts', `pinned at ${dirName}`])
// Remove contract from deployed contracts list on UI
props.removeInstance(props.index, false, false)
}

Loading…
Cancel
Save