Skip to content

Commit 673b0cb

Browse files
authored
Fixed relays event handlers (#42)
* Fixed proofValidationStatus field of relays events * Fixed attributes mapping of EventApplicationOverserviced event handler
1 parent 3eeb36c commit 673b0cb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/mappings/poktroll/relays.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ import { optimizedBulkCreate } from "../utils/db";
4242
import { getBlockId, getEventId, getRelayId, messageId } from "../utils/ids";
4343
import { parseJson, stringify } from "../utils/json";
4444

45-
function getClaimProofStatusFromSDK(item: typeof ClaimProofStatusSDKType | string | number): ClaimProofStatus {
45+
// this can return undefined because older events do not have this attribute
46+
function getClaimProofStatusFromSDK(item: typeof ClaimProofStatusSDKType | string | number): ClaimProofStatus | undefined {
47+
if (!item) return undefined;
48+
4649
switch (item) {
4750
case 0:
4851
case ClaimProofStatusSDKType.PENDING_VALIDATION:
@@ -149,7 +152,7 @@ function getAttributes(attributes: CosmosEvent["event"]["attributes"]) {
149152
// @ts-ignore
150153
claimed: CoinSDKType = {},
151154
failureReason = '',
152-
proofValidationStatus: ClaimProofStatus | null = null,
155+
proofValidationStatus: ClaimProofStatus | undefined,
153156
settlementResult: ClaimSettlementResultSDKType | null = null,
154157
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
155158
// @ts-ignore
@@ -574,11 +577,11 @@ function _handleEventApplicationOverserviced(event: CosmosEvent): EventApplicati
574577
let expectedBurn: Coin | null = null, effectiveBurn: Coin | null = null, applicationAddress = '', supplierAddress = '';
575578

576579
for (const attribute of event.event.attributes) {
577-
if (attribute.key === "application") {
580+
if (attribute.key === "application_addr") {
578581
applicationAddress = (attribute.value as string).replaceAll('"', '');
579582
}
580583

581-
if (attribute.key === "supplier") {
584+
if (attribute.key === "supplier_operator_addr") {
582585
supplierAddress = (attribute.value as string).replaceAll('"', '');
583586
}
584587

0 commit comments

Comments
 (0)