Skip to content

Commit

Permalink
bugfix: address lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed May 8, 2024
1 parent 3e69626 commit b522158
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 18 deletions.
32 changes: 16 additions & 16 deletions apollo/src/lnv3/lnv3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Lnv3Service implements OnModuleInit {

protected fetchSendDataInterval = 5000;

private readonly takeEachTime = 10;
private readonly takeEachTime = 6;
private skip = new Array(this.transferService.transfers.length).fill(0);

constructor(
Expand Down Expand Up @@ -93,7 +93,7 @@ export class Lnv3Service implements OnModuleInit {
}).then((res) => res.data?.data?.lnv3TransferRecords.items);
} else {
const url = transfer.url;
const query = `query { lnv3TransferRecords(first: 20, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}) { id, nonce, messageNonce, remoteChainId, provider, sourceToken, targetToken, sourceAmount, targetAmount, sender, receiver, timestamp, transactionHash, fee, transferId, hasWithdrawn } }`;
const query = `query { lnv3TransferRecords(first: 10, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}) { id, nonce, messageNonce, remoteChainId, provider, sourceToken, targetToken, sourceAmount, targetAmount, sender, receiver, timestamp, transactionHash, fee, transferId, hasWithdrawn } }`;
return await axios
.post(url, {
query: query,
Expand All @@ -112,7 +112,7 @@ export class Lnv3Service implements OnModuleInit {
variables: null,
}).then((res) => res.data?.data?.lnv3RelayUpdateRecords.items);
} else {
const query = `query { lnv3RelayUpdateRecords(first: 20, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}) { id, updateType, remoteChainId, provider, transactionHash, timestamp, sourceToken, targetToken, penalty, baseFee, liquidityFeeRate, transferLimit, paused } }`;
const query = `query { lnv3RelayUpdateRecords(first: 10, orderBy: nonce, orderDirection: asc, skip: ${latestNonce}) { id, updateType, remoteChainId, provider, transactionHash, timestamp, sourceToken, targetToken, penalty, baseFee, liquidityFeeRate, transferLimit, paused } }`;
return await axios.post(transfer.url, {
query: query,
variables: null,
Expand Down Expand Up @@ -169,23 +169,23 @@ export class Lnv3Service implements OnModuleInit {
this.fetchCache[index].latestNonce = latestNonce;
continue;
}
const fromToken = this.getTokenInfo(transfer, record.sourceToken);
const toToken = this.getTokenInfo(toChain, record.targetToken);
const fromToken = this.getTokenInfo(transfer, record.sourceToken.toLowerCase());
const toToken = this.getTokenInfo(toChain, record.targetToken.toLowerCase());

const responseHash = '';
const result = RecordStatus.pending;
const endTime = 0;
await this.aggregationService.createHistoryRecord({
id: this.genID(transfer, transfer.chainId.toString(), record.remoteChainId, record.id),
relayer: record.provider,
relayer: record.provider.toLowerCase(),
fromChain: transfer.chain,
toChain: toChain.chain,
bridge: `lnv3`,
messageNonce: record.messageNonce,
nonce: latestNonce + 1,
requestTxHash: record.transactionHash,
sender: record.sender,
recipient: record.receiver,
sender: record.sender.toLowerCase(),
recipient: record.receiver.toLowerCase(),
sendToken: fromToken.symbol,
recvToken: toToken.symbol,
sendAmount: record.sourceAmount,
Expand All @@ -197,8 +197,8 @@ export class Lnv3Service implements OnModuleInit {
feeToken: fromToken.symbol,
responseTxHash: responseHash,
reason: '',
sendTokenAddress: record.sourceToken,
recvTokenAddress: record.targetToken,
sendTokenAddress: record.sourceToken.toLowerCase(),
recvTokenAddress: record.targetToken.toLowerCase(),
endTxHash: '',
confirmedBlocks: '',
needWithdrawLiquidity: !record.hasWithdrawn,
Expand Down Expand Up @@ -281,7 +281,7 @@ export class Lnv3Service implements OnModuleInit {
responseTxHash: relayRecord.transactionHash,
endTxHash: endTxHash,
endTime: Number(relayRecord.timestamp),
relayer: relayRecord.relayer,
relayer: relayRecord.relayer.toLowerCase(),
needWithdrawLiquidity: needWithdrawLiquidity,
lastRequestWithdraw: requestWithdrawTimestamp,
};
Expand Down Expand Up @@ -376,8 +376,8 @@ export class Lnv3Service implements OnModuleInit {
const id = this.genRelayInfoID(
transfer.chainId,
record.remoteChainId,
record.provider,
record.sourceToken
record.provider.toLowerCase(),
record.sourceToken.toLowerCase(),
);
const relayerInfo = await this.aggregationService.queryLnBridgeRelayInfoById({
id: id,
Expand All @@ -391,7 +391,7 @@ export class Lnv3Service implements OnModuleInit {
}
const penalty = record.penalty ?? '0';
if (!relayerInfo) {
const fromToken = this.getTokenInfo(transfer, record.sourceToken);
const fromToken = this.getTokenInfo(transfer, record.sourceToken.toLowerCase());
const channel = this.getMessageChannel(transfer, toChain.chain);
if (fromToken === null || channel === null) {
latestNonce += 1;
Expand All @@ -407,8 +407,8 @@ export class Lnv3Service implements OnModuleInit {
toChain: toChain.chain,
bridge: `lnv3`,
nonce: latestNonce + 1,
relayer: record.provider,
sendToken: record.sourceToken,
relayer: record.provider.toLowerCase(),
sendToken: record.sourceToken.toLowerCase(),
tokenKey: fromToken.key,
transactionHash: record.transactionHash,
timestamp: Number(record.timestamp),
Expand Down
3 changes: 2 additions & 1 deletion ponder/lnv3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"type": "module",
"scripts": {
"dev": "ponder dev",
"test": "cp ponder.config.ts.testnet ponder.config.ts; ponder start",
"start": "ponder start",
"testnet": "cp ponder.config.ts.testnet ponder.config.ts; ponder start",
"mainnet": "cp ponder.config.ts.mainnet ponder.config.ts; ponder start -p 4005",
"codegen": "ponder codegen",
"lint": "eslint .",
"typecheck": "tsc"
Expand Down
100 changes: 100 additions & 0 deletions ponder/lnv3/ponder.config.ts.mainnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { createConfig } from "@ponder/core";
import { http } from "viem";

import { HelixLnBridgeV3Abi } from "./abis/HelixLnBridgeV3Abi";

export default createConfig({
networks: {
"arbitrum": {
chainId: 42161,
transport: http(process.env.PONDER_RPC_URL_42161),
pollingInterval: 1000,
maxRequestsPerSecond: 2,
maxHistoricalTaskConcurrency: 3
},
"optimistic": {
chainId: 10,
transport: http(process.env.PONDER_RPC_URL_10),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
"polygon-pos": {
chainId: 137,
transport: http(process.env.PONDER_RPC_URL_137),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
"astar-zkevm": {
chainId: 3776,
transport: http(process.env.PONDER_RPC_URL_3776),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
"linea": {
chainId: 59144,
transport: http(process.env.PONDER_RPC_URL_59144),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
"blast": {
chainId: 81457,
transport: http(process.env.PONDER_RPC_URL_81457),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
"darwinia": {
chainId: 46,
transport: http(process.env.PONDER_RPC_URL_46),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
"mantle": {
chainId: 5000,
transport: http(process.env.PONDER_RPC_URL_5000),
pollingInterval: 1000,
maxRequestsPerSecond: 1,
maxHistoricalTaskConcurrency: 1
},
},
contracts: {
HelixLnBridgeV3: {
abi: HelixLnBridgeV3Abi,
maxBlockRange: 2000,
address: "0xbA5D580B18b6436411562981e02c8A9aA1776D10",
network: {
"arbitrum": {
startBlock: 175050634,
},
"optimistic": {
startBlock: 115540206,
},
"polygon-pos": {
startBlock: 52848029,
},
"astar-zkevm": {
address: "0xD476650e03a45E70202b0bcAfa04E1513920f83a",
startBlock: 1039985,
},
"linea": {
startBlock: 1938417,
},
"blast": {
address: "0xB180D7DcB5CC161C862aD60442FA37527546cAFC",
startBlock: 459939,
},
"darwinia": {
startBlock: 2013481,
},
"mantle": {
startBlock: 51738488,
}
},
},
},
});
2 changes: 1 addition & 1 deletion ponder/lnv3/src/HelixLnBridgeV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ ponder.on("HelixLnBridgeV3:PenaltyReserveUpdated", async ({ event, context }) =>
const { Lnv3PenaltyReserve } = context.db;
const provider = event.args.provider;
const sourceToken = event.args.sourceToken;
let id = `${context.network.chainId}-${provider}-${sourceToken}`;
let id = `${context.network.chainId}-${provider.toLowerCase()}-${sourceToken.toLowerCase()}`;

await Lnv3PenaltyReserve.upsert({
id: id,
Expand Down

0 comments on commit b522158

Please sign in to comment.