Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use npm packages #34

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 deletions .changeset/silly-lemons-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'prax-marketing-website': major
'@repo/tailwind-config': major
'@repo/eslint-config': major
'@repo/tsconfig': major
'@repo/context': major
'chrome-extension': major
'@repo/ui': major
---

use imported packages
36 changes: 0 additions & 36 deletions .github/workflows/compile-wasm.yml

This file was deleted.

15 changes: 6 additions & 9 deletions .github/workflows/extension-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,29 @@ on:
workflow_call:
workflow_dispatch:

jobs:
turbo-compile:
name: Compile
uses: ./.github/workflows/compile-wasm.yml
env:
DO_NOT_TRACK: 1

jobs:
publish:
environment: ext-publish
name: Upload extension dist
runs-on: buildjet-16vcpu-ubuntu-2204
needs: turbo-compile

steps:
- uses: actions/checkout@v4
- id: built
uses: buildjet/cache@v3
with:
path: .turbo
key: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-built
restore-keys: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
key: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-publish
restore-keys: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly restore cache from a successful test run

- uses: pnpm/action-setup@v2
- uses: buildjet/setup-node@v4
with:
node-version: '21'
node-version: '22'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm turbo telemetry disable
- run: pnpm turbo build --cache-dir=.turbo

# Outputs beta.zip and prod.zip
Expand Down
91 changes: 13 additions & 78 deletions .github/workflows/turbo-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- main

env:
DO_NOT_TRACK: 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaces turbo telemetry disable command


concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -15,131 +18,63 @@ concurrency:
# the first action is commented, most of those comments apply to all actions
# every 'turbo' call is cached and essentially no-op if the inputs match

# tried to make wasm compile conditional, but that turned out to be complex.
# cache should make it decently fast.

# pnpm cached by lock hash
# turbo cached by cargo lock, pnpm lock in that order
# mostly, compiled wasm will restore from turbo cache
# rust cache only used in rust jobs
# turbo cached pnpm lock

jobs:
turbo-compile:
name: Compile
uses: ./.github/workflows/compile-wasm.yml

turbo-lint:
name: Lint
runs-on: buildjet-8vcpu-ubuntu-2204
needs: turbo-compile
steps:
- uses: actions/checkout@v4
- id: lint
uses: buildjet/cache@v3
with:
path: .turbo
key: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-lint
restore-keys: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
key: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-lint
restore-keys: ${{ hashFiles('pnpm-lock.yaml') }}
- uses: pnpm/action-setup@v2
- uses: buildjet/setup-node@v4
with:
node-version: '21'
node-version: '22'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm turbo telemetry disable
- run: pnpm turbo lint --cache-dir=.turbo

turbo-build:
name: Build
runs-on: buildjet-8vcpu-ubuntu-2204
needs: turbo-compile
steps:
- uses: actions/checkout@v4
- id: built
uses: buildjet/cache@v3
with:
path: .turbo
key: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-built
restore-keys: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
key: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-built
restore-keys: ${{ hashFiles('pnpm-lock.yaml') }}
- uses: pnpm/action-setup@v2
- uses: buildjet/setup-node@v4
with:
node-version: '21'
node-version: '22'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm turbo telemetry disable
- run: pnpm turbo build --cache-dir=.turbo

turbo-test:
name: test
runs-on: buildjet-4vcpu-ubuntu-2204
needs: turbo-compile
steps:
- uses: actions/checkout@v4
- id: tested
uses: buildjet/cache@v3
with:
path: .turbo
key: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-test
restore-keys: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
key: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-test
restore-keys: ${{ hashFiles('pnpm-lock.yaml') }}
- uses: pnpm/action-setup@v2
- uses: buildjet/setup-node@v4
with:
node-version: '21'
node-version: '22'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm turbo telemetry disable
- run: pnpm playwright install --with-deps chromium
- run: pnpm turbo test --cache-dir=.turbo

turbo-lint-rust:
name: lint:rust
runs-on: buildjet-4vcpu-ubuntu-2204
needs: turbo-compile
steps:
- uses: actions/checkout@v4
- id: rust-linted
uses: buildjet/cache@v3
with:
path: .turbo
key: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-lint:rust
restore-keys: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
- uses: pnpm/action-setup@v2
- uses: buildjet/setup-node@v4
with:
node-version: '21'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- run: pnpm turbo telemetry disable
- run: pnpm turbo lint:rust --cache-dir=.turbo

turbo-test-rust:
name: test:rust
runs-on: buildjet-16vcpu-ubuntu-2204
needs: turbo-compile
steps:
- uses: actions/checkout@v4
- id: tested
uses: buildjet/cache@v3
with:
path: .turbo
key: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-test:rust
restore-keys: ${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
- uses: pnpm/action-setup@v2
- uses: buildjet/setup-node@v4
with:
node-version: '21'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: jetli/[email protected]
with:
version: 'latest'
- uses: browser-actions/setup-firefox@v1
- run: pnpm turbo telemetry disable
- run: pnpm turbo test:rust --cache-dir=.turbo
4 changes: 2 additions & 2 deletions .syncpackrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@buf/*"
],
"snapTo": [
"penumbra-web"
"prax-wallet"
]
}
]
}
}
2 changes: 1 addition & 1 deletion apps/extension/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { penumbraEslintConfig } from '@penumbra-zone/eslint-config';
import { penumbraEslintConfig } from '@repo/eslint-config';
import { config, parser } from 'typescript-eslint';

export default config({
Expand Down
42 changes: 21 additions & 21 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@
"description": "chrome-extension",
"type": "module",
"scripts": {
"build": "NODE_ENV=mainnet pnpm bundle",
"build": "pnpm bundle",
"bundle": "NODE_OPTIONS=\"--import=./src/utils/webpack-register.js\" webpack",
"clean": "rm -rfv dist bin",
"dev": "NODE_ENV=testnet pnpm bundle --watch --mode=development -d inline-source-map",
"lint": "eslint src",
"test": "vitest run"
},
"dependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240528180215-8fe1c79485f8.1",
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20240606104028-442292b00c16.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240616005217-ca45ca80333e.1",
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect-web": "^1.4.0",
"@penumbra-labs/registry": "8.0.1",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/client": "workspace:*",
"@penumbra-zone/crypto-web": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
"@penumbra-zone/perspective": "workspace:*",
"@penumbra-zone/protobuf": "workspace:*",
"@penumbra-zone/query": "workspace:*",
"@penumbra-zone/services": "workspace:*",
"@penumbra-zone/services-context": "workspace:*",
"@penumbra-zone/storage": "workspace:*",
"@penumbra-zone/transport-chrome": "workspace:*",
"@penumbra-zone/transport-dom": "workspace:*",
"@penumbra-zone/types": "workspace:*",
"@penumbra-zone/ui": "workspace:*",
"@penumbra-zone/wasm": "workspace:*",
"@penumbra-zone/bech32m": "^6.1.0",
"@penumbra-zone/client": "^8.0.0",
"@penumbra-zone/crypto-web": "^5.0.0",
"@penumbra-zone/getters": "^8.0.0",
"@penumbra-zone/keys": "^4.1.0",
"@penumbra-zone/perspective": "^6.0.0",
"@penumbra-zone/protobuf": "^5.1.0",
"@penumbra-zone/query": "^6.0.0",
"@penumbra-zone/services": "^6.0.0",
"@penumbra-zone/storage": "^6.0.0",
"@penumbra-zone/transport-chrome": "^4.0.0",
"@penumbra-zone/transport-dom": "^7.1.0",
"@penumbra-zone/types": "^9.0.0",
"@penumbra-zone/wasm": "^9.0.0",
"@repo/context": "workspace:*",
"@repo/ui": "workspace:*",
"@tanstack/react-query": "4.36.1",
"buffer": "^6.0.3",
"exponential-backoff": "^3.1.1",
Expand All @@ -51,8 +53,8 @@
"zustand": "^4.5.2"
},
"devDependencies": {
"@penumbra-zone/keys": "workspace:*",
"@radix-ui/react-icons": "^1.3.0",
"@types/chrome": "0.0.268",
"@types/firefox-webext-browser": "^120.0.3",
"@types/lodash": "^4.17.4",
"@types/react": "^18.3.2",
Expand All @@ -67,11 +69,9 @@
"postcss-loader": "^8.1.1",
"promise.withresolvers": "^1.0.3",
"style-loader": "^4.0.0",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.4",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-merge": "^5.10.0"
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from '@penumbra-zone/ui/postcss.config.js';
export { default } from '@repo/ui/postcss.config.js';
2 changes: 1 addition & 1 deletion apps/extension/src/entry/page-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { pageRouter } from '../routes/page/router';
import { StrictMode, useState } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import '@penumbra-zone/ui/styles/globals.css';
import '@repo/ui/styles/globals.css';

const MainPage = () => {
const [queryClient] = useState(() => new QueryClient());
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/entry/popup-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { txApprovalSelector } from '../state/tx-approval';
import { errorToJson } from '@connectrpc/connect/protocol-connect';
import { ConnectError } from '@connectrpc/connect';

import '@penumbra-zone/ui/styles/globals.css';
import '@repo/ui/styles/globals.css';

chrome.runtime.onMessage.addListener(
(req: unknown, _: chrome.runtime.MessageSender, responder: (x: unknown) => void) => {
Expand Down
13 changes: 10 additions & 3 deletions apps/extension/src/hooks/full-sync-height.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { useQuery } from '@tanstack/react-query';
import { TendermintQuerier } from '@penumbra-zone/query/queriers/tendermint';
import { PopupLoaderData } from '../routes/popup/home';
import { useStore } from '../state';
import { networkSelector } from '../state/network';
import { useLoaderData } from 'react-router-dom';
import { TendermintProxyService } from '@penumbra-zone/protobuf';
import { createGrpcWebTransport } from '@connectrpc/connect-web';
import { createPromiseClient } from '@connectrpc/connect';

const tryGetMax = (a?: number, b?: number): number | undefined => {
// Height can be 0n which is falsy, so should compare to undefined state
Expand All @@ -29,8 +31,13 @@ export const useSyncProgress = () => {
const { data: queriedLatest, error } = useQuery({
queryKey: ['latestBlockHeight'],
queryFn: async () => {
const querier = new TendermintQuerier({ grpcEndpoint: grpcEndpoint! });
const blockHeight = await querier.latestBlockHeight();
if (!grpcEndpoint) return;
const tendermintClient = createPromiseClient(
TendermintProxyService,
createGrpcWebTransport({ baseUrl: grpcEndpoint }),
);
const blockHeight = (await tendermintClient.getStatus({}).catch(() => undefined))?.syncInfo
?.latestBlockHeight;
return Number(blockHeight);
},
enabled: Boolean(grpcEndpoint),
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/listeners/message-prax-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ chrome.runtime.onMessage.addListener(
}
},
e => {
if (process.env['NODE_ENV'] === 'development') {
if (globalThis.__DEV__) {
console.warn('Connection request listener failed:', e);
}
if (e instanceof ConnectError && e.code === Code.Unauthenticated) {
Expand Down
Loading
Loading