Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
69 changes: 20 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand All @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/coin/hns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
11 changes: 7 additions & 4 deletions src/utils/bech32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand All @@ -77,6 +80,6 @@ export const createBech32SegwitDecoder =

return concatBytes(
new Uint8Array([version, script.length]),
new Uint8Array(script)
new Uint8Array(script),
);
};
10 changes: 1 addition & 9 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"compilerOptions": {
"sourceMap": true,
"rootDir": "./src",
"moduleResolution": "Node"
"outDir": "dist"
}
}
10 changes: 0 additions & 10 deletions tsconfig.bun.json

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"extends": "./tsconfig.base.json",
"include": ["src"],
"exclude": [],
"references": [{ "path": "./tsconfig.bun.json" }]
"references": [{ "path": "./tsconfig.base.json" }]
}