From eb995457d7787af073f0a9eafe6e4d420228f5f0 Mon Sep 17 00:00:00 2001 From: Akash Gianchandani Date: Thu, 12 Oct 2023 18:53:05 +0530 Subject: [PATCH] feat(abstract-eth): add abstractethliketsscoin class WIN-497 TICKET: WIN-497 --- .../abstract-eth/src/abstractEthLikeMPCCoin.ts | 17 +++++++++++++++++ modules/abstract-eth/src/ethLikeMPCToken.ts | 17 +++++++++++++++++ modules/abstract-eth/src/index.ts | 2 ++ modules/sdk-coin-arbeth/src/arbeth.ts | 16 +++------------- modules/sdk-coin-bsc/src/bsc.ts | 16 +++------------- modules/sdk-coin-bsc/src/bscToken.ts | 14 +++----------- 6 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 modules/abstract-eth/src/abstractEthLikeMPCCoin.ts create mode 100644 modules/abstract-eth/src/ethLikeMPCToken.ts diff --git a/modules/abstract-eth/src/abstractEthLikeMPCCoin.ts b/modules/abstract-eth/src/abstractEthLikeMPCCoin.ts new file mode 100644 index 0000000000..709627d204 --- /dev/null +++ b/modules/abstract-eth/src/abstractEthLikeMPCCoin.ts @@ -0,0 +1,17 @@ +/** + * @prettier + */ +import { MPCAlgorithm } from '@bitgo/sdk-core'; +import { AbstractEthLikeCoin } from './abstractEthLikeCoin'; + +export abstract class AbstractEthLikeMPCCoin extends AbstractEthLikeCoin { + /** @inheritDoc */ + supportsTss(): boolean { + return true; + } + + /** @inheritDoc */ + getMPCAlgorithm(): MPCAlgorithm { + return 'ecdsa'; + } +} diff --git a/modules/abstract-eth/src/ethLikeMPCToken.ts b/modules/abstract-eth/src/ethLikeMPCToken.ts new file mode 100644 index 0000000000..47b5caab87 --- /dev/null +++ b/modules/abstract-eth/src/ethLikeMPCToken.ts @@ -0,0 +1,17 @@ +/** + * @prettier + */ +import { MPCAlgorithm } from '@bitgo/sdk-core'; +import { EthLikeToken } from './ethLikeToken'; + +export abstract class EthLikeMPCToken extends EthLikeToken { + /** @inheritDoc */ + supportsTss(): boolean { + return true; + } + + /** @inheritDoc */ + getMPCAlgorithm(): MPCAlgorithm { + return 'ecdsa'; + } +} diff --git a/modules/abstract-eth/src/index.ts b/modules/abstract-eth/src/index.ts index 55c7431455..7f0b554b57 100644 --- a/modules/abstract-eth/src/index.ts +++ b/modules/abstract-eth/src/index.ts @@ -1,2 +1,4 @@ export * from './abstractEthLikeCoin'; export * from './ethLikeToken'; +export * from './abstractEthLikeMPCCoin'; +export * from './ethLikeMPCToken'; diff --git a/modules/sdk-coin-arbeth/src/arbeth.ts b/modules/sdk-coin-arbeth/src/arbeth.ts index 80cdfd43ed..f9a9fa06ee 100644 --- a/modules/sdk-coin-arbeth/src/arbeth.ts +++ b/modules/sdk-coin-arbeth/src/arbeth.ts @@ -1,10 +1,10 @@ -import { BaseCoin, BitGoBase, MPCAlgorithm } from '@bitgo/sdk-core'; +import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics'; -import { AbstractEthLikeCoin } from '@bitgo/abstract-eth'; +import { AbstractEthLikeMPCCoin } from '@bitgo/abstract-eth'; import { TransactionBuilder as EthTransactionBuilder } from '@bitgo/sdk-coin-eth'; import { TransactionBuilder } from './lib'; -export class Arbeth extends AbstractEthLikeCoin { +export class Arbeth extends AbstractEthLikeMPCCoin { protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly) { super(bitgo, staticsCoin); } @@ -16,14 +16,4 @@ export class Arbeth extends AbstractEthLikeCoin { protected getTransactionBuilder(): EthTransactionBuilder { return new TransactionBuilder(coins.get(this.getBaseChain())); } - - /** @inheritDoc */ - supportsTss(): boolean { - return true; - } - - /** @inheritDoc */ - getMPCAlgorithm(): MPCAlgorithm { - return 'ecdsa'; - } } diff --git a/modules/sdk-coin-bsc/src/bsc.ts b/modules/sdk-coin-bsc/src/bsc.ts index 5356b8915f..6d0b197bba 100644 --- a/modules/sdk-coin-bsc/src/bsc.ts +++ b/modules/sdk-coin-bsc/src/bsc.ts @@ -1,10 +1,10 @@ -import { BaseCoin, BitGoBase, MPCAlgorithm } from '@bitgo/sdk-core'; +import { BaseCoin, BitGoBase } from '@bitgo/sdk-core'; import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics'; -import { AbstractEthLikeCoin } from '@bitgo/abstract-eth'; +import { AbstractEthLikeMPCCoin } from '@bitgo/abstract-eth'; import { TransactionBuilder as EthTransactionBuilder } from '@bitgo/sdk-coin-eth'; import { TransactionBuilder } from './lib'; -export class Bsc extends AbstractEthLikeCoin { +export class Bsc extends AbstractEthLikeMPCCoin { protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly) { super(bitgo, staticsCoin); } @@ -17,16 +17,6 @@ export class Bsc extends AbstractEthLikeCoin { return new TransactionBuilder(coins.get(this.getBaseChain())); } - /** @inheritDoc */ - supportsTss(): boolean { - return true; - } - - /** @inheritDoc */ - getMPCAlgorithm(): MPCAlgorithm { - return 'ecdsa'; - } - /** @inheritDoc */ allowsAccountConsolidations(): boolean { return true; diff --git a/modules/sdk-coin-bsc/src/bscToken.ts b/modules/sdk-coin-bsc/src/bscToken.ts index d5f09136de..f3489414ee 100644 --- a/modules/sdk-coin-bsc/src/bscToken.ts +++ b/modules/sdk-coin-bsc/src/bscToken.ts @@ -3,12 +3,12 @@ */ import { EthLikeTokenConfig } from '@bitgo/statics'; -import { BitGoBase, CoinConstructor, MPCAlgorithm, NamedCoinConstructor } from '@bitgo/sdk-core'; -import { CoinNames, EthLikeToken } from '@bitgo/abstract-eth'; +import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core'; +import { CoinNames, EthLikeMPCToken } from '@bitgo/abstract-eth'; export { EthLikeTokenConfig }; -export class BscToken extends EthLikeToken { +export class BscToken extends EthLikeMPCToken { public readonly tokenConfig: EthLikeTokenConfig; static coinNames: CoinNames = { Mainnet: 'bsc', @@ -28,12 +28,4 @@ export class BscToken extends EthLikeToken { getFullName(): string { return 'Bsc Token'; } - - supportsTss(): boolean { - return true; - } - - getMPCAlgorithm(): MPCAlgorithm { - return 'ecdsa'; - } }