@@ -3,7 +3,6 @@ import * as utxolib from '@bitgo/utxo-lib';
33import { IWallet } from '../wallet/iWallet' ;
44import { Environments } from '../environments' ;
55
6- const NUM_MESSAGES_PER_TRANSACTION = 2 ;
76const NUM_MESSAGES_PER_QUERY = 1000 ;
87export const MIDNIGHT_TNC_HASH = '31a6bab50a84b8439adcfb786bb2020f6807e6e8fda629b424110fc7bb1c6b8b' ;
98
@@ -44,17 +43,20 @@ export class MidnightMessageProvider implements IMessageProvider {
4443 protected midnightClaimUrl : string ;
4544 protected prevId : string | undefined ;
4645 protected ranOnce = false ;
46+ private readonly numMessagesPerTransaction : number ;
47+
4748 constructor ( private wallet : IWallet , private destinationAddress : string ) {
4849 this . unprocessedMessagesCache = [ ] ;
4950 this . network = utxolib . networks [ wallet . coin ( ) ] ;
5051 this . midnightClaimUrl = `${
5152 Environments [ wallet . bitgo . env ] . uri
5253 } /api/airdrop-claim/v1/midnight/claims/${ wallet . coin ( ) } /${ wallet . id ( ) } `;
54+ this . numMessagesPerTransaction = wallet . bitgo . env === 'prod' ? 200 : 4 ;
5355 }
5456
5557 async getMessagesAndAddressesToSign ( ) : Promise < MessageInfo [ ] > {
5658 if ( this . unprocessedMessagesCache . length > 0 ) {
57- return this . unprocessedMessagesCache . splice ( 0 , NUM_MESSAGES_PER_TRANSACTION ) ;
59+ return this . unprocessedMessagesCache . splice ( 0 , this . numMessagesPerTransaction ) ;
5860 } else if ( this . unprocessedMessagesCache . length === 0 && this . ranOnce && this . prevId === undefined ) {
5961 return [ ] ;
6062 }
@@ -87,7 +89,7 @@ export class MidnightMessageProvider implements IMessageProvider {
8789 address : claim . originAddress ,
8890 } ;
8991 } ) ;
90- const toReturn = this . unprocessedMessagesCache . splice ( 0 , NUM_MESSAGES_PER_TRANSACTION ) ;
92+ const toReturn = this . unprocessedMessagesCache . splice ( 0 , this . numMessagesPerTransaction ) ;
9193 return toReturn ;
9294 }
9395}
0 commit comments