From cb94a6b81ef401fff4407c2ad5c2c79adb1dd1f8 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 15 Jun 2022 14:56:30 +0530 Subject: [PATCH] detect etherscan route --- apps/remix-ide/src/app/tabs/theme-module.js | 3 ++- libs/remix-core-plugin/src/index.ts | 1 + libs/remix-ui/workspace/src/lib/actions/index.ts | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/theme-module.js b/apps/remix-ide/src/app/tabs/theme-module.js index 2fd9e92e1a..2711fb0429 100644 --- a/apps/remix-ide/src/app/tabs/theme-module.js +++ b/apps/remix-ide/src/app/tabs/theme-module.js @@ -37,7 +37,8 @@ export class ThemeModule extends Plugin { themes.map((theme) => { this.themes[theme.name.toLocaleLowerCase()] = { ...theme, - url: window.location.origin + window.location.pathname + theme.url + // url: window.location.origin + window.location.pathname + theme.url + url: window.location.origin + '/' + theme.url } }) this._paq = _paq diff --git a/libs/remix-core-plugin/src/index.ts b/libs/remix-core-plugin/src/index.ts index 420fe2e6d7..5018bca7e2 100644 --- a/libs/remix-core-plugin/src/index.ts +++ b/libs/remix-core-plugin/src/index.ts @@ -8,3 +8,4 @@ export { GistHandler } from './lib/gist-handler' export * from './types/contract' export { LinkLibraries, DeployLibraries } from './lib/link-libraries' export { OpenZeppelinProxy } from './lib/openzeppelin-proxy' +export { fetchContractFromEtherscan } from './lib/helpers/fetch-etherscan' diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 81566828ac..5b6cba7e62 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -6,6 +6,7 @@ import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryR import { listenOnPluginEvents, listenOnProviderEvents } from './events' import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin } from './workspace' import { QueryParams } from '@remix-project/remix-lib' +import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line import JSZip from 'jszip' export * from './events' @@ -31,7 +32,6 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const localhostProvider = filePanelPlugin.fileProviders.localhost const params = queryParams.get() as UrlParametersType const workspaces = await getWorkspaces() || [] - dispatch(setWorkspaces(workspaces)) if (params.gist) { await createWorkspaceTemplate('gist-sample', 'gist-template') @@ -44,7 +44,13 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. dispatch(setCurrentWorkspace('code-sample')) const filePath = await loadWorkspacePreset('code-template') plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) - } else { + } else if (window.location.pathname && window.location.pathname !== '/') { + const route = window.location.pathname + if (route.startsWith('/address/0x') && route.length === 51) { + console.log('this is an etherscan url') + } + } + else { if (workspaces.length === 0) { await createWorkspaceTemplate('default_workspace', 'remixDefault') plugin.setWorkspace({ name: 'default_workspace', isLocalhost: false })