Merge pull request #1047 from embark-framework/bug_fix/accounts-on-deploy

Fix $accounts not being replaced in onDeploy
This commit is contained in:
Iuri Matias 2018-11-08 16:47:24 -05:00 committed by GitHub
commit b66ac70050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -15,7 +15,7 @@ class ContractDeployer {
}
// TODO: determining the arguments could also be in a module since it's not
// part of ta 'normal' contract deployment
// part of a 'normal' contract deployment
determineArguments(suppliedArgs, contract, accounts, callback) {
const self = this;

View File

@ -37,9 +37,23 @@ class SpecialConfigs {
replaceWithAddresses(cmd, cb) {
const self = this;
let regex = /\$\w+/g;
stringReplaceAsync.seq(cmd, regex, (match) => {
let regex = /\$\w+\[?\d?\]?/g;
stringReplaceAsync.seq(cmd, regex, (match, index) => {
return (new Promise((resolve, reject) => {
if (match.startsWith('$accounts')) {
let accountIndex = cmd.substring(index + 10, index + 12);
accountIndex = parseInt(accountIndex, 10);
return self.events.request('blockchain:getAccounts', (err, accounts) => {
if (err) {
return reject('Error getting accounts: ' + err.message || err);
}
if (!accounts[accountIndex]) {
return reject(__('No corresponding account at index %d', accountIndex));
}
resolve(accounts[accountIndex]);
});
}
let referedContractName = match.slice(1);
self.events.request('contracts:contract', referedContractName, (referedContract) => {
if (!referedContract) {