File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
packages/gator-permissions-snap/src/permissions Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 88 type Hex ,
99} from '@metamask/utils' ;
1010
11+ import type { TimePeriod } from '../../core/types' ;
1112import type { TokenMetadataService } from '../../services/tokenMetadataService' ;
12- import { getClosestTimePeriod , TIME_PERIOD_TO_SECONDS } from '../../utils/time' ;
13+ import { TIME_PERIOD_TO_SECONDS } from '../../utils/time' ;
1314import { parseUnits , formatUnitsFromHex } from '../../utils/value' ;
1415import {
1516 validateAndParseAmount ,
@@ -177,8 +178,11 @@ export async function buildContext({
177178 decimals,
178179 } ) ;
179180
180- const periodType = getClosestTimePeriod ( data . periodDuration ) ;
181- const periodDuration = TIME_PERIOD_TO_SECONDS [ periodType ] . toString ( ) ;
181+ const periodType = ( Object . keys ( TIME_PERIOD_TO_SECONDS ) as TimePeriod [ ] ) . find (
182+ ( key : TimePeriod ) =>
183+ Number ( TIME_PERIOD_TO_SECONDS [ key ] ) === data . periodDuration ,
184+ ) ;
185+ const periodDuration = data . periodDuration . toString ( ) ;
182186
183187 const startTime = data . startTime ?? Math . floor ( Date . now ( ) / 1000 ) ;
184188
Original file line number Diff line number Diff line change 88 type Hex ,
99} from '@metamask/utils' ;
1010
11+ import type { TimePeriod } from '../../core/types' ;
1112import type { TokenMetadataService } from '../../services/tokenMetadataService' ;
12- import { getClosestTimePeriod , TIME_PERIOD_TO_SECONDS } from '../../utils/time' ;
13+ import { TIME_PERIOD_TO_SECONDS } from '../../utils/time' ;
1314import { parseUnits , formatUnitsFromHex } from '../../utils/value' ;
1415import {
1516 validateAndParseAmount ,
@@ -177,8 +178,11 @@ export async function buildContext({
177178 decimals,
178179 } ) ;
179180
180- const periodType = getClosestTimePeriod ( data . periodDuration ) ;
181- const periodDuration = TIME_PERIOD_TO_SECONDS [ periodType ] . toString ( ) ;
181+ const periodType = ( Object . keys ( TIME_PERIOD_TO_SECONDS ) as TimePeriod [ ] ) . find (
182+ ( key : TimePeriod ) =>
183+ Number ( TIME_PERIOD_TO_SECONDS [ key ] ) === data . periodDuration ,
184+ ) ;
185+ const periodDuration = data . periodDuration . toString ( ) ;
182186
183187 const startTime = data . startTime ?? Math . floor ( Date . now ( ) / 1000 ) ;
184188
You can’t perform that action at this time.
0 commit comments