Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
bunsenstraat committed Jan 10, 2025
1 parent 6c745d4 commit 0e01442
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 128 deletions.
1 change: 0 additions & 1 deletion libs/remix-lib/src/execution/txRunnerWeb3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class TxRunnerWeb3 {
}

async _executeTx (tx, network, txFee, api, promptCb, callback) {
console.log('executeTx', tx)
if (network && network.lastBlock && network.lastBlock.baseFeePerGas) {
// the sending stack (web3.js / metamask need to have the type defined)
// this is to avoid the following issue: https://github.com/MetaMask/metamask-extension/issues/11824
Expand Down
7 changes: 3 additions & 4 deletions libs/remix-ui/panel/src/lib/main/main-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-unused-expressions */
import React, { useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line
import React, {useContext, useEffect, useRef, useState} from 'react' // eslint-disable-line
import DragBar from '../dragbar/dragbar'
import RemixUIPanelPlugin from '../plugins/panel-plugin'
import { PluginRecord } from '../types'
import { AppContext, appPlatformTypes, platformContext } from '@remix-ui/app'
import { appPlatformTypes, platformContext } from '@remix-ui/app'
import './main-panel.css'

export type RemixUIMainPanelProps = {
Expand All @@ -18,7 +18,6 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
const mainPanelRef = useRef<HTMLDivElement>(null)
const tabsRef = useRef<HTMLDivElement>(null)
const terminalRef = useRef<HTMLDivElement>(null)
const appContext = useContext(AppContext)

const refs = [tabsRef, editorRef, mainPanelRef, terminalRef]

Expand All @@ -30,7 +29,7 @@ const RemixUIMainPanel = (props: RemixUIMainPanelProps) => {
profile: panel.plugin.profile,
active: panel.active,
view: panel.plugin.profile.name === 'tabs' ? panel.plugin.renderTabsbar() : panel.plugin.render(),
class: panel.plugin.profile.name + '-wrap ' + (panel.minimized ? 'minimized ' : ' ') + ((platform === appPlatformTypes.desktop) ? 'desktop' : ''),
class: panel.plugin.profile.name + '-wrap ' + (panel.minimized ? 'minimized ' : ' ') + ((platform === appPlatformTypes.desktop)? 'desktop' : ''),
minimized: panel.minimized,
pinned: panel.pinned
})
Expand Down
3 changes: 0 additions & 3 deletions libs/remix-ui/run-tab/src/lib/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const updateAccountBalances = async (plugin: RunTab, dispatch: React.Disp
}

export const fillAccountsList = async (plugin: RunTab, dispatch: React.Dispatch<any>) => {
console.log('fillAccountsList')
try {
dispatch(fetchAccountsListRequest())
try {
Expand All @@ -35,7 +34,6 @@ export const fillAccountsList = async (plugin: RunTab, dispatch: React.Dispatch<
const selectedAddress = plugin.blockchain.getInjectedWeb3Address()
if (!(Object.keys(loadedAccounts).includes(toChecksumAddress(selectedAddress)))) setAccount(dispatch, null)
}
console.log('loadedAccounts', loadedAccounts)
dispatch(fetchAccountsListSuccess(loadedAccounts))
} catch (e) {
dispatch(fetchAccountsListFailed(e.message))
Expand All @@ -59,7 +57,6 @@ const _getProviderDropdownValue = (plugin: RunTab): string => {
}

export const setExecutionContext = (plugin: RunTab, dispatch: React.Dispatch<any>, executionContext: { context: string, fork: string }) => {
console.log('setExecutionContext', executionContext)
plugin.blockchain.changeExecutionContext(executionContext, null, (alertMsg) => {
plugin.call('notification', 'toast', alertMsg)
}, () => { setFinalContext(plugin, dispatch) })
Expand Down
9 changes: 1 addition & 8 deletions libs/remix-ui/run-tab/src/lib/actions/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const setupEvents = (plugin: RunTab) => {
})

plugin.blockchain.event.register('contextChanged', async (context) => {
console.log('contextChanged', context)
dispatch(resetProxyDeployments())
if (!context.startsWith('vm')) getNetworkProxyAddresses(plugin, dispatch)
if (context !== 'walletconnect') {
Expand Down Expand Up @@ -99,12 +98,6 @@ export const setupEvents = (plugin: RunTab) => {

plugin.on('truffle', 'compilationFinished', (file, source, languageVersion, data) => broadcastCompilationResult('truffle', plugin, dispatch, file, source, languageVersion, data))

plugin.on('desktopHost', 'chainChanged', (context) => {
//console.log('desktopHost chainChanged', context)
//fillAccountsList(plugin, dispatch)
//updateInstanceBalance(plugin, dispatch)
})

plugin.on('udapp', 'setEnvironmentModeReducer', (env: { context: string, fork: string }, from: string) => {
plugin.call('notification', 'toast', envChangeNotification(env, from))
setExecutionContext(plugin, dispatch, env)
Expand All @@ -131,7 +124,7 @@ export const setupEvents = (plugin: RunTab) => {
if (activatedPlugin.name === 'remixd') {
dispatch(setRemixDActivated(true))
} else {
if (activatedPlugin && (activatedPlugin.name.startsWith('injected') || activatedPlugin.name === 'desktopHost')) {
if (activatedPlugin && activatedPlugin.name.startsWith('injected')) {
plugin.on(activatedPlugin.name, 'accountsChanged', (accounts: Array<string>) => {
const accountsMap = {}
accounts.map(account => { accountsMap[account] = shortenAddress(account, '0')})
Expand Down
96 changes: 81 additions & 15 deletions libs/remix-ui/run-tab/src/lib/components/environment.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
import React, { useRef, useState, useContext, useEffect } from 'react'
// eslint-disable-next-line no-use-before-define
import React, { useRef } from 'react'
import { FormattedMessage, useIntl } from 'react-intl'
import { EnvironmentProps, Provider } from '../types'
import { Dropdown } from 'react-bootstrap'
import { CustomMenu, CustomToggle, CustomTooltip } from '@remix-ui/helper'
import EnvironmentDropdown from './EnvironmentDropdown'
import { AppContext } from '@remix-ui/app'
import { desktopConnextionType } from '@remix-api'

const _paq = (window._paq = window._paq || [])

export function EnvironmentUI(props: EnvironmentProps) {
const vmStateName = useRef('')
const [filters, setFilters] = useState<((provider: Provider) => boolean)[]>([])
const context = useContext(AppContext) // Use the AppContext

useEffect(() => {
const filterFunction = (provider: Provider) => {
return context.appState.connectedToDesktop != desktopConnextionType.disabled ? provider.isInjected : true
}
setFilters((prevFilters) => [...prevFilters, filterFunction])
}, [context.appState.connectedToDesktop])

Object.entries(props.providers.providerList.filter((provider) => { return provider.isVM }))
Object.entries(props.providers.providerList.filter((provider) => { return provider.isInjected }))
Expand Down Expand Up @@ -147,7 +135,85 @@ export function EnvironmentUI(props: EnvironmentProps) {
</CustomTooltip> }
</label>
<div className="udapp_environment" data-id={`selected-provider-${currentProvider && currentProvider.name}`}>
<EnvironmentDropdown currentProvider={currentProvider} isL2={isL2} bridges={bridges} handleChangeExEnv={handleChangeExEnv} filters={filters} props={props} />
<Dropdown id="selectExEnvOptions" data-id="settingsSelectEnvOptions" className="udapp_selectExEnvOptions">
<Dropdown.Toggle as={CustomToggle} id="dropdown-custom-components" className="btn btn-light btn-block w-100 d-inline-block border border-dark form-control" icon={null}>
{isL2(currentProvider && currentProvider.displayName)}
{currentProvider && currentProvider.displayName}
{currentProvider && bridges[currentProvider.displayName.substring(0, 13)] && (
<CustomTooltip placement={'auto-end'} tooltipClasses="text-nowrap" tooltipId="info-recorder" tooltipText={<FormattedMessage id="udapp.tooltipText3" />}>
<i
style={{ fontSize: 'medium' }}
className={'ml-2 fa fa-rocket-launch'}
aria-hidden="true"
onClick={() => {
window.open(bridges[currentProvider.displayName.substring(0, 13)], '_blank')
}}
></i>
</CustomTooltip>
)}
</Dropdown.Toggle>
<Dropdown.Menu as={CustomMenu} className="w-100 custom-dropdown-items" data-id="custom-dropdown-items">
{props.providers.providerList.length === 0 && <Dropdown.Item>
<span className="">
No provider pinned
</span>
</Dropdown.Item>}
{ (props.providers.providerList.filter((provider) => { return provider.isInjected })).map(({ name, displayName }) => (
<Dropdown.Item
key={name}
onClick={async () => {
handleChangeExEnv(name)
}}
data-id={`dropdown-item-${name}`}
>
<span className="">
{displayName}
</span>
</Dropdown.Item>
))}
{ props.providers.providerList.filter((provider) => { return provider.isInjected }).length !== 0 && <Dropdown.Divider className='border-secondary'></Dropdown.Divider> }
{ (props.providers.providerList.filter((provider) => { return provider.isVM })).map(({ displayName, name }) => (
<Dropdown.Item
key={name}
onClick={() => {
handleChangeExEnv(name)
}}
data-id={`dropdown-item-${name}`}
>
<span className="">
{displayName}
</span>
</Dropdown.Item>
))}
{ props.providers.providerList.filter((provider) => { return provider.isVM }).length !== 0 && <Dropdown.Divider className='border-secondary'></Dropdown.Divider> }
{ (props.providers.providerList.filter((provider) => { return !(provider.isVM || provider.isInjected) })).map(({ displayName, name }) => (
<Dropdown.Item
key={name}
onClick={() => {
handleChangeExEnv(name)
}}
data-id={`dropdown-item-${name}`}
>
<span className="">
{isL2(displayName)}
{displayName}
</span>
</Dropdown.Item>
))}
<Dropdown.Divider className='border-secondary'></Dropdown.Divider>
<Dropdown.Item
key={10000}
onClick={() => {
props.setExecutionContext({ context: 'item-another-chain' })
}}
data-id={`dropdown-item-another-chain`}
>
<span className="">
Customize this list...
</span>
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
</div>
)
Expand Down
9 changes: 3 additions & 6 deletions libs/remix-ui/run-tab/src/lib/components/settingsUI.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// eslint-disable-next-line no-use-before-define
import React, { useContext, useEffect } from 'react'
import React, { useEffect } from 'react'
import { SettingsProps } from '../types'
import { EnvironmentUI } from './environment'
import { NetworkUI } from './network'
import { AccountUI } from './account'
import { GasLimitUI } from './gasLimit'
import { ValueUI } from './value'
import { AppContext } from '@remix-ui/app'
import { desktopConnextionType } from '@remix-api'

export function SettingsUI(props: SettingsProps) {
// this._deps.config.events.on('settings/personal-mode_changed', this.onPersonalChange.bind(this))
const appContext = useContext(AppContext)

return (
<div className="udapp_settings">
Expand Down Expand Up @@ -39,8 +36,8 @@ export function SettingsUI(props: SettingsProps) {
signMessageWithAddress={props.signMessageWithAddress}
passphrase={props.passphrase}
/>
{appContext.appState.connectedToDesktop === desktopConnextionType.disabled ?
<><GasLimitUI gasLimit={props.gasLimit} setGasFee={props.setGasFee} /><ValueUI setUnit={props.setUnit} sendValue={props.sendValue} sendUnit={props.sendUnit} setSendValue={props.setSendValue} /></> : null}
<GasLimitUI gasLimit={props.gasLimit} setGasFee={props.setGasFee} />
<ValueUI setUnit={props.setUnit} sendValue={props.sendValue} sendUnit={props.sendUnit} setSendValue={props.setSendValue} />
</div>
)
}
1 change: 0 additions & 1 deletion libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A

case SET_EXECUTION_ENVIRONMENT: {
const payload: string = action.payload
console.log('SET_EXECUTION_ENVIRONMENT', payload)

return {
...state,
Expand Down
Loading

0 comments on commit 0e01442

Please sign in to comment.