diff --git a/.size-limit.json b/.size-limit.json index 0706a568..b15afc33 100644 --- a/.size-limit.json +++ b/.size-limit.json @@ -1,19 +1,19 @@ [ { "name": "core (esm)", - "path": "./packages/core/_esm/index.js", - "limit": "100 kB", + "path": "./dist/_esm/index.js", + "limit": "5 kB", "import": "*" }, { "name": "core (cjs)", - "path": "./packages/core/_cjs/index.js", - "limit": "200 kB" + "path": "./dist/_cjs/index.js", + "limit": "10 kB" }, { "name": "core (tree-shaking)", - "path": "./packages/core/_esm/index.js", - "limit": "100 kB", + "path": "./dist/_esm/index.js", + "limit": "5 kB", "import": "{ createSmartAccount }" } ] diff --git a/bun.lockb b/bun.lockb index 364d1b08..74579e7a 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index ce20c9dd..4199a5d7 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,14 @@ { - "workspaces": ["packages/*"], "type": "module", - "name": "sdk", + "main": "./dist/_cjs/index.js", + "module": "./dist/_esm/index.js", + "types": "./dist/_types/index.d.ts", + "typings": "./dist/_types/index.d.ts", + "homepage": "https://biconomy.io", + "sideEffects": false, + "name": "@biconomy/core", "author": "Biconomy", - "version": "1.0.0", + "version": "0.0.1", "description": "sdk for account abstraction, smart accounts, erc-4337 and erc-7579.", "keywords": [ "erc-7579", @@ -12,18 +17,44 @@ "biconomy", "sdk" ], - "sideEffects": false, "license": "MIT", - "scope": "@biconomy", + "repository": "github:bcnmy/sdk", + "exports": { + ".": { + "types": "./dist/_types/index.d.ts", + "import": "./dist/_esm/index.js", + "default": "./dist/_cjs/index.js" + }, + "./account": { + "types": "./_types/account/index.d.ts", + "import": "./_esm/account/index.js", + "default": "./_cjs/account/index.js" + }, + "./bundler": { + "types": "./_types/bundler/index.d.ts", + "import": "./_esm/bundler/index.js", + "default": "./_cjs/bundler/index.js" + }, + "./paymaster": { + "types": "./_types/paymaster/index.d.ts", + "import": "./_esm/paymaster/index.js", + "default": "./_cjs/paymaster/index.js" + }, + "./modules": { + "types": "./_types/modules/index.d.ts", + "import": "./_esm/modules/index.js", + "default": "./_cjs/modules/index.js" + } + }, "scripts": { "format": "biome format . --write", "lint": "biome check .", "lint:fix": "bun run lint --apply", "build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types", - "build:cjs": "tsc --project ./tsconfig/tsconfig.cjs.json && tsc-alias -p ./tsconfig/tsconfig.cjs.json && echo > ./packages/core/_cjs/package.json '{\"type\":\"commonjs\"}'", - "build:esm": "tsc --project ./tsconfig/tsconfig.esm.json && tsc-alias -p ./tsconfig/tsconfig.esm.json && echo > ./packages/core/_esm/package.json '{\"type\": \"module\",\"sideEffects\":false}'", + "build:cjs": "tsc --project ./tsconfig/tsconfig.cjs.json && tsc-alias -p ./tsconfig/tsconfig.cjs.json && echo > ./dist/_cjs/package.json '{\"type\":\"commonjs\"}'", + "build:esm": "tsc --project ./tsconfig/tsconfig.esm.json && tsc-alias -p ./tsconfig/tsconfig.esm.json && echo > ./dist/_esm/package.json '{\"type\": \"module\",\"sideEffects\":false}'", "build:types": "tsc --project ./tsconfig/tsconfig.types.json && tsc-alias -p ./tsconfig/tsconfig.types.json", - "clean": "rimraf ./packages/core/_esm ./packages/core/_cjs ./packages/core/_types ./packages/core/tsconfig", + "clean": "rimraf ./src/_esm ./src/_cjs ./src/_types ./src/tsconfig", "test": "vitest dev -c ./tests/vitest.config.ts", "test:ci": "CI=true vitest -c ./tests/vitest.config.ts --coverage", "size": "size-limit", @@ -51,7 +82,8 @@ "vitest": "^1.3.1" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "^5", + "viem": "^2" }, "commitlint": { "extends": ["@commitlint/config-conventional"] diff --git a/packages/core/package.json b/packages/core/package.json deleted file mode 100644 index eb8510c5..00000000 --- a/packages/core/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@biconomy/core", - "version": "0.0.1", - "author": "Biconomy", - "homepage": "https://biconomy.io", - "repository": "github:bcnmy/sdk", - "main": "./_cjs/index.js", - "module": "./_esm/index.js", - "types": "./_types/index.d.ts", - "typings": "./_types/index.d.ts", - "type": "module", - "sideEffects": false, - "description": "A utility library for working with erc-7579", - "keywords": ["erc-7579", "smart account"], - "license": "MIT", - "exports": { - ".": { - "types": "./_types/index.d.ts", - "import": "./_esm/index.js", - "default": "./_cjs/index.js" - }, - "./core": { - "types": "./_types/core/index.d.ts", - "import": "./_esm/core/index.js", - "default": "./_cjs/core/index.js" - } - }, - "peerDependencies": { - "viem": "^2" - } -} diff --git a/packages/core/account/actions/getAccountAddress.ts b/src/account/actions/getAccountAddress.ts similarity index 100% rename from packages/core/account/actions/getAccountAddress.ts rename to src/account/actions/getAccountAddress.ts diff --git a/packages/core/account/actions/sendTransaction.ts b/src/account/actions/sendTransaction.ts similarity index 100% rename from packages/core/account/actions/sendTransaction.ts rename to src/account/actions/sendTransaction.ts diff --git a/packages/core/account/createSmartAccount.ts b/src/account/createSmartAccount.ts similarity index 100% rename from packages/core/account/createSmartAccount.ts rename to src/account/createSmartAccount.ts diff --git a/packages/core/account/index.ts b/src/account/index.ts similarity index 100% rename from packages/core/account/index.ts rename to src/account/index.ts diff --git a/packages/core/account/utils/abis.ts b/src/account/utils/abis.ts similarity index 100% rename from packages/core/account/utils/abis.ts rename to src/account/utils/abis.ts diff --git a/packages/core/account/utils/constants.ts b/src/account/utils/constants.ts similarity index 100% rename from packages/core/account/utils/constants.ts rename to src/account/utils/constants.ts diff --git a/packages/core/account/utils/errors.ts b/src/account/utils/errors.ts similarity index 100% rename from packages/core/account/utils/errors.ts rename to src/account/utils/errors.ts diff --git a/packages/core/account/utils/helpers.ts b/src/account/utils/helpers.ts similarity index 100% rename from packages/core/account/utils/helpers.ts rename to src/account/utils/helpers.ts diff --git a/packages/core/account/utils/types.ts b/src/account/utils/types.ts similarity index 100% rename from packages/core/account/utils/types.ts rename to src/account/utils/types.ts diff --git a/packages/core/bundler/actions/chainId.ts b/src/bundler/actions/chainId.ts similarity index 100% rename from packages/core/bundler/actions/chainId.ts rename to src/bundler/actions/chainId.ts diff --git a/packages/core/bundler/actions/index.ts b/src/bundler/actions/index.ts similarity index 100% rename from packages/core/bundler/actions/index.ts rename to src/bundler/actions/index.ts diff --git a/packages/core/bundler/createBundlerClient.ts b/src/bundler/createBundlerClient.ts similarity index 100% rename from packages/core/bundler/createBundlerClient.ts rename to src/bundler/createBundlerClient.ts diff --git a/src/bundler/index.ts b/src/bundler/index.ts new file mode 100644 index 00000000..6d0ca3a9 --- /dev/null +++ b/src/bundler/index.ts @@ -0,0 +1,4 @@ +export type { BundlerRpcSchema, BundlerActions } from "./actions/index.js" +export { bundlerActions } from "./actions/index.js" +export { extractChainIdFromBundlerUrl } from "./utils/helpers.js" +export { createBundlerClient } from "./createBundlerClient.js" diff --git a/packages/core/bundler/utils/helpers.ts b/src/bundler/utils/helpers.ts similarity index 100% rename from packages/core/bundler/utils/helpers.ts rename to src/bundler/utils/helpers.ts diff --git a/packages/core/index.ts b/src/index.ts similarity index 100% rename from packages/core/index.ts rename to src/index.ts diff --git a/packages/core/modules/ecdsaOwnershipValidationModule/createECDSAOwnershipModule.ts b/src/modules/ecdsaOwnershipValidationModule/createECDSAOwnershipModule.ts similarity index 100% rename from packages/core/modules/ecdsaOwnershipValidationModule/createECDSAOwnershipModule.ts rename to src/modules/ecdsaOwnershipValidationModule/createECDSAOwnershipModule.ts diff --git a/packages/core/modules/index.ts b/src/modules/index.ts similarity index 100% rename from packages/core/modules/index.ts rename to src/modules/index.ts diff --git a/packages/core/modules/sessionKeyManagerModule/createSessionKeyManagerModule.ts b/src/modules/sessionKeyManagerModule/createSessionKeyManagerModule.ts similarity index 100% rename from packages/core/modules/sessionKeyManagerModule/createSessionKeyManagerModule.ts rename to src/modules/sessionKeyManagerModule/createSessionKeyManagerModule.ts diff --git a/packages/core/modules/utils/types.ts b/src/modules/utils/types.ts similarity index 100% rename from packages/core/modules/utils/types.ts rename to src/modules/utils/types.ts diff --git a/packages/core/paymaster/actions/sponsorUserOp.ts b/src/paymaster/actions/sponsorUserOp.ts similarity index 100% rename from packages/core/paymaster/actions/sponsorUserOp.ts rename to src/paymaster/actions/sponsorUserOp.ts diff --git a/packages/core/paymaster/createPaymasterClient.ts b/src/paymaster/createPaymasterClient.ts similarity index 100% rename from packages/core/paymaster/createPaymasterClient.ts rename to src/paymaster/createPaymasterClient.ts diff --git a/tests/account.test.ts b/tests/account.test.ts index 070b30cd..152750d3 100644 --- a/tests/account.test.ts +++ b/tests/account.test.ts @@ -14,11 +14,11 @@ import { type UserOperationStruct, createSmartAccount, walletClientToSmartAccountSigner -} from "../packages/core/account/index.js" -import { DEFAULT_ECDSA_OWNERSHIP_MODULE } from "../packages/core/account/utils/constants.js" -import { SignTransactionNotSupportedBySmartAccount } from "../packages/core/account/utils/errors.js" -import { getChain } from "../packages/core/account/utils/helpers.js" -import { extractChainIdFromBundlerUrl } from "../packages/core/bundler/utils/helpers.js" +} from "../src/account/index.js" +import { DEFAULT_ECDSA_OWNERSHIP_MODULE } from "../src/account/utils/constants.js" +import { SignTransactionNotSupportedBySmartAccount } from "../src/account/utils/errors.js" +import { getChain } from "../src/account/utils/helpers.js" +import { extractChainIdFromBundlerUrl } from "../src/bundler/utils/helpers.js" describe("Biconomy Smart Account core tests", () => { let smartAccount: Awaited> diff --git a/tests/bundler.test.ts b/tests/bundler.test.ts index 2ec95693..31af074b 100644 --- a/tests/bundler.test.ts +++ b/tests/bundler.test.ts @@ -2,9 +2,9 @@ import { http } from "viem" import { describe, expect, it } from "vitest" import { privateKeyToAccount } from "viem/accounts" -import { getChain } from "../packages/core/account/utils/helpers.js" -import { createBundlerClient } from "../packages/core/bundler/createBundlerClient.js" -import { extractChainIdFromBundlerUrl } from "../packages/core/bundler/utils/helpers.js" +import { getChain } from "../src/account/utils/helpers.js" +import { createBundlerClient } from "../src/bundler/createBundlerClient.js" +import { extractChainIdFromBundlerUrl } from "../src/bundler/utils/helpers.js" describe("Bundler tests", () => { const bundlerUrl = process.env.BUNDLER_URL ?? "" diff --git a/tests/modules/ecdsaOwnershipModule.test.ts b/tests/modules/ecdsaOwnershipModule.test.ts index a68c1d18..170a70d9 100644 --- a/tests/modules/ecdsaOwnershipModule.test.ts +++ b/tests/modules/ecdsaOwnershipModule.test.ts @@ -11,10 +11,10 @@ import { privateKeyToAccount } from "viem/accounts" import { createSmartAccount, walletClientToSmartAccountSigner -} from "../../packages/core/account/index.js" -import { DEFAULT_ECDSA_OWNERSHIP_MODULE } from "../../packages/core/account/utils/constants.js" -import { getChain } from "../../packages/core/account/utils/helpers.js" -import { extractChainIdFromBundlerUrl } from "../../packages/core/bundler/utils/helpers.js" +} from "../../src/account/index.js" +import { DEFAULT_ECDSA_OWNERSHIP_MODULE } from "../../src/account/utils/constants.js" +import { getChain } from "../../src/account/utils/helpers.js" +import { extractChainIdFromBundlerUrl } from "../../src/bundler/utils/helpers.js" describe("Biconomy Smart Account core tests", () => { let smartAccount: Awaited> diff --git a/tests/tsconfig.json b/tests/tsconfig.json deleted file mode 100644 index 29f3c4fc..00000000 --- a/tests/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../tsconfig/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "target": "ESNext", - "types": ["bun-types"], - "baseUrl": ".", - } -} \ No newline at end of file diff --git a/tests/vitest.config.ts b/tests/vitest.config.ts index 70ad0ce6..5c7c1e71 100644 --- a/tests/vitest.config.ts +++ b/tests/vitest.config.ts @@ -3,10 +3,6 @@ import { defineConfig } from "vitest/config" export default defineConfig({ test: { - alias: { - "../packages": join(__dirname, "../packages"), - "~tests": join(__dirname, ".") - }, coverage: { all: false, provider: "v8", diff --git a/tsconfig/tsconfig.base.json b/tsconfig/tsconfig.base.json index 3b1c0e93..67111566 100644 --- a/tsconfig/tsconfig.base.json +++ b/tsconfig/tsconfig.base.json @@ -2,7 +2,6 @@ "include": [], "compilerOptions": { "incremental": false, - "strict": true, "useDefineForClassFields": true, "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, @@ -20,12 +19,11 @@ "moduleResolution": "NodeNext", "module": "NodeNext", "target": "ES2021", - "lib": [ - "ES2022", - "DOM" - ], + "lib": ["ES2022"], "skipLibCheck": true, - "noErrorTruncation": true + "noErrorTruncation": true, + "noEmit": true, + "strict": true }, "tsc-alias": { "resolveFullPaths": true, diff --git a/tsconfig/tsconfig.cjs.json b/tsconfig/tsconfig.cjs.json index 81cc7615..d5607ac1 100644 --- a/tsconfig/tsconfig.cjs.json +++ b/tsconfig/tsconfig.cjs.json @@ -2,8 +2,9 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", - "outDir": "../packages/core/_cjs", + "outDir": "../dist/_cjs", "removeComments": true, "verbatimModuleSyntax": false, + "noEmit": false } } diff --git a/tsconfig/tsconfig.esm.json b/tsconfig/tsconfig.esm.json index be0716ed..136a81fc 100644 --- a/tsconfig/tsconfig.esm.json +++ b/tsconfig/tsconfig.esm.json @@ -2,6 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "es2015", - "outDir": "../packages/core/_esm" + "outDir": "../dist/_esm", + "noEmit": false } } diff --git a/tsconfig/tsconfig.json b/tsconfig/tsconfig.json index 1620dd2e..2c9c1e63 100644 --- a/tsconfig/tsconfig.json +++ b/tsconfig/tsconfig.json @@ -1,16 +1,16 @@ { "extends": "./tsconfig.base.json", "include": [ - "../packages/" + "../src/" ], "exclude": [ - "../packages/**/*.test.ts", - "../packages/**/*.test-d.ts", - "../packages/**/*.bench.ts" + "../src/**/*.test.ts", + "../src/**/*.test-d.ts", + "../src/**/*.bench.ts" ], "compilerOptions": { "moduleResolution": "node", "sourceMap": true, - "rootDir": "../packages/core" + "rootDir": "../src" } } \ No newline at end of file diff --git a/tsconfig/tsconfig.types.json b/tsconfig/tsconfig.types.json index 86759c16..bb70b996 100644 --- a/tsconfig/tsconfig.types.json +++ b/tsconfig/tsconfig.types.json @@ -2,10 +2,11 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "esnext", - "outDir": "../packages/core/_esm", - "declarationDir": "../packages/core/_types", + "outDir": "../dist/_esm", + "declarationDir": "../dist/_types", "emitDeclarationOnly": true, "declaration": true, - "declarationMap": true + "declarationMap": true, + "noEmit": false } } diff --git a/typedoc.json b/typedoc.json index 550cc42c..6a717b22 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,8 +1,8 @@ { "$schema": "https://typedoc.org/schema.json", - "entryPoints": ["packages/core/index.ts"], - "basePath": "packages", - "includes": "packages", + "entryPoints": ["src/index.ts"], + "basePath": "src", + "includes": "src", "out": "docs", "gitRevision": "main" }