interface.jsView |
---|
90 | 90 | * the given offset. |
91 | 91 | * @param {integer} offset |
92 | 92 | */ |
93 | 93 | address (offset) { |
94 | | - this.setMemory(offset, constants.ADD_SIZE_BYTES, this.environment.address) |
| 94 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.address) |
95 | 95 | } |
96 | 96 | |
97 | 97 | |
98 | 98 | * Gets balance of the given account and loads it into memory at the given |
100 | 100 | * @param {integer} addressOffset the memory offset to laod the address |
101 | 101 | * @param {integer} resultOffset |
102 | 102 | */ |
103 | 103 | balance (addressOffset, offset) { |
104 | | - const address = this.getMemory(addressOffset, constants.ADD_SIZE_BYTES) |
| 104 | + const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
105 | 105 | |
106 | 106 | const balance = this.environment.parent.environment.getBalance(address) |
107 | | - this.setMemory(offset, constants.MAX_BAL_BYTES, balance) |
| 107 | + this.setMemory(offset, constants.BALANCE_SIZE_BYTES, balance) |
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | 111 | * Gets the execution's origination address and loads it into memory at the |
113 | 113 | * account with non-empty associated code. |
114 | 114 | * @param {integer} offset |
115 | 115 | */ |
116 | 116 | origin (offset) { |
117 | | - this.setMemory(offset, constants.ADD_SIZE_BYTES, this.environment.origin) |
| 117 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.origin) |
118 | 118 | } |
119 | 119 | |
120 | 120 | |
121 | 121 | * Gets caller address and loads it into memory at the given offset. This is |
122 | 122 | * the address of the account that is directly responsible for this execution. |
123 | 123 | * @param {integer} offset |
124 | 124 | */ |
125 | 125 | caller (offset) { |
126 | | - this.setMemory(offset, constants.ADD_SIZE_BYTES, this.environment.caller) |
| 126 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.caller) |
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | 130 | * Gets the deposited value by the instruction/transaction responsible for |
131 | 131 | * this execution and loads it into memory at the given location. |
132 | 132 | * @param {integer} offset |
133 | 133 | */ |
134 | 134 | callValue (offset) { |
135 | | - this.setMemory(offset, constants.MAX_BAL_BYTES, this.environment.callValue) |
| 135 | + this.setMemory(offset, constants.BALANCE_SIZE_BYTES, this.environment.callValue) |
136 | 136 | } |
137 | 137 | |
138 | 138 | |
139 | 139 | * Get size of input data in current environment. This pertains to the input |
180 | 180 | * @param {integer} addressOffset the offset in memory to load the address from |
181 | 181 | * @return {integer} |
182 | 182 | */ |
183 | 183 | extCodeSize (addressOffset) { |
184 | | - const address = this.getMemory(addressOffset, constants.ADD_SIZE_BYTES) |
| 184 | + const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
185 | 185 | const code = this.environment.getCode(address) |
186 | 186 | return code.byteLength |
187 | 187 | } |
188 | 188 | |
193 | 193 | * @param {integer} codeOffset the code offset |
194 | 194 | * @param {integer} length the length of code to copy |
195 | 195 | */ |
196 | 196 | extCodeCopy (addressOffset, offset, codeOffset, length) { |
197 | | - const address = this.getMemory(addressOffset, constants.ADD_SIZE_BYTES) |
| 197 | + const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
198 | 198 | let code = this.environment.getCode(address) |
199 | 199 | code = new Uint8Array(code, codeOffset, length) |
200 | 200 | this.setMemory(offset, length, code) |
201 | 201 | } |
222 | 222 | * Gets the block’s beneficiary address and loads into memory. |
223 | 223 | * @param offset |
224 | 224 | */ |
225 | 225 | coinbase (offset) { |
226 | | - this.setMemory(offset, constants.ADD_SIZE_BYTES, this.environment.coinbase) |
| 226 | + this.setMemory(offset, constants.ADDRESS_SIZE_BYTES, this.environment.coinbase) |
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | 230 | * Get the block’s timestamp. |
278 | 278 | * @param {integer} dataOffset the offset to load the code for the new contract from |
279 | 279 | * @param {integer} length the data length |
280 | 280 | */ |
281 | 281 | create (valueOffset, dataOffset, length) { |
282 | | - const value = this.getMemory(valueOffset, constants.MAX_BAL_BYTES) |
| 282 | + const value = this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES) |
283 | 283 | const data = this.getMemory(dataOffset, length) |
284 | 284 | const result = this.environment.create(value, data) |
285 | 285 | return result |
286 | 286 | } |
301 | 301 | if (gas === undefined) { |
302 | 302 | gas = this.gasLeft() |
303 | 303 | } |
304 | 304 | |
305 | | - const address = this.getMemory(addressOffset, constants.ADD_SIZE_BYTES) |
306 | | - const value = this.getMemory(valueOffset, constants.MAX_BAL_BYTES) |
| 305 | + const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
| 306 | + const value = this.getMemory(valueOffset, constants.BALANCE_SIZE_BYTES) |
307 | 307 | const data = this.getMemory(dataOffset, dataLength) |
308 | 308 | |
309 | 309 | const [result, errorCode] = this.environment.call(gas, address, value, data) |
310 | 310 | this.setMemory(resultOffset, resultLength, result) |
325 | 325 | * @return {integer} Returns 1 or 0 depending on if the VM trapped on the message or not |
326 | 326 | */ |
327 | 327 | callDelegate (gas, addressOffset, dataOffset, dataLength, resultOffset, resultLength) { |
328 | 328 | const data = this.getMemory(dataOffset, dataLength) |
329 | | - const address = this.getMemory(addressOffset, constants.ADD_SIZE_BYTES) |
| 329 | + const address = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
330 | 330 | const [result, errorCode] = this.environment.callDelegate(gas, address, data) |
331 | 331 | this.setMemory(resultOffset, resultLength, result) |
332 | 332 | |
333 | 333 | return errorCode |
384 | 384 | * balance to an address path |
385 | 385 | * @param {integer} offset the offset to load the address from |
386 | 386 | */ |
387 | 387 | suicide (addressOffset) { |
388 | | - this.environment.suicideAddress = this.getMemory(addressOffset, constants.ADD_SIZE_BYTES) |
| 388 | + this.environment.suicideAddress = this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES) |
389 | 389 | } |
390 | 390 | |
391 | 391 | getMemory (offset, length) { |
392 | 392 | return new Uint8Array(this.module.exports.memory, offset, length) |