Skip to content

Commit f5633db

Browse files
authored
simplify tsconfig, build & lint (#72)
* simplify tsconfig, build & lint * fix * build with tsc only * resolve modules without a bundler * include test folder in type checking in lint step * no unused locals in sdk only * fix ci script * small fixes * fix * fix ci pipeline * ignore specific rule for unused var in signUpdateDeposit * add changeset * manually override secp256k1
1 parent f65a707 commit f5633db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1990
-2056
lines changed

.changeset/strange-mangos-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@across-protocol/app-sdk": patch
3+
---
4+
5+
Simplify build using tsc for a more tree-shakable, unbundled output.

apps/example/app/ethers/providers.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
"use client";
2-
import {
3-
useEthers,
4-
useEtherBalance,
5-
DAppProvider,
6-
Arbitrum,
7-
Config,
8-
Mainnet,
9-
} from "@usedapp/core";
2+
import { DAppProvider, Arbitrum, Config, Mainnet } from "@usedapp/core";
103
import * as React from "react";
114
import { ThemeProvider } from "next-themes";
125

apps/example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"tailwindcss-animate": "^1.0.7",
3838
"usehooks-ts": "^3.1.0",
3939
"viem": "^2.20.1",
40-
"wagmi": "^2.12.7"
40+
"wagmi": "^2.12.25"
4141
},
4242
"devDependencies": {
4343
"@across-toolkit/eslint-config": "workspace:*",

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "across-toolkit",
23
"private": true,
34
"scripts": {
45
"build": "turbo build",
@@ -19,8 +20,12 @@
1920
"turbo": "^2.1.0"
2021
},
2122
"packageManager": "[email protected]",
23+
"pnpm": {
24+
"overrides": {
25+
"secp256k1": "^>=5.0.1"
26+
}
27+
},
2228
"engines": {
2329
"node": ">=18"
24-
},
25-
"name": "across-toolkit"
30+
}
2631
}

packages/eslint-config/library.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ const project = resolve(process.cwd(), "tsconfig.json");
44

55
/** @type {import("eslint").Linter.Config} */
66
module.exports = {
7-
extends: ["eslint:recommended", "prettier", "turbo"],
7+
extends: [
8+
"eslint:recommended",
9+
"prettier",
10+
"turbo",
11+
"plugin:@typescript-eslint/recommended",
12+
],
813
plugins: ["only-warn"],
914
env: {
1015
node: true,

packages/eslint-config/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"react-internal.js"
99
],
1010
"devDependencies": {
11+
"typescript": "^5.3.3"
12+
},
13+
"dependencies": {
1114
"@next/eslint-plugin-next": "^14.1.4",
1215
"@typescript-eslint/eslint-plugin": "^7.1.0",
1316
"@typescript-eslint/parser": "^7.1.0",
1417
"@vercel/style-guide": "^5.2.0",
1518
"eslint-config-prettier": "^9.1.0",
1619
"eslint-config-turbo": "^2.0.0",
17-
"eslint-plugin-only-warn": "^1.1.0",
18-
"typescript": "^5.3.3"
20+
"eslint-plugin-only-warn": "^1.1.0"
1921
}
2022
}

packages/sdk/.eslintrc.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/sdk/.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"root": true,
3+
"extends": ["@across-toolkit/eslint-config/library.js"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"project": true
7+
},
8+
"env": {
9+
"es2020": true
10+
}
11+
}

packages/sdk/package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"name": "@across-protocol/app-sdk",
33
"version": "0.0.3",
4-
"main": "./dist/index.mjs",
5-
"module": "./dist/index.mjs",
6-
"types": "./dist/index.d.mts",
4+
"main": "./dist/index.js",
5+
"type": "module",
76
"description": "The official SDK for integrating Across bridge into your dapp.",
87
"keywords": [
98
"bridge",
@@ -23,22 +22,22 @@
2322
"sideEffects": false,
2423
"license": "MIT",
2524
"files": [
26-
"dist/**"
25+
"dist"
2726
],
2827
"engines": {
2928
"node": ">=18.0.0"
3029
},
3130
"scripts": {
32-
"build": "tsup src/index.ts --format esm --dts",
33-
"dev": "tsup src/index.ts --format esm --watch --dts",
31+
"build": "tsc --project tsconfig.build.json",
32+
"dev": "tsc --watch --project tsconfig.build.json",
3433
"lint": "pnpm run type-check && eslint \"src/**/*.ts*\"",
34+
"type-check": "tsc --project tsconfig.json",
3535
"format": "prettier --write .",
3636
"check-format": "prettier --check .",
3737
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
38-
"type-check": "tsc",
3938
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
40-
"test": "vitest run --config ./vitest.config.mts",
41-
"ci": "pnpm run build && pnpm run check-exports pnpm npm run lint && pnpm run test",
39+
"test": "vitest run --config ./vitest.config.ts",
40+
"ci": "pnpm run build && pnpm run check-exports && pnpm run lint && pnpm run test",
4241
"typedoc": "typedoc --out docs src/index.ts"
4342
},
4443
"devDependencies": {
@@ -51,7 +50,6 @@
5150
"msw": "^2.4.9",
5251
"prettier": "^3.2.5",
5352
"prool": "^0.0.16",
54-
"tsup": "^8.0.2",
5553
"typedoc": "^0.26.7",
5654
"typedoc-plugin-markdown": "^4.2.8",
5755
"typescript": "^5.3.3",
@@ -63,8 +61,5 @@
6361
},
6462
"peerDependencies": {
6563
"viem": "^2.20.1"
66-
},
67-
"dependencies": {
68-
"@across-protocol/constants": "^3.1.15"
6964
}
7065
}

packages/sdk/src/actions/executeQuote.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import {
66
SimulateContractReturnType,
77
TransactionReceipt,
88
} from "viem";
9-
import { Quote } from "./getQuote";
10-
import { simulateDepositTx } from "./simulateDepositTx";
11-
import { LoggerT } from "../utils";
12-
import { simulateApproveTx } from "./simulateApproveTx";
13-
import { DepositStatus, waitForDepositTx } from "./waitForDepositTx";
14-
import { ConfiguredPublicClient, ConfiguredWalletClient } from "../types";
15-
import { waitForFillTx } from "./waitForFillTx";
9+
import { Quote } from "./getQuote.js";
10+
import { simulateDepositTx } from "./simulateDepositTx.js";
11+
import { LoggerT } from "../utils/index.js";
12+
import { simulateApproveTx } from "./simulateApproveTx.js";
13+
import { DepositStatus, waitForDepositTx } from "./waitForDepositTx.js";
14+
import {
15+
ConfiguredPublicClient,
16+
ConfiguredWalletClient,
17+
} from "../types/index.js";
18+
import { waitForFillTx } from "./waitForFillTx.js";
1619

1720
export type ExecutionProgress = TransactionProgress;
1821

packages/sdk/src/actions/getAvailableRoutes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Address } from "viem";
2-
import { LoggerT, fetchAcrossApi } from "../utils";
3-
import { Route } from "../types";
4-
import { MAINNET_API_URL } from "../constants";
2+
import { LoggerT, fetchAcrossApi } from "../utils/index.js";
3+
import { Route } from "../types/index.js";
4+
import { MAINNET_API_URL } from "../constants/index.js";
55

66
export type RoutesQueryParams = Partial<{
77
/**

packages/sdk/src/actions/getDeposit.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Address, Hex, isHash } from "viem";
2-
import { getDepositFromLogs } from "./getDepositFromLogs";
3-
import { ConfiguredPublicClient, Deposit } from "../types";
4-
import { getFillByDepositTx } from "./getFillByDepositTx";
5-
import { NoFillLogError } from "../errors";
2+
import { getDepositFromLogs } from "./getDepositFromLogs.js";
3+
import { ConfiguredPublicClient, Deposit } from "../types/index.js";
4+
import { getFillByDepositTx } from "./getFillByDepositTx.js";
5+
import { NoFillLogError } from "../errors/index.js";
66

77
export type GetDepositParams = {
88
originChainClient: ConfiguredPublicClient;

packages/sdk/src/actions/getDepositFromLogs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Address, parseEventLogs, TransactionReceipt } from "viem";
2-
import { spokePoolAbi } from "../abis/SpokePool";
3-
import { Deposit } from "../types";
2+
import { spokePoolAbi } from "../abis/SpokePool.js";
3+
import { Deposit } from "../types/index.js";
44

55
export type GetDepositLogsParams = {
66
originChainId: number;

packages/sdk/src/actions/getFillByDepositTx.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fetchIndexerApi, LoggerT } from "../utils";
1+
import { fetchIndexerApi, LoggerT } from "../utils/index.js";
22
import {
33
Address,
44
Hash,
@@ -8,9 +8,9 @@ import {
88
PublicClient,
99
TransactionReceipt,
1010
} from "viem";
11-
import { MAINNET_INDEXER_API } from "../constants";
12-
import { NoFillLogError } from "../errors";
13-
import { IndexerStatusResponse } from "../types";
11+
import { MAINNET_INDEXER_API } from "../constants/index.js";
12+
import { NoFillLogError } from "../errors/index.js";
13+
import { IndexerStatusResponse } from "../types/index.js";
1414

1515
export type GetFillByDepositTxParams = {
1616
deposit: {

packages/sdk/src/actions/getLimits.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Address, Hex } from "viem";
2-
import { fetchAcrossApi, LoggerT } from "../utils";
3-
import { MAINNET_API_URL } from "../constants";
4-
import { Amount } from "../types";
2+
import { fetchAcrossApi, LoggerT } from "../utils/index.js";
3+
import { MAINNET_API_URL } from "../constants/index.js";
4+
import { Amount } from "../types/index.js";
55

66
type LimitsQueryParams = {
77
originChainId: number;

packages/sdk/src/actions/getQuote.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Address, Hex } from "viem";
2-
import { Amount, CrossChainAction } from "../types";
2+
import { Amount, CrossChainAction } from "../types/index.js";
33
import {
44
getMultiCallHandlerAddress,
55
buildMulticallHandlerMessage,
66
LoggerT,
7-
} from "../utils";
8-
import { getSuggestedFees } from "./getSuggestedFees";
7+
} from "../utils/index.js";
8+
import { getSuggestedFees } from "./getSuggestedFees.js";
99

1010
/**
1111
* Params for {@link getQuote}.

packages/sdk/src/actions/getSuggestedFees.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Address } from "viem";
2-
import { LoggerT, fetchAcrossApi } from "../utils";
3-
import { Amount } from "../types";
4-
import { MAINNET_API_URL } from "../constants";
2+
import { LoggerT, fetchAcrossApi } from "../utils/index.js";
3+
import { Amount } from "../types/index.js";
4+
import { MAINNET_API_URL } from "../constants/index.js";
55

66
export type SuggestedFeesQueryParams = {
77
originChainId: number;

packages/sdk/src/actions/index.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
export * from "./getSuggestedFees";
2-
export * from "./getAvailableRoutes";
3-
export * from "./getLimits";
4-
export * from "./getQuote";
5-
export * from "./simulateDepositTx";
6-
export * from "./waitForDepositTx";
7-
export * from "./getFillByDepositTx";
8-
export * from "./getDeposit";
9-
export * from "./getDepositFromLogs";
10-
export * from "./waitForFillTx";
11-
export * from "./simulateApproveTx";
12-
export * from "./executeQuote";
1+
export * from "./getSuggestedFees.js";
2+
export * from "./getAvailableRoutes.js";
3+
export * from "./getLimits.js";
4+
export * from "./getQuote.js";
5+
export * from "./simulateDepositTx.js";
6+
export * from "./waitForDepositTx.js";
7+
export * from "./getFillByDepositTx.js";
8+
export * from "./getDeposit.js";
9+
export * from "./getDepositFromLogs.js";
10+
export * from "./waitForFillTx.js";
11+
export * from "./simulateApproveTx.js";
12+
export * from "./executeQuote.js";
13+
export * from "./simulateUpdateDepositTx.js";
14+
export * from "./signUpdateDeposit.js";

packages/sdk/src/actions/signUpdateDeposit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Address, Hex, WalletClient } from "viem";
2-
import { getUpdateDepositTypedData } from "../utils";
3-
// eslint-disable-next-line no-unused-vars
4-
import { simulateUpdateDepositTx } from "./simulateUpdateDepositTx";
2+
import { getUpdateDepositTypedData } from "../utils/index.js";
3+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4+
import { simulateUpdateDepositTx } from "./simulateUpdateDepositTx.js";
55

66
export type SignUpdateDepositTypedDataParams = {
77
walletClient: WalletClient;

packages/sdk/src/actions/simulateDepositTx.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
WalletClient,
66
zeroAddress,
77
} from "viem";
8-
import { Quote } from "./getQuote";
9-
import { getIntegratorDataSuffix, LoggerT } from "../utils";
10-
import { spokePoolAbi } from "../abis/SpokePool";
8+
import { Quote } from "./getQuote.js";
9+
import { getIntegratorDataSuffix, LoggerT } from "../utils/index.js";
10+
import { spokePoolAbi } from "../abis/SpokePool.js";
1111

1212
export type SimulateDepositTxParams = {
1313
walletClient: WalletClient;

packages/sdk/src/actions/simulateUpdateDepositTx.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Address, Hex, SimulateContractReturnType, WalletClient } from "viem";
2-
import { getQuote } from "./getQuote";
3-
import { LoggerT } from "../utils";
4-
import { spokePoolAbi } from "../abis/SpokePool";
5-
import { ConfiguredPublicClient, CrossChainAction } from "../types";
6-
import { getDeposit } from "./getDeposit";
7-
import { signUpdateDepositTypedData } from "./signUpdateDeposit";
2+
import { getQuote } from "./getQuote.js";
3+
import { LoggerT } from "../utils/index.js";
4+
import { spokePoolAbi } from "../abis/SpokePool.js";
5+
import { ConfiguredPublicClient, CrossChainAction } from "../types/index.js";
6+
import { getDeposit } from "./getDeposit.js";
7+
import { signUpdateDepositTypedData } from "./signUpdateDeposit.js";
88

99
export type SimulateUpdateDepositTxParams = {
1010
walletClient: WalletClient;

packages/sdk/src/actions/waitForDepositTx.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Hash, TransactionReceipt } from "viem";
2-
import { getDepositFromLogs } from "./getDepositFromLogs";
3-
import { NoDepositLogError } from "../errors";
4-
import { ConfiguredPublicClient } from "../types";
2+
import { getDepositFromLogs } from "./getDepositFromLogs.js";
3+
import { NoDepositLogError } from "../errors/index.js";
4+
import { ConfiguredPublicClient } from "../types/index.js";
55

66
export type WaitForDepositTxParams = {
77
transactionHash: Hash;

packages/sdk/src/actions/waitForFillTx.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Address, Hash, Hex, parseEventLogs } from "viem";
2-
import { ConfiguredPublicClient } from "../types";
3-
import { spokePoolAbi } from "../abis/SpokePool";
4-
import { FillStatus, waitForFillByDepositTx } from "./getFillByDepositTx";
5-
import { LoggerT, MulticallHandlerAbi } from "../utils";
2+
import { ConfiguredPublicClient } from "../types/index.js";
3+
import { spokePoolAbi } from "../abis/SpokePool.js";
4+
import { FillStatus, waitForFillByDepositTx } from "./getFillByDepositTx.js";
5+
import { LoggerT, MulticallHandlerAbi } from "../utils/index.js";
66

77
export type WaitForFillTxParams = {
88
depositId: number;

0 commit comments

Comments
 (0)