refactor: remove unnecessary auth (#4723)

* removed aws auth
* updated fetching and package scripts
* updated url usage
This commit is contained in:
cartcrom 2022-09-26 18:01:50 -04:00 committed by GitHub
parent 868edc6028
commit 0041b787ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 12 additions and 10660 deletions

@ -4,3 +4,4 @@ REACT_APP_INFURA_KEY="099fc58e0de9451d80b18d7c74caa7c1"
REACT_APP_FORTMATIC_KEY="pk_live_F937DF033A1666BF"
REACT_APP_GOOGLE_ANALYTICS_ID="G-KDP9B6W4H8"
REACT_APP_FIREBASE_KEY="AIzaSyBcZWwTcTJHj_R6ipZcrJkXdq05PuX0Rs0"
REACT_APP_AWS_API_ENDPOINT="https://api.uniswap.org/v1/graphql"

1
.gitignore vendored

@ -10,6 +10,7 @@
# generated graphql types
__generated__/
schema.graphql
# dependencies
/node_modules

@ -1,5 +1,5 @@
/* eslint-disable */
require('dotenv').config({ path: '.env.local' })
require('dotenv').config({ path: '.env.production' })
const { exec } = require('child_process')
const dataConfig = require('./relay.config')
const thegraphConfig = require('./relay_thegraph.config')
@ -8,11 +8,7 @@ const thegraphConfig = require('./relay_thegraph.config')
const THEGRAPH_API_URL = 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3'
exec(`get-graphql-schema ${THEGRAPH_API_URL} > ${thegraphConfig.schema}`)
const API_URL = process.env.REACT_APP_GQL_API_URL
const API_KEY = process.env.REACT_APP_GQL_API_KEY
if (API_URL && API_KEY) {
exec(`get-graphql-schema ${API_URL} --h X-API-KEY=${API_KEY} > ${dataConfig.schema}`)
} else {
console.log('REACT_APP_GQL_API_URL or REACT_APP_GQL_API_KEY is missing from env.local')
}
console.log(process.env.REACT_APP_AWS_API_ENDPOINT)
exec(
`get-graphql-schema --h Origin=https://app.uniswap.org ${process.env.REACT_APP_AWS_API_ENDPOINT} > ${dataConfig.schema}`
)

@ -16,7 +16,7 @@
"i18n:extract": "lingui extract --locale en-US",
"i18n:compile": "yarn i18n:extract && lingui compile",
"i18n:pseudo": "lingui extract --locale pseudo && lingui compile",
"prepare": "yarn contracts:compile && yarn graphql:generate && yarn i18n:compile",
"prepare": "yarn contracts:compile && yarn graphql:fetch && yarn graphql:generate && yarn i18n:compile",
"start": "craco start",
"build": "craco build",
"serve": "serve build -l 3000",
@ -170,7 +170,6 @@
"ajv": "^6.12.3",
"array.prototype.flat": "^1.2.4",
"array.prototype.flatmap": "^1.2.4",
"aws4fetch": "^1.0.13",
"cids": "^1.0.0",
"clsx": "^1.1.1",
"copy-to-clipboard": "^3.2.0",

@ -1,27 +1,14 @@
import { AwsClient } from 'aws4fetch'
import { Variables } from 'react-relay'
import { GraphQLResponse, RequestParameters } from 'relay-runtime'
const AWS_API_REGION = process.env.REACT_APP_AWS_API_REGION
const AWS_API_ACCESS_KEY = process.env.REACT_APP_AWS_API_ACCESS_KEY
const AWS_API_ACCESS_SECRET = process.env.REACT_APP_AWS_API_ACCESS_SECRET
const AWS_X_API_KEY = process.env.REACT_APP_AWS_X_API_KEY
const URL = process.env.REACT_APP_AWS_API_ENDPOINT
if (!AWS_API_REGION || !AWS_API_ACCESS_KEY || !AWS_API_ACCESS_SECRET || !AWS_X_API_KEY || !URL) {
throw new Error('AWS KEYS MISSING FROM ENVIRONMENT')
if (!URL) {
throw new Error('AWS URL MISSING FROM ENVIRONMENT')
}
const aws = new AwsClient({
accessKeyId: AWS_API_ACCESS_KEY, // required, akin to AWS_ACCESS_KEY_ID
secretAccessKey: AWS_API_ACCESS_SECRET, // required, akin to AWS_SECRET_ACCESS_KEY
service: 'execute-api',
region: AWS_API_REGION, // AWS region, by default parsed at fetch time
})
const headers = {
'Content-Type': 'application/json',
'x-api-key': AWS_X_API_KEY,
}
const fetchQuery = (params: RequestParameters, variables: Variables): Promise<GraphQLResponse> => {
const body = JSON.stringify({
@ -29,7 +16,7 @@ const fetchQuery = (params: RequestParameters, variables: Variables): Promise<Gr
variables,
})
return aws.fetch(URL, { body, headers }).then((res) => res.json())
return fetch(URL, { method: 'POST', body, headers }).then((res) => res.json())
}
export default fetchQuery

@ -1,432 +0,0 @@
"""This directive allows results to be deferred during execution"""
directive @defer on FIELD
"""
Tells the service this field/object has access authorized by sigv4 signing.
"""
directive @aws_iam on OBJECT | FIELD_DEFINITION
"""
Tells the service this field/object has access authorized by an API key.
"""
directive @aws_api_key on OBJECT | FIELD_DEFINITION
"""
Tells the service this field/object has access authorized by a Lambda Authorizer.
"""
directive @aws_lambda on OBJECT | FIELD_DEFINITION
"""Directs the schema to enforce authorization on a field"""
directive @aws_auth(
"""List of cognito user pool groups which have access on this field"""
cognito_groups: [String]
) on FIELD_DEFINITION
"""Tells the service which mutation triggers this subscription."""
directive @aws_subscribe(
"""
List of mutations which will trigger this subscription when they are called.
"""
mutations: [String]
) on FIELD_DEFINITION
"""
Tells the service which subscriptions will be published to when this mutation is
called. This directive is deprecated use @aws_susbscribe directive instead.
"""
directive @aws_publish(
"""
List of subscriptions which will be published to when this mutation is called.
"""
subscriptions: [String]
) on FIELD_DEFINITION
"""
Tells the service this field/object has access authorized by a Cognito User Pools token.
"""
directive @aws_cognito_user_pools(
"""List of cognito user pool groups which have access on this field"""
cognito_groups: [String]
) on OBJECT | FIELD_DEFINITION
"""
Tells the service this field/object has access authorized by an OIDC token.
"""
directive @aws_oidc on OBJECT | FIELD_DEFINITION
enum ActivityType {
APPROVE
CANCEL
CLAIM
SEND
RECEIVE
SWAP
DEPLOYMENT
UNKNOWN
money
market
LEND
BORROW
REPAY
WITHDRAW
NFT
MINT
BURN
Staking
STAKE
UNSTAKE
}
type Amount implements IAmount {
id: ID!
currency: Currency
value: Float
}
type AssetActivity {
id: ID!
timestamp: Int!
type: ActivityType!
gasUsed: Float
transaction: Transaction!
assetChanges: [AssetChange]!
}
union AssetChange = TokenTransfer | NftTransfer | TokenApproval | NftApproval | NftApproveForAll
enum Chain {
ARBITRUM
ETHEREUM
ETHEREUM_GOERLI
OPTIMISM
POLYGON
CELO
}
input ContractInput {
chain: Chain!
address: String
}
enum Currency {
USD
ETH
}
type Dimensions {
id: ID!
height: Float
width: Float
}
enum HighLow {
HIGH
LOW
}
enum HistoryDuration {
HOUR
DAY
WEEK
MONTH
YEAR
MAX
}
interface IAmount {
currency: Currency
value: Float
}
interface IContract {
chain: Chain!
address: String
}
type Image {
id: ID!
url: String
dimensions: Dimensions
}
enum MarketSortableField {
MARKET_CAP
VOLUME
}
type NftApproval {
id: ID!
nftStandard: NftStandard!
""" can be erc20 or erc1155"""
asset: NftAsset!
approvedAddress: String!
}
type NftApproveForAll {
id: ID!
nftStandard: NftStandard!
""" can be erc721 or erc1155"""
asset: NftAsset!
operatorAddress: String!
approved: Boolean!
}
type NftAsset {
id: ID!
collection: NftCollection
description: String
imageUrl: String
thumbnailUrl: String
animationUrl: String
smallImageUrl: String
image: Image
thumbnail: Image
smallImage: Image
name: String
nftContract: NftContract
"""
TODO: may need to be array to support erc1155 cases. not needed at the moment so will revisit.
ownerAddress: String
"""
tokenId: String
traits: [NftAssetTrait]
}
enum NftAssetSortableField {
PRICE
}
type NftAssetTrait {
id: ID!
name: String
rarity: Float
value: String
}
type NftBalance {
id: ID!
ownedAsset: NftAsset
}
type NftCollection {
id: ID!
collectionId: String
"""
TODO: support querying for collection assets here
assets(page: Int, pageSize: Int, orderBy: NftAssetSortableField): [NftAsset]
"""
bannerImageUrl: String
bannerImage: Image
description: String
discordUrl: String
homepageUrl: String
imageUrl: String
image: Image
instagramName: String
markets(currencies: [Currency!]!): [NftCollectionMarket]
name: String
nftContracts: [NftContract]
openseaUrl: String
"""
TODO: support collection-level traits.
traits: [NftCollectionTraits] (not needed yet)
"""
twitterName: String
isVerified: Boolean
numAssets: Int
}
type NftCollectionMarket {
id: ID!
floorPrice: Amount
owners: Int
volume24h: Amount
totalVolume: Amount
}
type NftCollectionTraits {
id: ID!
name: String
values: [String]
}
type NftContract implements IContract {
id: ID!
address: String
chain: Chain!
name: String
standard: NftStandard
symbol: String
totalSupply: Int
}
enum NftMarketSortableField {
VOLUME
FLOOR_PRICE
}
enum NftStandard {
ERC721
ERC1155
NONCOMPLIANT
}
type NftTransfer {
id: ID!
nftStandard: NftStandard!
asset: NftAsset!
sender: String!
recipient: String!
direction: TransactionDirection!
}
type Portfolio {
id: ID!
ownerAddress: String!
tokensTotalDenominatedValue: Amount
tokensTotalDenominatedValueHistory(duration: HistoryDuration): [TimestampedAmount]
tokenBalances: [TokenBalance]
assetsValueUSD: Float
totalValueUSD: Float
assetsValue: Float
totalValue: Float
absoluteChange24H: Float
relativeChange24H: Float
nftBalances: [NftBalance]
}
type Query {
tokens(contracts: [ContractInput!]!): [Token]
tokenProjects(contracts: [ContractInput!]!): [TokenProject]
topTokenProjects(orderBy: MarketSortableField!, page: Int!, pageSize: Int!, currency: Currency): [TokenProject]
searchTokens(searchQuery: String!): [Token]
searchTokenProjects(searchQuery: String!): [TokenProject]
assetActivities(address: String!, page: Int, pageSize: Int): [AssetActivity]
portfolio(ownerAddress: String!): Portfolio
portfolios(ownerAddresses: [String!]!): [Portfolio]
nftCollectionsById(collectionIds: [String]): [NftCollection]
topTokens(chain: Chain, page: Int!, pageSize: Int!): [Token]
}
type TimestampedAmount implements IAmount {
id: ID!
currency: Currency
value: Float
timestamp: Int!
}
type Token implements IContract {
id: ID!
chain: Chain!
address: String
standard: TokenStandard
decimals: Int
name: String
symbol: String
project: TokenProject
market(currency: Currency): TokenMarket
}
type TokenApproval {
id: ID!
tokenStandard: TokenStandard!
""" can be erc20 or erc1155"""
asset: Token!
approvedAddress: String!
quantity: String!
}
type TokenBalance {
id: ID!
blockNumber: Int
blockTimestamp: Int
quantity: Float
denominatedValue: Amount
ownerAddress: String!
token: Token
tokenProjectMarket: TokenProjectMarket
}
type TokenMarket {
id: ID!
token: Token!
price: Amount
totalValueLocked: Amount
volume(duration: HistoryDuration!): Amount
pricePercentChange(duration: HistoryDuration!): Amount
priceHistory(duration: HistoryDuration!): [TimestampedAmount]
}
type TokenProject {
id: ID!
name: String
tokens: [Token!]!
description: String
twitterName: String
homepageUrl: String
logoUrl: String
markets(currencies: [Currency!]!): [TokenProjectMarket]
}
type TokenProjectMarket {
id: ID!
tokenProject: TokenProject!
currency: Currency!
price: Amount
volume24h: Amount
pricePercentChange24h: Amount
marketCap: Amount
fullyDilutedMarketCap: Amount
priceHistory(duration: HistoryDuration!): [TimestampedAmount]
volume(duration: HistoryDuration!): Amount
pricePercentChange(duration: HistoryDuration!): Amount
priceHighLow(duration: HistoryDuration!, highLow: HighLow!): Amount
}
enum TokenStandard {
NATIVE
ERC20
ERC1155
}
type TokenTransfer {
id: ID!
tokenStandard: TokenStandard!
asset: Token!
sender: String!
recipient: String!
quantity: String!
direction: TransactionDirection!
transactedValue: Amount
}
type Transaction {
id: ID!
blockNumber: Int!
from: String!
to: String!
hash: String!
nonce: Int!
gasLimit: Float
maxFeePerGas: Float
status: TransactionStatus!
}
enum TransactionDirection {
IN
OUT
SELF
}
enum TransactionStatus {
FAILED
CONFIRMED
PENDING
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -5481,11 +5481,6 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59"
integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==
aws4fetch@^1.0.13:
version "1.0.13"
resolved "https://registry.yarnpkg.com/aws4fetch/-/aws4fetch-1.0.13.tgz#81f09e3b7c3c52742c55a5d09def641df252f682"
integrity sha512-UTlirJkLtGbJurR9PlL4rOZ9HM1G/1/joWItpVwQ0f7j5Alldd7rfCMcy2kd0l2nDZ4LBdd6cFhrMwsEtazCNw==
axe-core@^4.0.2:
version "4.2.3"
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.2.3.tgz#2a3afc332f0031b42f602f4a3de03c211ca98f72"
@ -15064,7 +15059,7 @@ redux-thunk@^2.4.1:
resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.4.1.tgz#0dd8042cf47868f4b29699941de03c9301a75714"
integrity sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==
redux@^4.0.0, redux@^4.1.2, redux@>=4.1.2:
redux@>=4.1.2, redux@^4.0.0, redux@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.1.2.tgz#140f35426d99bb4729af760afcf79eaaac407104"
integrity sha512-SH8PglcebESbd/shgf6mii6EIoRM0zrQyjcuQ+ojmfxjTtE0z9Y8pa62iA/OJ58qjP6j27uyW4kUF4jl/jd6sw==