diff --git a/.npmignore b/.npmignore index 1b76488..f907e87 100644 --- a/.npmignore +++ b/.npmignore @@ -5,4 +5,4 @@ src .prettierrc.json eslint.config.js jest.config.js -tsconfig.json +tsconfig.*.* diff --git a/package.json b/package.json index 7e9d873..d34ebae 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ }, "scripts": { "clean": "rimraf dist", - "build": "yarn clean && tsc", + "build": "yarn clean && tsc -p ./tsconfig.build.json", "test": "jest", - "lint": "eslint . && tsc --noEmit", + "lint": "eslint . && tsc --noEmit -p ./tsconfig.build.json", "lint:fix": "eslint . --fix", "prettier": "prettier --check '**'", "prettier:fix": "prettier --write '**'" @@ -32,6 +32,7 @@ "typescript-eslint": "^7.3.1" }, "dependencies": { + "@arktype/attest": "^0.7.0", "abitype": "^1.0.0", "ethers": "^6.11.1", "viem": "^2.9.12" diff --git a/src/v06/account/common/factoryAddress.ts b/src/v06/account/common/factoryAddress.ts new file mode 100644 index 0000000..2375135 --- /dev/null +++ b/src/v06/account/common/factoryAddress.ts @@ -0,0 +1 @@ +export const FACTORY_ADDRESS = "0x9406Cc6185a346906296840746125a0E44976454"; diff --git a/src/v06/account/common/index.ts b/src/v06/account/common/index.ts index e2a3557..e84dd57 100644 --- a/src/v06/account/common/index.ts +++ b/src/v06/account/common/index.ts @@ -1 +1,4 @@ -export * as SimpleAccount from "./simpleAccount"; +export * as SimpleAccountWithEthers from "./simpleAccountWithEthers"; +export * as SimpleAccountWithoutHoistedViemAccount from "./simpleAccountWithoutViemAccount"; +export * as SimpleAccountWithHoistedViemAccount from "./simpleAccountWithViemAccount"; +export * as SimpleAccountWithSigner from "./simpleAccountWithSigner"; diff --git a/src/v06/account/common/simpleAccount.ts b/src/v06/account/common/simpleAccount.ts deleted file mode 100644 index d4ef996..0000000 --- a/src/v06/account/common/simpleAccount.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { - Account, - Address, - Chain, - PublicClient, - Transport, - WalletClient, -} from "viem"; -import { JsonRpcProvider, Signer } from "ethers"; -import { AccountAbi, FactoryAbi } from "./abi/simpleAccount"; -import { RequiredAccountOpts } from "../types"; -import { RequestSignature } from "../hooks"; - -const FACTORY_ADDRESS = "0x9406Cc6185a346906296840746125a0E44976454"; - -export function base( - ethClient: PublicClient | JsonRpcProvider, - eoa: WalletClient, - account: Account, -): RequiredAccountOpts; -export function base( - ethClient: PublicClient | JsonRpcProvider, - eoa: WalletClient | Signer, -): RequiredAccountOpts; -export function base( - ethClient: PublicClient | JsonRpcProvider, - eoa: Signer | WalletClient, - account?: Account, -): RequiredAccountOpts { - return { - accountAbi: AccountAbi, - factoryAbi: FactoryAbi, - factoryAddress: FACTORY_ADDRESS, - ethClient, - async setFactoryData(salt, encoder) { - if (account !== undefined) { - return encoder("createAccount", [account.address, salt]); - } else if ("getAddresses" in eoa) { - return encoder("createAccount", [(await eoa.getAddresses())[0], salt]); - } else { - return encoder("createAccount", [ - (await eoa.getAddress()) as Address, - salt, - ]); - } - }, - requestSignature: - "getAddresses" in eoa - ? account !== undefined - ? RequestSignature.withViemWalletClient( - eoa as WalletClient, - account, - ) - : RequestSignature.withViemWalletClient( - eoa as WalletClient, - ) - : RequestSignature.withEthersSigner(eoa), - }; -} diff --git a/src/v06/account/common/simpleAccountWithEthers.ts b/src/v06/account/common/simpleAccountWithEthers.ts new file mode 100644 index 0000000..c892a9a --- /dev/null +++ b/src/v06/account/common/simpleAccountWithEthers.ts @@ -0,0 +1,35 @@ +import { Address } from "abitype"; +import { JsonRpcProvider, Signer } from "ethers"; +import { PublicClient, WalletClient, Transport, Chain, Account } from "viem"; +import { RequestSignature } from "../hooks"; +import { RequiredAccountOpts } from "../types"; +import { AccountAbi, FactoryAbi } from "./abi/simpleAccount"; +import { FACTORY_ADDRESS } from "./factoryAddress"; + +export function baseWithEthers( + ethClient: PublicClient | JsonRpcProvider, + eoa: WalletClient | Signer, +): RequiredAccountOpts { + return { + accountAbi: AccountAbi, + factoryAbi: FactoryAbi, + factoryAddress: FACTORY_ADDRESS, + ethClient, + async setFactoryData(salt, encoder) { + if ("getAddresses" in eoa) { + return encoder("createAccount", [(await eoa.getAddresses())[0], salt]); + } else { + return encoder("createAccount", [ + (await eoa.getAddress()) as Address, + salt, + ]); + } + }, + requestSignature: + "getAddresses" in eoa + ? RequestSignature.withViemWalletClient( + eoa as WalletClient, + ) + : RequestSignature.withEthersSigner(eoa), + }; +} diff --git a/src/v06/account/common/simpleAccountWithSigner.ts b/src/v06/account/common/simpleAccountWithSigner.ts new file mode 100644 index 0000000..d530d8c --- /dev/null +++ b/src/v06/account/common/simpleAccountWithSigner.ts @@ -0,0 +1,31 @@ +import { Address } from "abitype"; +import { JsonRpcProvider, Signer } from "ethers"; +import { PublicClient, Account } from "viem"; +import { RequestSignature } from "../hooks"; +import { RequiredAccountOpts } from "../types"; +import { AccountAbi, FactoryAbi } from "./abi/simpleAccount"; +import { FACTORY_ADDRESS } from "./factoryAddress"; + +export function base( + ethClient: PublicClient | JsonRpcProvider, + eoa: Signer, + account?: Account, +): RequiredAccountOpts { + return { + accountAbi: AccountAbi, + factoryAbi: FactoryAbi, + factoryAddress: FACTORY_ADDRESS, + ethClient, + async setFactoryData(salt, encoder) { + if (account !== undefined) { + return encoder("createAccount", [account.address, salt]); + } else { + return encoder("createAccount", [ + (await eoa.getAddress()) as Address, + salt, + ]); + } + }, + requestSignature: RequestSignature.withEthersSigner(eoa), + }; +} diff --git a/src/v06/account/common/simpleAccountWithViemAccount.ts b/src/v06/account/common/simpleAccountWithViemAccount.ts new file mode 100644 index 0000000..b39be3a --- /dev/null +++ b/src/v06/account/common/simpleAccountWithViemAccount.ts @@ -0,0 +1,32 @@ +import { JsonRpcProvider } from "ethers"; +import { PublicClient, WalletClient, Transport, Chain, Account } from "viem"; +import { RequestSignature } from "../hooks"; +import { RequiredAccountOpts } from "../types"; +import { AccountAbi, FactoryAbi } from "./abi/simpleAccount"; +import { FACTORY_ADDRESS } from "./factoryAddress"; + +export function baseWithViemHoistedAccount( + ethClient: PublicClient | JsonRpcProvider, + eoa: WalletClient, + account: Account, +): RequiredAccountOpts { + return { + accountAbi: AccountAbi, + factoryAbi: FactoryAbi, + factoryAddress: FACTORY_ADDRESS, + ethClient, + async setFactoryData(salt, encoder) { + if (account !== undefined) { + return encoder("createAccount", [account.address, salt]); + } else { + return encoder("createAccount", [(await eoa.getAddresses())[0], salt]); + } + }, + requestSignature: + "getAddresses" in eoa + ? RequestSignature.withViemWalletClient( + eoa as WalletClient, + ) + : RequestSignature.withEthersSigner(eoa), + }; +} diff --git a/src/v06/account/common/simpleAccountWithoutViemAccount.ts b/src/v06/account/common/simpleAccountWithoutViemAccount.ts new file mode 100644 index 0000000..e3a9c60 --- /dev/null +++ b/src/v06/account/common/simpleAccountWithoutViemAccount.ts @@ -0,0 +1,33 @@ +import { JsonRpcProvider } from "ethers"; +import { PublicClient, WalletClient, Transport, Chain, Account } from "viem"; +import { RequestSignature } from "../hooks"; +import { RequiredAccountOpts } from "../types"; +import { AccountAbi, FactoryAbi } from "./abi/simpleAccount"; +import { FACTORY_ADDRESS } from "./factoryAddress"; + +export function baseWithoutHoistedViemAccount( + ethClient: PublicClient | JsonRpcProvider, + eoa: WalletClient, + account: Account, +): RequiredAccountOpts { + return { + accountAbi: AccountAbi, + factoryAbi: FactoryAbi, + factoryAddress: FACTORY_ADDRESS, + ethClient, + async setFactoryData(salt, encoder) { + if (account !== undefined) { + return encoder("createAccount", [account.address, salt]); + } else { + return encoder("createAccount", [(await eoa.getAddresses())[0], salt]); + } + }, + requestSignature: + "getAddresses" in eoa + ? RequestSignature.withoutViemWalletClient( + eoa as WalletClient, + account, + ) + : RequestSignature.withEthersSigner(eoa), + }; +} diff --git a/src/v06/account/hooks/requestGasPrice/common.ts b/src/v06/account/hooks/requestGasPrice/common.ts deleted file mode 100644 index a580017..0000000 --- a/src/v06/account/hooks/requestGasPrice/common.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { PublicClient } from "viem"; -import { RequestGasPriceFunc } from "../types"; -import { JsonRpcProvider } from "ethers"; - -export const withEthClient = ( - ethClient: PublicClient | JsonRpcProvider, -): RequestGasPriceFunc => { - if (ethClient instanceof JsonRpcProvider) { - return async () => { - const feeData = await ethClient.getFeeData(); - if (!feeData.maxFeePerGas || !feeData.maxPriorityFeePerGas) { - return { - maxFeePerGas: feeData.gasPrice || 0n, - maxPriorityFeePerGas: feeData.gasPrice || 0n, - }; - } - - return { - maxFeePerGas: feeData.maxFeePerGas, - maxPriorityFeePerGas: feeData.maxPriorityFeePerGas, - }; - }; - } - - return async () => { - const block = await ethClient.getBlock(); - if (!block.baseFeePerGas) { - const gp = await ethClient.getGasPrice(); - return { - maxFeePerGas: gp, - maxPriorityFeePerGas: gp, - }; - } - - const maxPriorityFeePerGas = await ethClient.estimateMaxPriorityFeePerGas(); - const maxFeePerGas = block.baseFeePerGas * 2n + maxPriorityFeePerGas; - return { - maxFeePerGas, - maxPriorityFeePerGas, - }; - }; -}; diff --git a/src/v06/account/hooks/requestGasPrice/index.ts b/src/v06/account/hooks/requestGasPrice/index.ts index 6b57160..c5afdc1 100644 --- a/src/v06/account/hooks/requestGasPrice/index.ts +++ b/src/v06/account/hooks/requestGasPrice/index.ts @@ -1 +1,2 @@ -export * from "./common"; +export * from "./jsonProvider"; +export * from "./publicClient"; diff --git a/src/v06/account/hooks/requestGasPrice/jsonProvider.ts b/src/v06/account/hooks/requestGasPrice/jsonProvider.ts new file mode 100644 index 0000000..340d8b1 --- /dev/null +++ b/src/v06/account/hooks/requestGasPrice/jsonProvider.ts @@ -0,0 +1,21 @@ +import { JsonRpcProvider } from "ethers"; +import { RequestGasPriceFunc } from "../types"; + +export const withEthJsonRpcProvider = ( + ethClient: JsonRpcProvider, +): RequestGasPriceFunc => { + return async () => { + const feeData = await ethClient.getFeeData(); + if (!feeData.maxFeePerGas || !feeData.maxPriorityFeePerGas) { + return { + maxFeePerGas: feeData.gasPrice || 0n, + maxPriorityFeePerGas: feeData.gasPrice || 0n, + }; + } + + return { + maxFeePerGas: feeData.maxFeePerGas, + maxPriorityFeePerGas: feeData.maxPriorityFeePerGas, + }; + }; +}; diff --git a/src/v06/account/hooks/requestGasPrice/publicClient.ts b/src/v06/account/hooks/requestGasPrice/publicClient.ts new file mode 100644 index 0000000..28e65df --- /dev/null +++ b/src/v06/account/hooks/requestGasPrice/publicClient.ts @@ -0,0 +1,17 @@ +import { PublicClient } from "viem"; +import { RequestGasPriceFunc } from "../types"; + +export const withEthPublicClient = ( + ethClient: PublicClient, +): RequestGasPriceFunc => { + return async () => { + const gp = await ethClient.getGasPrice(); + const maxPriorityFeePerGas = await ethClient.estimateMaxPriorityFeePerGas(); + const maxFeePerGas = gp * 2n + maxPriorityFeePerGas; + + return { + maxFeePerGas, + maxPriorityFeePerGas, + }; + }; +}; diff --git a/src/v06/account/hooks/requestSignature/index.ts b/src/v06/account/hooks/requestSignature/index.ts index ed22760..db92623 100644 --- a/src/v06/account/hooks/requestSignature/index.ts +++ b/src/v06/account/hooks/requestSignature/index.ts @@ -1,2 +1,3 @@ export * from "./ethers"; -export * from "./viem"; +export * from "./withViemHoistedClient"; +export * from "./withouthViemHoistedClient"; diff --git a/src/v06/account/hooks/requestSignature/viem.ts b/src/v06/account/hooks/requestSignature/withViemHoistedClient.ts similarity index 66% rename from src/v06/account/hooks/requestSignature/viem.ts rename to src/v06/account/hooks/requestSignature/withViemHoistedClient.ts index 87b092e..3f79f9d 100644 --- a/src/v06/account/hooks/requestSignature/viem.ts +++ b/src/v06/account/hooks/requestSignature/withViemHoistedClient.ts @@ -2,16 +2,8 @@ import { WalletClient, Account, Transport, Chain } from "viem"; import { privateKeyToAccount, generatePrivateKey } from "viem/accounts"; import { RequestSignatureFunc } from "../types"; -export function withViemWalletClient( - client: WalletClient, - account: Account, -): RequestSignatureFunc; export function withViemWalletClient( client: WalletClient, -): RequestSignatureFunc; -export function withViemWalletClient( - client: WalletClient, - account?: Account, ): RequestSignatureFunc { const dummy = privateKeyToAccount(generatePrivateKey()); return async (type, message) => { @@ -21,9 +13,6 @@ export function withViemWalletClient( } case "final": { - if (account) { - return client.signMessage({ account, message: { raw: message } }); - } return ( client as WalletClient ).signMessage({ diff --git a/src/v06/account/hooks/requestSignature/withouthViemHoistedClient.ts b/src/v06/account/hooks/requestSignature/withouthViemHoistedClient.ts new file mode 100644 index 0000000..7583141 --- /dev/null +++ b/src/v06/account/hooks/requestSignature/withouthViemHoistedClient.ts @@ -0,0 +1,21 @@ +import { WalletClient, Transport, Chain, Account } from "viem"; +import { privateKeyToAccount, generatePrivateKey } from "viem/accounts"; +import { RequestSignatureFunc } from "../types"; + +export function withoutViemWalletClient( + client: WalletClient, + account: Account, +): RequestSignatureFunc { + const dummy = privateKeyToAccount(generatePrivateKey()); + return async (type, message) => { + switch (type) { + case "dummy": { + return dummy.signMessage({ message: { raw: message } }); + } + + case "final": { + return client.signMessage({ account, message: { raw: message } }); + } + } + }; +} diff --git a/src/v06/account/instance.ts b/src/v06/account/instance.ts index c0fadb0..5a1cc9c 100644 --- a/src/v06/account/instance.ts +++ b/src/v06/account/instance.ts @@ -24,6 +24,12 @@ import * as Hooks from "./hooks"; import * as Bundler from "../bundler"; import * as EntryPoint from "../entryPoint"; +function isJsonRpcProvider( + client: PublicClient | JsonRpcProvider, +): client is JsonRpcProvider { + return client instanceof JsonRpcProvider; +} + export class Instance { private readonly accountAbi: A; private readonly factoryAbi: F; @@ -65,7 +71,9 @@ export class Instance { this.requestSignature = opts.requestSignature; this.requestGasPrice = opts.requestGasPrice ?? - Hooks.RequestGasPrice.withEthClient(this.ethClient); + (this.ethClient instanceof JsonRpcProvider + ? Hooks.RequestGasPrice.withEthJsonRpcProvider(this.ethClient) + : Hooks.RequestGasPrice.withEthPublicClient(this.ethClient)); this.requestGasValues = opts.requestGasValues ?? Hooks.RequestGasValues.withEthClient(this.bundlerClient); @@ -91,11 +99,9 @@ export class Instance { } private async getChainId(): Promise { - if (this.ethClient instanceof JsonRpcProvider) { - const network = await this.ethClient.getNetwork(); - return Number(network.chainId); - } - return this.ethClient.getChainId(); + return isJsonRpcProvider(this.ethClient) + ? Number((await this.ethClient.getNetwork()).chainId) + : this.ethClient.getChainId(); } private async getByteCode(address: Address): Promise { diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..7765c9d --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,45 @@ +{ + // This tsconfig file contains the shared config for the build (tsconfig.build.json) and type checking (tsconfig.json) config. + "include": [], + "compilerOptions": { + // Incremental builds + // NOTE: Enabling incremental builds speeds up `tsc`. Keep in mind though that it does not reliably bust the cache when the `tsconfig.json` file changes. + "incremental": false, + + // Type checking + "strict": true, + "useDefineForClassFields": true, // Not enabled by default in `strict` mode unless we bump `target` to ES2022. + "noFallthroughCasesInSwitch": true, // Not enabled by default in `strict` mode. + "noImplicitReturns": true, // Not enabled by default in `strict` mode. + "useUnknownInCatchVariables": true, // TODO: This would normally be enabled in `strict` mode but would require some adjustments to the codebase. + "noImplicitOverride": true, // Not enabled by default in `strict` mode. + "noUnusedLocals": true, // Not enabled by default in `strict` mode. + "noUnusedParameters": true, // Not enabled by default in `strict` mode. + // "exactOptionalPropertyTypes": true, + // TODO: Uncomment and fix types. + "declaration": true, + // "noUncheckedIndexedAccess": true, + + // JavaScript support + "allowJs": false, + "checkJs": false, + + // Interop constraints + "esModuleInterop": false, + "allowSyntheticDefaultImports": false, + "forceConsistentCasingInFileNames": true, + "verbatimModuleSyntax": false, + "importHelpers": true, // This is only used for build validation. Since we do not have `tslib` installed, this will fail if we accidentally make use of anything that'd require injection of helpers. + + // Language and environment + "moduleResolution": "Node", + "module": "commonjs", + "target": "ES2021", // Setting this to `ES2021` enables native support for `Node v16+`: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping. + "lib": [ + "ES2022" // By using ES2022 we get access to the `.cause` property on `Error` instances. + ], + + // Skip type checking for node modules + "skipLibCheck": true + } +} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..d1a9bee --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.base.json", + + "include": ["src"], + "exclude": ["dist", "src/test", "node_modules"], + "compilerOptions": { + "moduleResolution": "Node10", + "sourceMap": true, + "outDir": "./dist", + "rootDir": "./src" + } +} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 388f67c..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs" /* Specify what module code is generated. */, - "rootDir": "./src" /* Specify the root folder within your source files. */, - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - "resolveJsonModule": true /* Enable importing .json files. */, - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./dist" /* Specify an output folder for all emitted files. */, - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - - /* Type Checking */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - "exclude": ["dist", "src/test"] -} diff --git a/yarn.lock b/yarn.lock index 40de4b3..187024a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25,6 +25,34 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" +"@arktype/attest@^0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@arktype/attest/-/attest-0.7.0.tgz#570cf064ef8c461fb9f48c027631871b26f4cba6" + integrity sha512-ip7fkqg3J0eHaeaIOevIKW6UDNC89G6x6WhbrKmYCU9cMfoGoXDgmj3QV+LWv9FeObJfmQwYU6+r0gn9FvpGWA== + dependencies: + "@arktype/fs" "0.0.16" + "@arktype/util" "0.0.33" + "@typescript/analyze-trace" "0.10.1" + "@typescript/vfs" "1.5.0" + arktype "2.0.0-dev.6" + +"@arktype/fs@0.0.16": + version "0.0.16" + resolved "https://registry.yarnpkg.com/@arktype/fs/-/fs-0.0.16.tgz#882d5d1c5024dc62fda24a2fb7587f45f6800295" + integrity sha512-+pHb9relEJrnQRF0DCeqFJsF8ZyaleOL+l+XIozGOb7s9pShimiRAj4P5ZE6uMflNXANs803nVl/76vvsWr6eA== + +"@arktype/schema@0.0.7": + version "0.0.7" + resolved "https://registry.yarnpkg.com/@arktype/schema/-/schema-0.0.7.tgz#b6b9b07f83372add36122c648d036fd82d233cd7" + integrity sha512-awo14Oi98bn6pEgN7soiXvD+mQzidLgzABVO7Tpbw6xtU7+XRWp6JucSEmWLASC+fcoK0QSJxdoC+rm3iIKarQ== + dependencies: + "@arktype/util" "0.0.33" + +"@arktype/util@0.0.33": + version "0.0.33" + resolved "https://registry.yarnpkg.com/@arktype/util/-/util-0.0.33.tgz#6faaefa6ab1f744510b56855b6b7187611c3b798" + integrity sha512-MYbrLHf0tVYjxI84m0mMRISmKKVoPzv25B1/X05nePUcyPqROoDBn+hYhHpB0GqnJZQOr8UG1CyMuxjFeVbTNg== + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.21.4": version "7.21.4" resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz" @@ -1134,6 +1162,27 @@ "@typescript-eslint/types" "7.3.1" eslint-visitor-keys "^3.4.1" +"@typescript/analyze-trace@0.10.1": + version "0.10.1" + resolved "https://registry.yarnpkg.com/@typescript/analyze-trace/-/analyze-trace-0.10.1.tgz#c2ccc33ddb70a0d6dc1b739589d6182f3ba913f1" + integrity sha512-RnlSOPh14QbopGCApgkSx5UBgGda5MX1cHqp2fsqfiDyCwGL/m1jaeB9fzu7didVS81LQqGZZuxFBcg8YU8EVw== + dependencies: + chalk "^4.1.2" + exit "^0.1.2" + jsonparse "^1.3.1" + jsonstream-next "^3.0.0" + p-limit "^3.1.0" + split2 "^3.2.2" + treeify "^1.1.0" + yargs "^16.2.0" + +"@typescript/vfs@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@typescript/vfs/-/vfs-1.5.0.tgz#ed942922724f9ace8c07c80b006c47e5e3833218" + integrity sha512-AJS307bPgbsZZ9ggCT3wwpg3VbTKMFNHfaY/uF0ahSkYYrPF2dSSKDNIDIQAHm9qJqbLvCsSJH7yN4Vs/CsMMg== + dependencies: + debug "^4.1.1" + "@ungap/structured-clone@^1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" @@ -1230,6 +1279,14 @@ argparse@^2.0.1: resolved "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz" integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== +arktype@2.0.0-dev.6: + version "2.0.0-dev.6" + resolved "https://registry.yarnpkg.com/arktype/-/arktype-2.0.0-dev.6.tgz#ecac08039519cf25226fe49c6133c5fc27939438" + integrity sha512-rA7/SiQ7QnAY/amyfo12wDHtdyrWwFv/kjkoSnVeEdx2Wvky5gfNBoErE30FJzHWCjtcMcJg0HQP2+u46e08Tg== + dependencies: + "@arktype/schema" "0.0.7" + "@arktype/util" "0.0.33" + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -1395,7 +1452,7 @@ chalk@^2.0.0, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.1.2: version "4.1.2" resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1418,6 +1475,15 @@ cjs-module-lexer@^1.0.0: resolved "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz" integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA== +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + cliui@^8.0.1: version "8.0.1" resolved "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz" @@ -2029,7 +2095,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2: +inherits@2, inherits@^2.0.3: version "2.0.4" resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -2615,6 +2681,19 @@ json5@^2.2.2, json5@^2.2.3: resolved "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== +jsonparse@^1.2.0, jsonparse@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== + +jsonstream-next@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/jsonstream-next/-/jsonstream-next-3.0.0.tgz#45664fb89e50799fb220b4e9017cbc458b5917e4" + integrity sha512-aAi6oPhdt7BKyQn1SrIIGZBt0ukKuOUE1qV6kJ3GgioSOYzsRc8z9Hfr1BVmacA/jLe9nARfmgMGgn68BqIAgg== + dependencies: + jsonparse "^1.2.0" + through2 "^4.0.2" + kleur@^3.0.3: version "3.0.3" resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz" @@ -2980,6 +3059,15 @@ react-is@^18.0.0: resolved "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz" integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== +readable-stream@3, readable-stream@^3.0.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" @@ -3042,6 +3130,11 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + semver@^6.0.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" @@ -3104,6 +3197,13 @@ source-map@^0.6.0, source-map@^0.6.1: resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +split2@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" + integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg== + dependencies: + readable-stream "^3.0.0" + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" @@ -3151,6 +3251,13 @@ string-width@^5.0.1, string-width@^5.1.2: emoji-regex "^9.2.2" strip-ansi "^7.0.1" +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + "strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -3227,6 +3334,13 @@ text-table@^0.2.0: resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== +through2@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/through2/-/through2-4.0.2.tgz#a7ce3ac2a7a8b0b966c80e7c49f0484c3b239764" + integrity sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw== + dependencies: + readable-stream "3" + tmpl@1.0.5: version "1.0.5" resolved "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz" @@ -3244,6 +3358,11 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +treeify@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/treeify/-/treeify-1.1.0.tgz#4e31c6a463accd0943879f30667c4fdaff411bb8" + integrity sha512-1m4RA7xVAJrSGrrXGs0L3YTwyvBs2S8PbRHaLZAkFw7JR8oIFwYtysxlBZhYIa7xSyiYJKZ3iGrrk55cGA3i9A== + ts-api-utils@^1.0.1: version "1.3.0" resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.3.0.tgz#4b490e27129f1e8e686b45cc4ab63714dc60eea1" @@ -3326,6 +3445,11 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + v8-to-istanbul@^9.0.1: version "9.1.0" resolved "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz" @@ -3428,11 +3552,29 @@ yallist@^4.0.0: resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + yargs-parser@^21.0.1, yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== +yargs@^16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + yargs@^17.3.1: version "17.7.1" resolved "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz"