git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: d3a050a5491cb0c8f228c86cf23e8cf4725e2038

Files: d3a050a5491cb0c8f228c86cf23e8cf4725e2038 / environment.js

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

Built with git-ssb-web