Commit 1039324df6ed695b396944c8d6f5f4157f3bf6ce
Kernel: execute contract in createHandler to retrieve the runtime bytecode
Alex Beregszaszi committed on 8/26/2016, 9:40:45 PMParent: 05bf86af31b825ac9b412fbc4b18522d2b40e829
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -126,17 +126,22 @@ | ||
126 | 126 | } |
127 | 127 | |
128 | 128 | createHandler (create) { |
129 | 129 | // Inject metering |
130 | - const code = this.callHandler({ to: meteringContract, data: create.data }).returnValue | |
130 | + const code = this.callHandler({ to: meteringContract, data: code }).returnValue | |
131 | 131 | |
132 | 132 | let address = Utils.newAccountAddress(create.from, code) |
133 | 133 | |
134 | 134 | this.environment.addAccount(address.toString(), { |
135 | 135 | balance: create.value, |
136 | 136 | code: code |
137 | 137 | }) |
138 | 138 | |
139 | + // Run code and take return value as contract code | |
140 | + code = this.callHandler({ from: create.from, to: address, gasLimit: create.gasLimit }).returnValue | |
141 | + | |
142 | + this.environment.state.get(address.toString()).set('code', code) | |
143 | + | |
139 | 144 | return { |
140 | 145 | accountCreated: address |
141 | 146 | } |
142 | 147 | } |
@@ -174,9 +179,9 @@ | ||
174 | 179 | return this.createHandler({ |
175 | 180 | from: tx.from, |
176 | 181 | gasLimit: tx.gasLimit, |
177 | 182 | value: tx.value, |
178 | - data: txdata | |
183 | + data: tx.data | |
179 | 184 | }) |
180 | 185 | } |
181 | 186 | } |
182 | 187 |
Built with git-ssb-web