From 936d42bb8313446ca7d3a73d96a87cdfc5fe3ac3 Mon Sep 17 00:00:00 2001 From: Tomek Marciniak Date: Fri, 26 Apr 2024 10:55:09 +0200 Subject: [PATCH] chore(dx): replace eslint and prettier with biome --- .all-contributorsrc | 20 +- .eslintignore | 7 - .eslintrc.json | 19 - .prettierrc | 7 - apps/extension/e2e/address-book.spec.ts | 26 +- apps/extension/e2e/create-wallet.spec.ts | 20 +- apps/extension/e2e/extension.ts | 22 +- apps/extension/e2e/fixtures.ts | 30 +- apps/extension/e2e/pom/base.ts | 2 +- apps/extension/e2e/pom/onboarding.ts | 52 +- apps/extension/e2e/provider-enable.spec.ts | 112 +- apps/extension/e2e/restore-wallet.spec.ts | 16 +- apps/extension/e2e/settings.spec.ts | 14 +- apps/extension/e2e/staking.spec.ts | 26 +- apps/extension/e2e/transaction.spec.ts | 28 +- apps/extension/e2e/unlock-wallet.spec.ts | 20 +- apps/extension/manifest.config.ts | 70 +- apps/extension/package.json | 3 - apps/extension/playwright.config.ts | 28 +- apps/extension/postcss.config.mjs | 2 +- apps/extension/public/pallad_rpc.js | 31 +- apps/extension/scripts/append-oninstall.cjs | 13 +- apps/extension/src/app.tsx | 14 +- apps/extension/src/background/index.ts | 98 +- apps/extension/src/inject/index.ts | 22 +- apps/extension/src/main.tsx | 14 +- apps/extension/src/prompt.tsx | 18 +- apps/extension/src/typings.ts | 3 +- apps/extension/src/welcome.tsx | 18 +- apps/extension/tailwind.config.mjs | 6 +- apps/extension/vite.config.ts | 36 +- biome.json | 42 + extension.turbowatch.ts | 16 +- package.json | 14 +- packages/_template/tsup.config.ts | 10 +- packages/_template/vitest.config.ts | 6 +- packages/common/package.json | 6 +- packages/common/src/index.ts | 18 +- packages/common/tsconfig.json | 9 +- packages/features/.ladle/components.tsx | 29 +- packages/features/.ladle/config.mjs | 4 +- packages/features/.ladle/utils.ts | 34 - packages/features/.ladle/vite.config.ts | 18 +- packages/features/components.json | 2 +- packages/features/postcss.config.mjs | 4 +- packages/features/src/about/routes/about.tsx | 4 +- .../src/about/views/about.stories.tsx | 8 +- packages/features/src/about/views/about.tsx | 24 +- .../address-book/components/contact-tile.tsx | 26 +- .../components/new-address-form.schema.ts | 4 +- .../components/new-address-form.tsx | 46 +- .../src/address-book/routes/address-book.tsx | 8 +- .../src/address-book/routes/new-address.tsx | 4 +- .../views/address-book.stories.tsx | 8 +- .../src/address-book/views/address-book.tsx | 21 +- .../views/new-address.stories.tsx | 8 +- .../src/address-book/views/new-address.tsx | 6 +- .../features/src/common/hooks/use-account.ts | 48 +- .../common/hooks/use-blockchain-summary.ts | 8 +- .../src/common/hooks/use-transaction.ts | 12 +- .../src/common/hooks/use-transactions.ts | 10 +- packages/features/src/common/lib/const.ts | 12 +- packages/features/src/common/lib/currency.ts | 8 +- packages/features/src/common/lib/numbers.ts | 2 +- packages/features/src/common/lib/string.ts | 4 +- .../features/src/common/lib/validation.ts | 6 +- .../features/src/common/store/address-book.ts | 18 +- packages/features/src/common/store/app.ts | 22 +- .../features/src/common/store/onboarding.ts | 4 +- .../src/common/store/pending-transactions.ts | 30 +- .../features/src/common/store/transaction.ts | 10 +- packages/features/src/common/types.ts | 6 +- .../features/src/components/app-layout.tsx | 8 +- .../features/src/components/autocomplete.tsx | 28 +- .../src/components/bottom-navigation.tsx | 55 +- .../features/src/components/button-arrow.tsx | 2 +- .../features/src/components/command-menu.tsx | 107 +- .../features/src/components/form-error.tsx | 6 +- .../features/src/components/list-skeleton.tsx | 2 +- .../features/src/components/meta-field.tsx | 6 +- .../features/src/components/mina-icon.tsx | 3 +- .../src/components/restart-wallet-alert.tsx | 10 +- .../src/components/security-check.tsx | 6 +- .../src/components/social-buttons.tsx | 13 +- .../features/src/components/ui/accordion.tsx | 18 +- .../src/components/ui/alert-dialog.tsx | 40 +- packages/features/src/components/ui/alert.tsx | 30 +- .../src/components/ui/aspect-ratio.tsx | 2 +- .../features/src/components/ui/avatar.tsx | 16 +- packages/features/src/components/ui/badge.tsx | 24 +- .../features/src/components/ui/button.tsx | 46 +- .../features/src/components/ui/calendar.tsx | 64 +- packages/features/src/components/ui/card.tsx | 32 +- .../features/src/components/ui/checkbox.tsx | 14 +- .../src/components/ui/collapsible.tsx | 2 +- .../features/src/components/ui/command.tsx | 40 +- .../src/components/ui/context-menu.tsx | 52 +- .../features/src/components/ui/dialog.tsx | 36 +- .../src/components/ui/dropdown-menu.tsx | 50 +- packages/features/src/components/ui/form.tsx | 52 +- .../features/src/components/ui/hover-card.tsx | 12 +- packages/features/src/components/ui/input.tsx | 12 +- packages/features/src/components/ui/label.tsx | 10 +- .../features/src/components/ui/menubar.tsx | 66 +- .../src/components/ui/navigation-menu.tsx | 40 +- .../features/src/components/ui/popover.tsx | 12 +- .../features/src/components/ui/progress.tsx | 10 +- .../src/components/ui/radio-group.tsx | 14 +- .../src/components/ui/scroll-area.tsx | 22 +- .../features/src/components/ui/select.tsx | 46 +- .../features/src/components/ui/separator.tsx | 18 +- packages/features/src/components/ui/sheet.tsx | 52 +- .../features/src/components/ui/skeleton.tsx | 4 +- .../features/src/components/ui/slider.tsx | 10 +- .../features/src/components/ui/switch.tsx | 12 +- packages/features/src/components/ui/table.tsx | 44 +- packages/features/src/components/ui/tabs.tsx | 18 +- .../features/src/components/ui/textarea.tsx | 12 +- packages/features/src/components/ui/toast.tsx | 42 +- .../features/src/components/ui/toaster.tsx | 30 +- .../src/components/ui/toggle-group.tsx | 20 +- .../features/src/components/ui/toggle.tsx | 30 +- .../features/src/components/ui/tooltip.tsx | 10 +- .../features/src/components/ui/use-toast.ts | 79 +- .../features/src/components/view-heading.tsx | 12 +- .../features/src/components/wizard-layout.tsx | 16 +- packages/features/src/index.ts | 18 +- packages/features/src/lib/explorer.ts | 6 +- packages/features/src/lib/utils.ts | 4 +- .../src/lock/routes/unlock-wallet.tsx | 49 +- .../src/lock/views/unlock-wallet.stories.tsx | 14 +- .../features/src/lock/views/unlock-wallet.tsx | 40 +- .../src/not-found/routes/not-found.tsx | 6 +- .../src/not-found/views/not-found.stories.tsx | 10 +- .../src/not-found/views/not-found.tsx | 8 +- .../components/wallet-info-form.tsx | 62 +- .../src/onboarding/routes/create-wallet.tsx | 20 +- .../routes/mnemonic-confirmation.tsx | 54 +- .../src/onboarding/routes/mnemonic-input.tsx | 52 +- .../onboarding/routes/mnemonic-writedown.tsx | 12 +- .../src/onboarding/routes/restore-wallet.tsx | 18 +- .../features/src/onboarding/routes/start.tsx | 29 +- .../src/onboarding/routes/stay-connected.tsx | 6 +- .../views/create-wallet.stories.tsx | 6 +- .../src/onboarding/views/create-wallet.tsx | 4 +- .../views/mnemonic-confirmation.stories.tsx | 12 +- .../views/mnemonic-confirmation.tsx | 26 +- .../views/mnemonic-input.stories.tsx | 12 +- .../src/onboarding/views/mnemonic-input.tsx | 38 +- .../views/mnemonic-writedown.stories.tsx | 14 +- .../onboarding/views/mnemonic-writedown.tsx | 21 +- .../views/restore-wallet.stories.tsx | 6 +- .../src/onboarding/views/restore-wallet.tsx | 4 +- .../src/onboarding/views/start.stories.tsx | 10 +- .../features/src/onboarding/views/start.tsx | 10 +- .../views/stay-connected.stories.tsx | 8 +- .../src/onboarding/views/stay-connected.tsx | 24 +- .../src/overview/components/asset-list.tsx | 22 +- .../src/overview/components/avatar-menu.tsx | 14 +- .../src/overview/components/overview-card.tsx | 28 +- .../features/src/overview/routes/overview.tsx | 10 +- .../src/overview/views/overview.stories.tsx | 8 +- .../features/src/overview/views/overview.tsx | 10 +- .../features/src/receive/routes/receive.tsx | 10 +- .../src/receive/views/receive.stories.tsx | 10 +- .../features/src/receive/views/receive.tsx | 18 +- packages/features/src/router.tsx | 62 +- .../confirm-transaction-form.schema.ts | 6 +- .../components/confirm-transaction-form.tsx | 114 +- .../src/send/components/send-form.schema.ts | 4 +- .../src/send/components/send-form.tsx | 77 +- .../send/components/transaction-result.tsx | 10 +- packages/features/src/send/routes/send.tsx | 4 +- .../src/send/routes/transaction-error.tsx | 4 +- .../src/send/routes/transaction-success.tsx | 6 +- .../src/send/routes/transaction-summary.tsx | 20 +- .../features/src/send/views/send.stories.tsx | 8 +- packages/features/src/send/views/send.tsx | 6 +- .../send/views/transaction-error.stories.tsx | 8 +- .../src/send/views/transaction-error.tsx | 20 +- .../views/transaction-success.stories.tsx | 8 +- .../src/send/views/transaction-success.tsx | 20 +- .../views/transaction-summary.stories.tsx | 20 +- .../src/send/views/transaction-summary.tsx | 24 +- .../features/src/settings/routes/settings.tsx | 18 +- .../src/settings/views/settings.stories.tsx | 8 +- .../features/src/settings/views/settings.tsx | 42 +- .../components/block-producer-tile.tsx | 12 +- .../components/delegate-form.schema.ts | 4 +- .../src/staking/components/delegate-form.tsx | 65 +- .../components/epoch-progress-chart.tsx | 8 +- .../src/staking/routes/block-producers.tsx | 18 +- .../features/src/staking/routes/delegate.tsx | 4 +- .../src/staking/routes/staking-overview.tsx | 10 +- .../staking/views/block-producers.stories.tsx | 10 +- .../src/staking/views/block-producers.tsx | 11 +- .../src/staking/views/delegate.stories.tsx | 8 +- .../features/src/staking/views/delegate.tsx | 6 +- .../views/staking-overview.stories.tsx | 6 +- .../src/staking/views/staking-overview.tsx | 34 +- .../components/transactions-list.tsx | 8 +- .../transactions/components/tx-indicator.tsx | 8 +- .../src/transactions/components/tx-tile.tsx | 20 +- .../routes/transaction-details.tsx | 12 +- .../src/transactions/routes/transactions.tsx | 17 +- .../utils/structurize-transactions.ts | 24 +- .../views/transaction-details.stories.tsx | 24 +- .../views/transaction-details.tsx | 34 +- .../views/transactions.stories.tsx | 8 +- .../src/transactions/views/transactions.tsx | 18 +- packages/features/src/typings.d.ts | 2 +- packages/features/src/web-connector/index.tsx | 34 +- packages/features/src/welcome/index.tsx | 5 +- packages/features/tailwind.config.mjs | 86 +- packages/features/tsup.config.ts | 22 +- packages/features/vitest.config.ts | 6 +- .../key-management/src/InMemoryKeyAgent.ts | 48 +- packages/key-management/src/KeyAgentBase.ts | 87 +- packages/key-management/src/KeyDecryptor.ts | 34 +- .../chains/Ethereum/credentialDerivation.ts | 37 +- .../src/chains/Ethereum/guards.ts | 14 +- .../src/chains/Ethereum/index.ts | 6 +- .../src/chains/Ethereum/keyDerivation.ts | 14 +- .../src/chains/Ethereum/keyDerivationUtils.ts | 4 +- .../src/chains/Ethereum/signingOperations.ts | 32 +- .../src/chains/Ethereum/types.ts | 29 +- .../src/chains/Mina/credentialDerivation.ts | 28 +- .../key-management/src/chains/Mina/guards.ts | 28 +- .../key-management/src/chains/Mina/index.ts | 8 +- .../src/chains/Mina/keyDerivation.ts | 24 +- .../src/chains/Mina/keyDerivationUtils.ts | 4 +- .../src/chains/Mina/signingOperations.ts | 49 +- .../key-management/src/chains/Mina/types.ts | 34 +- packages/key-management/src/chains/index.ts | 4 +- packages/key-management/src/emip3.ts | 16 +- .../src/errors/AuthenticationError.ts | 40 +- .../src/errors/InvalidMnemonicError.ts | 4 +- packages/key-management/src/errors/index.ts | 6 +- packages/key-management/src/index.ts | 14 +- packages/key-management/src/types.ts | 100 +- packages/key-management/src/util/bip39.ts | 12 +- packages/key-management/src/util/index.ts | 4 +- packages/key-management/src/util/key.ts | 6 +- .../ethereum/credential-derivation.test.ts | 133 ++- .../test/ethereum/in-memory-key-agent.test.ts | 146 +-- .../test/ethereum/key-agent-base.test.ts | 168 ++- .../key-management/test/keyDecryptor.test.ts | 62 +- .../test/mina/in-memory-key-agent.test.ts | 139 +-- .../mina/key-agent-base-zkapp-command.test.ts | 142 ++- .../test/mina/key-agent-base.test.ts | 401 ++++--- .../key-management/test/util/guards.test.ts | 66 +- packages/key-management/tsup.config.ts | 10 +- packages/key-management/vitest.config.ts | 6 +- packages/mina-core/src/Mina/Block.ts | 4 +- packages/mina-core/src/Mina/Fields.ts | 2 +- packages/mina-core/src/Mina/Message.ts | 2 +- packages/mina-core/src/Mina/Networks.ts | 8 +- packages/mina-core/src/Mina/Transaction.ts | 18 +- packages/mina-core/src/Mina/ZkApp.ts | 2 +- packages/mina-core/src/Mina/index.ts | 20 +- .../src/Providers/UnifiedProvider.ts | 24 +- .../Providers/account-info-provider/index.ts | 2 +- .../Providers/account-info-provider/types.ts | 4 +- .../Providers/chain-history-provider/index.ts | 2 +- .../Providers/chain-history-provider/types.ts | 8 +- .../Providers/daemon-status-provider/index.ts | 2 +- .../Providers/daemon-status-provider/types.ts | 2 +- packages/mina-core/src/Providers/index.ts | 14 +- .../src/Providers/tx-status-provider/index.ts | 2 +- .../src/Providers/tx-status-provider/types.ts | 10 +- .../src/Providers/tx-submit-provider/index.ts | 2 +- .../src/Providers/tx-submit-provider/types.ts | 20 +- packages/mina-core/src/borrowed-types.ts | 2 +- packages/mina-core/src/index.ts | 8 +- packages/mina-core/test/Mina/todo.test.ts | 10 +- packages/mina-core/test/Provider/todo.test.ts | 10 +- packages/mina-core/tsup.config.ts | 10 +- packages/mina-core/vitest.config.ts | 6 +- packages/offchain-data/src/const.ts | 2 +- packages/offchain-data/src/index.ts | 2 +- packages/offchain-data/src/useFiatPrice.ts | 8 +- packages/offchain-data/tsup.config.ts | 10 +- .../Providers/account-info-provider/index.ts | 2 +- .../Providers/account-info-provider/types.ts | 6 +- .../Providers/chain-history-provider/index.ts | 2 +- .../Providers/chain-history-provider/types.ts | 10 +- .../Providers/daemon-status-provider/index.ts | 2 +- .../Providers/daemon-status-provider/types.ts | 2 +- .../pallad-core/src/Mina/Providers/index.ts | 14 +- .../Providers/tx-status-provider/index.ts | 2 +- .../Providers/tx-status-provider/types.ts | 10 +- .../Providers/tx-submit-provider/index.ts | 2 +- .../Providers/tx-submit-provider/types.ts | 18 +- .../Mina/Providers/unified-mina-provider.ts | 24 +- packages/pallad-core/src/Mina/index.ts | 2 +- packages/pallad-core/src/Pallad/index.ts | 6 +- .../providers/account-info-provider/index.ts | 2 +- .../providers/account-info-provider/types.ts | 8 +- .../providers/chain-history-provider/index.ts | 2 +- .../providers/chain-history-provider/types.ts | 4 +- .../pallad-core/src/Pallad/providers/index.ts | 16 +- .../providers/node-status-provider/index.ts | 2 +- .../providers/node-status-provider/types.ts | 2 +- .../providers/tx-status-provider/index.ts | 2 +- .../providers/tx-status-provider/types.ts | 10 +- .../providers/tx-submit-provider/index.ts | 2 +- .../providers/tx-submit-provider/types.ts | 18 +- .../pallad-core/src/Pallad/providers/types.ts | 14 +- .../src/Pallad/providers/unified-provider.ts | 20 +- .../src/Pallad/transactions/evm/index.ts | 2 +- .../src/Pallad/transactions/index.ts | 2 +- .../Pallad/transactions/mina/build-mina-tx.ts | 22 +- .../src/Pallad/transactions/mina/build-tx.ts | 4 +- .../src/Pallad/transactions/mina/index.ts | 4 +- .../Pallad/utils/fetch-account-properties.ts | 24 +- .../pallad-core/src/Pallad/utils/index.ts | 2 +- packages/pallad-core/src/index.ts | 2 +- .../test/Mina/custom-token-tx.test.ts | 10 +- .../pallad-core/test/Provider/todo.test.ts | 10 +- packages/pallad-core/tsup.config.ts | 10 +- packages/pallad-core/vitest.config.ts | 6 +- packages/pals/src/index.ts | 2 +- packages/pals/src/pals-provider/index.ts | 2 +- .../pals/src/pals-provider/provider/index.ts | 2 +- .../provider/pals-handle-provider.ts | 25 +- .../src/pals-provider/utils/fetch-utils.ts | 10 +- .../pals-provider/utils/health-check-utils.ts | 8 +- .../pals/src/pals-provider/utils/index.ts | 4 +- packages/pals/test/provider/mocks/handlers.ts | 24 +- .../provider/pals-handle-provider.test.ts | 26 +- packages/pals/test/provider/test-setup.ts | 4 +- packages/pals/tsup.config.ts | 16 +- packages/pals/vitest.config.ts | 6 +- packages/persistence/src/index.ts | 12 +- packages/persistence/src/mobile.ts | 12 +- packages/persistence/src/typings.ts | 3 +- packages/persistence/src/web.ts | 28 +- packages/persistence/tsup.config.ts | 10 +- .../src/blockberry-provider/index.ts | 2 +- .../blockberry-provider/stake-pools/index.ts | 2 +- .../stake-pools/stake-pools-provider.ts | 29 +- .../blockberry-provider/utils/fetch-utils.ts | 8 +- .../src/blockberry-provider/utils/index.ts | 2 +- packages/providers/src/index.ts | 12 +- .../account-info/account-info-provider.ts | 22 +- .../src/mina-explorer/account-info/index.ts | 2 +- .../src/mina-explorer/account-info/queries.ts | 11 +- .../block-listener/BlockListenerProvider.ts | 52 +- .../src/mina-explorer/block-listener/index.ts | 2 +- .../chain-history/chain-history-provider.ts | 22 +- .../src/mina-explorer/chain-history/index.ts | 2 +- packages/providers/src/mina-explorer/index.ts | 10 +- .../src/mina-explorer/node-status/index.ts | 2 +- .../node-status/node-status-provider.ts | 10 +- .../src/mina-explorer/tx-submit/index.ts | 2 +- .../src/mina-explorer/tx-submit/mutations.ts | 10 +- .../tx-submit/tx-submit-provider.ts | 20 +- packages/providers/src/mina-explorer/types.ts | 10 +- .../src/mina-explorer/utils/custom-fetch.ts | 10 +- .../src/mina-explorer/utils/error-policy.ts | 2 +- .../src/mina-explorer/utils/errors.ts | 8 +- .../src/mina-explorer/utils/fetch-utils.ts | 20 +- .../mina-explorer/utils/health-check-utils.ts | 16 +- .../src/mina-explorer/utils/index.ts | 8 +- .../mina-explorer/utils/json-serializer.ts | 2 +- .../account-info/account-info-provider.ts | 22 +- .../src/mina-node/account-info/index.ts | 2 +- .../src/mina-node/account-info/queries.ts | 11 +- .../block-listener/BlockListenerProvider.ts | 52 +- .../src/mina-node/block-listener/index.ts | 2 +- .../chain-history/chain-history-provider.ts | 26 +- .../src/mina-node/chain-history/index.ts | 2 +- packages/providers/src/mina-node/index.ts | 10 +- .../src/mina-node/node-status/index.ts | 2 +- .../node-status/node-status-provider.ts | 10 +- .../src/mina-node/tx-submit/index.ts | 2 +- .../src/mina-node/tx-submit/mutations.ts | 10 +- .../mina-node/tx-submit/tx-submit-provider.ts | 20 +- packages/providers/src/mina-node/types.ts | 10 +- .../src/mina-node/utils/custom-fetch.ts | 10 +- .../src/mina-node/utils/error-policy.ts | 2 +- .../providers/src/mina-node/utils/errors.ts | 8 +- .../src/mina-node/utils/fetch-utils.ts | 20 +- .../src/mina-node/utils/health-check-utils.ts | 18 +- .../providers/src/mina-node/utils/index.ts | 8 +- .../src/mina-node/utils/json-serializer.ts | 2 +- .../account-info/account-info-provider.ts | 22 +- .../obscura-provider/account-info/index.ts | 2 +- .../obscura-provider/account-info/queries.ts | 13 +- .../chain-history/chain-history-provider.ts | 20 +- .../obscura-provider/chain-history/index.ts | 2 +- .../providers/src/obscura-provider/index.ts | 10 +- .../src/obscura-provider/node-status/index.ts | 2 +- .../node-status/node-status-provider.ts | 10 +- .../src/obscura-provider/tx-status/index.ts | 2 +- .../tx-status/tx-status-provider.ts | 16 +- .../src/obscura-provider/tx-submit/index.ts | 2 +- .../obscura-provider/tx-submit/mutations.ts | 10 +- .../tx-submit/tx-submit-provider.ts | 20 +- .../src/obscura-provider/utils/fetch-utils.ts | 12 +- .../utils/health-check-utils.ts | 12 +- .../src/obscura-provider/utils/index.ts | 4 +- packages/providers/src/open-mina/index.ts | 4 +- .../providers/src/open-mina/start-node.ts | 12 +- .../providers/src/open-mina/stats/index.ts | 2 +- .../src/open-mina/stats/sync-provider.ts | 4 +- .../account-info/account-info-provider.ts | 42 +- .../src/optimism/account-info/index.ts | 2 +- .../chain-history/chain-history-provider.ts | 22 +- .../src/optimism/chain-history/index.ts | 2 +- packages/providers/src/optimism/index.ts | 8 +- .../src/optimism/node-status/index.ts | 2 +- .../node-status/node-status-provider.ts | 14 +- .../src/optimism/utils/health-check-utils.ts | 14 +- .../providers/src/optimism/utils/index.ts | 2 +- .../account-info-provider.ts | 24 +- .../chain-history-provider.ts | 26 +- .../providers/src/unified-providers/index.ts | 12 +- .../unified-providers/node-status-provider.ts | 22 +- .../unified-providers/tx-submit-provider.ts | 18 +- .../providers/src/unified-providers/types.ts | 6 +- .../src/unified-providers/unified-provider.ts | 32 +- .../blockberry/stake-pools-provider.test.ts | 18 +- .../account-info-provider.test.ts | 24 +- .../chain-history-provider.test.ts | 44 +- .../submit-tx-provider.test.ts | 102 +- .../account-info-provider.test.ts | 24 +- .../chain-history-provider.test.ts | 44 +- .../node-status-provider.test.ts | 16 +- .../submit-tx-provider.test.ts | 102 +- .../account-info-provider.test.ts | 24 +- .../submit-tx-provider.test.ts | 106 +- .../individual-providers/util.ts | 34 +- .../account-info-provider.test.ts | 28 +- .../chain-history-provider.test.ts | 46 +- .../submit-tx-provider.test.ts | 104 +- .../tx-status-provider.test.ts | 22 +- .../test/open-mina/sync-provider.test.ts | 12 +- .../account-info-provider.test.ts | 27 +- .../chain-history-provider.test.ts | 37 +- .../account-info-provider.test.ts | 62 +- .../chain-history-provider.test.ts | 58 +- .../submit-tx-provider.test.ts | 112 +- .../universal-provider.test.ts | 80 +- packages/providers/tsup.config.ts | 16 +- packages/providers/vitest.config.ts | 6 +- packages/util/src/Range.ts | 25 +- packages/util/src/index.ts | 6 +- packages/util/test/Range.test.ts | 60 +- packages/util/tsup.config.ts | 10 +- packages/util/vitest.config.ts | 6 +- packages/vault/src/account/accountState.ts | 16 +- packages/vault/src/account/accountStore.ts | 40 +- packages/vault/src/account/index.ts | 4 +- .../vault/src/credentials/credentialsState.ts | 16 +- .../vault/src/credentials/credentialsStore.ts | 30 +- packages/vault/src/credentials/index.ts | 4 +- packages/vault/src/index.ts | 16 +- packages/vault/src/keyAgent/index.ts | 4 +- packages/vault/src/keyAgent/keyAgentState.ts | 24 +- packages/vault/src/keyAgent/keyAgentStore.ts | 30 +- packages/vault/src/lib/Errors/errors.ts | 6 +- packages/vault/src/lib/Errors/index.ts | 2 +- packages/vault/src/lib/utils.ts | 18 +- packages/vault/src/network-info/default.ts | 50 +- packages/vault/src/network-info/index.ts | 6 +- .../src/network-info/network-info-state.ts | 4 +- .../src/network-info/network-info-store.ts | 28 +- packages/vault/src/objects/default.ts | 38 +- packages/vault/src/objects/index.ts | 6 +- packages/vault/src/objects/objectsState.ts | 8 +- packages/vault/src/objects/objectsStore.ts | 29 +- packages/vault/src/provable-programs/index.ts | 2 +- .../provable-program-state.ts | 4 +- packages/vault/src/token-info/default.ts | 6 +- packages/vault/src/token-info/index.ts | 6 +- .../vault/src/token-info/token-info-store.ts | 18 +- packages/vault/src/types.ts | 5 +- .../vault/src/utils/current-wallet-utils.ts | 6 +- packages/vault/src/utils/index.ts | 4 +- packages/vault/src/utils/utils.ts | 4 +- packages/vault/src/vault/index.ts | 2 +- packages/vault/src/vault/utils/get-balance.ts | 8 +- .../src/vault/utils/get-current-wallet.ts | 16 +- .../vault/utils/get-wallet-account-info.ts | 12 +- .../vault/utils/get-wallet-transactions.ts | 14 +- packages/vault/src/vault/utils/index.ts | 24 +- .../vault/src/vault/utils/restart-wallet.ts | 6 +- .../vault/src/vault/utils/restore-wallet.ts | 44 +- packages/vault/src/vault/utils/sign.ts | 16 +- packages/vault/src/vault/utils/submit-tx.ts | 8 +- .../vault/src/vault/utils/switch-network.ts | 8 +- .../src/vault/utils/sync-account-info.ts | 8 +- .../src/vault/utils/sync-transactions.ts | 10 +- packages/vault/src/vault/utils/sync-wallet.ts | 20 +- packages/vault/src/vault/vaultState.ts | 38 +- packages/vault/src/vault/vaultStore.ts | 68 +- packages/vault/src/web-provider/index.ts | 4 +- .../src/web-provider/web-provider-state.ts | 6 +- .../src/web-provider/web-provider-store.ts | 18 +- .../vault/test/account/accountStore.test.ts | 92 +- .../test/credentials/credentialsStore.test.ts | 110 +- .../vault/test/keyAgent/keyAgentStore.test.ts | 134 +-- .../network-info/network-info-store.test.ts | 86 +- .../vault/test/objects/objectsStore.test.ts | 88 +- packages/vault/test/wallet/walletFlow.test.ts | 92 +- packages/vault/tsup.config.ts | 10 +- packages/vault/vitest.config.ts | 8 +- packages/web-provider/src/index.ts | 8 +- .../src/mina-network/constants/index.ts | 2 +- .../src/mina-network/constants/rpc.ts | 32 +- .../web-provider/src/mina-network/index.ts | 6 +- .../src/mina-network/mina-provider.ts | 289 ++--- .../web-provider/src/mina-network/types.ts | 42 +- .../web-provider/src/mina-network/utils.ts | 16 +- .../src/universal-provider/index.ts | 2 +- .../src/universal-provider/types.ts | 4 +- .../web-provider/src/utils/chain-mappings.ts | 12 +- packages/web-provider/src/utils/guards.ts | 8 +- packages/web-provider/src/utils/index.ts | 6 +- packages/web-provider/src/utils/prompts.ts | 26 +- .../web-provider/src/vault-service/index.ts | 2 +- .../web-provider/src/vault-service/types.ts | 12 +- .../src/vault-service/vault-service.ts | 74 +- .../src/web-provider-types/data-model.ts | 38 +- .../src/web-provider-types/index.ts | 2 +- .../test/mina/mina-provider.test.ts | 214 ++-- packages/web-provider/tsup.config.ts | 10 +- packages/web-provider/vitest.config.ts | 6 +- pnpm-lock.yaml | 1061 ++--------------- turbo.json | 14 +- vitest.config.ts | 4 +- 532 files changed, 5947 insertions(+), 6768 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json delete mode 100644 .prettierrc create mode 100644 biome.json delete mode 100644 packages/features/.ladle/utils.ts diff --git a/.all-contributorsrc b/.all-contributorsrc index 80fd7e50..788cb5a6 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,7 +1,5 @@ { - "files": [ - "README.md" - ], + "files": ["README.md"], "imageSize": 100, "commit": false, "commitType": "docs", @@ -12,36 +10,28 @@ "name": "Tomek Marciniak", "avatar_url": "https://avatars.githubusercontent.com/u/16132011?v=4", "profile": "https://github.com/mrcnk", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "teddyjfpender", "name": "Teddy Pender", "avatar_url": "https://avatars.githubusercontent.com/u/92999717?v=4", "profile": "https://github.com/teddyjfpender", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "rago4", "name": "Rafał Goławski", "avatar_url": "https://avatars.githubusercontent.com/u/19167236?v=4", "profile": "https://dev.to/rgolawski", - "contributions": [ - "code" - ] + "contributions": ["code"] }, { "login": "mich3lang3lo", "name": "Mariusz", "avatar_url": "https://avatars.githubusercontent.com/u/164676295?v=4", "profile": "https://github.com/mich3lang3lo", - "contributions": [ - "code" - ] + "contributions": ["code"] } ], "contributorsPerLine": 7, diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 96a43f13..00000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules -dist -.turbo -build -test-results -playwright-report -coverage diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 28bbfa1b..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": [ - "plugin:prettier/recommended", - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "simple-import-sort", "import"], - "root": true, - "rules": { - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/no-explicit-any": "warn", - "@typescript-eslint/no-inferrable-types": "error", - "import/no-extraneous-dependencies": "error", - "require-await": "error" - } -} diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index f2c8a73b..00000000 --- a/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "semi": false, - "trailingComma": "none", - "singleQuote": true, - "printWidth": 80, - "tabWidth": 2 -} diff --git a/apps/extension/e2e/address-book.spec.ts b/apps/extension/e2e/address-book.spec.ts index 6371061e..27b0c466 100644 --- a/apps/extension/e2e/address-book.spec.ts +++ b/apps/extension/e2e/address-book.spec.ts @@ -1,25 +1,25 @@ -import { expect, test } from './extension' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { OnboardingPom } from "./pom/onboarding" -const PUBLIC_KEY = 'B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS' +const PUBLIC_KEY = "B62qkYa1o6Mj6uTTjDQCob7FYZspuhkm4RRQhgJg9j4koEBWiSrTQrS" -test('creates and deletes contact', async ({ page, extensionId }) => { +test("creates and deletes contact", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() - await page.getByTestId('bottomNavigation__addressBook').click() - await page.getByTestId('addressBook__addAddressButton').click() - await page.getByTestId('newAddress__nameInput').fill('New Contact') - await page.getByTestId('newAddress__addressInput').fill(PUBLIC_KEY) - await page.getByTestId('newAddress__createButton').click() - await page.getByTestId('bottomNavigation__addressBook').click() + await page.getByTestId("bottomNavigation__addressBook").click() + await page.getByTestId("addressBook__addAddressButton").click() + await page.getByTestId("newAddress__nameInput").fill("New Contact") + await page.getByTestId("newAddress__addressInput").fill(PUBLIC_KEY) + await page.getByTestId("newAddress__createButton").click() + await page.getByTestId("bottomNavigation__addressBook").click() const contactsAfterCreation = await page - .getByTestId('addressBook__contact') + .getByTestId("addressBook__contact") .all() // 2 including donate Pallad option. expect(contactsAfterCreation.length).toEqual(2) - await page.getByTestId('addressBook__removeAddress').click() + await page.getByTestId("addressBook__removeAddress").click() const contactsAfterDeletion = await page - .getByTestId('addressBook__contact') + .getByTestId("addressBook__contact") .all() // Just donate Pallad. expect(contactsAfterDeletion.length).toEqual(1) diff --git a/apps/extension/e2e/create-wallet.spec.ts b/apps/extension/e2e/create-wallet.spec.ts index 5c29f87f..0c6b3059 100644 --- a/apps/extension/e2e/create-wallet.spec.ts +++ b/apps/extension/e2e/create-wallet.spec.ts @@ -1,8 +1,8 @@ -import { expect, test } from './extension' -import { devnetWallet } from './fixtures' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { devnetWallet } from "./fixtures" +import { OnboardingPom } from "./pom/onboarding" -test('create new wallet', async ({ page, extensionId }) => { +test("create new wallet", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.goto() await onboardingPom.startCreating() @@ -17,22 +17,22 @@ test('create new wallet', async ({ page, extensionId }) => { const confirmationIndex = await onboardingPom.getMnemonicConfirmationIndex() await onboardingPom.fillMnemonicConfirmation(mnemonicWords[confirmationIndex]) await onboardingPom.goNext() - const pageTitle = page.getByText('Stay Connected') + const pageTitle = page.getByText("Stay Connected") await pageTitle.waitFor() await onboardingPom.goNext() - expect(await onboardingPom.getMinaBalance()).toContain('MINA') + expect(await onboardingPom.getMinaBalance()).toContain("MINA") }) -test('validates create wallet data', async ({ page, extensionId }) => { +test("validates create wallet data", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.goto() await onboardingPom.startCreating() await onboardingPom.assertNextDisabled() await onboardingPom.fillWalletName(devnetWallet.walletName) - await onboardingPom.fillSpendingPassword('ASD') + await onboardingPom.fillSpendingPassword("ASD") await onboardingPom.toggleTos() await onboardingPom.goNext() - const errors = await page.getByTestId('form__error').all() + const errors = await page.getByTestId("form__error").all() expect(errors.length).toEqual(1) await onboardingPom.fillSpendingPassword(devnetWallet.spendingPassword) await onboardingPom.goNext() @@ -40,6 +40,6 @@ test('validates create wallet data', async ({ page, extensionId }) => { await onboardingPom.assertNextDisabled() await onboardingPom.toggleMnemonicWritten() await onboardingPom.goNext() - await onboardingPom.fillMnemonicConfirmation('boots') + await onboardingPom.fillMnemonicConfirmation("boots") await onboardingPom.assertNextDisabled() }) diff --git a/apps/extension/e2e/extension.ts b/apps/extension/e2e/extension.ts index 0ce0bffc..818b75c4 100644 --- a/apps/extension/e2e/extension.ts +++ b/apps/extension/e2e/extension.ts @@ -1,6 +1,6 @@ -import { type BrowserContext, chromium, test as base } from '@playwright/test' -import path from 'path' -import { fileURLToPath } from 'url' +import path from "node:path" +import { fileURLToPath } from "node:url" +import { type BrowserContext, test as base, chromium } from "@playwright/test" const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) @@ -8,25 +8,25 @@ export const test = base.extend<{ context: BrowserContext extensionId: string }>({ - /* eslint-disable */ + // biome-ignore lint: won't fix context: async ({}, use) => { - const pathToExtension = path.join(__dirname, '../dist') - const context = await chromium.launchPersistentContext('', { + const pathToExtension = path.join(__dirname, "../dist") + const context = await chromium.launchPersistentContext("", { headless: false, args: [ `--disable-extensions-except=${pathToExtension}`, - `--load-extension=${pathToExtension}` - ] + `--load-extension=${pathToExtension}`, + ], }) await use(context) await context.close() }, extensionId: async ({ context }, use) => { let [background] = context.serviceWorkers() - if (!background) background = await context.waitForEvent('serviceworker') + if (!background) background = await context.waitForEvent("serviceworker") - const extensionId = background.url().split('/')[2] + const extensionId = background.url().split("/")[2] await use(extensionId) - } + }, }) export const expect = test.expect diff --git a/apps/extension/e2e/fixtures.ts b/apps/extension/e2e/fixtures.ts index 72ae0092..fa784220 100644 --- a/apps/extension/e2e/fixtures.ts +++ b/apps/extension/e2e/fixtures.ts @@ -1,19 +1,19 @@ export const devnetWallet = { - walletName: 'Devnet Wallet', - spendingPassword: 'SuperSecure777', + walletName: "Devnet Wallet", + spendingPassword: "SuperSecure777", mnemonic: [ - 'habit', - 'hope', - 'tip', - 'crystal', - 'because', - 'grunt', - 'nation', - 'idea', - 'electric', - 'witness', - 'alert', - 'like' + "habit", + "hope", + "tip", + "crystal", + "because", + "grunt", + "nation", + "idea", + "electric", + "witness", + "alert", + "like", ], - addressTruncated: 'B62qjsV6...ZEumXzxb' + addressTruncated: "B62qjsV6...ZEumXzxb", } diff --git a/apps/extension/e2e/pom/base.ts b/apps/extension/e2e/pom/base.ts index e4e44181..73654ec8 100644 --- a/apps/extension/e2e/pom/base.ts +++ b/apps/extension/e2e/pom/base.ts @@ -1,5 +1,5 @@ // https://playwright.dev/docs/pom -import { Page } from '@playwright/test' +import type { Page } from "@playwright/test" export class BasePom { readonly page: Page diff --git a/apps/extension/e2e/pom/onboarding.ts b/apps/extension/e2e/pom/onboarding.ts index 44403d2e..6a990266 100644 --- a/apps/extension/e2e/pom/onboarding.ts +++ b/apps/extension/e2e/pom/onboarding.ts @@ -1,23 +1,23 @@ -import { expect } from '../extension' -import { devnetWallet } from '../fixtures' -import { BasePom } from './base' +import { expect } from "../extension" +import { devnetWallet } from "../fixtures" +import { BasePom } from "./base" const TestId = { - RESTORE_WALLET_BUTTON: 'onboarding__restoreWalletButton', - CREATE_WALLET_BUTTON: 'onboarding__createWalletButton', - WALLET_NAME_INPUT: 'onboarding__walletNameInput', - SPENDING_PASSWORD_INPUT: 'onboarding__spendingPasswordInput', - TOS_CHECKBOX: 'onboarding__tosCheckbox', - NEXT_BUTTON: 'onboarding__nextButton', - BACK_BUTTON: 'onboarding__backButton', - CONFIRM_ALONE: 'onboarding__confirmAlone', - MNEMONIC_FIELD: 'onboarding__mnemonicField', - ADDRESS_TRUNCATED: 'dashboard__addressTruncated', - MINA_BALANCE: 'dashboard__minaBalance', - MNEMONIC_WORD: 'onboarding__mnemonicWord', - MNEMONIC_WRITTEN_CHECKBOX: 'onboarding__mnemonicWrittenCheckbox', - MNEMONIC_WRITEDOWN_INDEX: 'onboarding__writedownIndex', - MNEMONIC_CONFIRMATION_INPUT: 'onboarding__mnemonicConfirmationInput' + RESTORE_WALLET_BUTTON: "onboarding__restoreWalletButton", + CREATE_WALLET_BUTTON: "onboarding__createWalletButton", + WALLET_NAME_INPUT: "onboarding__walletNameInput", + SPENDING_PASSWORD_INPUT: "onboarding__spendingPasswordInput", + TOS_CHECKBOX: "onboarding__tosCheckbox", + NEXT_BUTTON: "onboarding__nextButton", + BACK_BUTTON: "onboarding__backButton", + CONFIRM_ALONE: "onboarding__confirmAlone", + MNEMONIC_FIELD: "onboarding__mnemonicField", + ADDRESS_TRUNCATED: "dashboard__addressTruncated", + MINA_BALANCE: "dashboard__minaBalance", + MNEMONIC_WORD: "onboarding__mnemonicWord", + MNEMONIC_WRITTEN_CHECKBOX: "onboarding__mnemonicWrittenCheckbox", + MNEMONIC_WRITEDOWN_INDEX: "onboarding__writedownIndex", + MNEMONIC_CONFIRMATION_INPUT: "onboarding__mnemonicConfirmationInput", } as const export class OnboardingPom extends BasePom { @@ -26,13 +26,13 @@ export class OnboardingPom extends BasePom { } startRestoring() { const restoreWalletButton = this.page.getByTestId( - TestId.RESTORE_WALLET_BUTTON + TestId.RESTORE_WALLET_BUTTON, ) return restoreWalletButton.click() } startCreating() { const createWalletButton = this.page.getByTestId( - TestId.CREATE_WALLET_BUTTON + TestId.CREATE_WALLET_BUTTON, ) return createWalletButton.click() } @@ -42,7 +42,7 @@ export class OnboardingPom extends BasePom { } fillSpendingPassword(spendingPassword: string) { const spendingPasswordInput = this.page.getByTestId( - TestId.SPENDING_PASSWORD_INPUT + TestId.SPENDING_PASSWORD_INPUT, ) return spendingPasswordInput.fill(spendingPassword) } @@ -84,7 +84,7 @@ export class OnboardingPom extends BasePom { } toggleMnemonicWritten() { const mnemonicWritten = this.page.getByTestId( - TestId.MNEMONIC_WRITTEN_CHECKBOX + TestId.MNEMONIC_WRITTEN_CHECKBOX, ) return mnemonicWritten.click() } @@ -92,12 +92,12 @@ export class OnboardingPom extends BasePom { const inputLabel = await this.page .getByTestId(TestId.MNEMONIC_WRITEDOWN_INDEX) .innerText() - const [, confirmationIndex] = inputLabel.split('#') - return parseInt(confirmationIndex) - 1 + const [, confirmationIndex] = inputLabel.split("#") + return Number.parseInt(confirmationIndex) - 1 } fillMnemonicConfirmation(specificWord: string) { const mnemonicConfirmationInput = this.page.getByTestId( - TestId.MNEMONIC_CONFIRMATION_INPUT + TestId.MNEMONIC_CONFIRMATION_INPUT, ) return mnemonicConfirmationInput.fill(specificWord) } @@ -116,7 +116,7 @@ export class OnboardingPom extends BasePom { await this.confirmAlone() await this.fillMnemonic(devnetWallet.mnemonic) await this.goNext() - const pageTitle = this.page.getByText('Stay Connected') + const pageTitle = this.page.getByText("Stay Connected") await pageTitle.waitFor() await this.goNext() } diff --git a/apps/extension/e2e/provider-enable.spec.ts b/apps/extension/e2e/provider-enable.spec.ts index 39fdc64f..edf57a4f 100644 --- a/apps/extension/e2e/provider-enable.spec.ts +++ b/apps/extension/e2e/provider-enable.spec.ts @@ -1,19 +1,19 @@ -import { expect, test } from './extension' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { OnboardingPom } from "./pom/onboarding" -const VALIDATOR = 'B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb' +const VALIDATOR = "B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb" // Note: These tests are manual -test('enable window.mina and handle pop-up on a specific webpage', async ({ +test("enable window.mina and handle pop-up on a specific webpage", async ({ page, - extensionId + extensionId, }) => { // Restore the wallet or perform any setup required by your extension before interacting with the webpage. const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() // Navigate to the webpage where the injected script should be interacted with. - await page.goto('https://google.com') + await page.goto("https://google.com") // Verify that window.mina is available const minaExists = await page.evaluate(() => window.mina !== undefined) @@ -28,96 +28,96 @@ test('enable window.mina and handle pop-up on a specific webpage', async ({ //expect(enableResponse.result[0]).toBe(VALIDATOR) const account = await page.evaluate(() => - window.mina.request({ method: 'mina_accounts' }) + window.mina.request({ method: "mina_accounts" }), ) expect(account.result.length).toBe(1) expect(account.result[0]).toBe(VALIDATOR) const responseChainId = await page.evaluate(() => - window.mina.request({ method: 'mina_chainId' }) + window.mina.request({ method: "mina_chainId" }), ) - expect(responseChainId.result).not.toBe('...') + expect(responseChainId.result).not.toBe("...") const responseBalance = await page.evaluate(() => - window.mina.request({ method: 'mina_getBalance' }) + window.mina.request({ method: "mina_getBalance" }), ) expect(responseBalance.result).not.toBe(undefined) const responseRequestNetwork = await page.evaluate(() => - window.mina.request({ method: 'mina_requestNetwork' }) + window.mina.request({ method: "mina_requestNetwork" }), ) - console.log('responseRequestNetwork:', responseRequestNetwork) + console.log("responseRequestNetwork:", responseRequestNetwork) expect(responseRequestNetwork.result.chainId).not.toBe(undefined) const responseAddChain = await page.evaluate(() => window.mina.request({ - method: 'mina_addChain', + method: "mina_addChain", params: { nodeEndpoint: { - providerName: 'mina-node', - url: 'https://sequencer-zeko-dev.dcspark.io/graphql' + providerName: "mina-node", + url: "https://sequencer-zeko-dev.dcspark.io/graphql", }, archiveNodeEndpoint: { - providerName: 'mina-node', - url: '' + providerName: "mina-node", + url: "", }, - networkName: 'ZekoDevNet', - networkType: 'testnet', - chainId: '69420' - } - }) + networkName: "ZekoDevNet", + networkType: "testnet", + chainId: "69420", + }, + }), ) - console.log('responseAddChain:', responseAddChain) - expect(responseAddChain.result.networkName).toBe('ZekoDevNet') + console.log("responseAddChain:", responseAddChain) + expect(responseAddChain.result.networkName).toBe("ZekoDevNet") const responseSwitchChain = await page.evaluate(() => window.mina.request({ - method: 'mina_switchChain', + method: "mina_switchChain", params: { - chainId: '69420' - } - }) + chainId: "69420", + }, + }), ) - console.log('responseSwitchChain:', responseSwitchChain) - expect(responseSwitchChain.result.networkName).toBe('ZekoDevNet') + console.log("responseSwitchChain:", responseSwitchChain) + expect(responseSwitchChain.result.networkName).toBe("ZekoDevNet") const responseBalanceZeko = await page.evaluate(() => - window.mina.request({ method: 'mina_getBalance' }) + window.mina.request({ method: "mina_getBalance" }), ) - console.log('responseBalanceZeko:', responseBalanceZeko) + console.log("responseBalanceZeko:", responseBalanceZeko) expect(responseBalanceZeko.result).not.toBe(0) await page.evaluate(() => window.mina.request({ - method: 'mina_setState', + method: "mina_setState", params: { - objectName: 'New Example Credential', + objectName: "New Example Credential", object: { - '@context': ['https://www.w3.org/2018/credentials/v1'], - id: 'http://example.edu/credentials/3732', - type: ['VerifiableCredential', 'UniversityDegreeCredential'], - issuer: 'University of Example', - issuanceDate: '2010-01-01T00:00:00Z', + "@context": ["https://www.w3.org/2018/credentials/v1"], + id: "http://example.edu/credentials/3732", + type: ["VerifiableCredential", "UniversityDegreeCredential"], + issuer: "University of Example", + issuanceDate: "2010-01-01T00:00:00Z", credentialSubject: { - id: 'did:mina:B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb', + id: "did:mina:B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb", degree: { - type: 'BachelorDegree', - name: 'Bachelor of Science and Arts' - } + type: "BachelorDegree", + name: "Bachelor of Science and Arts", + }, }, proof: { - type: 'Kimchi', - created: '2023-09-19T12:40:16Z', + type: "Kimchi", + created: "2023-09-19T12:40:16Z", proof: { - publicInput: ['0'], - publicOutput: ['1'], + publicInput: ["0"], + publicOutput: ["1"], maxProofsVerified: 0, - proof: 'KChzdGF0ZW1...SkpKSkp' - } - } - } - } - }) + proof: "KChzdGF0ZW1...SkpKSkp", + }, + }, + }, + }, + }), ) /** Enter password manually @@ -125,9 +125,9 @@ test('enable window.mina and handle pop-up on a specific webpage', async ({ const responseGetState = await page.evaluate(() => window.mina.request({ - method: 'mina_getState', - params: { query: { issuer: 'University of Example' }, props: [] } - }) + method: "mina_getState", + params: { query: { issuer: "University of Example" }, props: [] }, + }), ) /** Enter password manually diff --git a/apps/extension/e2e/restore-wallet.spec.ts b/apps/extension/e2e/restore-wallet.spec.ts index beed4cba..1d9a7360 100644 --- a/apps/extension/e2e/restore-wallet.spec.ts +++ b/apps/extension/e2e/restore-wallet.spec.ts @@ -1,25 +1,25 @@ -import { expect, test } from './extension' -import { devnetWallet } from './fixtures' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { devnetWallet } from "./fixtures" +import { OnboardingPom } from "./pom/onboarding" -test('restores existing wallet', async ({ page, extensionId }) => { +test("restores existing wallet", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() expect(await onboardingPom.getAddressTruncated()).toEqual( - devnetWallet.addressTruncated + devnetWallet.addressTruncated, ) }) -test('validates restore wallet data', async ({ page, extensionId }) => { +test("validates restore wallet data", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.goto() await onboardingPom.startRestoring() await onboardingPom.assertNextDisabled() await onboardingPom.fillWalletName(devnetWallet.walletName) // Password has to be at least 4 characters long - await onboardingPom.fillSpendingPassword('ASD') + await onboardingPom.fillSpendingPassword("ASD") await onboardingPom.toggleTos() await onboardingPom.goNext() - const errors = await page.getByTestId('form__error').all() + const errors = await page.getByTestId("form__error").all() expect(errors.length).toEqual(1) }) diff --git a/apps/extension/e2e/settings.spec.ts b/apps/extension/e2e/settings.spec.ts index d88c7844..1e9bed4b 100644 --- a/apps/extension/e2e/settings.spec.ts +++ b/apps/extension/e2e/settings.spec.ts @@ -1,11 +1,11 @@ -import { test } from './extension' -import { OnboardingPom } from './pom/onboarding' +import { test } from "./extension" +import { OnboardingPom } from "./pom/onboarding" -test('restart wallet', async ({ page, extensionId }) => { +test("restart wallet", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() - await page.getByTestId('bottomNavigation__menu').click() - await page.getByTestId('commandMenu__settings').click() - await page.getByTestId('settings__restartWallet').click() - await page.getByTestId('restartWallet__confirm').click() + await page.getByTestId("bottomNavigation__menu").click() + await page.getByTestId("commandMenu__settings").click() + await page.getByTestId("settings__restartWallet").click() + await page.getByTestId("restartWallet__confirm").click() }) diff --git a/apps/extension/e2e/staking.spec.ts b/apps/extension/e2e/staking.spec.ts index 1722323d..26460df7 100644 --- a/apps/extension/e2e/staking.spec.ts +++ b/apps/extension/e2e/staking.spec.ts @@ -1,22 +1,22 @@ -import { expect, test } from './extension' -import { devnetWallet } from './fixtures' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { devnetWallet } from "./fixtures" +import { OnboardingPom } from "./pom/onboarding" -const VALIDATOR = 'B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb' +const VALIDATOR = "B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb" -test('delegate to self', async ({ page, extensionId }) => { +test("delegate to self", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() - await page.getByTestId('bottomNavigation__menu').click() - await page.getByTestId('commandMenu__delegate').click() - await page.getByTestId('delegate__to').fill(VALIDATOR) - await page.getByTestId('delegate__nextButton').click() + await page.getByTestId("bottomNavigation__menu").click() + await page.getByTestId("commandMenu__delegate").click() + await page.getByTestId("delegate__to").fill(VALIDATOR) + await page.getByTestId("delegate__nextButton").click() await page - .getByTestId('confirm__spendingPassword') + .getByTestId("confirm__spendingPassword") .fill(devnetWallet.spendingPassword) - await page.getByTestId('confirm__nextButton').click() - await page.getByTestId('transactionResult__nextButton').click() + await page.getByTestId("confirm__nextButton").click() + await page.getByTestId("transactionResult__nextButton").click() await expect( - page.getByTestId('transactions__pendingTransactions').first() + page.getByTestId("transactions__pendingTransactions").first(), ).toBeVisible() }) diff --git a/apps/extension/e2e/transaction.spec.ts b/apps/extension/e2e/transaction.spec.ts index 0a73e552..fec06df8 100644 --- a/apps/extension/e2e/transaction.spec.ts +++ b/apps/extension/e2e/transaction.spec.ts @@ -1,23 +1,23 @@ -import { expect, test } from './extension' -import { devnetWallet } from './fixtures' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { devnetWallet } from "./fixtures" +import { OnboardingPom } from "./pom/onboarding" -const RECEIVER = 'B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb' +const RECEIVER = "B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb" -test('sends a berkeley transaction', async ({ page, extensionId }) => { +test("sends a berkeley transaction", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() - await page.getByTestId('bottomNavigation__menu').click() - await page.getByTestId('commandMenu__send').click() - await page.getByTestId('send__to').fill(RECEIVER) - await page.getByTestId('send__amount').fill('1') - await page.getByTestId('send__nextButton').click() + await page.getByTestId("bottomNavigation__menu").click() + await page.getByTestId("commandMenu__send").click() + await page.getByTestId("send__to").fill(RECEIVER) + await page.getByTestId("send__amount").fill("1") + await page.getByTestId("send__nextButton").click() await page - .getByTestId('confirm__spendingPassword') + .getByTestId("confirm__spendingPassword") .fill(devnetWallet.spendingPassword) - await page.getByTestId('confirm__nextButton').click() - await page.getByTestId('transactionResult__nextButton').click() + await page.getByTestId("confirm__nextButton").click() + await page.getByTestId("transactionResult__nextButton").click() await expect( - page.getByTestId('transactions__pendingTransactions').first() + page.getByTestId("transactions__pendingTransactions").first(), ).toBeVisible() }) diff --git a/apps/extension/e2e/unlock-wallet.spec.ts b/apps/extension/e2e/unlock-wallet.spec.ts index 68e8b03d..3fcc9c04 100644 --- a/apps/extension/e2e/unlock-wallet.spec.ts +++ b/apps/extension/e2e/unlock-wallet.spec.ts @@ -1,18 +1,18 @@ -import { expect, test } from './extension' -import { devnetWallet } from './fixtures' -import { OnboardingPom } from './pom/onboarding' +import { expect, test } from "./extension" +import { devnetWallet } from "./fixtures" +import { OnboardingPom } from "./pom/onboarding" -test('locks and unlocks existing wallet', async ({ page, extensionId }) => { +test("locks and unlocks existing wallet", async ({ page, extensionId }) => { const onboardingPom = new OnboardingPom({ page, extensionId }) await onboardingPom.restoreTestWallet() - await page.getByTestId('bottomNavigation__menu').click() - await page.getByTestId('commandMenu__lockWallet').click() - await page.getByTestId('unlockWallet__password').fill('Wrong Password') - const unlockWalletButton = page.getByTestId('unlockWallet__unlockButton') + await page.getByTestId("bottomNavigation__menu").click() + await page.getByTestId("commandMenu__lockWallet").click() + await page.getByTestId("unlockWallet__password").fill("Wrong Password") + const unlockWalletButton = page.getByTestId("unlockWallet__unlockButton") expect(unlockWalletButton.isDisabled).toBeTruthy() await page - .getByTestId('unlockWallet__password') + .getByTestId("unlockWallet__password") .fill(devnetWallet.spendingPassword) await unlockWalletButton.click() - expect(await onboardingPom.getMinaBalance()).toContain('MINA') + expect(await onboardingPom.getMinaBalance()).toContain("MINA") }) diff --git a/apps/extension/manifest.config.ts b/apps/extension/manifest.config.ts index b441c5f2..d6fe5b6c 100644 --- a/apps/extension/manifest.config.ts +++ b/apps/extension/manifest.config.ts @@ -1,69 +1,69 @@ -import packageJson from './package.json' +import packageJson from "./package.json" const { version } = packageJson -import { createRequire } from 'node:module' +import { createRequire } from "node:module" const require = createRequire(import.meta.url) -const { defineManifest } = require('@crxjs/vite-plugin') +const { defineManifest } = require("@crxjs/vite-plugin") // Convert from Semver (example: 0.1.0-beta6) -const [major, minor, patch, label = '0'] = version +const [major, minor, patch, label = "0"] = version // can only contain digits, dots, or dash - .replace(/[^\d.-]+/g, '') + .replace(/[^\d.-]+/g, "") // split into version parts .split(/[.-]/) export default defineManifest((env) => ({ manifest_version: 3, - name: env.mode === 'DEVELOPMENT' ? '[DEV] Pallad' : 'Pallad', + name: env.mode === "DEVELOPMENT" ? "[DEV] Pallad" : "Pallad", description: "🦋 Discover the Future of Web3 with Pallad. Unlock the power of the world's lightest blockchain 🪶", icons: { - '16': 'icons/16.png', - '32': 'icons/32.png', - '48': 'icons/48.png', - '128': 'icons/128.png' + "16": "icons/16.png", + "32": "icons/32.png", + "48": "icons/48.png", + "128": "icons/128.png", }, version: `${major}.${minor}.${patch}.${label}`, version_name: version, - action: { default_popup: 'index.html' }, + action: { default_popup: "index.html" }, permissions: [ - 'storage', - 'notifications', - 'activeTab', - 'offscreen', - 'tabs', - 'background' + "storage", + "notifications", + "activeTab", + "offscreen", + "tabs", + "background", ], background: { - service_worker: 'src/background/index.ts', - type: 'module' + service_worker: "src/background/index.ts", + type: "module", }, content_scripts: [ { - matches: ['https://*/*'], - js: ['src/inject/index.ts'], - run_at: 'document_start', - all_frames: true - } + matches: ["https://*/*"], + js: ["src/inject/index.ts"], + run_at: "document_start", + all_frames: true, + }, ], web_accessible_resources: [ { - resources: ['pallad_rpc.js'], - matches: ['https://*/*'] - } + resources: ["pallad_rpc.js"], + matches: ["https://*/*"], + }, ], host_permissions: [ - 'https://*/*' + "https://*/*", // Add other URLs or patterns as needed ], commands: { _execute_action: { suggested_key: { - windows: 'Alt+Shift+P', - mac: 'Alt+Shift+P', - chromeos: 'Alt+Shift+P', - linux: 'Alt+Shift+P' + windows: "Alt+Shift+P", + mac: "Alt+Shift+P", + chromeos: "Alt+Shift+P", + linux: "Alt+Shift+P", }, - description: 'Open the Pallad extension' - } - } + description: "Open the Pallad extension", + }, + }, })) diff --git a/apps/extension/package.json b/apps/extension/package.json index b6036dd2..54165759 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -7,7 +7,6 @@ "build": "tsc && vite build && node scripts/append-oninstall.cjs", "build:firefox": "web-ext build --source-dir=dist", "build:safari": "xcrun safari-web-extension-converter dist --app-name Pallad --bundle-identifier xyz.pallad.app --swift --no-prompt --force --macos-only --no-open", - "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview", "cleanup": "rimraf node_modules dist .turbo", "test:e2e": "playwright test", @@ -45,8 +44,6 @@ "@types/react": "^18.2.45", "@types/react-dom": "^18.2.18", "@types/webextension-polyfill": "^0.10.7", - "@typescript-eslint/eslint-plugin": "^6.15.0", - "@typescript-eslint/parser": "^6.15.0", "@vitejs/plugin-react-swc": "^3.6.0", "path": "^0.12.7", "rollup-plugin-node-polyfills": "^0.2.1", diff --git a/apps/extension/playwright.config.ts b/apps/extension/playwright.config.ts index 5a599bf7..dd125eb4 100644 --- a/apps/extension/playwright.config.ts +++ b/apps/extension/playwright.config.ts @@ -1,37 +1,37 @@ -import { defineConfig, devices } from '@playwright/test' +import { defineConfig, devices } from "@playwright/test" -const BASE_URL = 'http://localhost:4173/' +const BASE_URL = "http://localhost:4173/" /** * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ - testDir: './e2e', + testDir: "./e2e", fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : undefined, - reporter: 'html', + reporter: "html", timeout: 180000, // 3 minutes timeout use: { baseURL: BASE_URL, - trace: 'on-first-retry' + trace: "on-first-retry", }, projects: [ { - name: 'chromium', + name: "chromium", use: { - ...devices['Desktop Chrome'], + ...devices["Desktop Chrome"], viewport: { width: 371, - height: 600 - } - } - } + height: 600, + }, + }, + }, ], webServer: { - command: 'pnpm preview', + command: "pnpm preview", url: BASE_URL, - reuseExistingServer: !process.env.CI - } + reuseExistingServer: !process.env.CI, + }, }) diff --git a/apps/extension/postcss.config.mjs b/apps/extension/postcss.config.mjs index 57dd572f..8e0202ee 100644 --- a/apps/extension/postcss.config.mjs +++ b/apps/extension/postcss.config.mjs @@ -1,3 +1,3 @@ -import postcssConfig from '@palladxyz/features/postcss.config.mjs' +import postcssConfig from "@palladxyz/features/postcss.config.mjs" export default postcssConfig diff --git a/apps/extension/public/pallad_rpc.js b/apps/extension/public/pallad_rpc.js index c1f7633a..5d81ece8 100644 --- a/apps/extension/public/pallad_rpc.js +++ b/apps/extension/public/pallad_rpc.js @@ -1,4 +1,3 @@ -/* eslint-disable */ function debounce(func, wait, immediate) { let timeout return function (...args) { @@ -16,13 +15,13 @@ function debounce(func, wait, immediate) { }) } } -const BROADCAST_CHANNEL_ID = 'pallad' +const BROADCAST_CHANNEL_ID = "pallad" const callPalladAsync = ({ method, payload }) => new Promise((resolve, reject) => { const privateChannelId = `private-${Math.random()}` const channel = new BroadcastChannel(BROADCAST_CHANNEL_ID) const responseChannel = new BroadcastChannel(privateChannelId) - responseChannel.addEventListener('message', ({ data }) => { + responseChannel.addEventListener("message", ({ data }) => { channel.close() if (data.error) return reject(data.error) return resolve(data.response) @@ -31,7 +30,7 @@ const callPalladAsync = ({ method, payload }) => method, payload, isPallad: true, - respondAt: privateChannelId + respondAt: privateChannelId, }) return channel.close() }) @@ -39,26 +38,26 @@ const debouncedCall = debounce(callPalladAsync, 300) const init = () => { window.mina = { wallet: { - name: 'Pallad', - icon: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTY1IiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDE2NSAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04Mi4zNTMgMTg4LjIzNkM4Mi4zNTMgMTg4LjIzNiAxNTIuOTQxIDE1Mi45NDIgMTUyLjk0MSAxMDAuMDAxVjM4LjIzNjJMODIuMzUzIDExLjc2NTZMMTEuNzY0OCAzOC4yMzYyVjEwMC4wMDFDMTEuNzY0OCAxNTIuOTQyIDgyLjM1MyAxODguMjM2IDgyLjM1MyAxODguMjM2WiIgc3Ryb2tlPSJ1cmwoI3BhaW50MF9saW5lYXJfMTUxXzQ5NikiIHN0cm9rZS13aWR0aD0iMTcuNjc4NiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CjxwYXRoIGQ9Ik02OS4zNTA2IDQ4LjYzNzdDNzEuMTE5NSA0NC4xMzYzIDc1LjQ2MzYgNDEuMTc2MyA4MC4zMDAxIDQxLjE3NjNIODIuMzEwMUM4Ny4xNDE4IDQxLjE3NjMgOTEuNDgxOCA0NC4xMyA5My4yNTQyIDQ4LjYyNDVMMTIxLjA5NSAxMTkuMjEzQzEyNC4xMzkgMTI2LjkzMyAxMTguNDQ5IDEzNS4yOTQgMTEwLjE1MSAxMzUuMjk0SDEwOC4wODdMNzguNjAxMiA1NC45OTc3SDgzLjQ3MThMNTMuOTg2MSAxMzUuMjk0SDUyLjU1ODVDNDQuMjY1NyAxMzUuMjk0IDM4LjU3NTcgMTI2Ljk0NCA0MS42MDkgMTE5LjIyNkw2OS4zNTA2IDQ4LjYzNzdaIiBmaWxsPSJ1cmwoI3BhaW50MV9saW5lYXJfMTUxXzQ5NikiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8xNTFfNDk2IiB4MT0iMTYxLjc2NSIgeTE9IjUuODgzMjciIHgyPSI4LjgyMzYiIHkyPSIyMDAuMDAxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiMxRkQ3RkYiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjOEQ3QUZGIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQxX2xpbmVhcl8xNTFfNDk2IiB4MT0iMTYxLjc2NSIgeTE9IjIuOTQwOTgiIHgyPSI1Ljg4MjM5IiB5Mj0iMTk3LjA1OSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMUZEN0ZGIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzhEN0FGRiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=' + name: "Pallad", + icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTY1IiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDE2NSAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04Mi4zNTMgMTg4LjIzNkM4Mi4zNTMgMTg4LjIzNiAxNTIuOTQxIDE1Mi45NDIgMTUyLjk0MSAxMDAuMDAxVjM4LjIzNjJMODIuMzUzIDExLjc2NTZMMTEuNzY0OCAzOC4yMzYyVjEwMC4wMDFDMTEuNzY0OCAxNTIuOTQyIDgyLjM1MyAxODguMjM2IDgyLjM1MyAxODguMjM2WiIgc3Ryb2tlPSJ1cmwoI3BhaW50MF9saW5lYXJfMTUxXzQ5NikiIHN0cm9rZS13aWR0aD0iMTcuNjc4NiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CjxwYXRoIGQ9Ik02OS4zNTA2IDQ4LjYzNzdDNzEuMTE5NSA0NC4xMzYzIDc1LjQ2MzYgNDEuMTc2MyA4MC4zMDAxIDQxLjE3NjNIODIuMzEwMUM4Ny4xNDE4IDQxLjE3NjMgOTEuNDgxOCA0NC4xMyA5My4yNTQyIDQ4LjYyNDVMMTIxLjA5NSAxMTkuMjEzQzEyNC4xMzkgMTI2LjkzMyAxMTguNDQ5IDEzNS4yOTQgMTEwLjE1MSAxMzUuMjk0SDEwOC4wODdMNzguNjAxMiA1NC45OTc3SDgzLjQ3MThMNTMuOTg2MSAxMzUuMjk0SDUyLjU1ODVDNDQuMjY1NyAxMzUuMjk0IDM4LjU3NTcgMTI2Ljk0NCA0MS42MDkgMTE5LjIyNkw2OS4zNTA2IDQ4LjYzNzdaIiBmaWxsPSJ1cmwoI3BhaW50MV9saW5lYXJfMTUxXzQ5NikiLz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl8xNTFfNDk2IiB4MT0iMTYxLjc2NSIgeTE9IjUuODgzMjciIHgyPSI4LjgyMzYiIHkyPSIyMDAuMDAxIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiMxRkQ3RkYiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjOEQ3QUZGIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQxX2xpbmVhcl8xNTFfNDk2IiB4MT0iMTYxLjc2NSIgeTE9IjIuOTQwOTgiIHgyPSI1Ljg4MjM5IiB5Mj0iMTk3LjA1OSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjMUZEN0ZGIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzhEN0FGRiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=", }, request: async ({ method, params }) => debouncedCall({ method, payload: params }), enable: async () => { return debouncedCall({ - method: 'enable', - payload: { origin: window.location.origin } + method: "enable", + payload: { origin: window.location.origin }, }) }, isPallad: true, isConnected: async () => { return debouncedCall({ - method: 'isConnected', - payload: { origin: window.location.origin } + method: "isConnected", + payload: { origin: window.location.origin }, }) }, otherOn: async () => { - return 'hello world!' + return "hello world!" }, /* Note: `listenerId` is used as a placeholder to identify listener functions. @@ -70,8 +69,8 @@ const init = () => { // I don't think we need listenerId for `on`, `once` on: async (event, listenerId) => { return debouncedCall({ - method: 'on', - payload: { event, listenerId } + method: "on", + payload: { event, listenerId }, }) }, /*once: async (event, listenerId) => { @@ -90,10 +89,10 @@ const init = () => { },*/ off: async (event, listenerId) => { return debouncedCall({ - method: 'off', - payload: { event, listenerId } + method: "off", + payload: { event, listenerId }, }) - } + }, } } init() diff --git a/apps/extension/scripts/append-oninstall.cjs b/apps/extension/scripts/append-oninstall.cjs index d7110e17..f49b2ca1 100644 --- a/apps/extension/scripts/append-oninstall.cjs +++ b/apps/extension/scripts/append-oninstall.cjs @@ -1,12 +1,11 @@ -/* eslint-disable */ -const fs = require('fs') -const path = require('path') +const fs = require("node:fs") +const path = require("node:path") fs.appendFile( - path.join(__dirname, '..', 'dist', 'service-worker-loader.js'), + path.join(__dirname, "..", "dist", "service-worker-loader.js"), `chrome.runtime.onInstalled.addListener(({reason}) => reason === 'install' && chrome.tabs.create({ url: chrome.runtime.getURL('welcome.html') }))`, - function (err) { + (err) => { if (err) throw err - console.log('onInstall script appended.') - } + console.log("onInstall script appended.") + }, ) diff --git a/apps/extension/src/app.tsx b/apps/extension/src/app.tsx index 5d880752..44d7b913 100644 --- a/apps/extension/src/app.tsx +++ b/apps/extension/src/app.tsx @@ -1,18 +1,18 @@ -import './assets/app.css' -import '@palladxyz/features/dist/index.css' +import "@palladxyz/features/dist/index.css" +import "./assets/app.css" -import { Router } from '@palladxyz/features' -import { ThemeProvider } from 'next-themes' -import { useEffect } from 'react' +import { Router } from "@palladxyz/features" +import { ThemeProvider } from "next-themes" +import { useEffect } from "react" function App() { useEffect(() => { const handleContextmenu = (e: MouseEvent) => { if (!e.metaKey) e.preventDefault() } - document.addEventListener('contextmenu', handleContextmenu) + document.addEventListener("contextmenu", handleContextmenu) return function cleanup() { - document.removeEventListener('contextmenu', handleContextmenu) + document.removeEventListener("contextmenu", handleContextmenu) } }, []) diff --git a/apps/extension/src/background/index.ts b/apps/extension/src/background/index.ts index 82845bb3..58a0fee9 100644 --- a/apps/extension/src/background/index.ts +++ b/apps/extension/src/background/index.ts @@ -1,11 +1,11 @@ -import { MinaProvider, ProviderEvent } from '@palladxyz/web-provider' -import { onMessage, sendMessage } from 'webext-bridge/background' +import { MinaProvider, type ProviderEvent } from "@palladxyz/web-provider" +import { onMessage, sendMessage } from "webext-bridge/background" //import { sendMessage } from 'webext-bridge/content-script' // options should be defined by user const opts = { - projectId: 'test', - chains: ['Mina - Berkeley'] + projectId: "test", + chains: ["Mina - Berkeley"], } const provider = await MinaProvider.init(opts, []) @@ -37,7 +37,7 @@ function registerListener(event: ProviderEvent /*, context: string*/): string { const listenerId = generateListenerId() const listener: ListenerFunction = (args) => { // Adjusting sendMessage call to match its signature - sendMessage('eventTriggered', { listenerId, event, args }) // Assuming context is handled elsewhere or not needed + sendMessage("eventTriggered", { listenerId, event, args }) // Assuming context is handled elsewhere or not needed } listenerRegistry[listenerId] = { event, listener } @@ -57,95 +57,95 @@ function removeListener(listenerId: string): void { } } -onMessage('enable', async (payload) => { +onMessage("enable", async (payload) => { const data = payload.data as { origin: string } return await provider.enable({ origin: data.origin }) }) -onMessage('on', ({ data }) => { +onMessage("on", ({ data }) => { const { event /*, context*/ } = data as unknown as OnEventData const listenerId = registerListener(event /*, context*/) - console.log('test emitted event', event) + console.log("test emitted event", event) return { success: true, listenerId } }) -onMessage('off', ({ data }) => { +onMessage("off", ({ data }) => { const { listenerId } = data as unknown as OnMessageData removeListener(listenerId) return { success: true } }) -onMessage('mina_setState', async (data) => { - console.log('test mina_setState method', data) +onMessage("mina_setState", async (data) => { + console.log("test mina_setState method", data) //return await provider.request({ method: 'mina_setState', params: data }) - return await provider.request({ method: 'mina_setState', params: data }) + return await provider.request({ method: "mina_setState", params: data }) }) -onMessage('mina_addChain', async (data) => { - console.log('test mina_addChain method', data) - return await provider.request({ method: 'mina_addChain', params: data }) +onMessage("mina_addChain", async (data) => { + console.log("test mina_addChain method", data) + return await provider.request({ method: "mina_addChain", params: data }) }) -onMessage('mina_requestNetwork', async (data) => { - console.log('test mina_requestNetwork method', data) - return await provider.request({ method: 'mina_requestNetwork', params: data }) +onMessage("mina_requestNetwork", async (data) => { + console.log("test mina_requestNetwork method", data) + return await provider.request({ method: "mina_requestNetwork", params: data }) }) -onMessage('mina_switchChain', async (data) => { - console.log('test mina_switchChain method', data) - return await provider.request({ method: 'mina_switchChain', params: data }) +onMessage("mina_switchChain", async (data) => { + console.log("test mina_switchChain method", data) + return await provider.request({ method: "mina_switchChain", params: data }) }) -onMessage('mina_getState', async (data) => { - console.log('test mina_getState method') +onMessage("mina_getState", async (data) => { + console.log("test mina_getState method") //return await provider.request({ method: 'mina_getState' }) - return await provider.request({ method: 'mina_getState', params: data }) + return await provider.request({ method: "mina_getState", params: data }) }) -onMessage('isConnected', (payload) => { - console.log('test isConnected method') +onMessage("isConnected", (payload) => { + console.log("test isConnected method") const data = payload.data as { origin: string } return provider.isConnected({ origin: data.origin }) }) -onMessage('mina_chainId', async () => { - console.log('test mina_chainId method') - return await provider.request({ method: 'mina_chainId' }) +onMessage("mina_chainId", async () => { + console.log("test mina_chainId method") + return await provider.request({ method: "mina_chainId" }) }) -onMessage('mina_accounts', async () => { - console.log('test mina_accounts method') - return await provider.request({ method: 'mina_accounts' }) +onMessage("mina_accounts", async () => { + console.log("test mina_accounts method") + return await provider.request({ method: "mina_accounts" }) }) -onMessage('mina_sign', async (data) => { - console.log('test mina_sign method') - return await provider.request({ method: 'mina_sign', params: data }) +onMessage("mina_sign", async (data) => { + console.log("test mina_sign method") + return await provider.request({ method: "mina_sign", params: data }) }) -onMessage('mina_signFields', async (data) => { - console.log('test mina_signFields method') - return await provider.request({ method: 'mina_signFields', params: data }) +onMessage("mina_signFields", async (data) => { + console.log("test mina_signFields method") + return await provider.request({ method: "mina_signFields", params: data }) }) -onMessage('mina_signTransaction', async (data) => { - console.log('test mina_signTransaction method') +onMessage("mina_signTransaction", async (data) => { + console.log("test mina_signTransaction method") return await provider.request({ - method: 'mina_signTransaction', - params: data + method: "mina_signTransaction", + params: data, }) }) -onMessage('mina_getBalance', async () => { - console.log('test mina_getBalance method') - return await provider.request({ method: 'mina_getBalance' }) +onMessage("mina_getBalance", async () => { + console.log("test mina_getBalance method") + return await provider.request({ method: "mina_getBalance" }) }) -onMessage('mina_createNullifier', async (data) => { - console.log('test mina_createNullifier method') +onMessage("mina_createNullifier", async (data) => { + console.log("test mina_createNullifier method") return await provider.request({ - method: 'mina_createNullifier', - params: data + method: "mina_createNullifier", + params: data, }) }) diff --git a/apps/extension/src/inject/index.ts b/apps/extension/src/inject/index.ts index 4872c33e..bc302740 100644 --- a/apps/extension/src/inject/index.ts +++ b/apps/extension/src/inject/index.ts @@ -1,19 +1,19 @@ -import { sendMessage } from 'webext-bridge/content-script' -import { runtime } from 'webextension-polyfill' +import { sendMessage } from "webext-bridge/content-script" +import { runtime } from "webextension-polyfill" const inject = () => { - const script = document.createElement('script') - script.src = runtime.getURL('/pallad_rpc.js') - script.type = 'module' + const script = document.createElement("script") + script.src = runtime.getURL("/pallad_rpc.js") + script.type = "module" document.documentElement.appendChild(script) - console.info('[Pallad] RPC has been initialized.') - const channel = new BroadcastChannel('pallad') - channel.addEventListener('message', async ({ data }) => { + console.info("[Pallad] RPC has been initialized.") + const channel = new BroadcastChannel("pallad") + channel.addEventListener("message", async ({ data }) => { const responseChannel = new BroadcastChannel(data.respondAt) if (!data.isPallad) - return responseChannel.postMessage({ error: 'Wrong context' }) - const result = await sendMessage(data.method, data.payload, 'background') - return responseChannel.postMessage({ response: { jsonrpc: '1.0', result } }) + return responseChannel.postMessage({ error: "Wrong context" }) + const result = await sendMessage(data.method, data.payload, "background") + return responseChannel.postMessage({ response: { jsonrpc: "1.0", result } }) }) } diff --git a/apps/extension/src/main.tsx b/apps/extension/src/main.tsx index 41742962..2c5d20e2 100644 --- a/apps/extension/src/main.tsx +++ b/apps/extension/src/main.tsx @@ -1,13 +1,13 @@ -import 'dotenv/config' -import '@total-typescript/ts-reset' +import "@total-typescript/ts-reset" +import "dotenv/config" -import React from 'react' -import ReactDOM from 'react-dom/client' +import React from "react" +import ReactDOM from "react-dom/client" -import App from './app' +import App from "./app" -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( +ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - + , ) diff --git a/apps/extension/src/prompt.tsx b/apps/extension/src/prompt.tsx index ef5d2ed0..25d46d92 100644 --- a/apps/extension/src/prompt.tsx +++ b/apps/extension/src/prompt.tsx @@ -1,16 +1,16 @@ -import 'dotenv/config' -import '@total-typescript/ts-reset' -import '@palladxyz/features/dist/index.css' +import "@palladxyz/features/dist/index.css" +import "@total-typescript/ts-reset" +import "dotenv/config" -import { WebConnector } from '@palladxyz/features' -import { ThemeProvider } from 'next-themes' -import React from 'react' -import ReactDOM from 'react-dom/client' +import { WebConnector } from "@palladxyz/features" +import { ThemeProvider } from "next-themes" +import React from "react" +import ReactDOM from "react-dom/client" -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( +ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - + , ) diff --git a/apps/extension/src/typings.ts b/apps/extension/src/typings.ts index c57d0939..227410e2 100644 --- a/apps/extension/src/typings.ts +++ b/apps/extension/src/typings.ts @@ -1,4 +1,4 @@ -declare module 'mina-signer' +declare module "mina-signer" interface ImportMetaEnv { readonly VITE_APP_MINA_PROXY_MAINNET_URL: string @@ -9,7 +9,6 @@ interface ImportMetaEnv { readonly VITE_APP_MINA_EXPLORER_BERKELEY_URL: string } -// eslint-disable-next-line @typescript-eslint/no-unused-vars interface ImportMeta { readonly env: ImportMetaEnv } diff --git a/apps/extension/src/welcome.tsx b/apps/extension/src/welcome.tsx index 42e56f97..fcec5210 100644 --- a/apps/extension/src/welcome.tsx +++ b/apps/extension/src/welcome.tsx @@ -1,16 +1,16 @@ -import 'dotenv/config' -import '@total-typescript/ts-reset' -import '@palladxyz/features/dist/index.css' +import "@palladxyz/features/dist/index.css" +import "@total-typescript/ts-reset" +import "dotenv/config" -import { WelcomeScreen } from '@palladxyz/features' -import { ThemeProvider } from 'next-themes' -import React from 'react' -import ReactDOM from 'react-dom/client' +import { WelcomeScreen } from "@palladxyz/features" +import { ThemeProvider } from "next-themes" +import React from "react" +import ReactDOM from "react-dom/client" -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( +ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - + , ) diff --git a/apps/extension/tailwind.config.mjs b/apps/extension/tailwind.config.mjs index 2b73e83c..49263ede 100644 --- a/apps/extension/tailwind.config.mjs +++ b/apps/extension/tailwind.config.mjs @@ -1,9 +1,9 @@ -import tailwindConfig from '@palladxyz/features/tailwind.config.mjs' +import tailwindConfig from "@palladxyz/features/tailwind.config.mjs" export default { content: [ ...tailwindConfig.content, - '../../packages/features/src/**/*.{js,jsx,ts,tsx,mdx}' + "../../packages/features/src/**/*.{js,jsx,ts,tsx,mdx}", ], - presets: [tailwindConfig] + presets: [tailwindConfig], } diff --git a/apps/extension/vite.config.ts b/apps/extension/vite.config.ts index 3054b414..a948cc77 100644 --- a/apps/extension/vite.config.ts +++ b/apps/extension/vite.config.ts @@ -1,11 +1,11 @@ -import { crx } from '@crxjs/vite-plugin' -import react from '@vitejs/plugin-react-swc' -import { defineConfig } from 'vite' -import { nodePolyfills } from 'vite-plugin-node-polyfills' -import svgr from 'vite-plugin-svgr' -import topLevelAwait from 'vite-plugin-top-level-await' +import { crx } from "@crxjs/vite-plugin" +import react from "@vitejs/plugin-react-swc" +import { defineConfig } from "vite" +import { nodePolyfills } from "vite-plugin-node-polyfills" +import svgr from "vite-plugin-svgr" +import topLevelAwait from "vite-plugin-top-level-await" -import manifest from './manifest.config' +import manifest from "./manifest.config" export default defineConfig({ plugins: [ @@ -13,23 +13,23 @@ export default defineConfig({ crx({ manifest }), topLevelAwait(), nodePolyfills({ protocolImports: true, globals: { Buffer: true } }), - svgr() + svgr(), ], define: { - 'global.browser': {} + "global.browser": {}, }, build: { rollupOptions: { input: { - app: 'app.html', - index: 'index.html', - prompt: 'prompt.html', - welcome: 'welcome.html', - inject: 'public/pallad_rpc.js' - } + app: "app.html", + index: "index.html", + prompt: "prompt.html", + welcome: "welcome.html", + inject: "public/pallad_rpc.js", + }, }, commonjsOptions: { - transformMixedEsModules: true - } - } + transformMixedEsModules: true, + }, + }, }) diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..5b08fbf4 --- /dev/null +++ b/biome.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.7.1/schema.json", + "organizeImports": { + "enabled": true + }, + "files": { + "ignore": [ + "apps/**/dist/*.js", + "apps/**/dist/*.ts", + "apps/**/dist/*.json", + "packages/**/dist/*.js", + "packages/**/dist/*.ts", + "packages/**/dist/*.json" + ] + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "off", + "noImplicitAnyLet": "off" + }, + "style": { + "noNonNullAssertion": "off", + "noParameterAssign": "off" + }, + "a11y": { + "useKeyWithClickEvents": "off" + } + } + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2 + }, + "javascript": { + "formatter": { + "semicolons": "asNeeded" + } + } +} diff --git a/extension.turbowatch.ts b/extension.turbowatch.ts index 262ae89e..0fc747eb 100644 --- a/extension.turbowatch.ts +++ b/extension.turbowatch.ts @@ -1,4 +1,4 @@ -import { ChokidarWatcher, defineConfig } from 'turbowatch' +import { ChokidarWatcher, defineConfig } from "turbowatch" export default defineConfig({ project: __dirname, @@ -6,14 +6,14 @@ export default defineConfig({ triggers: [ { expression: [ - 'allof', - ['not', ['dirname', 'node_modules']], - ['match', '*.ts', 'basename'] + "allof", + ["not", ["dirname", "node_modules"]], + ["match", "*.ts", "basename"], ], - name: 'build', + name: "build", onChange: async ({ spawn }) => { await spawn`pnpm build:extension` - } - } - ] + }, + }, + ], }) diff --git a/package.json b/package.json index 06468eb6..f932aba1 100644 --- a/package.json +++ b/package.json @@ -11,34 +11,28 @@ "build:features": "turbo run build --filter=@palladxyz/features...", "story:features": "turbo run story:build --filter=@palladxyz/features", "dev:extension": "turbowatch extension.turbowatch.ts", - "lint": "eslint \"{apps,packages}/**/*.{ts,tsx,js,jsx,cjs,mjs}\"", + "lint": "pnpm biome check .", "lint:fix": "pnpm lint --fix", "test:unit": "turbo run test:unit", "test:e2e:extension": "turbo run test:e2e --filter=@palladxyz/extension", - "format": "prettier --write \"**/*.{ts,tsx,md}\" && pnpm lint:fix", + "format": "pnpm biome check --apply .", + "format:unsafe": "pnpm biome check --apply-unsafe .", "f": "pnpm format", "cleanup": "turbo run cleanup && rimraf node_modules", "prepare": "husky install", "preinstall": "npx only-allow pnpm" }, "devDependencies": { + "@biomejs/biome": "1.7.1", "@testing-library/react": "^14.1.2", "@tsconfig/strictest": "^2.0.2", "@turbo/gen": "^1.11.2", "@types/jest": "^29.5.11", - "@typescript-eslint/eslint-plugin": "^6.15.0", - "@typescript-eslint/parser": "^6.15.0", "@vitest/coverage-c8": "^0.33.0", "autoprefixer": "^10.4.16", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-import": "^2.29.1", - "eslint-plugin-prettier": "^5.1.0", - "eslint-plugin-simple-import-sort": "^10.0.0", "happy-dom": "^12.10.3", "husky": "^8.0.3", "postcss": "^8.4.32", - "prettier": "^3.1.1", "rimraf": "^5.0.5", "tailwind-merge": "^2.1.0", "tailwindcss": "^3.4.0", diff --git a/packages/_template/tsup.config.ts b/packages/_template/tsup.config.ts index 172626bc..8449a56d 100644 --- a/packages/_template/tsup.config.ts +++ b/packages/_template/tsup.config.ts @@ -1,11 +1,11 @@ -import { baseTsupConfig } from '@palladxyz/common' -import { defineConfig } from 'tsup' // eslint-disable-line import/no-extraneous-dependencies +import { baseTsupConfig } from "@palladxyz/common" +import { defineConfig } from "tsup" -import packageJson from './package.json' +import packageJson from "./package.json" export default defineConfig([ { ...baseTsupConfig, - name: packageJson.name - } + name: packageJson.name, + }, ]) diff --git a/packages/_template/vitest.config.ts b/packages/_template/vitest.config.ts index 87da45f9..964f699c 100644 --- a/packages/_template/vitest.config.ts +++ b/packages/_template/vitest.config.ts @@ -1,6 +1,6 @@ -import { baseVitestConfig } from '@palladxyz/common' -import { defineConfig } from 'vitest/config' // eslint-disable-line import/no-extraneous-dependencies +import { baseVitestConfig } from "@palladxyz/common" +import { defineConfig } from "vitest/config" export default defineConfig({ - ...baseVitestConfig + ...baseVitestConfig, }) diff --git a/packages/common/package.json b/packages/common/package.json index 36bd5294..0acfa007 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -5,11 +5,7 @@ "type": "module", "module": "dist/index.js", "types": "dist/index.d.ts", - "files": [ - "tsconfig.json", - "dist/index.js", - "dist/index.d.ts" - ], + "files": ["tsconfig.json", "dist/index.js", "dist/index.d.ts"], "exports": { "./tsconfig.json": { "import": "./tsconfig.json", diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index d2ab54f4..d3c8b891 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,23 +1,23 @@ export const baseTsupConfig = { - entry: ['./src/index.ts'], - outDir: './dist', - format: 'esm' as any, + entry: ["./src/index.ts"], + outDir: "./dist", + format: "esm" as any, sourcemap: true, clean: true, bundle: true, - dts: true + dts: true, } export const baseVitestConfig = { test: { - environment: 'happy-dom', + environment: "happy-dom", globals: true, testTimeout: 100000, hookTimeout: 100000, test: { coverage: { - reporter: ['text', 'json', 'html'] - } - } - } + reporter: ["text", "json", "html"], + }, + }, + }, } diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json index f1c4ee4a..79f91738 100644 --- a/packages/common/tsconfig.json +++ b/packages/common/tsconfig.json @@ -4,11 +4,8 @@ "moduleResolution": "node", "allowSyntheticDefaultImports": true, "esModuleInterop": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "noPropertyAccessFromIndexSignature": false }, - "exclude": [ - "dist", - "node_modules", - ".turbo" - ] + "exclude": ["dist", "node_modules", ".turbo"] } diff --git a/packages/features/.ladle/components.tsx b/packages/features/.ladle/components.tsx index 72a3ba79..de98a948 100644 --- a/packages/features/.ladle/components.tsx +++ b/packages/features/.ladle/components.tsx @@ -1,18 +1,19 @@ -import '@/globals.css' -import { useEffect } from 'react' +import { Toaster } from "@/components/ui/toaster" +import { TooltipProvider } from "@/components/ui/tooltip" +import "@/globals.css" import { ActionType, - GlobalProvider, + type GlobalProvider, ThemeState, - useLadleContext -} from '@ladle/react' -import { MemoryRouter } from 'react-router-dom' -import { ThemeProvider } from 'next-themes' -import { TooltipProvider } from '@/components/ui/tooltip' -import { Toaster } from '@/components/ui/toaster' + useLadleContext, +} from "@ladle/react" +import { ThemeProvider } from "next-themes" +import { useEffect } from "react" +import { MemoryRouter } from "react-router-dom" export const Provider: GlobalProvider = ({ children }) => { const { dispatch } = useLadleContext() + // biome-ignore lint: first render useEffect(() => { dispatch({ type: ActionType.UpdateTheme, value: ThemeState.Dark }) }, []) @@ -23,12 +24,12 @@ export const Provider: GlobalProvider = ({ children }) => {
{children} diff --git a/packages/features/.ladle/config.mjs b/packages/features/.ladle/config.mjs index c893f9bb..797309af 100644 --- a/packages/features/.ladle/config.mjs +++ b/packages/features/.ladle/config.mjs @@ -1,4 +1,4 @@ export default { - base: '/pallad/', - viteConfig: `${process.cwd()}/.ladle/vite.config.ts` + base: "/pallad/", + viteConfig: `${process.cwd()}/.ladle/vite.config.ts`, } diff --git a/packages/features/.ladle/utils.ts b/packages/features/.ladle/utils.ts deleted file mode 100644 index 5507dd17..00000000 --- a/packages/features/.ladle/utils.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { useEffect } from 'react' -import { Network } from '@palladxyz/pallad-core' -import { Mina } from '@palladxyz/mina-core' -import { KeyAgents, useVault } from '@palladxyz/vault' - -const MNEMONIC = - 'habit hope tip crystal because grunt nation idea electric witness alert like' - -export const useStoriesWallet = () => { - const restoreWallet = useVault((state) => state.restoreWallet) - useEffect(() => { - const restore = async () => { - await restoreWallet( - { - network: Network.Mina, - accountIndex: 0, - addressIndex: 0, - }, - Mina.Networks.BERKELEY, - { - mnemonicWords: MNEMONIC.split(' '), - getPassphrase: () => - new Promise((resolve) => - resolve(Buffer.from('passphrase')) - ) - }, - 'Pallad', - KeyAgents.InMemory, - 'Test' - ) - } - restore() - }, []) -} diff --git a/packages/features/.ladle/vite.config.ts b/packages/features/.ladle/vite.config.ts index 8b5bb191..8528ec0b 100644 --- a/packages/features/.ladle/vite.config.ts +++ b/packages/features/.ladle/vite.config.ts @@ -1,22 +1,22 @@ -import { defineConfig } from 'vite' -import topLevelAwait from 'vite-plugin-top-level-await' -import { nodePolyfills } from 'vite-plugin-node-polyfills' -import svgr from 'vite-plugin-svgr' +import { defineConfig } from "vite" +import { nodePolyfills } from "vite-plugin-node-polyfills" +import svgr from "vite-plugin-svgr" +import topLevelAwait from "vite-plugin-top-level-await" const env = (import.meta as any).env export default defineConfig({ define: { - __DEV__: env?.MODE === 'development' + __DEV__: env?.MODE === "development", }, plugins: [ topLevelAwait(), nodePolyfills({ protocolImports: true, globals: { Buffer: true } }), - svgr({ exportAsDefault: true }) + svgr({ exportAsDefault: true }), ], build: { commonjsOptions: { - transformMixedEsModules: true - } - } + transformMixedEsModules: true, + }, + }, }) diff --git a/packages/features/components.json b/packages/features/components.json index ebbb645d..74a05082 100644 --- a/packages/features/components.json +++ b/packages/features/components.json @@ -13,4 +13,4 @@ "components": "@/components", "utils": "@/lib/utils" } -} \ No newline at end of file +} diff --git a/packages/features/postcss.config.mjs b/packages/features/postcss.config.mjs index 2b75bd8a..2e7af2b7 100644 --- a/packages/features/postcss.config.mjs +++ b/packages/features/postcss.config.mjs @@ -1,6 +1,6 @@ export default { plugins: { tailwindcss: {}, - autoprefixer: {} - } + autoprefixer: {}, + }, } diff --git a/packages/features/src/about/routes/about.tsx b/packages/features/src/about/routes/about.tsx index 746c79ed..d5570553 100644 --- a/packages/features/src/about/routes/about.tsx +++ b/packages/features/src/about/routes/about.tsx @@ -1,6 +1,6 @@ -import { useNavigate } from 'react-router-dom' +import { useNavigate } from "react-router-dom" -import { AboutView } from '../views/about' +import { AboutView } from "../views/about" export const AboutRoute = () => { const navigate = useNavigate() diff --git a/packages/features/src/about/views/about.stories.tsx b/packages/features/src/about/views/about.stories.tsx index 85ee1b9b..bab5bc86 100644 --- a/packages/features/src/about/views/about.stories.tsx +++ b/packages/features/src/about/views/about.stories.tsx @@ -1,9 +1,9 @@ -import { StoryDefault } from '@ladle/react' +import type { StoryDefault } from "@ladle/react" -import { AboutView } from './about' +import { AboutView } from "./about" -export const View = () => console.log('go back')} /> +export const View = () => console.log("go back")} /> export default { - title: 'Dashboard / About' + title: "Dashboard / About", } satisfies StoryDefault diff --git a/packages/features/src/about/views/about.tsx b/packages/features/src/about/views/about.tsx index c2d54cf6..30e0ab46 100644 --- a/packages/features/src/about/views/about.tsx +++ b/packages/features/src/about/views/about.tsx @@ -1,21 +1,21 @@ -import Logo from '@/common/assets/logo.svg' -import { AppLayout } from '@/components/app-layout' -import { MetaField } from '@/components/meta-field' -import { Button } from '@/components/ui/button' -import { Card } from '@/components/ui/card' -import { ViewHeading } from '@/components/view-heading' +import Logo from "@/common/assets/logo.svg" +import { AppLayout } from "@/components/app-layout" +import { MetaField } from "@/components/meta-field" +import { Button } from "@/components/ui/button" +import { Card } from "@/components/ui/card" +import { ViewHeading } from "@/components/view-heading" -import packageJson from '../../../package.json' +import packageJson from "../../../package.json" const AppMeta = [ { - label: 'Current Version', - value: packageJson.version + label: "Current Version", + value: packageJson.version, }, { - label: 'Commit Hash', - value: '9iufgds239803nf' - } + label: "Commit Hash", + value: "9iufgds239803nf", + }, ] type AboutViewProps = { diff --git a/packages/features/src/address-book/components/contact-tile.tsx b/packages/features/src/address-book/components/contact-tile.tsx index d68d6816..7032ecdf 100644 --- a/packages/features/src/address-book/components/contact-tile.tsx +++ b/packages/features/src/address-book/components/contact-tile.tsx @@ -1,17 +1,17 @@ -import { TrashIcon } from 'lucide-react' -import { useNavigate } from 'react-router-dom' +import { TrashIcon } from "lucide-react" +import { useNavigate } from "react-router-dom" -import { truncateString } from '@/common/lib/string' -import { useAddressBookStore } from '@/common/store/address-book' -import { Contact } from '@/common/types' -import { Badge } from '@/components/ui/badge' -import { Button } from '@/components/ui/button' -import { Card } from '@/components/ui/card' +import { truncateString } from "@/common/lib/string" +import { useAddressBookStore } from "@/common/store/address-book" +import type { Contact } from "@/common/types" +import { Badge } from "@/components/ui/badge" +import { Button } from "@/components/ui/button" +import { Card } from "@/components/ui/card" import { Tooltip, TooltipContent, - TooltipTrigger -} from '@/components/ui/tooltip' + TooltipTrigger, +} from "@/components/ui/tooltip" interface ContactTileProps { contact: Contact @@ -31,7 +31,7 @@ export const ContactTile = ({ contact, index }: ContactTileProps) => { variant="link" className="text-sky-400" onClick={() => - navigate('/send', { state: { address: contact.address } }) + navigate("/send", { state: { address: contact.address } }) } data-testid="addressBook__contactName" > @@ -44,10 +44,10 @@ export const ContactTile = ({ contact, index }: ContactTileProps) => { truncateString({ value: contact.address, firstCharCount: 4, - endCharCount: 4 + endCharCount: 4, })}

- {typeof index === 'number' && ( + {typeof index === "number" && ( diff --git a/packages/features/src/components/button-arrow.tsx b/packages/features/src/components/button-arrow.tsx index 52307425..5212b480 100644 --- a/packages/features/src/components/button-arrow.tsx +++ b/packages/features/src/components/button-arrow.tsx @@ -1,4 +1,4 @@ -import { ArrowRightIcon } from 'lucide-react' +import { ArrowRightIcon } from "lucide-react" export const ButtonArrow = () => { return ( diff --git a/packages/features/src/components/command-menu.tsx b/packages/features/src/components/command-menu.tsx index 8865baea..e77afef4 100644 --- a/packages/features/src/components/command-menu.tsx +++ b/packages/features/src/components/command-menu.tsx @@ -8,10 +8,10 @@ import { LockIcon, QrCodeIcon, ReplaceIcon, - SettingsIcon -} from 'lucide-react' -import React from 'react' -import { useNavigate } from 'react-router-dom' + SettingsIcon, +} from "lucide-react" +import React from "react" +import { useNavigate } from "react-router-dom" import { CommandDialog, @@ -19,8 +19,8 @@ import { CommandGroup, CommandInput, CommandItem, - CommandList -} from '@/components/ui/command' + CommandList, +} from "@/components/ui/command" interface CommandMenuProps { open: boolean @@ -31,102 +31,103 @@ interface CommandMenuProps { export const CommandMenu = ({ open, setOpen, - lockWallet + lockWallet, }: CommandMenuProps) => { const navigate = useNavigate() const COMMAND_GROUPS = [ { - name: 'General', + name: "General", items: [ { - name: 'Dashboard', + name: "Dashboard", icon: LayoutDashboardIcon, - onSelect: () => navigate('/dashboard'), - testId: 'commandMenu__dashboard' + onSelect: () => navigate("/dashboard"), + testId: "commandMenu__dashboard", }, { - name: 'Receive', + name: "Receive", icon: QrCodeIcon, - onSelect: () => navigate('/receive'), - testId: 'commandMenu__receive' + onSelect: () => navigate("/receive"), + testId: "commandMenu__receive", }, { - name: 'Address Book', + name: "Address Book", icon: BookIcon, - onSelect: () => navigate('/contacts'), - testId: 'commandMenu__addressBook' - } - ] + onSelect: () => navigate("/contacts"), + testId: "commandMenu__addressBook", + }, + ], }, { - name: 'Transactions', + name: "Transactions", items: [ { - name: 'Transactions', + name: "Transactions", icon: ListIcon, - onSelect: () => navigate('/transactions'), - testId: 'commandMenu__transactions' + onSelect: () => navigate("/transactions"), + testId: "commandMenu__transactions", }, { - name: 'New Transaction', + name: "New Transaction", icon: ArrowRightLeftIcon, - onSelect: () => navigate('/send'), - testId: 'commandMenu__send' - } - ] + onSelect: () => navigate("/send"), + testId: "commandMenu__send", + }, + ], }, { - name: 'Staking', + name: "Staking", items: [ { - name: 'Staking', + name: "Staking", icon: CoinsIcon, - onSelect: () => navigate('/staking'), - testId: 'commandMenu__staking' + onSelect: () => navigate("/staking"), + testId: "commandMenu__staking", }, { - name: 'Change Delegation', + name: "Change Delegation", icon: ReplaceIcon, - onSelect: () => navigate('/staking/delegate'), - testId: 'commandMenu__delegate' - } - ] + onSelect: () => navigate("/staking/delegate"), + testId: "commandMenu__delegate", + }, + ], }, { - name: 'Wallet', + name: "Wallet", items: [ { - name: 'Settings', + name: "Settings", icon: SettingsIcon, - onSelect: () => navigate('/settings'), - testId: 'commandMenu__settings' + onSelect: () => navigate("/settings"), + testId: "commandMenu__settings", }, { - name: 'About', + name: "About", icon: InfoIcon, - onSelect: () => navigate('/about'), - testId: 'commandMenu__about' + onSelect: () => navigate("/about"), + testId: "commandMenu__about", }, { - name: 'Lock Wallet', + name: "Lock Wallet", icon: LockIcon, onSelect: lockWallet, - testId: 'commandMenu__lockWallet' - } - ] - } + testId: "commandMenu__lockWallet", + }, + ], + }, ] const down = (e: KeyboardEvent) => { - if (e.key === 'k' && e.metaKey) { + if (e.key === "k" && e.metaKey) { setOpen(!open) } } + // biome-ignore lint: only add listeners on first render React.useEffect(() => { - document.addEventListener('keydown', down) - return () => document.removeEventListener('keydown', down) + document.addEventListener("keydown", down) + return () => document.removeEventListener("keydown", down) }, []) return ( @@ -135,9 +136,11 @@ export const CommandMenu = ({ No results found. {COMMAND_GROUPS.map((group, i) => ( + // biome-ignore lint: array won't update {group.items.map((item, j) => ( { item.onSelect() diff --git a/packages/features/src/components/form-error.tsx b/packages/features/src/components/form-error.tsx index ae978a27..cce7d0ce 100644 --- a/packages/features/src/components/form-error.tsx +++ b/packages/features/src/components/form-error.tsx @@ -1,9 +1,9 @@ -import { twc } from 'react-twc' +import { twc } from "react-twc" export const FormError = twc.div`text-destructive text-sm` -FormError.displayName = 'FormError' +FormError.displayName = "FormError" FormError.defaultProps = { - 'data-testid': 'form__error' + "data-testid": "form__error", } as never diff --git a/packages/features/src/components/list-skeleton.tsx b/packages/features/src/components/list-skeleton.tsx index 28b3be03..dc45185b 100644 --- a/packages/features/src/components/list-skeleton.tsx +++ b/packages/features/src/components/list-skeleton.tsx @@ -1,4 +1,4 @@ -import { Skeleton } from './ui/skeleton' +import { Skeleton } from "./ui/skeleton" export const ListSkeleton = () => { return ( diff --git a/packages/features/src/components/meta-field.tsx b/packages/features/src/components/meta-field.tsx index 8ef74d4b..707bed9d 100644 --- a/packages/features/src/components/meta-field.tsx +++ b/packages/features/src/components/meta-field.tsx @@ -1,4 +1,4 @@ -import { cn } from '@/lib/utils' +import { cn } from "@/lib/utils" interface MetaFieldProps { label: string @@ -11,7 +11,7 @@ export const MetaField = ({ label, value, url, - capitalize = false + capitalize = false, }: MetaFieldProps) => { return (
@@ -20,7 +20,7 @@ export const MetaField = ({ href={url} target="_blank" rel="noopener noreferrer" - className={cn('leading-8 break-all', capitalize && 'capitalize')} + className={cn("leading-8 break-all", capitalize && "capitalize")} > {value} diff --git a/packages/features/src/components/mina-icon.tsx b/packages/features/src/components/mina-icon.tsx index 05e47646..89b7a5c7 100644 --- a/packages/features/src/components/mina-icon.tsx +++ b/packages/features/src/components/mina-icon.tsx @@ -1,4 +1,4 @@ -export const MinaIcon = ({ stroke = '2', size = '20', className = '' }) => ( +export const MinaIcon = ({ stroke = "2", size = "20", className = "" }) => ( ( width={size} height={size} className={className} + role="presentation" > { const confirm = async () => { useVault.persist.clearStorage() diff --git a/packages/features/src/components/security-check.tsx b/packages/features/src/components/security-check.tsx index a05aca2b..ebe862f2 100644 --- a/packages/features/src/components/security-check.tsx +++ b/packages/features/src/components/security-check.tsx @@ -1,7 +1,7 @@ -import { CheckIcon } from 'lucide-react' +import { CheckIcon } from "lucide-react" -import { Button } from '@/components/ui/button' -import { Card } from '@/components/ui/card' +import { Button } from "@/components/ui/button" +import { Card } from "@/components/ui/card" export type SecurityCheckProps = { onConfirm: () => void diff --git a/packages/features/src/components/social-buttons.tsx b/packages/features/src/components/social-buttons.tsx index 2a57f0c4..89140822 100644 --- a/packages/features/src/components/social-buttons.tsx +++ b/packages/features/src/components/social-buttons.tsx @@ -1,17 +1,22 @@ -import { TwitterIcon } from 'lucide-react' +import { TwitterIcon } from "lucide-react" -import { Button } from '@/components/ui/button' +import { Button } from "@/components/ui/button" export const SocialButtons = () => { return (