Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(abstract-lightning): add new abstract lightning coin module #4644

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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 && \
Expand Down Expand Up @@ -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 && \
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions modules/abstract-lightning/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.idea
public
dist

3 changes: 3 additions & 0 deletions modules/abstract-lightning/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.idea/
dist/
8 changes: 8 additions & 0 deletions modules/abstract-lightning/.mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require: 'ts-node/register'
timeout: '60000'
reporter: 'min'
reporter-option:
- 'cdn=true'
- 'json=false'
exit: true
spec: ['test/unit/**/*.ts']
14 changes: 14 additions & 0 deletions modules/abstract-lightning/.npmignore
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions modules/abstract-lightning/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc_output/
dist/
3 changes: 3 additions & 0 deletions modules/abstract-lightning/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printWidth: 120
singleQuote: true
trailingComma: 'es5'
1 change: 1 addition & 0 deletions modules/abstract-lightning/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# BitGo abstract-lightning
42 changes: 42 additions & 0 deletions modules/abstract-lightning/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"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"
},
"author": "BitGo SDK Team <[email protected]>",
"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"
}
}
49 changes: 49 additions & 0 deletions modules/abstract-lightning/src/abstractLightningCoin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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);
}

getBaseFactor(): number {
throw new Error('Method not implemented.');
}

verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
throw new Error('Method not implemented.');
}

isWalletAddress(params: VerifyAddressOptions): Promise<boolean> {
throw new Error('Method not implemented.');
}

parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
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<SignedTransaction> {
throw new Error('Method not implemented.');
}
}
1 change: 1 addition & 0 deletions modules/abstract-lightning/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './abstractLightningCoin';
23 changes: 23 additions & 0 deletions modules/abstract-lightning/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 };
Expand Down
1 change: 1 addition & 0 deletions modules/bitgo/test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions modules/bitgo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
{
"path": "../abstract-utxo"
},
{
"path": "../abstract-lightning"
},
{
"path": "../sdk-api"
},
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
{
"path": "./modules/abstract-utxo"
},
{
"path": "./modules/abstract-lightning"
},
{
"path": "./modules/account-lib"
},
Expand Down
Loading