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 - 2 #2582

Merged
merged 19 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ff4880e
extra confirmation dialog out of udapp-ui
iurimatias Dec 30, 2019
71a083e
move udapp function call to blockchain module
iurimatias Dec 30, 2019
57b2963
remove udapp and executionContext from universal dapp ui
iurimatias Dec 31, 2019
806e250
move reset and init methods to blockchain class
iurimatias Dec 31, 2019
04801f5
remove udapp and execution context from run-tab
iurimatias Dec 31, 2019
0821c23
move udapp reference to blockchain class
iurimatias Dec 31, 2019
a5160fc
replace executionContext for debugger with blockchain object
iurimatias Dec 31, 2019
72d97a3
replace executionContext for network module with blockchain object
iurimatias Dec 31, 2019
d07ff7b
move executionContext initialization to blockchain object
iurimatias Dec 31, 2019
3d426df
move blockchain class to its own folder
iurimatias Dec 31, 2019
2ac2b64
move udapp from remix-lib back to remix-ide
iurimatias Dec 31, 2019
a9e16b8
listen to new transaction using blockchain abstraction instead of txl…
iurimatias Jan 1, 2020
a827b6b
Revert "listen to new transaction using blockchain abstraction instea…
iurimatias Jan 1, 2020
20f39ed
replace web3 from wei with directly using web3 utils
iurimatias Jan 1, 2020
18cadab
remove unused methods from udapp
iurimatias Jan 2, 2020
1732e9e
abstract udapp plugin so it maintains backwards compatibilify with th…
iurimatias Jan 2, 2020
5169cfb
move udapp into blockchain module
iurimatias Jan 2, 2020
ed22d29
update blockchain module syntax
iurimatias Jan 2, 2020
1800813
fix missing ref
yann300 Feb 5, 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