Commit ed1a622c86d302461688dd47df71585c8e5e74e4
Merge branch 'master' into refractor_async_testing
wanderer committed on 10/30/2016, 5:46:47 PMParent: 84e730af9e78896d112fb5818ef323f5d767f569
Parent: 48ac29e384052f91a71431f96b509f0fe11684fb
Files changed
deps/utils.js | changed |
index.js | changed |
deps/utils.js | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 | Utils.isWASMCode = function (code) { |
7 | 7 | return code.slice(0, 4).toString() === new Uint8Array([0, 0x61, 0x73, 0x6d]).toString() |
8 | 8 | } |
9 | 9 | |
10 | -Utils.newAccountAddress = function (sender, data) { | |
11 | - return new Address('0x' + ethUtil.sha3(Buffer.concat([ sender.toBuffer(), Buffer.from(data) ])).slice(0, 20).toString('hex')) | |
10 | +Utils.newAccountAddress = function (sender, nonce) { | |
11 | + return new Address('0x' + ethUtil.generateAddress(sender.toString(), nonce.toString()).toString('hex')) | |
12 | 12 | } |
13 | 13 | |
14 | 14 | module.exports = Utils |
index.js | ||
---|---|---|
@@ -180,10 +180,15 @@ | ||
180 | 180 | throw new Error('Metering injection failed: ' + Buffer.from(code).slice(1).toString()) |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - let address = Utils.newAccountAddress(create.from, code) | |
184 | + let account = this.environment.state.get(create.from.toString()) | |
185 | + if (!account) { | |
186 | + throw new Error('Account not found: ' + create.from.toString()) | |
187 | + } | |
185 | 188 | |
189 | + let address = Utils.newAccountAddress(create.from, account.get('nonce')) | |
190 | + | |
186 | 191 | this.environment.addAccount(address.toString(), { |
187 | 192 | balance: create.value, |
188 | 193 | code: code |
189 | 194 | }) |
Built with git-ssb-web