@ledgerhq/cryptoassets 6.31.0 → 6.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -1,119 +1,5 @@
1
- export type { CryptoCurrencyIds } from "./currencies";
1
+ import { cryptocurrenciesById } from "./currencies";
2
2
 
3
- /**
4
- *
5
- */
6
- export type Unit = {
7
- // display name of a given unit (example: satoshi)
8
- name: string;
9
- // string to use when formatting the unit. like 'BTC' or 'USD'
10
- code: string;
11
- // number of digits after the '.'
12
- magnitude: number;
13
- // should it always print all digits even if they are 0 (usually: true for fiats, false for cryptos)
14
- showAllDigits?: boolean;
15
- // true if the code should prefix amount when formatting
16
- prefixCode?: boolean;
17
- };
18
-
19
- /**
20
- *
21
- */
22
- type CurrencyCommon = {
23
- // display name of a currency
24
- name: string;
25
- // the ticker name in exchanges / countervalue apis (e.g. BTC).
26
- ticker: string;
27
- // all units of a currency (e.g. Bitcoin have bitcoin, mBTC, bit, satoshi)
28
- // by convention, [0] is the default and have "highest" magnitude
29
- units: Unit[];
30
- // a shorter version of code using the symbol of the currency. like Ƀ . not all cryptocurrencies have a symbol
31
- symbol?: string;
32
- // tells if countervalue need to be disabled (typically because colliding with other coins)
33
- disableCountervalue?: boolean;
34
- delisted?: boolean;
35
- // some countervalue will have a ticker alias
36
- countervalueTicker?: string;
37
- };
38
-
39
- /**
40
- *
41
- */
42
- export type TokenCurrency = CurrencyCommon & {
43
- type: "TokenCurrency";
44
- id: string;
45
- ledgerSignature?: string;
46
- contractAddress: string;
47
- // the currency it belongs to. e.g. 'ethereum'
48
- parentCurrency: CryptoCurrency;
49
- // the type of token in the blockchain it belongs. e.g. 'erc20'
50
- tokenType: string;
51
- // indicates this is a compound token and it's "parent" erc20 have this id
52
- compoundFor?: string;
53
- };
54
-
55
- /**
56
- *
57
- */
58
- export type FiatCurrency = CurrencyCommon & {
59
- type: "FiatCurrency";
60
- };
61
-
62
- /**
63
- *
64
- */
65
- export type ExplorerView = {
66
- tx?: string;
67
- address?: string;
68
- token?: string;
69
- };
70
-
71
- /**
72
- *
73
- */
74
- export type CryptoCurrency = CurrencyCommon & {
75
- type: "CryptoCurrency";
76
- // unique internal id of a crypto currency
77
- id: string;
78
- // define if a crypto is a fork from another coin. helps dealing with split/unsplit
79
- forkedFrom?: string;
80
- // name of the app as shown in the Manager
81
- managerAppName: string;
82
- // coin type according to slip44. THIS IS NOT GUARANTEED UNIQUE across currencies (e.g testnets,..)
83
- coinType: number;
84
- // the scheme name to use when formatting an URI (without the ':')
85
- scheme: string;
86
- // used for UI
87
- color: string;
88
- family: string;
89
- blockAvgTime?: number;
90
- // in seconds
91
- supportsSegwit?: boolean;
92
- supportsNativeSegwit?: boolean;
93
- // if defined this coin is a testnet for another crypto (id)};
94
- isTestnetFor?: string;
95
- // TODO later we could express union of types with mandatory bitcoinLikeInfo for "bitcoin" family...
96
- bitcoinLikeInfo?: {
97
- P2PKH: number;
98
- P2SH: number;
99
- XPUBVersion?: number;
100
- // FIXME optional as we miss some data to fill
101
- hasTimestamp?: boolean;
102
- };
103
- ethereumLikeInfo?: {
104
- chainId: number;
105
- networkId?: number;
106
- baseChain?: string;
107
- hardfork?: string;
108
- };
109
- explorerViews: ExplorerView[];
110
- terminated?: {
111
- link: string;
112
- };
113
- deviceTicker?: string;
114
- };
115
-
116
- /**
117
- *
118
- */
119
- export type Currency = FiatCurrency | CryptoCurrency | TokenCurrency;
3
+ // FIXME This should be the other way around, CryptoCurrencyIds should be defined on its own and cryptocurrenciesById should be derived from it.
4
+ // That way CryptoCurrencyIds could be moved to the types-cryptoassets lib where it belongs.
5
+ export type CryptoCurrencyIds = keyof typeof cryptocurrenciesById;