Skip to content

feat(statics): use const instead of enum #6541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5,156 changes: 2,601 additions & 2,555 deletions modules/statics/src/base.ts

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions modules/statics/src/coinFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ export const AVAXC_FEATURES = [
CoinFeature.MULTISIG,
CoinFeature.EIP1559,
];
export const CELO_FEATURES = [
...ETH_FEATURES,
CoinFeature.MULTISIG_COLD,
CoinFeature.MULTISIG,
CoinFeature.EIP1559,
].filter(
export const CELO_FEATURES = (
[...ETH_FEATURES, CoinFeature.MULTISIG_COLD, CoinFeature.MULTISIG, CoinFeature.EIP1559] as CoinFeature[]
).filter(
(feature) =>
feature !== CoinFeature.CUSTODY &&
feature !== CoinFeature.CUSTODY_BITGO_GERMANY &&
Expand Down Expand Up @@ -245,7 +242,7 @@ export const SOL_FEATURES = [
CoinFeature.BULK_TRANSACTION,
];
export const TSOL_FEATURES = [...SOL_FEATURES, CoinFeature.BULK_TRANSACTION, CoinFeature.CUSTODY_BITGO_SINGAPORE];
export const SOL_TOKEN_FEATURES = [
export const SOL_TOKEN_FEATURES: CoinFeature[] = [
...ACCOUNT_COIN_DEFAULT_FEATURES,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
Expand Down
28 changes: 16 additions & 12 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { bscTokens } from './coins/bscTokens';
import { polygonTokens } from './coins/polygonTokens';
import { solTokens } from './coins/solTokens';
import { CoinMap } from './map';
import { Networks } from './networks';
import { BaseNetwork, Networks } from './networks';
import { networkFeatureMapForTokens } from './networkFeatureMapForTokens';
import { utxoCoins } from './utxo';
import { lightningCoins } from './lightning';
Expand Down Expand Up @@ -224,11 +224,13 @@ export const coins = CoinMap.fromCoins([
BaseUnit.CSPR,
CSPR_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
account(
Expand Down Expand Up @@ -826,11 +828,13 @@ export const coins = CoinMap.fromCoins([
BaseUnit.COREUM,
COREUM_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
account(
Expand Down Expand Up @@ -4273,7 +4277,7 @@ export function createTokenMapUsingTrimmedConfigDetails(
reducedTokenConfigMap: Record<string, TrimmedAmsTokenConfig[]>
): CoinMap {
const amsTokenConfigMap: Record<string, AmsTokenConfig[]> = {};
const networkNameMap = new Map(
const networkNameMap = new Map<string, BaseNetwork>(
Object.values(Networks).flatMap((networkType) =>
Object.values(networkType).map((network) => [network.name, network])
)
Expand Down
24 changes: 14 additions & 10 deletions modules/statics/src/coins/erc20Coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,11 +1300,13 @@ export const erc20Coins = [
UnderlyingAsset.CEL,
ETH_FEATURES_WITH_FRANKFURT.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
erc20(
Expand Down Expand Up @@ -2557,11 +2559,13 @@ export const erc20Coins = [
UnderlyingAsset.FTT,
ETH_FEATURES_WITH_FRANKFURT.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
erc20(
Expand Down
24 changes: 14 additions & 10 deletions modules/statics/src/coins/polygonTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ export const polygonTokens = [
UnderlyingAsset['polygon:cel'],
POLYGON_TOKEN_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
polygonErc20(
Expand Down Expand Up @@ -887,11 +889,13 @@ export const polygonTokens = [
UnderlyingAsset['polygon:wrx'],
POLYGON_TOKEN_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
polygonErc20(
Expand Down
50 changes: 29 additions & 21 deletions modules/statics/src/coins/solTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,13 @@ export const solTokens = [
UnderlyingAsset.FTT,
SOL_TOKEN_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
solToken(
Expand Down Expand Up @@ -798,11 +800,13 @@ export const solTokens = [
UnderlyingAsset.CEL,
SOL_TOKEN_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
solToken(
Expand Down Expand Up @@ -1505,11 +1509,13 @@ export const solTokens = [
UnderlyingAsset.FTT,
SOL_TOKEN_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
solToken(
Expand Down Expand Up @@ -1572,11 +1578,13 @@ export const solTokens = [
UnderlyingAsset.WFFT,
SOL_TOKEN_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
solToken(
Expand Down Expand Up @@ -2712,7 +2720,7 @@ export const solTokens = [
'he1iusmfkpAdwvxLNGV8Y1iSbj4rUy6yMhEA3fotn9A',
'he1iusmfkpAdwvxLNGV8Y1iSbj4rUy6yMhEA3fotn9A',
UnderlyingAsset['sol:hsol'],
SOL_TOKEN_FEATURES.filter((feature) => ![CoinFeature.CUSTODY_BITGO_SINGAPORE].includes(feature))
SOL_TOKEN_FEATURES.filter((feature) => !([CoinFeature.CUSTODY_BITGO_SINGAPORE] as CoinFeature[]).includes(feature))
),
solToken(
'247b9f70-2e4c-4f31-a944-bb5b59f1529a',
Expand Down
12 changes: 7 additions & 5 deletions modules/statics/src/utxo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@ export const utxoCoins: Readonly<BaseCoin>[] = [
BaseUnit.DASH,
DASH_FEATURES.filter(
(feature) =>
![
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
].includes(feature)
!(
[
CoinFeature.CUSTODY_BITGO_SINGAPORE,
CoinFeature.CUSTODY_BITGO_CUSTODY_MENA_FZE,
CoinFeature.CUSTODY_BITGO_MENA_FZE,
] as CoinFeature[]
).includes(feature)
)
),
utxo(
Expand Down
10 changes: 5 additions & 5 deletions modules/statics/test/unit/base.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const should = require('should');
const { UnderlyingAsset } = require('../../src/base');
import should from 'should';
import { UnderlyingAsset, UnderlyingAssetValue } from '../../src/base';

describe('UnderlyingAsset', function () {
it('UnderlyingAsset values should be unique', function () {
const underlyingAssetSet = new Set();
const duplicateAssets: (typeof UnderlyingAsset)[] = [];
const duplicateAssets: UnderlyingAssetValue[] = [];

for (const asset in UnderlyingAsset) {
const assetValue = UnderlyingAsset[asset].toUpperCase();
for (const asset of Object.keys(UnderlyingAsset)) {
const assetValue = UnderlyingAsset[asset as keyof typeof UnderlyingAsset].toUpperCase() as UnderlyingAssetValue;
if (underlyingAssetSet.has(assetValue)) {
duplicateAssets.push(assetValue);
}
Expand Down
1 change: 1 addition & 0 deletions modules/statics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"outDir": "./dist",
"rootDir": ".",
"esModuleInterop": true,
"strict": true,
"typeRoots": ["../../types", "./node_modules/@types", "../../node_modules/@types"]
},
Expand Down