Skip to content

Commit

Permalink
Merge branch 'dev' into merge-main-into-dev-12
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwbabylonlab authored Oct 24, 2024
2 parents 2c018d3 + 97c88fc commit a5aa45d
Show file tree
Hide file tree
Showing 41 changed files with 3,837 additions and 1,554 deletions.
33 changes: 30 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
{
"extends": ["prettier"],
"sourceType": "module"
}
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": "latest"
},
"overrides": [
{
"files": [
"tests/**/*.ts"
],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": [
"jest.setup.js"
],
"rules": {
"no-undef": "off"
}
},
]
}
9 changes: 0 additions & 9 deletions eslint.config.js

This file was deleted.

32 changes: 24 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@babylonlabs-io/btc-staking-ts",
"version": "0.3.0",
"version": "0.4.0-canary.1",
"description": "Library exposing methods for the creation and consumption of Bitcoin transactions pertaining to Babylon's Bitcoin Staking protocol.",
"module": "dist/index.js",
"main": "dist/index.cjs",
Expand Down Expand Up @@ -49,10 +49,12 @@
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.11.30",
"@typescript-eslint/parser": "^7.4.0",
"dts-bundle-generator": "^9.3.1",
"ecpair": "^2.1.0",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"jest": "^29.7.0",
Expand Down
2 changes: 2 additions & 0 deletions src/constants/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// NO_COORD_PK_BYTE_LENGTH is the length of a BTC public key without the coordinate in bytes.
export const NO_COORD_PK_BYTE_LENGTH = 32;
30 changes: 30 additions & 0 deletions src/error/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export enum StakingErrorCode {
UNKNOWN_ERROR = "UNKNOWN_ERROR",
INVALID_INPUT = "INVALID_INPUT",
INVALID_OUTPUT = "INVALID_OUTPUT",
SCRIPT_FAILURE = "SCRIPT_FAILURE",
BUILD_TRANSACTION_FAILURE = "BUILD_TRANSACTION_FAILURE",
INVALID_PARAMS = "INVALID_PARAMS",
}

export class StakingError extends Error {
public code: StakingErrorCode;
constructor(code: StakingErrorCode, message?: string) {
super(message);
this.code = code;
}

// Static method to safely handle unknown errors
static fromUnknown(
error: unknown, code: StakingErrorCode, fallbackMsg?: string
): StakingError {
if (error instanceof StakingError) {
return error;
}

if (error instanceof Error) {
return new StakingError(code, error.message);
}
return new StakingError(code, fallbackMsg);
}
}
Loading

0 comments on commit a5aa45d

Please sign in to comment.