check for valid tx hash

pull/775/head
lianahus 4 years ago committed by Liana Husikyan
parent aa5d097e07
commit 18914407d9
  1. 2
      apps/remix-ide/src/app/tabs/debugger-tab.js
  2. 4
      apps/remix-ide/src/lib/helper.js
  3. 18
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx

@ -6,9 +6,9 @@ import * as packageJson from '../../../../../package.json'
import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom'
import modalDialogCustom from '../ui/modal-dialog-custom'
import bleach from '../../lib/bleach'
const yo = require('yo-yo')
const css = require('./styles/debugger-tab-styles')
import bleach from '../../lib/bleach'
const profile = {
name: 'debugger',

@ -64,6 +64,10 @@ module.exports = {
isNumeric (value) {
return /^\+?(0|[1-9]\d*)$/.test(value)
},
isValidHash (hash) { // 0x prefixed, hexadecimal, 64digit
const hexValue = hash.slice(2, hash.length)
return this.is0XPrefixed(hash) && /^[0-9a-fA-F]{64}$/.test(hexValue)
},
find: find
}

@ -8,6 +8,7 @@ import { DebuggerUIProps } from './idebugger-api' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
/* eslint-disable-next-line */
import './debugger-ui.css'
const helper = require('../../../../../apps/remix-ide/src/lib/helper')
export const DebuggerUI = (props: DebuggerUIProps) => {
const debuggerModule = props.debuggerAPI
@ -26,7 +27,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
debugWithGeneratedSources: false
},
toastMessage: '',
currentDebugTransaction: '',
validationError: '',
txNumberIsEmpty: true
})
@ -144,7 +144,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
vmDebuggerHead: false
},
debugging: false,
currentDebugTransaction: ''
txNumber: ''
}
})
}
@ -154,9 +154,19 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
setState(prevState => {
return {
...prevState,
currentDebugTransaction: txNumber
txNumber: txNumber
}
})
if (!helper.isValidHash(txNumber)) {
setState(prevState => {
return {
...prevState,
validationError: 'Invalid transaction hash.'
}
})
return
}
const web3 = await debuggerModule.getDebugWeb3()
let currentReceipt
try {
@ -186,6 +196,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
},
debugWithGeneratedSources: state.opt.debugWithGeneratedSources
})
debuggerInstance.debug(blockNumber, txNumber, tx, () => {
listenToEvents(debuggerInstance, currentReceipt)
setState(prevState => {
@ -210,7 +221,6 @@ export const DebuggerUI = (props: DebuggerUIProps) => {
validationError: message
}
})
console.log(message)
}
unLoad()
})

Loading…
Cancel
Save