fix parsing int

pull/5370/head
yann300 8 months ago
parent ca024e2f02
commit b464b88c0f
  1. 8
      libs/remix-lib/src/helpers/txResultHelper.ts

@ -1,6 +1,8 @@
'use strict' 'use strict'
import { bytesToHex } from '@ethereumjs/util' import { bytesToHex } from '@ethereumjs/util'
import { isHexString } from 'ethjs-util' import { isHexString } from 'ethjs-util'
import { BN } from 'bn.js'
import { isBigInt } from 'web3-validator'
function convertToPrefixedHex (input) { function convertToPrefixedHex (input) {
if (input === undefined || input === null || isHexString(input)) { if (input === undefined || input === null || isHexString(input)) {
@ -9,6 +11,9 @@ function convertToPrefixedHex (input) {
if (typeof input === 'number') { if (typeof input === 'number') {
return '0x' + input.toString(16) return '0x' + input.toString(16)
} }
if ((input.constructor && input.constructor.name === 'BigNumber') || BN.isBN(input) || isBigInt(input)) {
return '0x' + input.toString(16)
}
try { try {
return bytesToHex(input) return bytesToHex(input)
@ -47,10 +52,9 @@ export function resultToRemixTx (txResult, execResult?) {
errorMessage = execResult.exceptionError errorMessage = execResult.exceptionError
} }
console.log('resultToRemixTx', gasUsed, convertToPrefixedHex(gasUsed))
return { return {
transactionHash, transactionHash,
status, status: convertToPrefixedHex(status),
gasUsed: convertToPrefixedHex(gasUsed), gasUsed: convertToPrefixedHex(gasUsed),
error: errorMessage, error: errorMessage,
return: returnValue ? convertToPrefixedHex(returnValue) : undefined, return: returnValue ? convertToPrefixedHex(returnValue) : undefined,

Loading…
Cancel
Save