Skip to content
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

feat: add cold wallet feature flags #3685

Merged
merged 1 commit into from
Jun 23, 2023
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
1 change: 1 addition & 0 deletions modules/statics/src/ada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Ada extends BaseCoin {
public static readonly DEFAULT_FEATURES = [
CoinFeature.UNSPENT_MODEL,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.CUSTODY,
CoinFeature.TRANSACTION_DATA,
CoinFeature.REQUIRES_BIG_NUMBER,
Expand Down
1 change: 1 addition & 0 deletions modules/statics/src/avaxp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class AVAXPCoin extends BaseCoin {
CoinFeature.CUSTODY_BITGO_TRUST,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];

/**
Expand Down
8 changes: 8 additions & 0 deletions modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ export enum CoinFeature {
* This coin has transactions that expire after a certain amount of time.
*/
EXPIRING_TRANSACTIONS = 'expiring-transactions',
/**
* This coin supports cold wallets that use a multisig signing protocol
*/
MULTISIG_COLD = 'multisig-cold',
/**
* This coin supports cold wallets that use a TSS signing protocol
*/
TSS_COLD = 'tss-cold',
}

/**
Expand Down
77 changes: 57 additions & 20 deletions modules/statics/src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,56 +77,76 @@ const ETC_FEATURES = [
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.CUSTODY_BITGO_NEW_YORK,
CoinFeature.MULTISIG_COLD,
];

const AVAXC_FEATURES = [
...ETH_FEATURES_WITH_MMI,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const CELO_FEATURES = [
...ETH_FEATURES,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const CELO_FEATURES = [...ETH_FEATURES, CoinFeature.CUSTODY_BITGO_GERMANY, CoinFeature.CUSTODY_BITGO_FRANKFURT];
const ETH2_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.SUPPORTS_TOKENS];
const LTC_FEATURES = [
...UtxoCoin.DEFAULT_FEATURES,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_NEW_YORK,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
];
const RBTC_FEATURES = [...ETH_FEATURES, CoinFeature.CUSTODY_BITGO_GERMANY, CoinFeature.CUSTODY_BITGO_FRANKFURT];
const RBTC_FEATURES = [
...ETH_FEATURES,
CoinFeature.MULTISIG_COLD,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
];
const XLM_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_NEW_YORK,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const XTZ_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.ENTERPRISE_PAYS_FEES].filter(
(feature) => feature !== CoinFeature.CUSTODY && feature !== CoinFeature.CUSTODY_BITGO_TRUST
);
const XTZ_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.MULTISIG_COLD,
CoinFeature.ENTERPRISE_PAYS_FEES,
].filter((feature) => feature !== CoinFeature.CUSTODY && feature !== CoinFeature.CUSTODY_BITGO_TRUST);

const XRP_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_NEW_YORK,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const CSPR_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.REQUIRES_RESERVE,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_SWITZERLAND,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const ALGO_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.CUSTODY_BITGO_SWITZERLAND,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const DOT_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.STAKING,
CoinFeature.EXPIRING_TRANSACTIONS,
];
Expand All @@ -140,16 +160,20 @@ const EOS_FEATURES = [
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const HBAR_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const POLYGON_FEATURES = [
...ETH_FEATURES_WITH_STAKING_AND_MMI,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.MULTISIG_COLD,
CoinFeature.EVM_WALLET,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_SWITZERLAND,
Expand All @@ -158,6 +182,7 @@ const POLYGON_FEATURES = [
const SOL_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.REQUIRES_RESERVE,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.STAKING,
Expand All @@ -168,28 +193,36 @@ const STX_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const NEAR_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const NEAR_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const MATIC_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.STAKING,
CoinFeature.MULTISIG_COLD,
CoinFeature.METAMASK_INSTITUTIONAL,
CoinFeature.CUSTODY_BITGO_SWITZERLAND,
];
const SUI_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const SUI_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const TRX_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.SUPPORTS_TOKENS,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_FRANKFURT,
CoinFeature.MULTISIG_COLD,
];
const ATOM_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const OSMO_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const TIA_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const HASH_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const BLD_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const SEI_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.STAKING];
const INJECTIVE_FEATURES = [
...AccountCoin.DEFAULT_FEATURES,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.STAKING,
];
const ATOM_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const OSMO_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const TIA_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const HASH_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const BLD_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const SEI_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];
const INJECTIVE_FEATURES = [...AccountCoin.DEFAULT_FEATURES, CoinFeature.TSS, CoinFeature.STAKING];

const GENERIC_TOKEN_FEATURES = [
CoinFeature.ACCOUNT_MODEL,
Expand Down Expand Up @@ -286,7 +319,7 @@ export const coins = CoinMap.fromCoins([
Networks.test.bitcoinGold,
UnderlyingAsset.BTG,
BaseUnit.BTC,
BTG_FEATURES
BTG_FEATURES.filter((f) => f !== CoinFeature.MULTISIG_COLD)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we shouldn't even have this as an option in statics, since there is no such coin implementation for tbtg, only the mainnet one but I'd rather not open this change up to also include breaking changes if not necessary.

),
utxo(
'9c8097f1-5d2c-4a62-a94c-96c271c0e5e0',
Expand Down Expand Up @@ -453,6 +486,8 @@ export const coins = CoinMap.fromCoins([
[
...ETH_FEATURES_WITH_STAKING_AND_MMI,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.MULTISIG_COLD,
CoinFeature.EVM_WALLET,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_NEW_YORK,
Expand Down Expand Up @@ -481,6 +516,8 @@ export const coins = CoinMap.fromCoins([
[
...ETH_FEATURES_WITH_STAKING_AND_MMI,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.MULTISIG_COLD,
CoinFeature.EVM_WALLET,
CoinFeature.CUSTODY_BITGO_GERMANY,
CoinFeature.CUSTODY_BITGO_NEW_YORK,
Expand All @@ -496,7 +533,7 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset.ETH2,
BaseUnit.ETH,
[...ETH2_FEATURES, CoinFeature.TSS],
[...ETH2_FEATURES, CoinFeature.TSS, CoinFeature.MULTISIG_COLD, CoinFeature.TSS_COLD],
KeyCurve.BLS
),
account(
Expand All @@ -507,7 +544,7 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset.ETHW,
BaseUnit.ETH,
AccountCoin.DEFAULT_FEATURES
[...AccountCoin.DEFAULT_FEATURES]
),
account(
'37ee6253-04fb-4eec-bd88-310a480b1e43',
Expand All @@ -517,7 +554,7 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset.ETH2,
BaseUnit.ETH,
ETH2_FEATURES,
[...ETH2_FEATURES, CoinFeature.TSS, CoinFeature.MULTISIG_COLD, CoinFeature.TSS_COLD],
KeyCurve.BLS
),
account(
Expand Down Expand Up @@ -914,7 +951,7 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset.BSC,
BaseUnit.BSC,
[...ETH_FEATURES_WITH_MMI, CoinFeature.TSS, CoinFeature.EVM_WALLET]
[...ETH_FEATURES_WITH_MMI, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.EVM_WALLET]
),
account(
'0a205427-f7c9-48a4-a238-c4b33ba6384d',
Expand All @@ -924,7 +961,7 @@ export const coins = CoinMap.fromCoins([
18,
UnderlyingAsset.BSC,
BaseUnit.BSC,
[...ETH_FEATURES_WITH_MMI, CoinFeature.TSS, CoinFeature.EVM_WALLET]
[...ETH_FEATURES_WITH_MMI, CoinFeature.TSS, CoinFeature.TSS_COLD, CoinFeature.EVM_WALLET]
),
account(
'f0e226b6-6cd8-4384-b0a5-ba8e4148a049',
Expand Down
1 change: 1 addition & 0 deletions modules/statics/src/utxo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class UtxoCoin extends BaseCoin {
CoinFeature.CHILD_PAYS_FOR_PARENT,
CoinFeature.CUSTODY,
CoinFeature.CUSTODY_BITGO_TRUST,
CoinFeature.MULTISIG_COLD,
];

/**
Expand Down
52 changes: 52 additions & 0 deletions modules/statics/test/unit/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
UtxoCoin,
} from '../../src';
import { utxo } from '../../src/utxo';
import { expectedColdFeatures } from './fixtures/expectedColdFeatures';

interface DuplicateCoinObject {
name: string;
Expand Down Expand Up @@ -329,3 +330,54 @@ describe('ERC20 Coins', () => {
}, {});
});
});

describe('Cold Wallet Features', () => {
it('Coins that support both multisig & tss cold should have expected flags', () => {
const both = coins
.filter(
(coin) =>
!coin.isToken &&
coin.features.includes(CoinFeature.MULTISIG_COLD) &&
coin.features.includes(CoinFeature.TSS_COLD)
)
.map((coin) => coin.name)
.sort();
both.should.deepEqual(expectedColdFeatures.both.sort());
});
it('Coins that support just multisig cold should have expected flags', () => {
const justMultiSig = coins
.filter(
(coin) =>
!coin.isToken &&
coin.features.includes(CoinFeature.MULTISIG_COLD) &&
!coin.features.includes(CoinFeature.TSS_COLD)
)
.map((coin) => coin.name)
.sort();
justMultiSig.should.deepEqual(expectedColdFeatures.justMultiSig.sort());
});
it('Coins that support just tss cold should have expected flags', () => {
const justTSS = coins
.filter(
(coin) =>
!coin.isToken &&
!coin.features.includes(CoinFeature.MULTISIG_COLD) &&
coin.features.includes(CoinFeature.TSS_COLD)
)
.map((coin) => coin.name)
.sort();
justTSS.should.deepEqual(expectedColdFeatures.justTSS.sort());
});
it('Coins that dont support cold wallets at all should not have either flag', () => {
const neither = coins
.filter(
(coin) =>
!coin.isToken &&
!coin.features.includes(CoinFeature.MULTISIG_COLD) &&
!coin.features.includes(CoinFeature.TSS_COLD)
)
.map((coin) => coin.name)
.sort();
neither.should.deepEqual(expectedColdFeatures.neither.sort());
});
});
Loading