Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tryouge committed Nov 2, 2023
1 parent ab71fa3 commit cf1e991
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions subgraphs/orbit/src/common/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export function fetchTokenSymbol(tokenAddress: Address): string {
// for broken pairs that have no symbol function exposed
if (!isNullEthValue(symbolResultBytes.value.toHexString())) {
return symbolResultBytes.value.toString();
} else {
// try with the static definition
let staticTokenDefinition =
StaticTokenDefinition.fromAddress(tokenAddress);
if (staticTokenDefinition != null) {
return staticTokenDefinition.symbol;
}
}
}
log.warning(
Expand All @@ -57,13 +50,6 @@ export function fetchTokenName(tokenAddress: Address): string {
// for broken exchanges that have no name function exposed
if (!isNullEthValue(nameResultBytes.value.toHexString())) {
return nameResultBytes.value.toString();
} else {
// try with the static definition
let staticTokenDefinition =
StaticTokenDefinition.fromAddress(tokenAddress);
if (staticTokenDefinition != null) {
return staticTokenDefinition.name;
}
}
}
log.warning(
Expand All @@ -83,17 +69,11 @@ export function fetchTokenDecimals(tokenAddress: Address): i32 {
return decimalValue as i32;
}

// try with the static definition
let staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress);
if (staticTokenDefinition != null) {
return staticTokenDefinition.decimals as i32;
} else {
log.warning(
"[getTokenParams]token {} decimals() call reverted; default to 18 decimals",
[tokenAddress.toHexString()]
);
return 18 as i32;
}
log.warning(
"[getTokenParams]token {} decimals() call reverted; default to 18 decimals",
[tokenAddress.toHexString()]
);
return 18 as i32;

Check failure on line 76 in subgraphs/orbit/src/common/tokens.ts

View workflow job for this annotation

GitHub Actions / LintStagedFiles

No magic number: 18
}

export function isNullEthValue(value: string): boolean {
Expand Down

0 comments on commit cf1e991

Please sign in to comment.