Skip to content

Commit 9ce4ef2

Browse files
authored
chore(sdk): Add coin deprecation notices (#2557)
Add deprecation notices for values referenced on the legacy Coin model which need to be moved to the SDK.
1 parent b5f2e5c commit 9ce4ef2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/model/coin.dart

+21-1
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,20 @@ class Coin {
6262
CexPrice? usdPrice;
6363
final bool isTestCoin;
6464
bool isCustomCoin;
65+
66+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset multi-address support instead. The wallet now works with multiple addresses per account.')
6567
String? address;
68+
69+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset account management instead.')
6670
List<HdAccount>? accounts;
71+
6772
final double _balance;
6873
final String? _swapContractAddress;
6974
String? fallbackSwapContract;
75+
76+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s WalletManager to determine wallet type.')
7077
WalletType? enabledType;
78+
7179
final bool _walletOnly;
7280
final int priority;
7381
Coin? parentCoin;
@@ -83,9 +91,10 @@ class Coin {
8391
bool get isActivating => state == CoinState.activating;
8492
bool get isInactive => state == CoinState.inactive;
8593

94+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset.sendableBalance instead. This value is not updated after initial load and may be inaccurate.')
8695
double sendableBalance = 0;
8796

88-
@Deprecated('Use the balance manager from the SDK')
97+
@Deprecated('$_urgentDeprecationNotice Use the balance manager from the SDK. This balance value is not updated after initial load and may be inaccurate.')
8998
double get balance {
9099
switch (enabledType) {
91100
case WalletType.trezor:
@@ -95,6 +104,7 @@ class Coin {
95104
}
96105
}
97106

107+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset balance tracking instead. This balance value is not updated after initial load and may be inaccurate.')
98108
double? get _totalHdBalance {
99109
if (accounts == null) return null;
100110

@@ -115,6 +125,7 @@ class Coin {
115125
return amount * usdPrice!.price;
116126
}
117127

128+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset price and balance methods instead. This value uses potentially outdated balance and price information.')
118129
double? get usdBalance {
119130
if (usdPrice == null) return null;
120131
if (balance == 0) return 0;
@@ -127,6 +138,7 @@ class Coin {
127138
return '\$${formatAmt(calculateUsdAmount(amount))}';
128139
}
129140

141+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset balance methods. This getter uses outdated balance information.')
130142
String get getFormattedUsdBalance => amountToFormattedUsd(balance);
131143

132144
String get typeName => getCoinTypeName(type);
@@ -141,6 +153,7 @@ class Coin {
141153
bool get isTxMemoSupported =>
142154
type == CoinType.iris || type == CoinType.cosmos;
143155

156+
@Deprecated('TODO: Adapt SDK to cater for this use case and remove this method.')
144157
String? get defaultAddress {
145158
switch (enabledType) {
146159
case WalletType.trezor:
@@ -165,6 +178,7 @@ class Coin {
165178
return false;
166179
}
167180

181+
@Deprecated('TODO: Adapt SDK to cater for this use case and remove this method.')
168182
String? get _defaultTrezorAddress {
169183
if (enabledType != WalletType.trezor) return null;
170184
if (accounts == null) return null;
@@ -174,6 +188,7 @@ class Coin {
174188
return accounts!.first.addresses.first.address;
175189
}
176190

191+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset address management instead. This value is not updated after initial load and may be inaccurate.')
177192
List<HdAddress> nonEmptyHdAddresses() {
178193
final List<HdAddress>? allAddresses = accounts?.first.addresses;
179194
if (allAddresses == null) return [];
@@ -183,11 +198,13 @@ class Coin {
183198
return nonEmpty;
184199
}
185200

201+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset derivation methods instead. This method does not work for multiple addresses per coin.')
186202
String? getDerivationPath(String address) {
187203
final HdAddress? hdAddress = getHdAddress(address);
188204
return hdAddress?.derivationPath;
189205
}
190206

207+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset address management instead. This method does not work for multiple addresses per coin.')
191208
HdAddress? getHdAddress(String? address) {
192209
if (address == null) return null;
193210
if (enabledType == WalletType.iguana) return null;
@@ -209,6 +226,7 @@ class Coin {
209226
return 'Coin($abbr);';
210227
}
211228

229+
@Deprecated('$_urgentDeprecationNotice Use the SDK\'s Asset state management instead.')
212230
void reset() {
213231
enabledType = null;
214232
accounts = null;
@@ -382,3 +400,5 @@ extension CoinListExtension on List<Coin> {
382400
return Map.fromEntries(map((coin) => MapEntry(coin.abbr, coin)));
383401
}
384402
}
403+
404+
const String _urgentDeprecationNotice ='(URGENT) This must be fixed before the next release.';

0 commit comments

Comments
 (0)