check for valid tx hash

pull/5370/head
lianahus 4 years ago committed by Liana Husikyan
parent f7e5676d9a
commit 72f5311427
  1. 2
      apps/debugger/src/app/debugger-api.ts
  2. 2
      apps/remix-ide/src/app/tabs/debugger-tab.js
  3. 4
      apps/remix-ide/src/lib/helper.js
  4. 18
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx

@ -6,7 +6,7 @@ import type { CompilationResult } from '@remix-project/remix-solidity-ts'
export const DebuggerApiMixin = (Base) => class extends Base { export const DebuggerApiMixin = (Base) => class extends Base {
initDebuggerApi () { initDebuggerApi () {
this.debugHash = null this.debugHash = null
const self = this const self = this
this.web3Provider = { this.web3Provider = {
sendAsync (payload, callback) { sendAsync (payload, callback) {

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

@ -64,6 +64,10 @@ module.exports = {
isNumeric (value) { isNumeric (value) {
return /^\+?(0|[1-9]\d*)$/.test(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 find: find
} }

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

Loading…
Cancel
Save