diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6542e6..a6cfc3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ image: node:22 stages: + - test - publish cache: @@ -15,31 +16,26 @@ cache: - node_modules/ before_script: - - npm install - - npm run build - -.publish_to_npm: - # Configure which stage in the pipeline this part should be run in. - stage: publish + - npm install + - npm run build +test: + stage: test script: - - npm config set //registry.npmjs.org/:_authToken ${NPM_AUTH_TOKEN} - - npx lerna publish from-package --no-private --yes --registry https://registry.npmjs.org/ --tag ${NPM_TAG} + - npm run test publish:development: - # Configure what tag to use for this publication. - variables: - NPM_TAG: 'development' - - script: - # add the NPM_TAG to the version field in the package file during this script - - sed -i -r "/version/s/([0-9\.]+)/\1-${NPM_TAG}.${CI_JOB_ID}/g" packages/primitives/package.json - - only: - - development - - # Use the common template to publish the library. - extends: .publish_to_npm + # Configure what tag to use for this publication. + variables: + NPM_TAG: 'development' + script: + # add the NPM_TAG to the version field in the package file during this script + - sed -i -r "/version/s/([0-9\.]+)/\1-${NPM_TAG}.${CI_JOB_ID}/g" packages/primitives/package.json + # set our npm token and then use lerna to publish all packages that are not marked as "private". + - npm config set //registry.npmjs.org/:_authToken ${NPM_AUTH_TOKEN} + - npx lerna publish from-package --no-private --yes --registry https://registry.npmjs.org/ --tag ${NPM_TAG} + only: + - development # Publish the documentation to GitLab Pages (for now). pages: diff --git a/lerna.json b/lerna.json index 6998f2a..5fb2380 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,5 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "packages": [ - "packages/*" - ], + "packages": ["packages/*"], "version": "0.0.1" } diff --git a/packages/docs/src/tools/index.md b/packages/docs/src/tools/index.md index 2d08ac6..2de2c0d 100644 --- a/packages/docs/src/tools/index.md +++ b/packages/docs/src/tools/index.md @@ -3,4 +3,5 @@ + TODO: Once we have other tools, we might want to turn this into a page like that on Quick Start that presents a "box" of each Tool Group. diff --git a/packages/docs/src/tools/primitives.md b/packages/docs/src/tools/primitives.md index 4f7531e..23f27de 100644 --- a/packages/docs/src/tools/primitives.md +++ b/packages/docs/src/tools/primitives.md @@ -24,26 +24,31 @@ import { # Primitive Tools ## Address +

A Utility tool for converting between different address formats.

- +
## Block Header +

A utility tool for converting between different byte representations.

- +
## Bytes +

A utility tool for converting between different byte representations.

@@ -54,93 +59,111 @@ import {
## Hasher +

A utility tool for computing various cryptographic hashes commonly used in Bitcoin Cash.

- +
## HD Private Node +

A utility tool for generating and manipulating HD Private Nodes.

- +
## HD Public Node +

A utility tool for generating and manipulating HD Public Nodes.

- +
## Mnemonic +

A utility tool for generating and validating BIP39 Mnemonics. Note that mnemonics will be normalized by removing redundant whitespace and will also be validated against the BIP39 English Word List (other word-lists can be specified via the API)

- +
## Private Key +

A utility tool for generating and manipulating Private Keys.

- +
## Public Key +

A utility tool for generating and manipulating Public Keys.

- +
## Satoshis +

A utility tool for converting between Bitcoin Cash value units.

- +
## Script +

A utility tool for generating and manipulating Script objects.

- +
## Transaction +

A utility tool for generating and manipulating Transaction objects.

- +
diff --git a/packages/docs/src/tools/stack/utils.md b/packages/docs/src/tools/stack/utils.md index 0707e01..d3777f7 100644 --- a/packages/docs/src/tools/stack/utils.md +++ b/packages/docs/src/tools/stack/utils.md @@ -12,12 +12,14 @@ import { # Utils ## Encryption +

A Utility tool for converting between different address formats.

- +
diff --git a/packages/primitives/package.json b/packages/primitives/package.json index 278a2b9..bc6e8e0 100644 --- a/packages/primitives/package.json +++ b/packages/primitives/package.json @@ -12,10 +12,12 @@ "scripts": { "build": "tsc --build --clean && tsc --build", "prepublishOnly": "npm run build", - "test": "vitest", + "test": "vitest --run", "test:coverage": "vitest run --coverage", + "test:watch": "vitest", "watch": "tsc --watch" }, "author": "", - "license": "ISC" + "license": "ISC", + "gitHead": "2d550cef4b179b17110363512ee0fde54a5da79a" } diff --git a/packages/primitives/src/mnemonic.ts b/packages/primitives/src/mnemonic.ts index 3717896..f7cfbb1 100644 --- a/packages/primitives/src/mnemonic.ts +++ b/packages/primitives/src/mnemonic.ts @@ -6,7 +6,7 @@ import { export type MnemonicRaw = { words: string[]; passphrase?: string; -} +}; /** * Class representing a BIP39 Mnemonic phrase. @@ -32,7 +32,10 @@ export class Mnemonic { * @throws {Error} If mnemonic could not be generated. * @returns Instance of Mnemonic. */ - public static from(phraseOrWords: string | Array, wordList: Array = bip39WordListEnglish) { + public static from( + phraseOrWords: string | Array, + wordList: Array = bip39WordListEnglish, + ) { // If this is a list of words... if (Array.isArray(phraseOrWords)) { return this.fromWords(phraseOrWords, wordList); @@ -49,7 +52,10 @@ export class Mnemonic { * @throws {Error} If mnemonic could not be generated. * @returns Instance of Mnemonic. */ - public static fromString(phrase: string, wordList: Array = bip39WordListEnglish) { + public static fromString( + phrase: string, + wordList: Array = bip39WordListEnglish, + ) { // Split into words and remove any whitespace. const allWords = phrase .trim() @@ -67,7 +73,10 @@ export class Mnemonic { * @throws {Error} If mnemonic could not be generated. * @returns Instance of Mnemonic. */ - public static fromWords(words: Array, wordList: Array = bip39WordListEnglish) { + public static fromWords( + words: Array, + wordList: Array = bip39WordListEnglish, + ) { // Check if last word is a passphrase by looking at total count const hasPassphrase = words.length === 13 || @@ -79,10 +88,10 @@ export class Mnemonic { // Parse words and optional passphrase const mnemonicRaw: MnemonicRaw = { words: hasPassphrase ? words.slice(0, -1) : words, - } + }; - if(hasPassphrase) { - mnemonicRaw.passphrase = words[words.length - 1] + if (hasPassphrase) { + mnemonicRaw.passphrase = words[words.length - 1]; } // Validate word count @@ -226,9 +235,9 @@ export class Mnemonic { * @returns Number of words. */ public toWords(includePassphrase: boolean = true): Array { - const words = [ ...this.mnemonic.words ]; + const words = [...this.mnemonic.words]; - if(this.mnemonic.passphrase && includePassphrase) { + if (this.mnemonic.passphrase && includePassphrase) { words.push(this.mnemonic.passphrase); } diff --git a/packages/primitives/tsconfig.json b/packages/primitives/tsconfig.json index 1d08f4d..8cd9b54 100644 --- a/packages/primitives/tsconfig.json +++ b/packages/primitives/tsconfig.json @@ -4,16 +4,9 @@ "outDir": "./dist", "rootDir": "./src", "paths": { - "~/*": [ - "./*" - ] + "~/*": ["./*"] } }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "dist" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] } diff --git a/packages/stack/package.json b/packages/stack/package.json index 30786a0..d6c90f0 100644 --- a/packages/stack/package.json +++ b/packages/stack/package.json @@ -24,8 +24,9 @@ "bench": "vitest bench", "build": "tsc --build --clean && tsc --build", "prepublishOnly": "npm run build", - "test": "vitest", + "test": "vitest --run", "test:coverage": "vitest run --coverage", + "test:watch": "vitest", "watch": "tsc --watch" }, "author": "", diff --git a/packages/stack/src/storage/store-indexeddb.ts b/packages/stack/src/storage/store-indexeddb.ts index 1672163..f323998 100644 --- a/packages/stack/src/storage/store-indexeddb.ts +++ b/packages/stack/src/storage/store-indexeddb.ts @@ -1,9 +1,7 @@ import { BaseStorage, BaseStore, StorageOpts } from './base-store.js'; import { StoreInMemorySynced } from './store-inmemory-synced.js'; -import { - Encryption, -} from '../utils'; +import { Encryption } from '../utils'; import { encodeExtendedJsonObject, diff --git a/packages/stack/tsconfig.json b/packages/stack/tsconfig.json index b35464b..add0b90 100644 --- a/packages/stack/tsconfig.json +++ b/packages/stack/tsconfig.json @@ -4,19 +4,10 @@ "outDir": "./dist", "rootDir": "./src", "paths": { - "~/*": [ - "./*" - ] + "~/*": ["./*"] }, - "lib": [ - "dom" - ] + "lib": ["dom"] }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "dist" - ] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] }