|
|
@ -3,6 +3,7 @@ import { bufferToHex } from '@ethereumjs/util' |
|
|
|
import { hash } from '@remix-project/remix-lib' |
|
|
|
import { hash } from '@remix-project/remix-lib' |
|
|
|
import { TEMPLATE_METADATA, TEMPLATE_NAMES } from '../utils/constants' |
|
|
|
import { TEMPLATE_METADATA, TEMPLATE_NAMES } from '../utils/constants' |
|
|
|
import { TemplateType } from '../utils/types' |
|
|
|
import { TemplateType } from '../utils/types' |
|
|
|
|
|
|
|
import IpfsHttpClient from 'ipfs-http-client' |
|
|
|
import axios, { AxiosResponse } from 'axios' |
|
|
|
import axios, { AxiosResponse } from 'axios' |
|
|
|
import { |
|
|
|
import { |
|
|
|
addInputFieldSuccess, |
|
|
|
addInputFieldSuccess, |
|
|
@ -234,6 +235,7 @@ export const createWorkspaceTemplate = async (workspaceName: string, template: W |
|
|
|
export type UrlParametersType = { |
|
|
|
export type UrlParametersType = { |
|
|
|
gist: string |
|
|
|
gist: string |
|
|
|
code: string |
|
|
|
code: string |
|
|
|
|
|
|
|
shareCode: string |
|
|
|
url: string |
|
|
|
url: string |
|
|
|
language: string |
|
|
|
language: string |
|
|
|
} |
|
|
|
} |
|
|
@ -257,6 +259,31 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe |
|
|
|
content = atob(decodeURIComponent(params.code)) |
|
|
|
content = atob(decodeURIComponent(params.code)) |
|
|
|
await workspaceProvider.set(path, content) |
|
|
|
await workspaceProvider.set(path, content) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (params.shareCode) { |
|
|
|
|
|
|
|
console.log('inside params.shareCode------>', params.shareCode) |
|
|
|
|
|
|
|
const host = '127.0.0.1' |
|
|
|
|
|
|
|
const port = 5001 |
|
|
|
|
|
|
|
const protocol = 'http' |
|
|
|
|
|
|
|
// const projectId = ''
|
|
|
|
|
|
|
|
// const projectSecret = ''
|
|
|
|
|
|
|
|
// const auth = 'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ipfs = IpfsHttpClient({ port, host, protocol |
|
|
|
|
|
|
|
, headers: { |
|
|
|
|
|
|
|
// authorization: auth
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
const hashed = bufferToHex(hash.keccakFromString(params.shareCode)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path = 'contract-' + hashed.replace('0x', '').substring(0, 10) + (params.language && params.language.toLowerCase() === 'yul' ? '.yul' : '.sol') |
|
|
|
|
|
|
|
const fileData = ipfs.get(params.shareCode) |
|
|
|
|
|
|
|
for await (const file of fileData) { |
|
|
|
|
|
|
|
const fileContent = [] |
|
|
|
|
|
|
|
for await (const chunk of file.content) fileContent.push(chunk) |
|
|
|
|
|
|
|
content = Buffer.concat(fileContent).toString() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await 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) |
|
|
|
|
|
|
|
|
|
|
|