helpers erc updated

toaster-react
aniket-engg 4 years ago committed by Aniket
parent 79e564b547
commit 142d6478d9
  1. 6
      libs/remix-lib/src/helpers/compilerHelper.ts
  2. 9
      libs/remix-lib/src/helpers/txResultHelper.ts
  3. 26
      libs/remix-lib/src/helpers/uiHelper.ts

@ -1,8 +1,4 @@
module.exports = {
compilerInput: compilerInput
}
function compilerInput (contracts) {
export function compilerInput (contracts) {
return JSON.stringify({
language: 'Solidity',
sources: {

@ -1,5 +1,6 @@
'use strict'
const { bufferToHex, isHexString } = require('ethereumjs-util')
import { bufferToHex } from 'ethereumjs-util'
import { isHexString } from 'ethjs-util'
function convertToPrefixedHex (input) {
if (input === undefined || input === null || isHexString(input)) {
@ -19,7 +20,7 @@ function convertToPrefixedHex (input) {
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) {
export function resultToRemixTx (txResult) {
const { result, transactionHash } = txResult
const { status, execResult, gasUsed, createdAddress, contractAddress } = result
let returnValue, errorMessage
@ -40,7 +41,3 @@ function resultToRemixTx (txResult) {
createdAddress: convertToPrefixedHex(createdAddress || contractAddress)
}
}
module.exports = {
resultToRemixTx
}

@ -1,6 +1,5 @@
'use strict'
module.exports = {
formatMemory: function (mem, width) {
export function formatMemory (mem, width) {
const ret = {}
if (!mem) {
return ret
@ -16,9 +15,9 @@ module.exports = {
ret['0x' + (k / 2).toString(16)] = content.raw + '\t' + content.ascii
}
return ret
},
}
tryConvertAsciiFormat: function (memorySlot) {
export function tryConvertAsciiFormat (memorySlot) {
const ret = { ascii: '', raw: '' }
for (let k = 0; k < memorySlot.length; k += 2) {
const raw = memorySlot.substr(k, 2)
@ -31,9 +30,9 @@ module.exports = {
ret.raw += raw
}
return ret
},
}
/**
/**
* format @args css1, css2, css3 to css inline style
*
* @param {Object} css1 - css inline declaration
@ -44,7 +43,7 @@ module.exports = {
* if the key start with * the value is direcly appended to the inline style (which should be already inline style formatted)
* used if multiple occurences of the same key is needed
*/
formatCss: function (css1, css2) {
export function formatCss (css1, css2) {
let ret = ''
for (let arg in arguments) {
for (let k in arguments[arg]) {
@ -58,17 +57,17 @@ module.exports = {
}
}
return ret
},
}
normalizeHex: function (hex) {
export function normalizeHex (hex) {
if (hex.indexOf('0x') === 0) {
hex = hex.replace('0x', '')
}
hex = hex.replace(/^0+/, '')
return '0x' + hex
},
}
normalizeHexAddress: function (hex) {
export function normalizeHexAddress (hex) {
if (hex.indexOf('0x') === 0) hex = hex.replace('0x', '')
if (hex.length >= 40) {
const reg = /(.{40})$/.exec(hex)
@ -78,9 +77,8 @@ module.exports = {
} else {
return '0x' + (new Array(40 - hex.length + 1).join('0')) + hex
}
},
}
runInBrowser: function () {
export function runInBrowser () {
return typeof window !== 'undefined'
}
}

Loading…
Cancel
Save