add uniswap template

add_template_0
yann300 1 year ago
parent ee3b763534
commit 8e7e3e1937
  1. 1
      apps/remix-ide/src/app/tabs/locales/en/filePanel.json
  2. 14
      libs/remix-ui/home-tab/src/lib/components/homeTabGetStarted.tsx
  3. 11
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  4. 6
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  5. 2
      libs/remix-ui/workspace/src/lib/types/index.ts
  6. 10
      libs/remix-ui/workspace/src/lib/utils/constants.ts

@ -105,6 +105,7 @@
"filePanel.pausable": "Pausable",
"filePanel.semaphore": "Semaphore",
"filePanel.hashchecker": "Hash Checker",
"filePanel.breakthroughLabsUniswapv4Hooks": "Breakthrough-Labs Uniswapv4Hooks",
"filePanel.transparent": "Transparent",
"filePanel.initGitRepoTitle": "Check option to initialize workspace as a new git repository",
"filePanel.switchToBranchTitle1": "Checkout new branch from remote branch",

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, {useEffect, useRef, useContext} from 'react'
import {useIntl, FormattedMessage} from 'react-intl'
import {TEMPLATE_NAMES} from '@remix-ui/workspace'
import {TEMPLATE_NAMES,TEMPLATE_METADATA} from '@remix-ui/workspace'
import {ThemeContext} from '../themeContext'
import Carousel from 'react-multi-carousel'
import WorkspaceTemplate from './workspaceTemplate'
@ -59,12 +59,16 @@ function HomeTabGetStarted({plugin}: HomeTabGetStartedProps) {
const createWorkspace = async (templateName) => {
await plugin.appManager.activatePlugin('filePanel')
const timeStamp = Date.now()
let templateDisplayName = TEMPLATE_NAMES[templateName]
templateDisplayName = await plugin.call('filePanel', 'getAvailableWorkspaceName', templateDisplayName)
await plugin.call('filePanel', 'createWorkspace', templateDisplayName, templateName)
await plugin.call('filePanel', 'setWorkspace', templateDisplayName)
plugin.verticalIcons.select('filePanel')
const metadata = TEMPLATE_METADATA['breakthroughLabsUniswapv4Hooks']
if (metadata) {
plugin.call('dGitProvider', 'clone', {url: metadata.url, branch: metadata.branch}, templateDisplayName, true)
} else {
await plugin.call('filePanel', 'createWorkspace', templateDisplayName, templateName)
await plugin.call('filePanel', 'setWorkspace', templateDisplayName)
plugin.verticalIcons.select('filePanel')
}
_paq.push(['trackEvent', 'hometab', 'homeGetStarted', templateName])
}

@ -1,6 +1,7 @@
import React from 'react'
import { bufferToHex } from '@ethereumjs/util'
import { hash } from '@remix-project/remix-lib'
import { TEMPLATE_METADATA, TEMPLATE_NAMES } from '../utils/constants'
import axios, { AxiosResponse } from 'axios'
import {
addInputFieldSuccess,
@ -38,6 +39,7 @@ import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files
import { getUncommittedFiles } from '../utils/gitStatusFilter'
import { AppModal, ModalTypes } from '@remix-ui/app'
import { contractDeployerScripts, etherscanScripts } from '@remix-project/remix-ws-templates'
import { template } from 'lodash'
declare global {
interface Window {
@ -194,8 +196,13 @@ export const createWorkspaceTemplate = async (workspaceName: string, template: W
if (checkSpecialChars(workspaceName) || checkSlash(workspaceName)) throw new Error('special characters are not allowed')
if ((await workspaceExists(workspaceName)) && template === 'remixDefault') throw new Error('workspace already exists')
else {
const workspaceProvider = plugin.fileProviders.workspace
await workspaceProvider.createWorkspace(workspaceName)
const metadata = TEMPLATE_METADATA[template]
if (metadata) {
plugin.call('dGitProvider', 'clone', {url: metadata.url, branch: metadata.branch}, TEMPLATE_NAMES[template], true)
} else {
const workspaceProvider = plugin.fileProviders.workspace
await workspaceProvider.createWorkspace(workspaceName)
}
}
}

@ -754,8 +754,12 @@ export function Workspace() {
{intl.formatMessage({id: 'filePanel.hashchecker'})}
</option>
</optgroup>
<optgroup style={{fontSize: 'medium'}} label="Uniswap">
<option style={{fontSize: 'small'}} value="breakthroughLabsUniswapv4Hooks">
{intl.formatMessage({id: 'filePanel.breakthroughLabsUniswapv4Hooks'})}
</option>
</optgroup>
</select>
<div id="ozcustomization" data-id="ozCustomization" ref={displayOzCustomRef} style={{display: 'none'}} className="mb-2">
<label className="form-check-label d-block mb-2" style={{fontWeight: 'bolder'}}>
<FormattedMessage id="filePanel.customizeTemplate" />

@ -17,7 +17,7 @@ export interface JSONStandardInput {
}
}
export type MenuItems = action[]
export type WorkspaceTemplate = 'gist-template' | 'code-template' | 'remixDefault' | 'blank' | 'ozerc20' | 'zeroxErc20' | 'ozerc721' | 'playground' | 'semaphore' | 'hashchecker'
export type WorkspaceTemplate = 'gist-template' | 'code-template' | 'remixDefault' | 'blank' | 'ozerc20' | 'zeroxErc20' | 'ozerc721' | 'playground' | 'semaphore' | 'hashchecker' | 'breakthroughLabsUniswapv4Hooks'
export interface WorkspaceProps {
plugin: FilePanelType
}

@ -83,5 +83,13 @@ export const TEMPLATE_NAMES = {
'gnosisSafeMultisig': 'Gnosis Safe',
'playground': 'Playground',
'semaphore': 'Semaphore',
'hashchecker': 'Hash Checker'
'hashchecker': 'Hash Checker',
'breakthroughLabsUniswapv4Hooks': 'Breakthrough-Labs Uniswapv4Hooks'
}
export const TEMPLATE_METADATA = {
'breakthroughLabsUniswapv4Hooks': {
url: 'https://github.com/Breakthrough-Labs/Uniswapv4Hooks',
branch: 'foundry_pure'
}
}

Loading…
Cancel
Save