git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 0d9659e23045d218b41e945ebb6a50c7391a14da

Files: 0d9659e23045d218b41e945ebb6a50c7391a14da / environment.js

1336 bytesRaw
1const constants = require('./constants.js')
2const U256 = require('./u256.js')
3
4module.exports = class Environment {
5 constructor (data) {
6 const defaults = {
7 // gas tank
8 gasPrice: 0,
9 gasLimit: 1000000, // The gas limit for the block
10 gasRefund: 0,
11 // call infromation
12 address: new Uint8Array(constants.ADDRESS_SIZE_BYTES),
13 origin: new Uint8Array(constants.ADDRESS_SIZE_BYTES),
14 coinbase: new Uint8Array(constants.ADDRESS_SIZE_BYTES),
15 difficulty: 0,
16 caller: new Uint8Array(constants.ADDRESS_SIZE_BYTES),
17 callValue: new U256(0),
18 callData: new Uint8Array(),
19 // the ROM
20 code: new Uint8Array(), // the current running code
21 // output calls
22 logs: [],
23 selfDestructAddress: new Uint8Array(constants.ADDRESS_SIZE_BYTES),
24 // more output calls
25 returnValue: new Uint8Array()
26 }
27
28 this.state = new Map()
29
30 Object.assign(this, defaults, data || {})
31 }
32
33 getBalance (address) {
34 return this.state.get(address.toString()).balance
35 }
36
37 getCode (address) {
38 // STUB
39 }
40
41 getBlockHash (height) {
42 // STUB
43 }
44
45 // kernal
46 create (code, value) {
47 // STUB
48 }
49
50 call (gas, address, value, data) {
51 // STUB
52 return // result
53 }
54
55 delegateCall (gas, address, data) {
56 // STUB
57 return // result
58 }
59}
60

Built with git-ssb-web