@@ -135,9 +135,9 @@ export class DataUnion {
135135 async isMember ( memberAddress : EthereumAddress ) : Promise < boolean > {
136136 const address = getAddress ( memberAddress )
137137 const duSidechain = await this . getContracts ( ) . getSidechainContractReadOnly ( this . contractAddress )
138- const ACTIVE = 1 // memberData[0] is enum ActiveStatus {None, Active, Inactive}
139138 const memberData = await duSidechain . memberData ( address )
140139 const state = memberData [ 0 ]
140+ const ACTIVE = 1 // memberData[0] is enum ActiveStatus {None, Active, Inactive}
141141 return ( state === ACTIVE )
142142 }
143143
@@ -298,14 +298,16 @@ export class DataUnion {
298298 // TODO: use duSidechain.getMemberStats(address) once it's implemented, to ensure atomic read
299299 // (so that memberData is from same block as getEarnings, otherwise withdrawable will be foobar)
300300 const duSidechain = await this . getContracts ( ) . getSidechainContractReadOnly ( this . contractAddress )
301- const mdata = await duSidechain . memberData ( address )
302- const total = await duSidechain . getEarnings ( address ) . catch ( ( ) => BigNumber . from ( 0 ) )
303- const withdrawnEarnings = mdata [ 3 ]
301+ const [ memberData , total ] = await Promise . all ( [
302+ duSidechain . memberData ( address ) ,
303+ duSidechain . getEarnings ( address ) . catch ( ( ) => BigNumber . from ( 0 ) ) ,
304+ ] )
305+ const withdrawnEarnings = memberData [ 3 ]
304306 const withdrawable = total ? total . sub ( withdrawnEarnings ) : BigNumber . from ( 0 )
305307 const STATUSES = [ MemberStatus . NONE , MemberStatus . ACTIVE , MemberStatus . INACTIVE ]
306308 return {
307- status : STATUSES [ mdata [ 0 ] ] ,
308- earningsBeforeLastJoin : mdata [ 1 ] ,
309+ status : STATUSES [ memberData [ 0 ] ] ,
310+ earningsBeforeLastJoin : memberData [ 1 ] ,
309311 totalEarnings : total ,
310312 withdrawableEarnings : withdrawable ,
311313 }
@@ -669,8 +671,10 @@ export class DataUnion {
669671 */
670672 async transportMessage ( messageHash : AmbMessageHash , pollingIntervalMs : number = 1000 , retryTimeoutMs : number = 300000 ) {
671673 const helper = this . getContracts ( )
672- const sidechainAmb = await helper . getSidechainAmb ( )
673- const mainnetAmb = await helper . getMainnetAmb ( )
674+ const [ sidechainAmb , mainnetAmb ] = await Promise . all ( [
675+ helper . getSidechainAmb ( ) ,
676+ helper . getMainnetAmb ( ) ,
677+ ] )
674678
675679 log ( `Waiting until sidechain AMB has collected required signatures for hash=${ messageHash } ...` )
676680 await until ( async ( ) => helper . requiredSignaturesHaveBeenCollected ( messageHash ) , pollingIntervalMs , retryTimeoutMs )
@@ -682,8 +686,10 @@ export class DataUnion {
682686 const messageId = '0x' + message . substr ( 2 , 64 )
683687
684688 log ( `Checking mainnet AMB hasn't already processed messageId=${ messageId } ` )
685- const alreadySent = await mainnetAmb . messageCallStatus ( messageId )
686- const failAddress = await mainnetAmb . failedMessageSender ( messageId )
689+ const [ alreadySent , failAddress ] = await Promise . all ( [
690+ mainnetAmb . messageCallStatus ( messageId ) ,
691+ mainnetAmb . failedMessageSender ( messageId ) ,
692+ ] )
687693
688694 // zero address means no failed messages
689695 if ( alreadySent || failAddress !== '0x0000000000000000000000000000000000000000' ) {
0 commit comments