build working

revert-603-optF
aniket-engg 4 years ago committed by Aniket
parent d71e581b85
commit 63512c8312
  1. 5
      libs/remix-simulator/src/genesis.ts
  2. 50
      libs/remix-simulator/src/methods/misc.ts
  3. 20
      libs/remix-simulator/src/methods/net.ts
  4. 27
      libs/remix-simulator/src/provider.ts
  5. 25
      libs/remix-simulator/src/server.ts
  6. 90
      libs/remix-simulator/src/utils/logs.ts
  7. 3
      libs/remix-simulator/tsconfig.lib.json
  8. 26
      package-lock.json
  9. 1
      package.json
  10. 4
      workspace.json

@ -1,6 +1,5 @@
const EthJSBlock = require('ethereumjs-block')
const ethJSUtil = require('ethereumjs-util')
const BN = ethJSUtil.BN
import EthJSBlock from 'ethereumjs-block'
import { BN } from 'ethereumjs-util'
function generateBlock (executionContext) {
const block = new EthJSBlock({

@ -1,10 +1,9 @@
const version = require('../../package.json').version
const web3 = require('web3')
import web3 from 'web3'
const Misc = function () {
}
export class Misc {
Misc.prototype.methods = function () {
methods () {
return {
web3_clientVersion: this.web3_clientVersion.bind(this),
eth_protocolVersion: this.eth_protocolVersion.bind(this),
@ -17,48 +16,47 @@ Misc.prototype.methods = function () {
eth_compileLLL: this.eth_compileLLL.bind(this),
eth_compileSerpent: this.eth_compileSerpent.bind(this)
}
}
}
Misc.prototype.web3_clientVersion = function (payload, cb) {
web3_clientVersion (payload, cb) {
cb(null, 'Remix Simulator/' + version)
}
}
Misc.prototype.eth_protocolVersion = function (payload, cb) {
eth_protocolVersion (payload, cb) {
cb(null, '0x3f')
}
}
Misc.prototype.eth_syncing = function (payload, cb) {
eth_syncing (payload, cb) {
cb(null, false)
}
}
Misc.prototype.eth_mining = function (payload, cb) {
eth_mining (payload, cb) {
// TODO: should depend on the state
cb(null, false)
}
}
Misc.prototype.eth_hashrate = function (payload, cb) {
eth_hashrate (payload, cb) {
cb(null, '0x0')
}
}
Misc.prototype.web3_sha3 = function (payload, cb) {
web3_sha3 (payload, cb) {
const str = payload.params[0]
cb(null, web3.utils.sha3(str))
}
}
Misc.prototype.eth_getCompilers = function (payload, cb) {
eth_getCompilers (payload, cb) {
cb(null, [])
}
}
Misc.prototype.eth_compileSolidity = function (payload, cb) {
eth_compileSolidity (payload, cb) {
cb(null, 'unsupported')
}
}
Misc.prototype.eth_compileLLL = function (payload, cb) {
eth_compileLLL (payload, cb) {
cb(null, 'unsupported')
}
}
Misc.prototype.eth_compileSerpent = function (payload, cb) {
eth_compileSerpent (payload, cb) {
cb(null, 'unsupported')
}
}
module.exports = Misc

@ -1,26 +1,24 @@
const Net = function () {
}
export class Net {
Net.prototype.methods = function () {
methods () {
return {
net_version: this.net_version,
net_listening: this.net_listening,
net_peerCount: this.net_peerCount
}
}
}
Net.prototype.net_version = function (payload, cb) {
net_version (payload, cb) {
// should be configured networkId
cb(null, 1337)
}
}
Net.prototype.net_listening = function (payload, cb) {
net_listening (payload, cb) {
cb(null, true)
}
}
Net.prototype.net_peerCount = function (payload, cb) {
net_peerCount (payload, cb) {
cb(null, 0)
}
}
module.exports = Net

@ -1,16 +1,17 @@
import { Blocks } from './methods/blocks'
const RemixLib = require('@remix-project/remix-lib')
const executionContext = RemixLib.execution.executionContext
import { execution } from '@remix-project/remix-lib'
const { executionContext } = execution
const log = require('./utils/logs.js')
const merge = require('merge')
import { Logger } from './utils/logs'
const logger = new Logger()
import merge from 'merge'
const Accounts = require('./methods/accounts.js')
const Filters = require('./methods/filters.js')
const Misc = require('./methods/misc.js')
const Net = require('./methods/net.js')
const Transactions = require('./methods/transactions.js')
const Debug = require('./methods/debug.js')
import { Accounts } from './methods/accounts'
import { Filters } from './methods/filters'
import { Misc } from './methods/misc'
import { Net } from './methods/net.js'
import { Transactions } from './methods/transactions.js'
import { Debug } from './methods/debug.js'
const generateBlock = require('./genesis.js')
@ -51,13 +52,13 @@ export class Provider {
const method = this.methods[payload.method]
if (this.options.logDetails) {
log.info(payload)
logger.info(payload)
}
if (method) {
return method.call(method, payload, (err, result) => {
if (this.options.logDetails) {
log.info(err)
log.info(result)
logger.info(err)
logger.info(result)
}
if (err) {
return callback(err)

@ -1,18 +1,23 @@
const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
import express from 'express'
import cors from 'cors'
import bodyParser from 'body-parser'
const app = express()
const expressWs = require('express-ws')
const Provider = require('./provider')
const log = require('./utils/logs.js')
import expressWs from 'express-ws'
import { Provider } from './provider'
import { Logger } from './utils/logs'
const logger = new Logger()
class Server {
provider
rpcOnly
constructor (options) {
this.provider = new Provider(options)
this.provider.init().then(() => {
log('Provider initiated')
logger.log('Provider initiated')
}).catch((error) => {
log(error)
logger.log(error)
})
this.rpcOnly = options.rpc
}
@ -55,9 +60,9 @@ class Server {
}
app.listen(port, host, () => {
log('Remix Simulator listening on ws://' + host + ':' + port)
logger.log('Remix Simulator listening on ws://' + host + ':' + port)
if (!this.rpcOnly) {
log('http json-rpc is deprecated and disabled by default. To enable it use --rpc')
logger.log('http json-rpc is deprecated and disabled by default. To enable it use --rpc')
}
})
}

@ -1,19 +1,21 @@
'use strict'
const gray = require('ansi-gray')
const timestamp = require('time-stamp')
const supportsColor = require('color-support')
import gray from 'ansi-gray'
import timestamp from 'time-stamp'
import supportsColor from 'color-support'
function hasFlag (flag) {
export class Logger {
private hasFlag(flag) {
return ((typeof (process) !== 'undefined') && (process.argv.indexOf('--' + flag) !== -1))
}
}
function addColor (str) {
if (hasFlag('no-color')) {
private addColor(str) {
if (this.hasFlag('no-color')) {
return str
}
if (hasFlag('color')) {
if (this.hasFlag('color')) {
return gray(str)
}
@ -22,61 +24,55 @@ function addColor (str) {
}
return str
}
}
const logger = {
stdout: function (arg) {
private stdout(arg) {
if (typeof (process) === 'undefined' || !process.stdout) return
process.stdout.write(arg)
},
stderr: function (arg) {
}
private stderr(arg) {
if (typeof (process) === 'undefined' || process.stderr) return
process.stderr.write(arg)
}
}
function getTimestamp () {
const coloredTimestamp = addColor(timestamp('HH:mm:ss'))
private getTimestamp() {
const coloredTimestamp = this.addColor(timestamp('HH:mm:ss'))
return '[' + coloredTimestamp + ']'
}
}
function log () {
const time = getTimestamp()
logger.stdout(time + ' ')
console.log.apply(console, arguments)
log(...args: any[]) {
const time = this.getTimestamp()
this.stdout(time + ' ')
console.log(args)
return this
}
}
function info () {
const time = getTimestamp()
logger.stdout(time + ' ')
console.info.apply(console, arguments)
info(...args: any[]) {
const time = this.getTimestamp()
this.stdout(time + ' ')
console.info(args)
return this
}
}
function dir () {
const time = getTimestamp()
logger.stdout(time + ' ')
console.dir.apply(console, arguments)
dir(...args: any[]) {
const time = this.getTimestamp()
this.stdout(time + ' ')
console.dir(args)
return this
}
}
function warn () {
const time = getTimestamp()
logger.stderr(time + ' ')
console.warn.apply(console, arguments)
warn(...args: any[]) {
const time = this.getTimestamp()
this.stderr(time + ' ')
console.warn(args)
return this
}
}
function error () {
const time = getTimestamp()
logger.stderr(time + ' ')
console.error.apply(console, arguments)
error(...args: any[]) {
const time = this.getTimestamp()
this.stderr(time + ' ')
console.error(args)
return this
}
}
module.exports = log
module.exports.info = info
module.exports.dir = dir
module.exports.warn = warn
module.exports.error = error

@ -8,7 +8,8 @@
"types": ["node"]
},
"exclude": [
"**/*.spec.ts"
"**/*.spec.ts",
"test/"
],
"include": ["**/*.ts"]
}

26
package-lock.json generated

@ -9013,8 +9013,7 @@
"async-limiter": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==",
"dev": true
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
},
"async-settle": {
"version": "1.0.0",
@ -16901,6 +16900,24 @@
}
}
},
"express-ws": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/express-ws/-/express-ws-4.0.0.tgz",
"integrity": "sha512-KEyUw8AwRET2iFjFsI1EJQrJ/fHeGiJtgpYgEWG3yDv4l/To/m3a2GaYfeGyB3lsWdvbesjF5XCMx+SVBgAAYw==",
"requires": {
"ws": "^5.2.0"
},
"dependencies": {
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
"requires": {
"async-limiter": "~1.0.0"
}
}
}
},
"ext": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz",
@ -28265,7 +28282,6 @@
},
"dezalgo": {
"version": "1.0.3",
"resolved": false,
"integrity": "sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY=",
"requires": {
"asap": "^2.0.0",
@ -28894,7 +28910,6 @@
},
"normalize-git-url": {
"version": "3.0.2",
"resolved": false,
"integrity": "sha1-jl8Uvgva7bc+ByADEKpBbCc1D8Q="
},
"normalize-package-data": {
@ -28932,7 +28947,6 @@
},
"npm-install-checks": {
"version": "3.0.0",
"resolved": false,
"integrity": "sha1-1K7N/VGlPjcjt7L5Oy7ijjB7wNc=",
"requires": {
"semver": "^2.3.0 || 3.x || 4 || 5"
@ -29279,7 +29293,6 @@
},
"realize-package-specifier": {
"version": "3.0.3",
"resolved": false,
"integrity": "sha1-0N74gpUrjeP2frpekRmWYScfQfQ=",
"requires": {
"dezalgo": "^1.0.1",
@ -29816,7 +29829,6 @@
"dependencies": {
"unique-slug": {
"version": "2.0.0",
"resolved": false,
"integrity": "sha1-22Z258fMBimHj/GWCXx4hVrp9Ks=",
"requires": {
"imurmurhash": "^0.1.4"

@ -145,6 +145,7 @@
"ethereumjs-block": "^2.2.2",
"ethereumjs-tx": "^2.1.2",
"ethereumjs-vm": "4.1.3",
"express-ws": "^4.0.0",
"fs-extra": "^3.0.1",
"http-server": "^0.11.1",
"isbinaryfile": "^3.0.2",

@ -292,7 +292,7 @@
},
"remix-simulator": {
"root": "libs/remix-simulator",
"sourceRoot": "libs/remix-simulator/",
"sourceRoot": "libs/remix-simulator/src",
"projectType": "library",
"schematics": {},
"architect": {
@ -322,7 +322,7 @@
"outputPath": "dist/libs/remix-simulator",
"tsConfig": "libs/remix-simulator/tsconfig.lib.json",
"packageJson": "libs/remix-simulator/package.json",
"main": "libs/remix-simulator/index.js",
"main": "libs/remix-simulator/src/index.ts",
"assets": [
{
"glob": "ethsim",

Loading…
Cancel
Save