diff --git a/apollo/src/aggregation/aggregation.history.graphql b/apollo/src/aggregation/aggregation.history.graphql index 38f9868..c67321e 100644 --- a/apollo/src/aggregation/aggregation.history.graphql +++ b/apollo/src/aggregation/aggregation.history.graphql @@ -94,7 +94,7 @@ type HealthInfo { type Query { historyRecordById(id: String): HistoryRecord - historyRecordByNonce(fromChain: String, toChain: String, bridge: String, nonce: Int): HistoryRecord + previousHistoryRecord(fromChain: String, toChain: String, bridge: String, relayer: String, token: String, nonce: Int): HistoryRecord historyRecordByTxHash(txHash: String): HistoryRecord firstHistoryRecord(fromChain: String, toChain: String, bridge: String, results: [Int], relayer: String, token: String, order: String, notsubmited: Boolean): HistoryRecord historyRecords(sender: String, recipient: String, relayer: String, needWithdrawLiquidity: Boolean, fromChains: [String], toChains: [String], bridges: [String], row: Int, page: Int, results: [Int], recvTokenAddress: String, order: String): HistoryRecords diff --git a/apollo/src/aggregation/aggregation.resolver.ts b/apollo/src/aggregation/aggregation.resolver.ts index 0339d8a..79b8a65 100644 --- a/apollo/src/aggregation/aggregation.resolver.ts +++ b/apollo/src/aggregation/aggregation.resolver.ts @@ -68,18 +68,30 @@ export class AggregationResolver { } @Query() - async historyRecordByNonce( + async previousHistoryRecord( @Args('fromChain') fromChain: string, @Args('toChain') toChain: string, @Args('bridge') bridge: string, - @Args('nonce') nonce: number + @Args('relayer') relayer: string, + @Args('token') token: string, + @Args('nonce') nonce: number ) { - return this.aggregationService.queryHistoryRecordFirst({ - fromChain, - toChain, - bridge, - nonce - }); + const orderBy = { nonce: Prisma.SortOrder.desc }; + return this.aggregationService.queryHistoryRecordFirst( + { + AND: { + fromChain: fromChain, + toChain: toChain, + bridge: bridge, + relayer: relayer, + sendTokenAddress: token, + nonce: { + lt: nonce, + }, + }, + }, + orderBy + ); } // query by source tx hash diff --git a/apollo/src/graphql.ts b/apollo/src/graphql.ts index a3e04cc..0b425d0 100644 --- a/apollo/src/graphql.ts +++ b/apollo/src/graphql.ts @@ -1,4 +1,3 @@ - /* * ------------------------------------------------------- * THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) @@ -9,128 +8,226 @@ /* eslint-disable */ export class HistoryRecord { - id: string; - fromChain: string; - toChain: string; - bridge: string; - reason?: Nullable; - nonce: BigInt; - requestTxHash: string; - responseTxHash?: Nullable; - sender: string; - recipient: string; - sendToken: string; - recvToken: string; - sendAmount: string; - recvAmount?: Nullable; - startTime: number; - endTime?: Nullable; - result: number; - fee: string; - feeToken: string; - messageNonce?: Nullable; - sendTokenAddress?: Nullable; - recvTokenAddress?: Nullable; - sendOuterTokenAddress?: Nullable; - recvOuterTokenAddress?: Nullable; - guardSignatures?: Nullable; - relayer?: Nullable; - endTxHash?: Nullable; - confirmedBlocks?: Nullable; - needWithdrawLiquidity?: Nullable; - lastRequestWithdraw?: Nullable; - extData?: Nullable; + id: string; + fromChain: string; + toChain: string; + bridge: string; + reason?: Nullable; + nonce: BigInt; + requestTxHash: string; + responseTxHash?: Nullable; + sender: string; + recipient: string; + sendToken: string; + recvToken: string; + sendAmount: string; + recvAmount?: Nullable; + startTime: number; + endTime?: Nullable; + result: number; + fee: string; + feeToken: string; + messageNonce?: Nullable; + sendTokenAddress?: Nullable; + recvTokenAddress?: Nullable; + sendOuterTokenAddress?: Nullable; + recvOuterTokenAddress?: Nullable; + guardSignatures?: Nullable; + relayer?: Nullable; + endTxHash?: Nullable; + confirmedBlocks?: Nullable; + needWithdrawLiquidity?: Nullable; + lastRequestWithdraw?: Nullable; + extData?: Nullable; } export class HistoryRecords { - total: number; - records?: Nullable[]>; + total: number; + records?: Nullable[]>; } export class LnBridgeRelayInfo { - id: string; - version: string; - nonce: BigInt; - targetNonce?: Nullable; - fromChain: string; - toChain: string; - bridge: string; - relayer: string; - sendToken?: Nullable; - tokenKey?: Nullable; - transactionHash: string; - timestamp: number; - margin?: Nullable; - protocolFee?: Nullable; - baseFee?: Nullable; - liquidityFeeRate?: Nullable; - slashCount?: Nullable; - withdrawNonce?: Nullable; - lastTransferId?: Nullable; - cost?: Nullable; - profit?: Nullable; - heartbeatTimestamp?: Nullable; - messageChannel?: Nullable; - transferLimit?: Nullable; - softTransferLimit?: Nullable; - paused?: Nullable; - dynamicFee?: Nullable; - dynamicFeeExpire?: Nullable; - dynamicFeeSignature?: Nullable; + id: string; + version: string; + nonce: BigInt; + targetNonce?: Nullable; + fromChain: string; + toChain: string; + bridge: string; + relayer: string; + sendToken?: Nullable; + tokenKey?: Nullable; + transactionHash: string; + timestamp: number; + margin?: Nullable; + protocolFee?: Nullable; + baseFee?: Nullable; + liquidityFeeRate?: Nullable; + slashCount?: Nullable; + withdrawNonce?: Nullable; + lastTransferId?: Nullable; + cost?: Nullable; + profit?: Nullable; + heartbeatTimestamp?: Nullable; + messageChannel?: Nullable; + transferLimit?: Nullable; + softTransferLimit?: Nullable; + paused?: Nullable; + dynamicFee?: Nullable; + dynamicFeeExpire?: Nullable; + dynamicFeeSignature?: Nullable; } export class LnBridgeRelayInfos { - total: number; - records?: Nullable[]>; + total: number; + records?: Nullable[]>; } export class SortedLnBridgeRelayInfos { - transferLimit: BigInt; - records?: Nullable[]>; + transferLimit: BigInt; + records?: Nullable[]>; } export class SupportChains { - fromChain: string; - toChains?: Nullable[]>; + fromChain: string; + toChains?: Nullable[]>; } export class HealthInfo { - name?: Nullable; - callTimes?: Nullable; + name?: Nullable; + callTimes?: Nullable; } export abstract class IQuery { - abstract historyRecordById(id?: Nullable): Nullable | Promise>; - - abstract historyRecordByNonce(fromChain?: Nullable, toChain?: Nullable, bridge?: Nullable, nonce?: Nullable): Nullable | Promise>; - - abstract historyRecordByTxHash(txHash?: Nullable): Nullable | Promise>; - - abstract firstHistoryRecord(fromChain?: Nullable, toChain?: Nullable, bridge?: Nullable, results?: Nullable[]>, relayer?: Nullable, token?: Nullable, order?: Nullable, notsubmited?: Nullable): Nullable | Promise>; - - abstract historyRecords(sender?: Nullable, recipient?: Nullable, relayer?: Nullable, needWithdrawLiquidity?: Nullable, fromChains?: Nullable[]>, toChains?: Nullable[]>, bridges?: Nullable[]>, row?: Nullable, page?: Nullable, results?: Nullable[]>, recvTokenAddress?: Nullable, order?: Nullable): Nullable | Promise>; - - abstract checkLnBridgeExist(fromChainId?: Nullable, toChainId?: Nullable, fromToken?: Nullable, toToken?: Nullable, version?: Nullable): Nullable | Promise>; - - abstract tasksHealthCheck(name?: Nullable): Nullable[]> | Promise[]>>; - - abstract queryRelayRecords(fromChain?: Nullable, toChain?: Nullable, bridge?: Nullable, relayer?: Nullable, row?: Nullable): Nullable | Promise>; - - abstract queryLnBridgeRelayInfos(fromChain?: Nullable, toChain?: Nullable, version?: Nullable, bridge?: Nullable, relayer?: Nullable, row?: Nullable, page?: Nullable): Nullable | Promise>; - - abstract sortedLnBridgeRelayInfos(fromChain?: Nullable, toChain?: Nullable, version?: Nullable, bridge?: Nullable, token?: Nullable, row?: Nullable, amount?: Nullable, decimals?: Nullable): Nullable | Promise>; - - abstract queryLnBridgeSupportChains(tokenKey?: Nullable): Nullable[]> | Promise[]>>; - - abstract queryMaxTransfer(fromChain?: Nullable, toChain?: Nullable, bridge?: Nullable, token?: Nullable, balance?: Nullable): Nullable | Promise>; + abstract historyRecordById( + id?: Nullable + ): Nullable | Promise>; + + abstract previousHistoryRecord( + fromChain?: Nullable, + toChain?: Nullable, + bridge?: Nullable, + relayer?: Nullable, + token?: Nullable, + nonce?: Nullable + ): Nullable | Promise>; + + abstract historyRecordByTxHash( + txHash?: Nullable + ): Nullable | Promise>; + + abstract firstHistoryRecord( + fromChain?: Nullable, + toChain?: Nullable, + bridge?: Nullable, + results?: Nullable[]>, + relayer?: Nullable, + token?: Nullable, + order?: Nullable, + notsubmited?: Nullable + ): Nullable | Promise>; + + abstract historyRecords( + sender?: Nullable, + recipient?: Nullable, + relayer?: Nullable, + needWithdrawLiquidity?: Nullable, + fromChains?: Nullable[]>, + toChains?: Nullable[]>, + bridges?: Nullable[]>, + row?: Nullable, + page?: Nullable, + results?: Nullable[]>, + recvTokenAddress?: Nullable, + order?: Nullable + ): Nullable | Promise>; + + abstract checkLnBridgeExist( + fromChainId?: Nullable, + toChainId?: Nullable, + fromToken?: Nullable, + toToken?: Nullable, + version?: Nullable + ): Nullable | Promise>; + + abstract tasksHealthCheck( + name?: Nullable + ): Nullable[]> | Promise[]>>; + + abstract queryRelayRecords( + fromChain?: Nullable, + toChain?: Nullable, + bridge?: Nullable, + relayer?: Nullable, + row?: Nullable + ): Nullable | Promise>; + + abstract queryLnBridgeRelayInfos( + fromChain?: Nullable, + toChain?: Nullable, + version?: Nullable, + bridge?: Nullable, + relayer?: Nullable, + row?: Nullable, + page?: Nullable + ): Nullable | Promise>; + + abstract sortedLnBridgeRelayInfos( + fromChain?: Nullable, + toChain?: Nullable, + version?: Nullable, + bridge?: Nullable, + token?: Nullable, + row?: Nullable, + amount?: Nullable, + decimals?: Nullable + ): Nullable | Promise>; + + abstract queryLnBridgeSupportChains( + tokenKey?: Nullable + ): Nullable[]> | Promise[]>>; + + abstract queryMaxTransfer( + fromChain?: Nullable, + toChain?: Nullable, + bridge?: Nullable, + token?: Nullable, + balance?: Nullable + ): Nullable | Promise>; } export abstract class IMutation { - abstract signConfirmedBlock(id?: Nullable, relayer?: Nullable, block?: Nullable, timestamp?: Nullable, signature?: Nullable): Nullable | Promise>; - - abstract signHeartBeat(fromChainId?: Nullable, toChainId?: Nullable, version?: Nullable, relayer?: Nullable, tokenAddress?: Nullable, softTransferLimit?: Nullable, timestamp?: Nullable, signature?: Nullable): Nullable | Promise>; - - abstract signDynamicFee(fromChainId?: Nullable, toChainId?: Nullable, version?: Nullable, relayer?: Nullable, tokenAddress?: Nullable, dynamicFee?: Nullable, dynamicFeeExpire?: Nullable, dynamicFeeSignature?: Nullable, timestamp?: Nullable, signature?: Nullable): Nullable | Promise>; + abstract signConfirmedBlock( + id?: Nullable, + relayer?: Nullable, + block?: Nullable, + timestamp?: Nullable, + signature?: Nullable + ): Nullable | Promise>; + + abstract signHeartBeat( + fromChainId?: Nullable, + toChainId?: Nullable, + version?: Nullable, + relayer?: Nullable, + tokenAddress?: Nullable, + softTransferLimit?: Nullable, + timestamp?: Nullable, + signature?: Nullable + ): Nullable | Promise>; + + abstract signDynamicFee( + fromChainId?: Nullable, + toChainId?: Nullable, + version?: Nullable, + relayer?: Nullable, + tokenAddress?: Nullable, + dynamicFee?: Nullable, + dynamicFeeExpire?: Nullable, + dynamicFeeSignature?: Nullable, + timestamp?: Nullable, + signature?: Nullable + ): Nullable | Promise>; } export type BigInt = any;