Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bunsenstraat committed Jan 10, 2025
1 parent af44bd7 commit 916ac7f
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 144 deletions.
4 changes: 0 additions & 4 deletions libs/remix-lib/src/execution/txRunnerWeb3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class TxRunnerWeb3 {
const listenOnResponse = () => {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
console.log('listenOnResponse')
const receipt = await tryTillReceiptAvailable(resp, this.getWeb3())
tx = await tryTillTxAvailable(resp, this.getWeb3())
currentDateTime = new Date();
Expand Down Expand Up @@ -81,10 +80,8 @@ export class TxRunnerWeb3 {
} else {
try {
const res = await this.getWeb3().eth.sendTransaction(tx, null, { checkRevertBeforeSending: false, ignoreGasPricing: true })
console.log('res', res)
cb(null, res.transactionHash)
} catch (e) {
console.log(e)
if (!e.message) e.message = ''
if (e.error) {
e.message = e.message + ' ' + e.error
Expand Down Expand Up @@ -195,7 +192,6 @@ export class TxRunnerWeb3 {
async function tryTillReceiptAvailable (txhash: string, web3: Web3) {
try {
const receipt = await web3.eth.getTransactionReceipt(txhash)
console.log('receipt', receipt)
if (receipt) {
if (!receipt.to && !receipt.contractAddress) {
// this is a contract creation and the receipt doesn't contain a contract address. we have to keep polling...
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion libs/remix-ui/terminal-transactions/src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppContext, appPlatformTypes, platformContext } from '@remix-ui/app'
import { appPlatformTypes, platformContext } from '@remix-ui/app'
import { CustomTooltip } from '@remix-ui/helper'
import React, { useState, useEffect, useRef, useContext } from 'react' // eslint-disable-line
import { FormattedMessage, useIntl } from 'react-intl'
Expand All @@ -9,12 +9,10 @@ import { RemixUITerminalMenu } from './remix-ui-terminal-menu'
import { RemixUITerminalMenuToggle } from './remix-ui-terminal-menu-toggle'
import { RemixUIXtermMenu } from '../../../../xterm/src/lib/components/remix-ui-terminal-menu-xterm'
import { RemixUITerminalMenuButtons } from './remix-ui-terminal-menu-buttons'
import { desktopConnextionType } from '@remix-api'

export const RemixUITerminalBar = (props: RemixUiTerminalProps) => {
const { terminalState, xtermState } = useContext(TerminalContext)
const platform = useContext(platformContext)
const appContext = useContext(AppContext)
const intl = useIntl()
const terminalMenu = useRef(null)

Expand All @@ -30,17 +28,10 @@ export const RemixUITerminalBar = (props: RemixUiTerminalProps) => {
data-id="terminalToggleMenu"
>
<RemixUITerminalMenuToggle {...props} />
{appContext.appState.connectedToDesktop !== desktopConnextionType.disabled ?
<div className='d-flex flex-row w-100 justify-content-between '>
<RemixUITerminalMenuButtons {...props} />

</div> : null

}
{platform === appPlatformTypes.desktop ?
<div className='d-flex flex-row w-100 justify-content-between '>
<RemixUITerminalMenuButtons {...props} />
{xtermState.selectedTerminalTab === 'output' ? <RemixUITerminalMenu {...props} />: <RemixUIXtermMenu {...props} />}
{xtermState.showOutput? <RemixUITerminalMenu {...props} />: <RemixUIXtermMenu {...props} />}
</div> :
<RemixUITerminalMenu {...props} />
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,42 @@
import { AppContext } from '@remix-ui/app'
import React, { useContext, useEffect } from 'react' // eslint-disable-line
import { TerminalContext } from '../context'
import { RemixUiTerminalProps, SET_OPEN } from '../types/terminalTypes'
import './remix-ui-terminal-menu-buttons.css'
import { desktopConnextionType } from '@remix-api';

export const RemixUITerminalMenuButtons = (props: RemixUiTerminalProps) => {
const { xtermState, dispatchXterm, terminalState, dispatch } = useContext(TerminalContext)
const appContext = useContext(AppContext)

function selectOutput(event: any): void {
props.plugin.call('layout', 'minimize', props.plugin.profile.name, false)
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'output' })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: true })
dispatch({ type: SET_OPEN, payload: true })
}

const showTerminal = async (event: any): Promise<void> => {
const showTerminal = async(event: any): Promise<void> => {
props.plugin.call('layout', 'minimize', props.plugin.profile.name, false)
if (xtermState.terminals.length === 0) {
if ( xtermState.terminals.length === 0) {
const start_time = Date.now()
const pid = await props.plugin.call('xterm', 'createTerminal', xtermState.workingDir, null)
const end_time = Date.now()
console.log(`createTerminal took ${end_time - start_time} ms`)
dispatchXterm({ type: 'HIDE_ALL_TERMINALS', payload: null })
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'xterm' })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
dispatchXterm({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } })
} else {
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'xterm' })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
}
dispatch({ type: SET_OPEN, payload: true })
}

const showTransactions = async (event: any): Promise<void> => {
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'transactions' })
}

if (appContext.appState.connectedToDesktop === desktopConnextionType.connected) {

return null
return (
<div className='d-flex flex-row align-items-center'>

<button data-id="tab" id="tabTransactionsDebugger" className={`xtermButton w-100 btn btn-sm border-secondary btn-secondary'}`}
onClick={async (e) => await showTransactions(e)}
>
pending transactions
</button>
</div>
)
}

return (
<div className='d-flex flex-row align-items-center'>
<button id="tabOutput" data-id="tabOutput" className={`xtermButton btn btn-sm border-secondary mr-2 border ${!(xtermState.selectedTerminalTab === 'output') ? '' : 'd-flex btn-secondary'}`} onClick={selectOutput}>
<button id="tabOutput" data-id="tabOutput" className={`xtermButton btn btn-sm border-secondary mr-2 border ${!xtermState.showOutput ? '' : 'd-flex btn-secondary'}`} onClick={selectOutput}>
Output
</button>
<button data-id="tabXTerm" id="tabXTerm" className={`xtermButton mr-2 btn btn-sm border-secondary ${xtermState.terminalsEnabled ? 'd-block' : 'd-none'} ${xtermState.selectedTerminalTab === 'xterm' ? 'd-none' : 'btn-secondary'}`}
onClick={async (e) => await showTerminal(e)}>
<button data-id="tabXTerm" id="tabXTerm" className={`xtermButton btn btn-sm border-secondary ${xtermState.terminalsEnabled ? 'd-block' : 'd-none'} ${xtermState.showOutput ? 'd-none' : 'btn-secondary'}`}
onClick={async(e) => await showTerminal(e)}>
<span className="far fa-terminal border-0 ml-1"></span>
</button>
{/* <button data-id="tab" id="tabTransactionsDebugger" className={`xtermButton w-100 btn btn-sm border-secondary btn-secondary'}`}
onClick={async (e) => await showTransactions(e)}
>
pending transactions
</button> */}
</div>
)
}
29 changes: 3 additions & 26 deletions libs/remix-ui/terminal/src/lib/remix-ui-terminal-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,31 @@
import { AppContext, appPlatformTypes, platformContext } from '@remix-ui/app'
import { appPlatformTypes, platformContext } from '@remix-ui/app'
import { RemixUiXterminals, xTerminInitialState, xtermReducer } from '@remix-ui/xterm'
import { TerminalTransactions } from 'libs/remix-ui/terminal-transactions/src'
import React, { useContext, useEffect, useReducer } from 'react' // eslint-disable-line
import React, { useContext, useReducer } from 'react' // eslint-disable-line
import { RemixUITerminalBar } from './components/remix-ui-terminal-bar'
import { TerminalContext } from './context'
import { initialState, registerCommandReducer } from './reducers/terminalReducer'
import RemixUiTerminal from './remix-ui-terminal'
import { RemixUiTerminalProps } from './types/terminalTypes'
import { desktopConnextionType } from '@remix-api'

export const RemixUITerminalWrapper = (props: RemixUiTerminalProps) => {
const [terminalState, dispatch] = useReducer(registerCommandReducer, initialState)
const [xtermState, dispatchXterm] = useReducer(xtermReducer, xTerminInitialState)
const platform = useContext(platformContext)
const appContext = useContext(AppContext)
const providerState = {
terminalState,
dispatch,
xtermState,
dispatchXterm
}

useEffect(() => {
if (appContext.appState.connectedToDesktop === desktopConnextionType.connected) {
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'transactions' })
}
}, [appContext.appState.connectedToDesktop])

if (appContext.appState.connectedToDesktop === desktopConnextionType.disconnected) {
return <></>
}

if (appContext.appState.connectedToDesktop === desktopConnextionType.connected) {
return <>
<TerminalContext.Provider value={providerState}>
<RemixUITerminalBar {...props} />
{platform !== appPlatformTypes.desktop && <RemixUiTerminal {...props} />}
</TerminalContext.Provider>
</>
}

return (<>
<TerminalContext.Provider value={providerState}>
<RemixUITerminalBar {...props} />
{platform !== appPlatformTypes.desktop && <RemixUiTerminal {...props} />}
{platform === appPlatformTypes.desktop &&
<>
<RemixUiTerminal visible={xtermState.selectedTerminalTab === 'output'} plugin={props.plugin} onReady={props.onReady} />
<RemixUiTerminal visible={xtermState.showOutput} plugin={props.plugin} onReady={props.onReady} />
<RemixUiXterminals {...props} />
{/* <TerminalTransactions plugin={props.plugin} /> */}
</>
}
</TerminalContext.Provider>
Expand Down
2 changes: 1 addition & 1 deletion libs/remix-ui/xterm/src/lib/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Plugin } from "@remixproject/engine"

export const createTerminal = async (shell: string = '', plugin: Plugin, workingDir: string, dispatch: React.Dispatch<Actions>) => {
const pid = await plugin.call('xterm', 'createTerminal', workingDir, shell)
dispatch({ type: 'SET_TERMINAL_TAB', payload: 'xterm' })
dispatch({ type: 'SHOW_OUTPUT', payload: false })
dispatch({ type: 'HIDE_ALL_TERMINALS', payload: null })
dispatch({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const RemixUIXtermMenu = (props: RemixUiTerminalProps) => {
}

return (<>
<div className={`d-flex flex-row align-items-center ${xtermState.selectedTerminalTab === 'output' ? 'd-none' : ''}`}>
<div className={`d-flex flex-row align-items-center ${xtermState.showOutput ? 'd-none' : ''}`}>
<div data-id="createTerminalButton" className="mx-2" onClick={async () => onCreateTerminal()}>
<CustomTooltip tooltipText={<FormattedMessage id='xterm.new' defaultMessage='New terminal' />}>
<i className="fas fa-plus border-0 p-0 m-0"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
plugin.on('xterm', 'new', async () => {
const pid = await plugin.call('xterm', 'createTerminal', workingDir, null)
dispatchXterm({ type: 'HIDE_ALL_TERMINALS', payload: null })
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'xterm' })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: false })
dispatchXterm({ type: 'ADD_TERMINAL', payload: { pid, queue: '', timeStamp: Date.now(), ref: null, hidden: false } })
})

Expand Down Expand Up @@ -80,7 +80,7 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
useEffect(() => {
setTerminals(xtermState.terminals)
if (xtermState.terminals.length === 0) {
dispatchXterm({ type: 'SET_TERMINAL_TAB', payload: 'output' })
dispatchXterm({ type: 'SHOW_OUTPUT', payload: true })
}
}, [xtermState.terminals])

Expand Down Expand Up @@ -139,9 +139,9 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
}

return (<>
{<div style={{ flexGrow: 1 }} className={`flex-row ${xtermState.selectedTerminalTab === 'xterm' ? 'h-100 d-flex': 'h-0 d-none'}`}>
{<div style={{ flexGrow: 1 }} className={`flex-row ${xtermState.showOutput ? 'h-0 d-none' : 'h-100 d-flex'}`}>
<>
{<div className={`flex-row w-100 h-100 ${xtermState.selectedTerminalTab === 'xterm' ? 'h-100 d-flex': 'h-0 d-none'}`}>
{<div className={`flex-row w-100 h-100 ${xtermState.showOutput ? 'h-0 d-none' : 'h-100 d-flex'}`}>
{terminals.map((xtermState) => {
return (
<div className={`h-100 w-100 ${xtermState.hidden ? 'd-none' : 'd-block'}`} data-active={`${xtermState.hidden ? '0' : '1'}`} key={xtermState.pid} data-type="remixUIXT" data-id={`remixUIXT${xtermState.pid}`}>
Expand Down
10 changes: 1 addition & 9 deletions libs/remix-ui/xterm/src/lib/reducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export const xTerminInitialState: xTerminalUiState = {
terminals: [],
shells: [],
showOutput: true,
workingDir: '',
selectedTerminalTab: 'output'
workingDir: ''
}

export const xtermReducer = (state = xTerminInitialState, action: Actions) => {
Expand Down Expand Up @@ -60,13 +59,6 @@ export const xtermReducer = (state = xTerminInitialState, action: Actions) => {
...state,
showOutput: action.payload
}

case 'SET_TERMINAL_TAB':
return {
...state,
selectedTerminalTab: action.payload
}

case 'SET_WORKING_DIR':
return {
...state,
Expand Down
2 changes: 0 additions & 2 deletions libs/remix-ui/xterm/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface xTerminalUiState {
shells: string[]
showOutput: boolean
workingDir: string
selectedTerminalTab: 'output' | 'xterm' | 'transactions'
}

export interface ActionPayloadTypes {
Expand All @@ -27,7 +26,6 @@ export interface ActionPayloadTypes {
ADD_SHELLS: string[],
SHOW_OUTPUT: boolean
SET_WORKING_DIR: string
SET_TERMINAL_TAB: 'output' | 'xterm' | 'transactions'
}

export interface Action<T extends keyof ActionPayloadTypes> {
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@
"@remix-ui/xterm": [
"libs/remix-ui/xterm/src/index.ts"
],
"@remix-ui/terminal-transactions": [
"libs/remix-ui/erminal-transactions/src/index.ts"
],
"@remix-ui/remix-ai": [
"libs/remix-ui/remix-ai/src/index.ts"
],
Expand Down

0 comments on commit 916ac7f

Please sign in to comment.