git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 1a2a7cd98d2edb747a07a96b71f6315497059c94

Kernel: move contract deployment to the right place

Alex Beregszaszi committed on 8/23/2016, 12:27:46 AM
Parent: 6d71f9bda86609025af68d2581863e0ecb6685f6

Files changed

index.jschanged
index.jsView
@@ -61,8 +61,18 @@
6161 // Detects if code is EVM or WASM
6262 // Detects if the code injection is needed
6363 // Detects if transcompilation is needed
6464 callHandler (address, gaslimit, gasprice, value, data) {
65+ // Special case: contract deployment
66+ // FIXME: place this in the best location with the best condition checking
67+ if (address === 0) {
68+ if (data) {
69+ let codeHash = sha3(data)
70+ this.environment.state.set(codeHash, data);
71+ this.environment.state.set(new Uint8Array(address).toString(), { balance: value, codeHash: codeHash })
72+ }
73+ }
74+
6575 var account = this.environment.state.get(new Uint8Array(address).toString())
6676 if (!account) {
6777 throw new Error('Account not found')
6878 }
@@ -109,14 +119,8 @@
109119 // - reduce balance
110120
111121 this.environment = environment
112122
113- // Contract deployment
114- //const isDeployment = tx.data && !tx.to;
115- //if (isDeployment) {
116- // this.environment.accounts.set(new Uint8Array())
117- //}
118-
119123 //
120124 // environment.state - the merkle tree
121125 // key: address (20 byte, hex string, without 0x prefix)
122126 // every path has an account

Built with git-ssb-web