Skip to content

Commit f52bc45

Browse files
committed
feat(statics): use const instead of enum
BREAKING CHANGE: enums used in `statics/src/base` are changed to const, both the object and type are still exported but cannot rely on them being enums TICKET: CAAS-325
1 parent 1f7c624 commit f52bc45

File tree

9 files changed

+2691
-2625
lines changed

9 files changed

+2691
-2625
lines changed

modules/statics/src/base.ts

Lines changed: 2601 additions & 2555 deletions
Large diffs are not rendered by default.

modules/statics/src/coinFeatures.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,9 @@ export const AVAXC_FEATURES = [
6161
CoinFeature.MULTISIG,
6262
CoinFeature.EIP1559,
6363
];
64-
export const CELO_FEATURES = [
65-
...ETH_FEATURES,
66-
CoinFeature.MULTISIG_COLD,
67-
CoinFeature.MULTISIG,
68-
CoinFeature.EIP1559,
69-
].filter(
64+
export const CELO_FEATURES = (
65+
[...ETH_FEATURES, CoinFeature.MULTISIG_COLD, CoinFeature.MULTISIG, CoinFeature.EIP1559] as CoinFeature[]
66+
).filter(
7067
(feature) =>
7168
feature !== CoinFeature.CUSTODY &&
7269
feature !== CoinFeature.CUSTODY_BITGO_GERMANY &&
@@ -245,7 +242,7 @@ export const SOL_FEATURES = [
245242
CoinFeature.BULK_TRANSACTION,
246243
];
247244
export const TSOL_FEATURES = [...SOL_FEATURES, CoinFeature.BULK_TRANSACTION, CoinFeature.CUSTODY_BITGO_SINGAPORE];
248-
export const SOL_TOKEN_FEATURES = [
245+
export const SOL_TOKEN_FEATURES: CoinFeature[] = [
249246
...ACCOUNT_COIN_DEFAULT_FEATURES,
250247
CoinFeature.TSS,
251248
CoinFeature.TSS_COLD,

modules/statics/src/coins.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import { bscTokens } from './coins/bscTokens';
6262
import { polygonTokens } from './coins/polygonTokens';
6363
import { solTokens } from './coins/solTokens';
6464
import { CoinMap } from './map';
65-
import { Networks } from './networks';
65+
import { BaseNetwork, Networks } from './networks';
6666
import { networkFeatureMapForTokens } from './networkFeatureMapForTokens';
6767
import { utxoCoins } from './utxo';
6868
import { lightningCoins } from './lightning';
@@ -224,11 +224,13 @@ export const coins = CoinMap.fromCoins([
224224
BaseUnit.CSPR,
225225
CSPR_FEATURES.filter(
226226
(feature) =>
227-
![
228-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
229-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
230-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
231-
].includes(feature)
227+
!(
228+
[
229+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
230+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
231+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
232+
] as CoinFeature[]
233+
).includes(feature)
232234
)
233235
),
234236
account(
@@ -826,11 +828,13 @@ export const coins = CoinMap.fromCoins([
826828
BaseUnit.COREUM,
827829
COREUM_FEATURES.filter(
828830
(feature) =>
829-
![
830-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
831-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
832-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
833-
].includes(feature)
831+
!(
832+
[
833+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
834+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
835+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
836+
] as CoinFeature[]
837+
).includes(feature)
834838
)
835839
),
836840
account(
@@ -4273,7 +4277,7 @@ export function createTokenMapUsingTrimmedConfigDetails(
42734277
reducedTokenConfigMap: Record<string, TrimmedAmsTokenConfig[]>
42744278
): CoinMap {
42754279
const amsTokenConfigMap: Record<string, AmsTokenConfig[]> = {};
4276-
const networkNameMap = new Map(
4280+
const networkNameMap = new Map<string, BaseNetwork>(
42774281
Object.values(Networks).flatMap((networkType) =>
42784282
Object.values(networkType).map((network) => [network.name, network])
42794283
)

modules/statics/src/coins/erc20Coins.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,11 +1300,13 @@ export const erc20Coins = [
13001300
UnderlyingAsset.CEL,
13011301
ETH_FEATURES_WITH_FRANKFURT.filter(
13021302
(feature) =>
1303-
![
1304-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
1305-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
1306-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
1307-
].includes(feature)
1303+
!(
1304+
[
1305+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
1306+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
1307+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
1308+
] as CoinFeature[]
1309+
).includes(feature)
13081310
)
13091311
),
13101312
erc20(
@@ -2557,11 +2559,13 @@ export const erc20Coins = [
25572559
UnderlyingAsset.FTT,
25582560
ETH_FEATURES_WITH_FRANKFURT.filter(
25592561
(feature) =>
2560-
![
2561-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
2562-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
2563-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
2564-
].includes(feature)
2562+
!(
2563+
[
2564+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
2565+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
2566+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
2567+
] as CoinFeature[]
2568+
).includes(feature)
25652569
)
25662570
),
25672571
erc20(

modules/statics/src/coins/polygonTokens.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ export const polygonTokens = [
133133
UnderlyingAsset['polygon:cel'],
134134
POLYGON_TOKEN_FEATURES.filter(
135135
(feature) =>
136-
![
137-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
138-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
139-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
140-
].includes(feature)
136+
!(
137+
[
138+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
139+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
140+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
141+
] as CoinFeature[]
142+
).includes(feature)
141143
)
142144
),
143145
polygonErc20(
@@ -887,11 +889,13 @@ export const polygonTokens = [
887889
UnderlyingAsset['polygon:wrx'],
888890
POLYGON_TOKEN_FEATURES.filter(
889891
(feature) =>
890-
![
891-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
892-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
893-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
894-
].includes(feature)
892+
!(
893+
[
894+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
895+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
896+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
897+
] as CoinFeature[]
898+
).includes(feature)
895899
)
896900
),
897901
polygonErc20(

modules/statics/src/coins/solTokens.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,13 @@ export const solTokens = [
341341
UnderlyingAsset.FTT,
342342
SOL_TOKEN_FEATURES.filter(
343343
(feature) =>
344-
![
345-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
346-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
347-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
348-
].includes(feature)
344+
!(
345+
[
346+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
347+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
348+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
349+
] as CoinFeature[]
350+
).includes(feature)
349351
)
350352
),
351353
solToken(
@@ -798,11 +800,13 @@ export const solTokens = [
798800
UnderlyingAsset.CEL,
799801
SOL_TOKEN_FEATURES.filter(
800802
(feature) =>
801-
![
802-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
803-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
804-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
805-
].includes(feature)
803+
!(
804+
[
805+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
806+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
807+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
808+
] as CoinFeature[]
809+
).includes(feature)
806810
)
807811
),
808812
solToken(
@@ -1505,11 +1509,13 @@ export const solTokens = [
15051509
UnderlyingAsset.FTT,
15061510
SOL_TOKEN_FEATURES.filter(
15071511
(feature) =>
1508-
![
1509-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
1510-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
1511-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
1512-
].includes(feature)
1512+
!(
1513+
[
1514+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
1515+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
1516+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
1517+
] as CoinFeature[]
1518+
).includes(feature)
15131519
)
15141520
),
15151521
solToken(
@@ -1572,11 +1578,13 @@ export const solTokens = [
15721578
UnderlyingAsset.WFFT,
15731579
SOL_TOKEN_FEATURES.filter(
15741580
(feature) =>
1575-
![
1576-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
1577-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
1578-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
1579-
].includes(feature)
1581+
!(
1582+
[
1583+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
1584+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
1585+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
1586+
] as CoinFeature[]
1587+
).includes(feature)
15801588
)
15811589
),
15821590
solToken(
@@ -2712,7 +2720,7 @@ export const solTokens = [
27122720
'he1iusmfkpAdwvxLNGV8Y1iSbj4rUy6yMhEA3fotn9A',
27132721
'he1iusmfkpAdwvxLNGV8Y1iSbj4rUy6yMhEA3fotn9A',
27142722
UnderlyingAsset['sol:hsol'],
2715-
SOL_TOKEN_FEATURES.filter((feature) => ![CoinFeature.CUSTODY_BITGO_SINGAPORE].includes(feature))
2723+
SOL_TOKEN_FEATURES.filter((feature) => !([CoinFeature.CUSTODY_BITGO_SINGAPORE] as CoinFeature[]).includes(feature))
27162724
),
27172725
solToken(
27182726
'247b9f70-2e4c-4f31-a944-bb5b59f1529a',

modules/statics/src/utxo.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,13 @@ export const utxoCoins: Readonly<BaseCoin>[] = [
285285
BaseUnit.DASH,
286286
DASH_FEATURES.filter(
287287
(feature) =>
288-
![
289-
CoinFeature.CUSTODY_BITGO_SINGAPORE,
290-
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
291-
CoinFeature.CUSTODY_BITGO_MENA_FZE,
292-
].includes(feature)
288+
!(
289+
[
290+
CoinFeature.CUSTODY_BITGO_SINGAPORE,
291+
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
292+
CoinFeature.CUSTODY_BITGO_MENA_FZE,
293+
] as CoinFeature[]
294+
).includes(feature)
293295
)
294296
),
295297
utxo(

modules/statics/test/unit/base.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const should = require('should');
2-
const { UnderlyingAsset } = require('../../src/base');
1+
import should from 'should';
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
}

modules/statics/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"compilerOptions": {
44
"outDir": "./dist",
55
"rootDir": ".",
6+
"esModuleInterop": true,
67
"strict": true,
78
"typeRoots": ["../../types", "./node_modules/@types", "../../node_modules/@types"]
89
},

0 commit comments

Comments
 (0)