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