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
8757ec54
Commit
8757ec54
authored
Dec 30, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extra confirmation dialog out of udapp-ui
parent
3767ac45
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
64 deletions
+37
-64
run-tab.js
src/app/udapp/run-tab.js
+1
-1
universal-dapp-ui.js
src/app/ui/universal-dapp-ui.js
+36
-63
No files found.
src/app/udapp/run-tab.js
View file @
8757ec54
...
@@ -49,7 +49,7 @@ export class RunTab extends LibraryPlugin {
...
@@ -49,7 +49,7 @@ export class RunTab extends LibraryPlugin {
}
}
onActivationInternal
()
{
onActivationInternal
()
{
this
.
udappUI
=
new
UniversalDAppUI
(
this
.
udapp
,
this
.
logCallback
,
this
.
executionContext
)
this
.
udappUI
=
new
UniversalDAppUI
(
this
.
blockchain
,
this
.
udapp
,
this
.
logCallback
,
this
.
executionContext
)
this
.
udapp
.
resetAPI
({
this
.
udapp
.
resetAPI
({
getAddress
:
(
cb
)
=>
{
getAddress
:
(
cb
)
=>
{
cb
(
null
,
$
(
'#txorigin'
).
val
())
cb
(
null
,
$
(
'#txorigin'
).
val
())
...
...
src/app/ui/universal-dapp-ui.js
View file @
8757ec54
...
@@ -4,14 +4,12 @@
...
@@ -4,14 +4,12 @@
var
$
=
require
(
'jquery'
)
var
$
=
require
(
'jquery'
)
var
yo
=
require
(
'yo-yo'
)
var
yo
=
require
(
'yo-yo'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
Web3
=
require
(
'web3'
)
var
BN
=
ethJSUtil
.
BN
var
BN
=
ethJSUtil
.
BN
var
helper
=
require
(
'../../lib/helper'
)
var
helper
=
require
(
'../../lib/helper'
)
var
copyToClipboard
=
require
(
'./copy-to-clipboard'
)
var
copyToClipboard
=
require
(
'./copy-to-clipboard'
)
var
css
=
require
(
'../../universal-dapp-styles'
)
var
css
=
require
(
'../../universal-dapp-styles'
)
var
MultiParamManager
=
require
(
'./multiParamManager'
)
var
MultiParamManager
=
require
(
'./multiParamManager'
)
var
remixLib
=
require
(
'remix-lib'
)
var
remixLib
=
require
(
'remix-lib'
)
var
typeConversion
=
remixLib
.
execution
.
typeConversion
var
txExecution
=
remixLib
.
execution
.
txExecution
var
txExecution
=
remixLib
.
execution
.
txExecution
var
txFormat
=
remixLib
.
execution
.
txFormat
var
txFormat
=
remixLib
.
execution
.
txFormat
...
@@ -20,7 +18,8 @@ var modalCustom = require('./modal-dialog-custom')
...
@@ -20,7 +18,8 @@ var modalCustom = require('./modal-dialog-custom')
var
modalDialog
=
require
(
'./modaldialog'
)
var
modalDialog
=
require
(
'./modaldialog'
)
var
TreeView
=
require
(
'./TreeView'
)
var
TreeView
=
require
(
'./TreeView'
)
function
UniversalDAppUI
(
udapp
,
logCallback
,
executionContext
)
{
function
UniversalDAppUI
(
blockchain
,
udapp
,
logCallback
,
executionContext
)
{
this
.
blockchain
=
blockchain
this
.
udapp
=
udapp
this
.
udapp
=
udapp
this
.
logCallback
=
logCallback
this
.
logCallback
=
logCallback
this
.
compilerData
=
{
contractsDetails
:
{}}
this
.
compilerData
=
{
contractsDetails
:
{}}
...
@@ -139,6 +138,39 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
...
@@ -139,6 +138,39 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
return
instance
return
instance
}
}
UniversalDAppUI
.
prototype
.
getConfirmationCb
=
function
(
modalDialog
,
confirmDialog
)
{
const
confirmationCb
=
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
if
(
network
.
name
!==
'Main'
)
{
return
continueTxExecution
(
null
)
}
const
amount
=
this
.
blockchain
.
fromWei
(
tx
.
value
,
true
,
'ether'
)
const
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
null
,
this
.
blockchain
.
determineGasFees
(
tx
),
this
.
blockchain
.
determineGasPrice
)
modalDialog
(
'Confirm transaction'
,
content
,
{
label
:
'Confirm'
,
fn
:
()
=>
{
this
.
config
.
setUnpersistedProperty
(
'doNotShowTransactionConfirmationAgain'
,
content
.
querySelector
(
'input#confirmsetting'
).
checked
)
// TODO: check if this is check is still valid given the refactor
if
(
!
content
.
gasPriceStatus
)
{
cancelCb
(
'Given gas price is not correct'
)
}
else
{
var
gasPrice
=
this
.
blockchain
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
continueTxExecution
(
gasPrice
)
}
}
},
{
label
:
'Cancel'
,
fn
:
()
=>
{
return
cancelCb
(
'Transaction canceled by user.'
)
}
}
)
}
return
confirmationCb
}
// TODO this is used by renderInstance when a new instance is displayed.
// TODO this is used by renderInstance when a new instance is displayed.
// this returns a DOM element.
// this returns a DOM element.
UniversalDAppUI
.
prototype
.
getCallButton
=
function
(
args
)
{
UniversalDAppUI
.
prototype
.
getCallButton
=
function
(
args
)
{
...
@@ -159,66 +191,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -159,66 +191,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
var
value
=
inputsValues
var
value
=
inputsValues
const
confirmationCb
=
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
const
confirmationCb
=
self
.
getConfirmationCb
(
modalDialog
,
confirmDialog
)
if
(
network
.
name
!==
'Main'
)
{
return
continueTxExecution
(
null
)
}
var
amount
=
Web3
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
self
.
udapp
,
(
gasPrice
,
cb
)
=>
{
let
txFeeText
,
priceStatus
// TODO: this try catch feels like an anti pattern, can/should be
// removed, but for now keeping the original logic
try
{
var
fee
=
Web3
.
utils
.
toBN
(
tx
.
gas
).
mul
(
Web3
.
utils
.
toBN
(
Web3
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
txFeeText
=
' '
+
Web3
.
utils
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
priceStatus
=
true
}
catch
(
e
)
{
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
priceStatus
=
false
}
cb
(
txFeeText
,
priceStatus
)
},
(
cb
)
=>
{
self
.
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
const
warnMessage
=
' Please fix this issue before sending any transaction. '
if
(
error
)
{
return
cb
(
'Unable to retrieve the current network gas price.'
+
warnMessage
+
error
)
}
try
{
var
gasPriceValue
=
Web3
.
utils
.
fromWei
(
gasPrice
.
toString
(
10
),
'gwei'
)
cb
(
null
,
gasPriceValue
)
}
catch
(
e
)
{
cb
(
warnMessage
+
e
.
message
,
null
,
false
)
}
})
}
)
modalDialog
(
'Confirm transaction'
,
content
,
{
label
:
'Confirm'
,
fn
:
()
=>
{
self
.
udapp
.
config
.
setUnpersistedProperty
(
'doNotShowTransactionConfirmationAgain'
,
content
.
querySelector
(
'input#confirmsetting'
).
checked
)
// TODO: check if this is check is still valid given the refactor
if
(
!
content
.
gasPriceStatus
)
{
cancelCb
(
'Given gas price is not correct'
)
}
else
{
var
gasPrice
=
Web3
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
continueTxExecution
(
gasPrice
)
}
}},
{
label
:
'Cancel'
,
fn
:
()
=>
{
return
cancelCb
(
'Transaction canceled by user.'
)
}
}
)
}
const
continueCb
=
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
const
continueCb
=
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
if
(
error
)
{
if
(
error
)
{
const
msg
=
typeof
error
!==
'string'
?
error
.
message
:
error
const
msg
=
typeof
error
!==
'string'
?
error
.
message
:
error
...
...
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