Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
533e0626
Commit
533e0626
authored
Nov 20, 2020
by
aniket-engg
Committed by
Aniket
Nov 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
js to ts
parent
c7107ce5
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
74 additions
and
63 deletions
+74
-63
index.js
libs/remix-simulator/index.js
+0
-5
genesis.ts
libs/remix-simulator/src/genesis.ts
+0
-0
index.ts
libs/remix-simulator/src/index.ts
+3
-0
accounts.ts
libs/remix-simulator/src/methods/accounts.ts
+16
-13
blocks.ts
libs/remix-simulator/src/methods/blocks.ts
+8
-5
debug.ts
libs/remix-simulator/src/methods/debug.ts
+4
-3
filters.ts
libs/remix-simulator/src/methods/filters.ts
+4
-4
misc.ts
libs/remix-simulator/src/methods/misc.ts
+0
-0
net.ts
libs/remix-simulator/src/methods/net.ts
+0
-0
transactions.ts
libs/remix-simulator/src/methods/transactions.ts
+13
-13
txProcess.ts
libs/remix-simulator/src/methods/txProcess.ts
+1
-3
provider.ts
libs/remix-simulator/src/provider.ts
+10
-5
server.ts
libs/remix-simulator/src/server.ts
+0
-0
logs.ts
libs/remix-simulator/src/utils/logs.ts
+0
-0
accounts.ts
libs/remix-simulator/test/accounts.ts
+0
-0
blocks.ts
libs/remix-simulator/test/blocks.ts
+0
-0
misc.ts
libs/remix-simulator/test/misc.ts
+0
-0
tsconfig.json
libs/remix-simulator/tsconfig.json
+8
-0
tsconfig.lib.json
libs/remix-simulator/tsconfig.lib.json
+7
-12
No files found.
libs/remix-simulator/index.js
deleted
100644 → 0
View file @
c7107ce5
const
Provider
=
require
(
'./src/provider'
)
module
.
exports
=
{
Provider
:
Provider
}
libs/remix-simulator/src/genesis.
j
s
→
libs/remix-simulator/src/genesis.
t
s
View file @
533e0626
File moved
libs/remix-simulator/src/index.ts
0 → 100644
View file @
533e0626
import
{
Provider
}
from
'./provider'
export
{
Provider
}
libs/remix-simulator/src/methods/accounts.
j
s
→
libs/remix-simulator/src/methods/accounts.
t
s
View file @
533e0626
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
const
{
BN
,
privateToAddress
,
isValidPrivate
}
=
require
(
'ethereumjs-util'
)
const
Web3
=
require
(
'web3'
)
const
crypto
=
require
(
'crypto'
)
import
{
BN
,
privateToAddress
,
toChecksumAddress
,
isValidPrivate
}
from
'ethereumjs-util'
import
{
stripHexPrefix
}
from
'ethjs-util'
import
Web3
from
'web3'
import
*
as
crypto
from
'crypto'
class
Accounts
{
export
class
Accounts
{
web3
accounts
accountsKeys
executionContext
constructor
(
executionContext
)
{
this
.
web3
=
new
Web3
()
...
...
@@ -39,10 +44,10 @@ class Accounts{
_addAccount
(
privateKey
,
balance
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
privateKey
=
Buffer
.
from
(
privateKey
,
'hex'
)
const
address
=
ethJSUtil
.
privateToAddress
(
privateKey
)
const
address
=
privateToAddress
(
privateKey
)
this
.
accounts
[
ethJSUtil
.
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
{
privateKey
,
nonce
:
0
}
this
.
accountsKeys
[
ethJSUtil
.
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
'0x'
+
privateKey
.
toString
(
'hex'
)
this
.
accounts
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
{
privateKey
,
nonce
:
0
}
this
.
accountsKeys
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
'0x'
+
privateKey
.
toString
(
'hex'
)
let
stateManager
=
this
.
executionContext
.
vm
().
stateManager
stateManager
.
getAccount
(
address
,
(
error
,
account
)
=>
{
...
...
@@ -81,7 +86,7 @@ class Accounts{
eth_getBalance
(
payload
,
cb
)
{
let
address
=
payload
.
params
[
0
]
address
=
ethJSUtil
.
stripHexPrefix
(
address
)
address
=
stripHexPrefix
(
address
)
this
.
executionContext
.
vm
().
stateManager
.
getAccount
(
Buffer
.
from
(
address
,
'hex'
),
(
err
,
account
)
=>
{
if
(
err
)
{
...
...
@@ -95,7 +100,7 @@ class Accounts{
const
address
=
payload
.
params
[
0
]
const
message
=
payload
.
params
[
1
]
const
privateKey
=
this
.
accountsKeys
[
ethJSUtil
.
toChecksumAddress
(
address
)]
const
privateKey
=
this
.
accountsKeys
[
toChecksumAddress
(
address
)]
if
(
!
privateKey
)
{
return
cb
(
new
Error
(
'unknown account'
))
}
...
...
@@ -106,5 +111,3 @@ class Accounts{
cb
(
null
,
data
.
signature
)
}
}
\ No newline at end of file
module
.
exports
=
Accounts
\ No newline at end of file
libs/remix-simulator/src/methods/blocks.
j
s
→
libs/remix-simulator/src/methods/blocks.
t
s
View file @
533e0626
class
Blocks
{
export
class
Blocks
{
executionContext
coinbase
blockNumber
constructor
(
executionContext
,
_options
)
{
this
.
executionContext
=
executionContext
const
options
=
_options
||
{}
...
...
@@ -130,10 +135,8 @@ class Blocks {
return
cb
(
err
,
''
)
}
let
value
=
Object
.
values
(
result
.
storage
)[
0
]
.
value
let
value
=
Object
.
values
(
result
.
storage
)[
0
]
[
'value'
]
cb
(
err
,
value
)
})
}
}
\ No newline at end of file
module
.
exports
=
Blocks
\ No newline at end of file
libs/remix-simulator/src/methods/debug.
j
s
→
libs/remix-simulator/src/methods/debug.
t
s
View file @
533e0626
class
Debug
{
export
class
Debug
{
executionContext
constructor
(
executionContext
)
{
this
.
executionContext
=
executionContext
}
...
...
@@ -29,5 +32,3 @@ class Debug {
cb
)
}
}
module
.
exports
=
Debug
libs/remix-simulator/src/methods/filters.
j
s
→
libs/remix-simulator/src/methods/filters.
t
s
View file @
533e0626
class
Filters
{
export
class
Filters
{
executionContext
constructor
(
executionContext
)
{
this
.
executionContext
=
executionContext
}
...
...
@@ -58,5 +61,3 @@ class Filters {
cb
(
null
,
results
)
}
}
module
.
exports
=
Filters
\ No newline at end of file
libs/remix-simulator/src/methods/misc.
j
s
→
libs/remix-simulator/src/methods/misc.
t
s
View file @
533e0626
File moved
libs/remix-simulator/src/methods/net.
j
s
→
libs/remix-simulator/src/methods/net.
t
s
View file @
533e0626
File moved
libs/remix-simulator/src/methods/transactions.
j
s
→
libs/remix-simulator/src/methods/transactions.
t
s
View file @
533e0626
const
Web3
=
require
(
'web3'
)
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
const
processTx
=
require
(
'./txProcess.js'
)
const
BN
=
ethJSUtil
.
BN
import
Web3
from
'web3'
import
{
toChecksumAddress
,
BN
}
from
'ethereumjs-util'
import
{
processTx
}
from
'./txProcess'
class
Transactions
{
executionContext
accounts
constructor
(
executionContext
)
{
this
.
executionContext
=
executionContext
}
...
...
@@ -30,7 +32,7 @@ class Transactions{
eth_sendTransaction
(
payload
,
cb
)
{
// from might be lowercased address (web3)
if
(
payload
.
params
&&
payload
.
params
.
length
>
0
&&
payload
.
params
[
0
].
from
)
{
payload
.
params
[
0
].
from
=
ethJSUtil
.
toChecksumAddress
(
payload
.
params
[
0
].
from
)
payload
.
params
[
0
].
from
=
toChecksumAddress
(
payload
.
params
[
0
].
from
)
}
processTx
(
this
.
executionContext
,
this
.
accounts
,
payload
,
false
,
cb
)
}
...
...
@@ -83,10 +85,10 @@ class Transactions{
eth_call
(
payload
,
cb
)
{
// from might be lowercased address (web3)
if
(
payload
.
params
&&
payload
.
params
.
length
>
0
&&
payload
.
params
[
0
].
from
)
{
payload
.
params
[
0
].
from
=
ethJSUtil
.
toChecksumAddress
(
payload
.
params
[
0
].
from
)
payload
.
params
[
0
].
from
=
toChecksumAddress
(
payload
.
params
[
0
].
from
)
}
if
(
payload
.
params
&&
payload
.
params
.
length
>
0
&&
payload
.
params
[
0
].
to
)
{
payload
.
params
[
0
].
to
=
ethJSUtil
.
toChecksumAddress
(
payload
.
params
[
0
].
to
)
payload
.
params
[
0
].
to
=
toChecksumAddress
(
payload
.
params
[
0
].
to
)
}
payload
.
params
[
0
].
value
=
undefined
...
...
@@ -136,7 +138,7 @@ class Transactions{
}
if
(
receipt
.
to
)
{
r
.
to
=
receipt
.
to
r
[
'to'
]
=
receipt
.
to
}
if
(
r
.
value
===
'0x'
)
{
...
...
@@ -182,7 +184,7 @@ class Transactions{
}
if
(
receipt
.
to
)
{
r
.
to
=
receipt
.
to
r
[
'to'
]
=
receipt
.
to
}
if
(
r
.
value
===
'0x'
)
{
...
...
@@ -224,7 +226,7 @@ class Transactions{
}
if
(
receipt
.
to
)
{
r
.
to
=
receipt
.
to
r
[
'to'
]
=
receipt
.
to
}
if
(
r
.
value
===
'0x'
)
{
...
...
@@ -235,5 +237,3 @@ class Transactions{
})
}
}
\ No newline at end of file
module
.
exports
=
Transactions
\ No newline at end of file
libs/remix-simulator/src/methods/txProcess.
j
s
→
libs/remix-simulator/src/methods/txProcess.
t
s
View file @
533e0626
...
...
@@ -39,7 +39,7 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac
let
txRunnerInstance
function
processTx
(
executionContext
,
accounts
,
payload
,
isCall
,
callback
)
{
export
function
processTx
(
executionContext
,
accounts
,
payload
,
isCall
,
callback
)
{
const
api
=
{
logMessage
:
(
msg
)
=>
{
},
...
...
@@ -94,5 +94,3 @@ function processTx (executionContext, accounts, payload, isCall, callback) {
createContract
(
payload
,
from
,
data
,
value
,
gas
,
txRunnerInstance
,
callbacks
,
callback
)
}
}
module
.
exports
=
processTx
libs/remix-simulator/src/provider.
j
s
→
libs/remix-simulator/src/provider.
t
s
View file @
533e0626
...
...
@@ -5,7 +5,7 @@ const log = require('./utils/logs.js')
const
merge
=
require
(
'merge'
)
const
Accounts
=
require
(
'./methods/accounts.js'
)
const
Blocks
=
require
(
'./methods/blocks.js'
)
import
{
Blocks
}
from
'./methods/blocks'
const
Filters
=
require
(
'./methods/filters.js'
)
const
Misc
=
require
(
'./methods/misc.js'
)
const
Net
=
require
(
'./methods/net.js'
)
...
...
@@ -14,7 +14,14 @@ const Debug = require('./methods/debug.js')
const
generateBlock
=
require
(
'./genesis.js'
)
class
Provider
{
export
class
Provider
{
options
executionContext
Accounts
Transactions
methods
constructor
(
options
=
{})
{
this
.
options
=
options
// TODO: init executionContext here
...
...
@@ -75,5 +82,3 @@ class Provider {
this
.
executionContext
.
logsManager
.
addListener
(
type
,
cb
)
}
}
\ No newline at end of file
module
.
exports
=
Provider
\ No newline at end of file
libs/remix-simulator/src/server.
j
s
→
libs/remix-simulator/src/server.
t
s
View file @
533e0626
File moved
libs/remix-simulator/src/utils/logs.
j
s
→
libs/remix-simulator/src/utils/logs.
t
s
View file @
533e0626
File moved
libs/remix-simulator/test/accounts.
j
s
→
libs/remix-simulator/test/accounts.
t
s
View file @
533e0626
File moved
libs/remix-simulator/test/blocks.
j
s
→
libs/remix-simulator/test/blocks.
t
s
View file @
533e0626
File moved
libs/remix-simulator/test/misc.
j
s
→
libs/remix-simulator/test/misc.
t
s
View file @
533e0626
File moved
libs/remix-simulator/tsconfig.json
0 → 100644
View file @
533e0626
{
"extends"
:
"../../tsconfig.json"
,
"compilerOptions"
:
{
"types"
:
[
"node"
]
},
"include"
:
[
"**/*.ts"
]
}
\ No newline at end of file
libs/remix-simulator/tsconfig.lib.json
View file @
533e0626
{
"extends"
:
"../.
./tsconfig.json"
,
"extends"
:
"
./tsconfig.json"
,
"compilerOptions"
:
{
"module"
:
"commonjs"
,
"outDir"
:
"../../dist/out-tsc"
,
"allowJs"
:
true
,
"declaration"
:
true
,
"rootDir"
:
"./
"
,
"rootDir"
:
"./src
"
,
"types"
:
[
"node"
]
},
"exclude"
:
[
"**/*.spec.js"
],
"include"
:
[
"src/**/*.js"
,
"./index.js"
,
"bin/"
]
}
\ No newline at end of file
"exclude"
:
[
"**/*.spec.ts"
],
"include"
:
[
"**/*.ts"
]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment