Commit 1a2a7cd98d2edb747a07a96b71f6315497059c94
Kernel: move contract deployment to the right place
Alex Beregszaszi committed on 8/23/2016, 12:27:46 AMParent: 6d71f9bda86609025af68d2581863e0ecb6685f6
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -61,8 +61,18 @@ | ||
61 | 61 | // Detects if code is EVM or WASM |
62 | 62 | // Detects if the code injection is needed |
63 | 63 | // Detects if transcompilation is needed |
64 | 64 | 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 | + | |
65 | 75 | var account = this.environment.state.get(new Uint8Array(address).toString()) |
66 | 76 | if (!account) { |
67 | 77 | throw new Error('Account not found') |
68 | 78 | } |
@@ -109,14 +119,8 @@ | ||
109 | 119 | // - reduce balance |
110 | 120 | |
111 | 121 | this.environment = environment |
112 | 122 | |
113 | - // Contract deployment | |
114 | - //const isDeployment = tx.data && !tx.to; | |
115 | - //if (isDeployment) { | |
116 | - // this.environment.accounts.set(new Uint8Array()) | |
117 | - //} | |
118 | - | |
119 | 123 | // |
120 | 124 | // environment.state - the merkle tree |
121 | 125 | // key: address (20 byte, hex string, without 0x prefix) |
122 | 126 | // every path has an account |
Built with git-ssb-web