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
807ca5aa
Commit
807ca5aa
authored
Apr 20, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move transactions methods
parent
13b41702
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
41 deletions
+76
-41
package.json
remix-simulator/package.json
+1
-0
transactions.js
remix-simulator/src/methods/transactions.js
+58
-0
txProcess.js
remix-simulator/src/methods/txProcess.js
+0
-0
provider.js
remix-simulator/src/provider.js
+17
-41
No files found.
remix-simulator/package.json
View file @
807ca5aa
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
"body-parser"
:
"^1.18.2"
,
"body-parser"
:
"^1.18.2"
,
"express"
:
"^4.16.3"
,
"express"
:
"^4.16.3"
,
"fancy-log"
:
"^1.3.2"
,
"fancy-log"
:
"^1.3.2"
,
"merge"
:
"^1.2.0"
,
"remix-lib"
:
"latest"
,
"remix-lib"
:
"latest"
,
"standard"
:
"^10.0.3"
,
"standard"
:
"^10.0.3"
,
"web3"
:
"1.0.0-beta.27"
"web3"
:
"1.0.0-beta.27"
...
...
remix-simulator/src/methods/transactions.js
0 → 100644
View file @
807ca5aa
var
RemixLib
=
require
(
'remix-lib'
)
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
processTx
=
require
(
'./txProcess.js'
)
var
Transactions
=
function
(
accounts
)
{
this
.
accounts
=
accounts
;
// TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now
this
.
deployedContracts
=
{}
}
Transactions
.
prototype
.
methods
=
function
()
{
return
{
eth_sendTransaction
:
this
.
eth_sendTransaction
.
bind
(
this
),
eth_getTransactionReceipt
:
this
.
eth_getTransactionReceipt
.
bind
(
this
),
eth_getCode
:
this
.
eth_getCode
.
bind
(
this
),
eth_call
:
this
.
eth_call
.
bind
(
this
)
}
}
Transactions
.
prototype
.
eth_sendTransaction
=
function
(
payload
,
cb
)
{
processTx
(
this
.
accounts
,
payload
,
false
,
cb
);
}
Transactions
.
prototype
.
eth_getTransactionReceipt
=
function
(
payload
,
cb
)
{
const
self
=
this
;
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
if
(
error
)
{
return
cb
(
error
)
}
self
.
deployedContracts
[
receipt
.
contractAddress
]
=
receipt
.
data
var
r
=
{
'transactionHash'
:
receipt
.
hash
,
'transactionIndex'
:
'0x00'
,
'blockHash'
:
'0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5'
,
'blockNumber'
:
'0x06'
,
'gasUsed'
:
'0x06345f'
,
'cumulativeGasUsed'
:
'0x06345f'
,
'contractAddress'
:
receipt
.
contractAddress
,
'logs'
:
[],
'status'
:
1
}
cb
(
null
,
r
)
})
}
Transactions
.
prototype
.
eth_getCode
=
function
(
payload
,
cb
)
{
let
address
=
payload
.
params
[
0
]
cb
(
null
,
this
.
deployedContracts
[
address
]
||
'0x'
)
}
Transactions
.
prototype
.
eth_call
=
function
(
payload
,
cb
)
{
processTx
(
this
.
accounts
,
payload
,
true
,
cb
)
}
module
.
exports
=
Transactions
;
remix-simulator/src/txProcess.js
→
remix-simulator/src/
methods/
txProcess.js
View file @
807ca5aa
File moved
remix-simulator/src/provider.js
View file @
807ca5aa
var
Web3
=
require
(
'web3'
)
var
Web3
=
require
(
'web3'
)
var
RemixLib
=
require
(
'remix-lib'
)
var
RemixLib
=
require
(
'remix-lib'
)
var
executionContext
=
RemixLib
.
execution
.
executionContext
const
log
=
require
(
'fancy-log'
)
const
log
=
require
(
'fancy-log'
)
const
Transactions
=
require
(
'./methods/transactions.js'
)
var
processTx
=
require
(
'./txProcess.js
'
)
const
merge
=
require
(
'merge
'
)
function
jsonRPCResponse
(
id
,
result
)
{
function
jsonRPCResponse
(
id
,
result
)
{
return
{
'id'
:
id
,
'jsonrpc'
:
'2.0'
,
'result'
:
result
}
return
{
'id'
:
id
,
'jsonrpc'
:
'2.0'
,
'result'
:
result
}
...
@@ -17,8 +16,11 @@ var Provider = function () {
...
@@ -17,8 +16,11 @@ var Provider = function () {
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()]
=
this
.
accounts
[
0
]
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()]
=
this
.
accounts
[
0
]
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
=
Buffer
.
from
(
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
.
slice
(
2
),
'hex'
)
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
=
Buffer
.
from
(
this
.
accounts
[
this
.
accounts
[
0
].
address
.
toLowerCase
()].
privateKey
.
slice
(
2
),
'hex'
)
// TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now
this
.
Transactions
=
new
Transactions
(
this
.
accounts
);
this
.
deployedContracts
=
{}
this
.
methods
=
{}
this
.
methods
=
merge
(
this
.
methods
,
this
.
Transactions
.
methods
())
log
.
dir
(
this
.
methods
)
}
}
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
...
@@ -36,42 +38,6 @@ Provider.prototype.sendAsync = function (payload, callback) {
...
@@ -36,42 +38,6 @@ Provider.prototype.sendAsync = function (payload, callback) {
if
(
payload
.
method
===
'eth_gasPrice'
)
{
if
(
payload
.
method
===
'eth_gasPrice'
)
{
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
1
))
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
1
))
}
}
if
(
payload
.
method
===
'eth_sendTransaction'
)
{
processTx
(
this
.
accounts
,
payload
,
false
,
(
_err
,
result
)
=>
{
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
result
))
})
}
if
(
payload
.
method
===
'eth_getTransactionReceipt'
)
{
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
if
(
error
)
{
return
callback
(
error
)
}
self
.
deployedContracts
[
receipt
.
contractAddress
]
=
receipt
.
data
var
r
=
{
'transactionHash'
:
receipt
.
hash
,
'transactionIndex'
:
'0x00'
,
'blockHash'
:
'0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5'
,
'blockNumber'
:
'0x06'
,
'gasUsed'
:
'0x06345f'
,
'cumulativeGasUsed'
:
'0x06345f'
,
'contractAddress'
:
receipt
.
contractAddress
,
'logs'
:
[],
'status'
:
1
}
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
r
))
})
}
if
(
payload
.
method
===
'eth_getCode'
)
{
let
address
=
payload
.
params
[
0
]
// let block = payload.params[1]
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
self
.
deployedContracts
[
address
]
||
'0x'
))
}
if
(
payload
.
method
===
'eth_call'
)
{
processTx
(
this
.
accounts
,
payload
,
true
,
callback
)
}
if
(
payload
.
method
===
'web3_clientVersion'
)
{
if
(
payload
.
method
===
'web3_clientVersion'
)
{
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
'Remix Simulator/0.0.1'
))
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
'Remix Simulator/0.0.1'
))
}
}
...
@@ -103,6 +69,16 @@ Provider.prototype.sendAsync = function (payload, callback) {
...
@@ -103,6 +69,16 @@ Provider.prototype.sendAsync = function (payload, callback) {
}
}
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
b
))
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
b
))
}
}
let
method
=
this
.
methods
[
payload
.
method
]
if
(
method
)
{
return
method
.
call
(
method
,
payload
,
(
err
,
result
)
=>
{
if
(
err
)
{
return
callback
({
error
:
err
})
}
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
result
))
});
}
callback
(
"unknown method "
+
payload
.
method
);
}
}
Provider
.
prototype
.
isConnected
=
function
()
{
Provider
.
prototype
.
isConnected
=
function
()
{
...
...
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