mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-20 01:18:52 +00:00
fix(contracts): replace $accounts for onDeploy too
This was intended from the start, but was only done for args
This commit is contained in:
parent
3cf9ea6045
commit
8831dfb0ee
@ -15,7 +15,7 @@ class ContractDeployer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: determining the arguments could also be in a module since it's not
|
// 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) {
|
determineArguments(suppliedArgs, contract, accounts, callback) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
@ -37,9 +37,23 @@ class SpecialConfigs {
|
|||||||
replaceWithAddresses(cmd, cb) {
|
replaceWithAddresses(cmd, cb) {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
let regex = /\$\w+/g;
|
let regex = /\$\w+\[?\d?\]?/g;
|
||||||
stringReplaceAsync.seq(cmd, regex, (match) => {
|
stringReplaceAsync.seq(cmd, regex, (match, index) => {
|
||||||
return (new Promise((resolve, reject) => {
|
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);
|
let referedContractName = match.slice(1);
|
||||||
self.events.request('contracts:contract', referedContractName, (referedContract) => {
|
self.events.request('contracts:contract', referedContractName, (referedContract) => {
|
||||||
if (!referedContract) {
|
if (!referedContract) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user