Skip to content

Commit 6636b2c

Browse files
authored
fix: enhance makeUrlParamsForQuery to prioritize transaction types (#257)
Signed-off-by: Gerhard Steenkamp <gerhard@umaproject.org>
1 parent 552efc2 commit 6636b2c

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/helpers/util.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,32 @@ export function makeUrlParamsForQuery({
143143
requestLogIndex,
144144
assertionHash,
145145
assertionLogIndex,
146+
proposalHash,
147+
proposalLogIndex,
148+
disputeHash,
149+
disputeLogIndex,
150+
settlementHash,
151+
settlementLogIndex,
146152
}: OracleQueryUI) {
147-
const isRequest = !!requestHash && !!requestLogIndex;
148-
149-
const queryParams = {
150-
transactionHash: isRequest ? requestHash : assertionHash!,
151-
eventIndex: isRequest ? requestLogIndex : assertionLogIndex!,
152-
};
153+
// Priority: request/assertion > proposal > dispute > settlement
154+
if (requestHash && requestLogIndex) {
155+
return { transactionHash: requestHash, eventIndex: requestLogIndex };
156+
}
157+
if (assertionHash && assertionLogIndex) {
158+
return { transactionHash: assertionHash, eventIndex: assertionLogIndex };
159+
}
160+
if (proposalHash && proposalLogIndex) {
161+
return { transactionHash: proposalHash, eventIndex: proposalLogIndex };
162+
}
163+
if (disputeHash && disputeLogIndex) {
164+
return { transactionHash: disputeHash, eventIndex: disputeLogIndex };
165+
}
166+
if (settlementHash && settlementLogIndex) {
167+
return { transactionHash: settlementHash, eventIndex: settlementLogIndex };
168+
}
153169

154-
return queryParams;
170+
// Fallback for edge cases
171+
return { transactionHash: "", eventIndex: "" };
155172
}
156173

157174
export function getPageForQuery({ actionType }: OracleQueryUI) {

0 commit comments

Comments
 (0)