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
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

16 changes: 7 additions & 9 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"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",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"description": "The official SDK for integrating Across bridge into your dapp.",
"keywords": [
"bridge",
Expand All @@ -29,13 +30,14 @@
"node": ">=18.0.0"
},
"scripts": {
"build": "tsup src/index.ts --format esm --dts",
"build:esm": "tsc --project tsconfig.build.json",
"build": "pnpm run build:esm",
"dev": "tsup src/index.ts --format esm --watch --dts",
"lint": "pnpm run type-check && eslint \"src/**/*.ts*\"",
"type-check": "tsc",
"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",
Expand All @@ -51,7 +53,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 +64,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
pxrl marked this conversation as resolved.
Show resolved Hide resolved
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
24 changes: 10 additions & 14 deletions packages/sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ import {
executeQuote,
GetDepositParams,
GetFillByDepositTxParams,
} from "./actions";
simulateUpdateDepositTx,
SimulateUpdateDepositTxParams,
signUpdateDepositTypedData,
SignUpdateDepositTypedDataParams,
} from "./actions/index.js";
import {
MAINNET_API_URL,
MAINNET_INDEXER_API,
TESTNET_API_URL,
TESTNET_INDEXER_API,
} from "./constants";
} from "./constants/index.js";
import {
LogLevel,
DefaultLogger,
Expand All @@ -47,27 +51,19 @@ import {
TenderlySimulateTxParams,
assertValidIntegratorId,
AcrossChain,
} from "./utils";
} from "./utils/index.js";
import {
AcrossApiSimulationError,
ConfigError,
SimulationError,
} from "./errors";
} from "./errors/index.js";
import {
ChainInfoMap,
ConfiguredPublicClient,
ConfiguredPublicClientMap,
ConfiguredWalletClient,
} from "./types";
import {
simulateUpdateDepositTx,
SimulateUpdateDepositTxParams,
} from "./actions/simulateUpdateDepositTx";
import {
signUpdateDepositTypedData,
SignUpdateDepositTypedDataParams,
} from "./actions/signUpdateDeposit";
import { MakeOptional } from "./utils/typeUtils";
} from "./types/index.js";
import { MakeOptional } from "./utils/index.js";

const CLIENT_DEFAULTS = {
pollingInterval: 3_000,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, Hash, Hex } from "viem";
import { AcrossErrorCodeType } from "./acrossApi";
import { AcrossErrorCodeType } from "./acrossApi.js";

export type { AcrossErrorCodeType };

Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./client";
export * from "./types";
export * from "./actions";
export * from "./errors";
export * from "./utils";
export * from "./client.js";
export * from "./types/index.js";
export * from "./actions/index.js";
export * from "./errors/index.js";
export * from "./utils/index.js";
8 changes: 4 additions & 4 deletions packages/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
Transport,
WalletClient,
} from "viem";
import { STATUS } from "../constants";
import { AcrossChain } from "../utils/getSupportedChains";
import { spokePoolAbi } from "../abis/SpokePool";
import { NoNullValuesOfObject } from "../utils/typeUtils";
import { STATUS } from "../constants/index.js";
import { AcrossChain } from "../utils/getSupportedChains.js";
import { spokePoolAbi } from "../abis/SpokePool.js";
import { NoNullValuesOfObject } from "../utils/index.js";

export type Status = keyof typeof STATUS;

Expand Down
Loading
Loading