diff --git a/web-wallet/.eslintrc.cjs b/web-wallet/.eslintrc.cjs index 496a8229ac..495bac4d4b 100644 --- a/web-wallet/.eslintrc.cjs +++ b/web-wallet/.eslintrc.cjs @@ -1,73 +1,72 @@ module.exports = { - "env": { - "browser": true, - "es2022": true, - "node": true + env: { + browser: true, + es2022: true, + node: true, }, - "extends": [ + extends: [ "@dusk-network/eslint-config/js", - "@dusk-network/eslint-config/svelte" + "@dusk-network/eslint-config/svelte", ], - "globals": { - "CONFIG": false + globals: { + CONFIG: false, }, - "overrides": [{ - "files": ["*.svelte"], - "rules": { - "no-undef-init": 0, - "svelte/require-optimized-style-attribute": 0 - } - }, { - "files": ["*.spec.js", "*.test.js"], - "rules": { - "brace-style": [ - "error", - "1tbs", - { "allowSingleLine": true } - ], - "jsdoc/require-jsdoc": 0, - "max-len": [ - "error", { - "code": 110, - "comments": 110, - "ignorePattern": "^\\s*it\\(", - "ignoreUrls": true - } - ], - "max-nested-callbacks": [ - "error", - 5 - ], - "max-statements": 0, - "max-statements-per-line": [ - "error", { - "max": 2 - } - ], - "object-curly-newline": 0, - "quote-props": [ - "error", - "consistent" - ], - "sort-keys": 0 - } - }], - "root": true, - "settings": { + overrides: [ + { + files: ["*.svelte"], + rules: { + "no-undef-init": 0, + "svelte/require-optimized-style-attribute": 0, + }, + }, + { + files: ["*.spec.js", "*.test.js"], + rules: { + "brace-style": ["error", "1tbs", {allowSingleLine: true}], + "jsdoc/require-jsdoc": 0, + "max-len": [ + "error", + { + code: 110, + comments: 110, + ignorePattern: "^\\s*it\\(", + ignoreUrls: true, + }, + ], + "max-nested-callbacks": ["error", 5], + "max-statements": 0, + "max-statements-per-line": [ + "error", + { + max: 2, + }, + ], + "object-curly-newline": 0, + "sort-keys": 0, + }, + }, + ], + root: true, + settings: { "import/resolver": { "eslint-import-resolver-custom-alias": { - "alias": { - "$app": "node_modules/@sveltejs/kit/src/runtime/app", - "$config": "./src/config", - "$lib": "./src/lib", - "@sveltejs/kit": "node_modules/@sveltejs/kit/src/exports/index.js", - "@testing-library/svelte": "node_modules/@testing-library/svelte/src/index.js", - "svelte/motion": "node_modules/svelte/src/runtime/motion/index.js", - "svelte/store": "node_modules/svelte/src/runtime/store/index.js", - "svelte/transition": "node_modules/svelte/src/runtime/transition/index.js" + alias: { + $app: "node_modules/@sveltejs/kit/src/runtime/app", + $config: "./src/config", + $lib: "./src/lib", + "@sveltejs/kit": + "node_modules/@sveltejs/kit/src/exports/index.js", + "@testing-library/svelte": + "node_modules/@testing-library/svelte/src/index.js", + "svelte/motion": + "node_modules/svelte/src/runtime/motion/index.js", + "svelte/store": + "node_modules/svelte/src/runtime/store/index.js", + "svelte/transition": + "node_modules/svelte/src/runtime/transition/index.js", }, - "extensions": [".cjs", ".js", ".json", ".svelte"] - } - } - } + extensions: [".cjs", ".js", ".json", ".svelte"], + }, + }, + }, }; diff --git a/web-wallet/.prettierrc.js b/web-wallet/.prettierrc.js new file mode 100644 index 0000000000..0f6fa53016 --- /dev/null +++ b/web-wallet/.prettierrc.js @@ -0,0 +1,11 @@ +import duskJsPrettierConfig from "@dusk-network/prettier-config/js/index.js"; +import duskSveltePrettierConfig from "@dusk-network/prettier-config/svelte/index.js"; + +export default { + plugins: ["prettier-plugin-svelte"], + overrides: [{files: "*.svelte", options: {parser: "svelte"}}], + ...duskJsPrettierConfig, + ...duskSveltePrettierConfig, + arrowParens: "avoid", + bracketSpacing: false, +}; diff --git a/web-wallet/CHANGELOG.md b/web-wallet/CHANGELOG.md index d954a0cb78..5bf9f141ac 100644 --- a/web-wallet/CHANGELOG.md +++ b/web-wallet/CHANGELOG.md @@ -8,83 +8,85 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- Add Create Wallet flow tests [#1443] -- Add visible version, commit hash and build date [#1441] -- Add Address validation (Transfer flow) [#1377] + +- Add Create Wallet flow tests [#1443] +- Add visible version, commit hash and build date [#1441] +- Add Address validation (Transfer flow) [#1377] ### Changed -- Change Get Quote API Endpoint to env variable [#1311] +- Change Get Quote API Endpoint to env variable [#1311] ### Removed -- Remove the use of `checkValidity()` in Send and Stake flow amounts validity checks [#1391] +- Remove the use of `checkValidity()` in Send and Stake flow amounts validity checks [#1391] ### Fixed -- Fix typo in routes/welcome/\_\_tests\_\_/page.spec.js [#1445] -- Fix missing whitespace when Transaction list is empty [#1460] +- Fix typo in routes/welcome/\_\_tests\_\_/page.spec.js [#1445] +- Fix missing whitespace when Transaction list is empty [#1460] ## [0.2.1] - 2024-02-20 ### Added -- Add wallet restore flow tests [#1416] -- Add missing login flow tests [#1423] +- Add wallet restore flow tests [#1416] +- Add missing login flow tests [#1423] ### Fixed -- Fix restore flow allowing invalid mnemonic to be used to log in [#1416] -- Fix can't unlock the wallet with upper case words [#1417] +- Fix restore flow allowing invalid mnemonic to be used to log in [#1416] +- Fix can't unlock the wallet with upper case words [#1417] ## [0.2.0] - 2024-02-15 ### Added -- Add running node requirement notice in Staking flow [#1359] -- Add `fiatPrice` optional property to Balance component [#1323] -- Add ability to revert words when entering the mnemonic phrase [#1290] -- Add missing error handling when querying the quote API [#1322] -- Add gas settings validation to settings page [#1352] -- Add forced log out on inactive tabs [#1373] -- Add gas settings validation to block Send and Stake operations if invalid gas settings [#1354] -- Add abortable sync [#1401] -- Add `existing wallet notice` to wallet create, restore and login flows [#1360] -- Add `userId` value to localStorage preferences object during wallet create and restore [#1360] +- Add running node requirement notice in Staking flow [#1359] +- Add `fiatPrice` optional property to Balance component [#1323] +- Add ability to revert words when entering the mnemonic phrase [#1290] +- Add missing error handling when querying the quote API [#1322] +- Add gas settings validation to settings page [#1352] +- Add forced log out on inactive tabs [#1373] +- Add gas settings validation to block Send and Stake operations if invalid gas settings [#1354] +- Add abortable sync [#1401] +- Add `existing wallet notice` to wallet create, restore and login flows [#1360] +- Add `userId` value to localStorage preferences object during wallet create and restore [#1360] ### Changed -- Change Holdings component design [#1361] -- Change `fiatCurrency`, `locale`, `tokenCurrency`, `token` to required properties in Balance component [#1323] -- Change `package.json` fields to reflect repo change [#1367] -- Change `walletStore.js` to receive gasPrice and gasLimit when `transfer` , `stake`, `unstake` and `withdrawRewards` are called [#1353] -- Update deprecated Node actions in CI [#1343] -- Change `setGasSettings` event to `gasSettings` and include `isValidGas` property in event data [#1354] -- Change "withdraw stake" label to "unstake" [#1403] -- Change logout flow to abort a sync if in progress [#1401] -- Update dusk-wallet-js to from 0.3.2 to 0.4.2 [#1401] +- Change Holdings component design [#1361] +- Change `fiatCurrency`, `locale`, `tokenCurrency`, `token` to required properties in Balance component [#1323] +- Change `package.json` fields to reflect repo change [#1367] +- Change `walletStore.js` to receive gasPrice and gasLimit when `transfer` , `stake`, `unstake` and `withdrawRewards` are called [#1353] +- Update deprecated Node actions in CI [#1343] +- Change `setGasSettings` event to `gasSettings` and include `isValidGas` property in event data [#1354] +- Change "withdraw stake" label to "unstake" [#1403] +- Change logout flow to abort a sync if in progress [#1401] +- Update dusk-wallet-js to from 0.3.2 to 0.4.2 [#1401] ### Removed -- Remove `fiat` property from Balance component [#1323] -- Remove `gasSettings` store update from `dashboard/+page.svelte.js` [#1353] +- Remove `fiat` property from Balance component [#1323] +- Remove `gasSettings` store update from `dashboard/+page.svelte.js` [#1353] ### Fixed -- Fix Transactions table remains hidden for some screen resolutions [#1412] -- Fix Stake button is always disabled [#1410] -- Fix wizard progression on Stake flow [#1398] -- Fix Seed Phrase words size [#1335] -- Fix colors on red background [#1334] -- Fix Transactions table design [#1309] +- Fix Transactions table remains hidden for some screen resolutions [#1412] +- Fix Stake button is always disabled [#1410] +- Fix wizard progression on Stake flow [#1398] +- Fix Seed Phrase words size [#1335] +- Fix colors on red background [#1334] +- Fix Transactions table design [#1309] ## [0.1.0-beta] - 2024-02-02 ### Added -- Add initial commit +- Add initial commit + [#1359]: https://github.com/dusk-network/rusk/issues/1359 [#1311]: https://github.com/dusk-network/rusk/issues/1311 [#1323]: https://github.com/dusk-network/rusk/issues/1323 @@ -117,6 +119,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#1443]: https://github.com/dusk-network/rusk/issues/1443 + [Unreleased]: https://github.com/dusk-network/rusk/tree/master/web-wallet [0.2.1]: https://github.com/dusk-network/rusk/tree/web-wallet-0.2.1 [0.2.0]: https://github.com/dusk-network/rusk/tree/web-wallet-0.2.0 diff --git a/web-wallet/README.md b/web-wallet/README.md index 1c4a749d54..59ff82ecd4 100644 --- a/web-wallet/README.md +++ b/web-wallet/README.md @@ -4,12 +4,12 @@ Web Wallet website. ## TOC -- [Web Wallet](#web-wallet) - - [TOC](#toc) - - [Build system and dev environment](#build-system-and-dev-environment) - - [Environment variables](#environment-variables) - - [NPM scripts](#npm-scripts) - - [Running a local Rusk node](#running-a-local-rusk-node) +- [Web Wallet](#web-wallet) + - [TOC](#toc) + - [Build system and dev environment](#build-system-and-dev-environment) + - [Environment variables](#environment-variables) + - [NPM scripts](#npm-scripts) + - [Running a local Rusk node](#running-a-local-rusk-node) ## Build system and dev environment @@ -23,6 +23,7 @@ As the application uses the [Web Crypto API](https://developer.mozilla.org/en-US The staging environment is at https://web-wallet-staging-oxs3z.ondigitalocean.app/ ## Environment variables + The `dusk-wallet-js` library uses some [environment variables](https://github.com/dusk-network/dusk-wallet-js/blob/main/.env). The application defines these variables by reading a local `.env` file containing the same variables used in the `dusk-wallet-js`, with the addition of the `VITE_` prefix. @@ -53,19 +54,19 @@ To run a local node different steps are needed, so please read the [related sect ## NPM scripts -- `npm run build` generates the production build -- `npm run checks` runs all checks (lint, typecheck and test) -- `npm run dev` generates the development build and starts the dev server -- `npm run dev:host` generates the development build, starts the dev server and exposes it to the local network -- `npm run lint`: performs the linting checks -- `npm run lint:fix`: runs ESLint with the `--fix` flag to fix formatting errors -- `npm run preview` previews the production build -- `npm test` runs the test suite -- `npm run test:coverage` runs the test suite and generate the code coverage report in the `coverage` folder -- `npm run test:watch` runs the test suite in watch mode -- `npm run typecheck` runs the type checker -- `npm run typecheck:watch` runs the type checker in watch mode +- `npm run build` generates the production build +- `npm run checks` runs all checks (lint, typecheck and test) +- `npm run dev` generates the development build and starts the dev server +- `npm run dev:host` generates the development build, starts the dev server and exposes it to the local network +- `npm run lint`: performs the linting checks +- `npm run lint:fix`: runs ESLint with the `--fix` flag to fix formatting errors +- `npm run preview` previews the production build +- `npm test` runs the test suite +- `npm run test:coverage` runs the test suite and generate the code coverage report in the `coverage` folder +- `npm run test:watch` runs the test suite in watch mode +- `npm run typecheck` runs the type checker +- `npm run typecheck:watch` runs the type checker in watch mode ## Running a local Rusk node -To run a local node, follow the instructions outlined in the [Rusk's readme](https://github.com/dusk-network/rusk). \ No newline at end of file +To run a local node, follow the instructions outlined in the [Rusk's readme](https://github.com/dusk-network/rusk). diff --git a/web-wallet/__mocks__/Wallet.js b/web-wallet/__mocks__/Wallet.js index 96c610d579..338ead1e6e 100644 --- a/web-wallet/__mocks__/Wallet.js +++ b/web-wallet/__mocks__/Wallet.js @@ -1,5 +1,5 @@ class Wallet { - constructor (seed, gasLimit = 2900000000, gasPrice = 1) { + constructor(seed, gasLimit = 2900000000, gasPrice = 1) { this.gasLimit = gasLimit; this.gasPrice = gasPrice; this.seed = seed; @@ -11,17 +11,17 @@ class Wallet { seed; wasm; - async history () {} - async getBalance () {} - async getPsks () {} - async stake () {} - async stakeAllow () {} - async stakeInfo () {} - async reset () {} - async sync () {} - async transfer () {} - async unstake () {} - async withdrawReward () {} + async history() {} + async getBalance() {} + async getPsks() {} + async stake() {} + async stakeAllow() {} + async stakeInfo() {} + async reset() {} + async sync() {} + async transfer() {} + async unstake() {} + async withdrawReward() {} } export default Wallet; diff --git a/web-wallet/jsconfig.json b/web-wallet/jsconfig.json index 0f45dc0b32..902fa25d46 100644 --- a/web-wallet/jsconfig.json +++ b/web-wallet/jsconfig.json @@ -14,8 +14,6 @@ "$lib": ["./src/lib"], "$lib/*": ["./src/lib/*"] }, - "types": [ - "./node_modules/@testing-library/jest-dom/types/vitest.d.ts" - ] + "types": ["./node_modules/@testing-library/jest-dom/types/vitest.d.ts"] } } diff --git a/web-wallet/package.json b/web-wallet/package.json index 99578ce0a2..3e7a245ccd 100644 --- a/web-wallet/package.json +++ b/web-wallet/package.json @@ -18,9 +18,11 @@ }, "scripts": { "build": "vite build", - "checks": "npm run lint && npm run typecheck && npm test", + "checks": "npm run format && npm run lint && npm run typecheck && npm test", "dev": "vite dev", "dev:host": "vite dev --host", + "format": "prettier . --check", + "format:fix": "prettier . --write", "lint": "eslint .", "lint:fix": "eslint . --fix", "preview": "vite preview", @@ -44,7 +46,8 @@ "svelte-persisted-store": "0.7.0" }, "devDependencies": { - "@dusk-network/eslint-config": "2.1.0", + "@dusk-network/eslint-config": "3.0.2", + "@dusk-network/prettier-config": "1.0.0", "@sveltejs/adapter-static": "2.0.3", "@sveltejs/kit": "1.27.6", "@testing-library/jest-dom": "6.1.4", diff --git a/web-wallet/src/app.html b/web-wallet/src/app.html index bb6bc7f624..961f8c05dd 100644 --- a/web-wallet/src/app.html +++ b/web-wallet/src/app.html @@ -1,14 +1,25 @@ - +
Status: %sveltekit.status%
-Message: %sveltekit.error.message%
- + + +Status: %sveltekit.status%
+Message: %sveltekit.error.message%
+ diff --git a/web-wallet/src/lamb.d.ts b/web-wallet/src/lamb.d.ts index 5f2c390f24..ac7e625f3f 100644 --- a/web-wallet/src/lamb.d.ts +++ b/web-wallet/src/lamb.d.ts @@ -8,19 +8,19 @@ declare module "lamb" { type FoldAccumulatorCallback< L extends ArrayLike