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

simplify tsconfig, build & lint #72

Merged
merged 13 commits into from
Nov 5, 2024
5 changes: 5 additions & 0 deletions .changeset/strange-mangos-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@across-protocol/app-sdk": patch
---

Simplify build using tsc for a more tree-shakable, unbundled output.
9 changes: 1 addition & 8 deletions apps/example/app/ethers/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
"use client";
import {
useEthers,
useEtherBalance,
DAppProvider,
Arbitrum,
Config,
Mainnet,
} from "@usedapp/core";
import { DAppProvider, Arbitrum, Config, Mainnet } from "@usedapp/core";
import * as React from "react";
import { ThemeProvider } from "next-themes";

Expand Down
2 changes: 1 addition & 1 deletion apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^3.1.0",
"viem": "^2.20.1",
"wagmi": "^2.12.7"
"wagmi": "^2.12.25"
},
"devDependencies": {
"@across-toolkit/eslint-config": "workspace:*",
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "across-toolkit",
"private": true,
"scripts": {
"build": "turbo build",
Expand All @@ -19,8 +20,12 @@
"turbo": "^2.1.0"
},
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"secp256k1": "^>=5.0.1"
}
},
"engines": {
"node": ">=18"
},
"name": "across-toolkit"
}
}
7 changes: 6 additions & 1 deletion packages/eslint-config/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const project = resolve(process.cwd(), "tsconfig.json");

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
extends: [
"eslint:recommended",
"prettier",
"turbo",
"plugin:@typescript-eslint/recommended",
],
plugins: ["only-warn"],
env: {
node: true,
Expand Down
6 changes: 4 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"react-internal.js"
],
"devDependencies": {
"typescript": "^5.3.3"
},
"dependencies": {
"@next/eslint-plugin-next": "^14.1.4",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vercel/style-guide": "^5.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.0",
"eslint-plugin-only-warn": "^1.1.0",
"typescript": "^5.3.3"
"eslint-plugin-only-warn": "^1.1.0"
}
}
11 changes: 0 additions & 11 deletions packages/sdk/.eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions packages/sdk/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"root": true,
"extends": ["@across-toolkit/eslint-config/library.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
},
"env": {
"es2020": true
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you know if there is some rule to enforce the .js extension when importing? 🤔

Copy link
Collaborator Author

@gsteenkamp89 gsteenkamp89 Nov 5, 2024

Choose a reason for hiding this comment

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

I believe TSC will complain if you don't do it, while "module" is set to "NodeNext" in the tsconfig.

Screenshot 2024-11-05 at 10 43 49

21 changes: 8 additions & 13 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "@across-protocol/app-sdk",
"version": "0.0.3",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"main": "./dist/index.js",
"type": "module",
"description": "The official SDK for integrating Across bridge into your dapp.",
"keywords": [
"bridge",
Expand All @@ -23,22 +22,22 @@
"sideEffects": false,
"license": "MIT",
"files": [
"dist/**"
"dist"
],
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "tsup src/index.ts --format esm --dts",
"dev": "tsup src/index.ts --format esm --watch --dts",
"build": "tsc --project tsconfig.build.json",
"dev": "tsc --watch --project tsconfig.build.json",
"lint": "pnpm run type-check && eslint \"src/**/*.ts*\"",
"type-check": "tsc --project tsconfig.json",
"format": "prettier --write .",
"check-format": "prettier --check .",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"type-check": "tsc",
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
"test": "vitest run --config ./vitest.config.mts",
"ci": "pnpm run build && pnpm run check-exports pnpm npm run lint && pnpm run test",
"test": "vitest run --config ./vitest.config.ts",
"ci": "pnpm run build && pnpm run check-exports && pnpm run lint && pnpm run test",
"typedoc": "typedoc --out docs src/index.ts"
},
"devDependencies": {
Expand All @@ -51,7 +50,6 @@
"msw": "^2.4.9",
"prettier": "^3.2.5",
"prool": "^0.0.16",
"tsup": "^8.0.2",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.8",
"typescript": "^5.3.3",
Expand All @@ -63,8 +61,5 @@
},
"peerDependencies": {
"viem": "^2.20.1"
},
"dependencies": {
"@across-protocol/constants": "^3.1.15"
pxrl marked this conversation as resolved.
Show resolved Hide resolved
}
}
17 changes: 10 additions & 7 deletions packages/sdk/src/actions/executeQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import {
SimulateContractReturnType,
TransactionReceipt,
} from "viem";
import { Quote } from "./getQuote";
import { simulateDepositTx } from "./simulateDepositTx";
import { LoggerT } from "../utils";
import { simulateApproveTx } from "./simulateApproveTx";
import { DepositStatus, waitForDepositTx } from "./waitForDepositTx";
import { ConfiguredPublicClient, ConfiguredWalletClient } from "../types";
import { waitForFillTx } from "./waitForFillTx";
import { Quote } from "./getQuote.js";
import { simulateDepositTx } from "./simulateDepositTx.js";
import { LoggerT } from "../utils/index.js";
import { simulateApproveTx } from "./simulateApproveTx.js";
import { DepositStatus, waitForDepositTx } from "./waitForDepositTx.js";
import {
ConfiguredPublicClient,
ConfiguredWalletClient,
} from "../types/index.js";
import { waitForFillTx } from "./waitForFillTx.js";

export type ExecutionProgress = TransactionProgress;

Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/getAvailableRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from "viem";
import { LoggerT, fetchAcrossApi } from "../utils";
import { Route } from "../types";
import { MAINNET_API_URL } from "../constants";
import { LoggerT, fetchAcrossApi } from "../utils/index.js";
import { Route } from "../types/index.js";
import { MAINNET_API_URL } from "../constants/index.js";

export type RoutesQueryParams = Partial<{
/**
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/actions/getDeposit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Address, Hex, isHash } from "viem";
import { getDepositFromLogs } from "./getDepositFromLogs";
import { ConfiguredPublicClient, Deposit } from "../types";
import { getFillByDepositTx } from "./getFillByDepositTx";
import { NoFillLogError } from "../errors";
import { getDepositFromLogs } from "./getDepositFromLogs.js";
import { ConfiguredPublicClient, Deposit } from "../types/index.js";
import { getFillByDepositTx } from "./getFillByDepositTx.js";
import { NoFillLogError } from "../errors/index.js";

export type GetDepositParams = {
originChainClient: ConfiguredPublicClient;
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/actions/getDepositFromLogs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, parseEventLogs, TransactionReceipt } from "viem";
import { spokePoolAbi } from "../abis/SpokePool";
import { Deposit } from "../types";
import { spokePoolAbi } from "../abis/SpokePool.js";
import { Deposit } from "../types/index.js";

export type GetDepositLogsParams = {
originChainId: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/actions/getFillByDepositTx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchIndexerApi, LoggerT } from "../utils";
import { fetchIndexerApi, LoggerT } from "../utils/index.js";
import {
Address,
Hash,
Expand All @@ -8,9 +8,9 @@ import {
PublicClient,
TransactionReceipt,
} from "viem";
import { MAINNET_INDEXER_API } from "../constants";
import { NoFillLogError } from "../errors";
import { IndexerStatusResponse } from "../types";
import { MAINNET_INDEXER_API } from "../constants/index.js";
import { NoFillLogError } from "../errors/index.js";
import { IndexerStatusResponse } from "../types/index.js";

export type GetFillByDepositTxParams = {
deposit: {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/getLimits.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address, Hex } from "viem";
import { fetchAcrossApi, LoggerT } from "../utils";
import { MAINNET_API_URL } from "../constants";
import { Amount } from "../types";
import { fetchAcrossApi, LoggerT } from "../utils/index.js";
import { MAINNET_API_URL } from "../constants/index.js";
import { Amount } from "../types/index.js";

type LimitsQueryParams = {
originChainId: number;
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/getQuote.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Address, Hex } from "viem";
import { Amount, CrossChainAction } from "../types";
import { Amount, CrossChainAction } from "../types/index.js";
import {
getMultiCallHandlerAddress,
buildMulticallHandlerMessage,
LoggerT,
} from "../utils";
import { getSuggestedFees } from "./getSuggestedFees";
} from "../utils/index.js";
import { getSuggestedFees } from "./getSuggestedFees.js";

/**
* Params for {@link getQuote}.
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/getSuggestedFees.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from "viem";
import { LoggerT, fetchAcrossApi } from "../utils";
import { Amount } from "../types";
import { MAINNET_API_URL } from "../constants";
import { LoggerT, fetchAcrossApi } from "../utils/index.js";
import { Amount } from "../types/index.js";
import { MAINNET_API_URL } from "../constants/index.js";

export type SuggestedFeesQueryParams = {
originChainId: number;
Expand Down
26 changes: 14 additions & 12 deletions packages/sdk/src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export * from "./getSuggestedFees";
export * from "./getAvailableRoutes";
export * from "./getLimits";
export * from "./getQuote";
export * from "./simulateDepositTx";
export * from "./waitForDepositTx";
export * from "./getFillByDepositTx";
export * from "./getDeposit";
export * from "./getDepositFromLogs";
export * from "./waitForFillTx";
export * from "./simulateApproveTx";
export * from "./executeQuote";
export * from "./getSuggestedFees.js";
export * from "./getAvailableRoutes.js";
export * from "./getLimits.js";
export * from "./getQuote.js";
export * from "./simulateDepositTx.js";
export * from "./waitForDepositTx.js";
export * from "./getFillByDepositTx.js";
export * from "./getDeposit.js";
export * from "./getDepositFromLogs.js";
export * from "./waitForFillTx.js";
export * from "./simulateApproveTx.js";
export * from "./executeQuote.js";
export * from "./simulateUpdateDepositTx.js";
export * from "./signUpdateDeposit.js";
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/signUpdateDeposit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address, Hex, WalletClient } from "viem";
import { getUpdateDepositTypedData } from "../utils";
// eslint-disable-next-line no-unused-vars
import { simulateUpdateDepositTx } from "./simulateUpdateDepositTx";
import { getUpdateDepositTypedData } from "../utils/index.js";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { simulateUpdateDepositTx } from "./simulateUpdateDepositTx.js";

export type SignUpdateDepositTypedDataParams = {
walletClient: WalletClient;
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/simulateDepositTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
WalletClient,
zeroAddress,
} from "viem";
import { Quote } from "./getQuote";
import { getIntegratorDataSuffix, LoggerT } from "../utils";
import { spokePoolAbi } from "../abis/SpokePool";
import { Quote } from "./getQuote.js";
import { getIntegratorDataSuffix, LoggerT } from "../utils/index.js";
import { spokePoolAbi } from "../abis/SpokePool.js";

export type SimulateDepositTxParams = {
walletClient: WalletClient;
Expand Down
12 changes: 6 additions & 6 deletions packages/sdk/src/actions/simulateUpdateDepositTx.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Address, Hex, SimulateContractReturnType, WalletClient } from "viem";
import { getQuote } from "./getQuote";
import { LoggerT } from "../utils";
import { spokePoolAbi } from "../abis/SpokePool";
import { ConfiguredPublicClient, CrossChainAction } from "../types";
import { getDeposit } from "./getDeposit";
import { signUpdateDepositTypedData } from "./signUpdateDeposit";
import { getQuote } from "./getQuote.js";
import { LoggerT } from "../utils/index.js";
import { spokePoolAbi } from "../abis/SpokePool.js";
import { ConfiguredPublicClient, CrossChainAction } from "../types/index.js";
import { getDeposit } from "./getDeposit.js";
import { signUpdateDepositTypedData } from "./signUpdateDeposit.js";

export type SimulateUpdateDepositTxParams = {
walletClient: WalletClient;
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/actions/waitForDepositTx.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Hash, TransactionReceipt } from "viem";
import { getDepositFromLogs } from "./getDepositFromLogs";
import { NoDepositLogError } from "../errors";
import { ConfiguredPublicClient } from "../types";
import { getDepositFromLogs } from "./getDepositFromLogs.js";
import { NoDepositLogError } from "../errors/index.js";
import { ConfiguredPublicClient } from "../types/index.js";

export type WaitForDepositTxParams = {
transactionHash: Hash;
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/actions/waitForFillTx.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Address, Hash, Hex, parseEventLogs } from "viem";
import { ConfiguredPublicClient } from "../types";
import { spokePoolAbi } from "../abis/SpokePool";
import { FillStatus, waitForFillByDepositTx } from "./getFillByDepositTx";
import { LoggerT, MulticallHandlerAbi } from "../utils";
import { ConfiguredPublicClient } from "../types/index.js";
import { spokePoolAbi } from "../abis/SpokePool.js";
import { FillStatus, waitForFillByDepositTx } from "./getFillByDepositTx.js";
import { LoggerT, MulticallHandlerAbi } from "../utils/index.js";

export type WaitForFillTxParams = {
depositId: number;
Expand Down
Loading