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
38c67e58
Commit
38c67e58
authored
Dec 14, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass executionContext as param instead of relying in a global var
parent
6436db7c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
33 deletions
+33
-33
app.js
src/app.js
+1
-1
dropdownlogic.js
src/app/tabs/runTab/model/dropdownlogic.js
+6
-6
recorder.js
src/app/tabs/runTab/model/recorder.js
+6
-6
settings.js
src/app/tabs/runTab/model/settings.js
+16
-16
make-udapp.js
src/app/udapp/make-udapp.js
+1
-1
run-tab.js
src/app/udapp/run-tab.js
+3
-3
No files found.
src/app.js
View file @
38c67e58
...
...
@@ -229,7 +229,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
const
compilersArtefacts
=
new
CompilersArtefacts
()
// store all the compilation results (key represent a compiler name)
registry
.
put
({
api
:
compilersArtefacts
,
name
:
'compilersartefacts'
})
// ----------------- universal dapp: run transaction, listen on transactions, decode events
const
udapp
=
new
UniversalDApp
(
registry
.
get
(
'config'
).
api
)
const
udapp
=
new
UniversalDApp
(
registry
.
get
(
'config'
).
api
,
executionContext
)
const
{
eventsDecoder
,
txlistener
}
=
makeUdapp
(
udapp
,
executionContext
,
compilersArtefacts
,
(
domEl
)
=>
mainview
.
getTerminal
().
logHtml
(
domEl
))
// ----------------- network service (resolve network id / name) ----------------------------
const
networkModule
=
new
NetworkModule
(
executionContext
)
...
...
src/app/tabs/runTab/model/dropdownlogic.js
View file @
38c67e58
...
...
@@ -2,7 +2,6 @@ var ethJSUtil = require('ethereumjs-util')
var
remixLib
=
require
(
'remix-lib'
)
var
txHelper
=
remixLib
.
execution
.
txHelper
var
txFormat
=
remixLib
.
execution
.
txFormat
var
executionContext
=
remixLib
.
execution
.
executionContext
var
typeConversion
=
remixLib
.
execution
.
typeConversion
var
txExecution
=
remixLib
.
execution
.
txExecution
var
CompilerAbstract
=
require
(
'../../../compiler/compiler-abstract'
)
...
...
@@ -10,8 +9,9 @@ var EventManager = remixLib.EventManager
var
Web3
=
require
(
'web3'
)
class
DropdownLogic
{
constructor
(
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
runView
)
{
constructor
(
executionContext
,
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
runView
)
{
this
.
compilersArtefacts
=
compilersArtefacts
this
.
executionContext
=
executionContext
this
.
config
=
config
this
.
editor
=
editor
this
.
udapp
=
udapp
...
...
@@ -121,11 +121,11 @@ class DropdownLogic {
}
getGasPrice
(
cb
)
{
return
executionContext
.
web3
().
eth
.
getGasPrice
(
cb
)
return
this
.
executionContext
.
web3
().
eth
.
getGasPrice
(
cb
)
}
isVM
()
{
return
executionContext
.
isVM
()
return
this
.
executionContext
.
isVM
()
}
// TODO: check if selectedContract and data can be joined
...
...
@@ -159,7 +159,7 @@ class DropdownLogic {
cb
(
txFeeText
,
priceStatus
)
},
(
cb
)
=>
{
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
this
.
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
var
warnMessage
=
' Please fix this issue before sending any transaction. '
if
(
error
)
{
return
cb
(
'Unable to retrieve the current network gas price.'
+
warnMessage
+
error
)
...
...
@@ -197,7 +197,7 @@ class DropdownLogic {
if
(
error
)
{
return
finalCb
(
`creation of
${
selectedContract
.
name
}
errored:
${
error
}
`
)
}
var
isVM
=
executionContext
.
isVM
()
var
isVM
=
this
.
executionContext
.
isVM
()
if
(
isVM
)
{
var
vmError
=
txExecution
.
checkVMError
(
txResult
)
if
(
vmError
.
error
)
{
...
...
src/app/tabs/runTab/model/recorder.js
View file @
38c67e58
...
...
@@ -2,7 +2,6 @@ var async = require('async')
var
ethutil
=
require
(
'ethereumjs-util'
)
var
remixLib
=
require
(
'remix-lib'
)
var
EventManager
=
remixLib
.
EventManager
var
executionContext
=
remixLib
.
execution
.
executionContext
var
format
=
remixLib
.
execution
.
txFormat
var
txHelper
=
remixLib
.
execution
.
txHelper
var
typeConversion
=
remixLib
.
execution
.
typeConversion
...
...
@@ -15,9 +14,10 @@ var Web3 = require('web3')
*
*/
class
Recorder
{
constructor
(
udapp
,
fileManager
,
config
)
{
constructor
(
executionContext
,
udapp
,
fileManager
,
config
)
{
var
self
=
this
self
.
event
=
new
EventManager
()
self
.
executionContext
=
executionContext
self
.
data
=
{
_listen
:
true
,
_replay
:
false
,
journal
:
[],
_createdContracts
:
{},
_createdContractsReverse
:
{},
_usedAccounts
:
{},
_abis
:
{},
_contractABIReferences
:
{},
_linkReferences
:
{}
}
this
.
udapp
=
udapp
this
.
fileManager
=
fileManager
...
...
@@ -74,7 +74,7 @@ class Recorder {
if
(
error
)
return
console
.
log
(
error
)
if
(
call
)
return
const
rawAddress
=
executionContext
.
isVM
()
?
txResult
.
result
.
createdAddress
:
txResult
.
result
.
contractAddress
const
rawAddress
=
this
.
executionContext
.
isVM
()
?
txResult
.
result
.
createdAddress
:
txResult
.
result
.
contractAddress
if
(
!
rawAddress
)
return
// not a contract creation
const
stringAddress
=
this
.
addressToString
(
rawAddress
)
const
address
=
ethutil
.
toChecksumAddress
(
stringAddress
)
...
...
@@ -82,7 +82,7 @@ class Recorder {
this
.
data
.
_createdContracts
[
address
]
=
timestamp
this
.
data
.
_createdContractsReverse
[
timestamp
]
=
address
})
executionContext
.
event
.
register
(
'contextChanged'
,
this
.
clearAll
.
bind
(
this
))
this
.
executionContext
.
event
.
register
(
'contextChanged'
,
this
.
clearAll
.
bind
(
this
))
this
.
event
.
register
(
'newTxRecorded'
,
(
count
)
=>
{
this
.
event
.
trigger
(
'recorderCountChange'
,
[
count
])
})
...
...
@@ -261,7 +261,7 @@ class Recorder {
console
.
error
(
err
)
logCallBack
(
err
+
'. Execution failed at '
+
index
)
}
else
{
const
rawAddress
=
executionContext
.
isVM
()
?
txResult
.
result
.
createdAddress
:
txResult
.
result
.
contractAddress
const
rawAddress
=
this
.
executionContext
.
isVM
()
?
txResult
.
result
.
createdAddress
:
txResult
.
result
.
contractAddress
if
(
rawAddress
)
{
const
stringAddress
=
self
.
addressToString
(
rawAddress
)
const
address
=
ethutil
.
toChecksumAddress
(
stringAddress
)
...
...
@@ -335,7 +335,7 @@ class Recorder {
cb
(
txFeeText
,
priceStatus
)
},
(
cb
)
=>
{
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
this
.
executionContext
.
web3
().
eth
.
getGasPrice
((
error
,
gasPrice
)
=>
{
var
warnMessage
=
' Please fix this issue before sending any transaction. '
if
(
error
)
{
return
cb
(
'Unable to retrieve the current network gas price.'
+
warnMessage
+
error
)
...
...
src/app/tabs/runTab/model/settings.js
View file @
38c67e58
...
...
@@ -4,11 +4,11 @@ var remixLib = require('remix-lib')
var
Web3
=
require
(
'web3'
)
const
addTooltip
=
require
(
'../../../ui/tooltip'
)
var
EventManager
=
remixLib
.
EventManager
var
executionContext
=
remixLib
.
execution
.
executionContext
class
Settings
{
constructor
(
udapp
)
{
constructor
(
executionContext
,
udapp
)
{
this
.
executionContext
=
executionContext
this
.
udapp
=
udapp
this
.
event
=
new
EventManager
()
...
...
@@ -16,15 +16,15 @@ class Settings {
this
.
event
.
trigger
(
'transactionExecuted'
,
[
error
,
from
,
to
,
data
,
lookupOnly
,
txResult
])
})
executionContext
.
event
.
register
(
'contextChanged'
,
(
context
,
silent
)
=>
{
this
.
executionContext
.
event
.
register
(
'contextChanged'
,
(
context
,
silent
)
=>
{
this
.
event
.
trigger
(
'contextChanged'
,
[
context
,
silent
])
})
executionContext
.
event
.
register
(
'addProvider'
,
(
network
)
=>
{
this
.
executionContext
.
event
.
register
(
'addProvider'
,
(
network
)
=>
{
this
.
event
.
trigger
(
'addProvider'
,
[
network
])
})
executionContext
.
event
.
register
(
'removeProvider'
,
(
name
)
=>
{
this
.
executionContext
.
event
.
register
(
'removeProvider'
,
(
name
)
=>
{
this
.
event
.
trigger
(
'removeProvider'
,
[
name
])
})
...
...
@@ -32,15 +32,15 @@ class Settings {
}
changeExecutionContext
(
context
,
confirmCb
,
infoCb
,
cb
)
{
return
executionContext
.
executionContextChange
(
context
,
null
,
confirmCb
,
infoCb
,
cb
)
return
this
.
executionContext
.
executionContextChange
(
context
,
null
,
confirmCb
,
infoCb
,
cb
)
}
setProviderFromEndpoint
(
target
,
context
,
cb
)
{
return
executionContext
.
setProviderFromEndpoint
(
target
,
context
,
cb
)
return
this
.
executionContext
.
setProviderFromEndpoint
(
target
,
context
,
cb
)
}
getProvider
()
{
return
executionContext
.
getProvider
()
return
this
.
executionContext
.
getProvider
()
}
getAccountBalanceForAddress
(
address
,
cb
)
{
...
...
@@ -50,7 +50,7 @@ class Settings {
updateNetwork
(
cb
)
{
this
.
networkcallid
++
((
callid
)
=>
{
executionContext
.
detectNetwork
((
err
,
{
id
,
name
}
=
{})
=>
{
this
.
executionContext
.
detectNetwork
((
err
,
{
id
,
name
}
=
{})
=>
{
if
(
this
.
networkcallid
>
callid
)
return
this
.
networkcallid
++
if
(
err
)
{
...
...
@@ -70,18 +70,18 @@ class Settings {
}
isWeb3Provider
()
{
var
isVM
=
executionContext
.
isVM
()
var
isInjected
=
executionContext
.
getProvider
()
===
'injected'
var
isVM
=
this
.
executionContext
.
isVM
()
var
isInjected
=
this
.
executionContext
.
getProvider
()
===
'injected'
return
(
!
isVM
&&
!
isInjected
)
}
isInjectedWeb3
()
{
return
executionContext
.
getProvider
()
===
'injected'
return
this
.
executionContext
.
getProvider
()
===
'injected'
}
signMessage
(
message
,
account
,
passphrase
,
cb
)
{
var
isVM
=
executionContext
.
isVM
()
var
isInjected
=
executionContext
.
getProvider
()
===
'injected'
var
isVM
=
this
.
executionContext
.
isVM
()
var
isInjected
=
this
.
executionContext
.
getProvider
()
===
'injected'
if
(
isVM
)
{
const
personalMsg
=
ethJSUtil
.
hashPersonalMessage
(
Buffer
.
from
(
message
))
...
...
@@ -99,7 +99,7 @@ class Settings {
const
hashedMsg
=
Web3
.
utils
.
sha3
(
message
)
try
{
addTooltip
(
'Please check your provider to approve'
)
executionContext
.
web3
().
eth
.
sign
(
account
,
hashedMsg
,
(
error
,
signedData
)
=>
{
this
.
executionContext
.
web3
().
eth
.
sign
(
account
,
hashedMsg
,
(
error
,
signedData
)
=>
{
cb
(
error
.
message
,
hashedMsg
,
signedData
)
})
}
catch
(
e
)
{
...
...
@@ -110,7 +110,7 @@ class Settings {
const
hashedMsg
=
Web3
.
utils
.
sha3
(
message
)
try
{
var
personal
=
new
Personal
(
executionContext
.
web3
().
currentProvider
)
var
personal
=
new
Personal
(
this
.
executionContext
.
web3
().
currentProvider
)
personal
.
sign
(
hashedMsg
,
account
,
passphrase
,
(
error
,
signedData
)
=>
{
cb
(
error
.
message
,
hashedMsg
,
signedData
)
})
...
...
src/app/udapp/make-udapp.js
View file @
38c67e58
...
...
@@ -28,7 +28,7 @@ export function makeUdapp (udapp, executionContext, compilersArtefacts, logHtmlC
},
event
:
{
udapp
:
udapp
.
event
}})
}}
,
executionContext
)
registry
.
put
({
api
:
txlistener
,
name
:
'txlistener'
})
udapp
.
startListening
(
txlistener
)
...
...
src/app/udapp/run-tab.js
View file @
38c67e58
...
...
@@ -122,7 +122,7 @@ export class RunTab extends LibraryPlugin {
}
renderSettings
(
udapp
)
{
var
settings
=
new
Settings
(
udapp
)
var
settings
=
new
Settings
(
this
.
executionContext
,
udapp
)
this
.
settingsUI
=
new
SettingsUI
(
settings
,
this
.
networkModule
)
this
.
settingsUI
.
event
.
register
(
'clearInstance'
,
()
=>
{
...
...
@@ -131,7 +131,7 @@ export class RunTab extends LibraryPlugin {
}
renderDropdown
(
udappUI
,
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
logCallback
)
{
const
dropdownLogic
=
new
DropdownLogic
(
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
this
)
const
dropdownLogic
=
new
DropdownLogic
(
this
.
executionContext
,
fileManager
,
compilersArtefacts
,
config
,
editor
,
udapp
,
filePanel
,
this
)
this
.
contractDropdownUI
=
new
ContractDropdownUI
(
dropdownLogic
,
logCallback
)
this
.
contractDropdownUI
.
event
.
register
(
'clearInstance'
,
()
=>
{
...
...
@@ -149,7 +149,7 @@ export class RunTab extends LibraryPlugin {
renderRecorder
(
udapp
,
udappUI
,
fileManager
,
config
,
logCallback
)
{
this
.
recorderCount
=
yo
`<span>0</span>`
const
recorder
=
new
Recorder
(
udapp
,
fileManager
,
config
)
const
recorder
=
new
Recorder
(
this
.
executionContext
,
udapp
,
fileManager
,
config
)
recorder
.
event
.
register
(
'recorderCountChange'
,
(
count
)
=>
{
this
.
recorderCount
.
innerText
=
count
})
...
...
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