mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
fix(@embark/deploy-tracker): fix getting the block 0 with sim --fork
This commit is contained in:
parent
1b6987ee8f
commit
f6d7a54195
@ -58,26 +58,37 @@ class DeployTracker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentChain(cb) {
|
setCurrentChain(callback) {
|
||||||
const self = this;
|
const self = this;
|
||||||
if (this.chainConfig === false) {
|
if (this.chainConfig === false) {
|
||||||
this.currentChain = {contracts: []};
|
this.currentChain = {contracts: []};
|
||||||
return cb();
|
return callback();
|
||||||
}
|
}
|
||||||
this.events.request("blockchain:block:byNumber", 0, function(err, block) {
|
|
||||||
|
function getBlock(blockNum, cb) {
|
||||||
|
self.events.request("blockchain:block:byNumber", blockNum, (err, block) => {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
let chainId = block.hash;
|
||||||
|
|
||||||
|
if (self.chainConfig[chainId] === undefined) {
|
||||||
|
self.chainConfig[chainId] = {contracts: {}};
|
||||||
|
}
|
||||||
|
|
||||||
|
self.currentChain = self.chainConfig[chainId];
|
||||||
|
|
||||||
|
self.currentChain.name = self.env;
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getBlock(0, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
// Retry with block 1 (Block 0 fails with Ganache-cli using the --fork option)
|
||||||
|
return getBlock(1, callback);
|
||||||
}
|
}
|
||||||
let chainId = block.hash;
|
callback();
|
||||||
|
|
||||||
if (self.chainConfig[chainId] === undefined) {
|
|
||||||
self.chainConfig[chainId] = {contracts: {}};
|
|
||||||
}
|
|
||||||
|
|
||||||
self.currentChain = self.chainConfig[chainId];
|
|
||||||
|
|
||||||
self.currentChain.name = self.env;
|
|
||||||
cb();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user