@@ -2,6 +2,7 @@ import 'dart:async';
2
2
import 'dart:convert' ;
3
3
4
4
import 'package:komodo_defi_types/komodo_defi_types.dart' ;
5
+ import 'package:rational/rational.dart' ;
5
6
import 'package:web_dex/bloc/coins_bloc/coins_repo.dart' ;
6
7
import 'package:web_dex/mm2/mm2.dart' ;
7
8
import 'package:web_dex/mm2/mm2_api/mm2_api_nft.dart' ;
@@ -86,7 +87,7 @@ class Mm2Api {
86
87
Future <String ?> getBalance (String abbr) async {
87
88
dynamic response;
88
89
try {
89
- response = await _call (MyBalanceReq (coin: abbr));
90
+ response = await _mm2. call (MyBalanceReq (coin: abbr));
90
91
} catch (e, s) {
91
92
log (
92
93
'Error getting balance $abbr : ${e .toString ()}' ,
@@ -113,74 +114,6 @@ class Mm2Api {
113
114
return json['balance' ];
114
115
}
115
116
116
- Future <MaxMakerVolResponse ?> getMaxMakerVol (String abbr) async {
117
- dynamic response;
118
- try {
119
- response = await _call (MaxMakerVolRequest (coin: abbr));
120
- } catch (e, s) {
121
- log (
122
- 'Error getting max maker vol $abbr : ${e .toString ()}' ,
123
- path: 'api => getMaxMakerVol => _call' ,
124
- trace: s,
125
- isError: true ,
126
- );
127
- return _fallbackToBalance (abbr);
128
- }
129
-
130
- Map <String , dynamic > json;
131
- try {
132
- json = jsonDecode (response);
133
- } catch (e, s) {
134
- log (
135
- 'Error parsing of max maker vol $abbr response: ${e .toString ()}' ,
136
- path: 'api => getMaxMakerVol => jsonDecode' ,
137
- trace: s,
138
- isError: true ,
139
- );
140
- return _fallbackToBalance (abbr);
141
- }
142
-
143
- final error = json['error' ];
144
- if (error != null ) {
145
- log (
146
- 'Error parsing of max maker vol $abbr response: ${error .toString ()}' ,
147
- path: 'api => getMaxMakerVol => error' ,
148
- isError: true ,
149
- );
150
- return _fallbackToBalance (abbr);
151
- }
152
-
153
- try {
154
- return MaxMakerVolResponse .fromJson (json['result' ]);
155
- } catch (e, s) {
156
- log (
157
- 'Error constructing MaxMakerVolResponse for $abbr : ${e .toString ()}' ,
158
- path: 'api => getMaxMakerVol => fromJson' ,
159
- trace: s,
160
- isError: true ,
161
- );
162
- return _fallbackToBalance (abbr);
163
- }
164
- }
165
-
166
- Future <MaxMakerVolResponse ?> _fallbackToBalance (String abbr) async {
167
- final balance = await getBalance (abbr);
168
- if (balance == null ) {
169
- log (
170
- 'Failed to retrieve balance for fallback construction of MaxMakerVolResponse for $abbr ' ,
171
- path: 'api => _fallbackToBalance' ,
172
- isError: true ,
173
- );
174
- return null ;
175
- }
176
-
177
- final balanceValue = MaxMakerVolResponseValue (decimal: balance);
178
- return MaxMakerVolResponse (
179
- volume: balanceValue,
180
- balance: balanceValue,
181
- );
182
- }
183
-
184
117
Future <MaxTakerVolResponse ?> _fallbackToBalanceTaker (String abbr) async {
185
118
final balance = await getBalance (abbr);
186
119
if (balance == null ) {
0 commit comments