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
06b70683
Unverified
Commit
06b70683
authored
Mar 14, 2018
by
yann300
Committed by
GitHub
Mar 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1149 from ethereum/extract_tx_runner
extract modal dialog from txRunner
parents
84d81001
8c7f3db8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
txRunner.js
src/app/execution/txRunner.js
+18
-17
universal-dapp.js
src/universal-dapp.js
+3
-0
No files found.
src/app/execution/txRunner.js
View file @
06b70683
...
...
@@ -4,7 +4,6 @@ var EthJSBlock = require('ethereumjs-block')
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
var
executionContext
=
require
(
'../../execution-context'
)
var
modal
=
require
(
'../ui/modal-dialog-custom'
)
function
TxRunner
(
vmaccounts
,
api
)
{
this
.
_api
=
api
...
...
@@ -19,25 +18,27 @@ function TxRunner (vmaccounts, api) {
this
.
queusTxs
=
[]
}
TxRunner
.
prototype
.
rawRun
=
function
(
args
,
confirmationCb
,
gasEstimationForceSend
,
cb
)
{
run
(
this
,
args
,
Date
.
now
(),
confirmationCb
,
gasEstimationForceSend
,
cb
)
TxRunner
.
prototype
.
rawRun
=
function
(
args
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
cb
)
{
run
(
this
,
args
,
Date
.
now
(),
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
cb
)
}
function
executeTx
(
tx
,
gasPrice
,
api
,
callback
)
{
function
executeTx
(
tx
,
gasPrice
,
api
,
promptCb
,
callback
)
{
if
(
gasPrice
)
tx
.
gasPrice
=
executionContext
.
web3
().
toHex
(
gasPrice
)
if
(
api
.
personalMode
())
{
modal
.
promptPassphrase
(
null
,
'Personal mode is enabled. Please provide passphrase of account '
+
tx
.
from
,
''
,
(
value
)
=>
{
sendTransaction
(
executionContext
.
web3
().
personal
.
sendTransaction
,
tx
,
value
,
callback
)
},
()
=>
{
return
callback
(
'Canceled by user.'
)
})
promptCb
(
(
value
)
=>
{
sendTransaction
(
executionContext
.
web3
().
personal
.
sendTransaction
,
tx
,
value
,
callback
)
},
()
=>
{
return
callback
(
'Canceled by user.'
)
}
)
}
else
{
sendTransaction
(
executionContext
.
web3
().
eth
.
sendTransaction
,
tx
,
null
,
callback
)
}
}
TxRunner
.
prototype
.
execute
=
function
(
args
,
confirmationCb
,
gasEstimationForceSend
,
callback
)
{
TxRunner
.
prototype
.
execute
=
function
(
args
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
var
self
=
this
var
data
=
args
.
data
...
...
@@ -46,7 +47,7 @@ TxRunner.prototype.execute = function (args, confirmationCb, gasEstimationForceS
}
if
(
!
executionContext
.
isVM
())
{
self
.
runInNode
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
confirmationCb
,
gasEstimationForceSend
,
callback
)
self
.
runInNode
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
}
else
{
try
{
self
.
runInVm
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
callback
)
...
...
@@ -104,7 +105,7 @@ TxRunner.prototype.runInVm = function (from, to, data, value, gasLimit, useCall,
})
}
TxRunner
.
prototype
.
runInNode
=
function
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
confirmCb
,
gasEstimationForceSend
,
callback
)
{
TxRunner
.
prototype
.
runInNode
=
function
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
confirmCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
const
self
=
this
var
tx
=
{
from
:
from
,
to
:
to
,
data
:
data
,
value
:
value
}
...
...
@@ -123,7 +124,7 @@ TxRunner.prototype.runInNode = function (from, to, data, value, gasLimit, useCal
tx
.
gas
=
!
gasEstimation
?
gasLimit
:
gasEstimation
if
(
self
.
_api
.
config
.
getUnpersistedProperty
(
'doNotShowTransactionConfirmationAgain'
))
{
return
executeTx
(
tx
,
null
,
self
.
_api
,
callback
)
return
executeTx
(
tx
,
null
,
self
.
_api
,
promptCb
,
callback
)
}
self
.
_api
.
detectNetwork
((
err
,
network
)
=>
{
...
...
@@ -133,7 +134,7 @@ TxRunner.prototype.runInNode = function (from, to, data, value, gasLimit, useCal
}
confirmCb
(
network
,
tx
,
tx
.
gas
,
(
gasPrice
)
=>
{
return
executeTx
(
tx
,
gasPrice
,
self
.
_api
,
callback
)
return
executeTx
(
tx
,
gasPrice
,
self
.
_api
,
promptCb
,
callback
)
},
(
error
)
=>
{
callback
(
error
)
})
...
...
@@ -186,12 +187,12 @@ function sendTransaction (sendTx, tx, pass, callback) {
}
}
function
run
(
self
,
tx
,
stamp
,
confirmationCb
,
gasEstimationForceSend
,
callback
)
{
function
run
(
self
,
tx
,
stamp
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
if
(
!
self
.
runAsync
&&
Object
.
keys
(
self
.
pendingTxs
).
length
)
{
self
.
queusTxs
.
push
({
tx
,
stamp
,
callback
})
}
else
{
self
.
pendingTxs
[
stamp
]
=
tx
self
.
execute
(
tx
,
confirmationCb
,
gasEstimationForceSend
,
(
error
,
result
)
=>
{
self
.
execute
(
tx
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
(
error
,
result
)
=>
{
delete
self
.
pendingTxs
[
stamp
]
callback
(
error
,
result
)
if
(
self
.
queusTxs
.
length
)
{
...
...
src/universal-dapp.js
View file @
06b70683
...
...
@@ -330,6 +330,9 @@ UniversalDApp.prototype.runTx = function (args, cb) {
continueTxExecution
()
}
},
function
(
okCb
,
cancelCb
)
{
modalCustom
.
promptPassphrase
(
null
,
'Personal mode is enabled. Please provide passphrase of account '
+
tx
.
from
,
''
,
okCb
,
cancelCb
)
},
function
(
error
,
result
)
{
let
eventName
=
(
tx
.
useCall
?
'callExecuted'
:
'transactionExecuted'
)
self
.
event
.
trigger
(
eventName
,
[
error
,
tx
.
from
,
tx
.
to
,
tx
.
data
,
tx
.
useCall
,
result
,
timestamp
,
payLoad
])
...
...
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