-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give the same ability to config function on test than when running with embark run
- Loading branch information
1 parent
3a8808e
commit e3a7b74
Showing
4 changed files
with
52 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { extendZeroAddressShorthand, replaceZeroAddressShorthand } from "./addressUtils"; | ||
import { unitRegex } from "./regexConstants"; | ||
|
||
const web3 = require("web3"); | ||
const utils = require("./utils.js"); | ||
|
||
export function prepare(config: any) { | ||
Object.keys(config.contracts).forEach((contractName) => { | ||
const gas = config.contracts[contractName].gas; | ||
const gasPrice = config.contracts[contractName].gasPrice; | ||
const address = config.contracts[contractName].address; | ||
const args = config.contracts[contractName].args; | ||
const onDeploy = config.contracts[contractName].onDeploy; | ||
|
||
if (gas && gas.match(unitRegex)) { | ||
config.contracts[contractName].gas = utils.getWeiBalanceFromString(gas, web3); | ||
} | ||
|
||
if (gasPrice && gasPrice.match(unitRegex)) { | ||
config.contracts[contractName].gasPrice = utils.getWeiBalanceFromString(gasPrice, web3); | ||
} | ||
|
||
if (address) { | ||
config.contracts[contractName].address = extendZeroAddressShorthand(address); | ||
} | ||
|
||
if (args && args.length) { | ||
config.contracts[contractName].args = args.map((val: any) => { | ||
if (typeof val === "string") { | ||
return extendZeroAddressShorthand(val); | ||
} | ||
return val; | ||
}); | ||
} | ||
|
||
if (Array.isArray(onDeploy)) { | ||
config.contracts[contractName].onDeploy = onDeploy.map(replaceZeroAddressShorthand); | ||
} | ||
}); | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const unitRegex = /([0-9]+) ([a-zA-Z]+)/; |