Skip to content

Commit 23503ec

Browse files
Merge pull request #6764 from BitGo/COIN-5301
refactor(cosmos): use hashToken and deprecate cosmosToken
2 parents 3679dc3 + f07377b commit 23503ec

File tree

12 files changed

+72
-114
lines changed

12 files changed

+72
-114
lines changed

modules/abstract-cosmos/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
]
3939
},
4040
"dependencies": {
41-
"@bitgo/sdk-api": "^1.66.2",
4241
"@bitgo/sdk-core": "^36.3.0",
4342
"@bitgo/sdk-lib-mpc": "^10.6.0",
4443
"@bitgo/secp256k1": "^1.4.0",
@@ -55,7 +54,6 @@
5554
"superagent": "^9.0.1"
5655
},
5756
"devDependencies": {
58-
"@bitgo/sdk-test": "^9.0.3",
5957
"@types/lodash": "^4.14.183"
6058
},
6159
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c"
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
export * from './lib';
2-
export * from './register';
32
export { CosmosCoin } from './cosmosCoin';
4-
export { CosmosToken } from './cosmosToken';

modules/abstract-cosmos/src/register.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

modules/abstract-cosmos/test/unit/cosmosToken.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

modules/bitgo/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"gen-docs": "typedoc"
4545
},
4646
"dependencies": {
47-
"@bitgo/abstract-cosmos": "^11.12.2",
4847
"@bitgo/abstract-lightning": "^6.2.9",
4948
"@bitgo/abstract-utxo": "^9.22.1",
5049
"@bitgo/account-lib": "^27.9.3",

modules/bitgo/src/v2/coinFactory.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import {
6565
CeloToken,
6666
Coredao,
6767
CoredaoToken,
68-
CosmosToken,
6968
CosmosSharedCoin,
7069
Coreum,
7170
Cronos,
@@ -83,6 +82,7 @@ import {
8382
EthLikeCoin,
8483
EvmCoin,
8584
Flr,
85+
HashToken,
8686
TethLikeCoin,
8787
FiatAED,
8888
FiatEur,
@@ -524,7 +524,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
524524
({ name, coinConstructor }) => coinFactory.register(name, coinConstructor)
525525
);
526526

527-
CosmosToken.createTokenConstructors([...tokens.bitcoin.cosmos.tokens, ...tokens.testnet.cosmos.tokens]).forEach(
527+
HashToken.createTokenConstructors([...tokens.bitcoin.cosmos.tokens, ...tokens.testnet.cosmos.tokens]).forEach(
528528
({ name, coinConstructor }) => coinFactory.register(name, coinConstructor)
529529
);
530530

@@ -965,35 +965,9 @@ export function getTokenConstructor(tokenConfig: TokenConfig): CoinConstructor |
965965
case 'vet':
966966
case 'tvet':
967967
return VetToken.createTokenConstructor(tokenConfig as VetTokenConfig);
968-
case 'asi':
969-
case 'tasi':
970-
case 'atom':
971-
case 'tatom':
972-
case 'baby':
973-
case 'tbaby':
974-
case 'bld':
975-
case 'tbld':
976-
case 'coreum':
977-
case 'tcoreum':
978-
case 'cronos':
979-
case 'tcronos':
980968
case 'hash':
981969
case 'thash':
982-
case 'injective':
983-
case 'tinjective':
984-
case 'initia':
985-
case 'tinitia':
986-
case 'osmo':
987-
case 'tosmo':
988-
case 'thorchain:rune':
989-
case 'tthorchain:rune':
990-
case 'sei':
991-
case 'tsei':
992-
case 'tia':
993-
case 'ttia':
994-
case 'zeta':
995-
case 'tzeta':
996-
return CosmosToken.createTokenConstructor(tokenConfig as CosmosTokenConfig);
970+
return HashToken.createTokenConstructor(tokenConfig as CosmosTokenConfig);
997971
default:
998972
return undefined;
999973
}

modules/bitgo/src/v2/coins/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Btg } from '@bitgo/sdk-coin-btg';
2121
import { Celo, CeloToken, Tcelo } from '@bitgo/sdk-coin-celo';
2222
import { Coredao, Tcoredao, CoredaoToken } from '@bitgo/sdk-coin-coredao';
2323
import { Coreum, Tcoreum } from '@bitgo/sdk-coin-coreum';
24-
import { CosmosToken } from '@bitgo/abstract-cosmos';
2524
import { CosmosSharedCoin } from '@bitgo/sdk-coin-cosmos';
2625
import { Cronos, Tcronos } from '@bitgo/sdk-coin-cronos';
2726
import { Cspr, Tcspr } from '@bitgo/sdk-coin-cspr';
@@ -35,7 +34,7 @@ import { EvmCoin, EthLikeErc20Token } from '@bitgo/sdk-coin-evm';
3534
import { Flr, Tflr } from '@bitgo/sdk-coin-flr';
3635
import { Ethw } from '@bitgo/sdk-coin-ethw';
3736
import { EthLikeCoin, TethLikeCoin } from '@bitgo/sdk-coin-ethlike';
38-
import { Hash, Thash } from '@bitgo/sdk-coin-hash';
37+
import { Hash, Thash, HashToken } from '@bitgo/sdk-coin-hash';
3938
import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar';
4039
import { Icp, Ticp } from '@bitgo/sdk-coin-icp';
4140
import { Initia, Tinitia } from '@bitgo/sdk-coin-initia';
@@ -95,7 +94,6 @@ export { Btg };
9594
export { Celo, CeloToken, Tcelo };
9695
export { Coredao, Tcoredao, CoredaoToken };
9796
export { Coreum, Tcoreum };
98-
export { CosmosToken };
9997
export { CosmosSharedCoin };
10098
export { Cronos, Tcronos };
10199
export { Cspr, Tcspr };
@@ -110,7 +108,7 @@ export { EthLikeCoin, TethLikeCoin };
110108
export { Etc, Tetc };
111109
export { EvmCoin, EthLikeErc20Token };
112110
export { Flr, Tflr };
113-
export { Hash, Thash };
111+
export { Hash, Thash, HashToken };
114112
export { Hbar, Thbar };
115113
export { Icp, Ticp };
116114
export { Initia, Tinitia };

modules/bitgo/test/browser/browser.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ describe('Coins', () => {
4949
EvmCoin: 1,
5050
Nep141Token: 1,
5151
WorldToken: 1,
52-
CosmosToken: 1,
5352
CosmosSharedCoin: 1,
5453
VetToken: 1,
5554
EthLikeErc20Token: 1,
55+
HashToken: 1,
5656
};
5757
Object.keys(BitGoJS.Coin)
5858
.filter((coinName) => !excludedKeys[coinName])

modules/abstract-cosmos/src/cosmosToken.ts renamed to modules/sdk-coin-hash/src/hashToken.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core';
22
import { CosmosTokenConfig, coins, tokens } from '@bitgo/statics';
3-
import { CosmosCoin } from './cosmosCoin';
3+
import { Hash } from './hash';
44

5-
export class CosmosToken extends CosmosCoin {
5+
export class HashToken extends Hash {
66
public readonly tokenConfig: CosmosTokenConfig;
77

88
constructor(bitgo: BitGoBase, tokenConfig: CosmosTokenConfig) {
@@ -12,16 +12,18 @@ export class CosmosToken extends CosmosCoin {
1212
}
1313

1414
static createTokenConstructor(config: CosmosTokenConfig): CoinConstructor {
15-
return (bitgo: BitGoBase) => new CosmosToken(bitgo, config);
15+
return (bitgo: BitGoBase) => new HashToken(bitgo, config);
1616
}
1717

1818
static createTokenConstructors(
1919
tokenConfigs: CosmosTokenConfig[] = [...tokens.bitcoin.cosmos.tokens, ...tokens.testnet.cosmos.tokens]
2020
): NamedCoinConstructor[] {
2121
const tokensCtors: NamedCoinConstructor[] = [];
2222
for (const token of tokenConfigs) {
23-
const tokenConstructor = CosmosToken.createTokenConstructor(token);
24-
tokensCtors.push({ name: token.type, coinConstructor: tokenConstructor });
23+
if (token.coin === 'hash' || token.coin === 'thash') {
24+
const tokenConstructor = HashToken.createTokenConstructor(token);
25+
tokensCtors.push({ name: token.type, coinConstructor: tokenConstructor });
26+
}
2527
}
2628
return tokensCtors;
2729
}
@@ -55,8 +57,7 @@ export class CosmosToken extends CosmosCoin {
5557
}
5658

5759
getFullName(): string {
58-
const displayCoin = this.getFamily();
59-
return `${displayCoin.charAt(0).toUpperCase() + displayCoin.slice(1)} Token`;
60+
return 'Hash Token';
6061
}
6162

6263
getBaseFactor(): number {

modules/sdk-coin-hash/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './hash';
22
export * from './lib';
33
export * from './register';
44
export * from './thash';
5+
export * from './hashToken';

0 commit comments

Comments
 (0)