Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor, abstract and remove dependencies on executionContext and udapp #2516

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
39ab660
extra confirmation dialog out of udapp-ui
iurimatias Dec 30, 2019
c565a3c
move udapp function call to blockchain module
iurimatias Dec 30, 2019
be993a8
remove udapp and executionContext from universal dapp ui
iurimatias Dec 31, 2019
4b9452d
convert universal dapp ui to a class and update syntax
iurimatias Dec 31, 2019
361f4c1
move reset and init methods to blockchain class
iurimatias Dec 31, 2019
bcf8241
remove udapp and execution context from run-tab
iurimatias Dec 31, 2019
b329fca
move udapp reference to blockchain class
iurimatias Dec 31, 2019
50eb3b5
replace executionContext for debugger with blockchain object
iurimatias Dec 31, 2019
294bc22
replace executionContext for network module with blockchain object
iurimatias Dec 31, 2019
35d3153
move executionContext initialization to blockchain object
iurimatias Dec 31, 2019
69c26fa
move blockchain class to its own folder
iurimatias Dec 31, 2019
2feff2d
move udapp from remix-lib back to remix-ide
iurimatias Dec 31, 2019
10977aa
listen to new transaction using blockchain abstraction instead of txl…
iurimatias Jan 1, 2020
ac48675
Revert "listen to new transaction using blockchain abstraction instea…
iurimatias Jan 1, 2020
febf820
replace web3 from wei with directly using web3 utils
iurimatias Jan 1, 2020
4c54ef1
remove unused methods from udapp
iurimatias Jan 2, 2020
6f10193
abstract udapp plugin so it maintains backwards compatibilify with th…
iurimatias Jan 2, 2020
5d2aa72
move udapp into blockchain module
iurimatias Jan 2, 2020
36b7309
update blockchain module syntax
iurimatias Jan 2, 2020
1f29cc0
refactor some unnecessary if/else conditions
iurimatias Jan 2, 2020
fd2bd33
remove duplicated methods
iurimatias Jan 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ var toolTip = require('./app/ui/tooltip')
var CompilerMetadata = require('./app/files/compiler-metadata')
var CompilerImport = require('./app/compiler/compiler-imports')

var executionContext = remixLib.execution.executionContext

const Blockchain = require('./app/tabs/runTab/model/blockchain.js')
const Blockchain = require('./blockchain/blockchain.js')
const PluginUDapp = require('./blockchain/pluginUDapp.js')

const PluginManagerComponent = require('./app/components/plugin-manager-component')
const CompilersArtefacts = require('./app/compiler/compiler-artefacts')
Expand All @@ -50,7 +49,6 @@ import { HiddenPanel } from './app/components/hidden-panel'
import { VerticalIcons } from './app/components/vertical-icons'
import { LandingPage } from './app/ui/landing-page/landing-page'
import { MainPanel } from './app/components/main-panel'
import { UniversalDApp } from 'remix-lib'

import migrateFileSystem from './migrateFileSystem'

Expand Down Expand Up @@ -225,9 +223,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
const fileManager = new FileManager(editor)
registry.put({api: fileManager, name: 'filemanager'})

// ----------------- universal dapp: run transaction, listen on transactions, decode events
const udapp = new UniversalDApp(registry.get('config').api, executionContext)
const blockchain = new Blockchain(executionContext, udapp)
const blockchain = new Blockchain(registry.get('config').api)
const pluginUdapp = new PluginUDapp(blockchain)

// ----------------- compilation metadata generation servive ----------------------------
const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api)
Expand All @@ -237,7 +234,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org

const {eventsDecoder, txlistener} = makeUdapp(blockchain, compilersArtefacts, (domEl) => mainview.getTerminal().logHtml(domEl))
// ----------------- network service (resolve network id / name) ----------------------------
const networkModule = new NetworkModule(executionContext)
const networkModule = new NetworkModule(blockchain)
// ----------------- convert offset to line/column service ----------------------------
var offsetToLineColumnConverter = new OffsetToLineColumnConverter()
registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'})
Expand Down Expand Up @@ -300,8 +297,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
)
const run = new RunTab(
blockchain,
udapp,
executionContext,
pluginUdapp,
registry.get('config').api,
registry.get('filemanager').api,
registry.get('editor').api,
Expand All @@ -311,7 +307,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
mainview
)
const analysis = new AnalysisTab(registry)
const debug = new DebuggerTab(executionContext)
const debug = new DebuggerTab(blockchain)
const test = new TestTab(
registry.get('filemanager').api,
filePanel,
Expand Down
6 changes: 3 additions & 3 deletions src/app/tabs/debugger-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const profile = {

class DebuggerTab extends ViewPlugin {

constructor (executionContext) {
constructor (blockchain) {
super(profile)
this.el = null
this.executionContext = executionContext
this.blockchain = blockchain
}

render () {
Expand All @@ -34,7 +34,7 @@ class DebuggerTab extends ViewPlugin {
<div class="${css.debuggerTabView}" id="debugView">
<div id="debugger" class="${css.debugger}"></div>
</div>`
this.debuggerUI = new DebuggerUI(this.el.querySelector('#debugger'), this.executionContext)
this.debuggerUI = new DebuggerUI(this.el.querySelector('#debugger'), this.blockchain)
return this.el
}

Expand Down
10 changes: 5 additions & 5 deletions src/app/tabs/debugger/debuggerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var css = csjs`

class DebuggerUI {

constructor (container, executionContext) {
constructor (container, blockchain) {
this.registry = globalRegistry
this.executionContext = executionContext
this.blockchain = blockchain
this.event = new EventManager()

this.isActive = false
Expand Down Expand Up @@ -105,13 +105,13 @@ class DebuggerUI {

getDebugWeb3 () {
return new Promise((resolve, reject) => {
this.executionContext.detectNetwork((error, network) => {
this.blockchain.detectNetwork((error, network) => {
let web3
if (error || !network) {
web3 = init.web3DebugNode(this.executionContext.web3())
web3 = init.web3DebugNode(this.blockchain.web3())
} else {
const webDebugNode = init.web3DebugNode(network.name)
web3 = !webDebugNode ? this.executionContext.web3() : webDebugNode
web3 = !webDebugNode ? this.blockchain.web3() : webDebugNode
}
init.extendWeb3(web3)
resolve(web3)
Expand Down
18 changes: 9 additions & 9 deletions src/app/tabs/network-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export const profile = {
// - methods: ['getNetworkProvider', 'getEndpoint', 'detectNetwork', 'addNetwork', 'removeNetwork']

export class NetworkModule extends Plugin {
constructor (executionContext) {
constructor (blockchain) {
super(profile)
this.executionContext = executionContext
this.blockchain = blockchain
// TODO: See with remix-lib to make sementic coherent
this.executionContext.event.register('contextChanged', (provider) => {
this.blockchain.event.register('contextChanged', (provider) => {
this.emit('providerChanged', provider)
})
/*
Expand All @@ -37,34 +37,34 @@ export class NetworkModule extends Plugin {

/** Return the current network provider (web3, vm, injected) */
getNetworkProvider () {
return this.executionContext.getProvider()
return this.blockchain.getProvider()
}

/** Return the current network */
detectNetwork () {
return new Promise((resolve, reject) => {
this.executionContext.detectNetwork((error, network) => {
this.blockchain.detectNetwork((error, network) => {
error ? reject(error) : resolve(network)
})
})
}

/** Return the url only if network provider is 'web3' */
getEndpoint () {
const provider = this.executionContext.getProvider()
const provider = this.blockchain.getProvider()
if (provider !== 'web3') {
throw new Error('no endpoint: current provider is either injected or vm')
}
return this.executionContext.web3().currentProvider.host
return this.blockchain.web3().currentProvider.host
}

/** Add a custom network to the list of available networks */
addNetwork (customNetwork) {
this.executionContext.addProvider(customNetwork)
this.blockchain.addProvider(customNetwork)
}

/** Remove a network to the list of availble networks */
removeNetwork (name) {
this.executionContext.removeProvider(name)
this.blockchain.removeProvider(name)
}
}
Loading