git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit ed1a622c86d302461688dd47df71585c8e5e74e4

Merge branch 'master' into refractor_async_testing

wanderer committed on 10/30/2016, 5:46:47 PM
Parent: 84e730af9e78896d112fb5818ef323f5d767f569
Parent: 48ac29e384052f91a71431f96b509f0fe11684fb

Files changed

deps/utils.jschanged
index.jschanged
deps/utils.jsView
@@ -6,9 +6,9 @@
66 Utils.isWASMCode = function (code) {
77 return code.slice(0, 4).toString() === new Uint8Array([0, 0x61, 0x73, 0x6d]).toString()
88 }
99
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'))
1212 }
1313
1414 module.exports = Utils
index.jsView
@@ -180,10 +180,15 @@
180180 throw new Error('Metering injection failed: ' + Buffer.from(code).slice(1).toString())
181181 }
182182 }
183183
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+ }
185188
189+ let address = Utils.newAccountAddress(create.from, account.get('nonce'))
190+
186191 this.environment.addAccount(address.toString(), {
187192 balance: create.value,
188193 code: code
189194 })

Built with git-ssb-web