From 6253be3f9f657a9a14f21941c76ae1db36e2193c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Such=C3=BD?= Date: Thu, 17 Feb 2022 18:15:59 +0100 Subject: [PATCH] chore: Prettier refactor, update, add CI check (#4950) * chore: remove redundant prettier, gitignore files * fix: Fix missign html opening tag * chore: upgrade prettier * chore(ci): Add prettier check to CI * chore(eslint): turn off prettier-eslint * chore: fix formatting of translations * chore: run prettier over whole codebase --- .eslintrc.js | 3 +- .github/ISSUE_TEMPLATE/01_bug.md | 15 +- .github/ISSUE_TEMPLATE/02_code.md | 1 - .github/ISSUE_TEMPLATE/03_product.md | 1 - .github/workflows/validation.yml | 2 + .prettierrc | 8 +- .vscode/launch.json | 11 +- .vscode/tasks.json | 106 +- CHANGELOG.md | 1 + LICENSE.md | 2 +- README.md | 14 +- ci/validation.yml | 6 + docs/packages/suite-desktop.md | 36 +- docs/releases/npm-packages.md | 3 +- lerna.json | 12 +- package.json | 6 +- packages/blockchain-link/.prettierignore | 6 - packages/blockchain-link/.prettierrc | 10 - packages/blockchain-link/CHANGELOG.md | 48 +- packages/blockchain-link/README.md | 10 +- .../blockchain-link/scripts/build.workers.js | 2 +- packages/blockchain-link/src/index.ts | 24 +- .../blockchain-link/src/types/blockbook.ts | 12 +- .../blockchain-link/src/types/blockfrost.ts | 12 +- .../blockchain-link/src/types/electrum.ts | 12 +- packages/blockchain-link/src/ui/index.html | 2 +- packages/blockchain-link/src/ui/index.ui.ts | 4 +- .../src/workers/blockbook/index.ts | 6 +- .../src/workers/blockbook/utils.ts | 8 +- .../src/workers/blockbook/websocket.ts | 4 +- .../src/workers/blockfrost/index.ts | 4 +- .../src/workers/blockfrost/utils.ts | 14 +- .../src/workers/blockfrost/websocket.ts | 4 +- .../src/workers/electrum/client/electrum.ts | 2 +- .../src/workers/electrum/index.ts | 2 +- .../electrum/listeners/blockListener.ts | 2 +- .../workers/electrum/listeners/txListener.ts | 8 +- .../workers/electrum/methods/estimateFee.ts | 4 +- .../methods/getAccountBalanceHistory.ts | 6 +- .../electrum/methods/getAccountInfo.ts | 16 +- .../electrum/methods/getAccountUtxo.ts | 4 +- .../workers/electrum/utils/addressManager.ts | 10 +- .../src/workers/electrum/utils/transaction.ts | 6 +- .../src/workers/electrum/utils/transform.ts | 2 +- .../src/workers/ripple/index.ts | 4 +- packages/blockchain-link/src/workers/state.ts | 6 +- packages/blockchain-link/src/workers/utils.ts | 2 +- .../tests/unit/blockfrost/utils.ts | 2 +- .../rfkV3EoXimH6JrG1QAyofgbVhnyZZDjWSj.json | 3 +- .../tests/websocket/fixtures/blockbook.json | 90 +- .../tests/websocket/fixtures/ripple.json | 2 +- .../blockchain-link/tests/websocket/index.ts | 2 +- packages/blockchain-link/tsconfig.json | 2 +- packages/blockchain-link/tsconfig.lib.json | 2 +- packages/components/.gitignore | 97 - packages/components/.npmignore | 18 - packages/components/.prettierignore | 10 - packages/components/.prettierrc | 11 - .../components/.storybook/manager-head.html | 2 +- .../components/.storybook/preview-head.html | 2 +- packages/components/.storybook/preview.js | 10 +- packages/components/README.md | 1 - .../src/components/Dropdown/index.stories.tsx | 2 +- .../src/components/Dropdown/index.tsx | 6 +- .../components/src/components/Fade/index.tsx | 2 +- .../src/components/Flag/all.stories.tsx | 2 +- .../src/components/HoverAnimation/index.tsx | 2 +- .../src/components/Icon/all.stories.tsx | 2 +- .../components/src/components/Icon/index.tsx | 4 +- .../src/components/Modal/index.stories.tsx | 4 +- .../components/Timerange/index.stories.tsx | 2 +- .../src/components/Tooltip/all.stories.tsx | 2 +- .../src/components/Tooltip/index.stories.tsx | 2 +- .../buttons/Button/index.stories.tsx | 6 +- .../src/components/buttons/Button/index.tsx | 4 +- .../src/components/buttons/index.stories.tsx | 2 +- .../src/components/form/Checkbox/index.tsx | 2 +- .../src/components/form/RadioButton/index.tsx | 2 +- .../src/components/form/Select/index.tsx | 10 +- .../components/loaders/Loader/all.stories.tsx | 2 +- .../logos/TrezorLogo/index.stories.tsx | 2 +- .../src/components/logos/index.stories.tsx | 2 +- .../src/components/others/Card/index.tsx | 2 +- .../prompts/ConfirmOnDevice/index.stories.tsx | 2 +- .../typography/Heading/index.stories.tsx | 4 +- .../typography/Link/index.stories.tsx | 2 +- .../typography/Paragraph/index.stories.tsx | 6 +- .../components/typography/index.stories.tsx | 2 +- packages/components/src/utils/hooks.ts | 2 +- packages/connect-common/.gitignore | 21 - packages/connect-common/CHANGELOG.md | 2 +- .../connect-common/files/bridge/releases.json | 78 +- packages/connect-iframe/.gitignore | 20 - packages/connect-iframe/README.md | 1 + .../connect-iframe/src/static/iframe.html | 56 +- packages/connect-iframe/tsconfig.json | 2 +- packages/news-api/.gitignore | 2 - packages/rollout/.prettierrc | 10 - packages/rollout/CHANGELOG.md | 32 +- packages/rollout/README.md | 14 +- packages/rollout/integration/get-binary.ts | 10 +- packages/rollout/src/index.ts | 10 +- packages/rollout/src/utils/parse.ts | 4 +- packages/rollout/src/utils/releases.ts | 6 +- packages/rollout/tsconfig.json | 4 +- packages/rollout/tsconfig.lib.json | 7 +- packages/suite-build/README.md | 1 + .../files/oauth/oauth_receiver.html | 8 +- packages/suite-data/files/spend/index.html | 123 +- .../suite-data/files/translations/ca.json | 2 +- .../suite-data/files/translations/cs.json | 2 +- .../suite-data/files/translations/da.json | 2 +- .../suite-data/files/translations/de.json | 2 +- .../suite-data/files/translations/el.json | 2 +- .../suite-data/files/translations/en.json | 2 +- .../suite-data/files/translations/es.json | 2 +- .../suite-data/files/translations/fi.json | 2 +- .../suite-data/files/translations/fr.json | 2 +- .../suite-data/files/translations/he.json | 2 +- .../suite-data/files/translations/hi.json | 2 +- .../suite-data/files/translations/hu.json | 2 +- .../suite-data/files/translations/id.json | 2 +- .../suite-data/files/translations/it.json | 2 +- .../suite-data/files/translations/ja.json | 2 +- .../suite-data/files/translations/jv.json | 2 +- .../suite-data/files/translations/ko.json | 2 +- .../suite-data/files/translations/lol.json | 2 +- .../suite-data/files/translations/nl.json | 2 +- .../suite-data/files/translations/no.json | 2 +- .../suite-data/files/translations/pl.json | 2 +- .../suite-data/files/translations/pt.json | 2 +- .../suite-data/files/translations/ro.json | 2 +- .../suite-data/files/translations/ru.json | 2 +- .../suite-data/files/translations/sk.json | 2 +- .../suite-data/files/translations/sr.json | 2 +- .../suite-data/files/translations/sv.json | 2 +- .../suite-data/files/translations/tr.json | 2 +- .../suite-data/files/translations/uk.json | 2 +- .../suite-data/files/translations/vi.json | 2 +- .../suite-data/files/translations/zh.json | 2 +- packages/suite-desktop-api/README.md | 49 +- packages/suite-desktop-api/package.json | 5 +- packages/suite-desktop-api/src/methods.ts | 76 +- packages/suite-desktop-api/tsconfig.json | 2 +- packages/suite-desktop/.gitignore | 4 - packages/suite-desktop/README.md | 9 +- .../suite-desktop/src-electron/tsconfig.json | 15 +- packages/suite-desktop/src/static/index.html | 8 +- packages/suite-desktop/tsconfig.json | 18 +- packages/suite-native/app.json | 6 +- .../AppIcon.appiconset/Contents.json | 100 +- .../TrezorSuite/Images.xcassets/Contents.json | 8 +- packages/suite-native/tsconfig.json | 1089 +- packages/suite-storage/.prettierignore | 10 - packages/suite-storage/.prettierrc | 11 - packages/suite-storage/src/native/index.ts | 36 +- packages/suite-storage/src/web/index.ts | 44 +- packages/suite-storage/tsconfig.json | 4 +- packages/suite-storage/tsconfig.types.json | 2 +- packages/suite-web-landing/.gitignore | 1 - packages/suite-web-landing/tsconfig.json | 38 +- packages/suite-web/src/static/index.html | 73 +- packages/suite/docs/README.md | 2 +- packages/suite/docs/SEND.md | 236 +- packages/suite/docs/send/ARCHITECTURE.md | 25 +- packages/suite/package.json | 5 +- .../DeviceAnimation/lottie/t1_connect.json | 110 +- .../DeviceAnimation/lottie/tt_connect.json | 110 +- packages/suite/src/storage/CHANGELOG.md | 9 + .../__fixtures__/searchTransactions.json | 12054 +++++++++++++++- packages/transport/.gitignore | 7 - packages/transport/.prettierrc | 11 - packages/transport/CHANGELOG.md | 9 +- packages/transport/README.md | 15 +- packages/transport/tsconfig.json | 2 +- packages/utils/CHANGELOG.md | 3 +- packages/utils/package.json | 4 +- packages/utils/tsconfig.json | 2 +- packages/utils/tsconfig.lib.json | 7 +- packages/utxo-lib/.gitignore | 1 - packages/utxo-lib/README.md | 26 +- packages/utxo-lib/package.json | 4 +- packages/utxo-lib/tsconfig.lib.json | 7 +- yarn.lock | 13 +- 184 files changed, 14138 insertions(+), 1424 deletions(-) delete mode 100644 packages/blockchain-link/.prettierignore delete mode 100644 packages/blockchain-link/.prettierrc delete mode 100644 packages/components/.gitignore delete mode 100644 packages/components/.npmignore delete mode 100644 packages/components/.prettierignore delete mode 100644 packages/components/.prettierrc delete mode 100644 packages/connect-common/.gitignore delete mode 100644 packages/connect-iframe/.gitignore delete mode 100644 packages/news-api/.gitignore delete mode 100644 packages/rollout/.prettierrc delete mode 100644 packages/suite-desktop/.gitignore delete mode 100644 packages/suite-storage/.prettierignore delete mode 100644 packages/suite-storage/.prettierrc delete mode 100644 packages/suite-web-landing/.gitignore delete mode 100644 packages/transport/.gitignore delete mode 100644 packages/transport/.prettierrc delete mode 100644 packages/utxo-lib/.gitignore diff --git a/.eslintrc.js b/.eslintrc.js index e6da159299..92932c51ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -112,7 +112,8 @@ module.exports = { '@typescript-eslint/explicit-member-accessibility': 'off', '@typescript-eslint/no-explicit-any': 'off', 'react/destructuring-assignment': 'off', - 'prettier/prettier': 'error', + 'prettier/prettier': 'off', + 'func-names': 'off', 'react/require-default-props': 'off', '@typescript-eslint/no-non-null-assertion': 'off', // We use this syntax diff --git a/.github/ISSUE_TEMPLATE/01_bug.md b/.github/ISSUE_TEMPLATE/01_bug.md index 3caaeb3a92..4d96a24fb7 100644 --- a/.github/ISSUE_TEMPLATE/01_bug.md +++ b/.github/ISSUE_TEMPLATE/01_bug.md @@ -4,22 +4,23 @@ about: Something does not work as expected. title: '' labels: bug assignees: '' - --- **Describe the bug** A clear and concise description of what the bug is. **Info:** - - Remembered Wallet: yes/no - - Suite Version: app/web, commit - - Browser: name, version - - OS: name, version - - Bridge: version - - Firmware Version: model, version/commit + +- Remembered Wallet: yes/no +- Suite Version: app/web, commit +- Browser: name, version +- OS: name, version +- Bridge: version +- Firmware Version: model, version/commit **How to reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' diff --git a/.github/ISSUE_TEMPLATE/02_code.md b/.github/ISSUE_TEMPLATE/02_code.md index 8d50e5dbdd..aa16810265 100644 --- a/.github/ISSUE_TEMPLATE/02_code.md +++ b/.github/ISSUE_TEMPLATE/02_code.md @@ -4,5 +4,4 @@ about: Issues related to refactoring, dependencies, code improvements etc. title: '' labels: code assignees: '' - --- diff --git a/.github/ISSUE_TEMPLATE/03_product.md b/.github/ISSUE_TEMPLATE/03_product.md index 00bed759bc..405b88e2df 100644 --- a/.github/ISSUE_TEMPLATE/03_product.md +++ b/.github/ISSUE_TEMPLATE/03_product.md @@ -4,7 +4,6 @@ about: New product feature ready for development. title: '' labels: product assignees: '' - --- **Design:** [Figma](TODO) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 6614bd0e04..d4da3de57e 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -17,6 +17,8 @@ jobs: run: npx yarn-deduplicate --list --fail - name: install deps run: yarn + - name: check code formatting + run: yarn format:verify - name: build libs run: yarn build:libs - name: type check diff --git a/.prettierrc b/.prettierrc index 6bd410c2fa..7be574c93f 100644 --- a/.prettierrc +++ b/.prettierrc @@ -7,7 +7,7 @@ "trailingComma": "all", "tabWidth": 4, "useTabs": false, - "jsxBracketSameLine": false, + "bracketSameLine": false, "overrides": [ { "files": ["*.yml"], @@ -15,6 +15,12 @@ "tabWidth": 2, "singleQuote": false } + }, + { + "files": ["packages/suite-data/files/translations/*.json"], + "options": { + "tabWidth": 2 + } } ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index f6b0b389da..62949b46e0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,17 +10,12 @@ "args": [], "cwd": "${workspaceRoot}/packages/suite-desktop/dist", "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", - "runtimeArgs": [ - "--enable-logging", - "--remote-debugging-port=9223" - ], + "runtimeArgs": ["--enable-logging", "--remote-debugging-port=9223"], "env": {}, "sourceMaps": true, - "outFiles": [ - "${workspaceRoot}/packages/suite-desktop/dist/**/*.js" - ], + "outFiles": ["${workspaceRoot}/packages/suite-desktop/dist/**/*.js"], "preLaunchTask": "desktop:dev", "postDebugTask": "end-tasks" } ] -} \ No newline at end of file +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1f0776039c..1396d36bc4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,54 +1,54 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "end-tasks", - "command": "echo ${input:terminate}", - "type": "shell", - "problemMatcher": [] - }, - { - "label": "desktop:dev", - "dependsOn": [ "desktop:dev:prepare", "desktop:dev:local" ] - }, - { - "label": "desktop:dev:prepare", - "type": "npm", - "script": "dev:prepare", - "path": "packages/suite-desktop/", - "problemMatcher": [] - }, - { - "label": "desktop:dev:local", - "type": "npm", - "script": "dev:local", - "path": "packages/suite-desktop/", - "isBackground": true, - "problemMatcher": { - "owner": "node", - "fileLocation": "relative", - "pattern": { - "regexp": "^(err|warn|info) - (.*)$", - "file": 1, - "location": 2, - "severity": 3, - "code": 4, - "message": 5 - }, - "background": { - "activeOnStart": true, - "beginsPattern": "Project is running at", - "endsPattern": "Compiled successfully" - }, - } - } - ], - "inputs": [ - { - "id": "terminate", - "type": "command", - "command": "workbench.action.tasks.terminate", - "args": "terminateAll" - } - ] -} \ No newline at end of file + "version": "2.0.0", + "tasks": [ + { + "label": "end-tasks", + "command": "echo ${input:terminate}", + "type": "shell", + "problemMatcher": [] + }, + { + "label": "desktop:dev", + "dependsOn": ["desktop:dev:prepare", "desktop:dev:local"] + }, + { + "label": "desktop:dev:prepare", + "type": "npm", + "script": "dev:prepare", + "path": "packages/suite-desktop/", + "problemMatcher": [] + }, + { + "label": "desktop:dev:local", + "type": "npm", + "script": "dev:local", + "path": "packages/suite-desktop/", + "isBackground": true, + "problemMatcher": { + "owner": "node", + "fileLocation": "relative", + "pattern": { + "regexp": "^(err|warn|info) - (.*)$", + "file": 1, + "location": 2, + "severity": 3, + "code": 4, + "message": 5 + }, + "background": { + "activeOnStart": true, + "beginsPattern": "Project is running at", + "endsPattern": "Compiled successfully" + } + } + } + ], + "inputs": [ + { + "id": "terminate", + "type": "command", + "command": "workbench.action.tasks.terminate", + "args": "terminateAll" + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 71c9df3c8b..e96aaa963a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ # Changelog + As of version 21.5.1 we do not write a technical Changelog for Suite. Please see our [Github releases](https://github.com/trezor/trezor-suite/releases) for a brief overview or [Github projects](https://github.com/orgs/trezor/projects) for detailed one. diff --git a/LICENSE.md b/LICENSE.md index 879108ed8c..1bebd9dc53 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -47,4 +47,4 @@ Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and -non-infringement. \ No newline at end of file +non-infringement. diff --git a/README.md b/README.md index 1232ad7ed0..692f111384 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ## Packages -| Name | Packages | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| suite | [core](./packages/suite), [web](./packages/suite-web), [desktop](./packages/suite-desktop), [native](./packages/suite-native), [data](./packages/suite-data), [storage](./packages/suite-storage) | -| components | [components](./packages/components), [storybook native](./packages/components-storybook-native) | -| rollout | [rollout](./packages/rollout) | -| blockchain-link | [blockchain-link](./packages/blockchain-link) | -| integration-tests | [integration-tests](./packages/integration-tests) | +| Name | Packages | +| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| suite | [core](./packages/suite), [web](./packages/suite-web), [desktop](./packages/suite-desktop), [native](./packages/suite-native), [data](./packages/suite-data), [storage](./packages/suite-storage) | +| components | [components](./packages/components), [storybook native](./packages/components-storybook-native) | +| rollout | [rollout](./packages/rollout) | +| blockchain-link | [blockchain-link](./packages/blockchain-link) | +| integration-tests | [integration-tests](./packages/integration-tests) | ## Development diff --git a/ci/validation.yml b/ci/validation.yml index f267f71397..f19d80649e 100644 --- a/ci/validation.yml +++ b/ci/validation.yml @@ -1,3 +1,9 @@ +code format lint: + stage: validation + script: + - yarn install --frozen-lockfile --cache-folder .yarn --prefer-offline + - yarn format:verify + lint: stage: validation script: diff --git a/docs/packages/suite-desktop.md b/docs/packages/suite-desktop.md index 09c1f4d71e..ec2cc3253b 100644 --- a/docs/packages/suite-desktop.md +++ b/docs/packages/suite-desktop.md @@ -3,34 +3,35 @@ ## Main differences between suite-web and suite-desktop builds ### trezor-connect API -- suite-web - - `trezor-connect` is hosted at `[url]/build/static/connect` and injected as an iframe into DOM. - `iframe.postMessage/iframe.onmessage` interface is used as communication channel between suite and connect API. +- suite-web -- suite-desktop + `trezor-connect` is hosted at `[url]/build/static/connect` and injected as an iframe into DOM. - `trezor-connect` is installed as regular node_module in electron main process and works in nodejs environment. + `iframe.postMessage/iframe.onmessage` interface is used as communication channel between suite and connect API. - `trezor-connect` files are __not__ hosted on the electron renderer side, there is no iframe or /build/static/connect dir. +- suite-desktop - `Electron.IpcRenderer.send/Electron.IpcRenderer.on` interface is used as communication channel between suite (electron renderer) and connect API (electron main). see @trezor/suite-desktop/src-electron/trezor-connect-preload.ts + `trezor-connect` is installed as regular node_module in electron main process and works in nodejs environment. + + `trezor-connect` files are **not** hosted on the electron renderer side, there is no iframe or /build/static/connect dir. + + `Electron.IpcRenderer.send/Electron.IpcRenderer.on` interface is used as communication channel between suite (electron renderer) and connect API (electron main). see @trezor/suite-desktop/src-electron/trezor-connect-preload.ts ### Firmware binaries -- suite-web - newest firmware binaries are hosted at `[url]/build/static/connect/data/firmware` and they are downloaded using regular `fetch` API. +- suite-web -- suite-desktop + newest firmware binaries are hosted at `[url]/build/static/connect/data/firmware` and they are downloaded using regular `fetch` API. - firmware binaries are bundled as application resources in `bin` directory, full path depends on OS but it could be found on the as level as `app.asar` file, and they are downloaded using `fs.readFile` API. see @trezor/rollout/src/utils/fetch +- suite-desktop + + firmware binaries are bundled as application resources in `bin` directory, full path depends on OS but it could be found on the as level as `app.asar` file, and they are downloaded using `fs.readFile` API. see @trezor/rollout/src/utils/fetch ### Trezor Bridge (trezord) ### Tor - ## Debugging (VS Code) Using VS Code configuration files (inside `.vscode`), Suite Desktop can be built and run with a debugger attached to it. Running the `Suite-Desktop: App` task (F5) will execute all required scripts (Webpack development server + Electron build) and launch the Electron app. VS Code will be set in debugging mode, allowing you, for example, to set breakpoints and inspect variables inside the `electron-src` folder (as well as other dependencies). For more on Debugging, please refer to [the VS Code documentation](https://code.visualstudio.com/docs/editor/debugging). @@ -90,22 +91,29 @@ The auto-updater has been mocked to simulate similar behavior to the actual libr ## Debugging build #### Linux + `./Trezor-Suite-20.10.1.AppImage --log-level=debug` #### MacOS + `./Trezor\ Suite.app/Contents/MacOS/Trezor\ Suite --log-level=debug` #### NixOS + `appimage-run ./Trezor-Suite.AppImage --log-level=debug` ## Extract application #### MacOS + `npx asar extract ./Trezor\ Suite.app/Contents/Resources/app.asar ./decompiled` #### NixOS + Run application to get mount-id like: + ``` Trezor-Suite.AppImage installed in ~/.cache/appimage-run/e4f67ae8624c4079527c669d8a3c4bbc1dd00b83b2e1d15807a5863b11bd4f38 ``` -`npx asar extract ~/.cache/appimage-run/[mount-id]/resources/app.asar ./decompiled` \ No newline at end of file + +`npx asar extract ~/.cache/appimage-run/[mount-id]/resources/app.asar ./decompiled` diff --git a/docs/releases/npm-packages.md b/docs/releases/npm-packages.md index 431e79cd12..cb32f27bd1 100644 --- a/docs/releases/npm-packages.md +++ b/docs/releases/npm-packages.md @@ -29,9 +29,8 @@ If you want to publish to npm as `beta` (from any branch) do the following: 1. Commit your changes as `release: @trezor/ X.X.X-beta.X`. 1. Use `beta deploy npm` job. - ### Release new trezor-connect with updated package. 1. Upgrade the version of the package in `devDependencies` and `extendedDependencies` of `trezor-connect`. 1. Create [new beta release of trezor-connect](https://github.com/trezor/connect/blob/83af30f73f4cfa7c099c55b2b0f8a103abc299c8/docs/deployment/index.md#beta). -1. Use new trezor-connect in Suite. Upgrade `trezor-connect` dependency in `packages/*/package.json` \ No newline at end of file +1. Use new trezor-connect in Suite. Upgrade `trezor-connect` dependency in `packages/*/package.json` diff --git a/lerna.json b/lerna.json index 9e080f5805..934852c1fc 100644 --- a/lerna.json +++ b/lerna.json @@ -1,8 +1,6 @@ { - "packages": [ - "packages/*" - ], - "npmClient": "yarn", - "useWorkspaces": true, - "version": "independent" -} \ No newline at end of file + "packages": ["packages/*"], + "npmClient": "yarn", + "useWorkspaces": true, + "version": "independent" +} diff --git a/package.json b/package.json index a076fac607..8d59e5de19 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "lint:js": "eslint --cache --ignore-path .gitignore --ext .js,.ts,.tsx ./", "lint": "yarn lerna run lint:styles && yarn lint:js", "lint-staged": "npx lint-staged", - "deduplicate": "yarn-deduplicate && yarn" + "deduplicate": "yarn-deduplicate && yarn", + "format": "yarn prettier --write --ignore-path .gitignore \"**/*.{js,ts,tsx,mdx,md,html,json}\"", + "format:verify": "yarn prettier --check --ignore-path .gitignore \"**/*.{js,ts,tsx,mdx,md,html,json}\"" }, "lint-staged": { "packages/**/*.{ts,tsx}": [ @@ -80,7 +82,7 @@ "npm-run-all": "^4.1.5", "patch-package": "^6.2.1", "postinstall-postinstall": "^2.0.0", - "prettier": "2.3.2", + "prettier": "2.5.1", "prettier-eslint": "^13.0.0", "rimraf": "^3.0.2", "ts-jest": "^26.5.4", diff --git a/packages/blockchain-link/.prettierignore b/packages/blockchain-link/.prettierignore deleted file mode 100644 index 8217851eba..0000000000 --- a/packages/blockchain-link/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -lib -build -coverage -**/_old/* -node_modules -src/ui/** \ No newline at end of file diff --git a/packages/blockchain-link/.prettierrc b/packages/blockchain-link/.prettierrc deleted file mode 100644 index a2ac7822fe..0000000000 --- a/packages/blockchain-link/.prettierrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "printWidth": 100, - "tabWidth": 4, - "singleQuote": true, - "trailingComma": "es5", - "arrowParens": "avoid", - "bracketSpacing": true, - "semi": true, - "useTabs": false -} \ No newline at end of file diff --git a/packages/blockchain-link/CHANGELOG.md b/packages/blockchain-link/CHANGELOG.md index bc23805c35..ac43dae55b 100644 --- a/packages/blockchain-link/CHANGELOG.md +++ b/packages/blockchain-link/CHANGELOG.md @@ -1,49 +1,57 @@ # 2.1.1 #### changes -- Proxy agent in Ripple worker is set based on `RippleAPI._ALLOW_AGENT` flag, in order not to fail in standalone `trezor-connect` implementation (#4942) + +- Proxy agent in Ripple worker is set based on `RippleAPI._ALLOW_AGENT` flag, in order not to fail in standalone `trezor-connect` implementation (#4942) # 2.1.0 #### changes -- Added `proxy` param allowing workers to initialize SocksProxyAgent and use it for proxying communication -- Added support for `Electrum` backend -- Using common utilities from new `@trezor/utils` package -- Updated dependencies + +- Added `proxy` param allowing workers to initialize SocksProxyAgent and use it for proxying communication +- Added support for `Electrum` backend +- Using common utilities from new `@trezor/utils` package +- Updated dependencies # 2.0.0 #### changes -- Refactored architecture of workers. They may now be used as commonjs module in main context or in WebWorker context like before. -- Updated library build targets to es2017 reducing polyfills from typescript transpilation. -- Removed `build` directory from npm registry. -- Updated dependencies. + +- Refactored architecture of workers. They may now be used as commonjs module in main context or in WebWorker context like before. +- Updated library build targets to es2017 reducing polyfills from typescript transpilation. +- Removed `build` directory from npm registry. +- Updated dependencies. # 1.1.0 #### changes -- lower default XRP reserve -- set XRP reserve after `getInfo` call (get server info) -- added support for `Cardano` using `Blockfrost` backend -- fix blockbook transaction target when tx is sent to change address -- fix blockbook (ETH) transaction target when swapping ETH <> ERC20 + +- lower default XRP reserve +- set XRP reserve after `getInfo` call (get server info) +- added support for `Cardano` using `Blockfrost` backend +- fix blockbook transaction target when tx is sent to change address +- fix blockbook (ETH) transaction target when swapping ETH <> ERC20 # 1.0.17 #### changes -- Fixed tx.amount for btc-like sent txs -- Added tx.totalSpent -- Added tx.details.locktime + +- Fixed tx.amount for btc-like sent txs +- Added tx.totalSpent +- Added tx.details.locktime + # 1.0.16 #### changes -- Fixed an issue where account with non-zero balance could be marked as empty (eth) -- Pending ETH transaction fee calculated from `ethereumSpecific` field -- Added missing types (data) to `ethereumSpecific` field + +- Fixed an issue where account with non-zero balance could be marked as empty (eth) +- Pending ETH transaction fee calculated from `ethereumSpecific` field +- Added missing types (data) to `ethereumSpecific` field # 1.0.15 #### changes + - Added `details` to `Transaction` object (vin, vout, size) - Fixed types in `BlockchainLink` event listeners - Move "workersDepenedecies" to regular "dependencies" in package.json diff --git a/packages/blockchain-link/README.md b/packages/blockchain-link/README.md index fa49da8221..c447e9734c 100644 --- a/packages/blockchain-link/README.md +++ b/packages/blockchain-link/README.md @@ -30,14 +30,13 @@ const link = new BlockchainLink({ try { const resp = link.getInfo(); -} catch(error) { - -} +} catch (error) {} ``` For complete API see the methods of `BlockchainLink` class in [index.ts](./src/index.ts). ## Workers + Each `src/workers/*/index` file can be used in WebWorker thread. Built from source using webpack `worker-loader`: @@ -53,12 +52,13 @@ Run UI with webworkers support ```shell yarn workspace @trezor/blockchain-link dev ``` + or without webworkes support (workers are compiled into a bundle) + ```shell yarn workspace @trezor/blockchain-link dev:module ``` - ### Tests ``` @@ -68,7 +68,9 @@ yarn workspace @trezor/blockchain-link test:unit ``` ### Integration tests + Testing `lib` and `build` outputs: + ``` yarn workspace @trezor/blockchain-link build:lib yarn workspace @trezor/blockchain-link build:workers diff --git a/packages/blockchain-link/scripts/build.workers.js b/packages/blockchain-link/scripts/build.workers.js index f7a2ac9312..bffe7acd97 100644 --- a/packages/blockchain-link/scripts/build.workers.js +++ b/packages/blockchain-link/scripts/build.workers.js @@ -34,7 +34,7 @@ packageJSON.main = 'lib/index.js'; fs.writeFileSync( path.resolve(npm, 'package.json'), JSON.stringify(packageJSON, null, ' '), - 'utf-8' + 'utf-8', ); fs.copySync(path.resolve(npm, '../README.md'), path.resolve(npm, 'README.md')); diff --git a/packages/blockchain-link/src/index.ts b/packages/blockchain-link/src/index.ts index 5f92d5265b..6b97d0e6a2 100644 --- a/packages/blockchain-link/src/index.ts +++ b/packages/blockchain-link/src/index.ts @@ -112,7 +112,7 @@ class BlockchainLink extends EventEmitter { /** Get hash of a block of given height. */ getBlockHash( - payload: MessageTypes.GetBlockHash['payload'] + payload: MessageTypes.GetBlockHash['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_BLOCK_HASH, @@ -122,7 +122,7 @@ class BlockchainLink extends EventEmitter { /** Get info about an account, eg. derived addresses, balance, transaction history etc. */ getAccountInfo( - payload: MessageTypes.GetAccountInfo['payload'] + payload: MessageTypes.GetAccountInfo['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_ACCOUNT_INFO, @@ -132,7 +132,7 @@ class BlockchainLink extends EventEmitter { /** Get unspent inputs for given account. Works only for bitcoin(like) networks. */ getAccountUtxo( - payload: MessageTypes.GetAccountUtxo['payload'] + payload: MessageTypes.GetAccountUtxo['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_ACCOUNT_UTXO, @@ -146,7 +146,7 @@ class BlockchainLink extends EventEmitter { * this method exposes raw response from the BE. */ getTransaction( - payload: MessageTypes.GetTransaction['payload'] + payload: MessageTypes.GetTransaction['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_TRANSACTION, @@ -159,7 +159,7 @@ class BlockchainLink extends EventEmitter { * Used for rendering a graph in Suite's dashboard. */ getAccountBalanceHistory( - payload: MessageTypes.GetAccountBalanceHistory['payload'] + payload: MessageTypes.GetAccountBalanceHistory['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_ACCOUNT_BALANCE_HISTORY, @@ -168,7 +168,7 @@ class BlockchainLink extends EventEmitter { } getCurrentFiatRates( - payload: MessageTypes.GetCurrentFiatRates['payload'] + payload: MessageTypes.GetCurrentFiatRates['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_CURRENT_FIAT_RATES, @@ -178,7 +178,7 @@ class BlockchainLink extends EventEmitter { /** Get historical fiat rates. Only some backends support this. */ getFiatRatesForTimestamps( - payload: MessageTypes.GetFiatRatesForTimestamps['payload'] + payload: MessageTypes.GetFiatRatesForTimestamps['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_FIAT_RATES_FOR_TIMESTAMPS, @@ -188,7 +188,7 @@ class BlockchainLink extends EventEmitter { /** Get fiat currencies for which rates are available. */ getFiatRatesTickersList( - payload: MessageTypes.GetFiatRatesTickersList['payload'] + payload: MessageTypes.GetFiatRatesTickersList['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.GET_FIAT_RATES_TICKERS_LIST, @@ -198,7 +198,7 @@ class BlockchainLink extends EventEmitter { /** Get ‘recommended’ fee value inferred from current traffic in the network. */ estimateFee( - payload: MessageTypes.EstimateFee['payload'] + payload: MessageTypes.EstimateFee['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.ESTIMATE_FEE, @@ -216,7 +216,7 @@ class BlockchainLink extends EventEmitter { * Handling subscription state is left to the user. Hence the purpose of CONNECT and DISCONNECT notifications. */ subscribe( - payload: MessageTypes.Subscribe['payload'] + payload: MessageTypes.Subscribe['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.SUBSCRIBE, @@ -226,7 +226,7 @@ class BlockchainLink extends EventEmitter { /** Discard a subscription. */ unsubscribe( - payload: MessageTypes.Unsubscribe['payload'] + payload: MessageTypes.Unsubscribe['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.UNSUBSCRIBE, @@ -236,7 +236,7 @@ class BlockchainLink extends EventEmitter { /** Broadcast a transaction to the network. */ pushTransaction( - payload: MessageTypes.PushTransaction['payload'] + payload: MessageTypes.PushTransaction['payload'], ): Promise { return this.sendMessage({ type: MESSAGES.PUSH_TRANSACTION, diff --git a/packages/blockchain-link/src/types/blockbook.ts b/packages/blockchain-link/src/types/blockbook.ts index e7f08e4f3e..714d4e622c 100644 --- a/packages/blockchain-link/src/types/blockbook.ts +++ b/packages/blockchain-link/src/types/blockbook.ts @@ -170,31 +170,31 @@ declare function FSend(method: 'getTransaction', params: { txid: string }): Prom declare function FSend(method: 'sendTransaction', params: { hex: string }): Promise; declare function FSend( method: 'getBalanceHistory', - params: AccountBalanceHistoryParams + params: AccountBalanceHistoryParams, ): Promise; declare function FSend( method: 'getCurrentFiatRates', - params: GetCurrentFiatRatesParams + params: GetCurrentFiatRatesParams, ): Promise; declare function FSend( method: 'getFiatRatesTickersList', - params: GetFiatRatesTickersListParams + params: GetFiatRatesTickersListParams, ): Promise; declare function FSend( method: 'getFiatRatesForTimestamps', - params: GetFiatRatesForTimestampsParams + params: GetFiatRatesForTimestampsParams, ): Promise; declare function FSend(method: 'estimateFee', params: EstimateFeeParams): Promise; declare function FSend( method: 'subscribeAddresses', - params: { addresses: string[] } + params: { addresses: string[] }, ): Promise; declare function FSend(method: 'unsubscribeAddresses'): Promise; declare function FSend(method: 'subscribeNewBlock'): Promise; declare function FSend(method: 'unsubscribeNewBlock'): Promise; declare function FSend( method: 'subscribeFiatRates', - params: { currency?: string } + params: { currency?: string }, ): Promise; declare function FSend(method: 'unsubscribeFiatRates'): Promise; export type Send = typeof FSend; diff --git a/packages/blockchain-link/src/types/blockfrost.ts b/packages/blockchain-link/src/types/blockfrost.ts index 0343a8be8d..94c73f0884 100644 --- a/packages/blockchain-link/src/types/blockfrost.ts +++ b/packages/blockchain-link/src/types/blockfrost.ts @@ -247,31 +247,31 @@ export interface BlockfrostUtxos { declare function FSend(method: 'GET_SERVER_INFO'): Promise; declare function FSend( method: 'GET_BLOCK', - params: { hashOrNumber: number | string } + params: { hashOrNumber: number | string }, ): Promise; declare function FSend( method: 'GET_ACCOUNT_INFO', - params: AccountInfoParams + params: AccountInfoParams, ): Promise; declare function FSend( method: 'GET_ACCOUNT_UTXO', - params: AccountUtxoParams + params: AccountUtxoParams, ): Promise; declare function FSend( method: 'GET_TRANSACTION', - params: { txId: string } + params: { txId: string }, ): Promise; declare function FSend(method: 'PUSH_TRANSACTION', params: { txData: string }): Promise; declare function FSend(method: 'SUBSCRIBE_BLOCK'): Promise; declare function FSend(method: 'UNSUBSCRIBE_BLOCK'): Promise; declare function FSend( method: 'SUBSCRIBE_ADDRESS', - params: { addresses: string[] } + params: { addresses: string[] }, ): Promise; declare function FSend(method: 'UNSUBSCRIBE_ADDRESS'): Promise; declare function FSend( method: 'GET_BALANCE_HISTORY', - params: AccountBalanceHistoryParams + params: AccountBalanceHistoryParams, ): Promise; declare function FSend(method: 'ESTIMATE_FEE', params: EstimateFeeParams): Promise; export type Send = typeof FSend; diff --git a/packages/blockchain-link/src/types/electrum.ts b/packages/blockchain-link/src/types/electrum.ts index e92c87fe0f..3df4f5148e 100644 --- a/packages/blockchain-link/src/types/electrum.ts +++ b/packages/blockchain-link/src/types/electrum.ts @@ -106,7 +106,7 @@ export interface ElectrumAPI { request( method: 'server.version', client_name: string, - protocol_version: string | [string, string] + protocol_version: string | [string, string], ): Promise; request(method: 'server.banner'): Promise; request(method: 'server.ping'): Promise; @@ -124,7 +124,7 @@ export interface ElectrumAPI { method: 'blockchain.block.headers', start_height: number, count: number, - cp_height?: number + cp_height?: number, ): Promise; request(method: 'blockchain.estimatefee', number: number): Promise; request(method: 'blockchain.headers.subscribe'): Promise; @@ -133,24 +133,24 @@ export interface ElectrumAPI { request( method: 'blockchain.transaction.get', tx_hash: string, - verbose?: false + verbose?: false, ): Promise; request( method: 'blockchain.transaction.get', tx_hash: string, - verbose: true + verbose: true, ): Promise; request( method: 'blockchain.transaction.get_merkle', tx_hash: string, - height: number + height: number, ): Promise; request(method: 'mempool.get_fee_histogram'): Promise; /** @deprecated 1.1 */ request( method: 'blockchain.utxo.get_address', tx_hash: string, - index: unknown + index: unknown, ): Promise; /** @deprecated 1.1 */ request(method: 'blockchain.numblocks.subscribe'): Promise; diff --git a/packages/blockchain-link/src/ui/index.html b/packages/blockchain-link/src/ui/index.html index d04a50775b..39497aa01e 100644 --- a/packages/blockchain-link/src/ui/index.html +++ b/packages/blockchain-link/src/ui/index.html @@ -199,4 +199,4 @@ (function(){var script=document.createElement('script');script.onload=function(){var stats=new Stats();document.body.appendChild(stats.dom);requestAnimationFrame(function loop(){stats.update();requestAnimationFrame(loop)});};script.src='//mrdoob.github.io/stats.js/build/stats.min.js';document.head.appendChild(script);})(); --> - \ No newline at end of file + diff --git a/packages/blockchain-link/src/ui/index.ui.ts b/packages/blockchain-link/src/ui/index.ui.ts index 21132eaa33..0cadd89b2b 100644 --- a/packages/blockchain-link/src/ui/index.ui.ts +++ b/packages/blockchain-link/src/ui/index.ui.ts @@ -208,7 +208,7 @@ const handleClick = (event: MouseEvent) => { .getFiatRatesTickersList({ timestamp: parseInt( getInputValue('get-fiat-rates-ticker-list-timestamp'), - 10 + 10, ), }) .then(onResponse) @@ -283,7 +283,7 @@ const handleConnectionEvent = (blockchain: BlockchainLink, status: boolean) => { blockchain: blockchain.settings.name, connected: status, }, - !status + !status, ); }; diff --git a/packages/blockchain-link/src/workers/blockbook/index.ts b/packages/blockchain-link/src/workers/blockbook/index.ts index 9d0329989b..3c522e2163 100644 --- a/packages/blockchain-link/src/workers/blockbook/index.ts +++ b/packages/blockchain-link/src/workers/blockbook/index.ts @@ -56,7 +56,7 @@ const getAccountUtxo = async (request: Request) => }; const getAccountBalanceHistory = async ( - request: Request + request: Request, ) => { const { payload } = request; const api = await request.connect(); @@ -78,7 +78,7 @@ const getCurrentFiatRates = async (request: Request + request: Request, ) => { const { payload } = request; const api = await request.connect(); @@ -244,7 +244,7 @@ const subscribe = async (request: Request) => { const unsubscribeAccounts = async ( { state, connect }: Context, - accounts?: SubscriptionAccountInfo[] + accounts?: SubscriptionAccountInfo[], ) => { state.removeAccounts(accounts || state.getAccounts()); diff --git a/packages/blockchain-link/src/workers/blockbook/utils.ts b/packages/blockchain-link/src/workers/blockbook/utils.ts index 6bae08e302..549cac56d8 100644 --- a/packages/blockchain-link/src/workers/blockbook/utils.ts +++ b/packages/blockchain-link/src/workers/blockbook/utils.ts @@ -29,7 +29,7 @@ export const transformServerInfo = (payload: ServerInfo) => ({ export const filterTokenTransfers = ( addresses: Addresses, - transfers: BlockbookTransaction['tokenTransfers'] + transfers: BlockbookTransaction['tokenTransfers'], ): TokenTransfer[] => { if (typeof addresses === 'string') { addresses = [addresses]; @@ -81,7 +81,7 @@ export const filterTokenTransfers = ( export const transformTransaction = ( descriptor: string, addresses: AccountAddresses | undefined, - tx: BlockbookTransaction + tx: BlockbookTransaction, ): Transaction => { // combine all addresses into array const myAddresses = addresses @@ -196,7 +196,7 @@ export const transformTransaction = ( }; export const transformTokenInfo = ( - tokens: BlockbookAccountInfo['tokens'] + tokens: BlockbookAccountInfo['tokens'], ): TokenInfo[] | undefined => { if (!tokens || !Array.isArray(tokens)) return undefined; const info = tokens.reduce((arr, t) => { @@ -216,7 +216,7 @@ export const transformTokenInfo = ( }; export const transformAddresses = ( - tokens: BlockbookAccountInfo['tokens'] + tokens: BlockbookAccountInfo['tokens'], ): AccountAddresses | undefined => { if (!tokens || !Array.isArray(tokens)) return undefined; const addresses = tokens.reduce((arr, t) => { diff --git a/packages/blockchain-link/src/workers/blockbook/websocket.ts b/packages/blockchain-link/src/workers/blockbook/websocket.ts index eb0e32c843..deca689ebf 100644 --- a/packages/blockchain-link/src/workers/blockbook/websocket.ts +++ b/packages/blockchain-link/src/workers/blockbook/websocket.ts @@ -67,7 +67,7 @@ export class BlockbookAPI extends EventEmitter { this.clearConnectionTimeout(); this.connectionTimeout = setTimeout( this.onTimeout.bind(this), - this.options.timeout || DEFAULT_TIMEOUT + this.options.timeout || DEFAULT_TIMEOUT, ); } @@ -84,7 +84,7 @@ export class BlockbookAPI extends EventEmitter { } this.pingTimeout = setTimeout( this.onPing.bind(this), - this.options.pingTimeout || DEFAULT_PING_TIMEOUT + this.options.pingTimeout || DEFAULT_PING_TIMEOUT, ); } diff --git a/packages/blockchain-link/src/workers/blockfrost/index.ts b/packages/blockchain-link/src/workers/blockfrost/index.ts index 6d63d1351a..96cf0a0247 100644 --- a/packages/blockchain-link/src/workers/blockfrost/index.ts +++ b/packages/blockchain-link/src/workers/blockfrost/index.ts @@ -33,7 +33,7 @@ const getBlockHash = async (request: Request) => { }; const getAccountBalanceHistory = async ( - request: Request + request: Request, ) => { const socket = await request.connect(); const history = await socket.getAccountBalanceHistory(request.payload); @@ -188,7 +188,7 @@ const unsubscribeBlock = async ({ state, connect }: Context) => { const unsubscribeAccounts = async ( { state, connect }: Context, - accounts?: SubscriptionAccountInfo[] + accounts?: SubscriptionAccountInfo[], ) => { state.removeAccounts(accounts || state.getAccounts()); diff --git a/packages/blockchain-link/src/workers/blockfrost/utils.ts b/packages/blockchain-link/src/workers/blockfrost/utils.ts index ec49b61a1e..ddedd88a41 100644 --- a/packages/blockchain-link/src/workers/blockfrost/utils.ts +++ b/packages/blockchain-link/src/workers/blockfrost/utils.ts @@ -32,7 +32,7 @@ export const transformUtxos = (utxos: BlockfrostUtxos[]): Utxo[] => { unit: u.unit, }, }); - }) + }), ); return result; }; @@ -82,7 +82,7 @@ export const parseAsset = (hex: string): ParseAssetResult => { }; export const transformTokenInfo = ( - tokens: BlockfrostAccountInfo['tokens'] + tokens: BlockfrostAccountInfo['tokens'], ): TokenInfo[] | undefined => { if (!tokens || !Array.isArray(tokens)) return undefined; const info = tokens.map(t => { @@ -102,7 +102,7 @@ export const transformTokenInfo = ( export const transformInputOutput = ( data: BlockfrostTransaction['txUtxos']['inputs'] | BlockfrostTransaction['txUtxos']['outputs'], - asset = 'lovelace' + asset = 'lovelace', ): VinVout[] => data.map(utxo => ({ n: utxo.output_index, @@ -114,7 +114,7 @@ export const transformInputOutput = ( export const filterTokenTransfers = ( accountAddress: AccountAddresses, tx: BlockfrostTransaction, - type: Transaction['type'] + type: Transaction['type'], ): TokenTransfer[] => { const transfers: TokenTransfer[] = []; const myNonChangeAddresses = accountAddress.used.concat(accountAddress.unused); @@ -134,7 +134,7 @@ export const filterTokenTransfers = ( const incomingForOutput = filterTargets( myNonChangeAddresses, - transformInputOutput([output], token) + transformInputOutput([output], token), ); let amount = '0'; @@ -173,7 +173,7 @@ export const filterTokenTransfers = ( export const transformTransaction = ( descriptor: string, accountAddress: AccountAddresses | undefined, - blockfrostTxData: BlockfrostTransaction + blockfrostTxData: BlockfrostTransaction, ): Transaction => { const myAddresses = accountAddress ? accountAddress.change.concat(accountAddress.used, accountAddress.unused) @@ -272,7 +272,7 @@ export const transformAccountInfo = (info: BlockfrostAccountInfo): AccountInfo = transactions: !blockfrostTxs ? [] : blockfrostTxs?.map(tx => - transformTransaction(info.descriptor, info.addresses, tx) + transformTransaction(info.descriptor, info.addresses, tx), ), }, }; diff --git a/packages/blockchain-link/src/workers/blockfrost/websocket.ts b/packages/blockchain-link/src/workers/blockfrost/websocket.ts index fe598cdaa9..4c12a17604 100644 --- a/packages/blockchain-link/src/workers/blockfrost/websocket.ts +++ b/packages/blockchain-link/src/workers/blockfrost/websocket.ts @@ -56,7 +56,7 @@ export class BlockfrostAPI extends EventEmitter { this.clearConnectionTimeout(); this.connectionTimeout = setTimeout( this.onTimeout.bind(this), - this.options.timeout || DEFAULT_TIMEOUT + this.options.timeout || DEFAULT_TIMEOUT, ); } @@ -74,7 +74,7 @@ export class BlockfrostAPI extends EventEmitter { this.pingTimeout = setTimeout( this.onPing.bind(this), - this.options.pingTimeout || DEFAULT_PING_TIMEOUT + this.options.pingTimeout || DEFAULT_PING_TIMEOUT, ); } diff --git a/packages/blockchain-link/src/workers/electrum/client/electrum.ts b/packages/blockchain-link/src/workers/electrum/client/electrum.ts index 622f249eff..ee1555d610 100644 --- a/packages/blockchain-link/src/workers/electrum/client/electrum.ts +++ b/packages/blockchain-link/src/workers/electrum/client/electrum.ts @@ -47,7 +47,7 @@ export class ElectrumClient extends BatchingJsonRpcClient implements ElectrumAPI this.version = await (this as ElectrumAPI).request( 'server.version', name, - protocolVersion + protocolVersion, ); (this as ElectrumAPI).on('blockchain.headers.subscribe', this.onBlock); this.lastBlock = await (this as ElectrumAPI).request('blockchain.headers.subscribe'); diff --git a/packages/blockchain-link/src/workers/electrum/index.ts b/packages/blockchain-link/src/workers/electrum/index.ts index 94d378c34d..105d394985 100644 --- a/packages/blockchain-link/src/workers/electrum/index.ts +++ b/packages/blockchain-link/src/workers/electrum/index.ts @@ -42,7 +42,7 @@ type ResponseType = T extends typeof MESSAGES.GET_INFO type Reply = Without }>, 'id'>; const onRequest = async ( - request: Request + request: Request, ): Promise> => { const client = await request.connect(); switch (request.type) { diff --git a/packages/blockchain-link/src/workers/electrum/listeners/blockListener.ts b/packages/blockchain-link/src/workers/electrum/listeners/blockListener.ts index f31307ef0e..367d98c4c4 100644 --- a/packages/blockchain-link/src/workers/electrum/listeners/blockListener.ts +++ b/packages/blockchain-link/src/workers/electrum/listeners/blockListener.ts @@ -20,7 +20,7 @@ export const blockListener = (worker: BaseWorker) => { blockHash: blockheaderToBlockhash(hex), }, }, - }) + }), ); }; diff --git a/packages/blockchain-link/src/workers/electrum/listeners/txListener.ts b/packages/blockchain-link/src/workers/electrum/listeners/txListener.ts index 95c74a3e94..319f822f94 100644 --- a/packages/blockchain-link/src/workers/electrum/listeners/txListener.ts +++ b/packages/blockchain-link/src/workers/electrum/listeners/txListener.ts @@ -61,8 +61,8 @@ export const txListener = (worker: BaseWorker) => { await Promise.all( shToSubscribe.map(scripthash => - api().request('blockchain.scripthash.subscribe', scripthash) - ) + api().request('blockchain.scripthash.subscribe', scripthash), + ), ); return { subscribed: true }; }; @@ -82,8 +82,8 @@ export const txListener = (worker: BaseWorker) => { await Promise.all( shToUnsubscribe.map(scripthash => - api().request('blockchain.scripthash.unsubscribe', scripthash) - ) + api().request('blockchain.scripthash.unsubscribe', scripthash), + ), ); return { subscribed: false }; }; diff --git a/packages/blockchain-link/src/workers/electrum/methods/estimateFee.ts b/packages/blockchain-link/src/workers/electrum/methods/estimateFee.ts index 5d990a6df0..82b83068b7 100644 --- a/packages/blockchain-link/src/workers/electrum/methods/estimateFee.ts +++ b/packages/blockchain-link/src/workers/electrum/methods/estimateFee.ts @@ -7,8 +7,8 @@ const estimateFee: Api = (client, payload) => (payload.blocks || []).map(num => client .request('blockchain.estimatefee', num) - .then(btc => ({ feePerUnit: btcToSat(btc) })) - ) + .then(btc => ({ feePerUnit: btcToSat(btc) })), + ), ); export default estimateFee; diff --git a/packages/blockchain-link/src/workers/electrum/methods/getAccountBalanceHistory.ts b/packages/blockchain-link/src/workers/electrum/methods/getAccountBalanceHistory.ts index c12b1ab593..7b9c1c0f1e 100644 --- a/packages/blockchain-link/src/workers/electrum/methods/getAccountBalanceHistory.ts +++ b/packages/blockchain-link/src/workers/electrum/methods/getAccountBalanceHistory.ts @@ -51,7 +51,7 @@ const aggregateTransactions = (txs: (Transaction & { blockTime: number })[], gro const getAccountBalanceHistory: Api = async ( client, - { descriptor, from, to, groupBy } + { descriptor, from, to, groupBy }, ) => { let history: HistoryTx[]; let addresses: AccountAddresses | undefined; @@ -80,10 +80,10 @@ const getAccountBalanceHistory: Api = async ( txs .filter( ({ blockTime }) => - (from || 0) <= blockTime && blockTime <= (to || Number.MAX_SAFE_INTEGER) + (from || 0) <= blockTime && blockTime <= (to || Number.MAX_SAFE_INTEGER), ) .sort((a, b) => a.blockTime - b.blockTime) - .map(tx => ({ blockTime: -1, ...transformTransaction(descriptor, addresses, tx) })) + .map(tx => ({ blockTime: -1, ...transformTransaction(descriptor, addresses, tx) })), ); return aggregateTransactions(txs, groupBy); diff --git a/packages/blockchain-link/src/workers/electrum/methods/getAccountInfo.ts b/packages/blockchain-link/src/workers/electrum/methods/getAccountInfo.ts index 0da0fcf2df..e30fbada67 100644 --- a/packages/blockchain-link/src/workers/electrum/methods/getAccountInfo.ts +++ b/packages/blockchain-link/src/workers/electrum/methods/getAccountInfo.ts @@ -34,7 +34,7 @@ const getBalances = confirmed, unconfirmed, }; - }) + }), ); const getAccountInfo: Api = async (client, payload) => { @@ -56,7 +56,7 @@ const getAccountInfo: Api = async (client, payload) => { const transactions = details === 'txs' ? await getTransactions(client, history).then(txs => - txs.map(tx => transformTransaction(descriptor, undefined, tx)) + txs.map(tx => transformTransaction(descriptor, undefined, tx)), ) : undefined; @@ -84,15 +84,15 @@ const getAccountInfo: Api = async (client, payload) => { } const discover = discoverAddress(client); const receive = await discovery(discover, descriptor, 'receive', network).then( - getBalances(client) + getBalances(client), ); const change = await discovery(discover, descriptor, 'change', network).then( - getBalances(client) + getBalances(client), ); const batch = receive.concat(change); const [confirmed, unconfirmed] = batch.reduce( ([c, u], { confirmed, unconfirmed }) => [c + confirmed, u + unconfirmed], - [0, 0] + [0, 0], ); const history = batch.flatMap(({ history }) => history); const historyUnconfirmed = history.filter(r => r.height <= 0).length; @@ -112,19 +112,19 @@ const getAccountInfo: Api = async (client, payload) => { const transactions = ['tokenBalances', 'txids', 'txs'].includes(details) ? await getTransactions(client, history).then(txs => - txs.map(tx => transformTransaction(descriptor, addresses, tx)) + txs.map(tx => transformTransaction(descriptor, addresses, tx)), ) : []; const sumAddressValues = ( address: string, - getVinVouts: (tr: ReturnType) => VinVout[] + getVinVouts: (tr: ReturnType) => VinVout[], ) => transactions .flatMap(tx => getVinVouts(tx) .filter(({ addresses }) => addresses?.includes(address)) - .map(({ value }) => (value ? Number.parseFloat(value) : 0)) + .map(({ value }) => (value ? Number.parseFloat(value) : 0)), ) .reduce((a, b) => a + b, 0); diff --git a/packages/blockchain-link/src/workers/electrum/methods/getAccountUtxo.ts b/packages/blockchain-link/src/workers/electrum/methods/getAccountUtxo.ts index 206dda785f..6f1800fe93 100644 --- a/packages/blockchain-link/src/workers/electrum/methods/getAccountUtxo.ts +++ b/packages/blockchain-link/src/workers/electrum/methods/getAccountUtxo.ts @@ -48,8 +48,8 @@ const getAccountUtxo: Api = async (client, descriptor) => { .map(({ address, path, scripthash }) => client .request('blockchain.scripthash.listunspent', scripthash) - .then(utxos => utxos.map(transformUtxo(height, { address, path }))) - ) + .then(utxos => utxos.map(transformUtxo(height, { address, path }))), + ), ).then(res => res.flat()); return result; }; diff --git a/packages/blockchain-link/src/workers/electrum/utils/addressManager.ts b/packages/blockchain-link/src/workers/electrum/utils/addressManager.ts index 55b888ee62..c830b7e8f7 100644 --- a/packages/blockchain-link/src/workers/electrum/utils/addressManager.ts +++ b/packages/blockchain-link/src/workers/electrum/utils/addressManager.ts @@ -10,7 +10,7 @@ const addressesFromAccounts = (array: (AccountAddresses | undefined)[]) => array .filter(isNotUndefined) .flatMap(({ change, used, unused }) => - change.concat(used, unused).map(({ address }) => address) + change.concat(used, unused).map(({ address }) => address), ); export const createAddressManager = (network?: Network) => { @@ -25,7 +25,7 @@ export const createAddressManager = (network?: Network) => { ...dic, [addr]: addressToScripthash(addr, network), }), - subscribedAddrs + subscribedAddrs, ); return toAdd.map(addr => subscribedAddrs[addr]); @@ -49,7 +49,7 @@ export const createAddressManager = (network?: Network) => { ...dic, [acc.descriptor]: acc.addresses || { change: [], used: [], unused: [] }, }), - subscribedAccs + subscribedAccs, ); const addresses = addressesFromAccounts(toAdd.map(acc => acc.addresses)); @@ -61,7 +61,7 @@ export const createAddressManager = (network?: Network) => { const [toRemove, toPreserve] = accounts ? objectPartition( subscribedAccs, - accounts.map(({ descriptor }) => descriptor) + accounts.map(({ descriptor }) => descriptor), ) : [subscribedAccs, {}]; @@ -81,7 +81,7 @@ export const createAddressManager = (network?: Network) => { const [account, addresses] = Object.entries(subscribedAccs).find( ([_acc, { change, unused, used }]) => - !!change.concat(used, unused).find(ad => ad.address === address) + !!change.concat(used, unused).find(ad => ad.address === address), ) || []; return { descriptor: account || address, diff --git a/packages/blockchain-link/src/workers/electrum/utils/transaction.ts b/packages/blockchain-link/src/workers/electrum/utils/transaction.ts index 5d173799cf..b6aaeace95 100644 --- a/packages/blockchain-link/src/workers/electrum/utils/transaction.ts +++ b/packages/blockchain-link/src/workers/electrum/utils/transaction.ts @@ -76,7 +76,7 @@ const formatTransaction = export const getTransactions = async ( client: ElectrumAPI, - history: HistoryTx[] + history: HistoryTx[], ): Promise => { const txids = history.map(({ tx_hash }) => tx_hash).filter(arrayDistinct); @@ -84,7 +84,7 @@ export const getTransactions = async ( // binary data locally instead. Then the transaction could be cached indefinitely. const origTxs = await Promise.all( - txids.map(txid => client.request('blockchain.transaction.get', txid, true)) + txids.map(txid => client.request('blockchain.transaction.get', txid, true)), ).then(txs => arrayToDictionary(txs, ({ txid }) => txid)); const prevTxs = await Promise.all( @@ -92,7 +92,7 @@ export const getTransactions = async ( .flatMap(({ vin }) => vin.filter(isNotCoinbase).map(({ txid }) => txid)) .filter(arrayDistinct) .filter(txid => !origTxs[txid]) - .map(txid => client.request('blockchain.transaction.get', txid, true)) + .map(txid => client.request('blockchain.transaction.get', txid, true)), ).then(txs => arrayToDictionary(txs, ({ txid }) => txid)); /* TODO diff --git a/packages/blockchain-link/src/workers/electrum/utils/transform.ts b/packages/blockchain-link/src/workers/electrum/utils/transform.ts index d10673e433..c1bbac6246 100644 --- a/packages/blockchain-link/src/workers/electrum/utils/transform.ts +++ b/packages/blockchain-link/src/workers/electrum/utils/transform.ts @@ -21,7 +21,7 @@ export const blockheaderToBlockhash = (header: string) => { export const tryGetScripthash = ( address: string, - network?: Network + network?: Network, ): { valid: true; scripthash: string } | { valid: false } => { try { return { diff --git a/packages/blockchain-link/src/workers/ripple/index.ts b/packages/blockchain-link/src/workers/ripple/index.ts index 38d4cf02b8..fef2b2b6ce 100644 --- a/packages/blockchain-link/src/workers/ripple/index.ts +++ b/packages/blockchain-link/src/workers/ripple/index.ts @@ -148,7 +148,7 @@ const getAccountInfo = async (request: Request) => const api = await request.connect(); const transactionsData: RawTxData = await api.request('account_tx', requestOptions); account.history.transactions = transactionsData.transactions.map(raw => - utils.transformTransaction(payload.descriptor, raw.tx) + utils.transformTransaction(payload.descriptor, raw.tx), ); return { @@ -503,7 +503,7 @@ class RippleWorker extends BaseWorker { } this.pingTimeout = setTimeout( () => this.onPing(), - this.settings.pingTimeout || DEFAULT_PING_TIMEOUT + this.settings.pingTimeout || DEFAULT_PING_TIMEOUT, ); } diff --git a/packages/blockchain-link/src/workers/state.ts b/packages/blockchain-link/src/workers/state.ts index 50b5a4959c..d28980b0a1 100644 --- a/packages/blockchain-link/src/workers/state.ts +++ b/packages/blockchain-link/src/workers/state.ts @@ -65,7 +65,7 @@ export class WorkerState { this.accounts = others.concat(valid); const addresses = this.accounts.reduce( (addr, a) => addr.concat(this.getAccountAddresses(a)), - [] as string[] + [] as string[], ); this.addAddresses(addresses); return valid; @@ -91,11 +91,11 @@ export class WorkerState { removeAccounts(acc: SubscriptionAccountInfo[]): SubscriptionAccountInfo[] { const valid = this.validateAccounts(acc); const accountsToRemove = this.accounts.filter(a => - valid.find(b => b.descriptor === a.descriptor) + valid.find(b => b.descriptor === a.descriptor), ); const addressesToRemove = accountsToRemove.reduce( (addr, acc) => addr.concat(this.getAccountAddresses(acc)), - [] as string[] + [] as string[], ); this.accounts = this.accounts.filter(a => accountsToRemove.indexOf(a) < 0); this.removeAddresses(addressesToRemove); diff --git a/packages/blockchain-link/src/workers/utils.ts b/packages/blockchain-link/src/workers/utils.ts index dc02bee9cb..404b50635e 100644 --- a/packages/blockchain-link/src/workers/utils.ts +++ b/packages/blockchain-link/src/workers/utils.ts @@ -28,7 +28,7 @@ export const filterTargets = (addresses: Addresses, targets: VinVout[]): VinVout export const sumVinVout = ( vinVout: VinVout[], initialValue = '0', - operation: 'sum' | 'reduce' = 'sum' + operation: 'sum' | 'reduce' = 'sum', ) => { const sum = vinVout.reduce((bn, v) => { if (typeof v.value !== 'string') return bn; diff --git a/packages/blockchain-link/tests/unit/blockfrost/utils.ts b/packages/blockchain-link/tests/unit/blockfrost/utils.ts index ec1579a4f3..7dca2fa262 100644 --- a/packages/blockchain-link/tests/unit/blockfrost/utils.ts +++ b/packages/blockchain-link/tests/unit/blockfrost/utils.ts @@ -48,7 +48,7 @@ describe('blockfrost/utils', () => { it(f.description, () => { // @ts-expect-error incorrect params expect(transformTransaction(f.descriptor, f.accountAddress, f.data)).toMatchObject( - f.result + f.result, ); }); }); diff --git a/packages/blockchain-link/tests/unit/fixtures/accounts/ripple/rfkV3EoXimH6JrG1QAyofgbVhnyZZDjWSj.json b/packages/blockchain-link/tests/unit/fixtures/accounts/ripple/rfkV3EoXimH6JrG1QAyofgbVhnyZZDjWSj.json index 1b1ca7572a..f7c77fef2b 100644 --- a/packages/blockchain-link/tests/unit/fixtures/accounts/ripple/rfkV3EoXimH6JrG1QAyofgbVhnyZZDjWSj.json +++ b/packages/blockchain-link/tests/unit/fixtures/accounts/ripple/rfkV3EoXimH6JrG1QAyofgbVhnyZZDjWSj.json @@ -122,6 +122,5 @@ } ] } - } -} \ No newline at end of file +} diff --git a/packages/blockchain-link/tests/websocket/fixtures/blockbook.json b/packages/blockchain-link/tests/websocket/fixtures/blockbook.json index 5634b6846a..b1e7a96b69 100644 --- a/packages/blockchain-link/tests/websocket/fixtures/blockbook.json +++ b/packages/blockchain-link/tests/websocket/fixtures/blockbook.json @@ -1,68 +1,68 @@ { "getInfo": { - "data": { - "name": "Test", - "shortcut": "test", - "decimals": 9, - "bestHeight": 1 - } + "data": { + "name": "Test", + "shortcut": "test", + "decimals": 9, + "bestHeight": 1 + } }, "getBlockHash": { - "data": { - "hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048" - } + "data": { + "hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048" + } }, "subscribeNewBlock": { - "data": { - "subscribed": true - } + "data": { + "subscribed": true + } }, "unsubscribeNewBlock": { - "data": { - "subscribed": false - } + "data": { + "subscribed": false + } }, "subscribeAddresses": { - "data": { - "subscribed": true - } + "data": { + "subscribed": true + } }, "unsubscribeAddresses": { - "data": { - "subscribed": false - } + "data": { + "subscribed": false + } }, "getAccountInfo": { - "data": { - "address": "0", - "balance": "0", - "txs": 0, - "unconfirmedBalance": 0, - "unconfirmedTxs": 0, - "nonce": "0", - "totalReceived": "0", - "totalSent": "0", - "usedTokens": 0 - } + "data": { + "address": "0", + "balance": "0", + "txs": 0, + "unconfirmedBalance": 0, + "unconfirmedTxs": 0, + "nonce": "0", + "totalReceived": "0", + "totalSent": "0", + "usedTokens": 0 + } }, "getAccountUtxo": { - "data": [] + "data": [] }, "sendTransaction": { - "data": { - "error": { - "message": "-22: TX decode failed" - } - } + "data": { + "error": { + "message": "-22: TX decode failed" + } + } }, "estimateFee": { - "data": [] + "data": [] }, "getTransaction": { - "data": { - "error": { - "message": "Transaction not found" - } - } + "data": { + "error": { + "message": "Transaction not found" + } + } } - } \ No newline at end of file +} diff --git a/packages/blockchain-link/tests/websocket/fixtures/ripple.json b/packages/blockchain-link/tests/websocket/fixtures/ripple.json index 8e5d92f035..78c0ec172f 100644 --- a/packages/blockchain-link/tests/websocket/fixtures/ripple.json +++ b/packages/blockchain-link/tests/websocket/fixtures/ripple.json @@ -66,4 +66,4 @@ "error_code": 29, "error_message": "Transaction not found." } - } \ No newline at end of file +} diff --git a/packages/blockchain-link/tests/websocket/index.ts b/packages/blockchain-link/tests/websocket/index.ts index ed75fcb641..567c0fdf82 100644 --- a/packages/blockchain-link/tests/websocket/index.ts +++ b/packages/blockchain-link/tests/websocket/index.ts @@ -221,7 +221,7 @@ const createServer = async (type: keyof typeof DEFAULT_RESPONSES) => { } if (Array.isArray(request.accounts_proposed)) { server.addresses = server.addresses.filter( - a => request.accounts_proposed.indexOf(a) < 0 + a => request.accounts_proposed.indexOf(a) < 0, ); if (server.addresses.length === 0) server.addresses = undefined; } diff --git a/packages/blockchain-link/tsconfig.json b/packages/blockchain-link/tsconfig.json index ebf70df3a1..7e78af8746 100644 --- a/packages/blockchain-link/tsconfig.json +++ b/packages/blockchain-link/tsconfig.json @@ -5,4 +5,4 @@ }, "include": ["./src/**/*.ts", "./tests/**/*.ts"], "exclude": ["node_modules"] -} \ No newline at end of file +} diff --git a/packages/blockchain-link/tsconfig.lib.json b/packages/blockchain-link/tsconfig.lib.json index 567f92bf4b..36be8fc0b5 100644 --- a/packages/blockchain-link/tsconfig.lib.json +++ b/packages/blockchain-link/tsconfig.lib.json @@ -17,4 +17,4 @@ }, "include": ["./src/index.ts", "./src/utils/ws.ts", "./src/utils/socks-proxy-agent.ts"], "exclude": ["node_modules"] -} \ No newline at end of file +} diff --git a/packages/components/.gitignore b/packages/components/.gitignore deleted file mode 100644 index d4f0590900..0000000000 --- a/packages/components/.gitignore +++ /dev/null @@ -1,97 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.vscode - -docs - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# next.js build output -.next - -# nuxt.js build output -.nuxt - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -#DynamoDB Local files -.dynamodb/ - -# dev mess -src/.old_components - -# npm module -npm - -lib - -.DS_Store - -__diff_output__ -test/screenshots -test/screenshots -test/videos diff --git a/packages/components/.npmignore b/packages/components/.npmignore deleted file mode 100644 index 63eaa5bdf6..0000000000 --- a/packages/components/.npmignore +++ /dev/null @@ -1,18 +0,0 @@ -src -docs -.babel-config -.storybook -.eslintignore -.eslintrc -.gitignore -node_modules -.snyk -.stylelintrc -babel.config.js -yarn.lock -public -scripts -test - -.* -cypress.json \ No newline at end of file diff --git a/packages/components/.prettierignore b/packages/components/.prettierignore deleted file mode 100644 index 0e696071e8..0000000000 --- a/packages/components/.prettierignore +++ /dev/null @@ -1,10 +0,0 @@ -public -build -coverage -cache/** -node_modules -src/flowtype/npm -scripts/solidity/.* -**/_old/* -docs -lib \ No newline at end of file diff --git a/packages/components/.prettierrc b/packages/components/.prettierrc deleted file mode 100644 index 9cbc7dfd64..0000000000 --- a/packages/components/.prettierrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "printWidth": 100, - "tabWidth": 4, - "singleQuote": true, - "trailingComma": "es5", - "arrowParens": "avoid", - "bracketSpacing": true, - "semi": true, - "useTabs": false, - "jsxBracketSameLine": false -} \ No newline at end of file diff --git a/packages/components/.storybook/manager-head.html b/packages/components/.storybook/manager-head.html index 0ec4f1ca83..61847d549e 100644 --- a/packages/components/.storybook/manager-head.html +++ b/packages/components/.storybook/manager-head.html @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/packages/components/.storybook/preview-head.html b/packages/components/.storybook/preview-head.html index 0ec4f1ca83..61847d549e 100644 --- a/packages/components/.storybook/preview-head.html +++ b/packages/components/.storybook/preview-head.html @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/packages/components/.storybook/preview.js b/packages/components/.storybook/preview.js index 35adc03645..768b6e7aa6 100644 --- a/packages/components/.storybook/preview.js +++ b/packages/components/.storybook/preview.js @@ -1,7 +1,13 @@ import React from 'react'; import { StoryWrapper } from '../src/support/Story'; -export const decorators = [(Story) => ]; +export const decorators = [ + Story => ( + + + + ), +]; export const parameters = { options: { showPanel: true, @@ -11,4 +17,4 @@ export const parameters = { theme: { base: 'light', }, -}; \ No newline at end of file +}; diff --git a/packages/components/README.md b/packages/components/README.md index fb32cadd6d..f0c7a3d844 100644 --- a/packages/components/README.md +++ b/packages/components/README.md @@ -3,4 +3,3 @@ [![npm version](https://badge.fury.io/js/trezor-ui-components.svg)](https://badge.fury.io/js/trezor-ui-components) This repository contains UI components that are intended to be used accross related Trezor frontend projects. - diff --git a/packages/components/src/components/Dropdown/index.stories.tsx b/packages/components/src/components/Dropdown/index.stories.tsx index a3e8b757df..29850d7602 100644 --- a/packages/components/src/components/Dropdown/index.stories.tsx +++ b/packages/components/src/components/Dropdown/index.stories.tsx @@ -12,7 +12,7 @@ storiesOf('Dropdown', module).add('Dropdown', () => { left: 'left', right: 'right', }, - null + null, ); const isDisabled = boolean('isDisabled', false); const offset = number('offset', 10); diff --git a/packages/components/src/components/Dropdown/index.tsx b/packages/components/src/components/Dropdown/index.tsx index 2869065513..14242a37ba 100644 --- a/packages/components/src/components/Dropdown/index.tsx +++ b/packages/components/src/components/Dropdown/index.tsx @@ -279,7 +279,7 @@ const Dropdown = forwardRef( masterLink, ...rest }: Props, - ref + ref, ) => { const theme = useTheme(); const [toggled, setToggledState] = useState(false); @@ -300,7 +300,7 @@ const Dropdown = forwardRef( if (onToggle) onToggle(isToggled); setToggledState(isToggled); }, - [onToggle] + [onToggle], ); useLayoutEffect(() => { @@ -471,7 +471,7 @@ const Dropdown = forwardRef( {toggled && portalMenu} ); - } + }, ); Dropdown.displayName = 'Dropdown'; diff --git a/packages/components/src/components/Fade/index.tsx b/packages/components/src/components/Fade/index.tsx index d29cde728a..7703983318 100644 --- a/packages/components/src/components/Fade/index.tsx +++ b/packages/components/src/components/Fade/index.tsx @@ -43,7 +43,7 @@ export const Fade: React.FC = ({ } }); }, - { threshold } + { threshold }, ); observer.observe(div); return () => observer.unobserve(div); diff --git a/packages/components/src/components/Flag/all.stories.tsx b/packages/components/src/components/Flag/all.stories.tsx index 5d0cb4d93e..9bc02c452b 100644 --- a/packages/components/src/components/Flag/all.stories.tsx +++ b/packages/components/src/components/Flag/all.stories.tsx @@ -53,5 +53,5 @@ storiesOf('Flags', module).add( options: { showPanel: false, }, - } + }, ); diff --git a/packages/components/src/components/HoverAnimation/index.tsx b/packages/components/src/components/HoverAnimation/index.tsx index a9194dd726..9d846b8098 100644 --- a/packages/components/src/components/HoverAnimation/index.tsx +++ b/packages/components/src/components/HoverAnimation/index.tsx @@ -33,7 +33,7 @@ const Wrapper = styled.div<{ size?: string; isHoverable?: boolean }>` background-color: ${props => transparentize( props.theme.HOVER_TRANSPARENTIZE_FILTER, - props.theme.HOVER_PRIMER_COLOR + props.theme.HOVER_PRIMER_COLOR, )}; ${props.size === 'tiny' ? css` diff --git a/packages/components/src/components/Icon/all.stories.tsx b/packages/components/src/components/Icon/all.stories.tsx index aef586216c..43e2231281 100644 --- a/packages/components/src/components/Icon/all.stories.tsx +++ b/packages/components/src/components/Icon/all.stories.tsx @@ -46,5 +46,5 @@ storiesOf('Icons', module).add( options: { showPanel: false, }, - } + }, ); diff --git a/packages/components/src/components/Icon/index.tsx b/packages/components/src/components/Icon/index.tsx index 22fca38d21..25d5a68467 100644 --- a/packages/components/src/components/Icon/index.tsx +++ b/packages/components/src/components/Icon/index.tsx @@ -100,7 +100,7 @@ const Icon = React.forwardRef( onFocus, ...rest }: Props, - ref?: React.Ref + ref?: React.Ref, ) => { const theme = useTheme(); const defaultColor = color ?? theme.TYPE_LIGHT_GREY; @@ -131,7 +131,7 @@ const Icon = React.forwardRef( /> ); - } + }, ); export { Icon, Props as IconProps }; diff --git a/packages/components/src/components/Modal/index.stories.tsx b/packages/components/src/components/Modal/index.stories.tsx index 1f5bca37a1..f9d953a02d 100644 --- a/packages/components/src/components/Modal/index.stories.tsx +++ b/packages/components/src/components/Modal/index.stories.tsx @@ -16,7 +16,7 @@ storiesOf('Modals', module) const description = text('description', 'Description'); const children = text( 'children', - 'Ave Maria, gratia plena, Dominus tecum. Benedicta tu in mulieribus, et benedictus fructus ventris tui, Iesus.' + 'Ave Maria, gratia plena, Dominus tecum. Benedicta tu in mulieribus, et benedictus fructus ventris tui, Iesus.', ); const cancelable = boolean('cancelable', true); const bottomBar = boolean('bottomBar', false); @@ -54,7 +54,7 @@ storiesOf('Modals', module) const description = text('description', 'Description'); const children = text( 'children', - 'Ave Maria, gratia plena, Dominus tecum. Benedicta tu in mulieribus, et benedictus fructus ventris tui, Iesus.' + 'Ave Maria, gratia plena, Dominus tecum. Benedicta tu in mulieribus, et benedictus fructus ventris tui, Iesus.', ); const cancelable = boolean('cancelable', true); const useFixedWidth = boolean('useFixedWidth', false); diff --git a/packages/components/src/components/Timerange/index.stories.tsx b/packages/components/src/components/Timerange/index.stories.tsx index 91310fcb04..0d4dbe0312 100644 --- a/packages/components/src/components/Timerange/index.stories.tsx +++ b/packages/components/src/components/Timerange/index.stories.tsx @@ -36,5 +36,5 @@ storiesOf('Timerange', module).add( }, { argTypes: { onChange: { action: 'onChange' } }, - } + }, ); diff --git a/packages/components/src/components/Tooltip/all.stories.tsx b/packages/components/src/components/Tooltip/all.stories.tsx index a8042e472f..7e17376f91 100644 --- a/packages/components/src/components/Tooltip/all.stories.tsx +++ b/packages/components/src/components/Tooltip/all.stories.tsx @@ -73,5 +73,5 @@ storiesOf('Tooltip', module).add( options: { showPanel: false, }, - } + }, ); diff --git a/packages/components/src/components/Tooltip/index.stories.tsx b/packages/components/src/components/Tooltip/index.stories.tsx index 62b1f6bc03..a0df1d9096 100644 --- a/packages/components/src/components/Tooltip/index.stories.tsx +++ b/packages/components/src/components/Tooltip/index.stories.tsx @@ -22,7 +22,7 @@ storiesOf('Tooltip', module).add('Tooltip', () => { Left: 'left', Right: 'right', }, - 'bottom' + 'bottom', ); return ( diff --git a/packages/components/src/components/buttons/Button/index.stories.tsx b/packages/components/src/components/buttons/Button/index.stories.tsx index 3a8ce9f75d..6c4a3cff22 100644 --- a/packages/components/src/components/buttons/Button/index.stories.tsx +++ b/packages/components/src/components/buttons/Button/index.stories.tsx @@ -14,7 +14,7 @@ storiesOf('Buttons', module).add('Button', () => { Tertiary: 'tertiary', Danger: 'danger', }, - null + null, ); const size: any = select( 'Size', @@ -22,7 +22,7 @@ storiesOf('Buttons', module).add('Button', () => { 'Default (large)': null, Small: 'small', }, - null + null, ); const iconOptions: any = { @@ -39,7 +39,7 @@ storiesOf('Buttons', module).add('Button', () => { 'Default (left)': 'left', Right: 'right', }, - 'left' + 'left', ) : null; diff --git a/packages/components/src/components/buttons/Button/index.tsx b/packages/components/src/components/buttons/Button/index.tsx index f581ba150e..d0ec5cb01c 100644 --- a/packages/components/src/components/buttons/Button/index.tsx +++ b/packages/components/src/components/buttons/Button/index.tsx @@ -229,7 +229,7 @@ const Button = React.forwardRef( onChange, ...rest }: Props, - ref?: React.Ref + ref?: React.Ref, ) => { const theme = useTheme(); const hasLabel = !!children; @@ -267,7 +267,7 @@ const Button = React.forwardRef( {isLoading && alignIcon === 'right' && Loader} ); - } + }, ); export { Button, Props as ButtonProps }; diff --git a/packages/components/src/components/buttons/index.stories.tsx b/packages/components/src/components/buttons/index.stories.tsx index d0bcc70412..715c409f93 100644 --- a/packages/components/src/components/buttons/index.stories.tsx +++ b/packages/components/src/components/buttons/index.stories.tsx @@ -76,5 +76,5 @@ storiesOf('Buttons', module).add( options: { showPanel: false, }, - } + }, ); diff --git a/packages/components/src/components/form/Checkbox/index.tsx b/packages/components/src/components/form/Checkbox/index.tsx index d2e1e238d2..094bc2a465 100755 --- a/packages/components/src/components/form/Checkbox/index.tsx +++ b/packages/components/src/components/form/Checkbox/index.tsx @@ -52,7 +52,7 @@ const Label = styled.div` interface Props extends React.HTMLAttributes { onClick: ( - event: React.KeyboardEvent | React.MouseEvent | null + event: React.KeyboardEvent | React.MouseEvent | null, ) => any; isChecked?: boolean; } diff --git a/packages/components/src/components/form/RadioButton/index.tsx b/packages/components/src/components/form/RadioButton/index.tsx index c14afee6c2..71814e070e 100755 --- a/packages/components/src/components/form/RadioButton/index.tsx +++ b/packages/components/src/components/form/RadioButton/index.tsx @@ -53,7 +53,7 @@ const Label = styled.div` interface Props extends React.HTMLAttributes { onClick: ( - event: React.KeyboardEvent | React.MouseEvent | null + event: React.KeyboardEvent | React.MouseEvent | null, ) => any; isChecked?: boolean; } diff --git a/packages/components/src/components/form/Select/index.tsx b/packages/components/src/components/form/Select/index.tsx index 16f396ea07..3eeb64f67e 100644 --- a/packages/components/src/components/form/Select/index.tsx +++ b/packages/components/src/components/form/Select/index.tsx @@ -20,7 +20,7 @@ const selectStyle = ( borderRadius: number, borderWidth: number, theme: SuiteThemeColors, - selectState?: InputState + selectState?: InputState, ) => ({ singleValue: (base: Record) => ({ ...base, @@ -41,7 +41,7 @@ const selectStyle = ( }), control: ( base: Record, - { isDisabled, isFocused }: { isDisabled: boolean; isFocused: boolean } + { isDisabled, isFocused }: { isDisabled: boolean; isFocused: boolean }, ) => { let height = variant === 'small' ? '36px' : '48px'; const borderColor = selectState ? getStateColor(selectState, theme) : theme.STROKE_GREY; @@ -193,7 +193,7 @@ interface Option { /** Custom Type Guards to check if options are grouped or not */ const isOptionGrouped = ( - x: OptionsType