Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions handlebars/react/packages/react-app/src/App.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import React from "react";
import logo from "./ethereumLogo.png";
import { Contract } from "@ethersproject/contracts";
import { getDefaultProvider } from "@ethersproject/providers";
import { gql } from "apollo-boost";
import { useQuery } from "@apollo/react-hooks";
{{#each imports}}
{{{ this }}}
{{/each}}
import "./App.css";

{{#each graphqlQuery }}
{{{ this }}}
{{/each}}

async function readOnChainData() {
{{#each readOnChainData}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,12 @@
</template>

<script>
import gql from "graphql-tag";
import { Contract } from "@ethersproject/contracts";
import { getDefaultProvider } from "@ethersproject/providers";
{{#each imports}}
{{{ this }}}
{{/each}}

{{#each graphqlQuery }}
{{{ this }}}
{{/each}}

export default {
methods: {
readOnchainData: async function () {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const standardFiles: Record<FrameworkKey, string[]> = {
"packages/react-app/README.md",
"packages/react-app/src/index.js",
"packages/react-app/src/App.js",
"packages/react-app/src/graphql/subgraph.js",
],
vue: [
"package.json",
Expand All @@ -35,6 +36,7 @@ export const standardFiles: Record<FrameworkKey, string[]> = {
"packages/vue-app/README.md",
"packages/vue-app/src/main.js",
"packages/vue-app/src/components/HelloWorld.vue",
"packages/vue-app/src/graphql/subgraph.js",
],
};

Expand Down
17 changes: 2 additions & 15 deletions templates/react/aave/packages/react-app/src/App.js.ctx
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
{
"callToAction": "Read On-Chain Balance",
"graphqlQuery": [
"const GET_LENDING_POOL_CONFIGURATION_HISTORY_ITEMS = gql`",
" {",
" lendingPoolConfigurationHistoryItems(first: 5) {",
" id",
" provider {",
" id",
" }",
" lendingPool",
" lendingPoolCore",
" }",
" }",
"`;"
],
"graphqlQueryName": "GET_LENDING_POOL_CONFIGURATION_HISTORY_ITEMS",
"imports": [
"import { MAINNET_ID, addresses, abis } from \"@aave-app/contracts\";"
"import { MAINNET_ID, addresses, abis } from \"@aave-app/contracts\";",
"import GET_LENDING_POOL_CONFIGURATION_HISTORY_ITEMS from \"./graphql/subgraph\";"
],
"hooks": {
"readData": [
Expand Down
17 changes: 17 additions & 0 deletions templates/react/aave/packages/react-app/src/graphql/subgraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { gql } from "apollo-boost";

// See more example queries on https://thegraph.com/explorer/subgraph/aave/protocol
const GET_LENDING_POOL_CONFIGURATION_HISTORY_ITEMS = gql`
{
lendingPoolConfigurationHistoryItems(first: 5) {
id
provider {
id
}
lendingPool
lendingPoolCore
}
}
`;

export default GET_LENDING_POOL_CONFIGURATION_HISTORY_ITEMS;
29 changes: 2 additions & 27 deletions templates/react/compound/packages/react-app/src/App.js.ctx
Original file line number Diff line number Diff line change
@@ -1,31 +1,5 @@
{
"callToAction": "Read On-Chain Balance",
"graphqlQuery": [
"const GET_MONEY_MARKETS = gql`",
" {",
" markets(first: 7) {",
" borrowRate",
" cash",
" collateralFactor",
" exchangeRate",
" interestRateModelAddress",
" name",
" reserves",
" supplyRate",
" symbol",
" id",
" totalBorrows",
" totalSupply",
" underlyingAddress",
" underlyingName",
" underlyingPrice",
" underlyingSymbol",
" reserveFactor",
" underlyingPriceUSD",
" }",
" }",
"`;"
],
"graphqlQueryName": "GET_MONEY_MARKETS",
"hooks": {
"readData": [
Expand All @@ -35,7 +9,8 @@
]
},
"imports": [
"import { MAINNET_ID, addresses, abis } from \"@compound-app/contracts\";"
"import { MAINNET_ID, addresses, abis } from \"@compound-app/contracts\";",
"import GET_MONEY_MARKETS from \"./graphql/subgraph\";"
],
"learnUrl": "https://compound.finance/developers",
"readOnChainData": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { gql } from "apollo-boost";

// See more example queries on https://thegraph.com/explorer/subgraph/graphprotocol/compound-v2
const GET_MONEY_MARKETS = gql`
{
markets(first: 7) {
borrowRate
cash
collateralFactor
exchangeRate
interestRateModelAddress
name
reserves
supplyRate
symbol
id
totalBorrows
totalSupply
underlyingAddress
underlyingName
underlyingPrice
underlyingSymbol
reserveFactor
underlyingPriceUSD
}
}
`;

export default GET_MONEY_MARKETS;
15 changes: 2 additions & 13 deletions templates/react/default/packages/react-app/src/App.js.ctx
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
{
"callToAction": "Read On-Chain Balance",
"graphqlQuery": [
"const GET_TRANSFERS = gql`",
" {",
" transfers(first: 10) {",
" id",
" from",
" to",
" value",
" }",
" }",
"`;"
],
"graphqlQueryName": "GET_TRANSFERS",
"hooks": {
"readData": [
Expand All @@ -21,7 +9,8 @@
]
},
"imports": [
"import { addresses, abis } from \"@project/contracts\";"
"import { addresses, abis } from \"@project/contracts\";",
"import GET_TRANSFERS from \"./graphql/subgraph\";"
],
"learnUrl": "https://thegraph.com/docs/quick-start",
"readOnChainData": [
Expand Down
15 changes: 15 additions & 0 deletions templates/react/default/packages/react-app/src/graphql/subgraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { gql } from "apollo-boost";

// See more example queries on https://thegraph.com/explorer/subgraph/paulrberg/create-eth-app
const GET_TRANSFERS = gql`
{
transfers(first: 10) {
id
from
to
value
}
}
`;

export default GET_TRANSFERS;
21 changes: 2 additions & 19 deletions templates/react/kyber/packages/react-app/src/App.js.ctx
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
{
"callToAction": "Read On-Chain Exchange Rates",
"graphqlQuery": [
"const GET_FULL_TRADES = gql`",
" {",
" fullTrades(first: 5) {",
" id",
" trader {",
" id",
" }",
" src {",
" id",
" }",
" dest {",
" id",
" }",
" }",
" }",
"`;"
],
"graphqlQueryName": "GET_FULL_TRADES",
"hooks": {
"readData": [
Expand All @@ -27,7 +9,8 @@
]
},
"imports": [
"import { MAINNET_ID, addresses, abis } from \"@kyber-app/contracts\";"
"import { MAINNET_ID, addresses, abis } from \"@kyber-app/contracts\";",
"import GET_FULL_TRADES from \"./graphql/subgraph\";"
],
"learnUrl": "https://developer.kyber.network/",
"readOnChainData": [
Expand Down
21 changes: 21 additions & 0 deletions templates/react/kyber/packages/react-app/src/graphql/subgraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { gql } from "apollo-boost";

// See more example queries on https://thegraph.com/explorer/subgraph/protofire/kyber
const GET_FULL_TRADES = gql`
{
fullTrades(first: 5) {
id
trader {
id
}
src {
id
}
dest {
id
}
}
}
`;

export default GET_FULL_TRADES;
24 changes: 2 additions & 22 deletions templates/react/maker/packages/react-app/src/App.js.ctx
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
{
"callToAction": "Read On-Chain Collateral Information",
"graphqlQuery": [
"const GET_COLLATERAL_TYPES = gql`",
" {",
" collateralTypes(orderBy: addedAt) {",
" name: id",
" price {",
" block",
" value",
" }",
" debtCeiling",
" totalDebt",
" liquidationLotSize",
" liquidationPenalty",
" liquidationRatio",
" stabilityFee",
" auctionCount",
" vaultCount",
" }",
" }",
"`;"
],
"graphqlQueryName": "GET_COLLATERAL_TYPES",
"imports": [
"import { MAINNET_ID, addresses, abis } from \"@maker-app/contracts\";"
"import { MAINNET_ID, addresses, abis } from \"@maker-app/contracts\";",
"import GET_COLLATERAL_TYPES from \"./graphql/subgraph\";"
],
"hooks": {
"readData": [
Expand Down
24 changes: 24 additions & 0 deletions templates/react/maker/packages/react-app/src/graphql/subgraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { gql } from "apollo-boost";

// See more example queries on https://thegraph.com/explorer/subgraph/protofire/maker-protocol
const GET_COLLATERAL_TYPES = gql`
{
collateralTypes(orderBy: addedAt) {
name: id
price {
block
value
}
debtCeiling
totalDebt
liquidationLotSize
liquidationPenalty
liquidationRatio
stabilityFee
auctionCount
vaultCount
}
}
`;

export default GET_COLLATERAL_TYPES;
46 changes: 2 additions & 44 deletions templates/react/sablier-v1/packages/react-app/src/App.js.ctx
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
{
"callToAction": "Read On-Chain Data",
"graphqlQuery": [
"const GET_STREAMS = gql`",
" {",
" streams(first: 10, orderBy: timestamp, orderDirection: desc) {",
" id",
" cancellation {",
" recipientBalance",
" recipientInterest",
" timestamp",
" txhash",
" }",
" deposit",
" exchangeRateInitial",
" ratePerSecond",
" recipient",
" recipientSharePercentage",
" sender",
" senderSharePercentage",
" startTime",
" stopTime",
" timestamp",
" token {",
" id",
" decimals",
" name",
" symbol",
" }",
" txs {",
" id",
" block",
" event",
" from",
" timestamp",
" to",
" }",
" withdrawals {",
" id",
" amount",
" }",
" }",
" }",
"`;"
],
"graphqlQueryName": "GET_STREAMS",
"hooks": {
"readData": [
Expand All @@ -52,7 +9,8 @@
]
},
"imports": [
"import { MAINNET_ID, addresses, abis } from \"@sablier-v1-app/contracts\";"
"import { MAINNET_ID, addresses, abis } from \"@sablier-v1-app/contracts\";",
"import GET_STREAMS from \"./graphql/subgraph\";"
],
"learnUrl": "https://docs.sablier.finance/",
"readOnChainData": [
Expand Down
Loading