@ -8,7 +8,6 @@ import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin
import { QueryParams } from '@remix-project/remix-lib'
import { QueryParams } from '@remix-project/remix-lib'
import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line
import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line
import JSZip from 'jszip'
import JSZip from 'jszip'
import axios , { AxiosResponse } from 'axios'
export * from './events'
export * from './events'
export * from './workspace'
export * from './workspace'
@ -21,7 +20,8 @@ let plugin, dispatch: React.Dispatch<any>
export type UrlParametersType = {
export type UrlParametersType = {
gist : string ,
gist : string ,
code : string ,
code : string ,
url : string
url : string ,
address : string
}
}
const basicWorkspaceInit = async ( workspaces : { name : string ; isGitRepo : boolean ; } [ ] , workspaceProvider ) = > {
const basicWorkspaceInit = async ( workspaces : { name : string ; isGitRepo : boolean ; } [ ] , workspaceProvider ) = > {
@ -63,10 +63,9 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
dispatch ( setCurrentWorkspace ( { name : 'code-sample' , isGitRepo : false } ) )
dispatch ( setCurrentWorkspace ( { name : 'code-sample' , isGitRepo : false } ) )
const filePath = await loadWorkspacePreset ( 'code-template' )
const filePath = await loadWorkspacePreset ( 'code-template' )
plugin . on ( 'editor' , 'editorMounted' , async ( ) = > await plugin . fileManager . openFile ( filePath ) )
plugin . on ( 'editor' , 'editorMounted' , async ( ) = > await plugin . fileManager . openFile ( filePath ) )
} else if ( window . location . pathname && window . location . pathname !== '/' ) {
} else if ( params . address ) {
let route = window . location . pathname
if ( params . address . startsWith ( '0x' ) && params . address . length === 42 ) {
if ( route . startsWith ( '/address/0x' ) && route . length === 51 ) {
const contractAddress = params . address
const contractAddress = route . split ( '/' ) [ 2 ]
plugin . call ( 'notification' , 'toast' , ` Looking for contract(s) verified on different networks of Etherscan for contract address ${ contractAddress } ..... ` )
plugin . call ( 'notification' , 'toast' , ` Looking for contract(s) verified on different networks of Etherscan for contract address ${ contractAddress } ..... ` )
let data
let data
let count = 0
let count = 0
@ -109,23 +108,6 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
} catch ( error ) {
} catch ( error ) {
await basicWorkspaceInit ( workspaces , workspaceProvider )
await basicWorkspaceInit ( workspaces , workspaceProvider )
}
}
} else if ( route . endsWith ( '.sol' ) ) {
if ( route . includes ( 'blob' ) ) route = route . replace ( '/blob' , '' )
let response : AxiosResponse
try {
response = await axios . get ( ` https://raw.githubusercontent.com ${ route } ` )
} catch ( error ) {
plugin . call ( 'notification' , 'toast' , ` cound not find ${ route } on GitHub ` )
await basicWorkspaceInit ( workspaces , workspaceProvider )
}
if ( response && response . status === 200 ) {
const content = response . data
await createWorkspaceTemplate ( 'github-code-sample' , 'code-template' )
plugin . setWorkspace ( { name : 'github-code-sample' , isLocalhost : false } )
dispatch ( setCurrentWorkspace ( { name : 'github-code-sample' , isGitRepo : false } ) )
await workspaceProvider . set ( route , content )
plugin . on ( 'editor' , 'editorMounted' , async ( ) = > await plugin . fileManager . openFile ( route ) )
} else await basicWorkspaceInit ( workspaces , workspaceProvider )
} else await basicWorkspaceInit ( workspaces , workspaceProvider )
} else await basicWorkspaceInit ( workspaces , workspaceProvider )
} else if ( localStorage . getItem ( "currentWorkspace" ) ) {
} else if ( localStorage . getItem ( "currentWorkspace" ) ) {
const index = workspaces . findIndex ( element = > element . name == localStorage . getItem ( "currentWorkspace" ) )
const index = workspaces . findIndex ( element = > element . name == localStorage . getItem ( "currentWorkspace" ) )