@ -1,10 +1,12 @@
import React from 'react' // eslint-disable-line
import React from 'react' // eslint-disable-line
import { FormattedMessage , useIntl } from 'react-intl'
import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line
import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line
import { shortenHexData } from '@remix-ui/helper'
import { shortenHexData } from '@remix-ui/helper'
import { execution } from '@remix-project/remix-lib'
import { execution } from '@remix-project/remix-lib'
const typeConversion = execution . typeConversion
const typeConversion = execution . typeConversion
const showTable = ( opts , showTableHash ) = > {
const showTable = ( opts , showTableHash ) = > {
const intl = useIntl ( )
let msg = ''
let msg = ''
let toHash
let toHash
const data = opts . data // opts.data = data.tx
const data = opts . data // opts.data = data.tx
@ -15,17 +17,17 @@ const showTable = (opts, showTableHash) => {
}
}
let callWarning = ''
let callWarning = ''
if ( opts . isCall ) {
if ( opts . isCall ) {
callWarning = '(Cost only applies when called by a contract)'
callWarning = intl . formatMessage ( { id : 'terminal.callWarning' } )
}
}
if ( ! opts . isCall ) {
if ( ! opts . isCall ) {
if ( opts . status !== undefined && opts . status !== null ) {
if ( opts . status !== undefined && opts . status !== null ) {
if ( opts . status === 0 || opts . status === '0x0' || opts . status === false ) {
if ( opts . status === 0 || opts . status === '0x0' || opts . status === false ) {
msg = 'Transaction mined but execution failed'
msg = intl . formatMessage ( { id : 'terminal.msg1' } )
} else if ( opts . status === 1 || opts . status === '0x1' || opts . status === true ) {
} else if ( opts . status === 1 || opts . status === '0x1' || opts . status === true ) {
msg = 'Transaction mined and execution succeed'
msg = intl . formatMessage ( { id : 'terminal.msg2' } )
}
}
} else {
} else {
msg = 'Status not available at the moment'
msg = intl . formatMessage ( { id : 'terminal.msg3' } )
}
}
}
}
@ -40,7 +42,7 @@ const showTable = (opts, showTableHash) => {
{ opts . status !== undefined ? (
{ opts . status !== undefined ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
status
< FormattedMessage id = "terminal.status" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableStatus ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } > { ` ${ opts . status } ${ msg } ` } < / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableStatus ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } > { ` ${ opts . status } ${ msg } ` } < / td >
< / tr >
< / tr >
@ -48,7 +50,7 @@ const showTable = (opts, showTableHash) => {
{ opts . hash && ! opts . isCall ? (
{ opts . hash && ! opts . isCall ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
transaction hash
< FormattedMessage id = "terminal.transactionHash" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts . hash }
{ opts . hash }
@ -59,7 +61,7 @@ const showTable = (opts, showTableHash) => {
{ opts . blockHash ? (
{ opts . blockHash ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
block hash
< FormattedMessage id = "terminal.blockHash" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableContractAddress ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableContractAddress ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts . blockHash }
{ opts . blockHash }
@ -70,7 +72,7 @@ const showTable = (opts, showTableHash) => {
{ opts . blockNumber ? (
{ opts . blockNumber ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
block number
< FormattedMessage id = "terminal.blockNumber" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableContractAddress ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableContractAddress ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts . blockNumber }
{ opts . blockNumber }
@ -81,7 +83,7 @@ const showTable = (opts, showTableHash) => {
{ opts . contractAddress ? (
{ opts . contractAddress ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
contract address
< FormattedMessage id = "terminal.contractAddress" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableContractAddress ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableContractAddress ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts . contractAddress }
{ opts . contractAddress }
@ -125,7 +127,7 @@ const showTable = (opts, showTableHash) => {
{ opts . transactionCost ? (
{ opts . transactionCost ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
transaction cost
< FormattedMessage id = "terminal.transactionCost" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableTransactionCost ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableTransactionCost ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts . transactionCost } gas { callWarning }
{ opts . transactionCost } gas { callWarning }
@ -136,7 +138,7 @@ const showTable = (opts, showTableHash) => {
{ opts . executionCost ? (
{ opts . executionCost ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
execution cost
< FormattedMessage id = "terminal.executionCost" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableExecutionHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableExecutionHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts . executionCost } gas { callWarning }
{ opts . executionCost } gas { callWarning }
@ -147,7 +149,7 @@ const showTable = (opts, showTableHash) => {
{ opts . input ? (
{ opts . input ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
input
< FormattedMessage id = "terminal.input" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ shortenHexData ( opts . input ) }
{ shortenHexData ( opts . input ) }
@ -158,7 +160,7 @@ const showTable = (opts, showTableHash) => {
{ opts [ 'decoded input' ] ? (
{ opts [ 'decoded input' ] ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
decoded input
< FormattedMessage id = "terminal.decodedInput" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts [ 'decoded input' ] . trim ( ) }
{ opts [ 'decoded input' ] . trim ( ) }
@ -169,7 +171,7 @@ const showTable = (opts, showTableHash) => {
{ opts [ 'decoded output' ] ? (
{ opts [ 'decoded output' ] ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
decoded output
< FormattedMessage id = "terminal.decodedOutput" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ opts [ 'decoded output' ] }
{ opts [ 'decoded output' ] }
@ -180,7 +182,7 @@ const showTable = (opts, showTableHash) => {
{ opts . logs ? (
{ opts . logs ? (
< tr className = "remix_ui_terminal_tr" >
< tr className = "remix_ui_terminal_tr" >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - shared = { ` key_ ${ opts . hash } ` } >
logs
< FormattedMessage id = "terminal.logs" / >
< / td >
< / td >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
< td className = "remix_ui_terminal_td" data - id = { ` txLoggerTableHash ${ opts . hash } ` } data - shared = { ` pair_ ${ opts . hash } ` } >
{ JSON . stringify ( stringified , null , '\t' ) }
{ JSON . stringify ( stringified , null , '\t' ) }