Skip to content

Commit 8e5f47c

Browse files
fix(statics): backwards compat enum type
TICKET: WP-5182
1 parent 8dfec04 commit 8e5f47c

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

modules/statics/src/base.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export const CoinKind = {
1111
FIAT: 'fiat',
1212
} as const;
1313

14-
export type CoinKind = (typeof CoinKind)[keyof typeof CoinKind];
14+
export type CoinKindKey = keyof typeof CoinKind;
15+
export type CoinKindValue = (typeof CoinKind)[keyof typeof CoinKind];
16+
export type CoinKind = CoinKindValue;
1517

1618
/**
1719
* The coin family links related variants of a single coin together.
@@ -101,7 +103,9 @@ export const CoinFamily = {
101103
ZKETH: 'zketh',
102104
} as const;
103105

104-
export type CoinFamily = (typeof CoinFamily)[keyof typeof CoinFamily];
106+
export type CoinFamilyKey = keyof typeof CoinFamily;
107+
export type CoinFamilyValue = (typeof CoinFamily)[keyof typeof CoinFamily];
108+
export type CoinFamily = CoinFamilyValue;
105109

106110
/**
107111
* Coin features are yes or no questions about what a coin requires or is capable of.
@@ -406,7 +410,9 @@ export const CoinFeature = {
406410
REBASE_TOKEN: 'rebase-token',
407411
} as const;
408412

409-
export type CoinFeature = (typeof CoinFeature)[keyof typeof CoinFeature];
413+
export type CoinFeatureKey = keyof typeof CoinFeature;
414+
export type CoinFeatureValue = (typeof CoinFeature)[keyof typeof CoinFeature];
415+
export type CoinFeature = CoinFeatureValue;
410416

411417
/**
412418
* Some coins are representations of another underlying asset class. An example
@@ -2814,7 +2820,9 @@ export const UnderlyingAsset = {
28142820
USD: 'usd',
28152821
} as const;
28162822

2817-
export type UnderlyingAsset = (typeof UnderlyingAsset)[keyof typeof UnderlyingAsset];
2823+
export type UnderLyingAssetKey = keyof typeof UnderlyingAsset;
2824+
export type UnderlyingAssetValue = (typeof UnderlyingAsset)[keyof typeof UnderlyingAsset];
2825+
export type UnderlyingAsset = UnderlyingAssetValue;
28182826

28192827
/**
28202828
* This is the curve BitGo signs against with the user, backup and BitGo key.
@@ -2824,7 +2832,9 @@ export const KeyCurve = {
28242832
Ed25519: 'ed25519',
28252833
} as const;
28262834

2827-
export type KeyCurve = (typeof KeyCurve)[keyof typeof KeyCurve];
2835+
export type KeyCurveKey = keyof typeof KeyCurve;
2836+
export type KeyCurveValue = (typeof KeyCurve)[keyof typeof KeyCurve];
2837+
export type KeyCurve = KeyCurveValue;
28282838

28292839
/**
28302840
* This enum contains the base units for the coins that BitGo supports
@@ -2883,7 +2893,9 @@ export const BaseUnit = {
28832893
TASI: 'atestfet',
28842894
} as const;
28852895

2886-
export type BaseUnit = (typeof BaseUnit)[keyof typeof BaseUnit];
2896+
export type BaseUnitKey = keyof typeof BaseUnit;
2897+
export type BaseUnitValue = (typeof BaseUnit)[keyof typeof BaseUnit];
2898+
export type BaseUnit = BaseUnitValue;
28872899

28882900
export interface BaseCoinConstructorOptions {
28892901
id: string; // uuid v4

modules/statics/test/unit/base.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import should from 'should';
2-
import { UnderlyingAsset } from '../../src/base';
2+
import { UnderlyingAsset, UnderlyingAssetValue } from '../../src/base';
33

44
describe('UnderlyingAsset', function () {
55
it('UnderlyingAsset values should be unique', function () {
66
const underlyingAssetSet = new Set();
7-
const duplicateAssets: (typeof UnderlyingAsset)[] = [];
7+
const duplicateAssets: UnderlyingAssetValue[] = [];
88

9-
for (const asset in UnderlyingAsset) {
10-
const assetValue = UnderlyingAsset[asset].toUpperCase();
9+
for (const asset of Object.keys(UnderlyingAsset)) {
10+
const assetValue = UnderlyingAsset[asset as keyof typeof UnderlyingAsset].toUpperCase() as UnderlyingAssetValue;
1111
if (underlyingAssetSet.has(assetValue)) {
1212
duplicateAssets.push(assetValue);
1313
}

0 commit comments

Comments
 (0)