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
09bea4e6
Commit
09bea4e6
authored
Jan 12, 2018
by
ninabreznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display modal dialog when create is clicked (when !VM)
parent
edda84a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
25 deletions
+48
-25
app.js
src/app.js
+2
-1
txRunner.js
src/app/execution/txRunner.js
+41
-22
universal-dapp.js
src/universal-dapp.js
+5
-2
No files found.
src/app.js
View file @
09bea4e6
...
@@ -247,7 +247,8 @@ function run () {
...
@@ -247,7 +247,8 @@ function run () {
api
:
{
api
:
{
logMessage
:
(
msg
)
=>
{
logMessage
:
(
msg
)
=>
{
self
.
_components
.
editorpanel
.
log
({
type
:
'log'
,
value
:
msg
})
self
.
_components
.
editorpanel
.
log
({
type
:
'log'
,
value
:
msg
})
}
},
config
:
self
.
_api
.
config
},
},
opt
:
{
removable
:
false
,
removable_instances
:
true
}
opt
:
{
removable
:
false
,
removable_instances
:
true
}
})
})
...
...
src/app/execution/txRunner.js
View file @
09bea4e6
...
@@ -16,12 +16,17 @@ var css = csjs`
...
@@ -16,12 +16,17 @@ 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 {
display: flex;
margin: 1em 0;
}
`
`
function
TxRunner
(
vmaccounts
,
opts
)
{
function
TxRunner
(
vmaccounts
,
opts
)
{
this
.
personalMode
=
opts
.
personalMode
this
.
personalMode
=
opts
.
personalMode
this
.
blockNumber
=
0
this
.
blockNumber
=
0
this
.
runAsync
=
true
this
.
runAsync
=
true
this
.
config
=
opts
.
config
if
(
executionContext
.
isVM
())
{
if
(
executionContext
.
isVM
())
{
this
.
blockNumber
=
1150000
// The VM is running in Homestead mode, which started at this block.
this
.
blockNumber
=
1150000
// The VM is running in Homestead mode, which started at this block.
this
.
runAsync
=
false
// We have to run like this cause the VM Event Manager does not support running multiple txs at the same time.
this
.
runAsync
=
false
// We have to run like this cause the VM Event Manager does not support running multiple txs at the same time.
...
@@ -57,16 +62,19 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -57,16 +62,19 @@ TxRunner.prototype.execute = function (args, callback) {
}
}
if
(
args
.
useCall
)
{
if
(
args
.
useCall
)
{
tx
.
gas
=
gasLimit
tx
.
gas
=
gasLimit
modalDialog
(
'Confirm transaction'
,
remixdDialog
(
tx
),
modalDialog
(
'Confirm transaction'
,
remixdDialog
(
tx
,
self
),
{
label
:
'Confirm'
,
{
label
:
'Confirm'
,
fn
:
()
=>
{
fn
:
()
=>
{
executionContext
.
web3
().
eth
.
call
(
tx
,
function
(
error
,
result
)
{
execute
()
callback
(
error
,
{
result
:
result
,
transactionHash
:
result
.
transactionHash
})
})
}})
}})
function
execute
()
{
executionContext
.
web3
().
eth
.
call
(
tx
,
function
(
error
,
result
)
{
callback
(
error
,
{
result
:
result
,
transactionHash
:
result
.
transactionHash
})
})
}
}
else
{
}
else
{
executionContext
.
web3
().
eth
.
estimateGas
(
tx
,
function
(
err
,
gasEstimation
)
{
executionContext
.
web3
().
eth
.
estimateGas
(
tx
,
function
(
err
,
gasEstimation
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -85,23 +93,26 @@ TxRunner.prototype.execute = function (args, callback) {
...
@@ -85,23 +93,26 @@ TxRunner.prototype.execute = function (args, callback) {
}
}
tx
.
gas
=
gasEstimation
tx
.
gas
=
gasEstimation
modalDialog
(
'Confirm transaction'
,
remixdDialog
(
tx
),
modalDialog
(
'Confirm transaction'
,
remixdDialog
(
tx
,
self
),
{
label
:
'Confirm'
,
{
label
:
'Confirm'
,
fn
:
()
=>
{
fn
:
()
=>
{
var
sendTransaction
=
self
.
personalMode
?
executionContext
.
web3
().
personal
.
sendTransaction
:
executionContext
.
web3
().
eth
.
sendTransaction
execute
()
try
{
}})
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
return
callback
(
err
,
resp
)
}
tryTillResponse
(
resp
,
callback
)
})
}
catch
(
e
)
{
return
callback
(
`Send transaction failed:
${
e
.
message
}
. if you use an injected provider, please check it is properly unlocked. `
)
}
}})
})
})
function
execute
()
{
var
sendTransaction
=
self
.
personalMode
?
executionContext
.
web3
().
personal
.
sendTransaction
:
executionContext
.
web3
().
eth
.
sendTransaction
try
{
sendTransaction
(
tx
,
function
(
err
,
resp
)
{
if
(
err
)
{
return
callback
(
err
,
resp
)
}
tryTillResponse
(
resp
,
callback
)
})
}
catch
(
e
)
{
return
callback
(
`Send transaction failed:
${
e
.
message
}
. if you use an injected provider, please check it is properly unlocked. `
)
}
}
}
}
}
else
{
}
else
{
try
{
try
{
...
@@ -185,7 +196,7 @@ function run (self, tx, stamp, callback) {
...
@@ -185,7 +196,7 @@ function run (self, tx, stamp, callback) {
}
}
}
}
function
remixdDialog
(
tx
)
{
function
remixdDialog
(
tx
,
self
)
{
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 trying to execute transaction on the main network. Click confirm if you want to continue!</div>
...
@@ -196,8 +207,16 @@ function remixdDialog (tx) {
...
@@ -196,8 +207,16 @@ function remixdDialog (tx) {
<div>gas limit:
${
tx
.
gas
}
</div>
<div>gas limit:
${
tx
.
gas
}
</div>
<div>data:
${
helper
.
shortenHexData
(
tx
.
data
)}
</div>
<div>data:
${
helper
.
shortenHexData
(
tx
.
data
)}
</div>
</div>
</div>
<div class=
${
css
.
checkbox
}
>
<div><input type="checkbox" onchange=
${()
=>
updateConfig
(
self
)}
></div>
<span class="
${
css
.
checkboxText
}
">Never ask me to confirm again (this will be not be persisted)</span>
</div>
</div>
</div>
`
`
}
}
function
updateConfig
(
self
)
{
self
.
config
.
set
(
'doNotShowAgain'
,
!
self
.
get
(
'doNotShowAgain'
))
}
module
.
exports
=
TxRunner
module
.
exports
=
TxRunner
src/universal-dapp.js
View file @
09bea4e6
...
@@ -156,6 +156,7 @@ function UniversalDApp (opts = {}) {
...
@@ -156,6 +156,7 @@ function UniversalDApp (opts = {}) {
var
self
=
this
var
self
=
this
self
.
_api
=
opts
.
api
self
.
_api
=
opts
.
api
console
.
log
(
self
.
_api
.
config
)
self
.
removable
=
opts
.
opt
.
removable
self
.
removable
=
opts
.
opt
.
removable
self
.
removable_instances
=
opts
.
opt
.
removable_instances
self
.
removable_instances
=
opts
.
opt
.
removable_instances
self
.
el
=
yo
`<div class=
${
css
.
udapp
}
></div>`
self
.
el
=
yo
`<div class=
${
css
.
udapp
}
></div>`
...
@@ -166,7 +167,8 @@ function UniversalDApp (opts = {}) {
...
@@ -166,7 +167,8 @@ function UniversalDApp (opts = {}) {
self
.
reset
(
self
.
contracts
)
self
.
reset
(
self
.
contracts
)
})
})
self
.
txRunner
=
new
TxRunner
({},
{
self
.
txRunner
=
new
TxRunner
({},
{
personalMode
:
this
.
personalMode
personalMode
:
this
.
personalMode
,
config
:
self
.
_api
.
config
})
})
}
}
...
@@ -186,7 +188,8 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
...
@@ -186,7 +188,8 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
executionContext
.
vm
().
stateManager
.
cache
.
flush
(
function
()
{})
executionContext
.
vm
().
stateManager
.
cache
.
flush
(
function
()
{})
}
}
this
.
txRunner
=
new
TxRunner
(
this
.
accounts
,
{
this
.
txRunner
=
new
TxRunner
(
this
.
accounts
,
{
personalMode
:
this
.
personalMode
personalMode
:
this
.
personalMode
,
config
:
this
.
_api
.
config
})
})
}
}
...
...
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