Skip to content

Commit

Permalink
Proposed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mj52951 committed Oct 31, 2024
1 parent ceba4f1 commit f14ef35
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/indexer/evmIndexer/evmParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export class EVMParser implements IParser {
`Resource with ID ${event.resourceID} not found in shared configuration`,
);
}
const resourceType = resource.type || "";
const resourceDecimals = resource.decimals || 18;
const resourceType = resource.type ?? "";
const resourceDecimals = resource.decimals ?? 18;

const transaction = assertNotNull(log.transaction, "Missing transaction");

Expand Down Expand Up @@ -194,9 +194,9 @@ export class EVMParser implements IParser {
id: randomUUID(),
tokenAddress: fee.tokenAddress,
tokenSymbol:
this.tokens.get(fee.tokenAddress.toLowerCase())?.symbol || "",
this.tokens.get(fee.tokenAddress.toLowerCase())?.symbol ?? "",
decimals:
this.tokens.get(fee.tokenAddress.toLowerCase())?.decimals || 18,
this.tokens.get(fee.tokenAddress.toLowerCase())?.decimals ?? 18,
amount: fee.fee.toString(),
};
} catch (err) {
Expand Down
20 changes: 10 additions & 10 deletions src/indexer/substrateIndexer/substrateParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SubstrateParser implements ISubstrateParser {
);
}

const resourceType = resource.type || "";
const resourceType = resource.type ?? "";

const extrinsic = assertNotNull(event.extrinsic, "Missing extrinsic");

Expand All @@ -82,21 +82,21 @@ export class SubstrateParser implements ISubstrateParser {
fromDomainID: fromDomain.id,
resourceID: resource.resourceId,
txHash: extrinsic.id,
timestamp: new Date(event.block.timestamp || ""),
timestamp: new Date(event.block.timestamp ?? ""),
depositData: decodedEvent.depositData,
handlerResponse: decodedEvent.handlerResponse,
transferType: resourceType,
amount: decodeAmountOrTokenId(
decodedEvent.depositData,
resource.decimals || 12,
resource.decimals ?? 12,
resource.type,
),
fee: {
id: randomUUID(),
amount: "50",
decimals: resource.decimals || 0,
decimals: resource.decimals ?? 0,
tokenAddress: "",
tokenSymbol: resource.symbol || "",
tokenSymbol: resource.symbol ?? "",
},
};
}
Expand All @@ -118,7 +118,7 @@ export class SubstrateParser implements ISubstrateParser {
blockNumber: event.block.height,
depositNonce: decodedEvent.depositNonce,
txHash: extrinsic.id,
timestamp: new Date(event.block.timestamp || ""),
timestamp: new Date(event.block.timestamp ?? ""),
fromDomainID: decodedEvent.originDomainId,
toDomainID: toDomain.id,
};
Expand Down Expand Up @@ -154,7 +154,7 @@ export class SubstrateParser implements ISubstrateParser {
(resource) =>
resource.resourceId.toLowerCase() ==
decodedEvent.resourceId.toLowerCase(),
) as SubstrateResource;
) as SubstrateResource | undefined;
if (!resource) {
throw new Error(
`Resource with ID ${decodedEvent.resourceId} not found in shared configuration`,
Expand All @@ -165,10 +165,10 @@ export class SubstrateParser implements ISubstrateParser {

return {
id: randomUUID(),
amount: decodedEvent.feeAmount.toString().replace(/,/g, ""),
decimals: resource.decimals || 0,
amount: decodedEvent.feeAmount.toString().replaceAll(",", ""),
decimals: resource.decimals ?? 0,
tokenAddress: JSON.stringify(decodedEvent.feeAssetId),
tokenSymbol: resource.symbol || "",
tokenSymbol: resource.symbol ?? "",
txIdentifier: extrinsic.id,
};
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"target": "es2021",
"outDir": "lib",
"rootDir": "src",
"strict": true,
Expand Down

0 comments on commit f14ef35

Please sign in to comment.