Skip to content

Commit 776da83

Browse files
LianaHusAniket-Engg
authored andcommitted
listen on network is active for !vm
1 parent beda492 commit 776da83

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

apps/remix-ide/src/app/tabs/network-module.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ export class NetworkModule extends Plugin {
1919
constructor (blockchain) {
2020
super(profile)
2121
this.blockchain = blockchain
22+
2223
// TODO: See with remix-lib to make sementic coherent
2324
this.blockchain.event.register('contextChanged', (provider) => {
2425
this.emit('providerChanged', provider)
2526
})
2627
}
2728

29+
onActivation () {
30+
// emit the initial provider type
31+
this.emit('providerChanged', this.blockchain.getProvider)
32+
}
33+
2834
/** Return the current network provider (web3, vm, injected) */
2935
getNetworkProvider () {
3036
return this.blockchain.getProvider()

libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
5959
})
6060

6161
const [clearConsole, setClearConsole] = useState(false)
62+
const [isVM, setIsVM] = useState(false)
6263
const [paste, setPaste] = useState(false)
6364
const [storage, setStorage] = useState<any>(null)
6465
const [autoCompletState, setAutoCompleteState] = useState({
@@ -98,6 +99,10 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
9899
}
99100

100101
useEffect(() => {
102+
props.plugin.on('network', 'providerChanged', (provider) => {
103+
setIsVM(provider.startsWith('vm-'))
104+
})
105+
101106
props.onReady({
102107
logHtml: (html) => {
103108
scriptRunnerDispatch({
@@ -603,11 +608,22 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
603608
<CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="terminal.pendingTransactions" />}>
604609
<div className="mx-2">0</div>
605610
</CustomTooltip>
606-
<div className="h-80 mx-3 align-items-center remix_ui_terminal_listenOnNetwork custom-control custom-checkbox">
607-
<CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText={intl.formatMessage({ id: 'terminal.listenTitle' })}>
608-
<input className="custom-control-input" id="listenNetworkCheck" onChange={listenOnNetwork} type="checkbox" />
609-
</CustomTooltip>
610-
<CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText={intl.formatMessage({ id: 'terminal.listenTitle' })}>
611+
<CustomTooltip
612+
placement="top"
613+
tooltipId="terminalClear"
614+
tooltipClasses="text-nowrap"
615+
tooltipText={intl.formatMessage({ id: isVM ? 'terminal.listenVM' : 'terminal.listenTitle'})}
616+
>
617+
<div className="h-80 mx-3 align-items-center remix_ui_terminal_listenOnNetwork custom-control custom-checkbox">
618+
<CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText={intl.formatMessage({ id: 'terminal.listenTitle' })}>
619+
<input
620+
className="custom-control-input"
621+
id="listenNetworkCheck"
622+
onChange={listenOnNetwork}
623+
type="checkbox"
624+
disabled={isVM}
625+
/>
626+
</CustomTooltip>
611627
<label
612628
className="form-check-label custom-control-label text-nowrap"
613629
style={{ paddingTop: '0.125rem' }}
@@ -616,8 +632,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
616632
>
617633
<FormattedMessage id="terminal.listen" />
618634
</label>
619-
</CustomTooltip>
620-
</div>
635+
</div>
636+
</CustomTooltip>
621637
<div className="remix_ui_terminal_search d-flex align-items-center h-100">
622638
<i className="remix_ui_terminal_searchIcon d-flex align-items-center justify-content-center fas fa-search bg-light" aria-hidden="true"></i>
623639
<input

0 commit comments

Comments
 (0)