Skip to content

Commit ff19708

Browse files
authored
Fix update conversionDate return (#621)
1 parent 244207b commit ff19708

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/assets/CurrencyRateController.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ describe('CurrencyRateController', () => {
305305
await controller.updateExchangeRate();
306306

307307
expect(controller.state).toStrictEqual({
308-
conversionDate: getStubbedDate() / 1000,
308+
conversionDate: null,
309309
conversionRate: null,
310310
currentCurrency: '',
311311
nativeCurrency: 'BNB',

src/assets/CurrencyRateController.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { RestrictedControllerMessenger } from '../ControllerMessenger';
1818
* @property usdConversionRate - Conversion rate from usd to the current currency
1919
*/
2020
export type CurrencyRateState = {
21-
conversionDate: number;
21+
conversionDate: number | null;
2222
conversionRate: number | null;
2323
currentCurrency: string;
2424
nativeCurrency: string;
@@ -200,7 +200,7 @@ export class CurrencyRateController extends BaseController<
200200
pendingNativeCurrency,
201201
} = this.state;
202202

203-
const conversionDate: number = Date.now() / 1000;
203+
let conversionDate: number | null = null;
204204
let conversionRate: number | null = null;
205205
let usdConversionRate: number | null = null;
206206
const currentCurrency = pendingCurrentCurrency ?? stateCurrentCurrency;
@@ -221,6 +221,7 @@ export class CurrencyRateController extends BaseController<
221221
nativeCurrency,
222222
this.includeUsdRate,
223223
));
224+
conversionDate = Date.now() / 1000;
224225
}
225226
} catch (error) {
226227
if (!error.message.includes('market does not exist for this coin pair')) {

0 commit comments

Comments
 (0)