git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 52733a7622044cda7ec1de6a666ed8c8747162c6

Files: 52733a7622044cda7ec1de6a666ed8c8747162c6 / environment.js

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

Built with git-ssb-web