From 5ed9bb4d46881e4c61300a85f9fd7158f0197a5d Mon Sep 17 00:00:00 2001 From: yann300 Date: Sun, 26 Apr 2020 00:09:13 +0200 Subject: [PATCH] activate source-verifier plugin & try/catch --- .../compiler-sourceVerifier-fetchAndCompile.js | 10 ++++++++-- src/app/tabs/debugger-tab.js | 5 +++++ src/remixAppManager.js | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js b/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js index d5a933cbbf..6a7dceaad3 100644 --- a/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js +++ b/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js @@ -75,8 +75,14 @@ export default class FetchAndCompile extends Plugin { let name = network.name.toLowerCase() name === 'main' ? 'mainnet' : name // source-verifier api expect "mainnet" and not "main" - await this.call('manager', 'activatePlugin', 'source-verification') - const data = await this.call('source-verification', 'fetch', contractAddress, name.toLowerCase()) + let data + try { + data = await this.call('source-verification', 'fetch', contractAddress, name.toLowerCase()) + } catch (e) { + setTimeout(_ => this.emit('sourceVerificationNotAvailable'), 0) + this.unresolvedAddresses.push(contractAddress) + return localCompilation() + } if (!data || !data.metadata) { setTimeout(_ => this.emit('notFound', contractAddress), 0) this.unresolvedAddresses.push(contractAddress) diff --git a/src/app/tabs/debugger-tab.js b/src/app/tabs/debugger-tab.js index f25b13e1c6..c5bccd87a6 100644 --- a/src/app/tabs/debugger-tab.js +++ b/src/app/tabs/debugger-tab.js @@ -50,11 +50,16 @@ class DebuggerTab extends ViewPlugin { toaster(yo`
Using compilation result from Solidity module
`) }) + this.on('fetchAndCompile', 'sourceVerificationNotAvailable', () => { + toaster(yo`
Source verification plugin not activated or not available. continuing without source code debugging.
`) + }) + this.debuggerUI = new DebuggerUI( this.el.querySelector('#debugger'), this.blockchain, adddress => this.call('fetchAndCompile', 'resolve', adddress, '.debug', this.blockchain.web3())) + this.call('manager', 'activatePlugin', 'source-verification') // this.call('manager', 'activatePlugin', 'udapp') return this.el diff --git a/src/remixAppManager.js b/src/remixAppManager.js index d94fd6b1dd..9d008ff582 100644 --- a/src/remixAppManager.js +++ b/src/remixAppManager.js @@ -15,7 +15,7 @@ export function isNative (name) { } export function canActivate (name) { - return ['manager'].includes(name) + return ['manager', 'debugger'].includes(name) } export class RemixAppManager extends PluginManager {