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
710cf55e
Commit
710cf55e
authored
Aug 28, 2020
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify txRunner
parent
facd5a47
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
txRunner.js
libs/remix-lib/src/execution/txRunner.js
+9
-13
No files found.
libs/remix-lib/src/execution/txRunner.js
View file @
710cf55e
...
@@ -77,22 +77,21 @@ class TxRunner {
...
@@ -77,22 +77,21 @@ class TxRunner {
}
}
}
}
execute
(
args
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
execute
(
args
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
let
data
=
args
.
data
let
data
=
args
.
data
if
(
data
.
slice
(
0
,
2
)
!==
'0x'
)
{
if
(
data
.
slice
(
0
,
2
)
!==
'0x'
)
{
data
=
'0x'
+
data
data
=
'0x'
+
data
}
}
if
(
!
this
.
executionContext
.
isVM
())
{
if
(
!
this
.
executionContext
.
isVM
())
{
this
.
runInNode
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
return
this
.
runInNode
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
}
else
{
}
try
{
try
{
this
.
runInVm
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
args
.
timestamp
,
callback
)
this
.
runInVm
(
args
.
from
,
args
.
to
,
data
,
args
.
value
,
args
.
gasLimit
,
args
.
useCall
,
args
.
timestamp
,
callback
)
}
catch
(
e
)
{
}
catch
(
e
)
{
callback
(
e
,
null
)
callback
(
e
,
null
)
}
}
}
}
}
runInVm
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
timestamp
,
callback
)
{
runInVm
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
timestamp
,
callback
)
{
const
self
=
this
const
self
=
this
...
@@ -228,9 +227,8 @@ async function tryTillReceiptAvailable (txhash, executionContext) {
...
@@ -228,9 +227,8 @@ async function tryTillReceiptAvailable (txhash, executionContext) {
// Try again with a bit of delay if error or if result still null
// Try again with a bit of delay if error or if result still null
await
pause
()
await
pause
()
return
resolve
(
await
tryTillReceiptAvailable
(
txhash
,
executionContext
))
return
resolve
(
await
tryTillReceiptAvailable
(
txhash
,
executionContext
))
}
else
{
return
resolve
(
receipt
)
}
}
return
resolve
(
receipt
)
})
})
})
})
}
}
...
@@ -242,21 +240,20 @@ async function tryTillTxAvailable (txhash, executionContext) {
...
@@ -242,21 +240,20 @@ async function tryTillTxAvailable (txhash, executionContext) {
// Try again with a bit of delay if error or if result still null
// Try again with a bit of delay if error or if result still null
await
pause
()
await
pause
()
return
resolve
(
await
tryTillTxAvailable
(
txhash
,
executionContext
))
return
resolve
(
await
tryTillTxAvailable
(
txhash
,
executionContext
))
}
else
{
return
resolve
(
tx
)
}
}
return
resolve
(
tx
)
})
})
})
})
}
}
async
function
pause
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
resolve
,
500
)
})
}
async
function
pause
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
resolve
,
500
)
})
}
function
run
(
self
,
tx
,
stamp
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
function
run
(
self
,
tx
,
stamp
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
callback
)
{
if
(
!
self
.
runAsync
&&
Object
.
keys
(
self
.
pendingTxs
).
length
)
{
if
(
!
self
.
runAsync
&&
Object
.
keys
(
self
.
pendingTxs
).
length
)
{
self
.
queusTxs
.
push
({
tx
,
stamp
,
callback
})
return
self
.
queusTxs
.
push
({
tx
,
stamp
,
callback
})
}
else
{
}
self
.
pendingTxs
[
stamp
]
=
tx
self
.
pendingTxs
[
stamp
]
=
tx
self
.
execute
(
tx
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
function
(
error
,
result
)
{
self
.
execute
(
tx
,
confirmationCb
,
gasEstimationForceSend
,
promptCb
,
function
(
error
,
result
)
{
delete
self
.
pendingTxs
[
stamp
]
delete
self
.
pendingTxs
[
stamp
]
if
(
callback
&&
typeof
callback
===
'function'
)
callback
(
error
,
result
)
if
(
callback
&&
typeof
callback
===
'function'
)
callback
(
error
,
result
)
if
(
self
.
queusTxs
.
length
)
{
if
(
self
.
queusTxs
.
length
)
{
...
@@ -264,7 +261,6 @@ function run (self, tx, stamp, confirmationCb, gasEstimationForceSend, promptCb,
...
@@ -264,7 +261,6 @@ function run (self, tx, stamp, confirmationCb, gasEstimationForceSend, promptCb,
run
(
self
,
next
.
tx
,
next
.
stamp
,
next
.
callback
)
run
(
self
,
next
.
tx
,
next
.
stamp
,
next
.
callback
)
}
}
})
})
}
}
}
module
.
exports
=
TxRunner
module
.
exports
=
TxRunner
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