From 7263916a41543ea9cf4944b3f36e08cb56d12c5b Mon Sep 17 00:00:00 2001 From: dmelotik Date: Wed, 25 Oct 2023 21:41:31 -0600 Subject: [PATCH] fix _reference_ subgraph lint --- subgraphs/_reference_/src/common/tokens.ts | 49 +++++++++---------- .../_reference_/src/common/utils/datetime.ts | 1 - .../_reference_/src/prices/config/arbitrum.ts | 2 +- .../_reference_/src/prices/config/aurora.ts | 2 +- .../src/prices/config/avalanche.ts | 2 +- .../_reference_/src/prices/config/bsc.ts | 2 +- .../_reference_/src/prices/config/celo.ts | 2 +- .../_reference_/src/prices/config/cronos.ts | 2 +- .../_reference_/src/prices/config/fantom.ts | 2 +- .../_reference_/src/prices/config/fuse.ts | 2 +- .../_reference_/src/prices/config/gnosis.ts | 2 +- .../_reference_/src/prices/config/harmony.ts | 2 +- .../_reference_/src/prices/config/moonbeam.ts | 2 +- .../_reference_/src/prices/config/optimism.ts | 2 +- .../_reference_/src/prices/config/polygon.ts | 2 +- .../_reference_/src/prices/config/template.ts | 2 +- .../src/prices/routers/UniswapForksRouter.ts | 1 - .../src/sdk/protocols/bridge/chainIds.ts | 1 - 18 files changed, 38 insertions(+), 42 deletions(-) diff --git a/subgraphs/_reference_/src/common/tokens.ts b/subgraphs/_reference_/src/common/tokens.ts index 4d38f895ed..a6f22662e8 100644 --- a/subgraphs/_reference_/src/common/tokens.ts +++ b/subgraphs/_reference_/src/common/tokens.ts @@ -1,4 +1,3 @@ -/* eslint-disable prefer-const */ import { ERC20 } from "../../generated/UniswapV2Factory/ERC20"; import { ERC20SymbolBytes } from "../../generated/UniswapV2Factory/ERC20SymbolBytes"; import { ERC20NameBytes } from "../../generated/UniswapV2Factory/ERC20NameBytes"; @@ -9,25 +8,25 @@ export const INVALID_TOKEN_DECIMALS = 0; export const UNKNOWN_TOKEN_VALUE = "unknown"; export function fetchTokenSymbol(tokenAddress: Address): string { - let contract = ERC20.bind(tokenAddress); - let contractSymbolBytes = ERC20SymbolBytes.bind(tokenAddress); + const contract = ERC20.bind(tokenAddress); + const contractSymbolBytes = ERC20SymbolBytes.bind(tokenAddress); // try types string and bytes32 for symbol let symbolValue = UNKNOWN_TOKEN_VALUE; - let symbolResult = contract.try_symbol(); + const symbolResult = contract.try_symbol(); if (!symbolResult.reverted) { return symbolResult.value; } // non-standard ERC20 implementation - let symbolResultBytes = contractSymbolBytes.try_symbol(); + const symbolResultBytes = contractSymbolBytes.try_symbol(); if (!symbolResultBytes.reverted) { // for broken pairs that have no symbol function exposed if (!isNullEthValue(symbolResultBytes.value.toHexString())) { symbolValue = symbolResultBytes.value.toString(); } else { // try with the static definition - let staticTokenDefinition = + const staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress); if (staticTokenDefinition != null) { symbolValue = staticTokenDefinition.symbol; @@ -39,25 +38,25 @@ export function fetchTokenSymbol(tokenAddress: Address): string { } export function fetchTokenName(tokenAddress: Address): string { - let contract = ERC20.bind(tokenAddress); - let contractNameBytes = ERC20NameBytes.bind(tokenAddress); + const contract = ERC20.bind(tokenAddress); + const contractNameBytes = ERC20NameBytes.bind(tokenAddress); // try types string and bytes32 for name let nameValue = UNKNOWN_TOKEN_VALUE; - let nameResult = contract.try_name(); + const nameResult = contract.try_name(); if (!nameResult.reverted) { return nameResult.value; } // non-standard ERC20 implementation - let nameResultBytes = contractNameBytes.try_name(); + const nameResultBytes = contractNameBytes.try_name(); if (!nameResultBytes.reverted) { // for broken exchanges that have no name function exposed if (!isNullEthValue(nameResultBytes.value.toHexString())) { nameValue = nameResultBytes.value.toString(); } else { // try with the static definition - let staticTokenDefinition = + const staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress); if (staticTokenDefinition != null) { nameValue = staticTokenDefinition.name; @@ -69,17 +68,17 @@ export function fetchTokenName(tokenAddress: Address): string { } export function fetchTokenDecimals(tokenAddress: Address): i32 { - let contract = ERC20.bind(tokenAddress); + const contract = ERC20.bind(tokenAddress); // try types uint8 for decimals - let decimalResult = contract.try_decimals(); + const decimalResult = contract.try_decimals(); if (!decimalResult.reverted) { - let decimalValue = decimalResult.value; + const decimalValue = decimalResult.value; return decimalValue.toI32(); } // try with the static definition - let staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress); + const staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress); if (staticTokenDefinition != null) { return staticTokenDefinition.decimals as i32; } else { @@ -111,10 +110,10 @@ class StaticTokenDefinition { // Get all tokens with a static defintion static getStaticDefinitions(): Array { - let staticDefinitions = new Array(INT_SIX); + const staticDefinitions = new Array(INT_SIX); // Add DGD - let tokenDGD = new StaticTokenDefinition( + const tokenDGD = new StaticTokenDefinition( Address.fromString("0xe0b7927c4af23765cb51314a0e0521a9645f0e2a"), "DGD", "DGD", @@ -123,7 +122,7 @@ class StaticTokenDefinition { staticDefinitions.push(tokenDGD); // Add AAVE - let tokenAAVE = new StaticTokenDefinition( + const tokenAAVE = new StaticTokenDefinition( Address.fromString("0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9"), "AAVE", "Aave Token", @@ -132,7 +131,7 @@ class StaticTokenDefinition { staticDefinitions.push(tokenAAVE); // Add LIF - let tokenLIF = new StaticTokenDefinition( + const tokenLIF = new StaticTokenDefinition( Address.fromString("0xeb9951021698b42e4399f9cbb6267aa35f82d59d"), "LIF", "Lif", @@ -141,7 +140,7 @@ class StaticTokenDefinition { staticDefinitions.push(tokenLIF); // Add SVD - let tokenSVD = new StaticTokenDefinition( + const tokenSVD = new StaticTokenDefinition( Address.fromString("0xbdeb4b83251fb146687fa19d1c660f99411eefe3"), "SVD", "savedroid", @@ -150,7 +149,7 @@ class StaticTokenDefinition { staticDefinitions.push(tokenSVD); // Add TheDAO - let tokenTheDAO = new StaticTokenDefinition( + const tokenTheDAO = new StaticTokenDefinition( Address.fromString("0xbb9bc244d798123fde783fcc1c72d3bb8c189413"), "TheDAO", "TheDAO", @@ -159,7 +158,7 @@ class StaticTokenDefinition { staticDefinitions.push(tokenTheDAO); // Add HPB - let tokenHPB = new StaticTokenDefinition( + const tokenHPB = new StaticTokenDefinition( Address.fromString("0x38c6a68304cdefb9bec48bbfaaba5c5b47818bb2"), "HPB", "HPBCoin", @@ -172,12 +171,12 @@ class StaticTokenDefinition { // Helper for hardcoded tokens static fromAddress(tokenAddress: Address): StaticTokenDefinition | null { - let staticDefinitions = this.getStaticDefinitions(); - let tokenAddressHex = tokenAddress.toHexString(); + const staticDefinitions = this.getStaticDefinitions(); + const tokenAddressHex = tokenAddress.toHexString(); // Search the definition using the address for (let i = 0; i < staticDefinitions.length; i++) { - let staticDefinition = staticDefinitions[i]; + const staticDefinition = staticDefinitions[i]; if (staticDefinition.address.toHexString() == tokenAddressHex) { return staticDefinition; } diff --git a/subgraphs/_reference_/src/common/utils/datetime.ts b/subgraphs/_reference_/src/common/utils/datetime.ts index cd72185343..39b600c1e3 100644 --- a/subgraphs/_reference_/src/common/utils/datetime.ts +++ b/subgraphs/_reference_/src/common/utils/datetime.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers */ import { BigInt } from "@graphprotocol/graph-ts"; import { SECONDS_PER_DAY } from "../constants"; diff --git a/subgraphs/_reference_/src/prices/config/arbitrum.ts b/subgraphs/_reference_/src/prices/config/arbitrum.ts index 145692b274..bf39a7b81b 100644 --- a/subgraphs/_reference_/src/prices/config/arbitrum.ts +++ b/subgraphs/_reference_/src/prices/config/arbitrum.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/aurora.ts b/subgraphs/_reference_/src/prices/config/aurora.ts index 628013c4bf..d3b303b815 100644 --- a/subgraphs/_reference_/src/prices/config/aurora.ts +++ b/subgraphs/_reference_/src/prices/config/aurora.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/avalanche.ts b/subgraphs/_reference_/src/prices/config/avalanche.ts index 5d181039be..f40fbbf1aa 100644 --- a/subgraphs/_reference_/src/prices/config/avalanche.ts +++ b/subgraphs/_reference_/src/prices/config/avalanche.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/bsc.ts b/subgraphs/_reference_/src/prices/config/bsc.ts index ecef0f8d3e..0d00234608 100644 --- a/subgraphs/_reference_/src/prices/config/bsc.ts +++ b/subgraphs/_reference_/src/prices/config/bsc.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/celo.ts b/subgraphs/_reference_/src/prices/config/celo.ts index 2318f6b643..1e961cb575 100644 --- a/subgraphs/_reference_/src/prices/config/celo.ts +++ b/subgraphs/_reference_/src/prices/config/celo.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/cronos.ts b/subgraphs/_reference_/src/prices/config/cronos.ts index f847104822..5149b29d2a 100644 --- a/subgraphs/_reference_/src/prices/config/cronos.ts +++ b/subgraphs/_reference_/src/prices/config/cronos.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/fantom.ts b/subgraphs/_reference_/src/prices/config/fantom.ts index 9d461b497a..22920117cc 100644 --- a/subgraphs/_reference_/src/prices/config/fantom.ts +++ b/subgraphs/_reference_/src/prices/config/fantom.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/fuse.ts b/subgraphs/_reference_/src/prices/config/fuse.ts index 2392dba83d..87078fc497 100644 --- a/subgraphs/_reference_/src/prices/config/fuse.ts +++ b/subgraphs/_reference_/src/prices/config/fuse.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/gnosis.ts b/subgraphs/_reference_/src/prices/config/gnosis.ts index 8c4abb1db8..4d1ab5baaa 100644 --- a/subgraphs/_reference_/src/prices/config/gnosis.ts +++ b/subgraphs/_reference_/src/prices/config/gnosis.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/harmony.ts b/subgraphs/_reference_/src/prices/config/harmony.ts index 4ed750f8ca..6f9d265210 100644 --- a/subgraphs/_reference_/src/prices/config/harmony.ts +++ b/subgraphs/_reference_/src/prices/config/harmony.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/moonbeam.ts b/subgraphs/_reference_/src/prices/config/moonbeam.ts index 91b3002639..33bcd9e348 100644 --- a/subgraphs/_reference_/src/prices/config/moonbeam.ts +++ b/subgraphs/_reference_/src/prices/config/moonbeam.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/optimism.ts b/subgraphs/_reference_/src/prices/config/optimism.ts index 14a271641f..3bc65a7e56 100644 --- a/subgraphs/_reference_/src/prices/config/optimism.ts +++ b/subgraphs/_reference_/src/prices/config/optimism.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/polygon.ts b/subgraphs/_reference_/src/prices/config/polygon.ts index 55d2778512..782ba266d2 100644 --- a/subgraphs/_reference_/src/prices/config/polygon.ts +++ b/subgraphs/_reference_/src/prices/config/polygon.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { BigInt, Address, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/config/template.ts b/subgraphs/_reference_/src/prices/config/template.ts index c56b0e9785..e919b22c74 100644 --- a/subgraphs/_reference_/src/prices/config/template.ts +++ b/subgraphs/_reference_/src/prices/config/template.ts @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-unused-vars */ import * as constants from "../common/constants"; import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { Configurations, OracleConfig, OracleContract } from "../common/types"; diff --git a/subgraphs/_reference_/src/prices/routers/UniswapForksRouter.ts b/subgraphs/_reference_/src/prices/routers/UniswapForksRouter.ts index f809028dbb..19418ad759 100644 --- a/subgraphs/_reference_/src/prices/routers/UniswapForksRouter.ts +++ b/subgraphs/_reference_/src/prices/routers/UniswapForksRouter.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers */ import * as utils from "../common/utils"; import * as constants from "../common/constants"; import { CustomPriceType } from "../common/types"; diff --git a/subgraphs/_reference_/src/sdk/protocols/bridge/chainIds.ts b/subgraphs/_reference_/src/sdk/protocols/bridge/chainIds.ts index a72e25f32b..fe64a5766a 100644 --- a/subgraphs/_reference_/src/sdk/protocols/bridge/chainIds.ts +++ b/subgraphs/_reference_/src/sdk/protocols/bridge/chainIds.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-magic-numbers */ import { BigInt, TypedMap } from "@graphprotocol/graph-ts"; import { Network } from "../../util/constants";