@@ -64,6 +64,7 @@ import {
6464import { ORDER_MAPPING_CHANNEL } from '~@/constant/channel' ;
6565import { Order } from '~@/shared/types/channel/order' ;
6666import { sleep } from '../shared/helpers/time' ;
67+ import { TRANSACTION_TIME_TO_LIVE } from '~@/config/constant.config' ;
6768
6869@Injectable ( )
6970export class ChannelService {
@@ -82,7 +83,7 @@ export class ChannelService {
8283 channelOpenInitOperator ,
8384 constructedAddress ,
8485 ) ;
85- const validToTime = Date . now ( ) + 3 * 1e5 ;
86+ const validToTime = Date . now ( ) + TRANSACTION_TIME_TO_LIVE ;
8687 const validToSlot = unixTimeToSlot ( this . lucidService . lucid . config ( ) . network , Number ( validToTime ) ) ;
8788 const currentSlot = this . lucidService . lucid . currentSlot ( ) ;
8889 if ( currentSlot > validToSlot ) {
@@ -126,7 +127,8 @@ export class ChannelService {
126127 channelOpenTryOperator ,
127128 constructedAddress ,
128129 ) ;
129- const unsignedChannelOpenTryTxValidTo : TxBuilder = unsignedChannelOpenTryTx . validTo ( Date . now ( ) + 300 * 1e3 ) ;
130+ const validToTime = Date . now ( ) + TRANSACTION_TIME_TO_LIVE ;
131+ const unsignedChannelOpenTryTxValidTo : TxBuilder = unsignedChannelOpenTryTx . validTo ( validToTime ) ;
130132 // TODO: signing should be done by the relayer in the future
131133 const signedChannelOpenTryTxCompleted = await ( await unsignedChannelOpenTryTxValidTo . complete ( ) ) . sign
132134 . withWallet ( )
@@ -159,7 +161,7 @@ export class ChannelService {
159161 channelOpenAckOperator ,
160162 constructedAddress ,
161163 ) ;
162- const validToTime = Date . now ( ) + 3 * 1e5 ;
164+ const validToTime = Date . now ( ) + TRANSACTION_TIME_TO_LIVE ;
163165 const validToSlot = unixTimeToSlot ( this . lucidService . lucid . config ( ) . network , Number ( validToTime ) ) ;
164166 const currentSlot = this . lucidService . lucid . currentSlot ( ) ;
165167 if ( currentSlot > validToSlot ) {
@@ -200,9 +202,8 @@ export class ChannelService {
200202 channelOpenConfirmOperator ,
201203 constructedAddress ,
202204 ) ;
203- const unsignedChannelConfirmInitTxValidTo : TxBuilder = unsignedChannelConfirmInitTx . validTo (
204- Date . now ( ) + 600 * 1e3 ,
205- ) ;
205+ const validToTime = Date . now ( ) + TRANSACTION_TIME_TO_LIVE ;
206+ const unsignedChannelConfirmInitTxValidTo : TxBuilder = unsignedChannelConfirmInitTx . validTo ( validToTime ) ;
206207
207208 // TODO: signing should be done by the relayer in the future
208209 const signedChannelConfirmInitTxCompleted = await ( await unsignedChannelConfirmInitTxValidTo . complete ( ) ) . sign
@@ -243,7 +244,8 @@ export class ChannelService {
243244 channelCloseInitOperator ,
244245 constructedAddress ,
245246 ) ;
246- const unsignedChannelCloseInitTxValidTo : TxBuilder = unsignedChannelCloseInitTx . validTo ( Date . now ( ) + 300 * 1e3 ) ;
247+ const validToTime = Date . now ( ) + TRANSACTION_TIME_TO_LIVE ;
248+ const unsignedChannelCloseInitTxValidTo : TxBuilder = unsignedChannelCloseInitTx . validTo ( validToTime ) ;
247249
248250 // TODO: signing should be done by the relayer in the future
249251 const signedChannelCloseInitTxCompleted = await ( await unsignedChannelCloseInitTxValidTo . complete ( ) ) . sign
0 commit comments