Commit 20390909a4485d06cd4a720d5f69fc9deca7a9b3
Kernel: pass the correct details to callHandler from runTx
Alex Beregszaszi committed on 8/23/2016, 12:27:46 AMParent: 4c7c54ec09858f22c767210f0814625380b32c55
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -63,10 +63,10 @@ | ||
63 | 63 | // loads code from the merkle trie and delegates the message |
64 | 64 | // Detects if code is EVM or WASM |
65 | 65 | // Detects if the code injection is needed |
66 | 66 | // Detects if transcompilation is needed |
67 | - callHandler (address, gaslimit, gasprice, value, data) { | |
68 | - let account = this.environment.state.get(address.toString()) | |
67 | + callHandler (call) { | |
68 | + let account = this.environment.state.get(call.to.toString()) | |
69 | 69 | if (!account) { |
70 | 70 | throw new Error('Account not found') |
71 | 71 | } |
72 | 72 | |
@@ -79,11 +79,21 @@ | ||
79 | 79 | throw new Error('Not an eWASM contract') |
80 | 80 | } |
81 | 81 | |
82 | 82 | // creats a new Kernel |
83 | - const environment = new Environment(data) | |
83 | + const environment = new Environment() | |
84 | 84 | environment.parent = this |
85 | 85 | |
86 | + // copy the transaction details | |
87 | + environment.code = code | |
88 | + environment.address = call.to | |
89 | + // FIXME: make distinction between origin and caller | |
90 | + environment.origin = call.from | |
91 | + environment.caller = call.from | |
92 | + environment.callData = call.data | |
93 | + environment.callValue = call.value | |
94 | + environment.gasLimit = call.gasLimit | |
95 | + | |
86 | 96 | //environment.setCallHandler(callHandler) |
87 | 97 | |
88 | 98 | const kernel = new Kernel(this, environment) |
89 | 99 | kernel.codeHandler(code, new Interface(environment)) |
@@ -159,9 +169,15 @@ | ||
159 | 169 | } |
160 | 170 | |
161 | 171 | fromAccount.set('balance', fromAccount.get('balance').sub(tx.gasLimit.mul(tx.gasPrice))) |
162 | 172 | |
163 | - let ret = this.callHandler(tx.to, tx.gasLimit, tx.gasPrice, tx.value, tx.data) | |
173 | + let ret = this.callHandler({ | |
174 | + to: tx.to, | |
175 | + from: tx.from, | |
176 | + gasLimit: tx.gasLimit, | |
177 | + value: tx.value, | |
178 | + data: tx.data | |
179 | + }) | |
164 | 180 | |
165 | 181 | // refund gas |
166 | 182 | if (ret.executionOutcome === 1) { |
167 | 183 | fromAccount.set('balance', fromAccount.get('balance').add(tx.gasPrice.mul(ret.gasLeft.add(ret.gasRefund)))) |
Built with git-ssb-web