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
b75fb5cb
Commit
b75fb5cb
authored
Dec 19, 2019
by
LianaHus
Committed by
Liana Husikyan
Dec 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function modifiers ceck and style fixes
parent
f68e283d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
39 deletions
+46
-39
multiParamManager.js
src/app/ui/multiParamManager.js
+2
-2
universal-dapp-ui.js
src/app/ui/universal-dapp-ui.js
+42
-35
universal-dapp-styles.js
src/universal-dapp-styles.js
+2
-2
No files found.
src/app/ui/multiParamManager.js
View file @
b75fb5cb
...
@@ -186,7 +186,7 @@ class MultiParamManager {
...
@@ -186,7 +186,7 @@ class MultiParamManager {
expandedButton
.
classList
.
add
(
'btn-info'
)
expandedButton
.
classList
.
add
(
'btn-info'
)
funcButton
.
setAttribute
(
'title'
,
(
title
+
' - call'
))
funcButton
.
setAttribute
(
'title'
,
(
title
+
' - call'
))
funcButton
.
classList
.
add
(
'btn-info'
)
funcButton
.
classList
.
add
(
'btn-info'
)
}
else if (this.funABI.stateMutability === 'payable' || this.funABI.payable
=== true
) {
}
else if (this.funABI.stateMutability === 'payable' || this.funABI.payable) {
// transact. stateMutability = payable
// transact. stateMutability = payable
expandedButton.setAttribute('title', (title + ' - transact (payable)'))
expandedButton.setAttribute('title', (title + ' - transact (payable)'))
expandedButton.innerHTML = 'transact'
expandedButton.innerHTML = 'transact'
...
@@ -194,7 +194,7 @@ class MultiParamManager {
...
@@ -194,7 +194,7 @@ class MultiParamManager {
funcButton.setAttribute('title', (title + ' - transact (payable)'))
funcButton.setAttribute('title', (title + ' - transact (payable)'))
funcButton.classList.add('btn-danger')
funcButton.classList.add('btn-danger')
} else {
} else {
// transact. stateMutability = no
t
payable
// transact. stateMutability = no
n
payable
expandedButton.setAttribute('title', (title + ' - transact (not payable)'))
expandedButton.setAttribute('title', (title + ' - transact (not payable)'))
expandedButton.innerHTML = 'transact'
expandedButton.innerHTML = 'transact'
expandedButton.classList.add('btn-warning')
expandedButton.classList.add('btn-warning')
...
...
src/app/ui/universal-dapp-ui.js
View file @
b75fb5cb
...
@@ -142,35 +142,35 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
...
@@ -142,35 +142,35 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address
// 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
)
{
var
self
=
this
let
self
=
this
// args.funABI, args.address [fun only]
// args.funABI, args.address [fun only]
// args.contractName [constr only]
// args.contractName [constr only]
var
lookupOnly
=
args
.
funABI
.
constant
const
lookupOnly
=
args
.
funABI
.
stateMutability
===
'view'
||
args
.
funABI
.
stateMutability
===
'pure'
||
args
.
funABI
.
constant
var
outputOverride
=
yo
`<div class=
${
css
.
value
}
></div>`
// show return value
var
outputOverride
=
yo
`<div class=
${
css
.
value
}
></div>`
// show return value
function
clickButton
(
valArr
,
inputsValues
)
{
function
clickButton
(
valArr
,
inputsValues
)
{
var
logMsg
let
logMsg
if
(
!
args
.
funABI
.
constant
)
{
if
(
lookupOnly
)
{
logMsg
=
`transact to
${
args
.
contractName
}
.
${(
args
.
funABI
.
name
)
?
args
.
funABI
.
name
:
'(fallback)'
}
`
}
else
{
logMsg
=
`call to
${
args
.
contractName
}
.
${(
args
.
funABI
.
name
)
?
args
.
funABI
.
name
:
'(fallback)'
}
`
logMsg
=
`call to
${
args
.
contractName
}
.
${(
args
.
funABI
.
name
)
?
args
.
funABI
.
name
:
'(fallback)'
}
`
}
else
{
logMsg
=
`transact to
${
args
.
contractName
}
.
${(
args
.
funABI
.
name
)
?
args
.
funABI
.
name
:
'(fallback)'
}
`
}
}
var
value
=
inputsValues
var
value
=
inputsValues
var
confirmationCb
=
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
const
confirmationCb
=
(
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
=>
{
if
(
network
.
name
!==
'Main'
)
{
if
(
network
.
name
!==
'Main'
)
{
return
continueTxExecution
(
null
)
return
continueTxExecution
(
null
)
}
}
var
amount
=
executionContext
.
web3
().
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
const
amount
=
executionContext
.
web3
().
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
self
.
udapp
,
const
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
self
.
udapp
,
(
gasPrice
,
cb
)
=>
{
(
gasPrice
,
cb
)
=>
{
let
txFeeText
,
priceStatus
let
txFeeText
,
priceStatus
// TODO: this try catch feels like an anti pattern, can/should be
// TODO: this try catch feels like an anti pattern, can/should be
// removed, but for now keeping the original logic
// removed, but for now keeping the original logic
try
{
try
{
var
fee
=
executionContext
.
web3
().
toBigNumber
(
tx
.
gas
).
mul
(
executionContext
.
web3
().
toBigNumber
(
executionContext
.
web3
().
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
const
fee
=
executionContext
.
web3
().
toBigNumber
(
tx
.
gas
).
mul
(
executionContext
.
web3
().
toBigNumber
(
executionContext
.
web3
().
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
txFeeText
=
' '
+
executionContext
.
web3
().
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
txFeeText
=
' '
+
executionContext
.
web3
().
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
priceStatus
=
true
priceStatus
=
true
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -181,12 +181,12 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -181,12 +181,12 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
},
},
(
cb
)
=>
{
(
cb
)
=>
{
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
var
warnMessage
=
' Please fix this issue before sending any transaction. '
const
warnMessage
=
' Please fix this issue before sending any transaction. '
if
(
error
)
{
if
(
error
)
{
return
cb
(
'Unable to retrieve the current network gas price.'
+
warnMessage
+
error
)
return
cb
(
'Unable to retrieve the current network gas price.'
+
warnMessage
+
error
)
}
}
try
{
try
{
var
gasPriceValue
=
executionContext
.
web3
().
fromWei
(
gasPrice
.
toString
(
10
),
'gwei'
)
const
gasPriceValue
=
executionContext
.
web3
().
fromWei
(
gasPrice
.
toString
(
10
),
'gwei'
)
cb
(
null
,
gasPriceValue
)
cb
(
null
,
gasPriceValue
)
}
catch
(
e
)
{
}
catch
(
e
)
{
cb
(
warnMessage
+
e
.
message
,
null
,
false
)
cb
(
warnMessage
+
e
.
message
,
null
,
false
)
...
@@ -194,10 +194,15 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -194,10 +194,15 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
})
})
}
}
)
)
modalDialog
(
'Confirm transaction'
,
content
,
modalDialog
(
'Confirm transaction'
,
content
,
{
label
:
'Confirm'
,
{
label
:
'Confirm'
,
fn
:
()
=>
{
fn
:
()
=>
{
self
.
udapp
.
config
.
setUnpersistedProperty
(
'doNotShowTransactionConfirmationAgain'
,
content
.
querySelector
(
'input#confirmsetting'
).
checked
)
self
.
udapp
.
config
.
setUnpersistedProperty
(
'doNotShowTransactionConfirmationAgain'
,
content
.
querySelector
(
'input#confirmsetting'
).
checked
)
// TODO: check if this is check is still valid given the refactor
// TODO: check if this is check is still valid given the refactor
if
(
!
content
.
gasPriceStatus
)
{
if
(
!
content
.
gasPriceStatus
)
{
cancelCb
(
'Given gas price is not correct'
)
cancelCb
(
'Given gas price is not correct'
)
...
@@ -210,44 +215,46 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -210,44 +215,46 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
fn
:
()
=>
{
fn
:
()
=>
{
return
cancelCb
(
'Transaction canceled by user.'
)
return
cancelCb
(
'Transaction canceled by user.'
)
}
}
})
}
)
}
}
var
continueCb
=
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
const
continueCb
=
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
if
(
error
)
{
if
(
error
)
{
var
msg
=
typeof
error
!==
'string'
?
error
.
message
:
error
const
msg
=
typeof
error
!==
'string'
?
error
.
message
:
error
modalDialog
(
'Gas estimation failed'
,
yo
`<div>Gas estimation errored with the following message (see below).
modalDialog
(
The transaction execution will likely fail. Do you want to force sending? <br>
'Gas estimation failed'
,
${
msg
}
yo
`
</div>`
,
<div>Gas estimation errored with the following message (see below).
The transaction execution will likely fail. Do you want to force sending? <br>
${
msg
}
</div>
`
,
{
{
label
:
'Send Transaction'
,
label
:
'Send Transaction'
,
fn
:
()
=>
{
fn
:
()
=>
continueTxExecution
()
continueTxExecution
()
},
}},
{
{
label
:
'Cancel Transaction'
,
label
:
'Cancel Transaction'
,
fn
:
()
=>
{
fn
:
()
=>
cancelCb
()
cancelCb
()
}
}
)
})
}
else
{
}
else
{
continueTxExecution
()
continueTxExecution
()
}
}
}
}
var
outputCb
=
(
decoded
)
=>
{
const
outputCb
=
(
decoded
)
=>
{
outputOverride
.
innerHTML
=
''
outputOverride
.
innerHTML
=
''
outputOverride
.
appendChild
(
decoded
)
outputOverride
.
appendChild
(
decoded
)
}
}
var
promptCb
=
(
okCb
,
cancelCb
)
=>
{
const
promptCb
=
(
okCb
,
cancelCb
)
=>
{
modalCustom
.
promptPassphrase
(
'Passphrase requested'
,
'Personal mode is enabled. Please provide passphrase of account'
,
''
,
okCb
,
cancelCb
)
modalCustom
.
promptPassphrase
(
'Passphrase requested'
,
'Personal mode is enabled. Please provide passphrase of account'
,
''
,
okCb
,
cancelCb
)
}
}
// contractsDetails is used to resolve libraries
// contractsDetails is used to resolve libraries
txFormat
.
buildData
(
args
.
contractName
,
args
.
contractAbi
,
{},
false
,
args
.
funABI
,
args
.
funABI
.
type
!==
'fallback'
?
value
:
''
,
(
error
,
data
)
=>
{
txFormat
.
buildData
(
args
.
contractName
,
args
.
contractAbi
,
{},
false
,
args
.
funABI
,
args
.
funABI
.
type
!==
'fallback'
?
value
:
''
,
(
error
,
data
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
if
(
!
args
.
funABI
.
constant
)
{
if
(
args
.
funABI
.
stateMutability
!==
'constant'
||
args
.
funABI
.
constant
)
{
self
.
logCallback
(
`
${
logMsg
}
pending ... `
)
self
.
logCallback
(
`
${
logMsg
}
pending ... `
)
}
else
{
}
else
{
self
.
logCallback
(
`
${
logMsg
}
`
)
self
.
logCallback
(
`
${
logMsg
}
`
)
...
@@ -264,7 +271,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -264,7 +271,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
}
}
}
}
if
(
lookupOnly
)
{
if
(
lookupOnly
)
{
var
decoded
=
decodeResponseToTreeView
(
executionContext
.
isVM
()
?
txResult
.
result
.
execResult
.
returnValue
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
)
const
decoded
=
decodeResponseToTreeView
(
executionContext
.
isVM
()
?
txResult
.
result
.
execResult
.
returnValue
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
)
outputCb
(
decoded
)
outputCb
(
decoded
)
}
}
}
else
{
}
else
{
...
@@ -282,11 +289,11 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -282,11 +289,11 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
})
})
}
}
var
multiParamManager
=
new
MultiParamManager
(
lookupOnly
,
args
.
funABI
,
(
valArray
,
inputsValues
,
domEl
)
=>
{
const
multiParamManager
=
new
MultiParamManager
(
lookupOnly
,
args
.
funABI
,
(
valArray
,
inputsValues
,
domEl
)
=>
{
clickButton
(
valArray
,
inputsValues
,
domEl
)
clickButton
(
valArray
,
inputsValues
,
domEl
)
},
self
.
udapp
.
getInputs
(
args
.
funABI
))
},
self
.
udapp
.
getInputs
(
args
.
funABI
))
var
contractActionsContainer
=
yo
`<div class="
${
css
.
contractActionsContainer
}
" >
${
multiParamManager
.
render
()}
</div>`
const
contractActionsContainer
=
yo
`<div class="
${
css
.
contractActionsContainer
}
" >
${
multiParamManager
.
render
()}
</div>`
contractActionsContainer
.
appendChild
(
outputOverride
)
contractActionsContainer
.
appendChild
(
outputOverride
)
return
contractActionsContainer
return
contractActionsContainer
...
...
src/universal-dapp-styles.js
View file @
b75fb5cb
...
@@ -160,8 +160,8 @@ var css = csjs`
...
@@ -160,8 +160,8 @@ var css = csjs`
}
}
.value ul {
.value ul {
margin-bottom: 10px;
margin-bottom: 10px;
padding-
bottom
: 5px;
padding-
top
: 5px;
border-bottom:
1px solid var(--info
);
border-bottom:
4px solid var(--light
);
}
}
.contractActionsContainer {
.contractActionsContainer {
width: 98%;
width: 98%;
...
...
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