Skip to content

Commit

Permalink
update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Jan 5, 2025
1 parent f58b18d commit ac84898
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 78 deletions.
4 changes: 3 additions & 1 deletion apollo/.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions apollo/src/lnv2/lnv2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down
79 changes: 10 additions & 69 deletions apollo/src/lnv2/transfer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ export class TransferService extends BaseTransferServiceT3 {
private readonly lnEthereumOppositeEndpoint = this.configService.get<string>(
'LN_ETHEREUM_OPPOSITE_ENDPOINT'
);
private readonly lnLineaDefaultEndpoint = this.configService.get<string>(
'LN_LINEA_DEFAULT_ENDPOINT'
);
private readonly lnLineaOppositeEndpoint = this.configService.get<string>(
'LN_LINEA_OPPOSITE_ENDPOINT'
);
private readonly lnMantleDefaultEndpoint = this.configService.get<string>(
'LN_MANTLE_DEFAULT_ENDPOINT'
);
private readonly lnMantleOppositeEndpoint = this.configService.get<string>(
'LN_MANTLE_OPPOSITE_ENDPOINT'
);
private readonly lnArbitrumDefaultEndpoint = this.configService.get<string>(
'LN_ARBITRUM_DEFAULT_ENDPOINT'
);
Expand All @@ -32,78 +20,31 @@ export class TransferService extends BaseTransferServiceT3 {
private readonly lnZkSyncDefaultEndpoint = this.configService.get<string>(
'LN_ZKSYNC_DEFAULT_ENDPOINT'
);
private readonly lnPolygonDefaultEndpoint = this.configService.get<string>(
'LN_POLYGON_DEFAULT_ENDPOINT'
);
private readonly lnScrollDefaultEndpoint = this.configService.get<string>(
'LN_SCROLL_DEFAULT_ENDPOINT'
);
private readonly lnBaseDefaultEndpoint = this.configService.get<string>(
'LN_BASE_DEFAULT_ENDPOINT'
);
private readonly lnDarwiniaDefaultEndpoint = this.configService.get<string>(
'LN_DARWINIA_DEFAULT_ENDPOINT'
);
private readonly lnDarwiniaOppositeEndpoint = this.configService.get<string>(
'LN_DARWINIA_OPPOSITE_ENDPOINT'
);
private readonly lnCrabDefaultEndpoint = this.configService.get<string>(
'LN_CRAB_DEFAULT_ENDPOINT'
);
private readonly lnBscDefaultEndpoint = this.configService.get<string>('LN_BSC_DEFAULT_ENDPOINT');
private readonly lnOpDefaultEndpoint = this.configService.get<string>('LN_OP_DEFAULT_ENDPOINT');

private readonly lnv2DefaultEndpoint = this.configService.get<string>('LNV2_DEFAULT_ENDPOINT');
private readonly lnv2OppositeEndpoint = this.configService.get<string>('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[] = [
Expand Down
2 changes: 1 addition & 1 deletion apollo/src/lnv3/lnv3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit ac84898

Please sign in to comment.