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
92e955c5
Commit
92e955c5
authored
Jan 16, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add gas estimation, use unpersisted property
parent
3285767c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
txRunner.js
src/app/execution/txRunner.js
+25
-25
No files found.
src/app/execution/txRunner.js
View file @
92e955c5
...
@@ -5,7 +5,6 @@ var ethJSUtil = require('ethereumjs-util')
...
@@ -5,7 +5,6 @@ var ethJSUtil = require('ethereumjs-util')
var
BN
=
ethJSUtil
.
BN
var
BN
=
ethJSUtil
.
BN
var
executionContext
=
require
(
'../../execution-context'
)
var
executionContext
=
require
(
'../../execution-context'
)
var
modalDialog
=
require
(
'../ui/modaldialog'
)
var
modalDialog
=
require
(
'../ui/modaldialog'
)
var
helper
=
require
(
'../../lib/helper'
)
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
csjs
=
require
(
'csjs-inject'
)
var
csjs
=
require
(
'csjs-inject'
)
var
remixLib
=
require
(
'remix-lib'
)
var
remixLib
=
require
(
'remix-lib'
)
...
@@ -16,9 +15,12 @@ var css = csjs`
...
@@ -16,9 +15,12 @@ var css = csjs`
.txInfoBox {
.txInfoBox {
${
styles
.
rightPanel
.
compileTab
.
box_CompileContainer
}
; // add askToConfirmTXContainer to Remix and then replace this styling
${
styles
.
rightPanel
.
compileTab
.
box_CompileContainer
}
; // add askToConfirmTXContainer to Remix and then replace this styling
}
}
.checkbox {
.wrapword {
display: flex;
white-space: pre-wrap; /* Since CSS 2.1 */
margin: 1em 0;
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
}
`
`
...
@@ -63,12 +65,12 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -63,12 +65,12 @@ TxRunner.prototype.execute = function (args, callback) {
if
(
args
.
useCall
)
{
if
(
args
.
useCall
)
{
tx
.
gas
=
gasLimit
tx
.
gas
=
gasLimit
executionContext
.
web3
().
eth
.
call
(
tx
,
function
(
error
,
result
)
{
executionContext
.
web3
().
eth
.
call
(
tx
,
function
(
error
,
result
)
{
callback
(
error
,
{
callback
(
error
,
{
result
:
result
,
result
:
result
,
transactionHash
:
result
.
transactionHash
transactionHash
:
result
.
transactionHash
})
})
})
})
}
else
{
}
else
{
function
execute
()
{
function
execute
()
{
var
sendTransaction
=
self
.
personalMode
?
executionContext
.
web3
().
personal
.
sendTransaction
:
executionContext
.
web3
().
eth
.
sendTransaction
var
sendTransaction
=
self
.
personalMode
?
executionContext
.
web3
().
personal
.
sendTransaction
:
executionContext
.
web3
().
eth
.
sendTransaction
...
@@ -102,13 +104,13 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -102,13 +104,13 @@ TxRunner.prototype.execute = function (args, callback) {
tx
.
gas
=
gasEstimation
tx
.
gas
=
gasEstimation
if
(
!
self
.
config
.
get
(
'doNotShow
Again'
))
{
if
(
!
self
.
config
.
get
UnpersistedProperty
(
'doNotShowTransactionConfirmation
Again'
))
{
self
.
detectNetwork
((
err
,
network
)
=>
{
self
.
detectNetwork
((
err
,
network
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
}
else
{
}
else
{
if
(
network
.
name
===
'Main'
)
{
if
(
network
.
name
===
'Main'
)
{
modalDialog
(
'Confirm transaction'
,
remixdDialog
(
tx
,
self
),
modalDialog
(
'Confirm transaction'
,
remixdDialog
(
tx
,
gasEstimation
,
self
),
{
label
:
'Confirm'
,
{
label
:
'Confirm'
,
fn
:
()
=>
{
fn
:
()
=>
{
execute
()
execute
()
...
@@ -210,28 +212,26 @@ function run (self, tx, stamp, callback) {
...
@@ -210,28 +212,26 @@ function run (self, tx, stamp, callback) {
}
}
}
}
function
remixdDialog
(
tx
,
self
)
{
function
remixdDialog
(
tx
,
gasEstimation
,
self
)
{
var
input
=
yo
`<input type="checkbox" onchange=
${()
=>
{
self
.
config
.
setUnpersistedProperty
(
'doNotShowTransactionConfirmationAgain'
,
this
.
checked
)
}}
>
`
return yo`
return yo`
<
div
>
<
div
>
<div>You are
trying to execute transaction on the main network. Click confirm if you want to continue!
</div>
<
div
>
You
are
creating
a
transaction
on
the
main
network
.
Click
confirm
if
you
are
sure
to
continue
.
<
/div
>
<
div
class
=
$
{
css
.
txInfoBox
}
>
<
div
class
=
$
{
css
.
txInfoBox
}
>
<div>from:
${
tx
.
from
}
</div>
<div>From:
${
tx
.
from
}
</div>
<div>to:
${
tx
.
from
}
</div>
<div>To:
${
tx
.
to
?
tx
.
to
:
'(Contract Creation)'
}
</div>
<div>tx value:
${
tx
.
value
}
</div>
<div>Amount:
${
tx
.
value
}
</div>
<div>gas limit:
${
tx
.
gas
}
</div>
<div>Gas estimation:
${
gasEstimation
}
</div>
<div>data:
${
helper
.
shortenHexData
(
tx
.
data
)}
</div>
<div>Gas limit:
${
tx
.
gas
}
</div>
<div>Data:</div>
<pre class=
${
css
.
wrapword
}
>
${
tx
.
data
}
</pre>
</div>
</div>
<div class=
${
css
.
checkbox
}
>
<div class=
${
css
.
checkbox
}
>
<div><input type="checkbox" onchange=
${()
=>
updateConfig
(
self
)}
></div>
${
input
}
<
span class="
${
css
.
checkboxText
}
">Don't ask me to confirm again</span>
<
i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Do not ask for confirmation again. (the setting will not be persisted for the next page reload)
</div>
</div>
</div>
</div>
`
`
}
}
function
updateConfig
(
self
)
{
self
.
config
.
set
(
'doNotShowAgain'
,
!
self
.
config
.
get
(
'doNotShowAgain'
))
document
.
querySelector
(
'#askToConfirm'
).
setAttribute
(
'checked'
,
true
)
}
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