interface.jsView |
---|
86 | 86 | */ |
87 | 87 | getAddress (offset) { |
88 | 88 | this.takeGas(2) |
89 | 89 | |
90 | | - this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.address.toBuffer()) |
| 90 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.address.toMemory()) |
91 | 91 | } |
92 | 92 | |
93 | 93 | |
94 | 94 | * Gets balance of the given account and loads it into memory at the given |
98 | 98 | */ |
99 | 99 | getBalance (addressOffset, offset) { |
100 | 100 | this.takeGas(20) |
101 | 101 | |
102 | | - const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 102 | + const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
103 | 103 | |
104 | 104 | const balance = this.environment.getBalance(address) |
105 | | - this.setMemory(offset, constants.BALANCE_SIZE_BYTES, balance.toBuffer(constants.BALANCE_SIZE_BYTES)) |
| 105 | + this.setMemory(offset, constants.BALANCE_SIZE_BYTES, balance.toMemory(constants.BALANCE_SIZE_BYTES)) |
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | * Gets the execution's origination address and loads it into memory at the |
113 | 113 | */ |
114 | 114 | getTxOrigin (offset) { |
115 | 115 | this.takeGas(2) |
116 | 116 | |
117 | | - this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.origin.toBuffer()) |
| 117 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.origin.toMemory()) |
118 | 118 | } |
119 | 119 | |
120 | 120 | |
121 | 121 | * Gets caller address and loads it into memory at the given offset. This is |
124 | 124 | */ |
125 | 125 | getCaller (offset) { |
126 | 126 | this.takeGas(2) |
127 | 127 | |
128 | | - this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.caller.toBuffer()) |
| 128 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.caller.toMemory()) |
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | * Gets the deposited value by the instruction/transaction responsible for |
135 | 135 | */ |
136 | 136 | getCallValue (offset) { |
137 | 137 | this.takeGas(2) |
138 | 138 | |
139 | | - this.setMemory(offset, constants.BALANCE_SIZE_BYTES, this.environment.callValue.toBuffer(constants.BALANCE_SIZE_BYTES)) |
| 139 | + this.setMemory(offset, constants.BALANCE_SIZE_BYTES, this.environment.callValue.toMemory(constants.BALANCE_SIZE_BYTES)) |
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | 143 | * Get size of input data in current environment. This pertains to the input |
206 | 206 | */ |
207 | 207 | getExternalCodeSize (addressOffset) { |
208 | 208 | this.takeGas(20) |
209 | 209 | |
210 | | - const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 210 | + const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
211 | 211 | const code = this.environment.getCode(address) |
212 | 212 | return code.length |
213 | 213 | } |
214 | 214 | |
221 | 221 | */ |
222 | 222 | externalCodeCopy (addressOffset, resultOffset, codeOffset, length) { |
223 | 223 | this.takeGas(20 + ((length / 32) * 3)) |
224 | 224 | |
225 | | - const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 225 | + const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
226 | 226 | let code = this.environment.getCode(address) |
227 | 227 | code = new Uint8Array(code, codeOffset, length) |
228 | 228 | this.setMemory(resultOffset, length, code) |
229 | 229 | } |
253 | 253 | hash = new U256(0) |
254 | 254 | } else { |
255 | 255 | hash = new U256(this.environment.getBlockHash(number)) |
256 | 256 | } |
257 | | - this.setMemory(offset, 32, hash.toBuffer()) |
| 257 | + this.setMemory(offset, 32, hash.toMemory()) |
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | 261 | * Gets the block’s beneficiary address and loads into memory. |
263 | 263 | */ |
264 | 264 | getBlockCoinbase (offset) { |
265 | 265 | this.takeGas(2) |
266 | 266 | |
267 | | - this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.block.coinbase.toBuffer()) |
| 267 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.block.coinbase.toMemory()) |
268 | 268 | } |
269 | 269 | |
270 | 270 | |
271 | 271 | * Get the block’s timestamp. |
293 | 293 | */ |
294 | 294 | getBlockDifficulty (offset) { |
295 | 295 | this.takeGas(2) |
296 | 296 | |
297 | | - this.setMemory(offset, 32, this.environment.block.difficulty.toBuffer()) |
| 297 | + this.setMemory(offset, 32, this.environment.block.difficulty.toMemory()) |
298 | 298 | } |
299 | 299 | |
300 | 300 | |
301 | 301 | * Get the block’s gas limit. |
332 | 332 | */ |
333 | 333 | create (valueOffset, dataOffset, length) { |
334 | 334 | this.takeGas(32000) |
335 | 335 | |
336 | | - const value = new U256(this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES)) |
| 336 | + const value = U256.fromMemory(this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES)) |
337 | 337 | const data = this.getMemory(dataOffset, length) |
338 | 338 | const result = this.environment.create(value, data) |
339 | 339 | return result |
340 | 340 | } |
354 | 354 | |
355 | 355 | this.takeGas(40) |
356 | 356 | |
357 | 357 | |
358 | | - const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
359 | | - const value = new U256(this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES)) |
| 358 | + const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 359 | + const value = U256.fromMemory(this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES)) |
360 | 360 | const data = this.getMemory(dataOffset, dataLength) |
361 | 361 | |
362 | 362 | const [result, errorCode] = this.environment.call(gas, address, value, data) |
363 | 363 | this.setMemory(resultOffset, resultLength, result) |
379 | 379 | |
380 | 380 | this.takeGas(40) |
381 | 381 | |
382 | 382 | |
383 | | - const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
384 | | - const value = new U256(this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES)) |
| 383 | + const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 384 | + const value = U256.fromMemory(this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES)) |
385 | 385 | const data = this.getMemory(dataOffset, dataLength) |
386 | 386 | |
387 | 387 | const [result, errorCode] = this.environment.callCode(gas, address, value, data) |
388 | 388 | this.setMemory(resultOffset, resultLength, result) |
405 | 405 | |
406 | 406 | this.takeGas(40) |
407 | 407 | |
408 | 408 | const data = this.getMemory(dataOffset, dataLength) |
409 | | - const address = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 409 | + const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
410 | 410 | const [result, errorCode] = this.environment.callDelegate(gas, address, data) |
411 | 411 | this.setMemory(resultOffset, resultLength, result) |
412 | 412 | return errorCode |
413 | 413 | } |
468 | 468 | * balance to an address path |
469 | 469 | * @param {integer} offset the offset to load the address from |
470 | 470 | */ |
471 | 471 | selfDestruct (addressOffset) { |
472 | | - this.environment.suicideAddress = new Address(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
| 472 | + this.environment.suicideAddress = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES)) |
473 | 473 | this.environment.gasRefund += 24000 |
474 | 474 | } |
475 | 475 | |
476 | 476 | getMemory (offset, length) { |