From 786c693c21fccf9220f6b53d2d678adb7ea13c48 Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 19 Jan 2021 10:24:53 +0100 Subject: [PATCH] Added linting config --- libs/remix-ui/debugger-ui/.eslintrc | 262 +----------------- libs/remix-ui/debugger-ui/jest.config.js | 2 +- .../debugger-ui/src/hooks/extract-data.tsx | 96 +++---- .../lib/button-navigator/button-navigator.tsx | 4 +- .../debugger-ui/src/lib/debugger-ui.tsx | 93 +++---- .../debugger-ui/src/lib/idebugger-api.ts | 8 +- .../debugger-ui/src/lib/slider/slider.tsx | 20 +- .../src/lib/step-manager/step-manager.tsx | 2 +- .../src/lib/tx-browser/tx-browser.tsx | 2 +- .../src/lib/vm-debugger/assembly-items.tsx | 2 +- .../src/lib/vm-debugger/calldata-panel.tsx | 2 +- .../src/lib/vm-debugger/callstack-panel.tsx | 2 +- .../src/lib/vm-debugger/code-list-view.tsx | 4 +- .../src/lib/vm-debugger/dropdown-panel.tsx | 6 +- .../lib/vm-debugger/full-storages-changes.tsx | 2 +- .../src/lib/vm-debugger/solidity-locals.tsx | 4 +- .../src/lib/vm-debugger/solidity-state.tsx | 60 ++-- .../src/lib/vm-debugger/vm-debugger-head.tsx | 8 +- .../src/reducers/assembly-items.ts | 62 ++--- .../debugger-ui/src/reducers/calldata.ts | 76 ++--- libs/remix-ui/debugger-ui/src/types/index.ts | 2 +- .../src/utils/solidityTypeFormatter.ts | 78 +++--- package.json | 2 +- 23 files changed, 283 insertions(+), 516 deletions(-) diff --git a/libs/remix-ui/debugger-ui/.eslintrc b/libs/remix-ui/debugger-ui/.eslintrc index 73f9b856ee..b8666066e9 100644 --- a/libs/remix-ui/debugger-ui/.eslintrc +++ b/libs/remix-ui/debugger-ui/.eslintrc @@ -1,250 +1,18 @@ { - "rules": { - "@typescript-eslint/ban-types": "off", - "no-case-declarations": "off", - "array-callback-return": "warn", - "dot-location": ["warn", "property"], - "eqeqeq": ["warn", "smart"], - "new-parens": "warn", - "no-caller": "warn", - "no-cond-assign": ["warn", "except-parens"], - "no-const-assign": "warn", - "no-control-regex": "warn", - "no-delete-var": "warn", - "no-dupe-args": "warn", - "no-dupe-keys": "warn", - "no-duplicate-case": "warn", - "no-empty-character-class": "warn", - "no-empty-pattern": "warn", - "no-eval": "warn", - "no-ex-assign": "warn", - "no-extend-native": "warn", - "no-extra-bind": "warn", - "no-extra-label": "warn", - "no-fallthrough": "warn", - "no-func-assign": "warn", - "no-implied-eval": "warn", - "no-invalid-regexp": "warn", - "no-iterator": "warn", - "no-label-var": "warn", - "no-labels": ["warn", { "allowLoop": true, "allowSwitch": false }], - "no-lone-blocks": "warn", - "no-loop-func": "warn", - "no-mixed-operators": [ - "warn", - { - "groups": [ - ["&", "|", "^", "~", "<<", ">>", ">>>"], - ["==", "!=", "===", "!==", ">", ">=", "<", "<="], - ["&&", "||"], - ["in", "instanceof"] - ], - "allowSamePrecedence": false - } - ], - "no-multi-str": "warn", - "no-native-reassign": "warn", - "no-negated-in-lhs": "warn", - "no-new-func": "warn", - "no-new-object": "warn", - "no-new-symbol": "warn", - "no-new-wrappers": "warn", - "no-obj-calls": "warn", - "no-octal": "warn", - "no-octal-escape": "warn", - "no-redeclare": "warn", - "no-regex-spaces": "warn", - "no-restricted-syntax": ["warn", "WithStatement"], - "no-script-url": "warn", - "no-self-assign": "warn", - "no-self-compare": "warn", - "no-sequences": "warn", - "no-shadow-restricted-names": "warn", - "no-sparse-arrays": "warn", - "no-template-curly-in-string": "warn", - "no-this-before-super": "warn", - "no-throw-literal": "warn", - "no-restricted-globals": [ - "error", - "addEventListener", - "blur", - "close", - "closed", - "confirm", - "defaultStatus", - "defaultstatus", - "event", - "external", - "find", - "focus", - "frameElement", - "frames", - "history", - "innerHeight", - "innerWidth", - "length", - "location", - "locationbar", - "menubar", - "moveBy", - "moveTo", - "name", - "onblur", - "onerror", - "onfocus", - "onload", - "onresize", - "onunload", - "open", - "opener", - "opera", - "outerHeight", - "outerWidth", - "pageXOffset", - "pageYOffset", - "parent", - "print", - "removeEventListener", - "resizeBy", - "resizeTo", - "screen", - "screenLeft", - "screenTop", - "screenX", - "screenY", - "scroll", - "scrollbars", - "scrollBy", - "scrollTo", - "scrollX", - "scrollY", - "self", - "status", - "statusbar", - "stop", - "toolbar", - "top" - ], - "no-unexpected-multiline": "warn", - "no-unreachable": "warn", - "no-unused-expressions": [ - "error", - { - "allowShortCircuit": true, - "allowTernary": true, - "allowTaggedTemplates": true - } - ], - "no-unused-labels": "warn", - "no-useless-computed-key": "warn", - "no-useless-concat": "warn", - "no-useless-escape": "warn", - "no-useless-rename": [ - "warn", - { - "ignoreDestructuring": false, - "ignoreImport": false, - "ignoreExport": false - } - ], - "no-with": "warn", - "no-whitespace-before-property": "warn", - "react-hooks/exhaustive-deps": "warn", - "require-yield": "warn", - "rest-spread-spacing": ["warn", "never"], - "strict": ["warn", "never"], - "unicode-bom": ["warn", "never"], - "use-isnan": "warn", - "valid-typeof": "warn", - "no-restricted-properties": [ - "error", - { - "object": "require", - "property": "ensure", - "message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting" - }, - { - "object": "System", - "property": "import", - "message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting" - } - ], - "getter-return": "warn", - "import/first": "error", - "import/no-amd": "error", - "import/no-webpack-loader-syntax": "error", - "react/forbid-foreign-prop-types": ["warn", { "allowInPropTypes": true }], - "react/jsx-no-comment-textnodes": "warn", - "react/jsx-no-duplicate-props": "warn", - "react/jsx-no-target-blank": "warn", - "react/jsx-no-undef": "error", - "react/jsx-pascal-case": ["warn", { "allowAllCaps": true, "ignore": [] }], - "react/jsx-uses-react": "warn", - "react/jsx-uses-vars": "warn", - "react/no-danger-with-children": "warn", - "react/no-direct-mutation-state": "warn", - "react/no-is-mounted": "warn", - "react/no-typos": "error", - "react/react-in-jsx-scope": "error", - "react/require-render-return": "error", - "react/style-prop-object": "warn", - "react/jsx-no-useless-fragment": "warn", - "jsx-a11y/accessible-emoji": "warn", - "jsx-a11y/alt-text": "warn", - "jsx-a11y/anchor-has-content": "warn", - "jsx-a11y/anchor-is-valid": [ - "warn", - { "aspects": ["noHref", "invalidHref"] } - ], - "jsx-a11y/aria-activedescendant-has-tabindex": "warn", - "jsx-a11y/aria-props": "warn", - "jsx-a11y/aria-proptypes": "warn", - "jsx-a11y/aria-role": "warn", - "jsx-a11y/aria-unsupported-elements": "warn", - "jsx-a11y/heading-has-content": "warn", - "jsx-a11y/iframe-has-title": "warn", - "jsx-a11y/img-redundant-alt": "warn", - "jsx-a11y/no-access-key": "warn", - "jsx-a11y/no-distracting-elements": "warn", - "jsx-a11y/no-redundant-roles": "warn", - "jsx-a11y/role-has-required-aria-props": "warn", - "jsx-a11y/role-supports-aria-props": "warn", - "jsx-a11y/scope": "warn", - "react-hooks/rules-of-hooks": "error", - "default-case": "off", - "no-dupe-class-members": "off", - "no-undef": "off", - "@typescript-eslint/consistent-type-assertions": "warn", - "no-array-constructor": "off", - "@typescript-eslint/no-array-constructor": "warn", - "@typescript-eslint/no-namespace": "error", - "no-use-before-define": "off", - "@typescript-eslint/no-use-before-define": [ - "warn", - { - "functions": false, - "classes": false, - "variables": false, - "typedefs": false - } - ], - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "warn", - { "args": "none", "ignoreRestSiblings": true } - ], - "no-useless-constructor": "off", - "@typescript-eslint/no-useless-constructor": "warn" - }, "env": { - "browser": true, - "commonjs": true, - "es6": true, - "jest": true, - "node": true + "browser": true, + "es6": true + }, + "extends": "../../../.eslintrc", + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" }, - "settings": { "react": { "version": "detect" } }, - "plugins": ["import", "jsx-a11y", "react", "react-hooks"], - "extends": ["../../../.eslintrc"], - "ignorePatterns": ["!**/*"] -} + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + }, + "rules": { + "standard/no-callback-literal": "off" + } +} diff --git a/libs/remix-ui/debugger-ui/jest.config.js b/libs/remix-ui/debugger-ui/jest.config.js index 7b3def7c76..1505cc5eff 100644 --- a/libs/remix-ui/debugger-ui/jest.config.js +++ b/libs/remix-ui/debugger-ui/jest.config.js @@ -9,4 +9,4 @@ module.exports = { }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'], coverageDirectory: '../../coverage/libs/debugger-ui' -}; +} diff --git a/libs/remix-ui/debugger-ui/src/hooks/extract-data.tsx b/libs/remix-ui/debugger-ui/src/hooks/extract-data.tsx index da28dfb4bb..d65090363a 100644 --- a/libs/remix-ui/debugger-ui/src/hooks/extract-data.tsx +++ b/libs/remix-ui/debugger-ui/src/hooks/extract-data.tsx @@ -2,57 +2,57 @@ import React, { useState, useEffect } from 'react' import { ExtractData, ExtractFunc } from '../types' export const useExtractData = (json, extractFunc?: ExtractFunc): Array<{ key: string, data: ExtractData }> => { - const [data, setData] = useState([]) - - useEffect(() => { - const data: Array<{ key: string, data: ExtractData }> = Object.keys(json).map((innerKey) => { - if (extractFunc) { - return { - key: innerKey, - data : extractFunc(json[innerKey], json) - } - } else { - return { - key: innerKey, - data: extractDataDefault(json[innerKey], json) - } - } - }) - - setData(data) - - return () => { - setData(null) + const [data, setData] = useState([]) + + useEffect(() => { + const data: Array<{ key: string, data: ExtractData }> = Object.keys(json).map((innerKey) => { + if (extractFunc) { + return { + key: innerKey, + data: extractFunc(json[innerKey], json) } - }, [json, extractFunc]) - - const extractDataDefault: ExtractFunc = (item, parent?) => { - const ret: ExtractData = {} - - if (item instanceof Array) { - ret.children = item.map((item, index) => { - return {key: index, value: item} - }) - ret.self = 'Array' - ret.isNode = true - ret.isLeaf = false - } else if (item instanceof Object) { - ret.children = Object.keys(item).map((key) => { - return {key: key, value: item[key]} - }) - ret.self = 'Object' - ret.isNode = true - ret.isLeaf = false - } else { - ret.self = item - ret.children = null - ret.isNode = false - ret.isLeaf = true + } else { + return { + key: innerKey, + data: extractDataDefault(json[innerKey], json) } - return ret + } + }) + + setData(data) + + return () => { + setData(null) + } + }, [json, extractFunc]) + + const extractDataDefault: ExtractFunc = (item, parent?) => { + const ret: ExtractData = {} + + if (item instanceof Array) { + ret.children = item.map((item, index) => { + return { key: index, value: item } + }) + ret.self = 'Array' + ret.isNode = true + ret.isLeaf = false + } else if (item instanceof Object) { + ret.children = Object.keys(item).map((key) => { + return { key: key, value: item[key] } + }) + ret.self = 'Object' + ret.isNode = true + ret.isLeaf = false + } else { + ret.self = item + ret.children = null + ret.isNode = false + ret.isLeaf = true } + return ret + } - return data + return data } -export default useExtractData \ No newline at end of file +export default useExtractData diff --git a/libs/remix-ui/debugger-ui/src/lib/button-navigator/button-navigator.tsx b/libs/remix-ui/debugger-ui/src/lib/button-navigator/button-navigator.tsx index 8e2a893227..98da9e6eb7 100644 --- a/libs/remix-ui/debugger-ui/src/lib/button-navigator/button-navigator.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/button-navigator/button-navigator.tsx @@ -45,7 +45,7 @@ export const ButtonNavigation = ({ stepOverBack, stepIntoBack, stepIntoForward, intoForwardDisabled: stepState === 'end', overForwardDisabled: stepState === 'end', jumpNextBreakpointDisabled: stepState === 'end', - jumpOutDisabled: jumpOutDisabled ? jumpOutDisabled : true + jumpOutDisabled: jumpOutDisabled || true } }) } @@ -60,7 +60,7 @@ export const ButtonNavigation = ({ stepOverBack, stepIntoBack, stepIntoForward,
- +
diff --git a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx index b8cd7b9bcf..8c6fcc2fca 100644 --- a/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/debugger-ui.tsx @@ -34,7 +34,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { }, []) debuggerModule.onDebugRequested((hash) => { - if (hash) debug(hash) + if (hash) debug(hash) }) debuggerModule.onRemoveHighlights(async () => { @@ -43,15 +43,14 @@ export const DebuggerUI = (props: DebuggerUIProps) => { useEffect(() => { const setEditor = () => { - debuggerModule.onBreakpointCleared((fileName, row) => { - if (state.debugger) state.debugger.breakPointManager.remove({fileName: fileName, row: row}) + if (state.debugger) state.debugger.breakPointManager.remove({ fileName: fileName, row: row }) }) - + debuggerModule.onBreakpointAdded((fileName, row) => { - if (state.debugger) state.debugger.breakPointManager.add({fileName: fileName, row: row}) + if (state.debugger) state.debugger.breakPointManager.add({ fileName: fileName, row: row }) }) - + debuggerModule.onEditorContentChanged(() => { if (state.debugger) unLoad() }) @@ -65,7 +64,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { debuggerInstance.event.register('debuggerStatus', async (isActive) => { await debuggerModule.discardHighlight() - setState( prevState => { + setState(prevState => { return { ...prevState, isActive } }) }) @@ -151,7 +150,7 @@ export const DebuggerUI = (props: DebuggerUIProps) => { offsetToLineColumnConverter: debuggerModule.offsetToLineColumnConverter, compilationResult: async (address) => { try { - const ret = await debuggerModule.fetchContractAndCompile(address, currentReceipt) + const ret = await debuggerModule.fetchContractAndCompile(address, currentReceipt) return ret } catch (e) { console.error(e) @@ -184,49 +183,49 @@ export const DebuggerUI = (props: DebuggerUIProps) => { }) } -const debug = (txHash) => { - startDebugging(null, txHash, null) -} + const debug = (txHash) => { + startDebugging(null, txHash, null) + } -const stepManager = { - jumpTo: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpTo.bind(state.debugger.step_manager) : null, - stepOverBack: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepOverBack.bind(state.debugger.step_manager) : null, - stepIntoBack: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepIntoBack.bind(state.debugger.step_manager) : null, - stepIntoForward: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepIntoForward.bind(state.debugger.step_manager) : null, - stepOverForward: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepOverForward.bind(state.debugger.step_manager) : null, - jumpOut: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpOut.bind(state.debugger.step_manager) : null, - jumpPreviousBreakpoint: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpPreviousBreakpoint.bind(state.debugger.step_manager) : null, - jumpNextBreakpoint: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpNextBreakpoint.bind(state.debugger.step_manager) : null, - jumpToException: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpToException.bind(state.debugger.step_manager) : null, - traceLength: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.traceLength : null, - registerEvent: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.event.register.bind(state.debugger.step_manager.event) : null, -} -const vmDebugger = { - registerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.register.bind(state.debugger.vmDebuggerLogic.event) : null, - triggerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.trigger.bind(state.debugger.vmDebuggerLogic.event) : null -} - return ( -
- -
-
-

Debugger Configuration

-
- { - setState(prevState => { - return { ...prevState, opt: { debugWithGeneratedSources: checked }} - }) - }} type="checkbox" title="Debug with generated sources" /> - -
+ const stepManager = { + jumpTo: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpTo.bind(state.debugger.step_manager) : null, + stepOverBack: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepOverBack.bind(state.debugger.step_manager) : null, + stepIntoBack: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepIntoBack.bind(state.debugger.step_manager) : null, + stepIntoForward: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepIntoForward.bind(state.debugger.step_manager) : null, + stepOverForward: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.stepOverForward.bind(state.debugger.step_manager) : null, + jumpOut: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpOut.bind(state.debugger.step_manager) : null, + jumpPreviousBreakpoint: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpPreviousBreakpoint.bind(state.debugger.step_manager) : null, + jumpNextBreakpoint: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpNextBreakpoint.bind(state.debugger.step_manager) : null, + jumpToException: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.jumpToException.bind(state.debugger.step_manager) : null, + traceLength: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.traceLength : null, + registerEvent: state.debugger && state.debugger.step_manager ? state.debugger.step_manager.event.register.bind(state.debugger.step_manager.event) : null + } + const vmDebugger = { + registerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.register.bind(state.debugger.vmDebuggerLogic.event) : null, + triggerEvent: state.debugger && state.debugger.vmDebuggerLogic ? state.debugger.vmDebuggerLogic.event.trigger.bind(state.debugger.vmDebuggerLogic.event) : null + } + return ( +
+ +
+
+

Debugger Configuration

+
+ { + setState(prevState => { + return { ...prevState, opt: { debugWithGeneratedSources: checked } } + }) + }} type="checkbox" title="Debug with generated sources" /> +
- - { state.debugging && } - { state.debugging && }
- { state.debugging &&
{ state.statusMessage }
} - { state.debugging && } + + { state.debugging && } + { state.debugging && }
+ { state.debugging &&
{ state.statusMessage }
} + { state.debugging && } +
) } diff --git a/libs/remix-ui/debugger-ui/src/lib/idebugger-api.ts b/libs/remix-ui/debugger-ui/src/lib/idebugger-api.ts index 418cd9ba4a..212d6cac3d 100644 --- a/libs/remix-ui/debugger-ui/src/lib/idebugger-api.ts +++ b/libs/remix-ui/debugger-ui/src/lib/idebugger-api.ts @@ -2,13 +2,13 @@ import type { CompilationResult, CompilationSource } from '@remix-project/remix-solidity-ts' export interface DebuggerUIProps { - debuggerAPI: IDebuggerApi + debuggerAPI: IDebuggerApi } export interface LineColumnLocation { start: { line: number, column: number - }, + }, end: { line: number, column: number } @@ -39,7 +39,7 @@ export interface TransactionReceipt { transactionIndex: number from: string to: string - contractAddress: string | null + contractAddress: string | null } export type onBreakpointClearedListener = (params: string, row: number) => void @@ -63,4 +63,4 @@ export interface IDebuggerApi { getFile: (path: string) => Promise setFile: (path: string, content: string) => Promise getDebugWeb3: () => any // returns an instance of web3.js -} \ No newline at end of file +} diff --git a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx index 691b4175a1..bfd184fd78 100644 --- a/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/slider/slider.tsx @@ -25,16 +25,16 @@ export const Slider = ({ jumpTo, sliderValue, traceLength }) => { return (
- +
) } diff --git a/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx b/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx index 75259c179c..21812cf58e 100644 --- a/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/step-manager/step-manager.tsx @@ -31,7 +31,7 @@ export const StepManager = ({ stepManager: { jumpTo, traceLength, stepIntoBack, return (
- { debugging ? 'Stop' : 'Start' } debugging diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx index 77d4f0c5fa..d80b189f1e 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/assembly-items.tsx @@ -58,4 +58,4 @@ export const AssemblyItems = ({ registerEvent }) => { ) } -export default AssemblyItems \ No newline at end of file +export default AssemblyItems diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx index 70fc5be139..d9bc218adb 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/calldata-panel.tsx @@ -9,4 +9,4 @@ export const CalldataPanel = ({ calldata }) => { ) } -export default CalldataPanel \ No newline at end of file +export default CalldataPanel diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx index 63183b3ed5..974a2ffb37 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/callstack-panel.tsx @@ -9,4 +9,4 @@ export const CallstackPanel = ({ calldata }) => { ) } -export default CallstackPanel \ No newline at end of file +export default CallstackPanel diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx index 0869755cb1..13b83e7a0c 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/code-list-view.tsx @@ -10,7 +10,7 @@ export const CodeListView = ({ registerEvent }) => { }) const indexChanged = (index) => { - if(index < 0) return + if (index < 0) return setState(prevState => { return { ...prevState, @@ -31,7 +31,7 @@ export const CodeListView = ({ registerEvent }) => { } }) indexChanged(index) - } + } return (
diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx index 7a6d35b37b..332e334aed 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/dropdown-panel.tsx @@ -134,7 +134,7 @@ export const DropdownPanel = (props: DropdownPanelProps) => { } const update = function (calldata) { - let isEmpty = !calldata ? true : false + let isEmpty = !calldata if (calldata && Array.isArray(calldata) && calldata.length === 0) isEmpty = true else if (calldata && Object.keys(calldata).length === 0 && calldata.constructor === Object) isEmpty = true @@ -171,7 +171,7 @@ export const DropdownPanel = (props: DropdownPanelProps) => { handleExpand(keyPath)} expand={state.expandPath.includes(keyPath)}> {children} - {data.hasNext && { triggerEvent(loadMoreEvent, [data.cursor]) }} />} + {data.hasNext && { triggerEvent(loadMoreEvent, [data.cursor]) }} />} ) @@ -208,4 +208,4 @@ export const DropdownPanel = (props: DropdownPanelProps) => { ) } -export default DropdownPanel \ No newline at end of file +export default DropdownPanel diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx index 1bed4b97d1..5faa0b8f03 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/full-storages-changes.tsx @@ -9,4 +9,4 @@ export const FullStoragesChanges = ({ calldata }) => { ) } -export default FullStoragesChanges \ No newline at end of file +export default FullStoragesChanges diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx index bcf8ce11dd..80ef3c85e9 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/solidity-locals.tsx @@ -44,7 +44,7 @@ export const SolidityLocals = ({ data, message, registerEvent, triggerEvent }) = return (
- { - const formatSelf = (key: string, data: ExtractData) => { - let color = 'var(--primary)' - if (data.isArray || data.isStruct || data.isMapping) { - color = 'var(--info)' - } else if ( - data.type.indexOf('uint') === 0 || + const formatSelf = (key: string, data: ExtractData) => { + let color = 'var(--primary)' + if (data.isArray || data.isStruct || data.isMapping) { + color = 'var(--info)' + } else if ( + data.type.indexOf('uint') === 0 || data.type.indexOf('int') === 0 || data.type.indexOf('bool') === 0 || data.type.indexOf('enum') === 0 - ) { - color = 'var(--green)' - } else if (data.type === 'string') { - color = 'var(--teal)' + ) { + color = 'var(--green)' + } else if (data.type === 'string') { + color = 'var(--teal)' } else if (data.self == 0x0) { // eslint-disable-line - color = 'var(--gray)' - } - return ( - - ) + color = 'var(--gray)' } - return ( -
- { - - } -
+ ) + } + + return ( +
+ { + + } +
+ ) } -export default SolidityState \ No newline at end of file +export default SolidityState diff --git a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx index f9ed8d7612..7ea61fd67e 100644 --- a/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx +++ b/libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger-head.tsx @@ -11,7 +11,7 @@ export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent } }) 'vm trace step': '-', 'execution step': '-', 'add memory': '', - 'gas': '', + gas: '', 'remaining gas': '-', 'loaded address': '-' }) @@ -36,12 +36,12 @@ export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent } }) }) registerEvent && registerEvent('traceUnloaded', () => { setStepDetail(() => { - return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } + return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', gas: '', 'remaining gas': '-', 'loaded address': '-' } }) }) registerEvent && registerEvent('newTraceLoaded', () => { setStepDetail(() => { - return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', 'gas': '', 'remaining gas': '-', 'loaded address': '-' } + return { 'vm trace step': '-', 'execution step': '-', 'add memory': '', gas: '', 'remaining gas': '-', 'loaded address': '-' } }) }) registerEvent && registerEvent('traceCurrentStepUpdate', (error, step) => { @@ -56,7 +56,7 @@ export const VmDebuggerHead = ({ vmDebugger: { registerEvent, triggerEvent } }) }) registerEvent && registerEvent('traceStepCostUpdate', (error, gas) => { setStepDetail(prevState => { - return { ...prevState, 'gas': (error ? '-' : gas) } + return { ...prevState, gas: (error ? '-' : gas) } }) }) registerEvent && registerEvent('traceCurrentCalledAddressAtUpdate', (error, address) => { diff --git a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts index 12af113a14..f47eaedd67 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/assembly-items.ts @@ -6,18 +6,18 @@ interface Action { } export const initialState = { - opCodes: { - code: [], - index: 0, - address: '' - }, - display: [], + opCodes: { + code: [], index: 0, - top: 0, - bottom: 0, - isRequesting: false, - isSuccessful: false, - hasError: null + address: '' + }, + display: [], + index: 0, + top: 0, + bottom: 0, + isRequesting: false, + isSuccessful: false, + hasError: null } export const reducer = (state = initialState, action: Action) => { @@ -28,36 +28,36 @@ export const reducer = (state = initialState, action: Action) => { isRequesting: true, isSuccessful: false, hasError: null - }; + } } case 'FETCH_OPCODES_SUCCESS': { - const opCodes = action.payload.address === state.opCodes.address ? { - ...state.opCodes, index: action.payload.index + const opCodes = action.payload.address === state.opCodes.address ? { + ...state.opCodes, index: action.payload.index } : deepEqual(action.payload.code, state.opCodes.code) ? state.opCodes : action.payload const top = opCodes.index - 3 > 0 ? opCodes.index - 3 : 0 const bottom = opCodes.index + 4 < opCodes.code.length ? opCodes.index + 4 : opCodes.code.length - const display = opCodes.code.slice(top, bottom) + const display = opCodes.code.slice(top, bottom) return { - opCodes, - display, - index: display.findIndex(code => code === opCodes.code[opCodes.index]), - top, - bottom, - isRequesting: false, - isSuccessful: true, - hasError: null - }; + opCodes, + display, + index: display.findIndex(code => code === opCodes.code[opCodes.index]), + top, + bottom, + isRequesting: false, + isSuccessful: true, + hasError: null + } } case 'FETCH_OPCODES_ERROR': { return { - ...state, - isRequesting: false, - isSuccessful: false, - hasError: action.payload - }; + ...state, + isRequesting: false, + isSuccessful: false, + hasError: action.payload + } } default: - throw new Error(); + throw new Error() } -} \ No newline at end of file +} diff --git a/libs/remix-ui/debugger-ui/src/reducers/calldata.ts b/libs/remix-ui/debugger-ui/src/reducers/calldata.ts index aa37739a7a..e33425d8fd 100644 --- a/libs/remix-ui/debugger-ui/src/reducers/calldata.ts +++ b/libs/remix-ui/debugger-ui/src/reducers/calldata.ts @@ -4,58 +4,58 @@ interface Action { } export const initialState = { - calldata: {}, - isRequesting: false, - isSuccessful: false, - hasError: null + calldata: {}, + isRequesting: false, + isSuccessful: false, + hasError: null } export const reducer = (state = initialState, action: Action) => { switch (action.type) { case 'FETCH_CALLDATA_REQUEST': return { - ...state, - isRequesting: true, - isSuccessful: false, - hasError: null - }; + ...state, + isRequesting: true, + isSuccessful: false, + hasError: null + } case 'FETCH_CALLDATA_SUCCESS': return { - calldata: action.payload, - isRequesting: false, - isSuccessful: true, - hasError: null - }; + calldata: action.payload, + isRequesting: false, + isSuccessful: true, + hasError: null + } case 'FETCH_CALLDATA_ERROR': - return { - ...state, - isRequesting: false, - isSuccessful: false, - hasError: action.payload - }; + return { + ...state, + isRequesting: false, + isSuccessful: false, + hasError: action.payload + } case 'UPDATE_CALLDATA_REQUEST': return { - ...state, - isRequesting: true, - isSuccessful: false, - hasError: null - }; + ...state, + isRequesting: true, + isSuccessful: false, + hasError: null + } case 'UPDATE_CALLDATA_SUCCESS': return { - calldata: mergeLocals(action.payload, state.calldata), - isRequesting: false, - isSuccessful: true, - hasError: null - }; + calldata: mergeLocals(action.payload, state.calldata), + isRequesting: false, + isSuccessful: true, + hasError: null + } case 'UPDATE_CALLDATA_ERROR': - return { - ...state, - isRequesting: false, - isSuccessful: false, - hasError: action.payload - }; + return { + ...state, + isRequesting: false, + isSuccessful: false, + hasError: action.payload + } default: - throw new Error(); + throw new Error() } } @@ -69,4 +69,4 @@ function mergeLocals (locals1, locals2) { } }) return locals2 -} \ No newline at end of file +} diff --git a/libs/remix-ui/debugger-ui/src/types/index.ts b/libs/remix-ui/debugger-ui/src/types/index.ts index 7b3861b251..45a26384dc 100644 --- a/libs/remix-ui/debugger-ui/src/types/index.ts +++ b/libs/remix-ui/debugger-ui/src/types/index.ts @@ -30,4 +30,4 @@ export interface DropdownPanelProps { loadMoreCompletedEvent?: string } -export type FormatSelfFunc = (key: string | number, data: ExtractData) => JSX.Element \ No newline at end of file +export type FormatSelfFunc = (key: string | number, data: ExtractData) => JSX.Element diff --git a/libs/remix-ui/debugger-ui/src/utils/solidityTypeFormatter.ts b/libs/remix-ui/debugger-ui/src/utils/solidityTypeFormatter.ts index c0d0dfcb3b..25015892e3 100644 --- a/libs/remix-ui/debugger-ui/src/utils/solidityTypeFormatter.ts +++ b/libs/remix-ui/debugger-ui/src/utils/solidityTypeFormatter.ts @@ -2,43 +2,43 @@ import { BN } from 'ethereumjs-util' import { ExtractData } from '../types' export function extractData (item, parent): ExtractData { - const ret: ExtractData = {} + const ret: ExtractData = {} - if (item.isProperty) { - return item - } - if (item.type.lastIndexOf(']') === item.type.length - 1) { - ret.children = (item.value || []).map(function (item, index) { - return {key: index, value: item} - }) - ret.children.unshift({ - key: 'length', - value: { - self: (new BN(item.length.replace('0x', ''), 16)).toString(10), - type: 'uint', - isProperty: true - } - }) - ret.isArray = true - ret.self = parent.isArray ? '' : item.type - ret.cursor = item.cursor - ret.hasNext = item.hasNext - } else if (item.type.indexOf('struct') === 0) { - ret.children = Object.keys((item.value || {})).map(function (key) { - return {key: key, value: item.value[key]} - }) - ret.self = item.type - ret.isStruct = true - } else if (item.type.indexOf('mapping') === 0) { - ret.children = Object.keys((item.value || {})).map(function (key) { - return {key: key, value: item.value[key]} - }) - ret.isMapping = true - ret.self = item.type - } else { - ret.children = null - ret.self = item.value - ret.type = item.type - } - return ret -} \ No newline at end of file + if (item.isProperty) { + return item + } + if (item.type.lastIndexOf(']') === item.type.length - 1) { + ret.children = (item.value || []).map(function (item, index) { + return { key: index, value: item } + }) + ret.children.unshift({ + key: 'length', + value: { + self: (new BN(item.length.replace('0x', ''), 16)).toString(10), + type: 'uint', + isProperty: true + } + }) + ret.isArray = true + ret.self = parent.isArray ? '' : item.type + ret.cursor = item.cursor + ret.hasNext = item.hasNext + } else if (item.type.indexOf('struct') === 0) { + ret.children = Object.keys((item.value || {})).map(function (key) { + return { key: key, value: item.value[key] } + }) + ret.self = item.type + ret.isStruct = true + } else if (item.type.indexOf('mapping') === 0) { + ret.children = Object.keys((item.value || {})).map(function (key) { + return { key: key, value: item.value[key] } + }) + ret.isMapping = true + ret.self = item.type + } else { + ret.children = null + ret.self = item.value + ret.type = item.type + } + return ret +} diff --git a/package.json b/package.json index 04c5887ac2..783ad4b020 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "workspace-schematic": "nx workspace-schematic", "dep-graph": "nx dep-graph", "help": "nx help", - "lint:libs": "nx run-many --target=lint --projects=remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer", + "lint:libs": "nx run-many --target=lint --projects=remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui", "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "publish:libs": "npm run build:libs & lerna publish --skip-git & npm run bumpVersion:libs",