From dd1bf3dde2a8d7d5e29bbdbb79acc90ccdcd115a Mon Sep 17 00:00:00 2001 From: anupam-pandey Date: Thu, 20 Jun 2024 18:02:58 +0530 Subject: [PATCH 1/2] feat(statics): adding test token for solana tokens for go account Ticket: PX-4156 --- modules/statics/src/coins.ts | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/modules/statics/src/coins.ts b/modules/statics/src/coins.ts index 9aba10f668..e20a7426f2 100644 --- a/modules/statics/src/coins.ts +++ b/modules/statics/src/coins.ts @@ -1378,6 +1378,63 @@ export const coins = CoinMap.fromCoins([ UnderlyingAsset['sol:hnt'], SOL_TOKEN_FEATURES ), + tofcsolToken( + '24d678cf-e0f0-4cde-a338-d754289c5b27', + 'ofctsol:slnd', + 'testnet SOLEND', + 9, + UnderlyingAsset['sol:slnd'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( + '5610a965-d046-46e2-9077-40f496be3f18', + 'ofctsol:orca', + 'testnet ORCA', + 9, + UnderlyingAsset['sol:orca'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( + '6fd31137-ab29-441e-9136-8b4bad4f0477', + 'ofctsol:usdc', + 'testnet USD Coin', + 6, + UnderlyingAsset['sol:usdc'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( + '431a593e-0396-4d68-9db6-901d312df47d', + 'ofctsol:ray', + 'testnet Raydium', + 9, + UnderlyingAsset['sol:ray'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( + 'ff1955c9-988d-4c9e-86e7-cf589bb3d66f', + 'ofctsol:gmt', + 'testnet GMT', + 9, + UnderlyingAsset['sol:gmt'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( + '308d63c0-3a74-49c9-98d8-a4fe52e58226', + 'ofctsol:usdt', + 'testnet USD Tether', + 9, + UnderlyingAsset['sol:usdt'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( + '73a332da-1abf-4c4b-b5b5-f03fe36738cb', + 'ofctsol:srm', + 'testnet Serum', + 9, + UnderlyingAsset['sol:srm'], + SOL_TOKEN_FEATURES + ), + tofcsolToken( '20b20bc7-86b8-4f58-a8e9-a7cedbc2a507', 'ofctsol:gari', From 6490b9ad83d618317f2e92821e580d283110a865 Mon Sep 17 00:00:00 2001 From: Saravanan Mani Date: Thu, 20 Jun 2024 17:18:45 +0530 Subject: [PATCH 2/2] feat(abstract-lightning): add new abstract lightning coin module abstract lightning network coin module Ticket: BTC-1258 --- Dockerfile | 7 ++- modules/abstract-lightning/.eslintignore | 5 ++ modules/abstract-lightning/.gitignore | 3 ++ modules/abstract-lightning/.mocharc.yml | 8 +++ modules/abstract-lightning/.npmignore | 14 ++++++ modules/abstract-lightning/.prettierignore | 2 + modules/abstract-lightning/.prettierrc.yml | 3 ++ modules/abstract-lightning/README.md | 1 + modules/abstract-lightning/package.json | 42 ++++++++++++++++ .../src/abstractLightningCoin.ts | 49 +++++++++++++++++++ modules/abstract-lightning/src/index.ts | 1 + modules/abstract-lightning/tsconfig.json | 23 +++++++++ modules/bitgo/package.json | 1 + modules/bitgo/src/v2/coins/index.ts | 2 + modules/bitgo/test/browser/browser.spec.ts | 1 + modules/bitgo/tsconfig.json | 3 ++ tsconfig.packages.json | 3 ++ 17 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 modules/abstract-lightning/.eslintignore create mode 100644 modules/abstract-lightning/.gitignore create mode 100644 modules/abstract-lightning/.mocharc.yml create mode 100644 modules/abstract-lightning/.npmignore create mode 100644 modules/abstract-lightning/.prettierignore create mode 100644 modules/abstract-lightning/.prettierrc.yml create mode 100644 modules/abstract-lightning/README.md create mode 100644 modules/abstract-lightning/package.json create mode 100644 modules/abstract-lightning/src/abstractLightningCoin.ts create mode 100644 modules/abstract-lightning/src/index.ts create mode 100644 modules/abstract-lightning/tsconfig.json 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..68e3757659 --- /dev/null +++ b/modules/abstract-lightning/package.json @@ -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 ", + "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..311f72355b --- /dev/null +++ b/modules/abstract-lightning/src/abstractLightningCoin.ts @@ -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 { + 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" },