Skip to content

Commit

Permalink
feat: key generation utilities, utf8 normalization, API improvements
Browse files Browse the repository at this point in the history
BREAKING CHANGE: exposes script source compilations in ResolvedScript and renames
authenticationTemplate -> walletTemplate
  • Loading branch information
bitjson committed Jan 12, 2024
1 parent 406aa29 commit 5ad6520
Show file tree
Hide file tree
Showing 215 changed files with 39,285 additions and 10,201 deletions.
36 changes: 30 additions & 6 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json",
"language": "en",
"words": [
"activatable",
"ACTIVEBYTECODE",
"airgapped",
"altstack",
"Amagi",
"ANYONECANPAY",
"asmcrypto",
"auditability",
"auditable",
"authbase",
"authbases",
"authchain",
"authchains",
"authhead",
"BCHCHIPs",
"bchn",
"bchreg",
"bchtest",
"bcmr",
"bcoin",
"bcrypto",
"bech",
"benchmarkjs",
"bigint",
Expand All @@ -31,6 +39,7 @@
"camelcase",
"cashaddr",
"CASHTOKENS",
"Chaingraph",
"CHECKDATASIG",
"CHECKDATASIGVERIFY",
"CHECKLOCKTIMEVERIFY",
Expand All @@ -39,6 +48,7 @@
"CHECKSEQUENCEVERIFY",
"CHECKSIG",
"CHECKSIGVERIFY",
"chipnet",
"chuhai",
"codecov",
"codepoint",
Expand All @@ -47,8 +57,11 @@
"combinator",
"combinators",
"convertbits",
"corepack",
"counterparties",
"cyclomatic",
"Datacarrier",
"DDTHH",
"deno",
"deserialization",
"deserialize",
Expand All @@ -65,15 +78,18 @@
"esnext",
"FORKID",
"FROMALTSTACK",
"gitter",
"GREATERTHAN",
"GREATERTHANOREQUAL",
"HMAC",
"IFDUP",
"IIFE",
"INPUTBYTECODE",
"INPUTINDEX",
"INPUTSEQUENCENUMBER",
"Ints",
"INVALIDOPCODE",
"ipfs",
"LESSTHAN",
"LESSTHANOREQUAL",
"libauth",
Expand All @@ -90,8 +106,10 @@
"Merkle",
"minification",
"MINIMALIF",
"MITM",
"monospace",
"multisig",
"Nakamoto",
"NONFUNGIBLE",
"nops",
"NOTIF",
Expand Down Expand Up @@ -121,6 +139,9 @@
"PUBKEYS",
"PUSHBYTES",
"PUSHDATA",
"rebranded",
"rebranding",
"redenominated",
"regtest",
"reversebytes",
"ripemd",
Expand All @@ -133,15 +154,18 @@
"seckey",
"secp",
"secp256k1",
"sidechain",
"sigchecks",
"sighash",
"skippable",
"SMALLINTEGER",
"Spedn",
"STACKTOP",
"standardness",
"statelessly",
"STATICTOP",
"submodule",
"substack",
"templating",
"testnet",
"TOALTSTACK",
Expand Down Expand Up @@ -171,10 +195,14 @@
"wasm",
"wbindgen",
"webassembly",
"wechat",
"XAMPL",
"xprivkey",
"xprv",
"xpub",
"xpubkey",
"yarnpkg",
"ZDTC",
"𒂼𒄄"
],
"flagWords": [],
Expand All @@ -193,9 +221,5 @@
"pattern": "/:[qpzry9x8gf2tvdw0s3jn54khce6mua7l]+/g"
}
],
"ignoreRegExpList": [
"Base64",
"HexValues",
"cash-address-format"
]
"ignoreRegExpList": ["Base64", "HexValues", "cash-address-format"]
}
33 changes: 11 additions & 22 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,16 @@
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"env": { "es6": true },
"ignorePatterns": ["node_modules", "build", "coverage"],
"ignorePatterns": [
"node_modules",
"build",
"coverage",
"src/lib/schema/ajv/*.js"
],
"extends": ["bitauth"],
"globals": { "BigInt": true, "console": true, "WebAssembly": true },
// "globals": { "BigInt": true, "console": true, "WebAssembly": true },
"rules": {
"@typescript-eslint/prefer-readonly-parameter-types": "off", // TODO: enable when Uint8Array can be made readonly, see `Immutable` type
"@typescript-eslint/no-unused-expressions": "off", // TODO: bug causes crash in eslint 7.2.0 – re-enable later
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "default",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
},
{ "selector": "typeLike", "format": ["PascalCase"] },
{ "selector": "enumMember", "format": ["camelCase", "UPPER_CASE"] } // Allow UPPER_CASE for opcodes
],
"import/no-internal-modules": ["error"],
"import/extensions": ["error", "always"]
"@typescript-eslint/no-unsafe-enum-comparison": "off"
},
"overrides": [
/*
Expand All @@ -47,9 +34,11 @@
]
}
],
"functional/no-expression-statement": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-magic-numbers": "off",
"functional/no-expression-statements": "off",
"functional/no-conditional-statements": "off",
"functional/functional-parameters": "off",
"functional/immutable-data": "off",
"functional/no-return-void": "off"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This library should provide the primitives needed to hack on bitcoin and bitcoin

## Some Practical Details

- **accept `readonly`, return mutable** - We should always return mutable types to allow consumers the option of mutating results without running afoul of type-checking. For the same reason, when we accept a value, we should always accept it as `readonly` for maximum flexibility.
- **accept immutable, return mutable** - We should always return mutable types to allow consumers the option of mutating results without running afoul of type-checking. For the same reason, when we accept a value, we should generally avoid mutating it.
- **use `eslint-disable-next-line` or `eslint-disable-line`** - It's ok to disable eslint; in some cases, rules should be disabled every time they're hit (e.g. `no-bitwise`). By using single-line disables, we clearly mark intentional deviations from our conventions.
- **avoid Hungarian notation & name prefixing** – Including the type of a variable in its name is a code smell: a name should clearly describe only one concept, and types are the business of the type system. Likewise, using prefixes to distinguish between an interface and an instance typically indicates the concepts should be simplified. E.g. `IChecker` and `Checker` – this is likely made unnecessarily complex to accommodate an object-oriented style. Consider replacing with a single function (or if instantiation is required, an object containing only stateless functions).
- **don't throw things** – instead, return a result that can be either a success or error type. This strategy encourages a more functional approach to problems, and pragmatically, [TypeScript does not yet offer a `throws` clause or otherwise](https://github.com/microsoft/TypeScript/issues/13219), so only this strategy allows errors to be well-typed. A good pattern is `() => string | ResultType`, where ResultType is the desired output, and error messages are returned as a string. Consumers can easily use `typeof result === 'string'` to narrow the resulting type. When errors are more complex or `ResultType` is also a string, use an object with a `success` property, e.g. `() => { success: true, bytecode: Uint8Array } | { success: false, errors: ErrorType[] }`.
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:
deployments: write

concurrency:
group: "benchmarks"
group: 'benchmarks'
cancel-in-progress: true

jobs:
Expand All @@ -19,15 +19,15 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'true'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: Run benchmark
run: yarn && yarn bench
# TODO: Libauth-only benchmarks: test for performance regressions in Libauth functionality, format results to work with the below configuration
run: yarn && yarn playwright install && yarn bench

# TODO: Libauth-only benchmarks: test for performance regressions in Libauth functionality, format results to work with the below configuration

# - name: Push benchmark result to gh-pages
# uses: benchmark-action/github-action-benchmark@3d3bca03e83647895ef4f911fa57de3c7a391aaf
Expand Down
29 changes: 14 additions & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ name: Lint, Build, and Test Libauth
on: [push, pull_request]

jobs:

build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16 ]
node: [18, latest]
name: Test Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup node
uses: actions/setup-node@v3
submodules: 'recursive'
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: yarn install --immutable --immutable-cache
Expand All @@ -24,14 +23,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 18 ]
node: [20]
name: Test Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup node
uses: actions/setup-node@v3
submodules: 'recursive'
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: yarn install --immutable --immutable-cache
Expand All @@ -43,11 +42,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'true'
submodules: 'recursive'
- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
- run: yarn install --immutable --immutable-cache --check-cache
6 changes: 3 additions & 3 deletions .github/workflows/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:
id-token: write

concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: true

jobs:
Expand All @@ -21,11 +21,11 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'true'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
- name: Prepare dependencies
run: yarn
- name: Generate Docs
Expand Down
7 changes: 6 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
path = wasm/secp256k1
url = https://github.com/bitauth/libauth-secp256k1.git
branch = libauth
shallow = true
[submodule ".yarn"]
path = .yarn
url = https://github.com/bitauth/libauth-dependencies.git
shallow = true
shallow = true
[submodule "config/eslint-config-bitauth"]
path = config/eslint-config-bitauth
url = https://github.com/bitauth/eslint-config-bitauth/
shallow = true
Loading

0 comments on commit 5ad6520

Please sign in to comment.