Skip to content

Commit

Permalink
Update workspace.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 authored and Aniket-Engg committed Aug 28, 2024
1 parent 3894da5 commit cd6f696
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/remix-ui/workspace/src/lib/actions/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,15 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
let content

if (params.code) {
_paq.push(['trackEvent', 'workspace', 'template', 'code-template-code-param'])
const hashed = bytesToHex(hash.keccakFromString(params.code))

path = 'contract-' + hashed.replace('0x', '').substring(0, 10) + (params.language && params.language.toLowerCase() === 'yul' ? '.yul' : '.sol')
content = atob(decodeURIComponent(params.code))
await workspaceProvider.set(path, content)
}
if (params.shareCode) {
_paq.push(['trackEvent', 'workspace', 'template', 'code-template-shareCode-param'])
const host = '127.0.0.1'
const port = 5001
const protocol = 'http'
Expand All @@ -303,6 +305,7 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
await workspaceProvider.set(path, content)
}
if (params.url) {
_paq.push(['trackEvent', 'workspace', 'template', 'code-template-url-param'])
const data = await plugin.call('contentImport', 'resolve', params.url)
path = data.cleanUrl
content = data.content
Expand All @@ -326,6 +329,7 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
}
if (params.ghfolder) {
try {
_paq.push(['trackEvent', 'workspace', 'template', 'code-template-ghfolder-param'])
const files = await plugin.call('contentImport', 'resolveGithubFolder', params.ghfolder)
for (const [path, content] of Object.entries(files)) {
await workspaceProvider.set(path, content)
Expand All @@ -344,6 +348,7 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
case 'gist-template':
// creates a new workspace gist-sample and get the file from gist
try {
_paq.push(['trackEvent', 'workspace', 'template', 'gist-template'])
const gistId = params.gist
const response: AxiosResponse = await axios.get(`https://api.github.com/gists/${gistId}`)
const data = response.data as { files: any }
Expand Down

0 comments on commit cd6f696

Please sign in to comment.