|
|
@ -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() |
|
|
@ -81,29 +83,39 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp |
|
|
|
|
|
|
|
|
|
|
|
switch (template) { |
|
|
|
switch (template) { |
|
|
|
case 'code-template': |
|
|
|
case 'code-template': |
|
|
|
// creates a new workspace code-sample and loads code from url params.
|
|
|
|
// creates a new workspace code-sample and loads code from url params.
|
|
|
|
try { |
|
|
|
try { |
|
|
|
let path = ''; let content = '' |
|
|
|
let path = ''; let content = '' |
|
|
|
|
|
|
|
|
|
|
|
if (params.code) { |
|
|
|
if (params.code) { |
|
|
|
const hash = bufferToHex(keccakFromString(params.code)) |
|
|
|
const hash = bufferToHex(keccakFromString(params.code)) |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error(e) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break |
|
|
|
return path |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error(e) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
case 'gist-template': |
|
|
|
case 'gist-template': |
|
|
|
// creates a new workspace gist-sample and get the file from gist
|
|
|
|
// creates a new workspace gist-sample and get the file from gist
|
|
|
|