diff --git a/packages/onchain/package.json b/packages/onchain/package.json index b146bd6..e6e1d2a 100644 --- a/packages/onchain/package.json +++ b/packages/onchain/package.json @@ -26,6 +26,9 @@ "clean": "rimraf ./dist", "typecheck": "tsc --noEmit" }, + "devDependencies": { + "@coinbase-platform/utils": "workspace:*" + }, "peerDependencies": { "typescript": ">=5.0.4" }, diff --git a/packages/onchain/src/address/list-address-transactions.test.ts b/packages/onchain/src/address/list-address-transactions.test.ts index ef7d4fb..70ee26b 100644 --- a/packages/onchain/src/address/list-address-transactions.test.ts +++ b/packages/onchain/src/address/list-address-transactions.test.ts @@ -1,5 +1,5 @@ import { describe, test } from "vitest"; -import { RPC_URL } from "../constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { createRpcClient } from "../rpc"; import { listAddressTransactions } from "./list-address-transactions"; diff --git a/packages/onchain/src/balance/list-balance-details.test.ts b/packages/onchain/src/balance/list-balance-details.test.ts index 987d398..4830330 100644 --- a/packages/onchain/src/balance/list-balance-details.test.ts +++ b/packages/onchain/src/balance/list-balance-details.test.ts @@ -1,5 +1,5 @@ import { describe, test } from "vitest"; -import { RPC_URL } from "../constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { createRpcClient } from "../rpc"; import { listBalanceDetails } from "./list-balance-details"; diff --git a/packages/onchain/src/balance/list-balance-histories.test.ts b/packages/onchain/src/balance/list-balance-histories.test.ts index c044f93..427b5f9 100644 --- a/packages/onchain/src/balance/list-balance-histories.test.ts +++ b/packages/onchain/src/balance/list-balance-histories.test.ts @@ -1,5 +1,5 @@ import { describe, test } from "vitest"; -import { RPC_URL } from "../constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { createRpcClient } from "../rpc"; import { listBalanceHistories } from "./list-balance-histories"; diff --git a/packages/onchain/src/balance/list-balances.test.ts b/packages/onchain/src/balance/list-balances.test.ts index 63f2b46..615c68c 100644 --- a/packages/onchain/src/balance/list-balances.test.ts +++ b/packages/onchain/src/balance/list-balances.test.ts @@ -1,5 +1,5 @@ import { describe, test } from "vitest"; -import { RPC_URL } from "../constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { createRpcClient } from "../rpc"; import { listBalances } from "./list-balances"; diff --git a/packages/onchain/src/mocks/address.ts b/packages/onchain/src/mocks/address.ts index 62e6504..19f57ca 100644 --- a/packages/onchain/src/mocks/address.ts +++ b/packages/onchain/src/mocks/address.ts @@ -1,6 +1,6 @@ import { http, HttpResponse } from "msw"; import type { DefaultBodyType, PathParams } from "msw"; -import { RPC_URL } from "../constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { withRpcMethod } from "./predicates"; export const handlers = [ diff --git a/packages/onchain/src/mocks/balance.ts b/packages/onchain/src/mocks/balance.ts index d9c3bbe..9121e63 100644 --- a/packages/onchain/src/mocks/balance.ts +++ b/packages/onchain/src/mocks/balance.ts @@ -1,6 +1,6 @@ import { http, HttpResponse } from "msw"; import type { DefaultBodyType, PathParams } from "msw"; -import { RPC_URL } from "../constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { withRpcMethod } from "./predicates"; export const handlers = [ diff --git a/packages/onchain/src/rpc.test.ts b/packages/onchain/src/rpc.test.ts index 08b50ea..a592a9c 100644 --- a/packages/onchain/src/rpc.test.ts +++ b/packages/onchain/src/rpc.test.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from "vitest"; -import { RPC_URL } from "./constants"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; import { createRpcClient } from "./rpc"; describe("rpc", () => { diff --git a/packages/onchain/src/rpc.ts b/packages/onchain/src/rpc.ts index 51aabbb..2ff475a 100644 --- a/packages/onchain/src/rpc.ts +++ b/packages/onchain/src/rpc.ts @@ -1,5 +1,5 @@ -import { RPC_URL } from "./constants"; -import * as http from "./http"; +import { RPC_URL } from "@coinbase-platform/utils/constants"; +import * as http from "@coinbase-platform/utils/http"; export type RpcClient = { __url: string; diff --git a/packages/onchain/src/constants.ts b/packages/utils/constants.ts similarity index 100% rename from packages/onchain/src/constants.ts rename to packages/utils/constants.ts diff --git a/packages/onchain/src/http.ts b/packages/utils/http.ts similarity index 100% rename from packages/onchain/src/http.ts rename to packages/utils/http.ts diff --git a/packages/utils/package.json b/packages/utils/package.json new file mode 100644 index 0000000..3360d7f --- /dev/null +++ b/packages/utils/package.json @@ -0,0 +1,25 @@ +{ + "name": "@coinbase-platform/utils", + "version": "0.0.0", + "description": "Coinbase Platform Utils package", + "author": "roushou ", + "license": "MIT", + "private": true, + "homepage": "https://github.com/roushou/coinbase-platform#readme", + "type": "module", + "files": ["src"], + "scripts": { + "typecheck": "tsc --noEmit" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + }, + "engine": { + "node": "^18.0.0 || >=20.0.0" + } +} diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json new file mode 100644 index 0000000..53858a2 --- /dev/null +++ b/packages/utils/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "allowJs": false, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": true, + "noUnusedParameters": true, + "noPropertyAccessFromIndexSignature": false + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d791f17..6fa57c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,16 @@ importers: typescript: specifier: '>=5.0.4' version: 5.4.5 + devDependencies: + '@coinbase-platform/utils': + specifier: workspace:* + version: link:../utils + + packages/utils: + dependencies: + typescript: + specifier: '>=5.0.4' + version: 5.4.5 packages: