|
2 | 2 | import React from 'react' |
3 | 3 | import * as ethJSUtil from 'ethereumjs-util' |
4 | 4 | import Web3 from 'web3' |
5 | | -import { addressToString, createNonClashingNameAsync, extractNameFromKey, shortenAddress } from '@remix-ui/helper' |
6 | | -import { addNewInstance, addProvider, clearAllInstances, clearRecorderCount, displayNotification, displayPopUp, fetchAccountsListFailed, fetchAccountsListRequest, fetchAccountsListSuccess, fetchContractListSuccess, hidePopUp, removeExistingInstance, removeProvider, resetUdapp, setBaseFeePerGas, setConfirmSettings, setCurrentFile, setDecodedResponse, setEnvToasterContent, setExecutionEnvironment, setExternalEndpoint, setGasLimit, setGasPrice, setGasPriceStatus, setLoadType, setMatchPassphrase, setMaxFee, setMaxPriorityFee, setNetworkName, setPassphrase, setPathToScenario, setRecorderCount, setSelectedAccount, setSendUnit, setSendValue, setTxFeeContent, setWeb3Dialog } from './payload' |
| 5 | +import { addressToString, createNonClashingNameAsync, envChangeNotification, extractNameFromKey, shortenAddress, web3Dialog } from '@remix-ui/helper' |
| 6 | +import { addNewInstance, addProvider, clearAllInstances, clearRecorderCount, displayNotification, displayPopUp, fetchAccountsListFailed, fetchAccountsListRequest, fetchAccountsListSuccess, fetchContractListSuccess, hidePopUp, removeExistingInstance, removeProvider, resetUdapp, setBaseFeePerGas, setConfirmSettings, setCurrentFile, setDecodedResponse, setEnvToasterContent, setExecutionEnvironment, setExternalEndpoint, setGasLimit, setGasPrice, setGasPriceStatus, setLoadType, setMatchPassphrase, setMaxFee, setMaxPriorityFee, setNetworkName, setPassphrase, setPathToScenario, setRecorderCount, setSelectedAccount, setSendUnit, setSendValue, setTxFeeContent } from './payload' |
7 | 7 | import { RunTab } from '../types/run-tab' |
8 | 8 | import { CompilerAbstract } from '@remix-project/remix-solidity' |
9 | 9 | import * as remixLib from '@remix-project/remix-lib' |
@@ -75,8 +75,8 @@ const setupEvents = () => { |
75 | 75 | plugin.on('yulp', 'compilationFinished', (file, source, languageVersion, data) => broadcastCompilationResult(file, source, languageVersion, data)) |
76 | 76 |
|
77 | 77 | plugin.on('udapp', 'setEnvironmentModeReducer', (env: { context: string, fork: string }, from: string) => { |
78 | | - dispatch(displayPopUp(plugin.REACT_API.envToasterContent(env, from))) |
79 | | - setExecutionContext(env, plugin.REACT_API.web3Dialog()) |
| 78 | + plugin.call('notification', 'toast', envChangeNotification(env, from)) |
| 79 | + setExecutionContext(env) |
80 | 80 | }) |
81 | 81 |
|
82 | 82 | plugin.on('filePanel', 'setWorkspace', () => { |
@@ -106,11 +106,6 @@ const setupEvents = () => { |
106 | 106 | }) |
107 | 107 | } |
108 | 108 |
|
109 | | -export const initWebDialogs = (envToasterContent: (env: { context: string, fork: string }, from: string) => void, web3Dialog: () => void) => async (dispatch: React.Dispatch<any>) => { |
110 | | - dispatch(setEnvToasterContent(envToasterContent)) |
111 | | - dispatch(setWeb3Dialog(web3Dialog)) |
112 | | -} |
113 | | - |
114 | 109 | const updateAccountBalances = () => { |
115 | 110 | const accounts = plugin.REACT_API.accounts.loadedAccounts |
116 | 111 |
|
@@ -225,16 +220,28 @@ const removeExternalProvider = (name) => { |
225 | 220 | dispatch(removeProvider(name)) |
226 | 221 | } |
227 | 222 |
|
228 | | -export const setExecutionContext = (executionContext: { context: string, fork: string }, displayContent: JSX.Element) => { |
| 223 | +export const setExecutionContext = (executionContext: { context: string, fork: string }) => { |
| 224 | + const displayContent = web3Dialog(plugin.REACT_API.externalEndpoint, setWeb3Endpoint) |
| 225 | + |
229 | 226 | plugin.blockchain.changeExecutionContext(executionContext, () => { |
230 | | - dispatch(displayNotification('External node request', displayContent, 'OK', 'Cancel', () => { |
231 | | - plugin.blockchain.setProviderFromEndpoint(plugin.REACT_API.externalEndpoint, executionContext, (alertMsg) => { |
232 | | - if (alertMsg) dispatch(displayPopUp(alertMsg)) |
| 227 | + plugin.call('notification', 'modal', { |
| 228 | + id: 'envNotification', |
| 229 | + title: 'External node request', |
| 230 | + message: displayContent, |
| 231 | + okLabel: 'OK', |
| 232 | + cancelLabel: 'Cancel', |
| 233 | + okFn: () => { |
| 234 | + plugin.blockchain.setProviderFromEndpoint(plugin.REACT_API.externalEndpoint, executionContext, (alertMsg) => { |
| 235 | + if (alertMsg) plugin.call('notification', 'toast', alertMsg) |
| 236 | + setFinalContext() |
| 237 | + }) |
| 238 | + }, |
| 239 | + cancelFn: () => { |
233 | 240 | setFinalContext() |
234 | | - }) |
235 | | - }, () => { setFinalContext() })) |
| 241 | + } |
| 242 | + }) |
236 | 243 | }, (alertMsg) => { |
237 | | - dispatch(displayPopUp(alertMsg)) |
| 244 | + plugin.call('notification', 'toast', alertMsg) |
238 | 245 | }, () => { setFinalContext() }) |
239 | 246 | } |
240 | 247 |
|
|
0 commit comments