diff --git a/apollo/.env.prod b/apollo/.env.prod index ed98f29..a5f6beb 100644 --- a/apollo/.env.prod +++ b/apollo/.env.prod @@ -53,6 +53,8 @@ XTOKEN_DISPATCH_DARWINIA=https://thegraph.darwinia.network/helix/subgraphs/name/ XTOKEN_DISPATCH_CRAB=https://thegraph.darwinia.network/helix/subgraphs/name/xtokendispatch/crab XTOKEN_DISPATCH_ETHEREUM=https://api.studio.thegraph.com/query/59403/xtoken-dispatch-ethereum/v1.0.0 -LNV3_SUPER_ENDPOINT = http://34.142.158.162:8800/graphql +LNV3_SUPER_ENDPOINT = http://34.142.158.162:8202/lnv3/graphql +LNV2_DEFAULT_ENDPOINT = http://34.142.158.162:8202/lnv2default/graphql +LNV2_OPPOSITE_ENDPOINT = http://34.142.158.162:8202/lnv2opposite/graphql CHAIN_TYPE=formal diff --git a/apollo/src/lnv2/lnv2.service.ts b/apollo/src/lnv2/lnv2.service.ts index 69dfdd6..7a11ea3 100644 --- a/apollo/src/lnv2/lnv2.service.ts +++ b/apollo/src/lnv2/lnv2.service.ts @@ -274,7 +274,7 @@ export class Lnv2Service implements OnModuleInit { ); latestNonce = firstRecord ? Number(firstRecord.nonce) : 0; } - const query = `query { lnv2TransferRecords(first: 30, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}) { id, remoteChainId, nonce, provider, sender, receiver, sourceToken, targetToken, amount, transactionHash, timestamp, fee } }`; + const query = `query { lnv2TransferRecords(first: 30, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}, where: {localChainId: ${transfer.chainConfig.id}}) { id, remoteChainId, nonce, provider, sender, receiver, sourceToken, targetToken, amount, transactionHash, timestamp, fee } }`; const records = await axios .post(indexInfo.url, { @@ -364,9 +364,9 @@ export class Lnv2Service implements OnModuleInit { } // batch get status from target chain on sycing historical phase - async queryFillInfos(indexInfo: BridgeIndexInfo, latestTimestamp: number) { + async queryFillInfos(localChainId: number, indexInfo: BridgeIndexInfo, latestTimestamp: number) { const url = indexInfo.url; - const query = `query { lnv2RelayRecords(first: 30, orderBy: timestamp, orderDirection: asc, where: {timestamp_gt: "${latestTimestamp}", slasher: null}) { id, timestamp, transactionHash, fee } }`; + const query = `query { lnv2RelayRecords(first: 30, orderBy: timestamp, orderDirection: asc, where: {localChainId: ${localChainId}, timestamp_gt: ${latestTimestamp}, slasher: null}) { id, timestamp, transactionHash, fee } }`; return await axios .post(url, { query: query, @@ -392,7 +392,7 @@ export class Lnv2Service implements OnModuleInit { ); latestTimestamp = firstRecord ? firstRecord.endTime : -1; } - const relayRecords = await this.queryFillInfos(indexInfo, latestTimestamp); + const relayRecords = await this.queryFillInfos(Number(transfer.chainConfig.id), indexInfo, latestTimestamp); if (relayRecords.length === 0) { this.fetchCache[indexInfo.index].latestFillInfoTimestamp = 0; this.logger.log( @@ -637,7 +637,7 @@ export class Lnv2Service implements OnModuleInit { ); latestNonce = firstRecord ? Number(firstRecord.targetNonce) : 0; } - const query = `query { lnv2RelayUpdateRecords(first: 30, orderBy: nonce, orderDirection: asc, where: {updateType_in: [${RelayUpdateType.SLASH}, ${RelayUpdateType.WITHDRAW}]}, skip: ${latestNonce}) { id, remoteChainId, provider, margin, updateType, withdrawNonce, transactionHash, timestamp, sourceToken, targetToken } }`; + const query = `query { lnv2RelayUpdateRecords(first: 30, orderBy: nonce, orderDirection: asc, where: {localChainId: ${transfer.chainConfig.id}, updateType_in: [${RelayUpdateType.SLASH}, ${RelayUpdateType.WITHDRAW}]}, skip: ${latestNonce}) { id, remoteChainId, provider, margin, updateType, withdrawNonce, transactionHash, timestamp, sourceToken, targetToken } }`; const records = await axios .post(indexInfo.url, { query: query, @@ -761,7 +761,7 @@ export class Lnv2Service implements OnModuleInit { ); latestNonce = firstRecord ? Number(firstRecord.nonce) : 0; } - const query = `query { lnv2RelayUpdateRecords(first: 30, orderBy: nonce, orderDirection: asc, where: {updateType: ${RelayUpdateType.PROVIDER_UPDATE}}, skip: ${latestNonce}) { id, updateType, remoteChainId, provider, transactionHash, timestamp, sourceToken, targetToken, baseFee, liquidityFeeRate } }`; + const query = `query { lnv2RelayUpdateRecords(first: 30, orderBy: nonce, orderDirection: asc, where: {localChainId: ${transfer.chainConfig.id}, updateType: ${RelayUpdateType.PROVIDER_UPDATE}}, skip: ${latestNonce}) { id, updateType, remoteChainId, provider, transactionHash, timestamp, sourceToken, targetToken, baseFee, liquidityFeeRate } }`; const records = await axios .post(indexInfo.url, { @@ -876,7 +876,7 @@ export class Lnv2Service implements OnModuleInit { ); latestNonce = firstRecord ? Number(firstRecord.nonce) : 0; } - const query = `query { lnv2RelayUpdateRecords(first: 30, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}) { id, updateType, remoteChainId, provider, transactionHash, timestamp, sourceToken, targetToken, margin, baseFee, liquidityFeeRate } }`; + const query = `query { lnv2RelayUpdateRecords(first: 30, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}, where: {localChainId: ${transfer.chainConfig.id}}) { id, updateType, remoteChainId, provider, transactionHash, timestamp, sourceToken, targetToken, margin, baseFee, liquidityFeeRate } }`; const records = await axios .post(indexInfo.url, { diff --git a/apollo/src/lnv2/transfer.service.ts b/apollo/src/lnv2/transfer.service.ts index 69354dd..23a0d8e 100644 --- a/apollo/src/lnv2/transfer.service.ts +++ b/apollo/src/lnv2/transfer.service.ts @@ -11,18 +11,6 @@ export class TransferService extends BaseTransferServiceT3 { private readonly lnEthereumOppositeEndpoint = this.configService.get( 'LN_ETHEREUM_OPPOSITE_ENDPOINT' ); - private readonly lnLineaDefaultEndpoint = this.configService.get( - 'LN_LINEA_DEFAULT_ENDPOINT' - ); - private readonly lnLineaOppositeEndpoint = this.configService.get( - 'LN_LINEA_OPPOSITE_ENDPOINT' - ); - private readonly lnMantleDefaultEndpoint = this.configService.get( - 'LN_MANTLE_DEFAULT_ENDPOINT' - ); - private readonly lnMantleOppositeEndpoint = this.configService.get( - 'LN_MANTLE_OPPOSITE_ENDPOINT' - ); private readonly lnArbitrumDefaultEndpoint = this.configService.get( 'LN_ARBITRUM_DEFAULT_ENDPOINT' ); @@ -32,78 +20,31 @@ export class TransferService extends BaseTransferServiceT3 { private readonly lnZkSyncDefaultEndpoint = this.configService.get( 'LN_ZKSYNC_DEFAULT_ENDPOINT' ); - private readonly lnPolygonDefaultEndpoint = this.configService.get( - 'LN_POLYGON_DEFAULT_ENDPOINT' - ); - private readonly lnScrollDefaultEndpoint = this.configService.get( - 'LN_SCROLL_DEFAULT_ENDPOINT' - ); - private readonly lnBaseDefaultEndpoint = this.configService.get( - 'LN_BASE_DEFAULT_ENDPOINT' - ); - private readonly lnDarwiniaDefaultEndpoint = this.configService.get( - 'LN_DARWINIA_DEFAULT_ENDPOINT' - ); - private readonly lnDarwiniaOppositeEndpoint = this.configService.get( - 'LN_DARWINIA_OPPOSITE_ENDPOINT' - ); - private readonly lnCrabDefaultEndpoint = this.configService.get( - 'LN_CRAB_DEFAULT_ENDPOINT' - ); - private readonly lnBscDefaultEndpoint = this.configService.get('LN_BSC_DEFAULT_ENDPOINT'); - private readonly lnOpDefaultEndpoint = this.configService.get('LN_OP_DEFAULT_ENDPOINT'); + + private readonly lnv2DefaultEndpoint = this.configService.get('LNV2_DEFAULT_ENDPOINT'); + private readonly lnv2OppositeEndpoint = this.configService.get('LNV2_OPPOSITE_ENDPOINT'); formalChainTransfers: PartnerT3[] = [ { - defaultEndpoint: this.lnEthereumDefaultEndpoint, - oppositeEndpoint: this.lnEthereumOppositeEndpoint, + defaultEndpoint: this.lnv2DefaultEndpoint, + oppositeEndpoint: this.lnv2OppositeEndpoint, chainConfig: HelixChain.ethereum, }, { - defaultEndpoint: this.lnArbitrumDefaultEndpoint, - oppositeEndpoint: this.lnArbitrumOppositeEndpoint, + defaultEndpoint: this.lnv2DefaultEndpoint, + oppositeEndpoint: this.lnv2OppositeEndpoint, chainConfig: HelixChain.arbitrum, }, { - defaultEndpoint: this.lnPolygonDefaultEndpoint, + defaultEndpoint: this.lnv2DefaultEndpoint, oppositeEndpoint: null, chainConfig: HelixChain.polygon, }, { - defaultEndpoint: this.lnZkSyncDefaultEndpoint, - oppositeEndpoint: null, - chainConfig: HelixChain.zksync, - }, - { - defaultEndpoint: this.lnScrollDefaultEndpoint, - oppositeEndpoint: null, - chainConfig: HelixChain.scroll, - }, - { - defaultEndpoint: this.lnDarwiniaDefaultEndpoint, - oppositeEndpoint: this.lnDarwiniaOppositeEndpoint, + defaultEndpoint: this.lnv2DefaultEndpoint, + oppositeEndpoint: this.lnv2OppositeEndpoint, chainConfig: HelixChain.darwiniaDvm, }, - { - defaultEndpoint: this.lnBscDefaultEndpoint, - oppositeEndpoint: null, - chainConfig: HelixChain.bsc, - }, - { - defaultEndpoint: this.lnBaseDefaultEndpoint, - oppositeEndpoint: null, - chainConfig: HelixChain.base, - }, - { - defaultEndpoint: this.lnOpDefaultEndpoint, - oppositeEndpoint: null, - chainConfig: HelixChain.op, - }, - { - defaultEndpoint: this.lnLineaDefaultEndpoint, - oppositeEndpoint: null, - chainConfig: HelixChain.linea, - }, ]; testChainTransfers: PartnerT3[] = [ diff --git a/apollo/src/lnv3/lnv3.service.ts b/apollo/src/lnv3/lnv3.service.ts index 3acc7b5..b6c9a6b 100644 --- a/apollo/src/lnv3/lnv3.service.ts +++ b/apollo/src/lnv3/lnv3.service.ts @@ -307,7 +307,7 @@ export class Lnv3Service implements OnModuleInit { fromChain: transfer.chainConfig.code, toChain: toChain.chainConfig.code, bridge: `lnv3`, - messageNonce: record.messageNonce, + messageNonce: record.messageNonce.toString(), nonce: 0, requestTxHash: record.transactionHash, sender: record.sender.toLowerCase(),