Merge branch 'master' into reset-error

pull/2093/head
David Disu 3 years ago committed by GitHub
commit a4be0bc2a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  2. 11
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -4,9 +4,11 @@ import axios, { AxiosResponse } from 'axios'
import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload' import { addInputFieldSuccess, createWorkspaceError, createWorkspaceRequest, createWorkspaceSuccess, displayNotification, fetchWorkspaceDirectoryError, fetchWorkspaceDirectoryRequest, fetchWorkspaceDirectorySuccess, hideNotification, setCurrentWorkspace, setDeleteWorkspace, setMode, setReadOnlyMode, setRenameWorkspace } from './payload'
import { checkSlash, checkSpecialChars } from '@remix-ui/helper' import { checkSlash, checkSpecialChars } from '@remix-ui/helper'
import { JSONStandardInput } from '../types'
import { examples } from '../templates/examples' import { examples } from '../templates/examples'
import { QueryParams } from '@remix-project/remix-lib' import { QueryParams } from '@remix-project/remix-lib'
const LOCALHOST = ' - connect to localhost - ' const LOCALHOST = ' - connect to localhost - '
const NO_WORKSPACE = ' - none - ' const NO_WORKSPACE = ' - none - '
const queryParams = new QueryParams() const queryParams = new QueryParams()
@ -90,14 +92,24 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp
path = 'contract-' + hash.replace('0x', '').substring(0, 10) + '.sol' path = 'contract-' + hash.replace('0x', '').substring(0, 10) + '.sol'
content = atob(params.code) content = atob(params.code)
await workspaceProvider.set(path, content) workspaceProvider.set(path, content)
} }
if (params.url) { if (params.url) {
const data = await plugin.call('contentImport', 'resolve', params.url) const data = await plugin.call('contentImport', 'resolve', params.url)
path = data.cleanUrl path = data.cleanUrl
content = data.content content = data.content
await workspaceProvider.set(path, content) if (content && typeof content === 'object') {
const standardInput = content as JSONStandardInput
if (standardInput.language && standardInput.language === "Solidity" && standardInput.sources) {
for (const [fname, source] of Object.entries(standardInput.sources)) {
await workspaceProvider.set(fname, source.content)
}
}
return Object.keys(standardInput.sources)[0]
} else {
workspaceProvider.set(path, content)
}
} }
return path return path
} catch (e) { } catch (e) {

@ -2,7 +2,16 @@ import React from 'react'
import { customAction } from '@remixproject/plugin-api/lib/file-system/file-panel' import { customAction } from '@remixproject/plugin-api/lib/file-system/file-panel'
export type action = { name: string, type?: Array<'folder' | 'gist' | 'file'>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean } export type action = { name: string, type?: Array<'folder' | 'gist' | 'file'>, path?: string[], extension?: string[], pattern?: string[], id: string, multiselect: boolean, label: string, sticky?: boolean }
export interface JSONStandardInput {
language: "Solidity";
settings?: any,
sources: {
[globalName: string]: {
keccak256?: string;
content: string;
},
};
}
export type MenuItems = action[] export type MenuItems = action[]
export interface WorkspaceProps { export interface WorkspaceProps {
plugin: { plugin: {

Loading…
Cancel
Save