sh ti ipfs takes only hash now

pull/3137/head^2
lianahus 2 years ago committed by Aniket
parent eb683d43af
commit 1e0a57797b
  1. 4
      libs/remix-ui/app/src/lib/remix-app/components/dragbar/dragbar.tsx
  2. 6
      libs/remix-ui/app/src/lib/remix-app/remix-app.tsx
  3. 1
      libs/remix-ui/home-tab/src/lib/components/homeTabFeaturedPlugins.tsx
  4. 32
      libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx
  5. 1
      libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx
  6. 3
      libs/remix-ui/publish-to-storage/src/lib/publishToIPFS.tsx
  7. 4
      libs/remix-ui/run-tab/src/lib/css/run-tab.css

@ -58,8 +58,9 @@ const DragBar = (props: IRemixDragBarUi) => {
return () => window.removeEventListener('resize', handleResize)
}, [])
function stopDrag(e: MouseEvent, data: any) {
function stopDrag(data: any) {
setDragState(false)
console.log("drag")
if (data.x < props.minWidth) {
setDragBarPosX(offset)
props.setHideStatus(true)
@ -70,7 +71,6 @@ const DragBar = (props: IRemixDragBarUi) => {
setDragBarPosX(offset + props.refObject.current.offsetWidth)
}, 300)
}
}
function startDrag() {

@ -1,4 +1,4 @@
import React, { useContext, useEffect, useRef, useState } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import './style/remix-app.css'
import { RemixUIMainPanel } from '@remix-ui/panel'
import MatomoDialog from './components/modals/matomo'
@ -8,7 +8,6 @@ import { AppProvider } from './context/provider'
import AppDialogs from './components/modals/dialogs'
import DialogViewPlugin from './components/modals/dialogViewPlugin'
import { AppContext } from './context/context'
import { RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel'
import { IntlProvider } from 'react-intl'
interface IRemixAppUi {
@ -83,11 +82,10 @@ const RemixApp = (props: IRemixAppUi) => {
<AppProvider value={value}>
<OriginWarning></OriginWarning>
<MatomoDialog hide={!appReady}></MatomoDialog>
<div className={`remixIDE ${appReady ? '' : 'd-none'}`} data-id="remixIDE">
<div id="icon-panel" data-id="remixIdeIconPanel" className="iconpanel bg-light">{props.app.menuicons.render()}</div>
<div ref={sidePanelRef} id="side-panel" data-id="remixIdeSidePanel" className={`sidepanel border-right border-left ${hideSidePanel ? 'd-none' : ''}`}>{props.app.sidePanel.render()}</div>
<DragBar resetTrigger={resetTrigger} maximiseTrigger={maximiseTrigger} minWidth={250} refObject={sidePanelRef} hidden={hideSidePanel} setHideStatus={setHideSidePanel}></DragBar>
<DragBar resetTrigger={resetTrigger} maximiseTrigger={maximiseTrigger} minWidth={290} refObject={sidePanelRef} hidden={hideSidePanel} setHideStatus={setHideSidePanel}></DragBar>
<div id="main-panel" data-id="remixIdeMainPanel" className='mainpanel'>
<RemixUIMainPanel Context={AppContext}></RemixUIMainPanel>
</div>

@ -46,7 +46,6 @@ function HomeTabFeaturedPlugins ({plugin}: HomeTabFeaturedPluginsProps) {
e.stopPropagation()
let nextSlide = 0
if (e.wheelDelta < 0) {
console.log("scroll")
nextSlide = carouselRef.current.state.currentSlide + 1;
if (Math.abs(carouselRef.current.state.transform) >= carouselRef.current.containerRef.current.scrollWidth - carouselRef.current.state.containerWidth) return
carouselRef.current.goToSlide(nextSlide)

@ -23,13 +23,13 @@ function HomeTabFile ({plugin}: HomeTabFileProps) {
const [state, setState] = useState<{
searchInput: string,
showModalDialog: boolean,
modalInfo: { title: string, loadItem: string, examples: Array<string> },
modalInfo: { title: string, loadItem: string, examples: Array<string>, prefix?: string },
importSource: string,
toasterMsg: string
}>({
searchInput: '',
showModalDialog: false,
modalInfo: { title: '', loadItem: '', examples: [] },
modalInfo: { title: '', loadItem: '', examples: [], prefix: '' },
importSource: '',
toasterMsg: ''
})
@ -42,8 +42,15 @@ function HomeTabFile ({plugin}: HomeTabFileProps) {
_paq.push(['trackEvent', 'hometab', 'filesSection', 'importFrom' + type])
const contentImport = plugin.contentImport
const workspace = plugin.fileManager.getProvider('workspace')
const startsWith = state.importSource.substring(0, 4)
if ((type === 'ipfs' || type === 'IPFS') && (startsWith !== 'ipfs' && startsWith !== "IPFS")) {
setState(prevState => {
return { ...prevState, importSource: startsWith + state.importSource}
})
}
contentImport.import(
state.importSource,
state.modalInfo.prefix + state.importSource,
(loadingMsg) => dispatch({ tooltip: loadingMsg }),
async (error, content, cleanUrl, type, url) => {
if (error) {
@ -93,9 +100,9 @@ function HomeTabFile ({plugin}: HomeTabFileProps) {
plugin.verticalIcons.select('filePanel')
}
const showFullMessage = (title: string, loadItem: string, examples: Array<string>) => {
const showFullMessage = (title: string, loadItem: string, examples: Array<string>, prefix = '') => {
setState(prevState => {
return { ...prevState, showModalDialog: true, modalInfo: { title: title, loadItem: loadItem, examples: examples } }
return { ...prevState, showModalDialog: true, modalInfo: { title: title, loadItem: loadItem, examples: examples, prefix } }
})
}
@ -126,7 +133,9 @@ function HomeTabFile ({plugin}: HomeTabFileProps) {
{ examples }
</div>
</> }
<input
<div className="d-flex flex-row">
{ state.modalInfo.prefix && <span className='text-nowrap align-self-center mr-2'>ipfs://</span> }
<input
ref={inputValue}
type='text'
name='prompt_text'
@ -140,6 +149,7 @@ function HomeTabFile ({plugin}: HomeTabFileProps) {
})
}}
/>
</div>
</div>
</ModalDialog>
<Toaster message={state.toasterMsg} />
@ -155,9 +165,15 @@ function HomeTabFile ({plugin}: HomeTabFileProps) {
<button className="btn p-2 border my-1" style={{width: 'fit-content'}} onClick={() => connectToLocalhost()}><FormattedMessage id='home.connectToLocalhost' defaultMessage='Connect to Localhost' /></button>
<label className="pt-2"><FormattedMessage id='home.loadFrom' defaultMessage='Load From' /></label>
<div className="d-flex">
<button className="btn p-2 border mr-2" data-id="landingPageImportFromGitHubButton" onClick={() => showFullMessage('GitHub', 'github URL', ['https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol', 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol'])}>GitHub</button>
<button
className="btn p-2 border mr-2"
data-id="landingPageImportFromGitHubButton"
onClick={() => showFullMessage('GitHub', 'github URL', ['https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol', 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol'])}
>
GitHub
</button>
<button className="btn p-2 border mr-2" data-id="landingPageImportFromGistButton" onClick={() => importFromGist()}>Gist</button>
<button className="btn p-2 border mr-2" onClick={() => showFullMessage('Ipfs', 'ipfs URL', ['ipfs://<ipfs-hash>'])}>IPFS</button>
<button className="btn p-2 border mr-2" onClick={() => showFullMessage('Ipfs', 'ipfs hash', ['ipfs://QmQQfBMkpDgmxKzYaoAtqfaybzfgGm9b2LWYyT56Chv6xH'], "ipfs://")}>IPFS</button>
<button className="btn p-2 border" onClick={() => showFullMessage('Https', 'http/https raw content', ['https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/ERC20.sol'])}>HTTPS</button>
</div>
</div>

@ -75,6 +75,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
try {
const result = await publishToIPFS(contract, api)
modal(`Published ${contract.name}'s Metadata and Sources`, publishMessage(result.uploaded))
console.log("ptot")
} catch (err) {
modal('IPFS Publish Failed', publishMessageFailed(storage, err.message))
}

@ -1,7 +1,5 @@
import IpfsHttpClient from 'ipfs-http-client'
let ipfsNodes = []
export const publishToIPFS = async (contract, api) => {
@ -93,7 +91,6 @@ export const publishToIPFS = async (contract, api) => {
try {
const result = await ipfsVerifiedPublish(metadataContent, '', api)
try {
contract.metadataHash = result.url.match('dweb:/ipfs/(.+)')[1]
} catch (e) {

@ -45,8 +45,6 @@
width: 164px;
min-width: 164px;
}
.udapp_col2_2 {
}
.udapp_select {
font-weight: normal;
width: 100%;
@ -314,7 +312,7 @@
.udapp_cActionsWrapper {
border-top-left-radius: 0;
border-bottom-left-radius: 0.25rem;
border-top-rightt-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0.25rem;
padding: 8px 10px 7px;
}

Loading…
Cancel
Save