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
4a46ed9f
Commit
4a46ed9f
authored
Jan 28, 2020
by
LianaHus
Committed by
Liana Husikyan
Jan 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dded callbakcs file
parent
a08db5f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
0 deletions
+103
-0
sendTxCallbacks.js
src/app/ui/sendTxCallbacks.js
+103
-0
No files found.
src/app/ui/sendTxCallbacks.js
0 → 100644
View file @
4a46ed9f
const
yo
=
require
(
'yo-yo'
)
const
confirmDialog
=
require
(
'./confirmDialog'
)
const
modalCustom
=
require
(
'./modal-dialog-custom'
)
const
modalDialog
=
require
(
'./modaldialog'
)
const
typeConversion
=
remixLib
.
execution
.
typeConversion
const
Web3
=
require
(
'web3'
)
UniversalDAppUI
.
prototype
.
confirmationCb
=
function
(
executionContext
,
udapp
,
network
,
tx
,
gasEstimation
,
continueTxExecution
,
cancelCb
)
{
let
self
=
this
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.'
)
}
}
)
}
module
.
exports
=
confirmationCb
const
continueCb
=
(
error
,
continueTxExecution
,
cancelCb
)
=>
{
if
(
error
)
{
const
msg
=
typeof
error
!==
'string'
?
error
.
message
:
error
modalDialog
(
'Gas estimation failed'
,
yo
`
<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'
,
fn
:
()
=>
continueTxExecution
()
},
{
label
:
'Cancel Transaction'
,
fn
:
()
=>
cancelCb
()
}
)
}
else
{
continueTxExecution
()
}
}
module
.
exports
=
continueCb
const
promptCb
=
(
okCb
,
cancelCb
)
=>
{
modalCustom
.
promptPassphrase
(
'Passphrase requested'
,
'Personal mode is enabled. Please provide passphrase of account'
,
''
,
okCb
,
cancelCb
)
}
module
.
exports
=
promptCb
\ No newline at end of file
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