mirror of https://github.com/embarklabs/embark.git
Merge pull request #488 from embark-framework/default_account_fix
fix setting default account
This commit is contained in:
commit
6a10ef7187
|
@ -240,10 +240,12 @@ class Blockchain {
|
|||
});
|
||||
},
|
||||
function checkAccounts(next) {
|
||||
self.getAccounts(function(err, _accounts) {
|
||||
self.getAccounts(function(err, accounts) {
|
||||
if (err) {
|
||||
return next(NO_NODE_ERROR);
|
||||
}
|
||||
self.web3.defaultAccount = accounts[0];
|
||||
self.registerWeb3Object();
|
||||
return next();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ library Assert {
|
|||
|
||||
contract SimpleStorage is Ownable {
|
||||
uint public storedData;
|
||||
address public registar;
|
||||
|
||||
function() public payable { }
|
||||
|
||||
|
@ -39,4 +40,8 @@ contract SimpleStorage is Ownable {
|
|||
return "hello";
|
||||
}
|
||||
|
||||
function setRegistar(address x) public {
|
||||
registar = x;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ module.exports = {
|
|||
fromIndex: 0,
|
||||
args: [
|
||||
100
|
||||
],
|
||||
onDeploy: [
|
||||
"SimpleStorage.methods.setRegistar(web3.eth.defaultAccount).send()"
|
||||
]
|
||||
},
|
||||
AnotherStorage: {
|
||||
|
|
|
@ -5,7 +5,10 @@ const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
|
|||
config({
|
||||
contracts: {
|
||||
"SimpleStorage": {
|
||||
args: [100]
|
||||
args: [100],
|
||||
onDeploy: [
|
||||
"SimpleStorage.methods.setRegistar(web3.eth.defaultAccount).send()"
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -23,4 +26,10 @@ contract("SimpleStorage", function () {
|
|||
let result = await SimpleStorage.methods.get().call();
|
||||
assert.strictEqual(parseInt(result, 10), 499650);
|
||||
});
|
||||
|
||||
it("should set defaultAccount", async function () {
|
||||
let result = await SimpleStorage.methods.registar().call();
|
||||
assert.strictEqual(result, web3.eth.defaultAccount);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue