Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ethereum/remix-project in…
Browse files Browse the repository at this point in the history
…to desktop-master-git
  • Loading branch information
bunsenstraat committed Jul 31, 2024
2 parents dc436b0 + 87b366a commit 5fe967e
Show file tree
Hide file tree
Showing 198 changed files with 3,271 additions and 1,304 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-reminder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
freeze-date: '2024-07-15T18:00:00Z'
freeze-date: '2024-08-12T18:00:00Z'
2 changes: 2 additions & 0 deletions apps/etherscan/src/app/utils/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const scanAPIurls = {
59144: 'https://api.lineascan.build/api',
8453: 'https://api.basescan.org/api',
534352: 'https://api.scrollscan.com/api',
1116: 'https://openapi.coredao.org/api',

// all testnet
17000: 'https://api-holesky.etherscan.io/api',
Expand All @@ -39,4 +40,5 @@ export const scanAPIurls = {
1442: 'https://api-testnet-zkevm.polygonscan.com/api',
59140: 'https://api-testnet.lineascan.build/api',
534351: 'https://api-sepolia.scrollscan.com/api',
1115: 'https://api.test.btcs.network/api',
}
8 changes: 4 additions & 4 deletions apps/etherscan/src/app/views/CaptureKeyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const CaptureKeyView = () => {
const context = React.useContext(AppContext)

useEffect(() => {
if (!context.apiKey) setMsg('Please provide a 34-character API key to continue')
if (!context.apiKey) setMsg('Please provide a 34 or 32 character API key to continue')
}, [context.apiKey])

return (
Expand All @@ -24,14 +24,14 @@ export const CaptureKeyView = () => {
const errors = {} as any
if (!values.apiKey) {
errors.apiKey = 'Required'
} else if (values.apiKey.length !== 34) {
errors.apiKey = 'API key should be 34 characters long'
} else if (values.apiKey.length !== 34 && values.apiKey.length !== 32) {
errors.apiKey = 'API key should be 34 or 32 characters long'
}
return errors
}}
onSubmit={(values) => {
const apiKey = values.apiKey
if (apiKey.length === 34) {
if (apiKey.length === 34 || apiKey.length === 32) {
context.setAPIKey(values.apiKey)
navigate(location && location.state ? location.state : '/')
}
Expand Down
2 changes: 1 addition & 1 deletion apps/etherscan/src/app/views/VerifyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const VerifyView = ({apiKey, client, contracts, onVerifiedContract, netwo
type="button"
className="mr-2 mb-2 py-1 px-2 btn btn-secondary btn-block"
onClick={async () => {
etherscanScripts(client)
etherscanScripts({}, client)
}}
>
Generate Verification Scripts
Expand Down
8 changes: 5 additions & 3 deletions apps/learneth/src/components/BackButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ function BackButton({entity}: any) {
</li>
{isDetailPage && (
<li className="nav-item">
<Link className="btn" to={`/list?id=${entity.id}`} title="Tutorial menu" onClick={() => (window as any)._paq.push(['trackEvent', 'learneth', 'back_to_menu_step', entity && entity.name])}>
<i className="fas fa-bars" />
</Link>
<OverlayTrigger placement="right" overlay={<Tooltip id="tooltip-rightTutorialMenu">Tutorial menu</Tooltip>}>
<Link className="btn" to={`/list?id=${entity.id}`} onClick={() => (window as any)._paq.push(['trackEvent', 'learneth', 'back_to_menu_step', entity && entity.name])}>
<i className="fas fa-bars" />
</Link>
</OverlayTrigger>
</li>
)}
</ul>
Expand Down
90 changes: 61 additions & 29 deletions apps/learneth/src/pages/StepDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
import React, {useEffect} from 'react'
import {useLocation, useNavigate} from 'react-router-dom'
import React, { useEffect } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import Markdown from 'react-markdown'
import rehypeRaw from 'rehype-raw'
import BackButton from '../../components/BackButton'
import {useAppSelector, useAppDispatch} from '../../redux/hooks'
import { useAppSelector, useAppDispatch } from '../../redux/hooks'
import './index.scss'
import remixClient from '../../remix-client'

function StepDetailPage() {
const navigate = useNavigate()
const location = useLocation()
const dispatch = useAppDispatch()
const [clonedStep, setClonedStep] = React.useState(null)

const queryParams = new URLSearchParams(location.search)
const id = queryParams.get('id') as string
const stepId = Number(queryParams.get('stepId'))
const {
workshop: {detail, selectedId},
remixide: {errorLoadingFile, errors, success},
workshop: { detail, selectedId },
remixide: { errorLoadingFile, errors, success },
} = useAppSelector((state: any) => state)
const entity = detail[selectedId].entities[id]
const steps = entity.steps
const step = steps[stepId]
console.log(step)

useEffect(() => {
dispatch({
type: 'remixide/displayFile',
payload: step,
})
dispatch({
type: 'remixide/save',
payload: {errors: [], success: false},
setClonedStep(null)
const clonedStep = JSON.parse(JSON.stringify(step))
const loadFiles = async () => {
async function loadFile(step, fileType) {
if (step[fileType] && step[fileType].file && !step[fileType].content) {
clonedStep[fileType].content = (await remixClient.call('contentImport', 'resolve', step[fileType].file)).content;
}
}

const fileTypes = ['markdown', 'solidity', 'test', 'answer', 'js', 'vy'];
for (const fileType of fileTypes) {
await loadFile(step, fileType);
}
}
loadFiles().then(() => {

setClonedStep(clonedStep)
dispatch({
type: 'remixide/displayFile',
payload: clonedStep,
})
dispatch({
type: 'remixide/save',
payload: { errors: [], success: false },
})
window.scrollTo(0, 0)
})
window.scrollTo(0, 0)
}, [step])

useEffect(() => {
Expand All @@ -40,8 +60,20 @@ function StepDetailPage() {
}
}, [errors, success])

if (!clonedStep) {
return (<div className='pb-4'>
<div className="fixed-top">
<div className="bg-light">
<BackButton entity={entity} />
</div>
</div>
loading...
</div>
)
}

return (
<>
<div className='pb-4'>
<div className="fixed-top">
<div className="bg-light">
<BackButton entity={entity} />
Expand All @@ -51,13 +83,13 @@ function StepDetailPage() {
{errorLoadingFile ? (
<>
<div className="errorloadingspacer"></div>
<h1 className="pl-3 pr-3 pt-3 pb-1">{step.name}</h1>
<h1 className="pl-3 pr-3 pt-3 pb-1">{clonedStep.name}</h1>
<button
className="w-100nav-item rounded-0 nav-link btn btn-success test"
onClick={() => {
dispatch({
type: 'remixide/displayFile',
payload: step,
payload: clonedStep,
})
}}
>
Expand All @@ -68,13 +100,13 @@ function StepDetailPage() {
) : (
<>
<div className="menuspacer"></div>
<h1 className="pr-3 pl-3 pt-3 pb-1">{step.name}</h1>
<h1 className="pr-3 pl-3 pt-3 pb-1">{clonedStep.name}</h1>
</>
)}
<div className="container-fluid">
<Markdown rehypePlugins={[rehypeRaw]}>{step.markdown?.content}</Markdown>
<Markdown rehypePlugins={[rehypeRaw]}>{clonedStep.markdown?.content}</Markdown>
</div>
{step.test?.content ? (
{clonedStep.test?.content ? (
<>
<nav className="nav nav-pills nav-fill">
{errorLoadingFile ? (
Expand All @@ -83,7 +115,7 @@ function StepDetailPage() {
onClick={() => {
dispatch({
type: 'remixide/displayFile',
payload: step,
payload: clonedStep,
})
}}
>
Expand All @@ -98,19 +130,19 @@ function StepDetailPage() {
onClick={() => {
dispatch({
type: 'remixide/testStep',
payload: step,
payload: clonedStep,
})
}}
>
Check Answer
</button>
{step.answer?.content && (
{clonedStep.answer?.content && (
<button
className="nav-item rounded-0 nav-link btn btn-warning test"
onClick={() => {
dispatch({
type: 'remixide/showAnswer',
payload: step,
payload: clonedStep,
})
}}
>
Expand All @@ -130,13 +162,13 @@ function StepDetailPage() {
>
Next
</button>
{step.answer?.content && (
{clonedStep.answer?.content && (
<button
className="nav-item rounded-0 nav-link btn btn-warning test"
onClick={() => {
dispatch({
type: 'remixide/showAnswer',
payload: step,
payload: clonedStep,
})
}}
>
Expand Down Expand Up @@ -185,13 +217,13 @@ function StepDetailPage() {
) : (
<>
<nav className="nav nav-pills nav-fill">
{!errorLoadingFile && step.answer?.content && (
{!errorLoadingFile && clonedStep.answer?.content && (
<button
className="nav-item rounded-0 nav-link btn btn-warning test"
onClick={() => {
dispatch({
type: 'remixide/showAnswer',
payload: step,
payload: clonedStep,
})
}}
>
Expand Down Expand Up @@ -223,7 +255,7 @@ function StepDetailPage() {
)}
</>
)}
</>
</div>
)
}

Expand Down
5 changes: 0 additions & 5 deletions apps/learneth/src/redux/models/remixide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const Model: ModelType = {
const { detail, selectedId } = yield select((state) => state.workshop)

const workshop = detail[selectedId]
console.log('loading ', step, workshop)

path = `.learneth/${workshop.name}/${step.name}/${path}`
try {
Expand Down Expand Up @@ -138,14 +137,11 @@ const Model: ModelType = {
yield remixClient.call('fileManager', 'switchFile', `${path}`)
}

console.log('testing ', step.test.content)

path = getFilePath(step.test.file)
path = `.learneth/${workshop.name}/${step.name}/${path}`
yield remixClient.call('fileManager', 'setFile', path, step.test.content)

const result = yield remixClient.call('solidityUnitTesting', 'testFromPath', path)
console.log('result ', result);

if (!result) {
yield put({
Expand Down Expand Up @@ -196,7 +192,6 @@ const Model: ModelType = {
toast.info('loading answer into IDE')

try {
console.log('loading ', step)
const content = step.answer.content
let path = getFilePath(step.answer.file)

Expand Down
5 changes: 2 additions & 3 deletions apps/learneth/src/redux/models/workshop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Model: ModelType = {
},
effects: {
*init(_, { put }) {
const cache = localStorage.getItem('workshop.state')
const cache = null // don't use cache because remote might change

if (cache) {
const workshopState = JSON.parse(cache)
Expand Down Expand Up @@ -54,7 +54,6 @@ const Model: ModelType = {
const { list, detail } = yield select((state) => state.workshop)

const url = `${apiUrl}/clone/${encodeURIComponent(payload.name)}/${payload.branch}?${Math.random()}`
console.log('loading ', url)
const { data } = yield axios.get(url)
const repoId = `${payload.name}-${payload.branch}`

Expand Down Expand Up @@ -90,7 +89,7 @@ const Model: ModelType = {
const key = stepKeysWithFile[k]
if (step[key]) {
try {
step[key].content = (yield remixClient.call('contentImport', 'resolve', step[key].file)).content
step[key].content = null // we load this later
} catch (error) {
console.error(error)
}
Expand Down
2 changes: 0 additions & 2 deletions apps/learneth/src/remix-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class RemixClient extends PluginClient {
}

startTutorial(name: any, branch: any, id: any): void {
console.log('start tutorial', name, branch, id)
void router.navigate('/home')
store.dispatch({
type: 'workshop/loadRepo',
Expand All @@ -23,7 +22,6 @@ class RemixClient extends PluginClient {
}

addRepository(name: any, branch: any) {
console.log('add repo', name, branch)
void router.navigate('/home')
store.dispatch({
type: 'workshop/loadRepo',
Expand Down
34 changes: 34 additions & 0 deletions apps/remix-ide-e2e/src/commands/hideMetaMaskPopup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'

class HideMetaMaskPopup extends EventEmitter {
command(this: NightwatchBrowser) {
browser
.pause(5000)
.isVisible({
selector: 'button[data-testid="popover-close"]',
locateStrategy: 'css selector',
suppressNotFoundErrors: true,
timeout: 2000
}, (okVisible) => {
console.log('okVisible', okVisible)
if (!okVisible.value) {
console.log('popover not found')
} else {
console.log('popover found... closing')
browser.click('button[data-testid="popover-close"]')
}
})
.waitForElementNotPresent({
selector: 'button[data-testid="popover-close"]',
locateStrategy: 'css selector',
timeout: 2000
})
.perform((done) => {
done()
this.emit('complete')
})
}
}

module.exports = HideMetaMaskPopup
20 changes: 20 additions & 0 deletions apps/remix-ide-e2e/src/commands/pinGrid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'

class pinGrid extends EventEmitter {
command (this: NightwatchBrowser, provider: string, status: boolean): NightwatchBrowser {
this.api.useCss().waitForElementVisible('[data-id="settingsSelectEnvOptions"]')
.click('[data-id="settingsSelectEnvOptions"] button')
.waitForElementVisible(`[data-id="dropdown-item-another-chain"]`)
.click(`[data-id="dropdown-item-another-chain"]`)
.waitForElementVisible(`[data-id="${provider}-${status ? 'unpinned' : 'pinned'}"]`)
.click(`[data-id="${provider}-${status ? 'unpinned' : 'pinned'}"]`)
.perform((done) => {
done()
this.emit('complete')
})
return this
}
}

module.exports = pinGrid
Loading

0 comments on commit 5fe967e

Please sign in to comment.