From a5578b8ea8c209974385b9c54d4c84545a344594 Mon Sep 17 00:00:00 2001 From: David Disu Date: Mon, 12 Sep 2022 19:06:13 +0100 Subject: [PATCH 01/60] Add track workspace as new git repo --- .../workspace/src/lib/actions/workspace.ts | 1 + .../workspace/src/lib/contexts/index.ts | 2 +- .../src/lib/providers/FileSystemProvider.tsx | 4 ++-- .../workspace/src/lib/remix-ui-workspace.tsx | 22 ++++++++++++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 3ef203644e..083d9ce67c 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -53,6 +53,7 @@ export const createWorkspace = async (workspaceName: string, workspaceTemplateNa await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) await plugin.setWorkspaces(await getWorkspaces()) await plugin.workspaceCreated(workspaceName) + if (isGitRepo) await plugin.call('dGitProvider', 'init') if (!isEmpty) await loadWorkspacePreset(workspaceTemplateName) cb && cb(null, workspaceName) }).catch((error) => { diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 1724ca7c29..27f46391c4 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -9,7 +9,7 @@ export const FileSystemContext = createContext<{ dispatchFetchDirectory:(path: string) => Promise, dispatchAddInputField:(path: string, type: 'file' | 'folder') => Promise, dispatchRemoveInputField:(path: string) => Promise, - dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string) => Promise, + dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string, initGitRepo?: boolean) => Promise, toast: (toasterMsg: string) => void, dispatchFetchWorkspaceDirectory: (path: string) => Promise, dispatchSwitchToWorkspace: (name: string) => Promise, diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index 2d4010ca31..736811af00 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -45,8 +45,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await removeInputField(path) } - const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate) => { - await createWorkspace(workspaceName, workspaceTemplateName) + const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, initGitRepo?: boolean) => { + await createWorkspace(workspaceName, workspaceTemplateName, null, null, initGitRepo) } const dispatchFetchWorkspaceDirectory = async (path: string) => { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 91aa2c63ff..bdb9b9d1a3 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -19,6 +19,7 @@ export function Workspace () { const workspaceCreateInput = useRef() const workspaceCreateTemplateInput = useRef() const cloneUrlRef = useRef() + const initGitRepoRef = useRef() useEffect(() => { setCurrentWorkspace(localStorage.getItem('currentWorkspace') ? localStorage.getItem('currentWorkspace') : '') @@ -103,9 +104,10 @@ export function Workspace () { const workspaceName = workspaceCreateInput.current.value // @ts-ignore: Object is possibly 'null'. const workspaceTemplateName = workspaceCreateTemplateInput.current.value || 'remixDefault' + const initGitRepo = initGitRepoRef.current.checked try { - await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName) + await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName, initGitRepo) } catch (e) { global.modal('Create Workspace', e.message, 'OK', () => {}, '') console.error(e) @@ -168,6 +170,24 @@ export function Workspace () { +
+ {}} + /> + +
) } From 010dac5de27c2c1080285f891634eb37949f24c6 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 14 Sep 2022 14:37:31 +0200 Subject: [PATCH 02/60] updat text --- libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx index b15d0e52ed..793d2ea076 100644 --- a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx +++ b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx @@ -52,7 +52,7 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {
{to.displayName} :

{to.description || No description Provided}

{pluginMessage()} - { sensitiveCall ?

You are going to process a sensitive call. Please make sure you trust this plugin.

: '' } + { sensitiveCall ?

Make sure you trust this plugin before processing this call.

: '' }
{ !sensitiveCall &&
From e6299ebec916713d99bd93c18103200f39086125 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 14 Sep 2022 18:43:51 +0200 Subject: [PATCH 03/60] add imports to autodcomplete --- .../providers/completion/completionGlobals.ts | 268 +++++++++++++++++- .../src/lib/providers/completionProvider.ts | 131 +++++---- 2 files changed, 337 insertions(+), 62 deletions(-) diff --git a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts index a3dd0f05e8..de64477848 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts +++ b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts @@ -330,10 +330,10 @@ function CreateCompletionItem(label: string, kind: monaco.languages.CompletionIt export function GetCompletionKeywords(range: IRange, monaco): monaco.languages.CompletionItem[] { const completionItems = []; const keywords = ['modifier', 'mapping', 'break', 'continue', 'delete', 'else', 'for', - 'after', 'promise', 'alias', 'apply','auto', 'copyof', 'default', 'define', 'final', 'implements', + 'after', 'promise', 'alias', 'apply', 'auto', 'copyof', 'default', 'define', 'final', 'implements', 'inline', 'let', 'macro', 'match', 'mutable', 'null', 'of', 'partial', 'reference', 'relocatable', 'sealed', 'sizeof', 'static', 'supports', 'switch', 'typedef', - 'if', 'new', 'return', 'returns', 'while', 'using', 'emit', 'anonymous', 'indexed', + 'if', 'new', 'return', 'returns', 'while', 'using', 'emit', 'anonymous', 'indexed', 'private', 'public', 'external', 'internal', 'payable', 'nonpayable', 'view', 'pure', 'case', 'do', 'else', 'finally', 'in', 'instanceof', 'return', 'throw', 'try', 'catch', 'typeof', 'yield', 'void', 'virtual', 'override']; keywords.forEach(unit => { @@ -389,6 +389,268 @@ export function GeCompletionUnits(range: IRange, monaco): monaco.languages.Compl return completionItems; } +export function GetImports(range: IRange, monaco): monaco.languages.CompletionItem[] { + let list = [ + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/ERC20.sol', + label: 'OZ ERC20', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC721/ERC721.sol', + label: 'OZ ERC721', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/access/Ownable.sol', + label: 'OZ Ownable', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/Counters.sol', + label: 'OZ Counters', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/Address.sol', + label: 'OZ Address', + range + }, + { + detail: '@openzeppelin/contracts/utils/Context.sol', + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/Context.sol', + label: 'OZ Context', + range + }, + { + detail: '@openzeppelin/contracts/utils/EnumerableSet.sol', + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/EnumerableSet.sol', + label: 'OZ EnumerableSet', + range + }, + { + detail: '@openzeppelin/contracts/utils/EnumerableMap.sol', + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/EnumerableMap.sol', + label: 'OZ EnumerableMap', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/Strings.sol', + label: 'OZ Strings', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/ReentrancyGuard.sol', + label: 'OZ ReentrancyGuard', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/Pausable.sol', + label: 'OZ Pausable', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/structs/EnumerableSet.sol', + label: 'OZ EnumerableSet', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/structs/EnumerableMap.sol', + label: 'OZ EnumerableMap', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/math/SafeMath.sol', + label: 'OZ SafeMath', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/math/SafeCast.sol', + label: 'OZ SafeCast', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/math/Math.sol', + label: 'OZ Math', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/math/SignedSafeMath.sol', + label: 'OZ SignedSafeMath', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/math/SafeMath.sol', + label: 'OZ SafeMath', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/utils/math/SafeCast.sol', + label: 'OZ SafeCast', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol', + label: 'OZ ERC20Burnable', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol', + label: 'OZ ERC20Pausable', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol', + label: 'OZ ERC20Snapshot', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol', + label: 'OZ ERC20Permit', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Votes.sol', + label: 'OZ ERC20Votes', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC1155/ERC1155.sol', + label: 'OZ ERC1155', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/IERC20.sol', + label: 'OZ IERC20', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC721/IERC721.sol', + label: 'OZ IERC721', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC1155/IERC1155.sol', + label: 'OZ IERC1155', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/IERC20Metadata.sol', + label: 'OZ IERC20Metadata', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol', + label: 'OZ IERC721Metadata', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC1155/IERC1155MetadataURI.sol', + label: 'OZ IERC1155MetadataURI', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol', + label: 'OZ IERC1155Receiver', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol', + label: 'OZ IERC721Receiver', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol', + label: 'OZ SafeERC20', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/Governor.sol', + label: 'OZ Governor', + range + }, + { + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol', + label: 'OZ GovernorCountingSimple', + range + + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorVotes.sol', + label: 'OZ GovernorVotes', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol', + label: 'OZ GovernorVotesQuorumFraction', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorTimelockCompound.sol', + label: 'OZ GovernorTimelockCompound', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol', + label: 'OZ GovernorTimelockControl', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol', + label: 'OZ GovernorCountingSimple', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorSettings.sol', + label: 'OZ GovernorSettings', + range + },{ + kind: monaco.languages.CompletionItemKind.Module, + insertText: '@openzeppelin/contracts/governance/extensions/GovernorCompatibilityBravo.sol', + label: 'OZ GovernorCompatibilityBravo', + range + } + ] + list = list.map((item) => { + return { + ...item, + label: `${item.label}: ${item.insertText}`, + } + }) + console.log(list) + return list; +}; export function GetGlobalVariable(range: IRange, monaco): monaco.languages.CompletionItem[] { return [ @@ -668,7 +930,7 @@ export function getAddressCompletionItems(range: IRange, monaco): monaco.languag ] } - + export function getContextualAutoCompleteBTypeName(word: string, range: IRange, monaco): monaco.languages.CompletionItem[] { if (word === 'ArrayTypeName') { return getArrayCompletionItems(range, monaco); diff --git a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts index 745c5e395b..c9b88c9805 100644 --- a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts @@ -4,7 +4,7 @@ import { isArray } from "lodash" import { editor, languages, Position } from "monaco-editor" import monaco from "../../types/monaco" import { EditorUIProps } from "../remix-ui-editor" -import { GeCompletionUnits, GetCompletionKeywords, getCompletionSnippets, GetCompletionTypes, getContextualAutoCompleteBTypeName, getContextualAutoCompleteByGlobalVariable, GetGlobalFunctions, GetGlobalVariable } from "./completion/completionGlobals" +import { GeCompletionUnits, GetCompletionKeywords, getCompletionSnippets, GetCompletionTypes, getContextualAutoCompleteBTypeName, getContextualAutoCompleteByGlobalVariable, GetGlobalFunctions, GetGlobalVariable, GetImports } from "./completion/completionGlobals" export class RemixCompletionProvider implements languages.CompletionItemProvider { @@ -16,11 +16,11 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider this.monaco = monaco } - triggerCharacters = ['.', ''] + triggerCharacters = ['.', '', '"'] async provideCompletionItems(model: editor.ITextModel, position: Position, context: monaco.languages.CompletionContext): Promise { const completionSettings = await this.props.plugin.call('config', 'getAppParameter', 'settings/auto-completion') - if(!completionSettings) return + if (!completionSettings) return const word = model.getWordUntilPosition(position); const range = { startLineNumber: position.lineNumber, @@ -33,62 +33,75 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider let nodes: AstNode[] = [] let suggestions: monaco.languages.CompletionItem[] = [] - if (context.triggerCharacter === '.') { - const lineTextBeforeCursor: string = line.substring(0, position.column - 1) - const lastNodeInExpression = await this.getLastNodeInExpression(lineTextBeforeCursor) - const expressionElements = lineTextBeforeCursor.split('.') + if (context.triggerCharacter === '"') { - let dotCompleted = false + const ast = await this.props.plugin.call('codeParser', 'parseSolidity', line) + if (ast && ast.children && ast.children[0] && ast.children[0].type === "ImportDirective") { + suggestions = [...suggestions, + ...GetImports(range, this.monaco), + ] - // handles completion from for builtin types - if(lastNodeInExpression.memberName === 'sender') { // exception for this member - lastNodeInExpression.name = 'sender' + }else{ + return } - const globalCompletion = getContextualAutoCompleteByGlobalVariable(lastNodeInExpression.name, range, this.monaco) - if (globalCompletion) { - dotCompleted = true - suggestions = [...suggestions, ...globalCompletion] - setTimeout(() => { - // eslint-disable-next-line no-debugger - // debugger - }, 2000) - } - // handle completion for global THIS. - if (lastNodeInExpression.name === 'this') { - dotCompleted = true - nodes = [...nodes, ...await this.getThisCompletions(position)] - } - // handle completion for other dot completions - if (expressionElements.length > 1 && !dotCompleted) { + } else - const nameOfLastTypedExpression = lastNodeInExpression.name || lastNodeInExpression.memberName - const dotCompletions = await this.getDotCompletions(position, nameOfLastTypedExpression, range) - nodes = [...nodes, ...dotCompletions.nodes] - suggestions = [...suggestions, ...dotCompletions.suggestions] - } - } else { + if (context.triggerCharacter === '.') { + const lineTextBeforeCursor: string = line.substring(0, position.column - 1) + const lastNodeInExpression = await this.getLastNodeInExpression(lineTextBeforeCursor) + const expressionElements = lineTextBeforeCursor.split('.') - // handles contract completions and other suggestions - suggestions = [...suggestions, - ...GetGlobalVariable(range, this.monaco), - ...getCompletionSnippets(range, this.monaco), - ...GetCompletionTypes(range, this.monaco), - ...GetCompletionKeywords(range, this.monaco), - ...GetGlobalFunctions(range, this.monaco), - ...GeCompletionUnits(range, this.monaco), - ] - let contractCompletions = await this.getContractCompletions(position) + let dotCompleted = false - // we can't have external nodes without using this. - contractCompletions = contractCompletions.filter(node => { - if (node.visibility && node.visibility === 'external') { - return false + // handles completion from for builtin types + if (lastNodeInExpression.memberName === 'sender') { // exception for this member + lastNodeInExpression.name = 'sender' } - return true - }) - nodes = [...nodes, ...contractCompletions] + const globalCompletion = getContextualAutoCompleteByGlobalVariable(lastNodeInExpression.name, range, this.monaco) + if (globalCompletion) { + dotCompleted = true + suggestions = [...suggestions, ...globalCompletion] + setTimeout(() => { + // eslint-disable-next-line no-debugger + // debugger + }, 2000) + } + // handle completion for global THIS. + if (lastNodeInExpression.name === 'this') { + dotCompleted = true + nodes = [...nodes, ...await this.getThisCompletions(position)] + } + // handle completion for other dot completions + if (expressionElements.length > 1 && !dotCompleted) { - } + const nameOfLastTypedExpression = lastNodeInExpression.name || lastNodeInExpression.memberName + const dotCompletions = await this.getDotCompletions(position, nameOfLastTypedExpression, range) + nodes = [...nodes, ...dotCompletions.nodes] + suggestions = [...suggestions, ...dotCompletions.suggestions] + } + } else { + + // handles contract completions and other suggestions + suggestions = [...suggestions, + ...GetGlobalVariable(range, this.monaco), + ...getCompletionSnippets(range, this.monaco), + ...GetCompletionTypes(range, this.monaco), + ...GetCompletionKeywords(range, this.monaco), + ...GetGlobalFunctions(range, this.monaco), + ...GeCompletionUnits(range, this.monaco), + ] + let contractCompletions = await this.getContractCompletions(position) + + // we can't have external nodes without using this. + contractCompletions = contractCompletions.filter(node => { + if (node.visibility && node.visibility === 'external') { + return false + } + return true + }) + nodes = [...nodes, ...contractCompletions] + + } // remove duplicates const nodeIds = {}; @@ -220,7 +233,7 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider } suggestions.push(completion) - } + } } return { @@ -242,9 +255,9 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider // try to find the real block in the AST and get the nodes in that scope if (node.nodeType === 'ContractDefinition') { const contractNodes = fileNodes.contracts[node.name].contractNodes - for (const contractNode of Object.values(contractNodes)) { - if (contractNode['name'] === ANTLRBlock.name - || (contractNode['kind'] === 'constructor' && ANTLRBlock.name === null ) + for (const contractNode of Object.values(contractNodes)) { + if (contractNode['name'] === ANTLRBlock.name + || (contractNode['kind'] === 'constructor' && ANTLRBlock.name === null) ) { let nodeOfScope = await this.props.plugin.call('codeParser', 'getNodesWithScope', (contractNode as any).id) nodes = [...nodes, ...nodeOfScope] @@ -270,7 +283,7 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider */ } } - + // we are only interested in nodes that are in the same block as the cursor nodes = nodes.filter(node => { if (node.src) { @@ -279,7 +292,7 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider return true } } - if(node.outSideBlock){ return true } + if (node.outSideBlock) { return true } return false }) @@ -387,9 +400,9 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider nodes = [...nodes, ...filterNodes(nodeOfScope.members, nodeOfScope)] } else if (nodeOfScope.typeName && nodeOfScope.typeName.nodeType === 'ArrayTypeName') { suggestions = [...suggestions, ...getContextualAutoCompleteBTypeName('ArrayTypeName', range, this.monaco)] - } else if(nodeOfScope.typeName && nodeOfScope.typeName.nodeType === 'ElementaryTypeName' && nodeOfScope.typeName.name === 'bytes') { + } else if (nodeOfScope.typeName && nodeOfScope.typeName.nodeType === 'ElementaryTypeName' && nodeOfScope.typeName.name === 'bytes') { suggestions = [...suggestions, ...getContextualAutoCompleteBTypeName('bytes', range, this.monaco)] - } else if(nodeOfScope.typeName && nodeOfScope.typeName.nodeType === 'ElementaryTypeName' && nodeOfScope.typeName.name === 'address') { + } else if (nodeOfScope.typeName && nodeOfScope.typeName.nodeType === 'ElementaryTypeName' && nodeOfScope.typeName.name === 'address') { suggestions = [...suggestions, ...getContextualAutoCompleteBTypeName('address', range, this.monaco)] } } From 4bcb587214f91682a2aa9d9a5a24f01deacda142 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 14 Sep 2022 19:37:27 +0200 Subject: [PATCH 04/60] use generated list --- .../providers/completion/completionGlobals.ts | 275 ++--------------- .../contracts/OpenZeppelinContracts.txt | 278 ++++++++++++++++++ 2 files changed, 298 insertions(+), 255 deletions(-) create mode 100644 libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt diff --git a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts index de64477848..88c2369f5a 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts +++ b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts @@ -1,5 +1,16 @@ import { IRange } from "monaco-editor"; import monaco from "../../../types/monaco"; +import path from "path"; +let OZContracts; + +// @ts-ignore +import('raw-loader!libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt').then( + (txt) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + OZContracts = txt.default.split('\n').filter(x => !x.includes('mock')) + } +) + export function getStringCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { return [ @@ -390,262 +401,16 @@ export function GeCompletionUnits(range: IRange, monaco): monaco.languages.Compl return completionItems; } export function GetImports(range: IRange, monaco): monaco.languages.CompletionItem[] { - let list = [ - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/ERC20.sol', - label: 'OZ ERC20', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC721/ERC721.sol', - label: 'OZ ERC721', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/access/Ownable.sol', - label: 'OZ Ownable', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/Counters.sol', - label: 'OZ Counters', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/Address.sol', - label: 'OZ Address', - range - }, - { - detail: '@openzeppelin/contracts/utils/Context.sol', - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/Context.sol', - label: 'OZ Context', - range - }, - { - detail: '@openzeppelin/contracts/utils/EnumerableSet.sol', - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/EnumerableSet.sol', - label: 'OZ EnumerableSet', - range - }, - { - detail: '@openzeppelin/contracts/utils/EnumerableMap.sol', - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/EnumerableMap.sol', - label: 'OZ EnumerableMap', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/Strings.sol', - label: 'OZ Strings', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/ReentrancyGuard.sol', - label: 'OZ ReentrancyGuard', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/Pausable.sol', - label: 'OZ Pausable', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/structs/EnumerableSet.sol', - label: 'OZ EnumerableSet', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/structs/EnumerableMap.sol', - label: 'OZ EnumerableMap', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/math/SafeMath.sol', - label: 'OZ SafeMath', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/math/SafeCast.sol', - label: 'OZ SafeCast', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/math/Math.sol', - label: 'OZ Math', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/math/SignedSafeMath.sol', - label: 'OZ SignedSafeMath', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/math/SafeMath.sol', - label: 'OZ SafeMath', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/utils/math/SafeCast.sol', - label: 'OZ SafeCast', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol', - label: 'OZ ERC20Burnable', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol', - label: 'OZ ERC20Pausable', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol', - label: 'OZ ERC20Snapshot', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol', - label: 'OZ ERC20Permit', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Votes.sol', - label: 'OZ ERC20Votes', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC1155/ERC1155.sol', - label: 'OZ ERC1155', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/IERC20.sol', - label: 'OZ IERC20', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC721/IERC721.sol', - label: 'OZ IERC721', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC1155/IERC1155.sol', - label: 'OZ IERC1155', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/IERC20Metadata.sol', - label: 'OZ IERC20Metadata', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol', - label: 'OZ IERC721Metadata', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC1155/IERC1155MetadataURI.sol', - label: 'OZ IERC1155MetadataURI', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol', - label: 'OZ IERC1155Receiver', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol', - label: 'OZ IERC721Receiver', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol', - label: 'OZ SafeERC20', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/Governor.sol', - label: 'OZ Governor', - range - }, - { - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol', - label: 'OZ GovernorCountingSimple', - range - - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorVotes.sol', - label: 'OZ GovernorVotes', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol', - label: 'OZ GovernorVotesQuorumFraction', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorTimelockCompound.sol', - label: 'OZ GovernorTimelockCompound', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol', - label: 'OZ GovernorTimelockControl', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol', - label: 'OZ GovernorCountingSimple', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorSettings.sol', - label: 'OZ GovernorSettings', - range - },{ - kind: monaco.languages.CompletionItemKind.Module, - insertText: '@openzeppelin/contracts/governance/extensions/GovernorCompatibilityBravo.sol', - label: 'OZ GovernorCompatibilityBravo', - range - } - ] - list = list.map((item) => { + let list = [] + list.filter + list = OZContracts + .map((item) => { + const filename = path.basename(item) return { - ...item, - label: `${item.label}: ${item.insertText}`, + kind: monaco.languages.CompletionItemKind.Module, + range: range, + label: `OZ ${filename}: ${item}`, + insertText: `@openzeppelin${item}`, } }) console.log(list) diff --git a/libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt b/libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt new file mode 100644 index 0000000000..cffe37a8a7 --- /dev/null +++ b/libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt @@ -0,0 +1,278 @@ +/contracts/access/AccessControl.sol +/contracts/access/AccessControlCrossChain.sol +/contracts/access/AccessControlEnumerable.sol +/contracts/access/IAccessControl.sol +/contracts/access/IAccessControlEnumerable.sol +/contracts/access/Ownable.sol +/contracts/access/Ownable2Step.sol +/contracts/crosschain/amb/CrossChainEnabledAMB.sol +/contracts/crosschain/amb/LibAMB.sol +/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol +/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol +/contracts/crosschain/arbitrum/LibArbitrumL1.sol +/contracts/crosschain/arbitrum/LibArbitrumL2.sol +/contracts/crosschain/CrossChainEnabled.sol +/contracts/crosschain/errors.sol +/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol +/contracts/crosschain/optimism/LibOptimism.sol +/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol +/contracts/finance/PaymentSplitter.sol +/contracts/finance/VestingWallet.sol +/contracts/governance/compatibility/GovernorCompatibilityBravo.sol +/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol +/contracts/governance/extensions/GovernorCountingSimple.sol +/contracts/governance/extensions/GovernorPreventLateQuorum.sol +/contracts/governance/extensions/GovernorProposalThreshold.sol +/contracts/governance/extensions/GovernorSettings.sol +/contracts/governance/extensions/GovernorTimelockCompound.sol +/contracts/governance/extensions/GovernorTimelockControl.sol +/contracts/governance/extensions/GovernorVotes.sol +/contracts/governance/extensions/GovernorVotesComp.sol +/contracts/governance/extensions/GovernorVotesQuorumFraction.sol +/contracts/governance/extensions/IGovernorTimelock.sol +/contracts/governance/Governor.sol +/contracts/governance/IGovernor.sol +/contracts/governance/TimelockController.sol +/contracts/governance/utils/IVotes.sol +/contracts/governance/utils/Votes.sol +/contracts/interfaces/draft-IERC1822.sol +/contracts/interfaces/draft-IERC2612.sol +/contracts/interfaces/IERC1155.sol +/contracts/interfaces/IERC1155MetadataURI.sol +/contracts/interfaces/IERC1155Receiver.sol +/contracts/interfaces/IERC1271.sol +/contracts/interfaces/IERC1363.sol +/contracts/interfaces/IERC1363Receiver.sol +/contracts/interfaces/IERC1363Spender.sol +/contracts/interfaces/IERC165.sol +/contracts/interfaces/IERC1820Implementer.sol +/contracts/interfaces/IERC1820Registry.sol +/contracts/interfaces/IERC20.sol +/contracts/interfaces/IERC20Metadata.sol +/contracts/interfaces/IERC2309.sol +/contracts/interfaces/IERC2981.sol +/contracts/interfaces/IERC3156.sol +/contracts/interfaces/IERC3156FlashBorrower.sol +/contracts/interfaces/IERC3156FlashLender.sol +/contracts/interfaces/IERC4626.sol +/contracts/interfaces/IERC721.sol +/contracts/interfaces/IERC721Enumerable.sol +/contracts/interfaces/IERC721Metadata.sol +/contracts/interfaces/IERC721Receiver.sol +/contracts/interfaces/IERC777.sol +/contracts/interfaces/IERC777Recipient.sol +/contracts/interfaces/IERC777Sender.sol +/contracts/metatx/ERC2771Context.sol +/contracts/metatx/MinimalForwarder.sol +/contracts/mocks/AccessControlCrossChainMock.sol +/contracts/mocks/AccessControlEnumerableMock.sol +/contracts/mocks/AccessControlMock.sol +/contracts/mocks/AddressImpl.sol +/contracts/mocks/ArraysMock.sol +/contracts/mocks/BadBeacon.sol +/contracts/mocks/Base64Mock.sol +/contracts/mocks/BitmapMock.sol +/contracts/mocks/CallReceiverMock.sol +/contracts/mocks/CheckpointsMock.sol +/contracts/mocks/ClashingImplementation.sol +/contracts/mocks/ClonesMock.sol +/contracts/mocks/compound/CompTimelock.sol +/contracts/mocks/ConditionalEscrowMock.sol +/contracts/mocks/ContextMock.sol +/contracts/mocks/CountersImpl.sol +/contracts/mocks/Create2Impl.sol +/contracts/mocks/crosschain/bridges.sol +/contracts/mocks/crosschain/receivers.sol +/contracts/mocks/DoubleEndedQueueMock.sol +/contracts/mocks/DummyImplementation.sol +/contracts/mocks/ECDSAMock.sol +/contracts/mocks/EIP712External.sol +/contracts/mocks/EnumerableMapMock.sol +/contracts/mocks/EnumerableSetMock.sol +/contracts/mocks/ERC1155BurnableMock.sol +/contracts/mocks/ERC1155Mock.sol +/contracts/mocks/ERC1155PausableMock.sol +/contracts/mocks/ERC1155ReceiverMock.sol +/contracts/mocks/ERC1155SupplyMock.sol +/contracts/mocks/ERC1155URIStorageMock.sol +/contracts/mocks/ERC1271WalletMock.sol +/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +/contracts/mocks/ERC165/ERC165MaliciousData.sol +/contracts/mocks/ERC165/ERC165MissingData.sol +/contracts/mocks/ERC165/ERC165NotSupported.sol +/contracts/mocks/ERC165/ERC165ReturnBomb.sol +/contracts/mocks/ERC165CheckerMock.sol +/contracts/mocks/ERC165Mock.sol +/contracts/mocks/ERC165StorageMock.sol +/contracts/mocks/ERC1820ImplementerMock.sol +/contracts/mocks/ERC20BurnableMock.sol +/contracts/mocks/ERC20CappedMock.sol +/contracts/mocks/ERC20DecimalsMock.sol +/contracts/mocks/ERC20FlashMintMock.sol +/contracts/mocks/ERC20Mock.sol +/contracts/mocks/ERC20PausableMock.sol +/contracts/mocks/ERC20PermitMock.sol +/contracts/mocks/ERC20SnapshotMock.sol +/contracts/mocks/ERC20VotesCompMock.sol +/contracts/mocks/ERC20VotesMock.sol +/contracts/mocks/ERC20WrapperMock.sol +/contracts/mocks/ERC2771ContextMock.sol +/contracts/mocks/ERC3156FlashBorrowerMock.sol +/contracts/mocks/ERC4626Mock.sol +/contracts/mocks/ERC721BurnableMock.sol +/contracts/mocks/ERC721ConsecutiveMock.sol +/contracts/mocks/ERC721EnumerableMock.sol +/contracts/mocks/ERC721Mock.sol +/contracts/mocks/ERC721PausableMock.sol +/contracts/mocks/ERC721ReceiverMock.sol +/contracts/mocks/ERC721RoyaltyMock.sol +/contracts/mocks/ERC721URIStorageMock.sol +/contracts/mocks/ERC721VotesMock.sol +/contracts/mocks/ERC777Mock.sol +/contracts/mocks/ERC777SenderRecipientMock.sol +/contracts/mocks/EtherReceiverMock.sol +/contracts/mocks/GovernorCompatibilityBravoMock.sol +/contracts/mocks/GovernorCompMock.sol +/contracts/mocks/GovernorMock.sol +/contracts/mocks/GovernorPreventLateQuorumMock.sol +/contracts/mocks/GovernorTimelockCompoundMock.sol +/contracts/mocks/GovernorTimelockControlMock.sol +/contracts/mocks/GovernorVoteMock.sol +/contracts/mocks/GovernorWithParamsMock.sol +/contracts/mocks/InitializableMock.sol +/contracts/mocks/MathMock.sol +/contracts/mocks/MerkleProofWrapper.sol +/contracts/mocks/MulticallTest.sol +/contracts/mocks/MulticallTokenMock.sol +/contracts/mocks/MultipleInheritanceInitializableMocks.sol +/contracts/mocks/Ownable2StepMock.sol +/contracts/mocks/OwnableMock.sol +/contracts/mocks/PausableMock.sol +/contracts/mocks/PullPaymentMock.sol +/contracts/mocks/ReentrancyAttack.sol +/contracts/mocks/ReentrancyMock.sol +/contracts/mocks/RegressionImplementation.sol +/contracts/mocks/SafeCastMock.sol +/contracts/mocks/SafeERC20Helper.sol +/contracts/mocks/SafeMathMock.sol +/contracts/mocks/SignatureCheckerMock.sol +/contracts/mocks/SignedMathMock.sol +/contracts/mocks/SignedSafeMathMock.sol +/contracts/mocks/SingleInheritanceInitializableMocks.sol +/contracts/mocks/StorageSlotMock.sol +/contracts/mocks/StringsMock.sol +/contracts/mocks/TimersBlockNumberImpl.sol +/contracts/mocks/TimersTimestampImpl.sol +/contracts/mocks/UUPS/UUPSLegacy.sol +/contracts/mocks/UUPS/UUPSUpgradeableMock.sol +/contracts/mocks/VotesMock.sol +/contracts/mocks/wizard/MyGovernor1.sol +/contracts/mocks/wizard/MyGovernor2.sol +/contracts/mocks/wizard/MyGovernor3.sol +/contracts/proxy/beacon/BeaconProxy.sol +/contracts/proxy/beacon/IBeacon.sol +/contracts/proxy/beacon/UpgradeableBeacon.sol +/contracts/proxy/Clones.sol +/contracts/proxy/ERC1967/ERC1967Proxy.sol +/contracts/proxy/ERC1967/ERC1967Upgrade.sol +/contracts/proxy/Proxy.sol +/contracts/proxy/transparent/ProxyAdmin.sol +/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +/contracts/proxy/utils/Initializable.sol +/contracts/proxy/utils/UUPSUpgradeable.sol +/contracts/security/Pausable.sol +/contracts/security/PullPayment.sol +/contracts/security/ReentrancyGuard.sol +/contracts/token/common/ERC2981.sol +/contracts/token/ERC1155/ERC1155.sol +/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +/contracts/token/ERC1155/extensions/ERC1155Supply.sol +/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol +/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol +/contracts/token/ERC1155/IERC1155.sol +/contracts/token/ERC1155/IERC1155Receiver.sol +/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol +/contracts/token/ERC1155/utils/ERC1155Holder.sol +/contracts/token/ERC1155/utils/ERC1155Receiver.sol +/contracts/token/ERC20/ERC20.sol +/contracts/token/ERC20/extensions/draft-ERC20Permit.sol +/contracts/token/ERC20/extensions/draft-IERC20Permit.sol +/contracts/token/ERC20/extensions/ERC20Burnable.sol +/contracts/token/ERC20/extensions/ERC20Capped.sol +/contracts/token/ERC20/extensions/ERC20FlashMint.sol +/contracts/token/ERC20/extensions/ERC20Pausable.sol +/contracts/token/ERC20/extensions/ERC20Snapshot.sol +/contracts/token/ERC20/extensions/ERC20Votes.sol +/contracts/token/ERC20/extensions/ERC20VotesComp.sol +/contracts/token/ERC20/extensions/ERC20Wrapper.sol +/contracts/token/ERC20/extensions/ERC4626.sol +/contracts/token/ERC20/extensions/IERC20Metadata.sol +/contracts/token/ERC20/IERC20.sol +/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol +/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol +/contracts/token/ERC20/utils/SafeERC20.sol +/contracts/token/ERC20/utils/TokenTimelock.sol +/contracts/token/ERC721/ERC721.sol +/contracts/token/ERC721/extensions/draft-ERC721Votes.sol +/contracts/token/ERC721/extensions/ERC721Burnable.sol +/contracts/token/ERC721/extensions/ERC721Consecutive.sol +/contracts/token/ERC721/extensions/ERC721Enumerable.sol +/contracts/token/ERC721/extensions/ERC721Pausable.sol +/contracts/token/ERC721/extensions/ERC721Royalty.sol +/contracts/token/ERC721/extensions/ERC721URIStorage.sol +/contracts/token/ERC721/extensions/IERC721Enumerable.sol +/contracts/token/ERC721/extensions/IERC721Metadata.sol +/contracts/token/ERC721/IERC721.sol +/contracts/token/ERC721/IERC721Receiver.sol +/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol +/contracts/token/ERC721/utils/ERC721Holder.sol +/contracts/token/ERC777/ERC777.sol +/contracts/token/ERC777/IERC777.sol +/contracts/token/ERC777/IERC777Recipient.sol +/contracts/token/ERC777/IERC777Sender.sol +/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol +/contracts/utils/Address.sol +/contracts/utils/Arrays.sol +/contracts/utils/Base64.sol +/contracts/utils/Checkpoints.sol +/contracts/utils/Context.sol +/contracts/utils/Counters.sol +/contracts/utils/Create2.sol +/contracts/utils/cryptography/draft-EIP712.sol +/contracts/utils/cryptography/ECDSA.sol +/contracts/utils/cryptography/EIP712.sol +/contracts/utils/cryptography/MerkleProof.sol +/contracts/utils/cryptography/SignatureChecker.sol +/contracts/utils/escrow/ConditionalEscrow.sol +/contracts/utils/escrow/Escrow.sol +/contracts/utils/escrow/RefundEscrow.sol +/contracts/utils/introspection/ERC165.sol +/contracts/utils/introspection/ERC165Checker.sol +/contracts/utils/introspection/ERC165Storage.sol +/contracts/utils/introspection/ERC1820Implementer.sol +/contracts/utils/introspection/IERC165.sol +/contracts/utils/introspection/IERC1820Implementer.sol +/contracts/utils/introspection/IERC1820Registry.sol +/contracts/utils/math/Math.sol +/contracts/utils/math/SafeCast.sol +/contracts/utils/math/SafeMath.sol +/contracts/utils/math/SignedMath.sol +/contracts/utils/math/SignedSafeMath.sol +/contracts/utils/Multicall.sol +/contracts/utils/StorageSlot.sol +/contracts/utils/Strings.sol +/contracts/utils/structs/BitMaps.sol +/contracts/utils/structs/DoubleEndedQueue.sol +/contracts/utils/structs/EnumerableMap.sol +/contracts/utils/structs/EnumerableSet.sol +/contracts/utils/Timers.sol +/contracts/vendor/amb/IAMB.sol +/contracts/vendor/arbitrum/IArbSys.sol +/contracts/vendor/arbitrum/IBridge.sol +/contracts/vendor/arbitrum/IInbox.sol +/contracts/vendor/arbitrum/IMessageProvider.sol +/contracts/vendor/arbitrum/IOutbox.sol +/contracts/vendor/compound/ICompoundTimelock.sol +/contracts/vendor/optimism/ICrossDomainMessenger.sol +/contracts/vendor/polygon/IFxMessageProcessor.sol \ No newline at end of file From 7792e05224f9649dc6eba369c7e3ffe9daa273c0 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 14 Sep 2022 19:40:43 +0200 Subject: [PATCH 05/60] berlin --- .../src/app/plugins/parser/services/code-parser-compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts index 4a31356052..3f669a8814 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts @@ -131,7 +131,7 @@ export default class CodeParserCompiler { "*": ["evm.gasEstimates"] } }, - "evmVersion": state.evmVersion && state.evmVersion.toString() || "byzantium", + "evmVersion": state.evmVersion && state.evmVersion.toString() || "berlin", } } From 4839c3b5514ee15c472d241eabb59bbd45c544ad Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 14 Sep 2022 20:02:25 +0200 Subject: [PATCH 06/60] Update completionGlobals.ts --- .../editor/src/lib/providers/completion/completionGlobals.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts index 88c2369f5a..68345eab8a 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts +++ b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts @@ -402,7 +402,6 @@ export function GeCompletionUnits(range: IRange, monaco): monaco.languages.Compl } export function GetImports(range: IRange, monaco): monaco.languages.CompletionItem[] { let list = [] - list.filter list = OZContracts .map((item) => { const filename = path.basename(item) @@ -413,7 +412,6 @@ export function GetImports(range: IRange, monaco): monaco.languages.CompletionIt insertText: `@openzeppelin${item}`, } }) - console.log(list) return list; }; @@ -707,4 +705,4 @@ export function getContextualAutoCompleteBTypeName(word: string, range: IRange, return getAddressCompletionItems(range, monaco); } return []; -} \ No newline at end of file +} From c600954724eb83f0e7dadffcb190f392029f7176 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 00:48:46 +0200 Subject: [PATCH 07/60] refactor --- .../src/app/plugins/parser/code-parser.tsx | 18 +- .../parser/services/code-parser-compiler.ts | 4 +- .../parser/services/code-parser-imports.ts | 86 ++++++++ .../providers/completion/completionGlobals.ts | 107 ++++++++-- .../completion/contracts/contracts.txt | 198 ++++++++++++++++++ .../src/lib/providers/completionProvider.ts | 40 ++-- package.json | 6 +- yarn.lock | 15 ++ 8 files changed, 426 insertions(+), 48 deletions(-) create mode 100644 apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts create mode 100644 libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt diff --git a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx index b763f81a3c..9b51e42a4e 100644 --- a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx +++ b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx @@ -6,6 +6,7 @@ import { CompilationResult } from '@remix-project/remix-solidity' import CodeParserGasService from './services/code-parser-gas-service' import CodeParserCompiler from './services/code-parser-compiler' import CodeParserAntlrService from './services/code-parser-antlr-service' +import CodeParserImports, { CodeParserImportsData } from './services/code-parser-imports' import React from 'react' import { Profile } from '@remixproject/plugin-utils' import { ContractDefinitionAstNode, EventDefinitionAstNode, FunctionCallAstNode, FunctionDefinitionAstNode, IdentifierAstNode, ImportDirectiveAstNode, ModifierDefinitionAstNode, SourceUnitAstNode, StructDefinitionAstNode, VariableDeclarationAstNode } from 'dist/libs/remix-analyzer/src/types' @@ -15,7 +16,7 @@ import { ParseResult } from './types/antlr-types' const profile: Profile = { name: 'codeParser', - methods: ['nodesAtPosition', 'getContractNodes', 'getCurrentFileNodes', 'getLineColumnOfNode', 'getLineColumnOfPosition', 'getFunctionParamaters', 'getDeclaration', 'getFunctionReturnParameters', 'getVariableDeclaration', 'getNodeDocumentation', 'getNodeLink', 'listAstNodes', 'getANTLRBlockAtPosition', 'getLastNodeInLine', 'resolveImports', 'parseSolidity', 'getNodesWithScope', 'getNodesWithName', 'getNodes', 'compile', 'getNodeById', 'getLastCompilationResult', 'positionOfDefinition', 'definitionAtPosition', 'jumpToDefinition', 'referrencesAtPosition', 'referencesOf', 'getActiveHighlights', 'gasEstimation', 'declarationOf', 'getGasEstimates'], + methods: ['nodesAtPosition', 'getContractNodes', 'getCurrentFileNodes', 'getLineColumnOfNode', 'getLineColumnOfPosition', 'getFunctionParamaters', 'getDeclaration', 'getFunctionReturnParameters', 'getVariableDeclaration', 'getNodeDocumentation', 'getNodeLink', 'listAstNodes', 'getANTLRBlockAtPosition', 'getLastNodeInLine', 'resolveImports', 'parseSolidity', 'getNodesWithScope', 'getNodesWithName', 'getNodes', 'compile', 'getNodeById', 'getLastCompilationResult', 'positionOfDefinition', 'definitionAtPosition', 'jumpToDefinition', 'referrencesAtPosition', 'referencesOf', 'getActiveHighlights', 'gasEstimation', 'declarationOf', 'getGasEstimates', 'getImports'], events: [], version: '0.0.1' } @@ -70,12 +71,15 @@ export class CodeParser extends Plugin { gasService: CodeParserGasService compilerService: CodeParserCompiler antlrService: CodeParserAntlrService + importService: CodeParserImports parseSolidity: (text: string) => Promise getLastNodeInLine: (ast: string) => Promise listAstNodes: () => Promise getANTLRBlockAtPosition: (position: any, text?: string) => Promise getCurrentFileAST: (text?: string) => Promise + getImports: () => Promise + constructor(astWalker: any) { super(profile) @@ -94,7 +98,7 @@ export class CodeParser extends Plugin { } const showGasSettings = await this.call('config', 'getAppParameter', 'show-gas') const showErrorSettings = await this.call('config', 'getAppParameter', 'display-errors') - if(showGasSettings || showErrorSettings || completionSettings) { + if (showGasSettings || showErrorSettings || completionSettings) { await this.compilerService.compile() } } @@ -104,13 +108,14 @@ export class CodeParser extends Plugin { this.gasService = new CodeParserGasService(this) this.compilerService = new CodeParserCompiler(this) this.antlrService = new CodeParserAntlrService(this) + this.importService = new CodeParserImports(this) this.parseSolidity = this.antlrService.parseSolidity.bind(this.antlrService) this.getLastNodeInLine = this.antlrService.getLastNodeInLine.bind(this.antlrService) this.listAstNodes = this.antlrService.listAstNodes.bind(this.antlrService) this.getANTLRBlockAtPosition = this.antlrService.getANTLRBlockAtPosition.bind(this.antlrService) this.getCurrentFileAST = this.antlrService.getCurrentFileAST.bind(this.antlrService) - + this.getImports = this.importService.getImports.bind(this.importService) this.on('editor', 'didChangeFile', async (file) => { await this.call('editor', 'discardLineTexts') @@ -119,6 +124,7 @@ export class CodeParser extends Plugin { this.on('filePanel', 'setWorkspace', async () => { await this.call('fileDecorator', 'clearFileDecorators') + await this.importService.setFileTree() }) @@ -135,8 +141,6 @@ export class CodeParser extends Plugin { } - - /** * * @returns @@ -145,10 +149,6 @@ export class CodeParser extends Plugin { return this.compilerAbstract } - - - - getSubNodes(node: T): number[] { return node.nodeType == "ContractDefinition" && node.contractDependencies; } diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts index 3f669a8814..9acd434728 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts @@ -39,6 +39,7 @@ export default class CodeParserCompiler { init() { this.onAstFinished = async (success, data: CompilationResult, source: CompilationSource, input: any, version) => { + //console.log('onAstFinished', success, data, source, input, version) this.plugin.call('editor', 'clearAnnotations') this.errorState = true const result = new CompilerAbstract('soljson', data, source, input) @@ -46,7 +47,7 @@ export default class CodeParserCompiler { if (data.errors) { const sources = result.getSourceCode().sources for (const error of data.errors) { - + //console.log(error) const lineBreaks = sourceMappingDecoder.getLinebreakPositions(sources[error.sourceLocation.file].content) const lineColumn = sourceMappingDecoder.convertOffsetToLineColumn({ start: error.sourceLocation.start, @@ -213,6 +214,7 @@ export default class CodeParserCompiler { async clearDecorators(sources: any) { const decorators: fileDecoration[] = [] + if(!sources) return for (const fileName of Object.keys(sources)) { const decorator: fileDecoration = { path: fileName, diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts new file mode 100644 index 0000000000..d2261c3154 --- /dev/null +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts @@ -0,0 +1,86 @@ +'use strict' +import { CodeParser } from "../code-parser"; + +export type CodeParserImportsData= { + files?: string[], + modules?: string[], + packages?: string[], +} + +export default class CodeParserImports { + plugin: CodeParser + + data: CodeParserImportsData = {} + constructor(plugin: CodeParser) { + this.plugin = plugin + this.init() + } + + async getImports(){ + return this.data + } + + async init() { + // @ts-ignore + const txt = await import('raw-loader!libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt') + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + this.data.modules = txt.default.split('\n') + .filter(x => x !== '') + .map(x => x.replace('./node_modules/', '')) + .filter(x => { + if(x.includes('@openzeppelin')) { + return !x.includes('mock') + }else{ + return true + } + }) + + // get unique first words of the values in the array + this.data.packages = [...new Set(this.data.modules.map(x => x.split('/')[0]))] + console.log(this.data) + } + + setFileTree = async () => { + this.data.files = await this.getDirectory('/') + this.data.files = this.data.files.filter(x => x.endsWith('.sol') && !x.startsWith('.deps')) + console.log(this.data) + } + + getDirectory = async (dir: string) => { + let result = [] + const files = await this.plugin.call('fileManager', 'readdir', dir) + const fileArray = this.normalize(files) + for (const fi of fileArray) { + if (fi) { + const type = fi.data.isDirectory + if (type === true) { + result = [...result, ...(await this.getDirectory(`${fi.filename}`))] + } else { + result = [...result, fi.filename] + } + } + } + return result + } + + normalize = filesList => { + const folders = [] + const files = [] + Object.keys(filesList || {}).forEach(key => { + if (filesList[key].isDirectory) { + folders.push({ + filename: key, + data: filesList[key] + }) + } else { + files.push({ + filename: key, + data: filesList[key] + }) + } + }) + return [...folders, ...files] + } + +} \ No newline at end of file diff --git a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts index 88c2369f5a..2209aa8c61 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts +++ b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts @@ -1,16 +1,12 @@ import { IRange } from "monaco-editor"; import monaco from "../../../types/monaco"; import path from "path"; -let OZContracts; - -// @ts-ignore -import('raw-loader!libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt').then( - (txt) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - OZContracts = txt.default.split('\n').filter(x => !x.includes('mock')) - } -) +type CodeParserImportsData = { + files?: string[], + modules?: string[], + packages?: string[], +} export function getStringCompletionItems(range: IRange, monaco): monaco.languages.CompletionItem[] { return [ @@ -400,20 +396,87 @@ export function GeCompletionUnits(range: IRange, monaco): monaco.languages.Compl return completionItems; } -export function GetImports(range: IRange, monaco): monaco.languages.CompletionItem[] { + +export function GetImports(range: IRange + , monaco, data: CodeParserImportsData + , word: string +): monaco.languages.CompletionItem[] { let list = [] - list.filter - list = OZContracts - .map((item) => { - const filename = path.basename(item) - return { - kind: monaco.languages.CompletionItemKind.Module, - range: range, - label: `OZ ${filename}: ${item}`, - insertText: `@openzeppelin${item}`, - } - }) - console.log(list) + if (!word.startsWith('@')) { + word = word.replace('"', ''); + const nextPaths = [...new Set(data.files + .filter((item) => item.startsWith(word)) + .map((item) => item.replace(word, '').split('/')[0]))] + + list = [...list, ...nextPaths + .filter((item) => !item.endsWith('.sol')) + .map((item) => { + return { + kind: monaco.languages.CompletionItemKind.Folder, + range: range, + label: `${item}`, + insertText: `${item}`, + } + })] + + + list = [...list, + ...data.files + .filter((item) => item.startsWith(word)) + .map((item) => { + return { + kind: monaco.languages.CompletionItemKind.File, + range: range, + label: `${item}`, + insertText: `${item.replace(word, '')}`, + } + })] + } + if (word === '@' || word === '') { + list = [...list, ...data.packages.map((item) => { + return { + kind: monaco.languages.CompletionItemKind.Module, + range: range, + label: `${item}`, + insertText: word === '@' ? `${item.replace('@', '')}` : `${item}`, + } + })] + } + if (word.startsWith('@') && word.length > 1) { + const nextPaths = [...new Set(data.modules + .filter((item) => item.startsWith(word)) + .map((item) => item.replace(word, '').split('/')[0]))] + + list = [...list, ...nextPaths + .filter((item) => !item.endsWith('.sol')) + .map((item) => { + return { + kind: monaco.languages.CompletionItemKind.Folder, + range: range, + label: `${item}`, + insertText: `${item}`, + } + })] + + list = [...list + , ...data.modules + .filter((item) => item.startsWith(word)) + .map((item) => { + // remove the first part if it starts with @ + let label = item; + if (label.startsWith('@')) { + label = label.substring(label.indexOf('/') + 1); + } + const filename = path.basename(label) + return { + kind: monaco.languages.CompletionItemKind.Reference, + range: range, + label: `${filename}: ${label}`, + insertText: `${item.replace(word, '')}`, + } + }) + ] + } return list; }; diff --git a/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt b/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt new file mode 100644 index 0000000000..94615103e0 --- /dev/null +++ b/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt @@ -0,0 +1,198 @@ +./node_modules/@openzeppelin/contracts/access/AccessControl.sol +./node_modules/@openzeppelin/contracts/access/AccessControlCrossChain.sol +./node_modules/@openzeppelin/contracts/access/AccessControlEnumerable.sol +./node_modules/@openzeppelin/contracts/access/IAccessControl.sol +./node_modules/@openzeppelin/contracts/access/IAccessControlEnumerable.sol +./node_modules/@openzeppelin/contracts/access/Ownable.sol +./node_modules/@openzeppelin/contracts/crosschain/amb/CrossChainEnabledAMB.sol +./node_modules/@openzeppelin/contracts/crosschain/amb/LibAMB.sol +./node_modules/@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol +./node_modules/@openzeppelin/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol +./node_modules/@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL1.sol +./node_modules/@openzeppelin/contracts/crosschain/arbitrum/LibArbitrumL2.sol +./node_modules/@openzeppelin/contracts/crosschain/CrossChainEnabled.sol +./node_modules/@openzeppelin/contracts/crosschain/errors.sol +./node_modules/@openzeppelin/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol +./node_modules/@openzeppelin/contracts/crosschain/optimism/LibOptimism.sol +./node_modules/@openzeppelin/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol +./node_modules/@openzeppelin/contracts/finance/PaymentSplitter.sol +./node_modules/@openzeppelin/contracts/finance/VestingWallet.sol +./node_modules/@openzeppelin/contracts/governance/compatibility/GovernorCompatibilityBravo.sol +./node_modules/@openzeppelin/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorPreventLateQuorum.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorProposalThreshold.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorSettings.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorTimelockCompound.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotes.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesComp.sol +./node_modules/@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol +./node_modules/@openzeppelin/contracts/governance/extensions/IGovernorTimelock.sol +./node_modules/@openzeppelin/contracts/governance/Governor.sol +./node_modules/@openzeppelin/contracts/governance/IGovernor.sol +./node_modules/@openzeppelin/contracts/governance/TimelockController.sol +./node_modules/@openzeppelin/contracts/governance/utils/IVotes.sol +./node_modules/@openzeppelin/contracts/governance/utils/Votes.sol +./node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol +./node_modules/@openzeppelin/contracts/interfaces/draft-IERC2612.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1155.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1155MetadataURI.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1155Receiver.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1363Receiver.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1363Spender.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC165.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1820Implementer.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC1820Registry.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC20.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC20Metadata.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC2981.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC3156.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC3156FlashLender.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC4626.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC721.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC721Enumerable.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC721Metadata.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC721Receiver.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC777.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC777Recipient.sol +./node_modules/@openzeppelin/contracts/interfaces/IERC777Sender.sol +./node_modules/@openzeppelin/contracts/metatx/ERC2771Context.sol +./node_modules/@openzeppelin/contracts/metatx/MinimalForwarder.sol +./node_modules/@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol +./node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol +./node_modules/@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol +./node_modules/@openzeppelin/contracts/proxy/Clones.sol +./node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol +./node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol +./node_modules/@openzeppelin/contracts/proxy/Proxy.sol +./node_modules/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol +./node_modules/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +./node_modules/@openzeppelin/contracts/proxy/utils/Initializable.sol +./node_modules/@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol +./node_modules/@openzeppelin/contracts/security/Pausable.sol +./node_modules/@openzeppelin/contracts/security/PullPayment.sol +./node_modules/@openzeppelin/contracts/security/ReentrancyGuard.sol +./node_modules/@openzeppelin/contracts/token/common/ERC2981.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/ERC1155.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol +./node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol +./node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20FlashMint.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20VotesComp.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol +./node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol +./node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol +./node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol +./node_modules/@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol +./node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol +./node_modules/@openzeppelin/contracts/token/ERC20/utils/TokenTimelock.sol +./node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/draft-ERC721Votes.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol +./node_modules/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol +./node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol +./node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol +./node_modules/@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol +./node_modules/@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol +./node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol +./node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol +./node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol +./node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol +./node_modules/@openzeppelin/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol +./node_modules/@openzeppelin/contracts/utils/Address.sol +./node_modules/@openzeppelin/contracts/utils/Arrays.sol +./node_modules/@openzeppelin/contracts/utils/Base64.sol +./node_modules/@openzeppelin/contracts/utils/Checkpoints.sol +./node_modules/@openzeppelin/contracts/utils/Context.sol +./node_modules/@openzeppelin/contracts/utils/Counters.sol +./node_modules/@openzeppelin/contracts/utils/Create2.sol +./node_modules/@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol +./node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol +./node_modules/@openzeppelin/contracts/utils/cryptography/MerkleProof.sol +./node_modules/@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol +./node_modules/@openzeppelin/contracts/utils/escrow/ConditionalEscrow.sol +./node_modules/@openzeppelin/contracts/utils/escrow/Escrow.sol +./node_modules/@openzeppelin/contracts/utils/escrow/RefundEscrow.sol +./node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol +./node_modules/@openzeppelin/contracts/utils/introspection/ERC165Checker.sol +./node_modules/@openzeppelin/contracts/utils/introspection/ERC165Storage.sol +./node_modules/@openzeppelin/contracts/utils/introspection/ERC1820Implementer.sol +./node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol +./node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Implementer.sol +./node_modules/@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol +./node_modules/@openzeppelin/contracts/utils/math/Math.sol +./node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol +./node_modules/@openzeppelin/contracts/utils/math/SafeMath.sol +./node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol +./node_modules/@openzeppelin/contracts/utils/math/SignedSafeMath.sol +./node_modules/@openzeppelin/contracts/utils/Multicall.sol +./node_modules/@openzeppelin/contracts/utils/StorageSlot.sol +./node_modules/@openzeppelin/contracts/utils/Strings.sol +./node_modules/@openzeppelin/contracts/utils/structs/BitMaps.sol +./node_modules/@openzeppelin/contracts/utils/structs/DoubleEndedQueue.sol +./node_modules/@openzeppelin/contracts/utils/structs/EnumerableMap.sol +./node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol +./node_modules/@openzeppelin/contracts/utils/Timers.sol +./node_modules/@openzeppelin/contracts/vendor/amb/IAMB.sol +./node_modules/@openzeppelin/contracts/vendor/arbitrum/IArbSys.sol +./node_modules/@openzeppelin/contracts/vendor/arbitrum/IBridge.sol +./node_modules/@openzeppelin/contracts/vendor/arbitrum/IInbox.sol +./node_modules/@openzeppelin/contracts/vendor/arbitrum/IMessageProvider.sol +./node_modules/@openzeppelin/contracts/vendor/arbitrum/IOutbox.sol +./node_modules/@openzeppelin/contracts/vendor/compound/ICompoundTimelock.sol +./node_modules/@openzeppelin/contracts/vendor/optimism/ICrossDomainMessenger.sol +./node_modules/@openzeppelin/contracts/vendor/polygon/IFxMessageProcessor.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3FlashCallback.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/IERC20Minimal.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/IUniswapV3PoolDeployer.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolActions.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol +./node_modules/@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol +./node_modules/@uniswap/v3-core/contracts/libraries/BitMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/FixedPoint128.sol +./node_modules/@uniswap/v3-core/contracts/libraries/FixedPoint96.sol +./node_modules/@uniswap/v3-core/contracts/libraries/FullMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/LiquidityMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/Oracle.sol +./node_modules/@uniswap/v3-core/contracts/libraries/Position.sol +./node_modules/@uniswap/v3-core/contracts/libraries/SafeCast.sol +./node_modules/@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/SwapMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/Tick.sol +./node_modules/@uniswap/v3-core/contracts/libraries/TickBitmap.sol +./node_modules/@uniswap/v3-core/contracts/libraries/TickMath.sol +./node_modules/@uniswap/v3-core/contracts/libraries/TransferHelper.sol +./node_modules/@uniswap/v3-core/contracts/libraries/UnsafeMath.sol diff --git a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts index c9b88c9805..6e09dc1914 100644 --- a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts @@ -1,10 +1,10 @@ import { sourceMappingDecoder } from "@remix-project/remix-debug" import { AstNode } from "@remix-project/remix-solidity-ts" -import { isArray } from "lodash" +import { isArray, last } from "lodash" import { editor, languages, Position } from "monaco-editor" import monaco from "../../types/monaco" import { EditorUIProps } from "../remix-ui-editor" -import { GeCompletionUnits, GetCompletionKeywords, getCompletionSnippets, GetCompletionTypes, getContextualAutoCompleteBTypeName, getContextualAutoCompleteByGlobalVariable, GetGlobalFunctions, GetGlobalVariable, GetImports } from "./completion/completionGlobals" +import { GeCompletionUnits, GetCompletionKeywords, getCompletionSnippets, GetCompletionTypes, getContextualAutoCompleteBTypeName, getContextualAutoCompleteByGlobalVariable, GetContractRepositories, GetGlobalFunctions, GetGlobalVariable, GetImports } from "./completion/completionGlobals" export class RemixCompletionProvider implements languages.CompletionItemProvider { @@ -16,7 +16,7 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider this.monaco = monaco } - triggerCharacters = ['.', '', '"'] + triggerCharacters = ['.', '', '"', '@', '/'] async provideCompletionItems(model: editor.ITextModel, position: Position, context: monaco.languages.CompletionContext): Promise { const completionSettings = await this.props.plugin.call('config', 'getAppParameter', 'settings/auto-completion') @@ -28,21 +28,31 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider startColumn: word.startColumn, endColumn: word.endColumn }; - + console.log(word) const line = model.getLineContent(position.lineNumber) let nodes: AstNode[] = [] let suggestions: monaco.languages.CompletionItem[] = [] - - if (context.triggerCharacter === '"') { - - const ast = await this.props.plugin.call('codeParser', 'parseSolidity', line) - if (ast && ast.children && ast.children[0] && ast.children[0].type === "ImportDirective") { - suggestions = [...suggestions, - ...GetImports(range, this.monaco), - ] - - }else{ - return + console.log('context', context.triggerCharacter) + + if (context.triggerCharacter === '"' || context.triggerCharacter === '@' || context.triggerCharacter === '/') { + + const lastpart = line.substring(0, position.column - 1).split(';').pop() + console.log('lastpart', lastpart) + if (lastpart.startsWith('import')) { + const imports = await this.props.plugin.call('codeParser', 'getImports') + if (context.triggerCharacter === '"' || context.triggerCharacter === '@') { + suggestions = [...suggestions, + ...GetImports(range, this.monaco, imports, context.triggerCharacter), + ] + } else if (context.triggerCharacter === '/') { + const word = line.split('"')[1] + console.log(word) + suggestions = [...suggestions, + ...GetImports(range, this.monaco, imports, word), + ] + } else { + return + } } } else diff --git a/package.json b/package.json index 8399c040bc..e73b61e6ee 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,8 @@ "test-browser": "npm-run-all -lpr selenium make-mock-compiler serve browsertest", "watch": "watchify apps/remix-ide/src/index.js -dv -p browserify-reload -o apps/remix-ide/build/app.js --exclude solc", "reinstall": "rm ./node-modules/ -rf && rm yarn.lock && rm ./build/ -rf && yarn install & yarn run build", - "ganache-cli": "npx ganache-cli" + "ganache-cli": "npx ganache-cli", + "build-contracts": "find ./node_modules/@openzeppelin/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" }, "browserify": { "transform": [ @@ -234,6 +235,7 @@ "@babel/preset-typescript": "7.9.0", "@babel/register": "^7.4.4", "@fortawesome/fontawesome-free": "^5.8.1", + "@hq20/contracts": "^0.0.6", "@nrwl/cli": "12.3.6", "@nrwl/eslint-plugin-nx": "12.3.6", "@nrwl/jest": "12.3.6", @@ -261,6 +263,8 @@ "@types/ws": "^7.2.4", "@typescript-eslint/eslint-plugin": "^4.32.0", "@typescript-eslint/parser": "^4.32.0", + "@uniswap/v2-core": "^1.0.1", + "@uniswap/v3-core": "^1.0.1", "ace-mode-lexon": "^1.*.*", "ace-mode-move": "0.0.1", "ace-mode-solidity": "^0.1.0", diff --git a/yarn.lock b/yarn.lock index 3809c46cb6..d5e5cff8a1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2475,6 +2475,11 @@ resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.2.tgz#30aa825f11d438671d585bd44e7fd564535fc210" integrity sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw== +"@hq20/contracts@^0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@hq20/contracts/-/contracts-0.0.6.tgz#fc0a05884294da8757c4187f8567638982b74b6a" + integrity sha512-l94ARK0LfcRY7Y5EiInA+0vdXh8lnkTRAw9unli7UC75DY7aBMJl4OqTT5SMdm/n4N1dVVhCnyCM1W84UAx2Vw== + "@isomorphic-git/idb-keyval@3.3.2": version "3.3.2" resolved "https://registry.yarnpkg.com/@isomorphic-git/idb-keyval/-/idb-keyval-3.3.2.tgz#c0509a6c5987d8a62efb3e47f2815bcc5eda2489" @@ -4806,6 +4811,16 @@ resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== +"@uniswap/v2-core@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@uniswap/v2-core/-/v2-core-1.0.1.tgz#af8f508bf183204779938969e2e54043e147d425" + integrity sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q== + +"@uniswap/v3-core@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@uniswap/v3-core/-/v3-core-1.0.1.tgz#b6d2bdc6ba3c3fbd610bdc502395d86cd35264a0" + integrity sha512-7pVk4hEm00j9tc71Y9+ssYpO6ytkeI0y7WE9P6UcmNzhxPePwyAxImuhVsTqWK9YFvzgtvzJHi64pBl4jUzKMQ== + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" From 74efbe03a2b7ae7126b0eadc5fc78c2818d6874d Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 00:50:45 +0200 Subject: [PATCH 08/60] rm file --- .../contracts/OpenZeppelinContracts.txt | 278 ------------------ 1 file changed, 278 deletions(-) delete mode 100644 libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt diff --git a/libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt b/libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt deleted file mode 100644 index cffe37a8a7..0000000000 --- a/libs/remix-ui/editor/src/lib/providers/completion/contracts/OpenZeppelinContracts.txt +++ /dev/null @@ -1,278 +0,0 @@ -/contracts/access/AccessControl.sol -/contracts/access/AccessControlCrossChain.sol -/contracts/access/AccessControlEnumerable.sol -/contracts/access/IAccessControl.sol -/contracts/access/IAccessControlEnumerable.sol -/contracts/access/Ownable.sol -/contracts/access/Ownable2Step.sol -/contracts/crosschain/amb/CrossChainEnabledAMB.sol -/contracts/crosschain/amb/LibAMB.sol -/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL1.sol -/contracts/crosschain/arbitrum/CrossChainEnabledArbitrumL2.sol -/contracts/crosschain/arbitrum/LibArbitrumL1.sol -/contracts/crosschain/arbitrum/LibArbitrumL2.sol -/contracts/crosschain/CrossChainEnabled.sol -/contracts/crosschain/errors.sol -/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol -/contracts/crosschain/optimism/LibOptimism.sol -/contracts/crosschain/polygon/CrossChainEnabledPolygonChild.sol -/contracts/finance/PaymentSplitter.sol -/contracts/finance/VestingWallet.sol -/contracts/governance/compatibility/GovernorCompatibilityBravo.sol -/contracts/governance/compatibility/IGovernorCompatibilityBravo.sol -/contracts/governance/extensions/GovernorCountingSimple.sol -/contracts/governance/extensions/GovernorPreventLateQuorum.sol -/contracts/governance/extensions/GovernorProposalThreshold.sol -/contracts/governance/extensions/GovernorSettings.sol -/contracts/governance/extensions/GovernorTimelockCompound.sol -/contracts/governance/extensions/GovernorTimelockControl.sol -/contracts/governance/extensions/GovernorVotes.sol -/contracts/governance/extensions/GovernorVotesComp.sol -/contracts/governance/extensions/GovernorVotesQuorumFraction.sol -/contracts/governance/extensions/IGovernorTimelock.sol -/contracts/governance/Governor.sol -/contracts/governance/IGovernor.sol -/contracts/governance/TimelockController.sol -/contracts/governance/utils/IVotes.sol -/contracts/governance/utils/Votes.sol -/contracts/interfaces/draft-IERC1822.sol -/contracts/interfaces/draft-IERC2612.sol -/contracts/interfaces/IERC1155.sol -/contracts/interfaces/IERC1155MetadataURI.sol -/contracts/interfaces/IERC1155Receiver.sol -/contracts/interfaces/IERC1271.sol -/contracts/interfaces/IERC1363.sol -/contracts/interfaces/IERC1363Receiver.sol -/contracts/interfaces/IERC1363Spender.sol -/contracts/interfaces/IERC165.sol -/contracts/interfaces/IERC1820Implementer.sol -/contracts/interfaces/IERC1820Registry.sol -/contracts/interfaces/IERC20.sol -/contracts/interfaces/IERC20Metadata.sol -/contracts/interfaces/IERC2309.sol -/contracts/interfaces/IERC2981.sol -/contracts/interfaces/IERC3156.sol -/contracts/interfaces/IERC3156FlashBorrower.sol -/contracts/interfaces/IERC3156FlashLender.sol -/contracts/interfaces/IERC4626.sol -/contracts/interfaces/IERC721.sol -/contracts/interfaces/IERC721Enumerable.sol -/contracts/interfaces/IERC721Metadata.sol -/contracts/interfaces/IERC721Receiver.sol -/contracts/interfaces/IERC777.sol -/contracts/interfaces/IERC777Recipient.sol -/contracts/interfaces/IERC777Sender.sol -/contracts/metatx/ERC2771Context.sol -/contracts/metatx/MinimalForwarder.sol -/contracts/mocks/AccessControlCrossChainMock.sol -/contracts/mocks/AccessControlEnumerableMock.sol -/contracts/mocks/AccessControlMock.sol -/contracts/mocks/AddressImpl.sol -/contracts/mocks/ArraysMock.sol -/contracts/mocks/BadBeacon.sol -/contracts/mocks/Base64Mock.sol -/contracts/mocks/BitmapMock.sol -/contracts/mocks/CallReceiverMock.sol -/contracts/mocks/CheckpointsMock.sol -/contracts/mocks/ClashingImplementation.sol -/contracts/mocks/ClonesMock.sol -/contracts/mocks/compound/CompTimelock.sol -/contracts/mocks/ConditionalEscrowMock.sol -/contracts/mocks/ContextMock.sol -/contracts/mocks/CountersImpl.sol -/contracts/mocks/Create2Impl.sol -/contracts/mocks/crosschain/bridges.sol -/contracts/mocks/crosschain/receivers.sol -/contracts/mocks/DoubleEndedQueueMock.sol -/contracts/mocks/DummyImplementation.sol -/contracts/mocks/ECDSAMock.sol -/contracts/mocks/EIP712External.sol -/contracts/mocks/EnumerableMapMock.sol -/contracts/mocks/EnumerableSetMock.sol -/contracts/mocks/ERC1155BurnableMock.sol -/contracts/mocks/ERC1155Mock.sol -/contracts/mocks/ERC1155PausableMock.sol -/contracts/mocks/ERC1155ReceiverMock.sol -/contracts/mocks/ERC1155SupplyMock.sol -/contracts/mocks/ERC1155URIStorageMock.sol -/contracts/mocks/ERC1271WalletMock.sol -/contracts/mocks/ERC165/ERC165InterfacesSupported.sol -/contracts/mocks/ERC165/ERC165MaliciousData.sol -/contracts/mocks/ERC165/ERC165MissingData.sol -/contracts/mocks/ERC165/ERC165NotSupported.sol -/contracts/mocks/ERC165/ERC165ReturnBomb.sol -/contracts/mocks/ERC165CheckerMock.sol -/contracts/mocks/ERC165Mock.sol -/contracts/mocks/ERC165StorageMock.sol -/contracts/mocks/ERC1820ImplementerMock.sol -/contracts/mocks/ERC20BurnableMock.sol -/contracts/mocks/ERC20CappedMock.sol -/contracts/mocks/ERC20DecimalsMock.sol -/contracts/mocks/ERC20FlashMintMock.sol -/contracts/mocks/ERC20Mock.sol -/contracts/mocks/ERC20PausableMock.sol -/contracts/mocks/ERC20PermitMock.sol -/contracts/mocks/ERC20SnapshotMock.sol -/contracts/mocks/ERC20VotesCompMock.sol -/contracts/mocks/ERC20VotesMock.sol -/contracts/mocks/ERC20WrapperMock.sol -/contracts/mocks/ERC2771ContextMock.sol -/contracts/mocks/ERC3156FlashBorrowerMock.sol -/contracts/mocks/ERC4626Mock.sol -/contracts/mocks/ERC721BurnableMock.sol -/contracts/mocks/ERC721ConsecutiveMock.sol -/contracts/mocks/ERC721EnumerableMock.sol -/contracts/mocks/ERC721Mock.sol -/contracts/mocks/ERC721PausableMock.sol -/contracts/mocks/ERC721ReceiverMock.sol -/contracts/mocks/ERC721RoyaltyMock.sol -/contracts/mocks/ERC721URIStorageMock.sol -/contracts/mocks/ERC721VotesMock.sol -/contracts/mocks/ERC777Mock.sol -/contracts/mocks/ERC777SenderRecipientMock.sol -/contracts/mocks/EtherReceiverMock.sol -/contracts/mocks/GovernorCompatibilityBravoMock.sol -/contracts/mocks/GovernorCompMock.sol -/contracts/mocks/GovernorMock.sol -/contracts/mocks/GovernorPreventLateQuorumMock.sol -/contracts/mocks/GovernorTimelockCompoundMock.sol -/contracts/mocks/GovernorTimelockControlMock.sol -/contracts/mocks/GovernorVoteMock.sol -/contracts/mocks/GovernorWithParamsMock.sol -/contracts/mocks/InitializableMock.sol -/contracts/mocks/MathMock.sol -/contracts/mocks/MerkleProofWrapper.sol -/contracts/mocks/MulticallTest.sol -/contracts/mocks/MulticallTokenMock.sol -/contracts/mocks/MultipleInheritanceInitializableMocks.sol -/contracts/mocks/Ownable2StepMock.sol -/contracts/mocks/OwnableMock.sol -/contracts/mocks/PausableMock.sol -/contracts/mocks/PullPaymentMock.sol -/contracts/mocks/ReentrancyAttack.sol -/contracts/mocks/ReentrancyMock.sol -/contracts/mocks/RegressionImplementation.sol -/contracts/mocks/SafeCastMock.sol -/contracts/mocks/SafeERC20Helper.sol -/contracts/mocks/SafeMathMock.sol -/contracts/mocks/SignatureCheckerMock.sol -/contracts/mocks/SignedMathMock.sol -/contracts/mocks/SignedSafeMathMock.sol -/contracts/mocks/SingleInheritanceInitializableMocks.sol -/contracts/mocks/StorageSlotMock.sol -/contracts/mocks/StringsMock.sol -/contracts/mocks/TimersBlockNumberImpl.sol -/contracts/mocks/TimersTimestampImpl.sol -/contracts/mocks/UUPS/UUPSLegacy.sol -/contracts/mocks/UUPS/UUPSUpgradeableMock.sol -/contracts/mocks/VotesMock.sol -/contracts/mocks/wizard/MyGovernor1.sol -/contracts/mocks/wizard/MyGovernor2.sol -/contracts/mocks/wizard/MyGovernor3.sol -/contracts/proxy/beacon/BeaconProxy.sol -/contracts/proxy/beacon/IBeacon.sol -/contracts/proxy/beacon/UpgradeableBeacon.sol -/contracts/proxy/Clones.sol -/contracts/proxy/ERC1967/ERC1967Proxy.sol -/contracts/proxy/ERC1967/ERC1967Upgrade.sol -/contracts/proxy/Proxy.sol -/contracts/proxy/transparent/ProxyAdmin.sol -/contracts/proxy/transparent/TransparentUpgradeableProxy.sol -/contracts/proxy/utils/Initializable.sol -/contracts/proxy/utils/UUPSUpgradeable.sol -/contracts/security/Pausable.sol -/contracts/security/PullPayment.sol -/contracts/security/ReentrancyGuard.sol -/contracts/token/common/ERC2981.sol -/contracts/token/ERC1155/ERC1155.sol -/contracts/token/ERC1155/extensions/ERC1155Burnable.sol -/contracts/token/ERC1155/extensions/ERC1155Pausable.sol -/contracts/token/ERC1155/extensions/ERC1155Supply.sol -/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol -/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol -/contracts/token/ERC1155/IERC1155.sol -/contracts/token/ERC1155/IERC1155Receiver.sol -/contracts/token/ERC1155/presets/ERC1155PresetMinterPauser.sol -/contracts/token/ERC1155/utils/ERC1155Holder.sol -/contracts/token/ERC1155/utils/ERC1155Receiver.sol -/contracts/token/ERC20/ERC20.sol -/contracts/token/ERC20/extensions/draft-ERC20Permit.sol -/contracts/token/ERC20/extensions/draft-IERC20Permit.sol -/contracts/token/ERC20/extensions/ERC20Burnable.sol -/contracts/token/ERC20/extensions/ERC20Capped.sol -/contracts/token/ERC20/extensions/ERC20FlashMint.sol -/contracts/token/ERC20/extensions/ERC20Pausable.sol -/contracts/token/ERC20/extensions/ERC20Snapshot.sol -/contracts/token/ERC20/extensions/ERC20Votes.sol -/contracts/token/ERC20/extensions/ERC20VotesComp.sol -/contracts/token/ERC20/extensions/ERC20Wrapper.sol -/contracts/token/ERC20/extensions/ERC4626.sol -/contracts/token/ERC20/extensions/IERC20Metadata.sol -/contracts/token/ERC20/IERC20.sol -/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol -/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol -/contracts/token/ERC20/utils/SafeERC20.sol -/contracts/token/ERC20/utils/TokenTimelock.sol -/contracts/token/ERC721/ERC721.sol -/contracts/token/ERC721/extensions/draft-ERC721Votes.sol -/contracts/token/ERC721/extensions/ERC721Burnable.sol -/contracts/token/ERC721/extensions/ERC721Consecutive.sol -/contracts/token/ERC721/extensions/ERC721Enumerable.sol -/contracts/token/ERC721/extensions/ERC721Pausable.sol -/contracts/token/ERC721/extensions/ERC721Royalty.sol -/contracts/token/ERC721/extensions/ERC721URIStorage.sol -/contracts/token/ERC721/extensions/IERC721Enumerable.sol -/contracts/token/ERC721/extensions/IERC721Metadata.sol -/contracts/token/ERC721/IERC721.sol -/contracts/token/ERC721/IERC721Receiver.sol -/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol -/contracts/token/ERC721/utils/ERC721Holder.sol -/contracts/token/ERC777/ERC777.sol -/contracts/token/ERC777/IERC777.sol -/contracts/token/ERC777/IERC777Recipient.sol -/contracts/token/ERC777/IERC777Sender.sol -/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol -/contracts/utils/Address.sol -/contracts/utils/Arrays.sol -/contracts/utils/Base64.sol -/contracts/utils/Checkpoints.sol -/contracts/utils/Context.sol -/contracts/utils/Counters.sol -/contracts/utils/Create2.sol -/contracts/utils/cryptography/draft-EIP712.sol -/contracts/utils/cryptography/ECDSA.sol -/contracts/utils/cryptography/EIP712.sol -/contracts/utils/cryptography/MerkleProof.sol -/contracts/utils/cryptography/SignatureChecker.sol -/contracts/utils/escrow/ConditionalEscrow.sol -/contracts/utils/escrow/Escrow.sol -/contracts/utils/escrow/RefundEscrow.sol -/contracts/utils/introspection/ERC165.sol -/contracts/utils/introspection/ERC165Checker.sol -/contracts/utils/introspection/ERC165Storage.sol -/contracts/utils/introspection/ERC1820Implementer.sol -/contracts/utils/introspection/IERC165.sol -/contracts/utils/introspection/IERC1820Implementer.sol -/contracts/utils/introspection/IERC1820Registry.sol -/contracts/utils/math/Math.sol -/contracts/utils/math/SafeCast.sol -/contracts/utils/math/SafeMath.sol -/contracts/utils/math/SignedMath.sol -/contracts/utils/math/SignedSafeMath.sol -/contracts/utils/Multicall.sol -/contracts/utils/StorageSlot.sol -/contracts/utils/Strings.sol -/contracts/utils/structs/BitMaps.sol -/contracts/utils/structs/DoubleEndedQueue.sol -/contracts/utils/structs/EnumerableMap.sol -/contracts/utils/structs/EnumerableSet.sol -/contracts/utils/Timers.sol -/contracts/vendor/amb/IAMB.sol -/contracts/vendor/arbitrum/IArbSys.sol -/contracts/vendor/arbitrum/IBridge.sol -/contracts/vendor/arbitrum/IInbox.sol -/contracts/vendor/arbitrum/IMessageProvider.sol -/contracts/vendor/arbitrum/IOutbox.sol -/contracts/vendor/compound/ICompoundTimelock.sol -/contracts/vendor/optimism/ICrossDomainMessenger.sol -/contracts/vendor/polygon/IFxMessageProcessor.sol \ No newline at end of file From 9b5b0dcceecdccc9a6311aaaa641ebf6710d4720 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 00:55:57 +0200 Subject: [PATCH 09/60] rm undefined --- libs/remix-ui/editor/src/lib/providers/completionProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts index 6e09dc1914..78455fbe22 100644 --- a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts @@ -4,7 +4,7 @@ import { isArray, last } from "lodash" import { editor, languages, Position } from "monaco-editor" import monaco from "../../types/monaco" import { EditorUIProps } from "../remix-ui-editor" -import { GeCompletionUnits, GetCompletionKeywords, getCompletionSnippets, GetCompletionTypes, getContextualAutoCompleteBTypeName, getContextualAutoCompleteByGlobalVariable, GetContractRepositories, GetGlobalFunctions, GetGlobalVariable, GetImports } from "./completion/completionGlobals" +import { GeCompletionUnits, GetCompletionKeywords, getCompletionSnippets, GetCompletionTypes, getContextualAutoCompleteBTypeName, getContextualAutoCompleteByGlobalVariable, GetGlobalFunctions, GetGlobalVariable, GetImports } from "./completion/completionGlobals" export class RemixCompletionProvider implements languages.CompletionItemProvider { From 553139a05069391df0d3ce0e2886c1dabdf7b111 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 10:37:57 +0200 Subject: [PATCH 10/60] more error handling --- .../parser/services/code-parser-compiler.ts | 128 ++++++++++++------ .../parser/services/code-parser-imports.ts | 6 +- .../providers/completion/completionGlobals.ts | 7 - .../completion/contracts/contracts.txt | 31 +++++ .../src/lib/providers/completionProvider.ts | 7 +- .../src/lib/providers/definitionProvider.ts | 18 ++- libs/remix-ui/search/src/index.ts | 4 +- package.json | 2 +- 8 files changed, 139 insertions(+), 64 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts index 9acd434728..96daa42f4a 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-compiler.ts @@ -8,22 +8,23 @@ import { fileDecoration, fileDecorationType } from '@remix-ui/file-decorators' import { sourceMappingDecoder } from '@remix-project/remix-debug' import { CompilerRetriggerMode } from '@remix-project/remix-solidity-ts'; import { MarkerSeverity } from 'monaco-editor'; +import { findLinesInStringWithMatch, SearchResultLine } from '@remix-ui/search' type errorMarker = { message: string severity: MarkerSeverity position: { - start: { - line: number - column: number - }, - end: { - line: number - column: number - } + start: { + line: number + column: number + }, + end: { + line: number + column: number + } }, file: string - } +} export default class CodeParserCompiler { plugin: CodeParser compiler: any // used to compile the current file seperately from the main compiler @@ -39,41 +40,51 @@ export default class CodeParserCompiler { init() { this.onAstFinished = async (success, data: CompilationResult, source: CompilationSource, input: any, version) => { - //console.log('onAstFinished', success, data, source, input, version) this.plugin.call('editor', 'clearAnnotations') this.errorState = true const result = new CompilerAbstract('soljson', data, source, input) let allErrors: errorMarker[] = [] - if (data.errors) { - const sources = result.getSourceCode().sources - for (const error of data.errors) { - //console.log(error) - const lineBreaks = sourceMappingDecoder.getLinebreakPositions(sources[error.sourceLocation.file].content) - const lineColumn = sourceMappingDecoder.convertOffsetToLineColumn({ - start: error.sourceLocation.start, - length: error.sourceLocation.end - error.sourceLocation.start - }, lineBreaks) - - const filePath = error.sourceLocation.file - - allErrors = [...allErrors, { - message: error.formattedMessage, - severity: error.severity === 'error' ? MarkerSeverity.Error : MarkerSeverity.Warning, - position: { - start: { - line: ((lineColumn.start && lineColumn.start.line) || 0) + 1, - column: ((lineColumn.start && lineColumn.start.column) || 0) + 1 - }, - end: { - line: ((lineColumn.end && lineColumn.end.line) || 0) + 1, - column: ((lineColumn.end && lineColumn.end.column) || 0) + 1 + if (data.errors || data.error) { + const file = await this.plugin.call('fileManager', 'getCurrentFile') + const currentFileContent = await this.plugin.call('fileManager', 'readFile', file) + const sources = result.getSourceCode().sources || [] + if (data.error) { + if (data.error.formattedMessage) { + // mark this file as error + const errorMarker = await this.createErrorMarker(data.error, file, { start: { line: 0, column: 0 }, end: { line: 0, column: 100 } }) + allErrors = [...allErrors, errorMarker] + } + } else { + for (const error of data.errors) { + if (!error.sourceLocation) { + // mark this file as error + const errorMarker = await this.createErrorMarker(error, file, { start: { line: 0, column: 0 }, end: { line: 0, column: 100 } }) + allErrors = [...allErrors, errorMarker] + } else { + const lineBreaks = sourceMappingDecoder.getLinebreakPositions(sources[error.sourceLocation.file].content) + const lineColumn = sourceMappingDecoder.convertOffsetToLineColumn({ + start: error.sourceLocation.start, + length: error.sourceLocation.end - error.sourceLocation.start + }, lineBreaks) + + + const filePath = error.sourceLocation.file + const fileTarget = await this.plugin.call('fileManager', 'getUrlFromPath', filePath) + + const importFilePositions = await this.getPositionForImportErrors(fileTarget.file, currentFileContent) + for (const importFilePosition of importFilePositions) { + for (const line of importFilePosition.lines) { + allErrors = [...allErrors, await this.createErrorMarker(error, file, line.position)] + } } + + allErrors = [...allErrors, await this.createErrorMarker(error, filePath, lineColumn)] } - , file: filePath - }] + } } + const displayErrors = await this.plugin.call('config', 'getAppParameter', 'display-errors') - if(displayErrors) await this.plugin.call('editor', 'addErrorMarker', allErrors) + if (displayErrors) await this.plugin.call('editor', 'addErrorMarker', allErrors) this.addDecorators(allErrors, sources) } else { await this.plugin.call('editor', 'clearErrorMarkers', result.getSourceCode().sources) @@ -144,14 +155,14 @@ export default class CodeParserCompiler { this.compiler.compile(sources, this.plugin.currentFile) } } catch (e) { - // do nothing + // do nothing } } async addDecorators(allErrors: errorMarker[], sources: any) { const displayErrors = await this.plugin.call('config', 'getAppParameter', 'display-errors') - if(!displayErrors) return - const errorsPerFiles: {[fileName: string]: errorMarker[]} = {} + if (!displayErrors) return + const errorsPerFiles: { [fileName: string]: errorMarker[] } = {} for (const error of allErrors) { if (!errorsPerFiles[error.file]) { errorsPerFiles[error.file] = [] @@ -165,7 +176,7 @@ export default class CodeParserCompiler { } // sort errorPerFiles by error priority - const sortedErrorsPerFiles: {[fileName: string]: errorMarker[]} = {} + const sortedErrorsPerFiles: { [fileName: string]: errorMarker[] } = {} for (const fileName in errorsPerFiles) { const errors = errorsPerFiles[fileName] errors.sort((a, b) => { @@ -179,10 +190,11 @@ export default class CodeParserCompiler { const decorators: fileDecoration[] = [] for (const fileName in sortedErrorsPerFiles) { const errors = sortedErrorsPerFiles[fileName] + const fileTarget = await this.plugin.call('fileManager', 'getPathFromUrl', fileName) const decorator: fileDecoration = { - path: fileName, + path: fileTarget.file, isDirectory: false, - fileStateType: errors[0].severity == MarkerSeverity.Error? fileDecorationType.Error : fileDecorationType.Warning, + fileStateType: errors[0].severity == MarkerSeverity.Error ? fileDecorationType.Error : fileDecorationType.Warning, fileStateLabelClass: errors[0].severity == MarkerSeverity.Error ? 'text-danger' : 'text-warning', fileStateIconClass: '', fileStateIcon: '', @@ -194,8 +206,9 @@ export default class CodeParserCompiler { decorators.push(decorator) } for (const fileName of filesWithOutErrors) { + const fileTarget = await this.plugin.call('fileManager', 'getPathFromUrl', fileName) const decorator: fileDecoration = { - path: fileName, + path: fileTarget.file, isDirectory: false, fileStateType: fileDecorationType.None, fileStateLabelClass: '', @@ -212,9 +225,27 @@ export default class CodeParserCompiler { } + async createErrorMarker(error: any, filePath: string, lineColumn): Promise { + return { + message: error.formattedMessage, + severity: error.severity === 'error' ? MarkerSeverity.Error : MarkerSeverity.Warning, + position: { + start: { + line: ((lineColumn.start && lineColumn.start.line) || 0) + 1, + column: ((lineColumn.start && lineColumn.start.column) || 0) + 1 + }, + end: { + line: ((lineColumn.end && lineColumn.end.line) || 0) + 1, + column: ((lineColumn.end && lineColumn.end.column) || 0) + 1 + } + } + , file: filePath + } + } + async clearDecorators(sources: any) { const decorators: fileDecoration[] = [] - if(!sources) return + if (!sources) return for (const fileName of Object.keys(sources)) { const decorator: fileDecoration = { path: fileName, @@ -234,4 +265,13 @@ export default class CodeParserCompiler { await this.plugin.call('fileDecorator', 'setFileDecorators', decorators) } + async getPositionForImportErrors(importedFileName: string, text: string) { + const re = new RegExp(importedFileName, 'gi') + const result: SearchResultLine[] = findLinesInStringWithMatch( + text, + re + ) + return result + } + } \ No newline at end of file diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts index d2261c3154..9eaef92dd9 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts @@ -23,8 +23,6 @@ export default class CodeParserImports { async init() { // @ts-ignore const txt = await import('raw-loader!libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt') - - // eslint-disable-next-line @typescript-eslint/no-unused-vars this.data.modules = txt.default.split('\n') .filter(x => x !== '') .map(x => x.replace('./node_modules/', '')) @@ -38,13 +36,11 @@ export default class CodeParserImports { // get unique first words of the values in the array this.data.packages = [...new Set(this.data.modules.map(x => x.split('/')[0]))] - console.log(this.data) } setFileTree = async () => { this.data.files = await this.getDirectory('/') - this.data.files = this.data.files.filter(x => x.endsWith('.sol') && !x.startsWith('.deps')) - console.log(this.data) + this.data.files = this.data.files.filter(x => x.endsWith('.sol') && !x.startsWith('.deps') && !x.startsWith('.git')) } getDirectory = async (dir: string) => { diff --git a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts index ac8e3b9a61..4d69093b1c 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts +++ b/libs/remix-ui/editor/src/lib/providers/completion/completionGlobals.ts @@ -183,13 +183,6 @@ export function getCompletionSnippets(range: IRange, monaco): monaco.languages.C insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, range }, - { - label: 'import', - kind: monaco.languages.CompletionItemKind.Snippet, - insertText: 'import "${1:library}";', - insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, - range - }, { label: 'SPDX-License-Identifier', kind: monaco.languages.CompletionItemKind.Snippet, diff --git a/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt b/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt index 94615103e0..8342638bf6 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt +++ b/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt @@ -1,3 +1,34 @@ +./node_modules/@hq20/contracts/contracts/access/AccessControlBasic.sol +./node_modules/@hq20/contracts/contracts/access/Administered.sol +./node_modules/@hq20/contracts/contracts/access/AuthorizedAccess.sol +./node_modules/@hq20/contracts/contracts/access/Community.sol +./node_modules/@hq20/contracts/contracts/access/Democracy.sol +./node_modules/@hq20/contracts/contracts/access/Hierarchy.sol +./node_modules/@hq20/contracts/contracts/classifieds/Classifieds.sol +./node_modules/@hq20/contracts/contracts/dao/DAO.sol +./node_modules/@hq20/contracts/contracts/dao/VentureEth.sol +./node_modules/@hq20/contracts/contracts/energy/EnergyMarket.sol +./node_modules/@hq20/contracts/contracts/exchange/UniswapExchange.sol +./node_modules/@hq20/contracts/contracts/exchange/UniswapFactory.sol +./node_modules/@hq20/contracts/contracts/introspection/erc165/ERC20Whitelisted.sol +./node_modules/@hq20/contracts/contracts/introspection/erc165/IWhitelist.sol +./node_modules/@hq20/contracts/contracts/introspection/erc165/WhitelistERC165.sol +./node_modules/@hq20/contracts/contracts/introspection/erc165/WhitelistInterfaceId.sol +./node_modules/@hq20/contracts/contracts/issuance/Issuance.sol +./node_modules/@hq20/contracts/contracts/issuance/IssuanceEth.sol +./node_modules/@hq20/contracts/contracts/lists/DoubleLinkedList.sol +./node_modules/@hq20/contracts/contracts/lists/LinkedList.sol +./node_modules/@hq20/contracts/contracts/math/DecimalMath.sol +./node_modules/@hq20/contracts/contracts/state/StateMachine.sol +./node_modules/@hq20/contracts/contracts/token/ERC20DividendableEth.sol +./node_modules/@hq20/contracts/contracts/token/ERC20Mintable.sol +./node_modules/@hq20/contracts/contracts/token/ERC721Mintable.sol +./node_modules/@hq20/contracts/contracts/token/IERC20Detailed.sol +./node_modules/@hq20/contracts/contracts/token/IERC20Mintable.sol +./node_modules/@hq20/contracts/contracts/utils/SafeCast.sol +./node_modules/@hq20/contracts/contracts/voting/Democratic.sol +./node_modules/@hq20/contracts/contracts/voting/OneManOneVote.sol +./node_modules/@hq20/contracts/contracts/voting/OneTokenOneVote.sol ./node_modules/@openzeppelin/contracts/access/AccessControl.sol ./node_modules/@openzeppelin/contracts/access/AccessControlCrossChain.sol ./node_modules/@openzeppelin/contracts/access/AccessControlEnumerable.sol diff --git a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts index 78455fbe22..dafcd10011 100644 --- a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts @@ -28,16 +28,16 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider startColumn: word.startColumn, endColumn: word.endColumn }; - console.log(word) + const line = model.getLineContent(position.lineNumber) let nodes: AstNode[] = [] let suggestions: monaco.languages.CompletionItem[] = [] - console.log('context', context.triggerCharacter) + if (context.triggerCharacter === '"' || context.triggerCharacter === '@' || context.triggerCharacter === '/') { const lastpart = line.substring(0, position.column - 1).split(';').pop() - console.log('lastpart', lastpart) + if (lastpart.startsWith('import')) { const imports = await this.props.plugin.call('codeParser', 'getImports') if (context.triggerCharacter === '"' || context.triggerCharacter === '@') { @@ -46,7 +46,6 @@ export class RemixCompletionProvider implements languages.CompletionItemProvider ] } else if (context.triggerCharacter === '/') { const word = line.split('"')[1] - console.log(word) suggestions = [...suggestions, ...GetImports(range, this.monaco, imports, word), ] diff --git a/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts b/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts index d6236cb5e3..9d6daee730 100644 --- a/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/definitionProvider.ts @@ -13,8 +13,22 @@ export class RemixDefinitionProvider implements monaco.languages.DefinitionProvi // eslint-disable-next-line @typescript-eslint/no-unused-vars async provideDefinition(model: monaco.editor.ITextModel, position: monaco.Position, token: monaco.CancellationToken): Promise { const cursorPosition = this.props.editorAPI.getCursorPosition() - const jumpLocation = await this.jumpToDefinition(cursorPosition) - + let jumpLocation = await this.jumpToDefinition(cursorPosition) + if (!jumpLocation || !jumpLocation.fileName) { + const line = model.getLineContent(position.lineNumber) + const lastpart = line.substring(0, position.column - 1).split(';').pop() + if (lastpart.startsWith('import')) { + const importPath = line.substring(lastpart.indexOf('"') + 1) + const importPath2 = importPath.substring(0, importPath.indexOf('"')) + jumpLocation = { + startLineNumber: 1, + startColumn: 1, + endColumn: 1, + endLineNumber: 1, + fileName: importPath2 + } + } + } return [{ uri: this.monaco.Uri.parse(jumpLocation.fileName), range: { diff --git a/libs/remix-ui/search/src/index.ts b/libs/remix-ui/search/src/index.ts index 8617e2ddff..72588397c4 100644 --- a/libs/remix-ui/search/src/index.ts +++ b/libs/remix-ui/search/src/index.ts @@ -1 +1,3 @@ -export { SearchTab } from './lib/components/Search'; \ No newline at end of file +export { SearchTab } from './lib/components/Search'; +export * from './lib/components/results/SearchHelper'; +export * from './lib/types'; \ No newline at end of file diff --git a/package.json b/package.json index e73b61e6ee..e41139dd69 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "watch": "watchify apps/remix-ide/src/index.js -dv -p browserify-reload -o apps/remix-ide/build/app.js --exclude solc", "reinstall": "rm ./node-modules/ -rf && rm yarn.lock && rm ./build/ -rf && yarn install & yarn run build", "ganache-cli": "npx ganache-cli", - "build-contracts": "find ./node_modules/@openzeppelin/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" + "build-contracts": "find ./node_modules/@hq20/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@openzeppelin/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" }, "browserify": { "transform": [ From 6a7f56af2eac340fbc2627ff9ca82be45e7a2f29 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 10:42:40 +0200 Subject: [PATCH 11/60] lint --- libs/remix-ui/editor/src/lib/providers/completionProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts index dafcd10011..7202b1076a 100644 --- a/libs/remix-ui/editor/src/lib/providers/completionProvider.ts +++ b/libs/remix-ui/editor/src/lib/providers/completionProvider.ts @@ -1,6 +1,6 @@ import { sourceMappingDecoder } from "@remix-project/remix-debug" import { AstNode } from "@remix-project/remix-solidity-ts" -import { isArray, last } from "lodash" +import { isArray } from "lodash" import { editor, languages, Position } from "monaco-editor" import monaco from "../../types/monaco" import { EditorUIProps } from "../remix-ui-editor" From 733a3569e9ccbfa9776bcb6a405dd3cfc133ab65 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 10:58:46 +0200 Subject: [PATCH 12/60] events --- apps/remix-ide/src/app/plugins/parser/code-parser.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx index 9b51e42a4e..4e8db57d56 100644 --- a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx +++ b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx @@ -127,6 +127,14 @@ export class CodeParser extends Plugin { await this.importService.setFileTree() }) + this.on('fileManager', 'fileAdded', async () => { + await this.importService.setFileTree() + }) + this.on('fileManager', 'fileRemoved', async () => { + await this.importService.setFileTree() + }) + + this.on('fileManager', 'currentFileChanged', async () => { await this.call('editor', 'discardLineTexts') From 077a15f548a01e4b1b77f8b88fceddad5c4f1bd7 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 11:02:32 +0200 Subject: [PATCH 13/60] rm module --- .../completion/contracts/contracts.txt | 31 ------------------- package.json | 3 +- yarn.lock | 5 --- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt b/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt index 8342638bf6..94615103e0 100644 --- a/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt +++ b/libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt @@ -1,34 +1,3 @@ -./node_modules/@hq20/contracts/contracts/access/AccessControlBasic.sol -./node_modules/@hq20/contracts/contracts/access/Administered.sol -./node_modules/@hq20/contracts/contracts/access/AuthorizedAccess.sol -./node_modules/@hq20/contracts/contracts/access/Community.sol -./node_modules/@hq20/contracts/contracts/access/Democracy.sol -./node_modules/@hq20/contracts/contracts/access/Hierarchy.sol -./node_modules/@hq20/contracts/contracts/classifieds/Classifieds.sol -./node_modules/@hq20/contracts/contracts/dao/DAO.sol -./node_modules/@hq20/contracts/contracts/dao/VentureEth.sol -./node_modules/@hq20/contracts/contracts/energy/EnergyMarket.sol -./node_modules/@hq20/contracts/contracts/exchange/UniswapExchange.sol -./node_modules/@hq20/contracts/contracts/exchange/UniswapFactory.sol -./node_modules/@hq20/contracts/contracts/introspection/erc165/ERC20Whitelisted.sol -./node_modules/@hq20/contracts/contracts/introspection/erc165/IWhitelist.sol -./node_modules/@hq20/contracts/contracts/introspection/erc165/WhitelistERC165.sol -./node_modules/@hq20/contracts/contracts/introspection/erc165/WhitelistInterfaceId.sol -./node_modules/@hq20/contracts/contracts/issuance/Issuance.sol -./node_modules/@hq20/contracts/contracts/issuance/IssuanceEth.sol -./node_modules/@hq20/contracts/contracts/lists/DoubleLinkedList.sol -./node_modules/@hq20/contracts/contracts/lists/LinkedList.sol -./node_modules/@hq20/contracts/contracts/math/DecimalMath.sol -./node_modules/@hq20/contracts/contracts/state/StateMachine.sol -./node_modules/@hq20/contracts/contracts/token/ERC20DividendableEth.sol -./node_modules/@hq20/contracts/contracts/token/ERC20Mintable.sol -./node_modules/@hq20/contracts/contracts/token/ERC721Mintable.sol -./node_modules/@hq20/contracts/contracts/token/IERC20Detailed.sol -./node_modules/@hq20/contracts/contracts/token/IERC20Mintable.sol -./node_modules/@hq20/contracts/contracts/utils/SafeCast.sol -./node_modules/@hq20/contracts/contracts/voting/Democratic.sol -./node_modules/@hq20/contracts/contracts/voting/OneManOneVote.sol -./node_modules/@hq20/contracts/contracts/voting/OneTokenOneVote.sol ./node_modules/@openzeppelin/contracts/access/AccessControl.sol ./node_modules/@openzeppelin/contracts/access/AccessControlCrossChain.sol ./node_modules/@openzeppelin/contracts/access/AccessControlEnumerable.sol diff --git a/package.json b/package.json index e41139dd69..d3dd0f493e 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "watch": "watchify apps/remix-ide/src/index.js -dv -p browserify-reload -o apps/remix-ide/build/app.js --exclude solc", "reinstall": "rm ./node-modules/ -rf && rm yarn.lock && rm ./build/ -rf && yarn install & yarn run build", "ganache-cli": "npx ganache-cli", - "build-contracts": "find ./node_modules/@hq20/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@openzeppelin/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" + "build-contracts": "find ./node_modules/@openzeppelin/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" }, "browserify": { "transform": [ @@ -235,7 +235,6 @@ "@babel/preset-typescript": "7.9.0", "@babel/register": "^7.4.4", "@fortawesome/fontawesome-free": "^5.8.1", - "@hq20/contracts": "^0.0.6", "@nrwl/cli": "12.3.6", "@nrwl/eslint-plugin-nx": "12.3.6", "@nrwl/jest": "12.3.6", diff --git a/yarn.lock b/yarn.lock index d5e5cff8a1..70481bf105 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2475,11 +2475,6 @@ resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.2.tgz#30aa825f11d438671d585bd44e7fd564535fc210" integrity sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw== -"@hq20/contracts@^0.0.6": - version "0.0.6" - resolved "https://registry.yarnpkg.com/@hq20/contracts/-/contracts-0.0.6.tgz#fc0a05884294da8757c4187f8567638982b74b6a" - integrity sha512-l94ARK0LfcRY7Y5EiInA+0vdXh8lnkTRAw9unli7UC75DY7aBMJl4OqTT5SMdm/n4N1dVVhCnyCM1W84UAx2Vw== - "@isomorphic-git/idb-keyval@3.3.2": version "3.3.2" resolved "https://registry.yarnpkg.com/@isomorphic-git/idb-keyval/-/idb-keyval-3.3.2.tgz#c0509a6c5987d8a62efb3e47f2815bcc5eda2489" From d9f927db9b97821b1679e4110a3e90bd561d359f Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 15:55:49 +0200 Subject: [PATCH 14/60] fix --- apps/remix-ide-e2e/src/commands/addFile.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index f9536bb259..aa4698f786 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -14,8 +14,17 @@ class AddFile extends EventEmitter { } function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { - browser.clickLaunchIcon('udapp') - .clickLaunchIcon('filePanel') + browser + .isVisible({ + selector: "//*[@data-id='sidePanelSwapitTitle' and contains(.,'File explorer')]", + locateStrategy: 'xpath', + suppressNotFoundErrors: true, + timeout: 1000 + }, (okVisible) => { + if (!okVisible.value) { + browser.clickLaunchIcon('filePanel') + } + }) .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') .click('li[data-id="treeViewLitreeViewItemREADME.txt"]').pause(1000) // focus on root directory .elements('css selector', `li[data-id="treeViewLitreeViewItem${name}"]`, (res) => { From 3234fd3961b2628f84165b0680267d751ab279dc Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 16:08:44 +0200 Subject: [PATCH 15/60] add file --- apps/remix-ide-e2e/src/commands/addFile.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index f9536bb259..a1aa1a5948 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -2,7 +2,7 @@ import { NightwatchBrowser, NightwatchContractContent } from 'nightwatch' import EventEmitter from 'events' class AddFile extends EventEmitter { - command (this: NightwatchBrowser, name: string, content: NightwatchContractContent): NightwatchBrowser { + command(this: NightwatchBrowser, name: string, content: NightwatchContractContent): NightwatchBrowser { this.api.perform((done) => { addFile(this.api, name, content, () => { done() @@ -13,9 +13,18 @@ class AddFile extends EventEmitter { } } -function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { - browser.clickLaunchIcon('udapp') - .clickLaunchIcon('filePanel') +function addFile(browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { + browser + .isVisible({ + selector: "//*[@data-id='sidePanelSwapitTitle' and contains(.,'File explorer')]", + locateStrategy: 'xpath', + suppressNotFoundErrors: true, + timeout: 1000 + }, (okVisible) => { + if (!okVisible.value) { + browser.clickLaunchIcon('filePanel') + } + }) .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') .click('li[data-id="treeViewLitreeViewItemREADME.txt"]').pause(1000) // focus on root directory .elements('css selector', `li[data-id="treeViewLitreeViewItem${name}"]`, (res) => { From daa077533a558ed1f20212f05007bc7a8c8e7f97 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 2 Sep 2022 13:09:58 +0200 Subject: [PATCH 16/60] typo and better condition --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 84aab5e5d0..e0379d1b11 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -80,9 +80,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const tmp: RegExpExecArray | null = /^(\d+.\d+.\d+)/.exec(version) return tmp ? tmp[1] : version } - if (version != '' && !semver.gt(truncateVersion(version), '0.4.12')) { + if (version && version != '' && !semver.gt(truncateVersion(version), '0.4.12')) { setIsSupportedVersion(false) - setRunButtonTitle('Sselect Solidity compiler version greater than 0.4.12.') + setRunButtonTitle('Select Solidity compiler version greater than 0.4.12.') } else { setIsSupportedVersion(true) setRunButtonTitle('Run static analysis') From e9f10fd8c957f87a83af09be1c3a707f37fd3ce2 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 2 Sep 2022 14:27:12 +0200 Subject: [PATCH 17/60] rm double scroll --- libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css index db1165b494..44e67f30fd 100644 --- a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css +++ b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css @@ -7,7 +7,7 @@ } .remixui_fileexplorer { position : relative; - overflow-y : auto; + overflow-y : hidden; } .remixui_fileExplorerTree { cursor : default; From 873e9fe601d0ceea8111e9a79f2fe424d500f46f Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 5 Sep 2022 12:41:00 +0200 Subject: [PATCH 18/60] editor menu color scheme fixes for some themes editor's tab layout fix FE selection color fixed for several themes --- .../src/assets/css/themes/bootstrap-cyborg.min.css | 8 ++++---- .../src/assets/css/themes/bootstrap-flatly.min.css | 4 ++-- .../src/assets/css/themes/bootstrap-spacelab.min.css | 4 ++-- .../remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css | 2 +- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 4 +++- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css index 30026bb48b..ced466267d 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css @@ -25,7 +25,7 @@ --gray:#555; --gray-dark:#222; --primary:#2a9fd6; - --secondary:#555; + --secondary:#3c3939; --success:#77b300; --info:#93c; --warning:#f80; @@ -5595,7 +5595,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#2180ac!important } .bg-secondary { - background-color:#555!important + background-color:#3c3939!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:#3c3c3c!important @@ -8358,7 +8358,7 @@ a.text-warning:focus,a.text-warning:hover { color:#b35f00!important } .text-danger { - color:#c00!important + color:#ff4242!important } a.text-danger:focus,a.text-danger:hover { color:maroon!important @@ -8594,7 +8594,7 @@ legend { color:#555 } .nav-pills .nav-link.active,.nav-tabs .nav-link.active { - background-color:#2a9fd6 + background-color:#034767 } .breadcrumb a { color:#fff diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css index c62ab28e0f..5940867b25 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css @@ -24,7 +24,7 @@ --gray:#95a5a6; --gray-dark:#343a40; --primary:#2c3e50; - --secondary:#95a5a6; + --secondary:#dadfe0; --success:#18bc9c; --info:#3498db; --warning:#f39c12; @@ -4460,7 +4460,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#1a252f!important } .bg-secondary { - background-color:#95a5a6!important + background-color:#dadfe0!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:#798d8f!important diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css index 4639bcdad8..b8e90b0107 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css @@ -25,7 +25,7 @@ --gray:#777; --gray-dark:#333; --primary:#446e9b; - --secondary:#999; + --secondary:#dadfe0; --success:#3cb521; --info:#3399f3; --warning:#d47500; @@ -5596,7 +5596,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#345578!important } .bg-secondary { - background-color:#999!important + background-color:#dadfe0!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:gray!important diff --git a/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css b/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css index e039facfec..28503c8562 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css +++ b/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css @@ -3641,7 +3641,7 @@ input[type="submit"].btn-block { .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active { color: #fff; - background-color: var(--body-bg); + background-color: #2a2c3f; border-color: #3f4455; } .nav-tabs .dropdown-menu { diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 715ecf9c7a..d51cd7f0d0 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -158,6 +158,7 @@ export const EditorUI = (props: EditorUIProps) => { const infoColor = formatColor('--info') const darkColor = formatColor('--dark') const secondaryColor = formatColor('--secondary') + const primaryColor = formatColor('--primary') const textColor = formatColor('--text') || darkColor const textbackground = formatColor('--text-background') || lightColor @@ -266,7 +267,8 @@ export const EditorUI = (props: EditorUIProps) => { 'editorSuggestWidget.background': lightColor, 'editorSuggestWidget.selectedBackground': secondaryColor, 'editorSuggestWidget.selectedForeground': textColor, - 'editorSuggestWidget.highlightForeground': infoColor, + 'editorSuggestWidget.highlightForeground': primaryColor, + 'editorSuggestWidget.focusHighlightForeground': infoColor, 'editor.lineHighlightBorder': secondaryColor, 'editor.lineHighlightBackground': textbackground === darkColor ? lightColor : secondaryColor, 'editorGutter.background': lightColor, diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index afe4c54897..4bca319f0e 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -186,7 +186,7 @@ export const TabsUI = (props: TabsUIProps) => { }} > - {props.tabs.map((tab, i) => {renderTab(tab, i)})} + {props.tabs.map((tab, i) => {renderTab(tab, i)})} {props.tabs.map((tab) => )} From c94dcc03459644d78136f95665f3315ac11b5758 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 7 Sep 2022 11:11:13 +0200 Subject: [PATCH 19/60] fixing e2e golden input --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 9ca0bb89ba..a522e92eca 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -163,7 +163,7 @@ const remixIdeThemes = { }, flatly: { primary: '#2C3E50', - secondary: '#95a5a6', + secondary: '#dadfe0', success: '#18BC9C', info: '#3498DB', warning: '#F39C12', From 59fd87f7ddfae497ac42949bb7ee006807ace9f6 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Sep 2022 13:24:17 +0200 Subject: [PATCH 20/60] e2e`:wq `` --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index a522e92eca..32a6636b81 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -171,7 +171,7 @@ const remixIdeThemes = { }, spacelab: { primary: '#446E9B', - secondary: '#999', + secondary: '#dadfe0', success: '#3CB521', info: '#3399F3', warning: '#D47500', From de91960554693cb7a80575cc28dedf254cff4dcf Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Sep 2022 15:10:05 +0200 Subject: [PATCH 21/60] e2e --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 32a6636b81..ef6213ea23 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -179,7 +179,7 @@ const remixIdeThemes = { }, cyborg: { primary: '#2A9FD6', - secondary: '#555', + secondary: '#3c3939', success: '#77B300', info: '#93C', warning: '#F80', diff --git a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx index 75c3698f1f..37fa018c92 100644 --- a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx @@ -15,7 +15,7 @@ export function RemixPluginPanel (props: RemixPanelProps) { <> {props.header}
-
+
{Object.values(props.plugins).map((pluginRecord) => { return })} From d51660c654d8a7e143b4fab81e235996b7cd81c9 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Sep 2022 17:10:26 +0200 Subject: [PATCH 22/60] fix config --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e308cf5191..3e19a05dbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -493,10 +493,10 @@ jobs: working_directory: ~/remix-project steps: + - checkout - node/install: install-yarn: true node-version: "v14.17.6" - - checkout - run: yarn - run: yarn run downloadsolc_assets - run: yarn run build:production @@ -526,6 +526,9 @@ jobs: steps: - checkout + - node/install: + install-yarn: true + node-version: "v14.17.6" - run: yarn - run: yarn run downloadsolc_assets - run: yarn run build:production From 69c4f2bd87082f9063aeb6e0c8d1c9b2e9503ee9 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 2 Sep 2022 13:09:58 +0200 Subject: [PATCH 23/60] typo and better condition --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 84aab5e5d0..e0379d1b11 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -80,9 +80,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const tmp: RegExpExecArray | null = /^(\d+.\d+.\d+)/.exec(version) return tmp ? tmp[1] : version } - if (version != '' && !semver.gt(truncateVersion(version), '0.4.12')) { + if (version && version != '' && !semver.gt(truncateVersion(version), '0.4.12')) { setIsSupportedVersion(false) - setRunButtonTitle('Sselect Solidity compiler version greater than 0.4.12.') + setRunButtonTitle('Select Solidity compiler version greater than 0.4.12.') } else { setIsSupportedVersion(true) setRunButtonTitle('Run static analysis') From b1fdb6637fc8bcf5cb4a642be54b1a53e92e20e0 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 2 Sep 2022 14:27:12 +0200 Subject: [PATCH 24/60] rm double scroll --- libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css index db1165b494..44e67f30fd 100644 --- a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css +++ b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css @@ -7,7 +7,7 @@ } .remixui_fileexplorer { position : relative; - overflow-y : auto; + overflow-y : hidden; } .remixui_fileExplorerTree { cursor : default; From 02f56484a6960a2b75d4d91189b2bdfd197e0dec Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 5 Sep 2022 12:41:00 +0200 Subject: [PATCH 25/60] editor menu color scheme fixes for some themes editor's tab layout fix FE selection color fixed for several themes --- .../src/assets/css/themes/bootstrap-cyborg.min.css | 8 ++++---- .../src/assets/css/themes/bootstrap-flatly.min.css | 4 ++-- .../src/assets/css/themes/bootstrap-spacelab.min.css | 4 ++-- .../remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css | 2 +- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 4 +++- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css index 30026bb48b..ced466267d 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css @@ -25,7 +25,7 @@ --gray:#555; --gray-dark:#222; --primary:#2a9fd6; - --secondary:#555; + --secondary:#3c3939; --success:#77b300; --info:#93c; --warning:#f80; @@ -5595,7 +5595,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#2180ac!important } .bg-secondary { - background-color:#555!important + background-color:#3c3939!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:#3c3c3c!important @@ -8358,7 +8358,7 @@ a.text-warning:focus,a.text-warning:hover { color:#b35f00!important } .text-danger { - color:#c00!important + color:#ff4242!important } a.text-danger:focus,a.text-danger:hover { color:maroon!important @@ -8594,7 +8594,7 @@ legend { color:#555 } .nav-pills .nav-link.active,.nav-tabs .nav-link.active { - background-color:#2a9fd6 + background-color:#034767 } .breadcrumb a { color:#fff diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css index c62ab28e0f..5940867b25 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css @@ -24,7 +24,7 @@ --gray:#95a5a6; --gray-dark:#343a40; --primary:#2c3e50; - --secondary:#95a5a6; + --secondary:#dadfe0; --success:#18bc9c; --info:#3498db; --warning:#f39c12; @@ -4460,7 +4460,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#1a252f!important } .bg-secondary { - background-color:#95a5a6!important + background-color:#dadfe0!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:#798d8f!important diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css index 4639bcdad8..b8e90b0107 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css @@ -25,7 +25,7 @@ --gray:#777; --gray-dark:#333; --primary:#446e9b; - --secondary:#999; + --secondary:#dadfe0; --success:#3cb521; --info:#3399f3; --warning:#d47500; @@ -5596,7 +5596,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#345578!important } .bg-secondary { - background-color:#999!important + background-color:#dadfe0!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:gray!important diff --git a/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css b/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css index e039facfec..28503c8562 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css +++ b/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css @@ -3641,7 +3641,7 @@ input[type="submit"].btn-block { .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active { color: #fff; - background-color: var(--body-bg); + background-color: #2a2c3f; border-color: #3f4455; } .nav-tabs .dropdown-menu { diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 715ecf9c7a..d51cd7f0d0 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -158,6 +158,7 @@ export const EditorUI = (props: EditorUIProps) => { const infoColor = formatColor('--info') const darkColor = formatColor('--dark') const secondaryColor = formatColor('--secondary') + const primaryColor = formatColor('--primary') const textColor = formatColor('--text') || darkColor const textbackground = formatColor('--text-background') || lightColor @@ -266,7 +267,8 @@ export const EditorUI = (props: EditorUIProps) => { 'editorSuggestWidget.background': lightColor, 'editorSuggestWidget.selectedBackground': secondaryColor, 'editorSuggestWidget.selectedForeground': textColor, - 'editorSuggestWidget.highlightForeground': infoColor, + 'editorSuggestWidget.highlightForeground': primaryColor, + 'editorSuggestWidget.focusHighlightForeground': infoColor, 'editor.lineHighlightBorder': secondaryColor, 'editor.lineHighlightBackground': textbackground === darkColor ? lightColor : secondaryColor, 'editorGutter.background': lightColor, diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index afe4c54897..4bca319f0e 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -186,7 +186,7 @@ export const TabsUI = (props: TabsUIProps) => { }} > - {props.tabs.map((tab, i) => {renderTab(tab, i)})} + {props.tabs.map((tab, i) => {renderTab(tab, i)})} {props.tabs.map((tab) => )} From 948e992e6cbbd95934f86fc0832e6f230f0c5981 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 7 Sep 2022 11:11:13 +0200 Subject: [PATCH 26/60] fixing e2e golden input --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 9ca0bb89ba..a522e92eca 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -163,7 +163,7 @@ const remixIdeThemes = { }, flatly: { primary: '#2C3E50', - secondary: '#95a5a6', + secondary: '#dadfe0', success: '#18BC9C', info: '#3498DB', warning: '#F39C12', From b07bc5014bcbf246237c9198ce54bfe2251b6f91 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Sep 2022 13:24:17 +0200 Subject: [PATCH 27/60] e2e`:wq `` --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index a522e92eca..32a6636b81 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -171,7 +171,7 @@ const remixIdeThemes = { }, spacelab: { primary: '#446E9B', - secondary: '#999', + secondary: '#dadfe0', success: '#3CB521', info: '#3399F3', warning: '#D47500', From 62f2f725ccd9b482961c05038aabe562aa701f2b Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Sep 2022 15:10:05 +0200 Subject: [PATCH 28/60] e2e --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 32a6636b81..ef6213ea23 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -179,7 +179,7 @@ const remixIdeThemes = { }, cyborg: { primary: '#2A9FD6', - secondary: '#555', + secondary: '#3c3939', success: '#77B300', info: '#93C', warning: '#F80', diff --git a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx index 75c3698f1f..37fa018c92 100644 --- a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx @@ -15,7 +15,7 @@ export function RemixPluginPanel (props: RemixPanelProps) { <> {props.header}
-
+
{Object.values(props.plugins).map((pluginRecord) => { return })} From 8af0e5dbe539b6c96cb34da4b19039546244e01c Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 2 Sep 2022 13:09:58 +0200 Subject: [PATCH 29/60] typo and better condition --- .../static-analyser/src/lib/remix-ui-static-analyser.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx index 84aab5e5d0..e0379d1b11 100644 --- a/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx +++ b/libs/remix-ui/static-analyser/src/lib/remix-ui-static-analyser.tsx @@ -80,9 +80,9 @@ export const RemixUiStaticAnalyser = (props: RemixUiStaticAnalyserProps) => { const tmp: RegExpExecArray | null = /^(\d+.\d+.\d+)/.exec(version) return tmp ? tmp[1] : version } - if (version != '' && !semver.gt(truncateVersion(version), '0.4.12')) { + if (version && version != '' && !semver.gt(truncateVersion(version), '0.4.12')) { setIsSupportedVersion(false) - setRunButtonTitle('Sselect Solidity compiler version greater than 0.4.12.') + setRunButtonTitle('Select Solidity compiler version greater than 0.4.12.') } else { setIsSupportedVersion(true) setRunButtonTitle('Run static analysis') From fa9f3dda5aba22e91e9f778b7042024639032a03 Mon Sep 17 00:00:00 2001 From: lianahus Date: Fri, 2 Sep 2022 14:27:12 +0200 Subject: [PATCH 30/60] rm double scroll --- libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css index db1165b494..44e67f30fd 100644 --- a/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css +++ b/libs/remix-ui/workspace/src/lib/css/remix-ui-workspace.css @@ -7,7 +7,7 @@ } .remixui_fileexplorer { position : relative; - overflow-y : auto; + overflow-y : hidden; } .remixui_fileExplorerTree { cursor : default; From 904b21525eb5bff496e4591f0fbb66d97a31241f Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 5 Sep 2022 12:41:00 +0200 Subject: [PATCH 31/60] editor menu color scheme fixes for some themes editor's tab layout fix FE selection color fixed for several themes --- .../src/assets/css/themes/bootstrap-cyborg.min.css | 8 ++++---- .../src/assets/css/themes/bootstrap-flatly.min.css | 4 ++-- .../src/assets/css/themes/bootstrap-spacelab.min.css | 4 ++-- .../remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css | 2 +- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 4 +++- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css index 30026bb48b..ced466267d 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-cyborg.min.css @@ -25,7 +25,7 @@ --gray:#555; --gray-dark:#222; --primary:#2a9fd6; - --secondary:#555; + --secondary:#3c3939; --success:#77b300; --info:#93c; --warning:#f80; @@ -5595,7 +5595,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#2180ac!important } .bg-secondary { - background-color:#555!important + background-color:#3c3939!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:#3c3c3c!important @@ -8358,7 +8358,7 @@ a.text-warning:focus,a.text-warning:hover { color:#b35f00!important } .text-danger { - color:#c00!important + color:#ff4242!important } a.text-danger:focus,a.text-danger:hover { color:maroon!important @@ -8594,7 +8594,7 @@ legend { color:#555 } .nav-pills .nav-link.active,.nav-tabs .nav-link.active { - background-color:#2a9fd6 + background-color:#034767 } .breadcrumb a { color:#fff diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css index c62ab28e0f..5940867b25 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-flatly.min.css @@ -24,7 +24,7 @@ --gray:#95a5a6; --gray-dark:#343a40; --primary:#2c3e50; - --secondary:#95a5a6; + --secondary:#dadfe0; --success:#18bc9c; --info:#3498db; --warning:#f39c12; @@ -4460,7 +4460,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#1a252f!important } .bg-secondary { - background-color:#95a5a6!important + background-color:#dadfe0!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:#798d8f!important diff --git a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css index 4639bcdad8..b8e90b0107 100644 --- a/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css +++ b/apps/remix-ide/src/assets/css/themes/bootstrap-spacelab.min.css @@ -25,7 +25,7 @@ --gray:#777; --gray-dark:#333; --primary:#446e9b; - --secondary:#999; + --secondary:#dadfe0; --success:#3cb521; --info:#3399f3; --warning:#d47500; @@ -5596,7 +5596,7 @@ a.bg-primary:focus,a.bg-primary:hover,button.bg-primary:focus,button.bg-primary: background-color:#345578!important } .bg-secondary { - background-color:#999!important + background-color:#dadfe0!important } a.bg-secondary:focus,a.bg-secondary:hover,button.bg-secondary:focus,button.bg-secondary:hover { background-color:gray!important diff --git a/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css b/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css index e039facfec..28503c8562 100644 --- a/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css +++ b/apps/remix-ide/src/assets/css/themes/remix-dark_tvx1s2.css @@ -3641,7 +3641,7 @@ input[type="submit"].btn-block { .nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active { color: #fff; - background-color: var(--body-bg); + background-color: #2a2c3f; border-color: #3f4455; } .nav-tabs .dropdown-menu { diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 715ecf9c7a..d51cd7f0d0 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -158,6 +158,7 @@ export const EditorUI = (props: EditorUIProps) => { const infoColor = formatColor('--info') const darkColor = formatColor('--dark') const secondaryColor = formatColor('--secondary') + const primaryColor = formatColor('--primary') const textColor = formatColor('--text') || darkColor const textbackground = formatColor('--text-background') || lightColor @@ -266,7 +267,8 @@ export const EditorUI = (props: EditorUIProps) => { 'editorSuggestWidget.background': lightColor, 'editorSuggestWidget.selectedBackground': secondaryColor, 'editorSuggestWidget.selectedForeground': textColor, - 'editorSuggestWidget.highlightForeground': infoColor, + 'editorSuggestWidget.highlightForeground': primaryColor, + 'editorSuggestWidget.focusHighlightForeground': infoColor, 'editor.lineHighlightBorder': secondaryColor, 'editor.lineHighlightBackground': textbackground === darkColor ? lightColor : secondaryColor, 'editorGutter.background': lightColor, diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index afe4c54897..4bca319f0e 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -186,7 +186,7 @@ export const TabsUI = (props: TabsUIProps) => { }} > - {props.tabs.map((tab, i) => {renderTab(tab, i)})} + {props.tabs.map((tab, i) => {renderTab(tab, i)})} {props.tabs.map((tab) => )} From 1c8603ebcb9fd8cc063c3d54c44892ce050263e8 Mon Sep 17 00:00:00 2001 From: lianahus Date: Wed, 7 Sep 2022 11:11:13 +0200 Subject: [PATCH 32/60] fixing e2e golden input --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 9ca0bb89ba..a522e92eca 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -163,7 +163,7 @@ const remixIdeThemes = { }, flatly: { primary: '#2C3E50', - secondary: '#95a5a6', + secondary: '#dadfe0', success: '#18BC9C', info: '#3498DB', warning: '#F39C12', From c29f29a8e79df62a844b630ad6aa175e99e83b19 Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Sep 2022 13:24:17 +0200 Subject: [PATCH 33/60] e2e`:wq `` --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index a522e92eca..32a6636b81 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -171,7 +171,7 @@ const remixIdeThemes = { }, spacelab: { primary: '#446E9B', - secondary: '#999', + secondary: '#dadfe0', success: '#3CB521', info: '#3399F3', warning: '#D47500', From 0c98746302a826a60a5252e6da70e544dc4c1bdd Mon Sep 17 00:00:00 2001 From: lianahus Date: Mon, 12 Sep 2022 15:10:05 +0200 Subject: [PATCH 34/60] e2e --- apps/remix-ide-e2e/src/tests/generalSettings.test.ts | 2 +- libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts index 32a6636b81..ef6213ea23 100644 --- a/apps/remix-ide-e2e/src/tests/generalSettings.test.ts +++ b/apps/remix-ide-e2e/src/tests/generalSettings.test.ts @@ -179,7 +179,7 @@ const remixIdeThemes = { }, cyborg: { primary: '#2A9FD6', - secondary: '#555', + secondary: '#3c3939', success: '#77B300', info: '#93C', warning: '#F80', diff --git a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx index 75c3698f1f..37fa018c92 100644 --- a/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx +++ b/libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx @@ -15,7 +15,7 @@ export function RemixPluginPanel (props: RemixPanelProps) { <> {props.header}
-
+
{Object.values(props.plugins).map((pluginRecord) => { return })} From 0179fedda1da1ef45e658d38617e3398b40bfac4 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 16 Sep 2022 09:26:24 +0200 Subject: [PATCH 35/60] debug --- apps/remix-ide-e2e/src/commands/addFile.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index ea3999cffc..aa6b7ce971 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -15,6 +15,7 @@ class AddFile extends EventEmitter { function addFile (browser: NightwatchBrowser, name: string, content: NightwatchContractContent, done: VoidFunction) { browser + .saveScreenshot('./reports/screenshots/addFile.png') .isVisible({ selector: "//*[@data-id='sidePanelSwapitTitle' and contains(.,'File explorer')]", locateStrategy: 'xpath', @@ -23,8 +24,10 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC }, (okVisible) => { if (!okVisible.value) { browser.clickLaunchIcon('filePanel') + .saveScreenshot('./reports/screenshots/addFile2.png') } }) + .saveScreenshot('./reports/screenshots/addFile3.png') .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') .click('li[data-id="treeViewLitreeViewItemREADME.txt"]').pause(1000) // focus on root directory .elements('css selector', `li[data-id="treeViewLitreeViewItem${name}"]`, (res) => { From eba995208f1302181dcf7454cb923d867524894e Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 16 Sep 2022 09:39:23 +0200 Subject: [PATCH 36/60] scroll --- apps/remix-ide-e2e/src/commands/addFile.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/remix-ide-e2e/src/commands/addFile.ts b/apps/remix-ide-e2e/src/commands/addFile.ts index aa6b7ce971..c64fb830f6 100644 --- a/apps/remix-ide-e2e/src/commands/addFile.ts +++ b/apps/remix-ide-e2e/src/commands/addFile.ts @@ -27,6 +27,7 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC .saveScreenshot('./reports/screenshots/addFile2.png') } }) + .scrollInto('li[data-id="treeViewLitreeViewItemREADME.txt"]') .saveScreenshot('./reports/screenshots/addFile3.png') .waitForElementVisible('li[data-id="treeViewLitreeViewItemREADME.txt"]') .click('li[data-id="treeViewLitreeViewItemREADME.txt"]').pause(1000) // focus on root directory From e3d6d1656631bf04eabaca4bd2479f84c0591cfe Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 16 Sep 2022 09:53:51 +0200 Subject: [PATCH 37/60] update options --- apps/remix-ide-e2e/nightwatch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/nightwatch.ts b/apps/remix-ide-e2e/nightwatch.ts index 3f59c1549e..1e936d3f80 100644 --- a/apps/remix-ide-e2e/nightwatch.ts +++ b/apps/remix-ide-e2e/nightwatch.ts @@ -84,8 +84,8 @@ module.exports = { 'moz:firefoxOptions': { args: [ '-headless', - '-width=2560', - '-height=1440' + '--width=2560', + '--height=1440' ] } } From c29540ad5e61bbcd63fcd7c2eb837f666a8c4728 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 16 Sep 2022 09:59:19 +0200 Subject: [PATCH 38/60] rm options --- apps/remix-ide-e2e/nightwatch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/nightwatch.ts b/apps/remix-ide-e2e/nightwatch.ts index 1e936d3f80..3f59c1549e 100644 --- a/apps/remix-ide-e2e/nightwatch.ts +++ b/apps/remix-ide-e2e/nightwatch.ts @@ -84,8 +84,8 @@ module.exports = { 'moz:firefoxOptions': { args: [ '-headless', - '--width=2560', - '--height=1440' + '-width=2560', + '-height=1440' ] } } From 92d4632e07e8e1c00b7e39047120a3366c4f57be Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 16 Sep 2022 10:02:13 +0200 Subject: [PATCH 39/60] do not max --- apps/remix-ide-e2e/src/helpers/init.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/helpers/init.ts b/apps/remix-ide-e2e/src/helpers/init.ts index ddf8c13917..0a64b64710 100644 --- a/apps/remix-ide-e2e/src/helpers/init.ts +++ b/apps/remix-ide-e2e/src/helpers/init.ts @@ -24,8 +24,8 @@ export default function (browser: NightwatchBrowser, callback: VoidFunction, url .pause(6000) .perform(done()) }) - .maximizeWindow() - .fullscreenWindow(() => { + //.maximizeWindow() + .perform(() => { if (preloadPlugins) { initModules(browser, () => { browser.pause(2000).clickLaunchIcon('solidity') From 837cacad752797647eb0cfd81effd386170e32b2 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 8 Sep 2022 15:27:29 +0530 Subject: [PATCH 40/60] workspace template categories --- .../workspace/src/lib/remix-ui-workspace.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 512fd2ec65..c587019851 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -159,16 +159,23 @@ export function Workspace () { const createModalMessage = () => { return ( <> - -
+

+ + ) } From e1ebb5b30729171dc2b574600d0660eb423caf80 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 9 Sep 2022 12:54:20 +0200 Subject: [PATCH 41/60] Updated the style in options list --- .../workspace/src/lib/remix-ui-workspace.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index c587019851..c7e0854d43 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -161,16 +161,16 @@ export function Workspace () { <>

From 0670d8eacb880bed610ca448fe6d8fa0a397457d Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 13 Sep 2022 10:01:05 +0200 Subject: [PATCH 42/60] better colors for create workspace modal --- .../workspace/src/lib/remix-ui-workspace.tsx | 100 ++++++++++++++++-- 1 file changed, 89 insertions(+), 11 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index c7e0854d43..4d7e79a2fb 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -161,16 +161,16 @@ export function Workspace () { <>

@@ -286,9 +286,9 @@ export function Workspace () { { - createWorkspace() - }} + onClick={() => { + createWorkspace() + }} > { - create a new workspace - @@ -397,6 +397,84 @@ export function Workspace () { />
} + { !(global.fs.browser.isRequestingWorkspace || + global.fs.browser.isRequestingCloning) && + (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && +
+ +
+ } + { + global.fs.localhost.isRequestingLocalhost ?
+ :
+ { global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost && + + } +
+ } +>>>>>>> 1a3a8ea0e (better colors for create workspace modal)
From 6ac43b88875e64d6108f98ad39082610cccf2ede Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 13 Sep 2022 12:39:55 +0200 Subject: [PATCH 43/60] sizes --- .../workspace/src/lib/remix-ui-workspace.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 4d7e79a2fb..f70ec5163f 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -160,20 +160,19 @@ export function Workspace () { return ( <> - + + + - - - + + + - - + + -

From b4765d37bd4a399ed28fbb07002246e14f20a74c Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 13 Sep 2022 14:34:31 +0200 Subject: [PATCH 44/60] medium for categoriy size --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index f70ec5163f..4965f8d32d 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -161,15 +161,15 @@ export function Workspace () { <> From 395ba085b75f27f50c74e8e2c534d8d06e966dd9 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 14 Sep 2022 22:59:36 +0530 Subject: [PATCH 45/60] conflict fix --- .../workspace/src/lib/remix-ui-workspace.tsx | 78 ------------------- 1 file changed, 78 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 4965f8d32d..3d56589027 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -396,84 +396,6 @@ export function Workspace () { />
} - { !(global.fs.browser.isRequestingWorkspace || - global.fs.browser.isRequestingCloning) && - (global.fs.mode === 'browser') && (currentWorkspace !== NO_WORKSPACE) && -
- -
- } - { - global.fs.localhost.isRequestingLocalhost ?
- :
- { global.fs.mode === 'localhost' && global.fs.localhost.isSuccessfulLocalhost && - - } -
- } ->>>>>>> 1a3a8ea0e (better colors for create workspace modal)
From 98ddc043660cd8959cb701d9bde1be3a47387139 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 15 Sep 2022 17:40:00 +0530 Subject: [PATCH 46/60] oz template custom option --- .../workspace/src/lib/remix-ui-workspace.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 3d56589027..9d0a9e2fba 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -15,6 +15,7 @@ export function Workspace () { const [currentWorkspace, setCurrentWorkspace] = useState(NO_WORKSPACE) const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean}>(null) const [showDropdown, setShowDropdown] = useState(false) + const [displayOzCustoms, setDisplayOzCustoms] = useState(false) const global = useContext(FileSystemContext) const workspaceRenameInput = useRef() const workspaceCreateInput = useRef() @@ -138,6 +139,8 @@ export function Workspace () { } const updateWsName = () => { + setDisplayOzCustoms(true) + console.log('inside updateWsName', displayOzCustoms) // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` } @@ -173,6 +176,17 @@ export function Workspace () { + { displayOzCustoms && +
+
+
+
+ + +

+
+ } + From 7b2a83252ebd7f8bbcf4701c2c9bb030e75789ed Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 15 Sep 2022 18:16:01 +0530 Subject: [PATCH 47/60] show only for oz templates --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 9d0a9e2fba..1bab48486e 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -139,7 +139,9 @@ export function Workspace () { } const updateWsName = () => { - setDisplayOzCustoms(true) + // @ts-ignore + if (workspaceCreateTemplateInput.current.value.startsWith('oz')) setDisplayOzCustoms(true) + else setDisplayOzCustoms(false) console.log('inside updateWsName', displayOzCustoms) // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` @@ -179,7 +181,7 @@ export function Workspace () { { displayOzCustoms &&

-
+
From 55bd2ec3eda2f2cb73b497f2436c88d961d8b974 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 15 Sep 2022 19:55:43 +0530 Subject: [PATCH 48/60] upgradeable ERC20 --- .../workspace/src/lib/actions/events.ts | 2 +- .../workspace/src/lib/actions/workspace.ts | 12 +++---- .../workspace/src/lib/contexts/index.ts | 2 +- .../src/lib/providers/FileSystemProvider.tsx | 4 +-- .../workspace/src/lib/remix-ui-workspace.tsx | 35 ++++++++++++++----- .../src/templates/ozerc20/index.ts | 5 +-- 6 files changed, 39 insertions(+), 21 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index 74b767cf73..7a9ed8a416 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.ts @@ -13,7 +13,7 @@ export const listenOnPluginEvents = (filePanelPlugin) => { plugin = filePanelPlugin plugin.on('filePanel', 'createWorkspaceReducerEvent', (name: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb: (err: Error, result?: string | number | boolean | Record) => void) => { - createWorkspace(name, workspaceTemplateName, isEmpty, cb) + createWorkspace(name, workspaceTemplateName, null, isEmpty, cb) }) plugin.on('filePanel', 'renameWorkspaceReducerEvent', (oldName: string, workspaceName: string, cb: (err: Error, result?: string | number | boolean | Record) => void) => { diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 3ef203644e..dc69bc5408 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -43,17 +43,17 @@ export const addInputField = async (type: 'file' | 'folder', path: string, cb?: return promise } -export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void, isGitRepo: boolean = false) => { +export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, opts = null, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void, isGitRepo: boolean = false) => { await plugin.fileManager.closeAllFiles() const promise = createWorkspaceTemplate(workspaceName, workspaceTemplateName) - + console.log('opts-->', opts) dispatch(createWorkspaceRequest(promise)) promise.then(async () => { dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) await plugin.setWorkspace({ name: workspaceName, isLocalhost: false }) await plugin.setWorkspaces(await getWorkspaces()) await plugin.workspaceCreated(workspaceName) - if (!isEmpty) await loadWorkspacePreset(workspaceTemplateName) + if (!isEmpty) await loadWorkspacePreset(workspaceTemplateName, opts) cb && cb(null, workspaceName) }).catch((error) => { dispatch(createWorkspaceError({ error })) @@ -80,7 +80,7 @@ export type UrlParametersType = { language: string } -export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDefault') => { +export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDefault', opts?) => { const workspaceProvider = plugin.fileProviders.workspace const params = queryParams.get() as UrlParametersType @@ -159,7 +159,7 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe if (!templateList.includes(template)) break _paq.push(['trackEvent', 'workspace', 'template', template]) // @ts-ignore - const files = await templateWithContent[template]() + const files = await templateWithContent[template](opts) for (const file in files) { try { await workspaceProvider.set(file, files[file]) @@ -339,7 +339,7 @@ export const cloneRepository = async (url: string) => { try { const repoName = await getRepositoryTitle(url) - await createWorkspace(repoName, 'blank', true, null, true) + await createWorkspace(repoName, 'blank', null, true, null, true) const promise = plugin.call('dGitProvider', 'clone', repoConfig, repoName, true) dispatch(cloneRepositoryRequest()) diff --git a/libs/remix-ui/workspace/src/lib/contexts/index.ts b/libs/remix-ui/workspace/src/lib/contexts/index.ts index 1724ca7c29..e6b8242bdf 100644 --- a/libs/remix-ui/workspace/src/lib/contexts/index.ts +++ b/libs/remix-ui/workspace/src/lib/contexts/index.ts @@ -9,7 +9,7 @@ export const FileSystemContext = createContext<{ dispatchFetchDirectory:(path: string) => Promise, dispatchAddInputField:(path: string, type: 'file' | 'folder') => Promise, dispatchRemoveInputField:(path: string) => Promise, - dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string) => Promise, + dispatchCreateWorkspace: (workspaceName: string, workspaceTemplateName: string, opts?) => Promise, toast: (toasterMsg: string) => void, dispatchFetchWorkspaceDirectory: (path: string) => Promise, dispatchSwitchToWorkspace: (name: string) => Promise, diff --git a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx index 2d4010ca31..b1b321c189 100644 --- a/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx +++ b/libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx @@ -45,8 +45,8 @@ export const FileSystemProvider = (props: WorkspaceProps) => { await removeInputField(path) } - const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate) => { - await createWorkspace(workspaceName, workspaceTemplateName) + const dispatchCreateWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, opts?) => { + await createWorkspace(workspaceName, workspaceTemplateName, opts) } const dispatchFetchWorkspaceDirectory = async (path: string) => { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 1bab48486e..135bac5b31 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -16,6 +16,7 @@ export function Workspace () { const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean}>(null) const [showDropdown, setShowDropdown] = useState(false) const [displayOzCustoms, setDisplayOzCustoms] = useState(false) + const upgradeable = useRef() const global = useContext(FileSystemContext) const workspaceRenameInput = useRef() const workspaceCreateInput = useRef() @@ -105,9 +106,13 @@ export function Workspace () { const workspaceName = workspaceCreateInput.current.value // @ts-ignore: Object is possibly 'null'. const workspaceTemplateName = workspaceCreateTemplateInput.current.value || 'remixDefault' + console.log('upgradeable.current--->', upgradeable.current) + const opts = { + upgradeable: upgradeable.current + } try { - await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName) + await global.dispatchCreateWorkspace(workspaceName, workspaceTemplateName, opts) } catch (e) { global.modal('Create Workspace', e.message, 'OK', () => {}, '') console.error(e) @@ -161,6 +166,12 @@ export function Workspace () { setShowDropdown(isOpen) } + const handleUpgradeChange = (e) => { + console.log('selected option', e.target.value) + // @ts-ignore + upgradeable.current = e.target.value + } + const createModalMessage = () => { return ( <> @@ -178,17 +189,23 @@ export function Workspace () { - { displayOzCustoms && +
-
+

+
-
- - -

+
handleUpgradeChange(e)}> +
+ + +
+
+ + +
+
- } - +
diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index f44f812bb2..3addf406cd 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -1,8 +1,9 @@ import { erc20 } from '@openzeppelin/wizard'; -export default async () => { +export default async (opts) => { + console.log('opts---->', opts) return { - 'contracts/MyToken.sol': erc20.print(), + 'contracts/MyToken.sol': erc20.print({ ...erc20.defaults, upgradeable: opts.upgradeable}), // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, // @ts-ignore From 94da48a64820e0a4296285858c3e8303c6eb2c7e Mon Sep 17 00:00:00 2001 From: filip mertens Date: Fri, 16 Sep 2022 11:32:21 +0200 Subject: [PATCH 49/60] path --- apps/remix-ide/webpack.config.js | 9 ++++++++- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/webpack.config.js b/apps/remix-ide/webpack.config.js index 529fe58d39..57fd709495 100644 --- a/apps/remix-ide/webpack.config.js +++ b/apps/remix-ide/webpack.config.js @@ -16,6 +16,13 @@ module.exports = config => { const nxWebpackConfig = nxWebpack(config) const webpackConfig = { ...nxWebpackConfig, + resolve: { + ...nxWebpackConfig.resolve, + alias: { + path: require.resolve("path-browserify"), + } + }, + node: { fs: 'empty', tls: 'empty', @@ -38,7 +45,7 @@ module.exports = config => { }) ] } - + webpackConfig.output.chunkLoadTimeout = 600000 if (process.env.NODE_ENV === 'production') { diff --git a/package.json b/package.json index 90740ac3d5..4a8164df48 100644 --- a/package.json +++ b/package.json @@ -198,6 +198,7 @@ "merge": "^2.1.1", "monaco-editor": "^0.30.1", "npm-install-version": "^6.0.2", + "path-browserify": "^1.0.1", "prettier": "^2.7.1", "prettier-plugin-solidity": "^1.0.0-beta.24", "raw-loader": "^4.0.2", diff --git a/yarn.lock b/yarn.lock index 1f51deb7ae..62de31106f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18523,6 +18523,11 @@ path-browserify@0.0.1, path-browserify@~0.0.0: resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== +path-browserify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" + integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== + path-case@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/path-case/-/path-case-3.0.4.tgz#9168645334eb942658375c56f80b4c0cb5f82c6f" From 7e34a82cadbff279cf7fdcb5903d91bbfcd498da Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 16 Sep 2022 15:50:32 +0530 Subject: [PATCH 50/60] upgradable ERC721 --- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 1 - libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 9 ++++----- libs/remix-ws-templates/src/templates/ozerc20/index.ts | 1 - libs/remix-ws-templates/src/templates/ozerc721/index.ts | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index dc69bc5408..0d821bc75d 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -46,7 +46,6 @@ export const addInputField = async (type: 'file' | 'folder', path: string, cb?: export const createWorkspace = async (workspaceName: string, workspaceTemplateName: WorkspaceTemplate, opts = null, isEmpty = false, cb?: (err: Error, result?: string | number | boolean | Record) => void, isGitRepo: boolean = false) => { await plugin.fileManager.closeAllFiles() const promise = createWorkspaceTemplate(workspaceName, workspaceTemplateName) - console.log('opts-->', opts) dispatch(createWorkspaceRequest(promise)) promise.then(async () => { dispatch(createWorkspaceSuccess({ name: workspaceName, isGitRepo })) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 135bac5b31..c7ba7e0bd5 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -106,7 +106,7 @@ export function Workspace () { const workspaceName = workspaceCreateInput.current.value // @ts-ignore: Object is possibly 'null'. const workspaceTemplateName = workspaceCreateTemplateInput.current.value || 'remixDefault' - console.log('upgradeable.current--->', upgradeable.current) + const opts = { upgradeable: upgradeable.current } @@ -147,7 +147,6 @@ export function Workspace () { // @ts-ignore if (workspaceCreateTemplateInput.current.value.startsWith('oz')) setDisplayOzCustoms(true) else setDisplayOzCustoms(false) - console.log('inside updateWsName', displayOzCustoms) // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` } @@ -166,8 +165,7 @@ export function Workspace () { setShowDropdown(isOpen) } - const handleUpgradeChange = (e) => { - console.log('selected option', e.target.value) + const handleUpgradeability = (e) => { // @ts-ignore upgradeable.current = e.target.value } @@ -194,7 +192,7 @@ export function Workspace () {


-
handleUpgradeChange(e)}> +
handleUpgradeability(e)}>
@@ -206,6 +204,7 @@ export function Workspace () {

+ diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 3addf406cd..17ed9113f2 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -1,7 +1,6 @@ import { erc20 } from '@openzeppelin/wizard'; export default async (opts) => { - console.log('opts---->', opts) return { 'contracts/MyToken.sol': erc20.print({ ...erc20.defaults, upgradeable: opts.upgradeable}), // @ts-ignore diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts index 26a3acd59b..6505e5f0ef 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -1,8 +1,8 @@ import { erc721 } from '@openzeppelin/wizard'; -export default async () => { +export default async (opts) => { return { - 'contracts/MyToken.sol': erc721.print(), + 'contracts/MyToken.sol': erc721.print({ ...erc721.defaults, upgradeable: opts.upgradeable}), // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, // @ts-ignore From 837c74968b1ce2601015daaaaf9ea193e2d93f93 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 16 Sep 2022 15:59:51 +0530 Subject: [PATCH 51/60] linting fix --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index c7ba7e0bd5..b533b7d4cc 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -188,6 +188,7 @@ export function Workspace () { + { displayOzCustoms &&


@@ -203,6 +204,7 @@ export function Workspace () {
+ }
From a14cbe4dacc503c953b9d67ab6e10133d8f9661d Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 16 Sep 2022 16:44:00 +0530 Subject: [PATCH 52/60] condition display and name update --- .../workspace/src/lib/remix-ui-workspace.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index b533b7d4cc..c3631ef1e0 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -15,7 +15,7 @@ export function Workspace () { const [currentWorkspace, setCurrentWorkspace] = useState(NO_WORKSPACE) const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean}>(null) const [showDropdown, setShowDropdown] = useState(false) - const [displayOzCustoms, setDisplayOzCustoms] = useState(false) + const displayOzCustomRef = useRef() const upgradeable = useRef() const global = useContext(FileSystemContext) const workspaceRenameInput = useRef() @@ -145,8 +145,10 @@ export function Workspace () { const updateWsName = () => { // @ts-ignore - if (workspaceCreateTemplateInput.current.value.startsWith('oz')) setDisplayOzCustoms(true) - else setDisplayOzCustoms(false) + if (workspaceCreateTemplateInput.current.value.startsWith('oz') && displayOzCustomRef && displayOzCustomRef.current) + displayOzCustomRef.current.style.display = 'block' + else displayOzCustomRef.current.style.display = 'none' + // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` } @@ -168,6 +170,8 @@ export function Workspace () { const handleUpgradeability = (e) => { // @ts-ignore upgradeable.current = e.target.value + // @ts-ignore + workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value + '_upgradeable'}_${Date.now()}` } const createModalMessage = () => { @@ -188,8 +192,7 @@ export function Workspace () { - { displayOzCustoms && -
+



@@ -204,7 +207,6 @@ export function Workspace () {
- }
From 4c3cd5840c01853f12c85a555fadb6bd4b8fa45c Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 16 Sep 2022 17:16:52 +0530 Subject: [PATCH 53/60] ui update --- .../workspace/src/lib/remix-ui-workspace.tsx | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 29750fb63f..8a4eac301f 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -179,25 +179,24 @@ export function Workspace () { const createModalMessage = () => { return ( <> - - + + + - - - + + + - - + + -
-

- -
+
+ +
handleUpgradeability(e)}>
@@ -209,9 +208,8 @@ export function Workspace () {
-
- +
From ee8c6f927f56c158cd1e1e276d0403c361bfb3ac Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 19 Sep 2022 15:01:40 +0530 Subject: [PATCH 54/60] added oz ERC1155 template --- .../workspace/src/lib/remix-ui-workspace.tsx | 6 ++-- libs/remix-ws-templates/src/index.ts | 4 ++- .../src/templates/ozerc1155/index.ts | 20 +++++++++++ .../ozerc1155/scripts/deploy_with_ethers.ts | 10 ++++++ .../ozerc1155/scripts/deploy_with_web3.ts | 10 ++++++ .../templates/ozerc1155/scripts/ethers-lib.ts | 29 +++++++++++++++ .../templates/ozerc1155/scripts/web3-lib.ts | 36 +++++++++++++++++++ .../ozerc1155/tests/MyToken_test.sol | 19 ++++++++++ 8 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 libs/remix-ws-templates/src/templates/ozerc1155/index.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_ethers.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_web3.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_test.sol diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 8a4eac301f..5610fc2b1d 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -147,9 +147,10 @@ export function Workspace () { const updateWsName = () => { // @ts-ignore - if (workspaceCreateTemplateInput.current.value.startsWith('oz') && displayOzCustomRef && displayOzCustomRef.current) + if (workspaceCreateTemplateInput.current.value.startsWith('oz') && displayOzCustomRef && displayOzCustomRef.current) { displayOzCustomRef.current.style.display = 'block' - else displayOzCustomRef.current.style.display = 'none' + upgradeable.current = undefined + } else displayOzCustomRef.current.style.display = 'none' // @ts-ignore workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` @@ -188,6 +189,7 @@ export function Workspace () { + diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts index 9e12a868c8..f00b25f961 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,5 +1,7 @@ export { default as remixDefault } from './templates/remixDefault' export { default as blank } from './templates/blank' export { default as ozerc20 } from './templates/ozerc20' -export { default as zeroxErc20 } from './templates/zeroxErc20' export { default as ozerc721 } from './templates/ozerc721' +export { default as ozerc1155 } from './templates/ozerc1155' +export { default as zeroxErc20 } from './templates/zeroxErc20' + diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts new file mode 100644 index 0000000000..2902d4a4e1 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -0,0 +1,20 @@ +import { erc1155 } from '@openzeppelin/wizard'; + +export default async (opts) => { + let filesObj = { + 'contracts/MyToken.sol': erc1155.print({ ...erc1155.defaults, upgradeable: opts.upgradeable}), + // @ts-ignore + 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, + // @ts-ignore + 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, + // @ts-ignore + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, + // @ts-ignore + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, + } + // If no options is selected, opts.upgradeable will be undefined + // We do not show test file for upgradeable contract + // @ts-ignore + if (opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + return filesObj +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_ethers.ts new file mode 100644 index 0000000000..a6c8cf30e5 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_ethers.ts @@ -0,0 +1,10 @@ +import { deploy } from './ethers-lib' + +(async () => { + try { + const result = await deploy('MyToken', []) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } + })() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_web3.ts new file mode 100644 index 0000000000..b22b119246 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_web3.ts @@ -0,0 +1,10 @@ +import { deploy } from './web3-lib' + +(async () => { + try { + const result = await deploy('MyToken', []) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } +})() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts new file mode 100644 index 0000000000..e875db9a43 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts @@ -0,0 +1,29 @@ +import { ethers } from 'ethers' + +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {Number} accountIndex account index from the exposed account + * @return {Contract} deployed contract + */ +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { + + console.log(`deploying ${contractName}`) + // Note that the script needs the ABI which is generated from the compilation artifact. + // Make sure contract is compiled and artifacts are generated + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + // 'web3Provider' is a remix global variable object + + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) + + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) + + const contract = await factory.deploy(...args) + + // The contract is NOT deployed yet; we must wait until it is mined + await contract.deployed() + return contract +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts new file mode 100644 index 0000000000..e6d9e09f35 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/scripts/web3-lib.ts @@ -0,0 +1,36 @@ +import Web3 from 'web3' +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' + +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {string} from account used to send the transaction + * @param {number} gas gas limit + * @return {Options} deployed contract + */ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + + const web3 = new Web3(web3Provider) + console.log(`deploying ${contractName}`) + // Note that the script needs the ABI which is generated from the compilation artifact. + // Make sure contract is compiled and artifacts are generated + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + + const accounts = await web3.eth.getAccounts() + + const contract: Contract = new web3.eth.Contract(metadata.abi) + + const contractSend: ContractSendMethod = contract.deploy({ + data: metadata.data.bytecode.object, + arguments: args + }) + + const newContractInstance = await contractSend.send({ + from: from || accounts[0], + gas: gas || 3600000 + }) + return newContractInstance.options +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_test.sol b/libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_test.sol new file mode 100644 index 0000000000..73a77e7094 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc1155/tests/MyToken_test.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +import "remix_tests.sol"; +import "../contracts/MyToken.sol"; + +contract MyTokenTest { + + MyToken s; + function beforeAll () public { + s = new MyToken(); + } + + function testSetURI () public { + string memory uri = "https://testuri.io/token"; + s.setURI(uri); + Assert.equal(s.uri(1), uri, "uri did not match"); + } +} \ No newline at end of file From e445e8c398a1fb1039f6b2807ff36c0b62603ff0 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 19 Sep 2022 17:44:46 +0530 Subject: [PATCH 55/60] linting fix --- libs/remix-ws-templates/src/templates/ozerc1155/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts index 2902d4a4e1..51b7c441b7 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -1,7 +1,7 @@ import { erc1155 } from '@openzeppelin/wizard'; export default async (opts) => { - let filesObj = { + const filesObj = { 'contracts/MyToken.sol': erc1155.print({ ...erc1155.defaults, upgradeable: opts.upgradeable}), // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, From bf414fc516199e209d88390b7ab728e4e566b039 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 19 Sep 2022 18:19:47 +0530 Subject: [PATCH 56/60] remove test file for upgradable contracts --- .../src/templates/ozerc1155/index.ts | 2 +- .../src/templates/ozerc20/index.ts | 12 ++++++++---- .../src/templates/ozerc721/index.ts | 12 ++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts index 51b7c441b7..2bbd5a5673 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -10,7 +10,7 @@ export default async (opts) => { // @ts-ignore 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, // @ts-ignore - 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default } // If no options is selected, opts.upgradeable will be undefined // We do not show test file for upgradeable contract diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 17ed9113f2..3a070be29e 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -1,7 +1,7 @@ import { erc20 } from '@openzeppelin/wizard'; export default async (opts) => { - return { + const filesObj = { 'contracts/MyToken.sol': erc20.print({ ...erc20.defaults, upgradeable: opts.upgradeable}), // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, @@ -10,8 +10,12 @@ export default async (opts) => { // @ts-ignore 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, // @ts-ignore - 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, - // @ts-ignore - 'tests/MyToken_test.sol': (await import('raw-loader!./tests/MyToken_test.sol')).default + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default } + + // If no options is selected, opts.upgradeable will be undefined + // We do not show test file for upgradeable contract + // @ts-ignore + if (opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + return filesObj } \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts index 6505e5f0ef..35f91450b3 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -1,7 +1,7 @@ import { erc721 } from '@openzeppelin/wizard'; export default async (opts) => { - return { + const filesObj = { 'contracts/MyToken.sol': erc721.print({ ...erc721.defaults, upgradeable: opts.upgradeable}), // @ts-ignore 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, @@ -10,8 +10,12 @@ export default async (opts) => { // @ts-ignore 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, // @ts-ignore - 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, - // @ts-ignore - 'tests/MyToken_test.sol': (await import('raw-loader!./tests/MyToken_test.sol')).default + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default } + + // If no options is selected, opts.upgradeable will be undefined + // We do not show test file for upgradeable contract + // @ts-ignore + if (opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default + return filesObj } \ No newline at end of file From 4f8853b55ccf9619133f9e2ade7d9e8645009651 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 19 Sep 2022 18:24:59 +0530 Subject: [PATCH 57/60] added e2e for 1155 --- .../remix-ide-e2e/src/tests/workspace.test.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 477ed83b7b..bf683aa722 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -207,6 +207,54 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests/MyToken_test.sol"]') }, + 'Should create ERC1155 workspace with files #group1': function (browser: NightwatchBrowser) { + browser + .click('*[data-id="workspaceCreate"]') + .waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]') + .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > button') + // eslint-disable-next-line dot-notation + .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc1155' }) + .click('select[id="wstemplate"]') + .click('select[id="wstemplate"] option[value=ozerc1155]') + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .pause(100) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + .pause(4000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests/MyToken_test.sol"]') + }, + // WORKSPACE TEMPLATES E2E END 'Should create two workspace and switch to the first one #group1': function (browser: NightwatchBrowser) { From 9d3c9a6b1a3a426ff0f60907a1c4943fc277ff36 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 20 Sep 2022 14:06:21 +0530 Subject: [PATCH 58/60] fix compiler license loading --- libs/remix-solidity/src/compiler/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index f1302f88b9..08efe15f14 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -281,7 +281,7 @@ export class Compiler { } switch (data.cmd) { case 'versionLoaded': - if (data.data && data.license) this.onCompilerLoaded(data.data, data.license) + if (data.data) this.onCompilerLoaded(data.data, data.license) break case 'compiled': { From 1b6e1b344e69da9784c660fba7a25c0a7bf27b41 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 20 Sep 2022 15:32:46 +0530 Subject: [PATCH 59/60] features for oz templates --- .../workspace/src/lib/remix-ui-workspace.tsx | 30 +++++++++++++++++-- .../src/templates/ozerc1155/index.ts | 6 ++++ .../src/templates/ozerc20/index.ts | 6 ++++ .../src/templates/ozerc721/index.ts | 6 ++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 5610fc2b1d..3fe327f9e5 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -16,6 +16,7 @@ export function Workspace () { const [selectedWorkspace, setSelectedWorkspace] = useState<{ name: string, isGitRepo: boolean}>(null) const [showDropdown, setShowDropdown] = useState(false) const displayOzCustomRef = useRef() + const ozFeatures = useRef({mintable: false, burnable: false, pausable: false}) const upgradeable = useRef() const global = useContext(FileSystemContext) const workspaceRenameInput = useRef() @@ -108,9 +109,10 @@ export function Workspace () { // @ts-ignore: Object is possibly 'null'. const workspaceTemplateName = workspaceCreateTemplateInput.current.value || 'remixDefault' const initGitRepo = initGitRepoRef.current.checked - + const features = ozFeatures.current const opts = { - upgradeable: upgradeable.current + upgradeable: upgradeable.current, + features } try { @@ -150,6 +152,7 @@ export function Workspace () { if (workspaceCreateTemplateInput.current.value.startsWith('oz') && displayOzCustomRef && displayOzCustomRef.current) { displayOzCustomRef.current.style.display = 'block' upgradeable.current = undefined + ozFeatures.current = {mintable: false, burnable: false, pausable: false} } else displayOzCustomRef.current.style.display = 'none' // @ts-ignore @@ -177,6 +180,11 @@ export function Workspace () { workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value + '_upgradeable'}_${Date.now()}` } + const handleFeatures = (e) => { + // @ts-ignore + ozFeatures.current[e.target.value] = e.target.checked + } + const createModalMessage = () => { return ( <> @@ -198,6 +206,23 @@ export function Workspace () {
+ + +
handleFeatures(e)}> +
+ + +
+
+ + +
+
+ + +
+
+
handleUpgradeability(e)}>
@@ -209,6 +234,7 @@ export function Workspace () {
+
diff --git a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts index 2bbd5a5673..4164d91e76 100644 --- a/libs/remix-ws-templates/src/templates/ozerc1155/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc1155/index.ts @@ -1,6 +1,12 @@ import { erc1155 } from '@openzeppelin/wizard'; export default async (opts) => { + if (opts.features) { + erc1155.defaults.mintable = opts.features.mintable + erc1155.defaults.burnable = opts.features.burnable + erc1155.defaults.pausable = opts.features.pausable + } + const filesObj = { 'contracts/MyToken.sol': erc1155.print({ ...erc1155.defaults, upgradeable: opts.upgradeable}), // @ts-ignore diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 3a070be29e..5eca9475f8 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -1,6 +1,12 @@ import { erc20 } from '@openzeppelin/wizard'; export default async (opts) => { + if (opts.features) { + erc20.defaults.mintable = opts.features.mintable + erc20.defaults.burnable = opts.features.burnable + erc20.defaults.pausable = opts.features.pausable + } + const filesObj = { 'contracts/MyToken.sol': erc20.print({ ...erc20.defaults, upgradeable: opts.upgradeable}), // @ts-ignore diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts index 35f91450b3..5c7f01293d 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -1,6 +1,12 @@ import { erc721 } from '@openzeppelin/wizard'; export default async (opts) => { + if (opts.features) { + erc721.defaults.mintable = opts.features.mintable + erc721.defaults.burnable = opts.features.burnable + erc721.defaults.pausable = opts.features.pausable + } + const filesObj = { 'contracts/MyToken.sol': erc721.print({ ...erc721.defaults, upgradeable: opts.upgradeable}), // @ts-ignore From c72b2da1222c417d4f4c22d04e126723335bec31 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 20 Sep 2022 18:39:15 +0530 Subject: [PATCH 60/60] e2e tests --- .../remix-ide-e2e/src/tests/workspace.test.ts | 84 ++++++++++++++++--- .../workspace/src/lib/remix-ui-workspace.tsx | 2 +- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index bf683aa722..139c50d77b 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -66,7 +66,7 @@ module.exports = { }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(2000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') @@ -129,28 +129,28 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') // check js and ts files are not transformed .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') - .pause(5000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, 'Incorrect content') @@ -177,28 +177,28 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') // check js and ts files are not transformed .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') - .pause(4000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, 'Incorrect content') @@ -225,28 +225,28 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') // check js and ts files are not transformed .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') - .pause(4000) + .pause(1000) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') }) .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, 'Incorrect content') @@ -255,6 +255,64 @@ module.exports = { .waitForElementVisible('*[data-id="treeViewLitreeViewItemtests/MyToken_test.sol"]') }, + 'Should create ERC1155 workspace with template customizations #group1': function (browser: NightwatchBrowser) { + browser + .click('*[data-id="workspaceCreate"]') + .waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]') + .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > button') + .click('select[id="wstemplate"]') + .click('select[id="wstemplate"] option[value=ozerc1155]') + .waitForElementPresent('*[data-id="ozCustomization"]') + .click('*[data-id="featureTypeMintable"]') + .click('*[data-id="featureTypeBurnable"]') + .click('*[data-id="featureTypePausable"]') + .click('*[data-id="upgradeTypeUups"]') + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .pause(100) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]') + .click('*[data-id="treeViewLitreeViewItemcontracts/MyToken.sol"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`contract MyToken is Initializable, ERC1155Upgradeable, OwnableUpgradeable, PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable {`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts"]') + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, + 'Incorrect content') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + 'Incorrect content') + browser.assert.ok(content.indexOf(`gas: gas || 3600000`) !== -1, + 'Incorrect gas cost') + }) + .waitForElementVisible('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, + 'Incorrect content') + }) + // No test file is added in upgradeable contract template + }, + // WORKSPACE TEMPLATES E2E END 'Should create two workspace and switch to the first one #group1': function (browser: NightwatchBrowser) { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 3fe327f9e5..7aef284f10 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -204,7 +204,7 @@ export function Workspace () {
-
+