diff --git a/bun.lockb b/bun.lockb index f3dd3195..be613532 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index b903c431..5df52471 100644 --- a/package.json +++ b/package.json @@ -1,57 +1,32 @@ { "name": "@ensdomains/address-encoder", - "version": "1.0.0-rc.3", + "version": "2.0.0-rc.0", "description": "Encodes and decodes address formats for various cryptocurrencies", "type": "module", - "main": "./dist/cjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/types/index.d.ts", - "typings": "./dist/types/index.d.ts", "sideEffects": false, "exports": { ".": { - "types": "./dist/types/index.d.ts", - "import": "./dist/esm/index.js", - "default": "./dist/cjs/index.js" + "types": "./dist/index.d.ts", + "default": "./dist/index.js" }, "./async": { - "types": "./dist/types/async.d.ts", - "import": "./dist/esm/async.js", - "default": "./dist/cjs/async.js" + "types": "./dist/async.d.ts", + "default": "./dist/async.js" }, "./coins": { - "types": "./dist/types/coins.d.ts", - "import": "./dist/esm/coins.js", - "default": "./dist/cjs/coins.js" + "types": "./dist/coins.d.ts", + "default": "./dist/coins.js" }, "./coders": { - "types": "./dist/types/coders.d.ts", - "import": "./dist/esm/coders.js", - "default": "./dist/cjs/coders.js" + "types": "./dist/coders.d.ts", + "default": "./dist/coders.js" }, "./utils": { - "types": "./dist/types/utils/index.d.ts", - "import": "./dist/esm/utils/index.js", - "default": "./dist/cjs/utils/index.js" + "types": "./dist/utils/index.d.ts", + "default": "./dist/utils/index.js" }, "./package.json": "./package.json" }, - "typesVersions": { - "*": { - "async": [ - "./dist/types/async.d.ts" - ], - "coins": [ - "./dist/types/coins.d.ts" - ], - "coders": [ - "./dist/types/coders.d.ts" - ], - "utils": [ - "./dist/types/utils/index.d.ts" - ] - } - }, "files": [ "dist/", "src/", @@ -64,24 +39,20 @@ "scripts": { "generateCoin": "bun ./scripts/generateCoin.ts", "clean": "rm -rf ./dist && rm -rf ./tsconfig.build.tsbuildinfo", - "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'", - "build:esm": "tsc --project tsconfig.build.json --module es2022 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}'", - "build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap", - "build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types", - "generatePublishStructure": "bun ./scripts/prepublishOnly.ts" + "build": "bun run clean && tsc -p tsconfig.build.json" }, "devDependencies": { - "@types/fs-extra": "^11.0.2", + "@types/fs-extra": "^11.0.4", "bun-types": "1.0.22", - "fs-extra": "^11.1.1", - "mitata": "^0.1.6", + "fs-extra": "^11.3.2", + "mitata": "^0.1.14", "ts-arithmetic": "^0.1.1", - "ts-markdown": "^1.0.0", - "typescript": "^5.1.6" + "ts-markdown": "^1.3.0", + "typescript": "^5.9.3" }, "dependencies": { - "@noble/curves": "^1.2.0", - "@noble/hashes": "^1.3.2", - "@scure/base": "^1.1.5" + "@noble/curves": "^1.9.7", + "@noble/hashes": "^1.8.0", + "@scure/base": "^1.2.6" } } diff --git a/src/coin/hns.ts b/src/coin/hns.ts index 11715a02..dc50423e 100644 --- a/src/coin/hns.ts +++ b/src/coin/hns.ts @@ -12,7 +12,7 @@ export const encodeHnsAddress = (source: Uint8Array): string => { return bech32.encode(hrp, [versionBytes[0], ...bech32.toWords(source)]); }; export const decodeHnsAddress = (source: string): Uint8Array => { - const { prefix, words } = bech32.decode(source); + const { prefix, words } = bech32.decode(source as `${string}1${string}`); if (prefix !== hrp) throw new Error("Unrecognised address format"); diff --git a/src/utils/bech32.ts b/src/utils/bech32.ts index dff51eb2..03f0e0a9 100644 --- a/src/utils/bech32.ts +++ b/src/utils/bech32.ts @@ -18,10 +18,13 @@ const createInternalBech32Encoder = const createInternalBech32Decoder = ({ bechLib, hrp, limit }: Bech32Parameters) => (source: string): Uint8Array => { - const { prefix, words } = bechLib.decode(source, limit); + const { prefix, words } = bechLib.decode( + source as `${string}1${string}`, + limit, + ); if (prefix !== hrp) { throw new Error( - "Unexpected human-readable part in bech32 encoded address" + "Unexpected human-readable part in bech32 encoded address", ); } return new Uint8Array(bechLib.fromWords(words)); @@ -66,7 +69,7 @@ export const createBech32SegwitDecoder = if (prefix !== hrp) throw new Error( - "Unexpected human-readable part in bech32 encoded address" + "Unexpected human-readable part in bech32 encoded address", ); const script = bech32.fromWords(words.slice(1)); @@ -77,6 +80,6 @@ export const createBech32SegwitDecoder = return concatBytes( new Uint8Array([version, script.length]), - new Uint8Array(script) + new Uint8Array(script), ); }; diff --git a/tsconfig.base.json b/tsconfig.base.json index e95f261c..e61f35aa 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -28,20 +28,12 @@ "allowSyntheticDefaultImports": false, "forceConsistentCasingInFileNames": true, "verbatimModuleSyntax": true, - "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": "NodeNext", "module": "NodeNext", - "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. - "DOM" // For `btoa` and `atob`. - ], - - // Skip type checking for node modules + "target": "ESNext", "skipLibCheck": true, - "composite": true } } diff --git a/tsconfig.build.json b/tsconfig.build.json index 6ba3d188..c5dfbc1e 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,6 +5,6 @@ "compilerOptions": { "sourceMap": true, "rootDir": "./src", - "moduleResolution": "Node" + "outDir": "dist" } } diff --git a/tsconfig.bun.json b/tsconfig.bun.json deleted file mode 100644 index 390b384d..00000000 --- a/tsconfig.bun.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - // This configuration is used for local development and type checking of configuration and script files that are not part of the build. - "include": ["scripts", "src/**/*.test.ts"], - "compilerOptions": { - "composite": true, - "module": "NodeNext", - "resolveJsonModule": true, - "types": ["bun-types"] - } -} diff --git a/tsconfig.json b/tsconfig.json index da572b40..41efa734 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,5 +3,5 @@ "extends": "./tsconfig.base.json", "include": ["src"], "exclude": [], - "references": [{ "path": "./tsconfig.bun.json" }] + "references": [{ "path": "./tsconfig.base.json" }] }