Commit db23f70a authored by aniket-engg's avatar aniket-engg Committed by Aniket

txFormat and txHelper

parent 1678b0e9
'use strict' 'use strict'
const ethers = require('ethers') import { ethers } from 'ethers'
const helper = require('./txHelper') const helper = require('./txHelper')
const asyncJS = require('async') import { eachOfSeries } from 'async'
const solcLinker = require('solc/linker') import { linkBytecode } from 'solc/linker'
const ethJSUtil = require('ethereumjs-util') import { isValidAddress, addHexPrefix } from 'ethereumjs-util'
module.exports = { module.exports = {
...@@ -38,7 +38,7 @@ module.exports = { ...@@ -38,7 +38,7 @@ module.exports = {
* @param {Function} callback - callback * @param {Function} callback - callback
*/ */
encodeParams: function (params, funAbi, callback) { encodeParams: function (params, funAbi, callback) {
let data = '' let data: any = ''
let dataHex = '' let dataHex = ''
let funArgs let funArgs
if (params.indexOf('raw:0x') === 0) { if (params.indexOf('raw:0x') === 0) {
...@@ -104,7 +104,7 @@ module.exports = { ...@@ -104,7 +104,7 @@ module.exports = {
for (let libFile in linkLibraries) { for (let libFile in linkLibraries) {
for (let lib in linkLibraries[libFile]) { for (let lib in linkLibraries[libFile]) {
const address = linkLibraries[libFile][lib] const address = linkLibraries[libFile][lib]
if (!ethJSUtil.isValidAddress(address)) return callback(address + ' is not a valid address. Please check the provided address is valid.') if (!isValidAddress(address)) return callback(address + ' is not a valid address. Please check the provided address is valid.')
bytecodeToDeploy = this.linkLibraryStandardFromlinkReferences(lib, address.replace('0x', ''), bytecodeToDeploy, linkReferences) bytecodeToDeploy = this.linkLibraryStandardFromlinkReferences(lib, address.replace('0x', ''), bytecodeToDeploy, linkReferences)
} }
} }
...@@ -168,7 +168,7 @@ module.exports = { ...@@ -168,7 +168,7 @@ module.exports = {
*/ */
buildData: function (contractName, contract, contracts, isConstructor, funAbi, params, callback, callbackStep, callbackDeployLibrary) { buildData: function (contractName, contract, contracts, isConstructor, funAbi, params, callback, callbackStep, callbackDeployLibrary) {
let funArgs = [] let funArgs = []
let data = '' let data: any = ''
let dataHex = '' let dataHex = ''
if (params.indexOf('raw:0x') === 0) { if (params.indexOf('raw:0x') === 0) {
...@@ -223,8 +223,8 @@ module.exports = { ...@@ -223,8 +223,8 @@ module.exports = {
linkBytecodeStandard: function (contract, contracts, callback, callbackStep, callbackDeployLibrary) { linkBytecodeStandard: function (contract, contracts, callback, callbackStep, callbackDeployLibrary) {
let contractBytecode = contract.evm.bytecode.object let contractBytecode = contract.evm.bytecode.object
asyncJS.eachOfSeries(contract.evm.bytecode.linkReferences, (libs, file, cbFile) => { eachOfSeries(contract.evm.bytecode.linkReferences, (libs, file, cbFile) => {
asyncJS.eachOfSeries(contract.evm.bytecode.linkReferences[file], (libRef, libName, cbLibDeployed) => { eachOfSeries(contract.evm.bytecode.linkReferences[file], (libRef, libName, cbLibDeployed) => {
const library = contracts[file][libName] const library = contracts[file][libName]
if (library) { if (library) {
this.deployLibrary(file + ':' + libName, libName, library, contracts, (error, address) => { this.deployLibrary(file + ':' + libName, libName, library, contracts, (error, address) => {
...@@ -351,7 +351,7 @@ module.exports = { ...@@ -351,7 +351,7 @@ module.exports = {
}, },
linkLibrary: function (libraryName, address, bytecodeToLink) { linkLibrary: function (libraryName, address, bytecodeToLink) {
return solcLinker.linkBytecode(bytecodeToLink, { [libraryName]: ethJSUtil.addHexPrefix(address) }) return linkBytecode(bytecodeToLink, { [libraryName]: addHexPrefix(address) })
}, },
decodeResponse: function (response, fnabi) { decodeResponse: function (response, fnabi) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment