|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import { envChangeNotification } from "@remix-ui/helper" |
|
|
|
|
import { RunTab } from "../types/run-tab" |
|
|
|
|
import { setExecutionContext, setFinalContext, updateAccountBalances, fillAccountsList } from "./account" |
|
|
|
|
import { addExternalProvider, addInstance, addPinnedInstance, addNewProxyDeployment, removeExternalProvider, setNetworkNameFromProvider } from "./actions" |
|
|
|
|
import { addExternalProvider, addInstance, addPinnedInstance, addNewProxyDeployment, removeExternalProvider, setNetworkNameFromProvider, setPinnedChainId } from "./actions" |
|
|
|
|
import { addDeployOption, clearAllInstances, clearAllPinnedInstances, clearRecorderCount, fetchContractListSuccess, resetProxyDeployments, resetUdapp, setCurrentContract, setCurrentFile, setLoadType, setRecorderCount, setRemixDActivated, setSendValue, fetchAccountsListSuccess } from "./payload" |
|
|
|
|
import { updateInstanceBalance } from './deploy' |
|
|
|
|
import { CompilerAbstract } from '@remix-project/remix-solidity' |
|
|
|
@ -35,7 +35,7 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => { |
|
|
|
|
fillAccountsList(plugin, dispatch) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
plugin.blockchain.event.register('networkStatus', ({ error, network }) => { |
|
|
|
|
plugin.blockchain.event.register('networkStatus', async ({ error, network }) => { |
|
|
|
|
if (error) { |
|
|
|
|
const netUI = 'can\'t detect network' |
|
|
|
|
setNetworkNameFromProvider(dispatch, netUI) |
|
|
|
@ -44,8 +44,10 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => { |
|
|
|
|
} |
|
|
|
|
const networkProvider = plugin.networkModule.getNetworkProvider.bind(plugin.networkModule) |
|
|
|
|
const netUI = !networkProvider().startsWith('vm') ? `${network.name} (${network.id || '-'}) network` : 'VM' |
|
|
|
|
|
|
|
|
|
const pinnedChainId = !networkProvider().startsWith('vm') ? network.id : networkProvider() |
|
|
|
|
setNetworkNameFromProvider(dispatch, netUI) |
|
|
|
|
setPinnedChainId(dispatch, pinnedChainId) |
|
|
|
|
await loadPinnedContracts(plugin, dispatch, pinnedChainId) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
plugin.blockchain.event.register('addProvider', provider => addExternalProvider(dispatch, provider)) |
|
|
|
@ -94,7 +96,6 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => { |
|
|
|
|
plugin.on('filePanel', 'setWorkspace', async () => { |
|
|
|
|
dispatch(resetUdapp()) |
|
|
|
|
resetAndInit(plugin) |
|
|
|
|
await loadPinnedContracts(plugin, dispatch) |
|
|
|
|
await migrateSavedContracts(plugin) |
|
|
|
|
plugin.call('manager', 'isActive', 'remixd').then((activated) => { |
|
|
|
|
dispatch(setRemixDActivated(activated)) |
|
|
|
@ -165,9 +166,11 @@ export const setupEvents = (plugin: RunTab, dispatch: React.Dispatch<any>) => { |
|
|
|
|
}, 30000)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const loadPinnedContracts = async (plugin, dispatch) => { |
|
|
|
|
const { network } = await plugin.call('blockchain', 'getCurrentNetworkStatus') |
|
|
|
|
const dirName = plugin.REACT_API.networkName === 'VM' ? plugin.REACT_API.selectExEnv : network.id |
|
|
|
|
const loadPinnedContracts = async (plugin, dispatch, dirName) => { |
|
|
|
|
console.log('loadPinnedContracts---->') |
|
|
|
|
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}`) |
|
|
|
|
if (isPinnedAvailable) { |
|
|
|
|
try { |
|
|
|
|