Skip to content

Commit

Permalink
move udapp from remix-lib back to remix-ide
Browse files Browse the repository at this point in the history
  • Loading branch information
iurimatias authored and yann300 committed Feb 5, 2020
1 parent 3d426df commit 2ac2b64
Show file tree
Hide file tree
Showing 3 changed files with 422 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/blockchain/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ethJSUtil = require('ethereumjs-util')
const Personal = require('web3-eth-personal')
const Web3 = require('web3')

import { UniversalDApp } from 'remix-lib'
const UniversalDApp = require('./universalDapp')

class Blockchain {

Expand Down
46 changes: 46 additions & 0 deletions src/blockchain/txResultHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict'
const { bufferToHex, isHexString } = require('ethereumjs-util')

function convertToPrefixedHex (input) {
if (input === undefined || input === null || isHexString(input)) {
return input
} else if (Buffer.isBuffer(input)) {
return bufferToHex(input)
}
return '0x' + input.toString(16)
}

/*
txResult.result can be 3 different things:
- VM call or tx: ethereumjs-vm result object
- Node transaction: object returned from eth.getTransactionReceipt()
- Node call: return value from function call (not an object)
Also, VM results use BN and Buffers, Node results use hex strings/ints,
So we need to normalize the values to prefixed hex strings
*/
function resultToRemixTx (txResult) {
const { result, transactionHash } = txResult
const { status, execResult, gasUsed, createdAddress, contractAddress } = result
let returnValue, errorMessage

if (isHexString(result)) {
returnValue = result
} else if (execResult !== undefined) {
returnValue = execResult.returnValue
errorMessage = execResult.exceptionError
}

return {
transactionHash,
status,
gasUsed: convertToPrefixedHex(gasUsed),
error: errorMessage,
return: convertToPrefixedHex(returnValue),
createdAddress: convertToPrefixedHex(createdAddress || contractAddress)
}
}

module.exports = {
resultToRemixTx
}
Loading

0 comments on commit 2ac2b64

Please sign in to comment.