diff --git a/Dockerfile b/Dockerfile index 9841934695..fa00d92582 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ COPY --from=builder /tmp/bitgo/modules/blake2b /var/modules/blake2b/ COPY --from=builder /tmp/bitgo/modules/blake2b-wasm /var/modules/blake2b-wasm/ COPY --from=builder /tmp/bitgo/modules/bitgo /var/modules/bitgo/ COPY --from=builder /tmp/bitgo/modules/abstract-utxo /var/modules/abstract-utxo/ +COPY --from=builder /tmp/bitgo/modules/abstract-lightning /var/modules/abstract-lightning/ COPY --from=builder /tmp/bitgo/modules/blockapis /var/modules/blockapis/ COPY --from=builder /tmp/bitgo/modules/sdk-api /var/modules/sdk-api/ COPY --from=builder /tmp/bitgo/modules/unspents /var/modules/unspents/ @@ -115,6 +116,7 @@ cd /var/modules/blake2b && yarn link && \ cd /var/modules/blake2b-wasm && yarn link && \ cd /var/modules/bitgo && yarn link && \ cd /var/modules/abstract-utxo && yarn link && \ +cd /var/modules/abstract-lightning && yarn link && \ cd /var/modules/blockapis && yarn link && \ cd /var/modules/sdk-api && yarn link && \ cd /var/modules/unspents && yarn link && \ @@ -185,6 +187,7 @@ RUN cd /var/bitgo-express && \ yarn link @bitgo/blake2b-wasm && \ yarn link bitgo && \ yarn link @bitgo/abstract-utxo && \ + yarn link @bitgo/abstract-lightning && \ yarn link @bitgo/blockapis && \ yarn link @bitgo/sdk-api && \ yarn link @bitgo/unspents && \ @@ -244,9 +247,9 @@ RUN cd /var/bitgo-express && \ #LINK_END #LABEL_START -LABEL created="Fri, 14 Jun 2024 19:33:53 GMT" +LABEL created="Thu, 20 Jun 2024 08:36:08 GMT" LABEL version=10.0.1 -LABEL git_hash=494873a9a815a1944efe443ebcfb8c6d16e5905c +LABEL git_hash=43ca8bc9facbe84d6dbf8cd6dc25da59a35aaf03 #LABEL_END USER node diff --git a/modules/abstract-lightning/.eslintignore b/modules/abstract-lightning/.eslintignore new file mode 100644 index 0000000000..190f83e0df --- /dev/null +++ b/modules/abstract-lightning/.eslintignore @@ -0,0 +1,5 @@ +node_modules +.idea +public +dist + diff --git a/modules/abstract-lightning/.gitignore b/modules/abstract-lightning/.gitignore new file mode 100644 index 0000000000..67ccce4c64 --- /dev/null +++ b/modules/abstract-lightning/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +.idea/ +dist/ diff --git a/modules/abstract-lightning/.mocharc.yml b/modules/abstract-lightning/.mocharc.yml new file mode 100644 index 0000000000..95814796d1 --- /dev/null +++ b/modules/abstract-lightning/.mocharc.yml @@ -0,0 +1,8 @@ +require: 'ts-node/register' +timeout: '60000' +reporter: 'min' +reporter-option: + - 'cdn=true' + - 'json=false' +exit: true +spec: ['test/unit/**/*.ts'] diff --git a/modules/abstract-lightning/.npmignore b/modules/abstract-lightning/.npmignore new file mode 100644 index 0000000000..d5fb3a098c --- /dev/null +++ b/modules/abstract-lightning/.npmignore @@ -0,0 +1,14 @@ +!dist/ +dist/test/ +dist/tsconfig.tsbuildinfo +.idea/ +.prettierrc.yml +tsconfig.json +src/ +test/ +scripts/ +.nyc_output +CODEOWNERS +node_modules/ +.prettierignore +.mocharc.js diff --git a/modules/abstract-lightning/.prettierignore b/modules/abstract-lightning/.prettierignore new file mode 100644 index 0000000000..3a11d6af29 --- /dev/null +++ b/modules/abstract-lightning/.prettierignore @@ -0,0 +1,2 @@ +.nyc_output/ +dist/ diff --git a/modules/abstract-lightning/.prettierrc.yml b/modules/abstract-lightning/.prettierrc.yml new file mode 100644 index 0000000000..7c3d8dd32a --- /dev/null +++ b/modules/abstract-lightning/.prettierrc.yml @@ -0,0 +1,3 @@ +printWidth: 120 +singleQuote: true +trailingComma: 'es5' diff --git a/modules/abstract-lightning/README.md b/modules/abstract-lightning/README.md new file mode 100644 index 0000000000..589c5c4b9d --- /dev/null +++ b/modules/abstract-lightning/README.md @@ -0,0 +1 @@ +# BitGo abstract-lightning diff --git a/modules/abstract-lightning/package.json b/modules/abstract-lightning/package.json new file mode 100644 index 0000000000..e929abfbc2 --- /dev/null +++ b/modules/abstract-lightning/package.json @@ -0,0 +1,45 @@ +{ + "name": "@bitgo/abstract-lightning", + "version": "1.0.0", + "description": "BitGo SDK coin library for base Lightning Network coin implementation", + "main": "./dist/src/index.js", + "types": "./dist/src/index.d.ts", + "scripts": { + "build": "yarn tsc --build --incremental --verbose .", + "fmt": "prettier --write .", + "check-fmt": "prettier --check .", + "clean": "rm -r ./dist", + "lint": "eslint --quiet .", + "prepare": "npm run build", + "test": "npm run coverage", + "coverage": "nyc -- npm run unit-test", + "unit-test": "mocha" + }, + "author": "BitGo SDK Team ", + "license": "MIT", + "engines": { + "node": ">=18 <21" + }, + "repository": { + "type": "git", + "url": "https://github.com/BitGo/BitGoJS.git", + "directory": "modules/abstract-lightning" + }, + "lint-staged": { + "*.{js,ts}": [ + "yarn prettier --write", + "yarn eslint --fix" + ] + }, + "publishConfig": { + "access": "public" + }, + "nyc": { + "extension": [ + ".ts" + ] + }, + "dependencies": { + "@bitgo/sdk-core": "^27.1.0" + } +} diff --git a/modules/abstract-lightning/src/abstractLightningCoin.ts b/modules/abstract-lightning/src/abstractLightningCoin.ts new file mode 100644 index 0000000000..38f1f9bc22 --- /dev/null +++ b/modules/abstract-lightning/src/abstractLightningCoin.ts @@ -0,0 +1,52 @@ +import { + BaseCoin, + BitGoBase, + KeyPair, + ParsedTransaction, + ParseTransactionOptions, + SignedTransaction, + SignTransactionOptions, + VerifyAddressOptions, + VerifyTransactionOptions, +} from '@bitgo/sdk-core'; + +export abstract class AbstractLightningCoin extends BaseCoin { + protected constructor(bitgo: BitGoBase) { + super(bitgo); + } + + /** + * Factor between the coin's base unit and its smallest subdivison + */ + public getBaseFactor(): number { + throw new Error('Method not implemented.'); + } + + verifyTransaction(params: VerifyTransactionOptions): Promise { + throw new Error('Method not implemented.'); + } + + isWalletAddress(params: VerifyAddressOptions): Promise { + throw new Error('Method not implemented.'); + } + + parseTransaction(params: ParseTransactionOptions): Promise { + throw new Error('Method not implemented.'); + } + + generateKeyPair(seed?: Buffer): KeyPair { + throw new Error('Method not implemented.'); + } + + isValidPub(pub: string): boolean { + throw new Error('Method not implemented.'); + } + + isValidAddress(address: string): boolean { + throw new Error('Method not implemented.'); + } + + signTransaction(params: SignTransactionOptions): Promise { + throw new Error('Method not implemented.'); + } +} diff --git a/modules/abstract-lightning/src/index.ts b/modules/abstract-lightning/src/index.ts new file mode 100644 index 0000000000..29136e403d --- /dev/null +++ b/modules/abstract-lightning/src/index.ts @@ -0,0 +1 @@ +export * from './abstractLightningCoin'; diff --git a/modules/abstract-lightning/tsconfig.json b/modules/abstract-lightning/tsconfig.json new file mode 100644 index 0000000000..339ace24a2 --- /dev/null +++ b/modules/abstract-lightning/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./", + "strictPropertyInitialization": false, + "esModuleInterop": true, + "typeRoots": ["../../types", "./node_modules/@types", "../../node_modules/@types"] + }, + "include": ["src/**/*", "test/**/*"], + "exclude": ["node_modules"], + "references": [ + { + "path": "../sdk-api" + }, + { + "path": "../sdk-core" + }, + { + "path": "../sdk-test" + } + ] +} diff --git a/modules/bitgo/package.json b/modules/bitgo/package.json index 0ae3e4103d..ca21b77339 100644 --- a/modules/bitgo/package.json +++ b/modules/bitgo/package.json @@ -45,6 +45,7 @@ }, "dependencies": { "@bitgo/abstract-utxo": "^8.7.0", + "@bitgo/abstract-lightning": "^1.0.0", "@bitgo/account-lib": "^23.0.19", "@bitgo/blockapis": "^1.9.5", "@bitgo/sdk-api": "^1.49.0", diff --git a/modules/bitgo/src/v2/coins/index.ts b/modules/bitgo/src/v2/coins/index.ts index e181926ce5..8aa8029cc9 100644 --- a/modules/bitgo/src/v2/coins/index.ts +++ b/modules/bitgo/src/v2/coins/index.ts @@ -1,4 +1,5 @@ import { AbstractUtxoCoin } from '@bitgo/abstract-utxo'; +import { AbstractLightningCoin } from '@bitgo/abstract-lightning'; import { Ada, Tada } from '@bitgo/sdk-coin-ada'; import { Algo, AlgoToken, Talgo } from '@bitgo/sdk-coin-algo'; import { Arbeth, Tarbeth, ArbethToken } from '@bitgo/sdk-coin-arbeth'; @@ -49,6 +50,7 @@ import { Tzeta, Zeta } from '@bitgo/sdk-coin-zeta'; import { Zketh, Tzketh, ZkethToken } from '@bitgo/sdk-coin-zketh'; export { AbstractUtxoCoin }; +export { AbstractLightningCoin }; export { Algo, AlgoToken, Talgo }; export { Arbeth, Tarbeth, ArbethToken }; export { Ada, Tada }; diff --git a/modules/bitgo/test/browser/browser.spec.ts b/modules/bitgo/test/browser/browser.spec.ts index 73ef4dcea5..0385fe633b 100644 --- a/modules/bitgo/test/browser/browser.spec.ts +++ b/modules/bitgo/test/browser/browser.spec.ts @@ -12,6 +12,7 @@ describe('Coins', () => { // these objects are defined in BitGoJS.Coin, but are not coins in the traditional sense const excludedKeys = { AbstractUtxoCoin: 1, + AbstractLightningCoin: 1, Erc20Token: 1, EthLikeCoin: 1, TethLikeCoin: 1, diff --git a/modules/bitgo/tsconfig.json b/modules/bitgo/tsconfig.json index 4bd6d1411d..0127629f73 100644 --- a/modules/bitgo/tsconfig.json +++ b/modules/bitgo/tsconfig.json @@ -32,6 +32,9 @@ { "path": "../abstract-utxo" }, + { + "path": "../abstract-lightning" + }, { "path": "../sdk-api" }, diff --git a/tsconfig.packages.json b/tsconfig.packages.json index efac72e0da..20f3895ad1 100644 --- a/tsconfig.packages.json +++ b/tsconfig.packages.json @@ -10,6 +10,9 @@ { "path": "./modules/abstract-utxo" }, + { + "path": "./modules/abstract-lightning" + }, { "path": "./modules/account-lib" },