From 8c43178af3b840469c4c940db5ae4220b991e4f6 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Mon, 17 Jun 2024 19:59:58 -0700 Subject: [PATCH] review changes --- ...-seals-smell.md => ninety-meals-vanish.md} | 7 +- apps/minifront/tailwind.config.js | 2 +- apps/node-status/tailwind.config.js | 2 +- pack-public.sh | 28 +++---- packages/bech32m/package.json | 3 +- packages/client/package.json | 3 +- packages/crypto/package.json | 1 - packages/getters/package.json | 1 - packages/perspective/package.json | 1 - packages/protobuf/package.json | 3 +- packages/query/package.json | 1 - packages/query/src/block-processor.ts | 83 ++++++++++--------- packages/services/package.json | 1 - packages/storage/package.json | 1 - packages/tailwind-config/package.json | 18 +--- .../resolved-tailwind-config.ts | 4 + packages/transport-chrome/package.json | 1 - packages/transport-dom/package.json | 1 - packages/types/package.json | 1 - packages/ui/components/ui/box.tsx | 7 ++ packages/ui/tailwind.config.js | 2 +- packages/wasm/package.json | 1 - 22 files changed, 80 insertions(+), 92 deletions(-) rename .changeset/{eighty-seals-smell.md => ninety-meals-vanish.md} (84%) create mode 100644 packages/tailwind-config/resolved-tailwind-config.ts diff --git a/.changeset/eighty-seals-smell.md b/.changeset/ninety-meals-vanish.md similarity index 84% rename from .changeset/eighty-seals-smell.md rename to .changeset/ninety-meals-vanish.md index bde7cbc38b..cba1d07602 100644 --- a/.changeset/eighty-seals-smell.md +++ b/.changeset/ninety-meals-vanish.md @@ -1,11 +1,12 @@ --- '@penumbra-zone/transport-chrome': major -'@penumbra-zone/eslint-config': major +'@repo/tailwind-config': major +'@repo/eslint-config': major '@penumbra-zone/transport-dom': major '@penumbra-zone/perspective': major '@penumbra-zone/protobuf': major '@penumbra-zone/services': major -'tsconfig': major +'@repo/tsconfig': major 'node-status': major '@penumbra-zone/bech32m': major '@penumbra-zone/getters': major @@ -17,7 +18,7 @@ '@penumbra-zone/query': major '@penumbra-zone/types': major '@penumbra-zone/wasm': major -'@penumbra-zone/ui': major +'@repo/ui': major --- reconfigure all package builds diff --git a/apps/minifront/tailwind.config.js b/apps/minifront/tailwind.config.js index 2a13f7dd7f..9e1382f8a1 100644 --- a/apps/minifront/tailwind.config.js +++ b/apps/minifront/tailwind.config.js @@ -1 +1 @@ -export * from '@repo/tailwind-config'; +export { default } from '@repo/tailwind-config'; diff --git a/apps/node-status/tailwind.config.js b/apps/node-status/tailwind.config.js index 2a13f7dd7f..9e1382f8a1 100644 --- a/apps/node-status/tailwind.config.js +++ b/apps/node-status/tailwind.config.js @@ -1 +1 @@ -export * from '@repo/tailwind-config'; +export { default } from '@repo/tailwind-config'; diff --git a/pack-public.sh b/pack-public.sh index 5c5ff075af..60dde66bc9 100644 --- a/pack-public.sh +++ b/pack-public.sh @@ -2,18 +2,18 @@ # pnpm doesn't like to recurse for the pack command, and turbo doesn't # understand it as a script. this script should pack every non-private package. -pnpm turbo compile -pnpm pack -C packages/bech32m -pnpm pack -C packages/client -pnpm pack -C packages/crypto -pnpm pack -C packages/getters -pnpm pack -C packages/keys -pnpm pack -C packages/perspective -pnpm pack -C packages/protobuf -pnpm pack -C packages/query -pnpm pack -C packages/services -pnpm pack -C packages/storage -pnpm pack -C packages/transport-chrome -pnpm pack -C packages/transport-dom -pnpm pack -C packages/types +pnpm turbo build --filter="./packages/*" +pnpm pack -C packages/bech32m && \ +pnpm pack -C packages/client && \ +pnpm pack -C packages/crypto && \ +pnpm pack -C packages/getters && \ +pnpm pack -C packages/keys && \ +pnpm pack -C packages/perspective && \ +pnpm pack -C packages/protobuf && \ +pnpm pack -C packages/query && \ +pnpm pack -C packages/services && \ +pnpm pack -C packages/storage && \ +pnpm pack -C packages/transport-chrome && \ +pnpm pack -C packages/transport-dom && \ +pnpm pack -C packages/types && \ pnpm pack -C packages/wasm diff --git a/packages/bech32m/package.json b/packages/bech32m/package.json index fd3c0f0380..b8efc04df1 100644 --- a/packages/bech32m/package.json +++ b/packages/bech32m/package.json @@ -10,8 +10,7 @@ "scripts": { "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", - "lint": "eslint src", - "prepack": "$npm_execpath run build", + "lint": "tsc --noEmit && eslint src", "test": "vitest run" }, "files": [ diff --git a/packages/client/package.json b/packages/client/package.json index 8af40153b2..163a52d7ff 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -10,8 +10,7 @@ "scripts": { "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", - "lint": "eslint src", - "prepack": "$npm_execpath run build" + "lint": "eslint src" }, "files": [ "dist" diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 26ef3d8042..52b20f923c 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -10,7 +10,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/getters/package.json b/packages/getters/package.json index 9bec62f171..d5eff3adbe 100644 --- a/packages/getters/package.json +++ b/packages/getters/package.json @@ -11,7 +11,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/perspective/package.json b/packages/perspective/package.json index 048cac74e0..aca9ae5853 100644 --- a/packages/perspective/package.json +++ b/packages/perspective/package.json @@ -11,7 +11,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/protobuf/package.json b/packages/protobuf/package.json index 6bfbb1ce08..d03e6acd19 100644 --- a/packages/protobuf/package.json +++ b/packages/protobuf/package.json @@ -10,8 +10,7 @@ "scripts": { "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", - "lint": "eslint src", - "prepack": "$npm_execpath run build" + "lint": "eslint src" }, "files": [ "dist" diff --git a/packages/query/package.json b/packages/query/package.json index d8416583a4..b1de5e91a0 100644 --- a/packages/query/package.json +++ b/packages/query/package.json @@ -10,7 +10,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/query/src/block-processor.ts b/packages/query/src/block-processor.ts index 88b2494551..9fce9afa53 100644 --- a/packages/query/src/block-processor.ts +++ b/packages/query/src/block-processor.ts @@ -1,11 +1,8 @@ -import { RootQuerier } from './root-querier'; -import { sha256Hash } from '@penumbra-zone/crypto-web/sha256'; -import { computePositionId, getLpNftMetadata } from '@penumbra-zone/wasm/dex'; - import { - getExchangeRateFromValidatorInfoResponse, - getIdentityKeyFromValidatorInfoResponse, -} from '@penumbra-zone/getters/validator-info-response'; + AssetId, + Metadata, +} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; +import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1/auction_pb'; import { PositionState, PositionState_PositionStateEnum, @@ -14,6 +11,7 @@ import { CommitmentSource, Nullifier, } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/sct/v1/sct_pb'; +import { ValidatorInfoResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/stake/v1/stake_pb'; import { Action, Transaction, @@ -24,28 +22,29 @@ import { SpendableNoteRecord, SwapRecord, } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb'; -import { backOff } from 'exponential-backoff'; -import type { BlockProcessorInterface } from '@penumbra-zone/types/block-processor'; -import type { IndexedDbInterface } from '@penumbra-zone/types/indexed-db'; -import type { ViewServerInterface } from '@penumbra-zone/types/servers'; -import { customizeSymbol } from '@penumbra-zone/wasm/metadata'; -import { updatePricesFromSwaps } from './helpers/price-indexer'; -import { - AssetId, - Metadata, -} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; +import { auctionIdFromBech32 } from '@penumbra-zone/bech32m/pauctid'; import { bech32mIdentityKey } from '@penumbra-zone/bech32m/penumbravalid'; +import { sha256Hash } from '@penumbra-zone/crypto-web/sha256'; import { getAssetId } from '@penumbra-zone/getters/metadata'; -import { PRICE_RELEVANCE_THRESHOLDS, assetPatterns } from '@penumbra-zone/types/assets'; +import { + getExchangeRateFromValidatorInfoResponse, + getIdentityKeyFromValidatorInfoResponse, +} from '@penumbra-zone/getters/validator-info-response'; import { toDecimalExchangeRate } from '@penumbra-zone/types/amount'; -import { ValidatorInfoResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/stake/v1/stake_pb'; +import { PRICE_RELEVANCE_THRESHOLDS, assetPatterns } from '@penumbra-zone/types/assets'; +import type { BlockProcessorInterface } from '@penumbra-zone/types/block-processor'; import { uint8ArrayToHex } from '@penumbra-zone/types/hex'; -import { AuctionId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1/auction_pb'; -import { auctionIdFromBech32 } from '@penumbra-zone/bech32m/pauctid'; +import type { IndexedDbInterface } from '@penumbra-zone/types/indexed-db'; +import type { ViewServerInterface } from '@penumbra-zone/types/servers'; import { ScanBlockResult } from '@penumbra-zone/types/state-commitment-tree'; +import { computePositionId, getLpNftMetadata } from '@penumbra-zone/wasm/dex'; +import { customizeSymbol } from '@penumbra-zone/wasm/metadata'; +import { backOff } from 'exponential-backoff'; +import { updatePricesFromSwaps } from './helpers/price-indexer'; import { processActionDutchAuctionEnd } from './helpers/process-action-dutch-auction-end'; import { processActionDutchAuctionSchedule } from './helpers/process-action-dutch-auction-schedule'; import { processActionDutchAuctionWithdraw } from './helpers/process-action-dutch-auction-withdraw'; +import { RootQuerier } from './root-querier'; declare global { // eslint-disable-next-line no-var @@ -309,29 +308,33 @@ export class BlockProcessor implements BlockProcessorInterface { } if (globalThis.__ASSERT_ROOT__) { - /* - * Compares the locally stored, filtered TCT root with the actual one on chain. They should match. - * This is expensive to do every block, so should only be done in development for debugging purposes. - */ - const remoteRoot = await this.querier.cnidarium.fetchRemoteRoot(compactBlock.height); - const inMemoryRoot = this.viewServer.getSctRoot(); - - if (remoteRoot.equals(inMemoryRoot)) { - console.log( - `Block height: ${compactBlock.height} root matches remote ✅ \n`, - `Hash: ${uint8ArrayToHex(inMemoryRoot.inner)}`, - ); - } else { - console.log( - `Block height: ${compactBlock.height} root does not match remote ❌ \n`, - `Local hash: ${uint8ArrayToHex(inMemoryRoot.inner)} \n`, - `Remote hash: ${uint8ArrayToHex(remoteRoot.inner)}`, - ); - } + await this.assertRootValid(compactBlock.height); } } } + /* + * Compares the locally stored, filtered TCT root with the actual one on chain. They should match. + * This is expensive to do every block, so should only be done in development for debugging purposes. + */ + private async assertRootValid(blockHeight: bigint): Promise { + const remoteRoot = await this.querier.cnidarium.fetchRemoteRoot(blockHeight); + const inMemoryRoot = this.viewServer.getSctRoot(); + + if (remoteRoot.equals(inMemoryRoot)) { + console.debug( + `Block height: ${blockHeight} root matches remote ✅ \n`, + `Hash: ${uint8ArrayToHex(inMemoryRoot.inner)}`, + ); + } else { + console.warn( + `Block height: ${blockHeight} root does not match remote ❌ \n`, + `Local hash: ${uint8ArrayToHex(inMemoryRoot.inner)} \n`, + `Remote hash: ${uint8ArrayToHex(remoteRoot.inner)}`, + ); + } + } + private async saveRecoveredCommitmentSources(recovered: (SpendableNoteRecord | SwapRecord)[]) { for (const record of recovered) if (record instanceof SpendableNoteRecord) await this.indexedDb.saveSpendableNote(record); diff --git a/packages/services/package.json b/packages/services/package.json index b7d6a16728..26fc8fc127 100644 --- a/packages/services/package.json +++ b/packages/services/package.json @@ -10,7 +10,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/storage/package.json b/packages/storage/package.json index f2c618abca..22c1ae69c6 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -10,7 +10,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-transport-dom-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/tailwind-config/package.json b/packages/tailwind-config/package.json index 3df5a8130a..50a2703f46 100644 --- a/packages/tailwind-config/package.json +++ b/packages/tailwind-config/package.json @@ -3,22 +3,8 @@ "version": "2.0.1", "private": true, "license": "(MIT OR Apache-2.0)", - "type": "module", - "files": [ - "dist" - ], - "exports": { - ".": "./index.ts" - }, - "publishConfig": { - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./dist/index.d.ts" - } - } - }, - "peerDependencies": { + "main": "index.ts", + "dependencies": { "tailwindcss": "^3.4.3", "tailwindcss-animate": "^1.0.7" } diff --git a/packages/tailwind-config/resolved-tailwind-config.ts b/packages/tailwind-config/resolved-tailwind-config.ts new file mode 100644 index 0000000000..f1dc872c60 --- /dev/null +++ b/packages/tailwind-config/resolved-tailwind-config.ts @@ -0,0 +1,4 @@ +import resolveConfig from 'tailwindcss/resolveConfig'; +import tailwindConfig from '@repo/tailwind-config'; + +export const RESOLVED_TAILWIND_CONFIG = resolveConfig(tailwindConfig); diff --git a/packages/transport-chrome/package.json b/packages/transport-chrome/package.json index 3b876921d0..e019d181ea 100644 --- a/packages/transport-chrome/package.json +++ b/packages/transport-chrome/package.json @@ -11,7 +11,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-transport-dom-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/transport-dom/package.json b/packages/transport-dom/package.json index 147d1da429..ab6786349e 100644 --- a/packages/transport-dom/package.json +++ b/packages/transport-dom/package.json @@ -10,7 +10,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-transport-dom-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/types/package.json b/packages/types/package.json index 69db5ad19c..639b35177b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -10,7 +10,6 @@ "build": "tsc --build", "clean": "rm -rfv dist package penumbra-zone-*.tgz", "lint": "eslint src", - "prepack": "$npm_execpath run build", "test": "vitest run" }, "files": [ diff --git a/packages/ui/components/ui/box.tsx b/packages/ui/components/ui/box.tsx index 7b9ba8e0fd..87835dfe6d 100644 --- a/packages/ui/components/ui/box.tsx +++ b/packages/ui/components/ui/box.tsx @@ -2,6 +2,7 @@ import { cva, VariantProps } from 'class-variance-authority'; import { motion } from 'framer-motion'; import { PropsWithChildren, ReactNode } from 'react'; import { cn } from '../../lib/utils'; +import { RESOLVED_TAILWIND_CONFIG } from '@repo/tailwind-config/resolved-tailwind-config'; const variants = cva('rounded-lg border bg-background', { variants: { @@ -50,6 +51,12 @@ export const Box = ({ layout={layout ?? !!layoutId} layoutId={layoutId} className={cn('flex flex-col gap-4', variants({ spacing, state, overflow }))} + /** + * Set the border radius via the style prop so it doesn't get distorted by framer-motion. + * + * @see https://www.framer.com/motion/layout-animations/##scale-correction + */ + style={{ borderRadius: RESOLVED_TAILWIND_CONFIG.theme.borderRadius.lg }} > {(label ?? headerContent) && (
diff --git a/packages/ui/tailwind.config.js b/packages/ui/tailwind.config.js index 2a13f7dd7f..9e1382f8a1 100644 --- a/packages/ui/tailwind.config.js +++ b/packages/ui/tailwind.config.js @@ -1 +1 @@ -export * from '@repo/tailwind-config'; +export { default } from '@repo/tailwind-config'; diff --git a/packages/wasm/package.json b/packages/wasm/package.json index 6e5df21867..74ee6a833e 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -17,7 +17,6 @@ "lint:rust": "cd crate && cargo fmt --all -- --check && cargo clippy -- -D warnings && cargo clippy --tests -- -D warnings", "postcompile": "touch ./wasm/.npmignore", "prebuild": "tsc --build --clean", - "prepack": "$npm_execpath run build", "test": "vitest run", "test:rust": "cd crate && wasm-pack test --headless --firefox -- --test build --target wasm32-unknown-unknown --release --features 'mock-database'" },