Commit ce1ba233 authored by davidzagi93@gmail.com's avatar davidzagi93@gmail.com

feat: clear-console, terminal-search, fix-input terminal input to buttom

parent d2c5b071
...@@ -288,6 +288,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -288,6 +288,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
// -------------------Terminal---------------------------------------- // -------------------Terminal----------------------------------------
// move this up for *** level so as to access it in the terminal
makeUdapp(blockchain, compilersArtefacts, (domEl) => terminal.logHtml(domEl))
const terminal = new Terminal( const terminal = new Terminal(
{ appManager, blockchain }, { appManager, blockchain },
{ {
...@@ -300,10 +302,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ...@@ -300,10 +302,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
return height - newpos return height - newpos
} }
}, },
{ config: registry.get('config').api } { config: registry.get('config').api },
registry
) )
makeUdapp(blockchain, compilersArtefacts, (domEl) => terminal.logHtml(domEl))
// previous *** level for makeUdapp method
const contextualListener = new ContextualListener({ editor }) const contextualListener = new ContextualListener({ editor })
engine.register([ engine.register([
......
This diff is collapsed.
...@@ -70,8 +70,9 @@ export const registerCommandAction = (name, command, activate, dispatch) => { ...@@ -70,8 +70,9 @@ export const registerCommandAction = (name, command, activate, dispatch) => {
if (activate.filterFn) { if (activate.filterFn) {
registerFilter(name, activate.filterFn) registerFilter(name, activate.filterFn)
} }
dispatch({ type: name, payload: { commands: commands, _commands: _commands, data: data } }) if (name !== ('knownTransaction' || 'unkownTransaction' || 'emptyBlock')) {
dispatch({ type: name, payload: { commands: commands, _commands: _commands, data: data } })
}
const blockify = (el) => { const blockify = (el) => {
return `<div class="px-4 block_2A0YE0" data-id="block_null">${el}</div>` return `<div class="px-4 block_2A0YE0" data-id="block_null">${el}</div>`
} }
...@@ -89,7 +90,6 @@ export const registerCommandAction = (name, command, activate, dispatch) => { ...@@ -89,7 +90,6 @@ export const registerCommandAction = (name, command, activate, dispatch) => {
console.log({ scopedCommands }) console.log({ scopedCommands })
return scopedCommands return scopedCommands
} }
} }
export const filterFnAction = (name, filterFn, dispatch) => { export const filterFnAction = (name, filterFn, dispatch) => {
...@@ -133,3 +133,103 @@ export const registerErrorScriptRunnerAction = (event, commandName, commandFn, d ...@@ -133,3 +133,103 @@ export const registerErrorScriptRunnerAction = (event, commandName, commandFn, d
export const registerRemixWelcomeTextAction = (welcomeText, dispatch) => { export const registerRemixWelcomeTextAction = (welcomeText, dispatch) => {
dispatch({ type: 'welcomeText', payload: { welcomeText } }) dispatch({ type: 'welcomeText', payload: { welcomeText } })
} }
export const listenOnNetworkAction = async (props, isListening) => {
props.event.trigger('listenOnNetWork', [isListening])
}
export const initListeningOnNetwork = (props, dispatch) => {
props.txListener.event.register('newBlock', (block) => {
if (!block.transactions || (block.transactions && !block.transactions.length)) {
dispatch({ type: 'emptyBlock', payload: { message: 0 } })
console.log({ block }, ' david')
// registerCommandAction('emptyBlock', (args, cmds, append) => {
// const data = args[0]
// console.log({ data }, ' useEffect props')
// // // var el = renderEmptyBlock(this, data)
// // // append(el)
// }, { activate: true }, dispatch)
} else {
registerCommandAction('knownTransaction', function (args, cmds, append) {
var data = args[0]
console.log({ data })
// let el
// if (data.tx.isCall) {
// console.log({ data })
// // el = renderCall(this, data)
// } else {
// // el = renderKnownTransaction(this, data, blockchain)
// }
// this.seen[data.tx.hash] = el
// append(el)
}, { activate: true }, dispatch)
}
})
props.txListener.event.register('newCall', (tx) => {
console.log('new call action')
// log(this, tx, null)
})
props.txListener.event.register('newTransaction', (tx, receipt) => {
log(props, tx, receipt, dispatch)
registerCommandAction('knownTransaction', function (args, cmds, append) {
var data = args[0]
console.log({ data })
// let el
// if (data.tx.isCall) {
// console.log({ data })
// // el = renderCall(this, data)
// } else {
// // el = renderKnownTransaction(this, data, blockchain)
// }
// this.seen[data.tx.hash] = el
// append(el)
}, { activate: true }, dispatch)
// const result = Object.assign([], tx)
// console.log({ result })
// scriptRunnerDispatch({ type: 'knownTransaction', payload: { message: result } })
})
const log = async (props, tx, receipt, dispatch) => {
const resolvedTransaction = await props.txListener.resolvedTransaction(tx.hash)
if (resolvedTransaction) {
var compiledContracts = null
if (props._deps.compilersArtefacts.__last) {
compiledContracts = await props._deps.compilersArtefacts.__last.getContracts()
}
console.log({ compiledContracts })
await props.eventsDecoder.parseLogs(tx, resolvedTransaction.contractName, compiledContracts, (error, logs) => {
if (!error) {
console.log({ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs })
console.log('knownTransaction')
// logKnownTX({ tx: tx, receipt: receipt, resolvedData: resolvedTransaction, logs: logs })
registerCommandAction('knownTransaction', function (args, cmds, append) {
var data = args[0]
console.log({ data }, 'knownTransaction')
// let el
// if (data.tx.isCall) {
// console.log({ data })
// // el = renderCall(this, data)
// } else {
// // el = renderKnownTransaction(this, data, blockchain)
// }
// this.seen[data.tx.hash] = el
// append(el)
}, { activate: true }, dispatch)
}
})
} else {
console.log('unknownTransaction')
// contract unknown - just displaying raw tx.
// logUnknownTX({ tx: tx, receipt: receipt })
await dispatch({ type: 'unknownTransaction', payload: { message: [{ tx: tx, receipt: receipt }] } })
}
}
props.txListener.event.register('debuggingRequested', async (hash) => {
// TODO should probably be in the run module
console.log({ hash }, 'register Call')
if (!await props.options.appManager.isActive('debugger')) await props.options.appManager.activatePlugin('debugger')
props.thisState.call('menuicons', 'select', 'debugger')
props.thisState.call('debugger', 'debug', hash)
})
}
...@@ -67,6 +67,17 @@ export const registerCommandReducer = (state, action) => { ...@@ -67,6 +67,17 @@ export const registerCommandReducer = (state, action) => {
commands: Object.assign(initialState.commands, action.payload.commands), commands: Object.assign(initialState.commands, action.payload.commands),
data: Object.assign(initialState.data, action.payload.data) data: Object.assign(initialState.data, action.payload.data)
} }
case 'clearconsole':
return {
...state,
...state.journalBlocks.splice(0)
}
case 'listenOnNetWork':
console.log({ action: action.payload })
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-info' })
}
default : default :
return { state } return { state }
} }
...@@ -75,14 +86,12 @@ export const registerCommandReducer = (state, action) => { ...@@ -75,14 +86,12 @@ export const registerCommandReducer = (state, action) => {
export const registerFilterReducer = (state, action) => { export const registerFilterReducer = (state, action) => {
switch (action.type) { switch (action.type) {
case 'log': case 'log':
console.log({ action }, { state }, 'register Filter')
return { return {
...state, ...state,
data: Object.assign(initialState.data.filterFns, action.payload.data.filterFns) data: Object.assign(initialState.data.filterFns, action.payload.data.filterFns)
} }
case 'info': case 'info':
console.log({ action }, 'registerFilter')
return { return {
...state, ...state,
data: Object.assign(initialState.data.filterFns, action.payload.data.filterFns) data: Object.assign(initialState.data.filterFns, action.payload.data.filterFns)
...@@ -132,7 +141,8 @@ export const remixWelcomeTextReducer = (state, action) => { ...@@ -132,7 +141,8 @@ export const remixWelcomeTextReducer = (state, action) => {
} }
export const registerScriptRunnerReducer = (state, action) => { export const registerScriptRunnerReducer = (state, action) => {
console.log({ state }, { action }, 'register script runner reducer') const result = Object.assign([], action.payload.message)
console.log({ result })
switch (action.type) { switch (action.type) {
case 'log': case 'log':
return { return {
...@@ -159,5 +169,26 @@ export const registerScriptRunnerReducer = (state, action) => { ...@@ -159,5 +169,26 @@ export const registerScriptRunnerReducer = (state, action) => {
...state, ...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-log' }) journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: 'text-log' })
} }
case 'knownTransaction':
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'knownTransaction' })
}
case 'unknownTransaction':
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'knownTransaction' })
}
case 'emptyBlock':
console.log({ action: action.payload.message }, ' emptyBLock reducer')
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '', name: 'emptyBlock' })
}
case 'newTransaction':
return {
...state,
journalBlocks: initialState.journalBlocks.push({ message: action.payload.message, style: '' })
}
} }
} }
...@@ -17,6 +17,18 @@ element.style { ...@@ -17,6 +17,18 @@ element.style {
input #terminalCliInput { input #terminalCliInput {
} }
.border-primary {
border-color: #007aa6!important;
}
.border {
border: 1px solid #3f4455!important;
}
.selectedOptions {
background-color: #222336;
}
.panel { .panel {
position : relative; position : relative;
display : flex; display : flex;
...@@ -138,6 +150,10 @@ input #terminalCliInput { ...@@ -138,6 +150,10 @@ input #terminalCliInput {
cursor : row-resize; cursor : row-resize;
z-index : 999; z-index : 999;
} }
.console {
cursor : pointer;
}
.dragbarHorizontal:hover { .dragbarHorizontal:hover {
background-color: #007AA6; background-color: #007AA6;
...@@ -171,7 +187,6 @@ input #terminalCliInput { ...@@ -171,7 +187,6 @@ input #terminalCliInput {
.popup { .popup {
position : absolute; position : absolute;
text-align : left; text-align : left;
display : none;
width : 95%; width : 95%;
font-family : monospace; font-family : monospace;
background-color : var(--secondary); background-color : var(--secondary);
...@@ -234,4 +249,108 @@ input #terminalCliInput { ...@@ -234,4 +249,108 @@ input #terminalCliInput {
@keyframes animatetop { @keyframes animatetop {
from {bottom: -300px; opacity: 0} from {bottom: -300px; opacity: 0}
to {bottom: 0; opacity: 1} to {bottom: 0; opacity: 1}
} }
\ No newline at end of file
/* tx logger css*/
.log {
display: flex;
cursor: pointer;
align-items: center;
cursor: pointer;
}
.log:hover {
opacity: 0.8;
}
.arrow {
color: var(--text-info);
font-size: 20px;
cursor: pointer;
display: flex;
margin-left: 10px;
}
.arrow:hover {
color: var(--secondary);
}
.txLog {
}
.txStatus {
display: flex;
font-size: 20px;
margin-right: 20px;
float: left;
}
.succeeded {
color: var(--success);
}
.failed {
color: var(--danger);
}
.notavailable {
}
.call {
font-size: 7px;
border-radius: 50%;
min-width: 20px;
min-height: 20px;
display: flex;
justify-content: center;
align-items: center;
color: var(--text-info);
text-transform: uppercase;
font-weight: bold;
}
.txItem {
color: var(--text-info);
margin-right: 5px;
float: left;
}
.txItemTitle {
font-weight: bold;
}
.tx {
color: var(--text-info);
font-weight: bold;
float: left;
margin-right: 10px;
}
.txTable,
.tr,
.td {
border-collapse: collapse;
font-size: 10px;
color: var(--text-info);
border: 1px solid var(--text-info);
}
#txTable {
margin-top: 1%;
margin-bottom: 5%;
align-self: center;
width: 85%;
}
.tr, .td {
padding: 4px;
vertical-align: baseline;
}
.td:first-child {
min-width: 30%;
width: 30%;
align-items: baseline;
font-weight: bold;
}
.tableTitle {
width: 25%;
}
.buttons {
display: flex;
margin-left: auto;
}
.debug {
white-space: nowrap;
}
.debug:hover {
opacity: 0.8;
}
// var async = require('async')
// const ethJSUtil = require('ethereumjs-util')
// export const shortenAddress = (address, etherBalance) => {
// var len = address.length
// return address.slice(0, 5) + '...' + address.slice(len - 5, len) + (etherBalance ? ' (' + etherBalance.toString() + ' ether)' : '')
// }
// export const addressToString = (address) => {
// if (!address) return null
// if (typeof address !== 'string') {
// address = address.toString('hex')
// }
// if (address.indexOf('0x') === -1) {
// address = '0x' + address
// }
// return ethJSUtil.toChecksumAddress(address)
// }
// export const shortenHexData = (data) => {
// if (!data) return ''
// if (data.length < 5) return data
// var len = data.length
// return data.slice(0, 5) + '...' + data.slice(len - 5, len)
// }
// export const createNonClashingNameWithPrefix = (name, fileProvider, prefix, cb) => {
// if (!name) name = 'Undefined'
// var counter = ''
// var ext = 'sol'
// var reg = /(.*)\.([^.]+)/g
// var split = reg.exec(name)
// if (split) {
// name = split[1]
// ext = split[2]
// }
// var exist = true
// async.whilst(
// () => { return exist },
// (callback) => {
// fileProvider.exists(name + counter + prefix + '.' + ext).then(currentExist => {
// exist = currentExist
// if (exist) counter = (counter | 0) + 1
// callback()
// }).catch(error => {
// if (error) console.log(error)
// })
// },
// (error) => { cb(error, name + counter + prefix + '.' + ext) }
// )
// }
// export const createNonClashingName = (name, fileProvider, cb) => {
// this.createNonClashingNameWithPrefix(name, fileProvider, '', cb)
// },
// export const createNonClashingNameAsync = async (name, fileManager, prefix = '') => {
// if (!name) name = 'Undefined'
// let counter = ''
// let ext = 'sol'
// const reg = /(.*)\.([^.]+)/g
// const split = reg.exec(name)
// if (split) {
// name = split[1]
// ext = split[2]
// }
// let exist = true
// do {
// const isDuplicate = await fileManager.exists(name + counter + prefix + '.' + ext)
// if (isDuplicate) counter = (counter | 0) + 1
// else exist = false
// } while (exist)
// return name + counter + prefix + '.' + ext
// }
// export const createNonClashingDirNameAsync = async (name, fileManager) => {
// if (!name) name = 'Undefined'
// let counter = ''
// let exist = true
// do {
// const isDuplicate = await fileManager.exists(name + counter)
// if (isDuplicate) counter = (counter | 0) + 1
// else exist = false
// } while (exist)
// return name + counter
// }
// export const checkSpecialChars = (name) => {
// return name.match(/[:*?"<>\\'|]/) != null
// }
// export const checkSlash = (name) => {
// return name.match(/\//) != null
// }
// export const isHexadecimal = (value) => {
// return /^[0-9a-fA-F]+$/.test(value) && (value.length % 2 === 0)
// }
// export const is0XPrefixed = (value) => {
// return value.substr(0, 2) === '0x'
// }
// export const isNumeric = (value) => {
// return /^\+?(0|[1-9]\d*)$/.test(value)
// }
// export const isValidHash = (hash) => { // 0x prefixed, hexadecimal, 64digit
// const hexValue = hash.slice(2, hash.length)
// return this.is0XPrefixed(hash) && /^[0-9a-fA-F]{64}$/.test(hexValue)
// }
// export const removeTrailingSlashes = (text) {
// // Remove single or consecutive trailing slashes
// return text.replace(/\/+$/g, '')
// },
// removeMultipleSlashes (text) {
// // Replace consecutive slashes with '/'
// return text.replace(/\/+/g, '/')
// },
// find: find,
// getPathIcon (path) {
// return path.endsWith('.txt')
// ? 'far fa-file-alt' : path.endsWith('.md')
// ? 'far fa-file-alt' : path.endsWith('.sol')
// ? 'fak fa-solidity-mono' : path.endsWith('.js')
// ? 'fab fa-js' : path.endsWith('.json')
// ? 'fas fa-brackets-curly' : path.endsWith('.vy')
// ? 'fak fa-vyper-mono' : path.endsWith('.lex')
// ? 'fak fa-lexon' : path.endsWith('.contract')
// ? 'fab fa-ethereum' : 'far fa-file'
// },
// joinPath (...paths) {
// paths = paths.filter((value) => value !== '').map((path) => path.replace(/^\/|\/$/g, '')) // remove first and last slash)
// if (paths.length === 1) return paths[0]
// return paths.join('/')
// },
// extractNameFromKey (key) {
// const keyPath = key.split('/')
// return keyPath[keyPath.length - 1]
// }
// const findDeep = (object, fn, found = { break: false, value: undefined }) => {
// if (typeof object !== 'object' || object === null) return
// for (var i in object) {
// if (found.break) break
// var el = object[i]
// if (el && el.innerText !== undefined && el.innerText !== null) el = el.innerText
// if (fn(el, i, object)) {
// found.value = el
// found.break = true
// break
// } else {
// findDeep(el, fn, found)
// }
// }
// return found.value
// }
// const find = (args, query) => {
// query = query.trim()
// var isMatch = !!findDeep(args, function check (value, key) {
// if (value === undefined || value === null) return false
// if (typeof value === 'function') return false
// if (typeof value === 'object') return false
// var contains = String(value).indexOf(query.trim()) !== -1
// return contains
// })
// return isMatch
// }
...@@ -6,3 +6,37 @@ export const getKeyOf = (item) => { ...@@ -6,3 +6,37 @@ export const getKeyOf = (item) => {
export const getValueOf = (item) => { export const getValueOf = (item) => {
return Object.values(item)[0] return Object.values(item)[0]
} }
export const Objectfilter = (obj: any, filterValue: any) =>
obj.filter((item: any) => Object.keys(item)[0].indexOf(filterValue) > -1)
export const matched = (arr, value) => arr.map(x => Object.keys(x).some(x => x.startsWith(value))).some(x => x === true)
const findDeep = (object, fn, found = { break: false, value: undefined }) => {
if (typeof object !== 'object' || object === null) return
for (var i in object) {
if (found.break) break
var el = object[i]
if (el && el.innerText !== undefined && el.innerText !== null) el = el.innerText
if (fn(el, i, object)) {
found.value = el
found.break = true
break
} else {
findDeep(el, fn, found)
}
}
return found.value
}
export const find = (args, query) => {
query = query.trim()
var isMatch = !!findDeep(args, function check (value) {
if (value === undefined || value === null) return false
if (typeof value === 'function') return false
if (typeof value === 'object') return false
var contains = String(value).indexOf(query.trim()) !== -1
return contains
})
return isMatch
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment