From 903d86715a597ddbcf53a99af4f5eadde19fc3bc Mon Sep 17 00:00:00 2001 From: v1rtl Date: Wed, 5 Nov 2025 15:52:41 +0200 Subject: [PATCH] fix: drop cjs --- bun.lockb | Bin 7212 -> 7701 bytes package.json | 69 +++++++++++++------------------------------- src/coin/hns.ts | 2 +- src/utils/bech32.ts | 11 ++++--- tsconfig.base.json | 10 +------ tsconfig.build.json | 2 +- tsconfig.bun.json | 10 ------- tsconfig.json | 2 +- 8 files changed, 31 insertions(+), 75 deletions(-) delete mode 100644 tsconfig.bun.json diff --git a/bun.lockb b/bun.lockb index f3dd31952e06ccc4e144ef32200593c523bcebd2..be613532d842a718c772c7cda7b74fec42b84c3a 100755 GIT binary patch delta 2265 zcmcgtc~FyA5dU5hASWRqkOZ`XQe;p*0tqHIh|$p&0YU45T8&_daw=ExM2wCXq9Z;~ z#1^TjsHMuGt)o^Qv0k-`S4HbV6;VXNqZZT(-S?4iCY|Zu-I>k4x4+-p-S1~~{`43_Nk!4jSnaL{F2 zumI`#x_9EAVvB3c*o3@X3=tRFgSUAsh^*gp!_bs-52vGaT#fj+2`MCSjDl2*IO1>7 zK= zH4+e8C+EHWe8${VFHE-*GQDOLE^GIRItE()muz^b)AXs32~pkBZpK1>oA6e= zZE2pONa?vK92OTFlND8TTf4(bEn26)YmA@hpLguk!}}}J+tF_q43=D@>_c{p@Lk!{ z5|_MB<$Qv5G3I+`;zPVU0ZndVL%d6<@x_x%_{b$nhjq_!%)^oyEcYi0o z9s1gT#MwSwk4)_eOFkS}Joa*3-o&+6C$F4wD1+Z*R~>mkR(RIhRT*xo{u+IcW_if2 z6`4L473=#7BcB}2{^jM?+UA?a>M~&2W zr)-FB@cG*mFydAsj7GMirmw zqjmc$v?ErNa?*F?{7>qm>O0;mDyurW;uh5u#n1Aa*8XKri_6|KDa~6iTT(Aoo8p2F zZd>c~_`~l#ZP$D%?aFh)Qw327;ckI4@71W(tL7hDo4YoI9Sfaw>9e@EXUx8jcXoB0 z3uzsEJ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zv>4QPJ8Vk&`K_CuHE;>$vdL=`ZqSalAGFI zsgK@FY>SFiHGViYSi9RNw=DT##f@tD<7n?I_mvU4ukLs|UQ37`PL5^`^xet0*?R=~ zvA2i+F?L~Am5CcG#*JR`OJT|M?xc$y0pU>}U%a|x9s5+d&l+8MT8#T-&20ib;?gmlA*&t)=DaoTYp&bX`}5YE;#Hk5DtT{K zP2>?hE+ffP*XlGzBC<0yZ%|HH%IcF034>8o`tWGc4v+NE^+m`>Pe$a->S$G@=J?Vt}ogvo?JiFFsK)`EY-Sw_Q#*jk?Y@4`7vs? z(ZR(LmK^ToxTihw<+IY_f4g0nere1hQi7|9;+d?|pOhc(uA3g*vYnmyIOC!&yXM~TLRSK<Au0h^DD zGg|2qt-v?c)n>vLJOS{@VN4TR+x4!&u3jR19Bjg`VGb-d`rSpg90%}V!Cba3jPYE? zBLgSFdtBExtBCo%kl>sweGCkZH{IxitI1=4G z+Ioy47ePfVGg+*^-Z|nKuGyw%o~0qnl&>=ym8SH}g7iEzO)Jm>H!W|-=2R&|d2Ux2 z{>o*@ET4~(ByOY{70JC&rNoV)Qu?7LNhGNP#uJI9a?%eC%REuBG=U5Re-HFhN<*wa Ya+MXJ>oN^0m4&rX@&zP>EOsCJ8 ./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" }] }