diff --git a/package.json b/package.json index 8d1c1da5..cc43e1e6 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "winston": "^3.8.2" }, "devDependencies": { - "@snapshot-labs/eslint-config": "^0.1.0-beta.15", + "@snapshot-labs/eslint-config": "^0.1.0-beta.17", "@snapshot-labs/prettier-config": "^0.1.0-beta.17", "@types/jest": "^29.5.3", "@types/node": "^14.0.13", diff --git a/src/api.ts b/src/api.ts index 65757424..51579edf 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,8 +1,8 @@ -import express from 'express'; import { capture } from '@snapshot-labs/snapshot-sentry'; +import express from 'express'; import { getSpace } from './helpers/spaces'; -import { name, version } from '../package.json'; import { sendError } from './helpers/utils'; +import { name, version } from '../package.json'; const router = express.Router(); const network = process.env.NETWORK || 'testnet'; diff --git a/src/eip4824.ts b/src/eip4824.ts index b03e8e08..2d83ad3b 100644 --- a/src/eip4824.ts +++ b/src/eip4824.ts @@ -1,6 +1,6 @@ import express from 'express'; -import { getSpace } from './helpers/spaces'; import db, { sequencerDB } from './helpers/mysql'; +import { getSpace } from './helpers/spaces'; const router = express.Router(); const context = ''; diff --git a/src/graphql/helpers.ts b/src/graphql/helpers.ts index acb65d8c..712a916e 100644 --- a/src/graphql/helpers.ts +++ b/src/graphql/helpers.ts @@ -1,12 +1,12 @@ import snapshot from '@snapshot-labs/snapshot.js'; import graphqlFields from 'graphql-fields'; -import fetch from 'node-fetch'; import castArray from 'lodash/castArray'; import intersection from 'lodash/intersection'; import uniq from 'lodash/uniq'; -import { jsonParse } from '../helpers/utils'; -import { spacesMetadata } from '../helpers/spaces'; +import fetch from 'node-fetch'; import db from '../helpers/mysql'; +import { spacesMetadata } from '../helpers/spaces'; +import { jsonParse } from '../helpers/utils'; const network = process.env.NETWORK || 'testnet'; diff --git a/src/graphql/index.ts b/src/graphql/index.ts index 42b51456..8ff358de 100644 --- a/src/graphql/index.ts +++ b/src/graphql/index.ts @@ -1,11 +1,11 @@ -import path from 'path'; import fs from 'fs'; -import { graphqlHTTP } from 'express-graphql'; +import path from 'path'; import { makeExecutableSchema } from '@graphql-tools/schema'; -import queryCountLimit from 'graphql-query-count-limit'; +import { graphqlHTTP } from 'express-graphql'; import depthLimit from 'graphql-depth-limit'; -import Query from './operations'; +import queryCountLimit from 'graphql-query-count-limit'; import defaultQuery from './examples'; +import Query from './operations'; const schemaFile = path.join(__dirname, './schema.gql'); const typeDefs = fs.readFileSync(schemaFile, 'utf8'); diff --git a/src/graphql/operations/aliases.ts b/src/graphql/operations/aliases.ts index df3b7b62..a6f75b28 100644 --- a/src/graphql/operations/aliases.ts +++ b/src/graphql/operations/aliases.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; import { buildWhereQuery, checkLimits } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/follows.ts b/src/graphql/operations/follows.ts index 4288c826..5b70d784 100644 --- a/src/graphql/operations/follows.ts +++ b/src/graphql/operations/follows.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; import { buildWhereQuery, checkLimits, formatFollow } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/index.ts b/src/graphql/operations/index.ts index 3e9526c9..d9e7e250 100644 --- a/src/graphql/operations/index.ts +++ b/src/graphql/operations/index.ts @@ -1,27 +1,27 @@ -import space from './space'; -import spaces from './spaces'; -import proposal from './proposal'; -import proposals from './proposals'; -import vote from './vote'; -import votes from './votes'; import aliases from './aliases'; import follows from './follows'; -import subscriptions from './subscriptions'; -import skins from './skins'; +import leaderboards from './leaderboards'; +import messages from './messages'; import networks from './networks'; -import validations from './validations'; import plugins from './plugins'; +import proposal from './proposal'; +import proposals from './proposals'; +import ranking from './ranking'; +import roles from './roles'; +import skins from './skins'; +import space from './space'; +import spaces from './spaces'; +import statement from './statement'; +import statements from './statements'; import strategies from './strategies'; import strategy from './strategy'; -import users from './users'; +import subscriptions from './subscriptions'; import user from './user'; -import statements from './statements'; -import statement from './statement'; +import users from './users'; +import validations from './validations'; +import vote from './vote'; +import votes from './votes'; import vp from './vp'; -import messages from './messages'; -import ranking from './ranking'; -import roles from './roles'; -import leaderboards from './leaderboards'; export default { space, diff --git a/src/graphql/operations/leaderboards.ts b/src/graphql/operations/leaderboards.ts index d3260c2b..6a263ee6 100644 --- a/src/graphql/operations/leaderboards.ts +++ b/src/graphql/operations/leaderboards.ts @@ -1,8 +1,8 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; import uniq from 'lodash/uniq'; -import db from '../../helpers/mysql'; import log from '../../helpers/log'; +import db from '../../helpers/mysql'; import { buildWhereQuery, checkLimits } from '../helpers'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/messages.ts b/src/graphql/operations/messages.ts index 7d93d359..31747c59 100644 --- a/src/graphql/operations/messages.ts +++ b/src/graphql/operations/messages.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import { sequencerDB } from '../../helpers/mysql'; import { buildWhereQuery, checkLimits } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/proposal.ts b/src/graphql/operations/proposal.ts index b54e1f18..529529a6 100644 --- a/src/graphql/operations/proposal.ts +++ b/src/graphql/operations/proposal.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; import { formatProposal } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, { id }) { const query = ` diff --git a/src/graphql/operations/proposals.ts b/src/graphql/operations/proposals.ts index 7559ebd0..0b4e0b8d 100644 --- a/src/graphql/operations/proposals.ts +++ b/src/graphql/operations/proposals.ts @@ -1,7 +1,7 @@ -import db from '../../helpers/mysql'; -import { buildWhereQuery, formatProposal, checkLimits } from '../helpers'; -import log from '../../helpers/log'; import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; +import db from '../../helpers/mysql'; +import { buildWhereQuery, checkLimits, formatProposal } from '../helpers'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/ranking.ts b/src/graphql/operations/ranking.ts index 2cf74b4a..71bd629e 100644 --- a/src/graphql/operations/ranking.ts +++ b/src/graphql/operations/ranking.ts @@ -1,13 +1,13 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; +import db from '../../helpers/mysql'; +import { rankedSpaces } from '../../helpers/spaces'; import { checkLimits, formatSpace, handleRelatedSpaces, PublicError } from '../helpers'; -import log from '../../helpers/log'; -import db from '../../helpers/mysql'; -import { rankedSpaces } from '../../helpers/spaces'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (_parent, args, context, info) { checkLimits(args, 'ranking'); diff --git a/src/graphql/operations/roles.ts b/src/graphql/operations/roles.ts index 51af93c1..35d9bdd0 100644 --- a/src/graphql/operations/roles.ts +++ b/src/graphql/operations/roles.ts @@ -1,6 +1,6 @@ import { capture } from '@snapshot-labs/snapshot-sentry'; -import db from '../../helpers/mysql'; import log from '../../helpers/log'; +import db from '../../helpers/mysql'; export default async function (parent, args) { const { where = {} } = args; diff --git a/src/graphql/operations/space.ts b/src/graphql/operations/space.ts index 53d3e6d5..859ad870 100644 --- a/src/graphql/operations/space.ts +++ b/src/graphql/operations/space.ts @@ -1,6 +1,6 @@ -import { fetchSpaces, handleRelatedSpaces, PublicError } from '../helpers'; -import log from '../../helpers/log'; import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; +import { fetchSpaces, handleRelatedSpaces, PublicError } from '../helpers'; export default async function (_parent, { id }, context, info) { try { diff --git a/src/graphql/operations/spaces.ts b/src/graphql/operations/spaces.ts index b4b42584..ff446508 100644 --- a/src/graphql/operations/spaces.ts +++ b/src/graphql/operations/spaces.ts @@ -1,11 +1,11 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import { checkLimits, fetchSpaces, handleRelatedSpaces, PublicError } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (_parent, args, context, info) { checkLimits(args, 'spaces'); diff --git a/src/graphql/operations/statement.ts b/src/graphql/operations/statement.ts index 50a76c09..621279aa 100644 --- a/src/graphql/operations/statement.ts +++ b/src/graphql/operations/statement.ts @@ -1,6 +1,6 @@ -import db from '../../helpers/mysql'; -import log from '../../helpers/log'; import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; +import db from '../../helpers/mysql'; export default async function (parent, args) { const id = args.id; diff --git a/src/graphql/operations/statements.ts b/src/graphql/operations/statements.ts index d27b12ec..5f8968a2 100644 --- a/src/graphql/operations/statements.ts +++ b/src/graphql/operations/statements.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; import { buildWhereQuery, checkLimits } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/subscriptions.ts b/src/graphql/operations/subscriptions.ts index 4750dec8..452696ea 100644 --- a/src/graphql/operations/subscriptions.ts +++ b/src/graphql/operations/subscriptions.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; import { buildWhereQuery, checkLimits, formatSubscription } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/user.ts b/src/graphql/operations/user.ts index 6e9852d4..62ab4561 100644 --- a/src/graphql/operations/user.ts +++ b/src/graphql/operations/user.ts @@ -1,5 +1,5 @@ -import { formatAddresses, PublicError } from '../helpers'; import users from './users'; +import { formatAddresses, PublicError } from '../helpers'; export default async function (parent, args) { const addresses = formatAddresses([args.id]); diff --git a/src/graphql/operations/users.ts b/src/graphql/operations/users.ts index e7d5d2aa..ef9414ff 100644 --- a/src/graphql/operations/users.ts +++ b/src/graphql/operations/users.ts @@ -1,7 +1,7 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; import { buildWhereQuery, checkLimits, formatUser } from '../helpers'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { const { first, skip, where = {} } = args; diff --git a/src/graphql/operations/vote.ts b/src/graphql/operations/vote.ts index 678e8d2a..d87f3f98 100644 --- a/src/graphql/operations/vote.ts +++ b/src/graphql/operations/vote.ts @@ -1,6 +1,6 @@ import { capture } from '@snapshot-labs/snapshot-sentry'; -import log from '../../helpers/log'; import fetchVotes from './votes'; +import log from '../../helpers/log'; export default async function (parent, { id }, context, info) { try { diff --git a/src/graphql/operations/votes.ts b/src/graphql/operations/votes.ts index 264f39d8..0163dc52 100644 --- a/src/graphql/operations/votes.ts +++ b/src/graphql/operations/votes.ts @@ -1,5 +1,8 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; import graphqlFields from 'graphql-fields'; +import log from '../../helpers/log'; import db from '../../helpers/mysql'; +import serve from '../../helpers/requestDeduplicator'; import { buildWhereQuery, checkLimits, @@ -7,9 +10,6 @@ import { formatSpace, formatVote } from '../helpers'; -import serve from '../../helpers/requestDeduplicator'; -import log from '../../helpers/log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; async function query(parent, args, context?, info?) { const requestedFields = info ? graphqlFields(info) : {}; diff --git a/src/helpers/metrics.ts b/src/helpers/metrics.ts index 02b4b5d1..b538fc6d 100644 --- a/src/helpers/metrics.ts +++ b/src/helpers/metrics.ts @@ -1,10 +1,10 @@ import init, { client } from '@snapshot-labs/snapshot-metrics'; import { capture } from '@snapshot-labs/snapshot-sentry'; -import { Express, type Request, type Response } from 'express'; +import { Express, Request, Response } from 'express'; import { GraphQLError, parse } from 'graphql'; +import db from './mysql'; import { spacesMetadata } from './spaces'; import { strategies } from './strategies'; -import db from './mysql'; import operations from '../graphql/operations/'; const whitelistedPath = [ diff --git a/src/helpers/mysql.ts b/src/helpers/mysql.ts index 965a96ae..f5903bdb 100644 --- a/src/helpers/mysql.ts +++ b/src/helpers/mysql.ts @@ -1,8 +1,8 @@ -import mysql from 'mysql'; -import Pool from 'mysql/lib/Pool'; -import Connection from 'mysql/lib/Connection'; import bluebird from 'bluebird'; import parse from 'connection-string'; +import mysql from 'mysql'; +import Connection from 'mysql/lib/Connection'; +import Pool from 'mysql/lib/Pool'; import log from './log'; const connectionLimit = parseInt(process.env.CONNECTION_LIMIT || '25'); diff --git a/src/helpers/spaces.ts b/src/helpers/spaces.ts index f47104c3..334010fd 100644 --- a/src/helpers/spaces.ts +++ b/src/helpers/spaces.ts @@ -1,9 +1,9 @@ +import { capture } from '@snapshot-labs/snapshot-sentry'; import snapshot from '@snapshot-labs/snapshot.js'; import networks from '@snapshot-labs/snapshot.js/src/networks.json'; import { uniq } from 'lodash'; -import db from './mysql'; import log from './log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; +import db from './mysql'; const RUN_INTERVAL = 120e3; const TEST_STRATEGIES = [ diff --git a/src/helpers/strategies.ts b/src/helpers/strategies.ts index aaf57fc5..e408f015 100644 --- a/src/helpers/strategies.ts +++ b/src/helpers/strategies.ts @@ -1,8 +1,8 @@ +import { URL } from 'url'; +import { capture } from '@snapshot-labs/snapshot-sentry'; import snapshot from '@snapshot-labs/snapshot.js'; -import { spaces } from './spaces'; import log from './log'; -import { capture } from '@snapshot-labs/snapshot-sentry'; -import { URL } from 'url'; +import { spaces } from './spaces'; export let strategies: any[] = []; export let strategiesObj: any = {}; diff --git a/src/index.ts b/src/index.ts index 522a0b22..142ef09e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,14 @@ import 'dotenv/config'; +import { fallbackLogger, initLogger } from '@snapshot-labs/snapshot-sentry'; import cors from 'cors'; import express from 'express'; -import { initLogger, fallbackLogger } from '@snapshot-labs/snapshot-sentry'; import api from './api'; import eip4824 from './eip4824'; import graphql from './graphql'; -import rateLimit from './helpers/rateLimit'; +import { checkKeycard } from './helpers/keycard'; import log from './helpers/log'; import initMetrics from './helpers/metrics'; -import { checkKeycard } from './helpers/keycard'; +import rateLimit from './helpers/rateLimit'; import refreshSpacesCache from './helpers/spaces'; import './helpers/strategies'; diff --git a/test/setupDb.ts b/test/setupDb.ts index 2fa73a82..8dbec39a 100644 --- a/test/setupDb.ts +++ b/test/setupDb.ts @@ -1,9 +1,9 @@ -import mysql from 'mysql'; -import Pool from 'mysql/lib/Pool'; -import Connection from 'mysql/lib/Connection'; +import fs from 'fs'; import bluebird from 'bluebird'; import parse from 'connection-string'; -import fs from 'fs'; +import mysql from 'mysql'; +import Connection from 'mysql/lib/Connection'; +import Pool from 'mysql/lib/Pool'; import { TEST_DATABASE_SUFFIX } from './setup'; // @ts-ignore diff --git a/yarn.lock b/yarn.lock index 50edde74..10316e66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1325,10 +1325,10 @@ dependencies: "@sinonjs/commons" "^3.0.0" -"@snapshot-labs/eslint-config-base@^0.1.0-beta.15": - version "0.1.0-beta.15" - resolved "https://registry.yarnpkg.com/@snapshot-labs/eslint-config-base/-/eslint-config-base-0.1.0-beta.15.tgz#2f64a21a0590d0ffea8a82852ab4bd5742495daa" - integrity sha512-uqOqCDTsl92e1k3edaGweQCSlDo9mU8I1ejqXCJHHDr/ZZyBldd8R73qOjhEVdYBtbdHd97QRdKh3JhMjzhrtg== +"@snapshot-labs/eslint-config-base@^0.1.0-beta.17": + version "0.1.0-beta.17" + resolved "https://registry.yarnpkg.com/@snapshot-labs/eslint-config-base/-/eslint-config-base-0.1.0-beta.17.tgz#e989acfb31facb1518cdf170499de47aec1832c3" + integrity sha512-+NE6BTOKhxvs1el73r9cQEm3SOBhp9La8HUumE4WbMoZz67ovPsdJQt7QuqnqZNDAEiW5sP0eJNsnvvxGxO0ug== dependencies: "@typescript-eslint/eslint-plugin" "^6.7.3" "@typescript-eslint/parser" "^6.7.3" @@ -1336,12 +1336,12 @@ eslint-plugin-import "^2.29.0" eslint-plugin-prettier "^5.0.1" -"@snapshot-labs/eslint-config@^0.1.0-beta.15": - version "0.1.0-beta.15" - resolved "https://registry.yarnpkg.com/@snapshot-labs/eslint-config/-/eslint-config-0.1.0-beta.15.tgz#9aef268a7946476180e433522a4e197d5149fe11" - integrity sha512-bzx8wxho5K1w7jFgo2nikVmr1jzGWE7zcGOlrrEYz9DRNccMAan83BqLSlzxJZn24Jey40eoARiEvFhgtY9MVg== +"@snapshot-labs/eslint-config@^0.1.0-beta.17": + version "0.1.0-beta.17" + resolved "https://registry.yarnpkg.com/@snapshot-labs/eslint-config/-/eslint-config-0.1.0-beta.17.tgz#fe6d4721937902415888a1fa6fec15c57b114870" + integrity sha512-hgEL6hbMAeYKaw7D6Fh+axsU/RZtfCsZHdJOD+CpG/x4+jXaWnV+tKSe6AidT/Yz/wK/4V76t6cAkVJ10ciLOw== dependencies: - "@snapshot-labs/eslint-config-base" "^0.1.0-beta.15" + "@snapshot-labs/eslint-config-base" "^0.1.0-beta.17" "@snapshot-labs/keycard@^0.5.1": version "0.5.1"