diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml new file mode 100644 index 000000000..e96aef683 --- /dev/null +++ b/.github/workflows/typecheck.yml @@ -0,0 +1,42 @@ +name: TypeScript Check + +on: + pull_request: + branches: [main] + +jobs: + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'pnpm' + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + + - name: Setup env files + run: | + for pkg in packages/*/; do + if [ -f "$pkg.env.example" ]; then + cp "$pkg.env.example" "$pkg.env" + fi + done + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build contracts + run: pnpm --filter 'contracts' run build + + - name: Build libs + run: pnpm build:libs && pnpm --filter 'query-server' run build + + - name: TypeScript check + # claim-frontend, auction-frontend: deprecated, events over + run: pnpm --filter '!claim-frontend' --filter '!auction-frontend' check diff --git a/packages/client/src/lib/components/Admin/helpers.ts b/packages/client/src/lib/components/Admin/helpers.ts index 6e6903129..e5deae7be 100644 --- a/packages/client/src/lib/components/Admin/helpers.ts +++ b/packages/client/src/lib/components/Admin/helpers.ts @@ -59,7 +59,7 @@ export function calculateProfitLossForTrip( const previousOutcome = tripOutcomes[i - 1] const outcomeTime = new Date(outcome._createdAt).getTime() - const previousOutcomeValue = previousOutcome?.tripValue || Number(trip.tripCreationCost) // Value from the previous trip, and if it's the first outcome, creation cost of the trip + const previousOutcomeValue = previousOutcome?.tripValue ?? outcome.oldTripValue ?? Number(trip.tripCreationCost) // Value from the previous trip, or oldTripValue (accounts for boosts), or creation cost const currentTripValue = outcome.tripValue || 0 const valueChange = currentTripValue - previousOutcomeValue diff --git a/packages/contracts/src/external/swap-router/RatRouter.sol b/packages/contracts/src/external/swap-router/RatRouter.sol index e4180c3af..92e33000c 100644 --- a/packages/contracts/src/external/swap-router/RatRouter.sol +++ b/packages/contracts/src/external/swap-router/RatRouter.sol @@ -127,6 +127,7 @@ contract RatRouter { amountOutMinimum: 0 }) ); + require(amountOut <= type(uint128).max, "amount overflow"); return uint128(amountOut); } diff --git a/packages/contracts/src/systems/RatSystem.sol b/packages/contracts/src/systems/RatSystem.sol index 364e4361c..801c520ae 100644 --- a/packages/contracts/src/systems/RatSystem.sol +++ b/packages/contracts/src/systems/RatSystem.sol @@ -14,7 +14,6 @@ import { } from "../codegen/index.sol"; import { System } from "@latticexyz/world/src/System.sol"; import { LibUtils, LibRat, LibWorld } from "../libraries/Libraries.sol"; -import { console2 as console } from "forge-std/console2.sol"; contract RatSystem is System { /**