Skip to content
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
2 changes: 0 additions & 2 deletions modules/abstract-cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
]
},
"dependencies": {
"@bitgo/sdk-api": "^1.66.2",
"@bitgo/sdk-core": "^36.3.0",
"@bitgo/sdk-lib-mpc": "^10.6.0",
"@bitgo/secp256k1": "^1.4.0",
Expand All @@ -55,7 +54,6 @@
"superagent": "^9.0.1"
},
"devDependencies": {
"@bitgo/sdk-test": "^9.0.3",
"@types/lodash": "^4.14.183"
},
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c"
Expand Down
2 changes: 0 additions & 2 deletions modules/abstract-cosmos/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './lib';
export * from './register';
export { CosmosCoin } from './cosmosCoin';
export { CosmosToken } from './cosmosToken';
8 changes: 0 additions & 8 deletions modules/abstract-cosmos/src/register.ts

This file was deleted.

54 changes: 0 additions & 54 deletions modules/abstract-cosmos/test/unit/cosmosToken.ts

This file was deleted.

1 change: 0 additions & 1 deletion modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"gen-docs": "typedoc"
},
"dependencies": {
"@bitgo/abstract-cosmos": "^11.12.2",
"@bitgo/abstract-lightning": "^6.2.9",
"@bitgo/abstract-utxo": "^9.22.1",
"@bitgo/account-lib": "^27.9.3",
Expand Down
32 changes: 3 additions & 29 deletions modules/bitgo/src/v2/coinFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import {
CeloToken,
Coredao,
CoredaoToken,
CosmosToken,
CosmosSharedCoin,
Coreum,
Cronos,
Expand All @@ -83,6 +82,7 @@ import {
EthLikeCoin,
EvmCoin,
Flr,
HashToken,
TethLikeCoin,
FiatAED,
FiatEur,
Expand Down Expand Up @@ -524,7 +524,7 @@ export function registerCoinConstructors(coinFactory: CoinFactory, coinMap: Coin
({ name, coinConstructor }) => coinFactory.register(name, coinConstructor)
);

CosmosToken.createTokenConstructors([...tokens.bitcoin.cosmos.tokens, ...tokens.testnet.cosmos.tokens]).forEach(
HashToken.createTokenConstructors([...tokens.bitcoin.cosmos.tokens, ...tokens.testnet.cosmos.tokens]).forEach(
({ name, coinConstructor }) => coinFactory.register(name, coinConstructor)
);

Expand Down Expand Up @@ -965,35 +965,9 @@ export function getTokenConstructor(tokenConfig: TokenConfig): CoinConstructor |
case 'vet':
case 'tvet':
return VetToken.createTokenConstructor(tokenConfig as VetTokenConfig);
case 'asi':
case 'tasi':
case 'atom':
case 'tatom':
case 'baby':
case 'tbaby':
case 'bld':
case 'tbld':
case 'coreum':
case 'tcoreum':
case 'cronos':
case 'tcronos':
case 'hash':
case 'thash':
case 'injective':
case 'tinjective':
case 'initia':
case 'tinitia':
case 'osmo':
case 'tosmo':
case 'thorchain:rune':
case 'tthorchain:rune':
case 'sei':
case 'tsei':
case 'tia':
case 'ttia':
case 'zeta':
case 'tzeta':
return CosmosToken.createTokenConstructor(tokenConfig as CosmosTokenConfig);
return HashToken.createTokenConstructor(tokenConfig as CosmosTokenConfig);
default:
return undefined;
}
Expand Down
6 changes: 2 additions & 4 deletions modules/bitgo/src/v2/coins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { Btg } from '@bitgo/sdk-coin-btg';
import { Celo, CeloToken, Tcelo } from '@bitgo/sdk-coin-celo';
import { Coredao, Tcoredao, CoredaoToken } from '@bitgo/sdk-coin-coredao';
import { Coreum, Tcoreum } from '@bitgo/sdk-coin-coreum';
import { CosmosToken } from '@bitgo/abstract-cosmos';
import { CosmosSharedCoin } from '@bitgo/sdk-coin-cosmos';
import { Cronos, Tcronos } from '@bitgo/sdk-coin-cronos';
import { Cspr, Tcspr } from '@bitgo/sdk-coin-cspr';
Expand All @@ -35,7 +34,7 @@ import { EvmCoin, EthLikeErc20Token } from '@bitgo/sdk-coin-evm';
import { Flr, Tflr } from '@bitgo/sdk-coin-flr';
import { Ethw } from '@bitgo/sdk-coin-ethw';
import { EthLikeCoin, TethLikeCoin } from '@bitgo/sdk-coin-ethlike';
import { Hash, Thash } from '@bitgo/sdk-coin-hash';
import { Hash, Thash, HashToken } from '@bitgo/sdk-coin-hash';
import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar';
import { Icp, Ticp } from '@bitgo/sdk-coin-icp';
import { Initia, Tinitia } from '@bitgo/sdk-coin-initia';
Expand Down Expand Up @@ -95,7 +94,6 @@ export { Btg };
export { Celo, CeloToken, Tcelo };
export { Coredao, Tcoredao, CoredaoToken };
export { Coreum, Tcoreum };
export { CosmosToken };
export { CosmosSharedCoin };
export { Cronos, Tcronos };
export { Cspr, Tcspr };
Expand All @@ -110,7 +108,7 @@ export { EthLikeCoin, TethLikeCoin };
export { Etc, Tetc };
export { EvmCoin, EthLikeErc20Token };
export { Flr, Tflr };
export { Hash, Thash };
export { Hash, Thash, HashToken };
export { Hbar, Thbar };
export { Icp, Ticp };
export { Initia, Tinitia };
Expand Down
2 changes: 1 addition & 1 deletion modules/bitgo/test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ describe('Coins', () => {
EvmCoin: 1,
Nep141Token: 1,
WorldToken: 1,
CosmosToken: 1,
CosmosSharedCoin: 1,
VetToken: 1,
EthLikeErc20Token: 1,
HashToken: 1,
};
Object.keys(BitGoJS.Coin)
.filter((coinName) => !excludedKeys[coinName])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core';
import { CosmosTokenConfig, coins, tokens } from '@bitgo/statics';
import { CosmosCoin } from './cosmosCoin';
import { Hash } from './hash';

export class CosmosToken extends CosmosCoin {
export class HashToken extends Hash {
public readonly tokenConfig: CosmosTokenConfig;

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

static createTokenConstructor(config: CosmosTokenConfig): CoinConstructor {
return (bitgo: BitGoBase) => new CosmosToken(bitgo, config);
return (bitgo: BitGoBase) => new HashToken(bitgo, config);
}

static createTokenConstructors(
tokenConfigs: CosmosTokenConfig[] = [...tokens.bitcoin.cosmos.tokens, ...tokens.testnet.cosmos.tokens]
): NamedCoinConstructor[] {
const tokensCtors: NamedCoinConstructor[] = [];
for (const token of tokenConfigs) {
const tokenConstructor = CosmosToken.createTokenConstructor(token);
tokensCtors.push({ name: token.type, coinConstructor: tokenConstructor });
if (token.coin === 'hash' || token.coin === 'thash') {
const tokenConstructor = HashToken.createTokenConstructor(token);
tokensCtors.push({ name: token.type, coinConstructor: tokenConstructor });
}
}
return tokensCtors;
}
Expand Down Expand Up @@ -55,8 +57,7 @@ export class CosmosToken extends CosmosCoin {
}

getFullName(): string {
const displayCoin = this.getFamily();
return `${displayCoin.charAt(0).toUpperCase() + displayCoin.slice(1)} Token`;
return 'Hash Token';
}

getBaseFactor(): number {
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-coin-hash/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './hash';
export * from './lib';
export * from './register';
export * from './thash';
export * from './hashToken';
9 changes: 3 additions & 6 deletions modules/sdk-coin-hash/src/register.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { BitGoBase } from '@bitgo/sdk-core';
import { CosmosToken } from '@bitgo/abstract-cosmos';
import { Hash } from './hash';
import { Thash } from './thash';
import { HashToken } from './hashToken';

export const register = (sdk: BitGoBase): void => {
sdk.register('hash', Hash.createInstance);
sdk.register('thash', Thash.createInstance);
CosmosToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
const baseCoin = name.split(':')[0];
if (baseCoin === 'hash' || baseCoin === 'thash') {
sdk.register(name, coinConstructor);
}
HashToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
};
54 changes: 54 additions & 0 deletions modules/sdk-coin-hash/test/unit/hashToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'should';

import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';
import { BitGoAPI } from '@bitgo/sdk-api';
import { HashToken } from '../../src';
import HashUtils from '../../src/lib/utils';

describe('Hash Tokens', function () {
let bitgo: TestBitGoAPI;
let mainnetHashToken;
let testnetHashToken;
const testnetTokenName = 'thash:ylds';
const mainnetTokenName = 'hash:ylds';

before(function () {
bitgo = TestBitGo.decorate(BitGoAPI, { env: 'test' });
HashToken.createTokenConstructors().forEach(({ name, coinConstructor }) => {
bitgo.safeRegister(name, coinConstructor);
});
bitgo.initializeTestVars();
mainnetHashToken = bitgo.coin(mainnetTokenName);
testnetHashToken = bitgo.coin(testnetTokenName);
});

it('should return constants for Hash YLDS testnet token', function () {
testnetHashToken.getChain().should.equal(testnetTokenName);
testnetHashToken.getBaseChain().should.equal('thash');
testnetHashToken.getFullName().should.equal('Hash Token');
testnetHashToken.getBaseFactor().should.equal(1e6);
testnetHashToken.type.should.equal(testnetTokenName);
testnetHashToken.name.should.equal('Testnet YLDS Token');
testnetHashToken.coin.should.equal('thash');
testnetHashToken.network.should.equal('Testnet');
testnetHashToken.denom.should.equal('uylds.fcc');
testnetHashToken.decimalPlaces.should.equal(6);
});

it('should return constants for Hash YLDS mainnet token', function () {
mainnetHashToken.getChain().should.equal(mainnetTokenName);
mainnetHashToken.getBaseChain().should.equal('hash');
mainnetHashToken.getFullName().should.equal('Hash Token');
mainnetHashToken.getBaseFactor().should.equal(1e6);
mainnetHashToken.type.should.equal(mainnetTokenName);
mainnetHashToken.name.should.equal('YLDS Token');
mainnetHashToken.coin.should.equal('hash');
mainnetHashToken.network.should.equal('Mainnet');
mainnetHashToken.denom.should.equal('uylds.fcc');
mainnetHashToken.decimalPlaces.should.equal(6);
});

it('should return denomination for YLDS token on hash using hash as coinFamily', function () {
HashUtils.getTokenDenomsUsingCoinFamily('hash').should.deepEqual(['uylds.fcc']);
});
});
Loading