Skip to content

Commit 01d0da4

Browse files
authored
Merge pull request #177 from helix-bridge/xiaoch05-query-by-nonce
previousHistoryRecord interface
2 parents 61a39ae + 410c570 commit 01d0da4

File tree

3 files changed

+224
-97
lines changed

3 files changed

+224
-97
lines changed

apollo/src/aggregation/aggregation.history.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type HealthInfo {
9494

9595
type Query {
9696
historyRecordById(id: String): HistoryRecord
97+
previousHistoryRecord(fromChain: String, toChain: String, bridge: String, relayer: String, token: String, nonce: Int): HistoryRecord
9798
historyRecordByTxHash(txHash: String): HistoryRecord
9899
firstHistoryRecord(fromChain: String, toChain: String, bridge: String, results: [Int], relayer: String, token: String, order: String, notsubmited: Boolean): HistoryRecord
99100
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

apollo/src/aggregation/aggregation.resolver.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,33 @@ export class AggregationResolver {
6767
});
6868
}
6969

70+
@Query()
71+
async previousHistoryRecord(
72+
@Args('fromChain') fromChain: string,
73+
@Args('toChain') toChain: string,
74+
@Args('bridge') bridge: string,
75+
@Args('relayer') relayer: string,
76+
@Args('token') token: string,
77+
@Args('nonce') nonce: number
78+
) {
79+
const orderBy = { nonce: Prisma.SortOrder.desc };
80+
return this.aggregationService.queryHistoryRecordFirst(
81+
{
82+
AND: {
83+
fromChain: fromChain,
84+
toChain: toChain,
85+
bridge: bridge,
86+
relayer: relayer,
87+
sendTokenAddress: token,
88+
nonce: {
89+
lt: nonce,
90+
},
91+
},
92+
},
93+
orderBy
94+
);
95+
}
96+
7097
// query by source tx hash
7198
@Query()
7299
async historyRecordByTxHash(@Args('txHash') txHash: string) {

apollo/src/graphql.ts

Lines changed: 196 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* -------------------------------------------------------
43
* THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
@@ -9,126 +8,226 @@
98
/* eslint-disable */
109

1110
export class HistoryRecord {
12-
id: string;
13-
fromChain: string;
14-
toChain: string;
15-
bridge: string;
16-
reason?: Nullable<string>;
17-
nonce: BigInt;
18-
requestTxHash: string;
19-
responseTxHash?: Nullable<string>;
20-
sender: string;
21-
recipient: string;
22-
sendToken: string;
23-
recvToken: string;
24-
sendAmount: string;
25-
recvAmount?: Nullable<string>;
26-
startTime: number;
27-
endTime?: Nullable<number>;
28-
result: number;
29-
fee: string;
30-
feeToken: string;
31-
messageNonce?: Nullable<string>;
32-
sendTokenAddress?: Nullable<string>;
33-
recvTokenAddress?: Nullable<string>;
34-
sendOuterTokenAddress?: Nullable<string>;
35-
recvOuterTokenAddress?: Nullable<string>;
36-
guardSignatures?: Nullable<string>;
37-
relayer?: Nullable<string>;
38-
endTxHash?: Nullable<string>;
39-
confirmedBlocks?: Nullable<string>;
40-
needWithdrawLiquidity?: Nullable<boolean>;
41-
lastRequestWithdraw?: Nullable<BigInt>;
42-
extData?: Nullable<string>;
11+
id: string;
12+
fromChain: string;
13+
toChain: string;
14+
bridge: string;
15+
reason?: Nullable<string>;
16+
nonce: BigInt;
17+
requestTxHash: string;
18+
responseTxHash?: Nullable<string>;
19+
sender: string;
20+
recipient: string;
21+
sendToken: string;
22+
recvToken: string;
23+
sendAmount: string;
24+
recvAmount?: Nullable<string>;
25+
startTime: number;
26+
endTime?: Nullable<number>;
27+
result: number;
28+
fee: string;
29+
feeToken: string;
30+
messageNonce?: Nullable<string>;
31+
sendTokenAddress?: Nullable<string>;
32+
recvTokenAddress?: Nullable<string>;
33+
sendOuterTokenAddress?: Nullable<string>;
34+
recvOuterTokenAddress?: Nullable<string>;
35+
guardSignatures?: Nullable<string>;
36+
relayer?: Nullable<string>;
37+
endTxHash?: Nullable<string>;
38+
confirmedBlocks?: Nullable<string>;
39+
needWithdrawLiquidity?: Nullable<boolean>;
40+
lastRequestWithdraw?: Nullable<BigInt>;
41+
extData?: Nullable<string>;
4342
}
4443

4544
export class HistoryRecords {
46-
total: number;
47-
records?: Nullable<Nullable<HistoryRecord>[]>;
45+
total: number;
46+
records?: Nullable<Nullable<HistoryRecord>[]>;
4847
}
4948

5049
export class LnBridgeRelayInfo {
51-
id: string;
52-
version: string;
53-
nonce: BigInt;
54-
targetNonce?: Nullable<BigInt>;
55-
fromChain: string;
56-
toChain: string;
57-
bridge: string;
58-
relayer: string;
59-
sendToken?: Nullable<string>;
60-
tokenKey?: Nullable<string>;
61-
transactionHash: string;
62-
timestamp: number;
63-
margin?: Nullable<string>;
64-
protocolFee?: Nullable<string>;
65-
baseFee?: Nullable<string>;
66-
liquidityFeeRate?: Nullable<number>;
67-
slashCount?: Nullable<number>;
68-
withdrawNonce?: Nullable<BigInt>;
69-
lastTransferId?: Nullable<string>;
70-
cost?: Nullable<string>;
71-
profit?: Nullable<string>;
72-
heartbeatTimestamp?: Nullable<number>;
73-
messageChannel?: Nullable<string>;
74-
transferLimit?: Nullable<string>;
75-
softTransferLimit?: Nullable<string>;
76-
paused?: Nullable<boolean>;
77-
dynamicFee?: Nullable<string>;
78-
dynamicFeeExpire?: Nullable<string>;
79-
dynamicFeeSignature?: Nullable<string>;
50+
id: string;
51+
version: string;
52+
nonce: BigInt;
53+
targetNonce?: Nullable<BigInt>;
54+
fromChain: string;
55+
toChain: string;
56+
bridge: string;
57+
relayer: string;
58+
sendToken?: Nullable<string>;
59+
tokenKey?: Nullable<string>;
60+
transactionHash: string;
61+
timestamp: number;
62+
margin?: Nullable<string>;
63+
protocolFee?: Nullable<string>;
64+
baseFee?: Nullable<string>;
65+
liquidityFeeRate?: Nullable<number>;
66+
slashCount?: Nullable<number>;
67+
withdrawNonce?: Nullable<BigInt>;
68+
lastTransferId?: Nullable<string>;
69+
cost?: Nullable<string>;
70+
profit?: Nullable<string>;
71+
heartbeatTimestamp?: Nullable<number>;
72+
messageChannel?: Nullable<string>;
73+
transferLimit?: Nullable<string>;
74+
softTransferLimit?: Nullable<string>;
75+
paused?: Nullable<boolean>;
76+
dynamicFee?: Nullable<string>;
77+
dynamicFeeExpire?: Nullable<string>;
78+
dynamicFeeSignature?: Nullable<string>;
8079
}
8180

8281
export class LnBridgeRelayInfos {
83-
total: number;
84-
records?: Nullable<Nullable<LnBridgeRelayInfo>[]>;
82+
total: number;
83+
records?: Nullable<Nullable<LnBridgeRelayInfo>[]>;
8584
}
8685

8786
export class SortedLnBridgeRelayInfos {
88-
transferLimit: BigInt;
89-
records?: Nullable<Nullable<LnBridgeRelayInfo>[]>;
87+
transferLimit: BigInt;
88+
records?: Nullable<Nullable<LnBridgeRelayInfo>[]>;
9089
}
9190

9291
export class SupportChains {
93-
fromChain: string;
94-
toChains?: Nullable<Nullable<string>[]>;
92+
fromChain: string;
93+
toChains?: Nullable<Nullable<string>[]>;
9594
}
9695

9796
export class HealthInfo {
98-
name?: Nullable<string>;
99-
callTimes?: Nullable<number>;
97+
name?: Nullable<string>;
98+
callTimes?: Nullable<number>;
10099
}
101100

102101
export abstract class IQuery {
103-
abstract historyRecordById(id?: Nullable<string>): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
104-
105-
abstract historyRecordByTxHash(txHash?: Nullable<string>): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
106-
107-
abstract firstHistoryRecord(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, results?: Nullable<Nullable<number>[]>, relayer?: Nullable<string>, token?: Nullable<string>, order?: Nullable<string>, notsubmited?: Nullable<boolean>): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
108-
109-
abstract historyRecords(sender?: Nullable<string>, recipient?: Nullable<string>, relayer?: Nullable<string>, needWithdrawLiquidity?: Nullable<boolean>, fromChains?: Nullable<Nullable<string>[]>, toChains?: Nullable<Nullable<string>[]>, bridges?: Nullable<Nullable<string>[]>, row?: Nullable<number>, page?: Nullable<number>, results?: Nullable<Nullable<number>[]>, recvTokenAddress?: Nullable<string>, order?: Nullable<string>): Nullable<HistoryRecords> | Promise<Nullable<HistoryRecords>>;
110-
111-
abstract checkLnBridgeExist(fromChainId?: Nullable<number>, toChainId?: Nullable<number>, fromToken?: Nullable<string>, toToken?: Nullable<string>, version?: Nullable<string>): Nullable<boolean> | Promise<Nullable<boolean>>;
112-
113-
abstract tasksHealthCheck(name?: Nullable<string>): Nullable<Nullable<HealthInfo>[]> | Promise<Nullable<Nullable<HealthInfo>[]>>;
114-
115-
abstract queryRelayRecords(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, relayer?: Nullable<string>, row?: Nullable<number>): Nullable<HistoryRecords> | Promise<Nullable<HistoryRecords>>;
116-
117-
abstract queryLnBridgeRelayInfos(fromChain?: Nullable<string>, toChain?: Nullable<string>, version?: Nullable<string>, bridge?: Nullable<string>, relayer?: Nullable<string>, row?: Nullable<number>, page?: Nullable<number>): Nullable<LnBridgeRelayInfos> | Promise<Nullable<LnBridgeRelayInfos>>;
118-
119-
abstract sortedLnBridgeRelayInfos(fromChain?: Nullable<string>, toChain?: Nullable<string>, version?: Nullable<string>, bridge?: Nullable<string>, token?: Nullable<string>, row?: Nullable<number>, amount?: Nullable<string>, decimals?: Nullable<number>): Nullable<SortedLnBridgeRelayInfos> | Promise<Nullable<SortedLnBridgeRelayInfos>>;
120-
121-
abstract queryLnBridgeSupportChains(tokenKey?: Nullable<string>): Nullable<Nullable<SupportChains>[]> | Promise<Nullable<Nullable<SupportChains>[]>>;
122-
123-
abstract queryMaxTransfer(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, token?: Nullable<string>, balance?: Nullable<string>): Nullable<BigInt> | Promise<Nullable<BigInt>>;
102+
abstract historyRecordById(
103+
id?: Nullable<string>
104+
): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
105+
106+
abstract previousHistoryRecord(
107+
fromChain?: Nullable<string>,
108+
toChain?: Nullable<string>,
109+
bridge?: Nullable<string>,
110+
relayer?: Nullable<string>,
111+
token?: Nullable<string>,
112+
nonce?: Nullable<number>
113+
): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
114+
115+
abstract historyRecordByTxHash(
116+
txHash?: Nullable<string>
117+
): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
118+
119+
abstract firstHistoryRecord(
120+
fromChain?: Nullable<string>,
121+
toChain?: Nullable<string>,
122+
bridge?: Nullable<string>,
123+
results?: Nullable<Nullable<number>[]>,
124+
relayer?: Nullable<string>,
125+
token?: Nullable<string>,
126+
order?: Nullable<string>,
127+
notsubmited?: Nullable<boolean>
128+
): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
129+
130+
abstract historyRecords(
131+
sender?: Nullable<string>,
132+
recipient?: Nullable<string>,
133+
relayer?: Nullable<string>,
134+
needWithdrawLiquidity?: Nullable<boolean>,
135+
fromChains?: Nullable<Nullable<string>[]>,
136+
toChains?: Nullable<Nullable<string>[]>,
137+
bridges?: Nullable<Nullable<string>[]>,
138+
row?: Nullable<number>,
139+
page?: Nullable<number>,
140+
results?: Nullable<Nullable<number>[]>,
141+
recvTokenAddress?: Nullable<string>,
142+
order?: Nullable<string>
143+
): Nullable<HistoryRecords> | Promise<Nullable<HistoryRecords>>;
144+
145+
abstract checkLnBridgeExist(
146+
fromChainId?: Nullable<number>,
147+
toChainId?: Nullable<number>,
148+
fromToken?: Nullable<string>,
149+
toToken?: Nullable<string>,
150+
version?: Nullable<string>
151+
): Nullable<boolean> | Promise<Nullable<boolean>>;
152+
153+
abstract tasksHealthCheck(
154+
name?: Nullable<string>
155+
): Nullable<Nullable<HealthInfo>[]> | Promise<Nullable<Nullable<HealthInfo>[]>>;
156+
157+
abstract queryRelayRecords(
158+
fromChain?: Nullable<string>,
159+
toChain?: Nullable<string>,
160+
bridge?: Nullable<string>,
161+
relayer?: Nullable<string>,
162+
row?: Nullable<number>
163+
): Nullable<HistoryRecords> | Promise<Nullable<HistoryRecords>>;
164+
165+
abstract queryLnBridgeRelayInfos(
166+
fromChain?: Nullable<string>,
167+
toChain?: Nullable<string>,
168+
version?: Nullable<string>,
169+
bridge?: Nullable<string>,
170+
relayer?: Nullable<string>,
171+
row?: Nullable<number>,
172+
page?: Nullable<number>
173+
): Nullable<LnBridgeRelayInfos> | Promise<Nullable<LnBridgeRelayInfos>>;
174+
175+
abstract sortedLnBridgeRelayInfos(
176+
fromChain?: Nullable<string>,
177+
toChain?: Nullable<string>,
178+
version?: Nullable<string>,
179+
bridge?: Nullable<string>,
180+
token?: Nullable<string>,
181+
row?: Nullable<number>,
182+
amount?: Nullable<string>,
183+
decimals?: Nullable<number>
184+
): Nullable<SortedLnBridgeRelayInfos> | Promise<Nullable<SortedLnBridgeRelayInfos>>;
185+
186+
abstract queryLnBridgeSupportChains(
187+
tokenKey?: Nullable<string>
188+
): Nullable<Nullable<SupportChains>[]> | Promise<Nullable<Nullable<SupportChains>[]>>;
189+
190+
abstract queryMaxTransfer(
191+
fromChain?: Nullable<string>,
192+
toChain?: Nullable<string>,
193+
bridge?: Nullable<string>,
194+
token?: Nullable<string>,
195+
balance?: Nullable<string>
196+
): Nullable<BigInt> | Promise<Nullable<BigInt>>;
124197
}
125198

126199
export abstract class IMutation {
127-
abstract signConfirmedBlock(id?: Nullable<string>, relayer?: Nullable<string>, block?: Nullable<string>, timestamp?: Nullable<number>, signature?: Nullable<string>): Nullable<string> | Promise<Nullable<string>>;
128-
129-
abstract signHeartBeat(fromChainId?: Nullable<string>, toChainId?: Nullable<string>, version?: Nullable<string>, relayer?: Nullable<string>, tokenAddress?: Nullable<string>, softTransferLimit?: Nullable<string>, timestamp?: Nullable<number>, signature?: Nullable<string>): Nullable<string> | Promise<Nullable<string>>;
130-
131-
abstract signDynamicFee(fromChainId?: Nullable<string>, toChainId?: Nullable<string>, version?: Nullable<string>, relayer?: Nullable<string>, tokenAddress?: Nullable<string>, dynamicFee?: Nullable<string>, dynamicFeeExpire?: Nullable<string>, dynamicFeeSignature?: Nullable<string>, timestamp?: Nullable<number>, signature?: Nullable<string>): Nullable<string> | Promise<Nullable<string>>;
200+
abstract signConfirmedBlock(
201+
id?: Nullable<string>,
202+
relayer?: Nullable<string>,
203+
block?: Nullable<string>,
204+
timestamp?: Nullable<number>,
205+
signature?: Nullable<string>
206+
): Nullable<string> | Promise<Nullable<string>>;
207+
208+
abstract signHeartBeat(
209+
fromChainId?: Nullable<string>,
210+
toChainId?: Nullable<string>,
211+
version?: Nullable<string>,
212+
relayer?: Nullable<string>,
213+
tokenAddress?: Nullable<string>,
214+
softTransferLimit?: Nullable<string>,
215+
timestamp?: Nullable<number>,
216+
signature?: Nullable<string>
217+
): Nullable<string> | Promise<Nullable<string>>;
218+
219+
abstract signDynamicFee(
220+
fromChainId?: Nullable<string>,
221+
toChainId?: Nullable<string>,
222+
version?: Nullable<string>,
223+
relayer?: Nullable<string>,
224+
tokenAddress?: Nullable<string>,
225+
dynamicFee?: Nullable<string>,
226+
dynamicFeeExpire?: Nullable<string>,
227+
dynamicFeeSignature?: Nullable<string>,
228+
timestamp?: Nullable<number>,
229+
signature?: Nullable<string>
230+
): Nullable<string> | Promise<Nullable<string>>;
132231
}
133232

134233
export type BigInt = any;

0 commit comments

Comments
 (0)