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
8948c6ba
Commit
8948c6ba
authored
Apr 16, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address linting issues
parent
dd88eedb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
60 deletions
+68
-60
run.js
run.js
+2
-2
deployer.js
src/deployer.js
+1
-1
provider.js
src/provider.js
+30
-28
testRunner.js
src/testRunner.js
+2
-2
txProcess.js
src/txProcess.js
+33
-27
No files found.
run.js
View file @
8948c6ba
...
@@ -7,9 +7,9 @@ const Provider = require('./src/provider.js')
...
@@ -7,9 +7,9 @@ const Provider = require('./src/provider.js')
commander
.
action
(
function
(
filename
)
{
commander
.
action
(
function
(
filename
)
{
let
web3
=
new
Web3
()
let
web3
=
new
Web3
()
//web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
//
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
web3
.
setProvider
(
new
Provider
())
web3
.
setProvider
(
new
Provider
())
//web3.setProvider(new web3.providers.WebsocketProvider('ws://localhost:8546'))
//
web3.setProvider(new web3.providers.WebsocketProvider('ws://localhost:8546'))
let
isDirectory
=
fs
.
lstatSync
(
filename
).
isDirectory
()
let
isDirectory
=
fs
.
lstatSync
(
filename
).
isDirectory
()
RemixTests
.
runTestFiles
(
filename
,
isDirectory
,
web3
)
RemixTests
.
runTestFiles
(
filename
,
isDirectory
,
web3
)
...
...
src/deployer.js
View file @
8948c6ba
...
@@ -91,7 +91,7 @@ function deployAll (compileResult, web3, callback) {
...
@@ -91,7 +91,7 @@ function deployAll (compileResult, web3, callback) {
contracts
[
contractName
]
=
contractObject
contracts
[
contractName
]
=
contractObject
nextEach
()
nextEach
()
}).
on
(
'error'
,
function
(
err
)
{
}).
on
(
'error'
,
function
(
err
)
{
console
.
dir
(
err
)
console
.
dir
(
err
)
nextEach
(
err
)
nextEach
(
err
)
})
})
...
...
src/provider.js
View file @
8948c6ba
var
Web3
=
require
(
'web3'
)
var
Web3
=
require
(
'web3'
)
var
utils
=
require
(
'ethereumjs-util'
)
var
RemixLib
=
require
(
'remix-lib'
)
var
RemixLib
=
require
(
'remix-lib'
)
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
processTx
=
require
(
'./txProcess.js'
)
var
processTx
=
require
(
'./txProcess.js'
)
function
jsonRPCResponse
(
id
,
result
)
{
function
jsonRPCResponse
(
id
,
result
)
{
return
{
"id"
:
id
,
"jsonrpc"
:
"2.0"
,
"result"
:
result
};
return
{
'id'
:
id
,
'jsonrpc'
:
'2.0'
,
'result'
:
result
}
}
}
Provider
=
function
()
{
var
Provider
=
function
()
{
this
.
web3
=
new
Web3
()
;
this
.
web3
=
new
Web3
()
// TODO: make it random
// TODO: make it random
this
.
accounts
=
[
this
.
web3
.
eth
.
accounts
.
create
([
"abcd"
])]
this
.
accounts
=
[
this
.
web3
.
eth
.
accounts
.
create
([
'abcd'
])]
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
// TODO: fix me; this is a temporary and very hackish thing just to get the getCode working for now
this
.
deployedContracts
=
{}
;
this
.
deployedContracts
=
{}
}
}
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
const
self
=
this
;
const
self
=
this
if
(
payload
.
method
===
'eth_accounts'
)
{
if
(
payload
.
method
===
'eth_accounts'
)
{
return
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
this
.
accounts
.
map
((
x
)
=>
x
.
address
)))
return
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
this
.
accounts
.
map
((
x
)
=>
x
.
address
)))
...
@@ -38,36 +37,39 @@ Provider.prototype.sendAsync = function(payload, callback) {
...
@@ -38,36 +37,39 @@ Provider.prototype.sendAsync = function(payload, callback) {
}
}
if
(
payload
.
method
===
'eth_getTransactionReceipt'
)
{
if
(
payload
.
method
===
'eth_getTransactionReceipt'
)
{
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
executionContext
.
web3
().
eth
.
getTransactionReceipt
(
payload
.
params
[
0
],
(
error
,
receipt
)
=>
{
if
(
error
)
{
return
callback
(
error
)
}
self
.
deployedContracts
[
receipt
.
contractAddress
]
=
receipt
.
data
self
.
deployedContracts
[
receipt
.
contractAddress
]
=
receipt
.
data
var
r
=
{
var
r
=
{
"transactionHash"
:
receipt
.
hash
,
'transactionHash'
:
receipt
.
hash
,
"transactionIndex"
:
"0x00"
,
'transactionIndex'
:
'0x00'
,
"blockHash"
:
"0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5"
,
'blockHash'
:
'0x766d18646a06cf74faeabf38597314f84a82c3851859d9da9d94fc8d037269e5'
,
"blockNumber"
:
"0x06"
,
'blockNumber'
:
'0x06'
,
"gasUsed"
:
"0x06345f"
,
'gasUsed'
:
'0x06345f'
,
"cumulativeGasUsed"
:
"0x06345f"
,
'cumulativeGasUsed'
:
'0x06345f'
,
"contractAddress"
:
receipt
.
contractAddress
,
'contractAddress'
:
receipt
.
contractAddress
,
"logs"
:
[],
'logs'
:
[],
"status"
:
1
'status'
:
1
}
}
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
r
))
;
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
r
))
})
;
})
}
}
if
(
payload
.
method
===
'eth_getCode'
)
{
if
(
payload
.
method
===
'eth_getCode'
)
{
let
address
=
payload
.
params
[
0
]
;
let
address
=
payload
.
params
[
0
]
let
block
=
payload
.
params
[
1
];
// let block = payload.params[1]
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
self
.
deployedContracts
[
address
]))
;
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
self
.
deployedContracts
[
address
]))
}
}
if
(
payload
.
method
===
'eth_call'
)
{
if
(
payload
.
method
===
'eth_call'
)
{
processTx
(
this
.
accounts
,
payload
,
true
,
callback
)
processTx
(
this
.
accounts
,
payload
,
true
,
callback
)
}
}
}
}
Provider
.
prototype
.
isConnected
=
function
()
{
Provider
.
prototype
.
isConnected
=
function
()
{
return
true
;
return
true
}
}
module
.
exports
=
Provider
;
module
.
exports
=
Provider
src/testRunner.js
View file @
8948c6ba
...
@@ -83,8 +83,8 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
...
@@ -83,8 +83,8 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
}
}
}
}
next
()
next
()
}).
on
(
'error'
,
function
(
err
)
{
}).
on
(
'error'
,
function
(
err
)
{
next
(
err
)
;
next
(
err
)
})
})
}
}
},
function
()
{
},
function
()
{
...
...
src/txProcess.js
View file @
8948c6ba
...
@@ -3,15 +3,18 @@ var TxExecution = RemixLib.execution.txExecution
...
@@ -3,15 +3,18 @@ var TxExecution = RemixLib.execution.txExecution
var
TxRunner
=
RemixLib
.
execution
.
txRunner
var
TxRunner
=
RemixLib
.
execution
.
txRunner
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
executionContext
=
RemixLib
.
execution
.
executionContext
function
jsonRPCResponse
(
id
,
result
)
{
function
jsonRPCResponse
(
id
,
result
)
{
return
{
"id"
:
id
,
"jsonrpc"
:
"2.0"
,
"result"
:
result
};
return
{
'id'
:
id
,
'jsonrpc'
:
'2.0'
,
'result'
:
result
}
}
}
function
runTx
(
payload
,
from
,
to
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
isCall
,
callback
)
{
function
runTx
(
payload
,
from
,
to
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
isCall
,
callback
)
{
let
finalCallback
=
function
(
err
,
result
)
{
let
finalCallback
=
function
(
err
,
result
)
{
let
toReturn
;
if
(
err
)
{
return
callback
(
err
)
}
let
toReturn
if
(
isCall
)
{
if
(
isCall
)
{
toReturn
=
"0x"
+
result
.
result
.
vm
.
return
.
toString
(
'hex'
)
toReturn
=
'0x'
+
result
.
result
.
vm
.
return
.
toString
(
'hex'
)
if
(
toReturn
===
'0x'
)
{
if
(
toReturn
===
'0x'
)
{
toReturn
=
'0x0'
toReturn
=
'0x0'
}
}
...
@@ -25,30 +28,30 @@ function runTx(payload, from, to, data, value, gasLimit, txRunner, callbacks, is
...
@@ -25,30 +28,30 @@ function runTx(payload, from, to, data, value, gasLimit, txRunner, callbacks, is
TxExecution
.
callFunction
(
from
,
to
,
data
,
value
,
gasLimit
,
null
,
txRunner
,
callbacks
,
finalCallback
,
isCall
)
TxExecution
.
callFunction
(
from
,
to
,
data
,
value
,
gasLimit
,
null
,
txRunner
,
callbacks
,
finalCallback
,
isCall
)
}
}
function
createContract
(
payload
,
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
callback
)
{
function
createContract
(
payload
,
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
callback
)
{
let
finalCallback
=
function
(
err
,
result
)
{
let
finalCallback
=
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
return
callback
(
err
)
;
return
callback
(
err
)
}
}
let
contractAddress
=
(
'0x'
+
result
.
result
.
createdAddress
.
toString
(
'hex'
))
//
let contractAddress = ('0x' + result.result.createdAddress.toString('hex'))
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
result
.
transactionHash
))
callback
(
null
,
jsonRPCResponse
(
payload
.
id
,
result
.
transactionHash
))
}
}
TxExecution
.
createContract
(
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
finalCallback
)
;
TxExecution
.
createContract
(
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
finalCallback
)
}
}
function
processTx
(
accounts
,
payload
,
isCall
,
callback
)
{
function
processTx
(
accounts
,
payload
,
isCall
,
callback
)
{
let
api
=
{
let
api
=
{
logMessage
:
(
msg
)
=>
{
logMessage
:
(
msg
)
=>
{
},
},
logHtmlMessage
:
(
msg
)
=>
{
logHtmlMessage
:
(
msg
)
=>
{
},
},
//config: self._api.config,
//
config: self._api.config,
config
:
{
config
:
{
getUnpersistedProperty
:
(
key
)
=>
{
getUnpersistedProperty
:
(
key
)
=>
{
//if (key === 'settings/always-use-vm') {
//
if (key === 'settings/always-use-vm') {
// return true
//
return true
//}
//
}
return
true
return
true
},
},
get
:
()
=>
{
get
:
()
=>
{
...
@@ -59,34 +62,37 @@ function processTx(accounts, payload, isCall, callback) {
...
@@ -59,34 +62,37 @@ function processTx(accounts, payload, isCall, callback) {
cb
()
cb
()
},
},
personalMode
:
()
=>
{
personalMode
:
()
=>
{
//return self._api.config.get('settings/personal-mode')
//
return self._api.config.get('settings/personal-mode')
return
false
return
false
}
}
}
}
executionContext
.
init
(
api
.
config
)
;
executionContext
.
init
(
api
.
config
)
let
txRunner
=
new
TxRunner
(
accounts
,
api
)
;
let
txRunner
=
new
TxRunner
(
accounts
,
api
)
let
{
from
:
from
,
to
:
to
,
data
:
data
,
value
:
value
,
gas
:
gas
}
=
payload
.
params
[
0
];
let
{
from
,
to
,
data
,
value
,
gas
}
=
payload
.
params
[
0
]
gas
=
gas
||
3000000
;
gas
=
gas
||
3000000
let
callbacks
=
{
let
callbacks
=
{
confirmationCb
:
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
confirmationCb
:
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
continueTxExecution
(
null
)
;
continueTxExecution
(
null
)
},
},
gasEstimationForceSend
:
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
gasEstimationForceSend
:
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
continueTxExecution
();
if
(
error
)
{
continueTxExecution
(
error
)
}
continueTxExecution
()
},
},
promptCb
:
(
okCb
,
cancelCb
)
=>
{
promptCb
:
(
okCb
,
cancelCb
)
=>
{
okCb
()
;
okCb
()
}
}
}
}
if
(
to
)
{
if
(
to
)
{
runTx
(
payload
,
from
,
to
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
isCall
,
callback
)
;
runTx
(
payload
,
from
,
to
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
isCall
,
callback
)
}
else
{
}
else
{
createContract
(
payload
,
from
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
callback
)
;
createContract
(
payload
,
from
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
callback
)
}
}
}
}
module
.
exports
=
processTx
;
module
.
exports
=
processTx
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