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
e448ded4
Commit
e448ded4
authored
Dec 06, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user Web3 utils instead of execution context web3
parent
9ed91e81
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
22 deletions
+27
-22
dropdownlogic.js
src/app/tabs/runTab/model/dropdownlogic.js
+10
-9
recorder.js
src/app/tabs/runTab/model/recorder.js
+6
-5
settings.js
src/app/tabs/runTab/model/settings.js
+3
-2
run-tab.js
src/app/udapp/run-tab.js
+2
-1
universal-dapp-ui.js
src/app/ui/universal-dapp-ui.js
+6
-5
No files found.
src/app/tabs/runTab/model/dropdownlogic.js
View file @
e448ded4
...
@@ -7,6 +7,7 @@ var typeConversion = remixLib.execution.typeConversion
...
@@ -7,6 +7,7 @@ var typeConversion = remixLib.execution.typeConversion
var
txExecution
=
remixLib
.
execution
.
txExecution
var
txExecution
=
remixLib
.
execution
.
txExecution
var
CompilerAbstract
=
require
(
'../../../compiler/compiler-abstract'
)
var
CompilerAbstract
=
require
(
'../../../compiler/compiler-abstract'
)
var
EventManager
=
remixLib
.
EventManager
var
EventManager
=
remixLib
.
EventManager
var
Web3
=
require
(
'web3'
)
class
DropdownLogic
{
class
DropdownLogic
{
constructor
(
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
runView
)
{
constructor
(
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
runView
)
{
...
@@ -106,17 +107,17 @@ class DropdownLogic {
...
@@ -106,17 +107,17 @@ class DropdownLogic {
fromWei
(
value
,
doTypeConversion
,
unit
)
{
fromWei
(
value
,
doTypeConversion
,
unit
)
{
if
(
doTypeConversion
)
{
if
(
doTypeConversion
)
{
return
executionContext
.
web3
()
.
utils
.
fromWei
(
typeConversion
.
toInt
(
value
),
unit
||
'ether'
)
return
Web3
.
utils
.
fromWei
(
typeConversion
.
toInt
(
value
),
unit
||
'ether'
)
}
}
return
executionContext
.
web3
()
.
utils
.
fromWei
(
value
.
toString
(
10
),
unit
||
'ether'
)
return
Web3
.
utils
.
fromWei
(
value
.
toString
(
10
),
unit
||
'ether'
)
}
}
toWei
(
value
,
unit
)
{
toWei
(
value
,
unit
)
{
return
executionContext
.
web3
()
.
utils
.
toWei
(
value
,
unit
||
'gwei'
)
return
Web3
.
utils
.
toWei
(
value
,
unit
||
'gwei'
)
}
}
calculateFee
(
gas
,
gasPrice
,
unit
)
{
calculateFee
(
gas
,
gasPrice
,
unit
)
{
return
executionContext
.
web3
().
utils
.
toBN
(
gas
).
mul
(
executionContext
.
web3
().
utils
.
toBN
(
executionContext
.
web3
()
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
unit
||
'gwei'
)))
return
Web3
.
utils
.
toBN
(
gas
).
mul
(
Web3
.
utils
.
toBN
(
Web3
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
unit
||
'gwei'
)))
}
}
getGasPrice
(
cb
)
{
getGasPrice
(
cb
)
{
...
@@ -139,7 +140,7 @@ class DropdownLogic {
...
@@ -139,7 +140,7 @@ class DropdownLogic {
if
(
network
.
name
!==
'Main'
)
{
if
(
network
.
name
!==
'Main'
)
{
return
continueTxExecution
(
null
)
return
continueTxExecution
(
null
)
}
}
var
amount
=
executionContext
.
web3
()
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
var
amount
=
Web3
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
// TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily
// TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
this
.
recorder
,
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
this
.
recorder
,
...
@@ -148,8 +149,8 @@ class DropdownLogic {
...
@@ -148,8 +149,8 @@ class DropdownLogic {
// 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
().
utils
.
toBN
(
tx
.
gas
).
mul
(
executionContext
.
web3
().
utils
.
toBN
(
executionContext
.
web3
()
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
var
fee
=
Web3
.
utils
.
toBN
(
tx
.
gas
).
mul
(
Web3
.
utils
.
toBN
(
Web3
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
txFeeText
=
' '
+
executionContext
.
web3
()
.
utils
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
txFeeText
=
' '
+
Web3
.
utils
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
priceStatus
=
true
priceStatus
=
true
}
catch
(
e
)
{
}
catch
(
e
)
{
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
...
@@ -164,7 +165,7 @@ class DropdownLogic {
...
@@ -164,7 +165,7 @@ class DropdownLogic {
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
()
.
utils
.
fromWei
(
gasPrice
.
toString
(
10
),
'gwei'
)
var
gasPriceValue
=
Web3
.
utils
.
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
)
...
@@ -180,7 +181,7 @@ class DropdownLogic {
...
@@ -180,7 +181,7 @@ class DropdownLogic {
if
(
!
content
.
gasPriceStatus
)
{
if
(
!
content
.
gasPriceStatus
)
{
cancelCb
(
'Given gas price is not correct'
)
cancelCb
(
'Given gas price is not correct'
)
}
else
{
}
else
{
var
gasPrice
=
executionContext
.
web3
()
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
var
gasPrice
=
Web3
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
continueTxExecution
(
gasPrice
)
continueTxExecution
(
gasPrice
)
}
}
}},
{
}},
{
...
...
src/app/tabs/runTab/model/recorder.js
View file @
e448ded4
...
@@ -7,6 +7,7 @@ var format = remixLib.execution.txFormat
...
@@ -7,6 +7,7 @@ var format = remixLib.execution.txFormat
var
txHelper
=
remixLib
.
execution
.
txHelper
var
txHelper
=
remixLib
.
execution
.
txHelper
var
typeConversion
=
remixLib
.
execution
.
typeConversion
var
typeConversion
=
remixLib
.
execution
.
typeConversion
var
helper
=
require
(
'../../../../lib/helper.js'
)
var
helper
=
require
(
'../../../../lib/helper.js'
)
var
Web3
=
require
(
'web3'
)
/**
/**
* Record transaction as long as the user create them.
* Record transaction as long as the user create them.
...
@@ -315,7 +316,7 @@ class Recorder {
...
@@ -315,7 +316,7 @@ class Recorder {
if
(
network
.
name
!==
'Main'
)
{
if
(
network
.
name
!==
'Main'
)
{
return
continueTxExecution
(
null
)
return
continueTxExecution
(
null
)
}
}
var
amount
=
executionContext
.
web3
()
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
var
amount
=
Web3
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
// TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily
// TODO: there is still a UI dependency to remove here, it's still too coupled at this point to remove easily
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
this
.
recorder
,
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
this
.
recorder
,
...
@@ -324,8 +325,8 @@ class Recorder {
...
@@ -324,8 +325,8 @@ class Recorder {
// 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
().
utils
.
toBN
(
tx
.
gas
).
mul
(
executionContext
.
web3
().
utils
.
toBN
(
executionContext
.
web3
()
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
var
fee
=
Web3
.
utils
.
toBN
(
tx
.
gas
).
mul
(
Web3
.
utils
.
toBN
(
Web3
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
txFeeText
=
' '
+
executionContext
.
web3
()
.
utils
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
txFeeText
=
' '
+
Web3
.
utils
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
priceStatus
=
true
priceStatus
=
true
}
catch
(
e
)
{
}
catch
(
e
)
{
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
...
@@ -340,7 +341,7 @@ class Recorder {
...
@@ -340,7 +341,7 @@ class Recorder {
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
()
.
utils
.
fromWei
(
gasPrice
.
toString
(
10
),
'gwei'
)
var
gasPriceValue
=
Web3
.
utils
.
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
)
...
@@ -356,7 +357,7 @@ class Recorder {
...
@@ -356,7 +357,7 @@ class Recorder {
if
(
!
content
.
gasPriceStatus
)
{
if
(
!
content
.
gasPriceStatus
)
{
cancelCb
(
'Given gas price is not correct'
)
cancelCb
(
'Given gas price is not correct'
)
}
else
{
}
else
{
var
gasPrice
=
executionContext
.
web3
()
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
var
gasPrice
=
Web3
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
continueTxExecution
(
gasPrice
)
continueTxExecution
(
gasPrice
)
}
}
}},
{
}},
{
...
...
src/app/tabs/runTab/model/settings.js
View file @
e448ded4
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
Personal
=
require
(
'web3-eth-personal'
)
var
Personal
=
require
(
'web3-eth-personal'
)
var
remixLib
=
require
(
'remix-lib'
)
var
remixLib
=
require
(
'remix-lib'
)
var
Web3
=
require
(
'web3'
)
const
addTooltip
=
require
(
'../../../ui/tooltip'
)
const
addTooltip
=
require
(
'../../../ui/tooltip'
)
var
EventManager
=
remixLib
.
EventManager
var
EventManager
=
remixLib
.
EventManager
var
executionContext
=
remixLib
.
execution
.
executionContext
var
executionContext
=
remixLib
.
execution
.
executionContext
...
@@ -95,7 +96,7 @@ class Settings {
...
@@ -95,7 +96,7 @@ class Settings {
return
return
}
}
if
(
isInjected
)
{
if
(
isInjected
)
{
const
hashedMsg
=
executionContext
.
web3
()
.
sha3
(
message
)
const
hashedMsg
=
Web3
.
utils
.
sha3
(
message
)
try
{
try
{
addTooltip
(
'Please check your provider to approve'
)
addTooltip
(
'Please check your provider to approve'
)
executionContext
.
web3
().
eth
.
sign
(
account
,
hashedMsg
,
(
error
,
signedData
)
=>
{
executionContext
.
web3
().
eth
.
sign
(
account
,
hashedMsg
,
(
error
,
signedData
)
=>
{
...
@@ -107,7 +108,7 @@ class Settings {
...
@@ -107,7 +108,7 @@ class Settings {
return
return
}
}
const
hashedMsg
=
executionContext
.
web3
()
.
sha3
(
message
)
const
hashedMsg
=
Web3
.
utils
.
sha3
(
message
)
try
{
try
{
var
personal
=
new
Personal
(
executionContext
.
web3
().
currentProvider
)
var
personal
=
new
Personal
(
executionContext
.
web3
().
currentProvider
)
personal
.
sign
(
hashedMsg
,
account
,
passphrase
,
(
error
,
signedData
)
=>
{
personal
.
sign
(
hashedMsg
,
account
,
passphrase
,
(
error
,
signedData
)
=>
{
...
...
src/app/udapp/run-tab.js
View file @
e448ded4
...
@@ -4,6 +4,7 @@ import * as packageJson from '../../../package.json'
...
@@ -4,6 +4,7 @@ import * as packageJson from '../../../package.json'
const
$
=
require
(
'jquery'
)
const
$
=
require
(
'jquery'
)
const
yo
=
require
(
'yo-yo'
)
const
yo
=
require
(
'yo-yo'
)
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
const
ethJSUtil
=
require
(
'ethereumjs-util'
)
const
Web3
=
require
(
'web3'
)
const
EventManager
=
require
(
'../../lib/events'
)
const
EventManager
=
require
(
'../../lib/events'
)
const
Card
=
require
(
'../ui/card'
)
const
Card
=
require
(
'../ui/card'
)
...
@@ -63,7 +64,7 @@ export class RunTab extends LibraryPlugin {
...
@@ -63,7 +64,7 @@ export class RunTab extends LibraryPlugin {
if
([
'ether'
,
'finney'
,
'gwei'
,
'wei'
].
indexOf
(
selectedUnit
)
>=
0
)
{
if
([
'ether'
,
'finney'
,
'gwei'
,
'wei'
].
indexOf
(
selectedUnit
)
>=
0
)
{
unit
=
selectedUnit
unit
=
selectedUnit
}
}
cb
(
null
,
executionContext
.
web3
()
.
utils
.
toWei
(
number
,
unit
))
cb
(
null
,
Web3
.
utils
.
toWei
(
number
,
unit
))
}
catch
(
e
)
{
}
catch
(
e
)
{
cb
(
e
)
cb
(
e
)
}
}
...
...
src/app/ui/universal-dapp-ui.js
View file @
e448ded4
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
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'
)
...
@@ -163,15 +164,15 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -163,15 +164,15 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
if
(
network
.
name
!==
'Main'
)
{
if
(
network
.
name
!==
'Main'
)
{
return
continueTxExecution
(
null
)
return
continueTxExecution
(
null
)
}
}
var
amount
=
executionContext
.
web3
()
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
var
amount
=
Web3
.
utils
.
fromWei
(
typeConversion
.
toInt
(
tx
.
value
),
'ether'
)
var
content
=
confirmDialog
(
tx
,
amount
,
gasEstimation
,
self
.
udapp
,
var
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
().
utils
.
toBN
(
tx
.
gas
).
mul
(
executionContext
.
web3
().
utils
.
toBN
(
executionContext
.
web3
()
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
var
fee
=
Web3
.
utils
.
toBN
(
tx
.
gas
).
mul
(
Web3
.
utils
.
toBN
(
Web3
.
utils
.
toWei
(
gasPrice
.
toString
(
10
),
'gwei'
)))
txFeeText
=
' '
+
executionContext
.
web3
()
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
txFeeText
=
' '
+
Web3
.
utils
.
fromWei
(
fee
.
toString
(
10
),
'ether'
)
+
' Ether'
priceStatus
=
true
priceStatus
=
true
}
catch
(
e
)
{
}
catch
(
e
)
{
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
txFeeText
=
' Please fix this issue before sending any transaction. '
+
e
.
message
...
@@ -186,7 +187,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -186,7 +187,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
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
()
.
utils
.
fromWei
(
gasPrice
.
toString
(
10
),
'gwei'
)
var
gasPriceValue
=
Web3
.
utils
.
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
)
...
@@ -207,7 +208,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
...
@@ -207,7 +208,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
if
(
!
content
.
gasPriceStatus
)
{
if
(
!
content
.
gasPriceStatus
)
{
cancelCb
(
'Given gas price is not correct'
)
cancelCb
(
'Given gas price is not correct'
)
}
else
{
}
else
{
var
gasPrice
=
executionContext
.
web3
()
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
var
gasPrice
=
Web3
.
utils
.
toWei
(
content
.
querySelector
(
'#gasprice'
).
value
,
'gwei'
)
continueTxExecution
(
gasPrice
)
continueTxExecution
(
gasPrice
)
}
}
}},
{
}},
{
...
...
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