Skip to content

Commit

Permalink
Merge pull request #411 from ourzora/replace-zora-renderer
Browse files Browse the repository at this point in the history
Replace zora renderer on indexer
  • Loading branch information
neokry authored Nov 23, 2023
2 parents 7a19998 + c3b494b commit 7f7dd49
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 15 deletions.
3 changes: 2 additions & 1 deletion apps/subgraph/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/build
/generated
/data
.env
.env
subgraph.yaml
7 changes: 7 additions & 0 deletions apps/subgraph/config/base-goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "base-goerli",
"manager": {
"address": "0x550c326d688fD51ae65AC6A2d48749E631023A03",
"startBlock": 6585050
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "base",
"manager": {
"address": "0x3ac0e64fe2931f8e082c6bb29283540de9b5371c",
"startBlock": 1991500
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "goerli",
"manager": {
"address": "0x0E9F3382Cf2508E3bc83248B5b4707FbA86D7Ee0",
"startBlock": 7810600
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "mainnet",
"manager": {
"address": "0xd310a3041dfcf14def5ccbc508668974b5da7174",
"startBlock": 15799000
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/optimism-goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "optimism-goerli",
"manager": {
"address": "0x5f9c1e7E31875beAa6ba6B0AB573a4AbEcC95d67",
"startBlock": 11032400
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/optimism.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "optimism",
"manager": {
"address": "0x3ac0E64Fe2931f8e082C6Bb29283540DE9b5371C",
"startBlock": 107290000
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/zora-goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "zora-testnet",
"manager": {
"address": "0xc521f85613985b7e417fccd5b348f64263d79397",
"startBlock": 597700
}
}
7 changes: 7 additions & 0 deletions apps/subgraph/config/zora.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"network": "zora-mainnet",
"manager": {
"address": "0x3ac0E64Fe2931f8e082C6Bb29283540DE9b5371C",
"startBlock": 1778012
}
}
28 changes: 22 additions & 6 deletions apps/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,35 @@
"name": "nouns-builder-subgraph",
"license": "UNLICENSED",
"scripts": {
"clean": "rm -rf ./generated ./build subgraph.yaml",
"local-node": "docker-compose up",
"codegen": "graph codegen",
"build": "pnpm codegen && graph build",
"deploy": "graph deploy --product hosted-service neokry/nouns-builder-goerli",
"create-local": "graph create --node http://localhost:8020/ nouns-builder",
"remove-local": "graph remove --node http://localhost:8020/ nouns-builder",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 --network goerli nouns-builder"
"prepare:goerli": "mustache config/goerli.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:mainnet": "mustache config/mainnet.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:base": "mustache config/base.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:base-goerli": "mustache config/base-goerli.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:optimism": "mustache config/optimism.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:optimism-goerli": "mustache config/optimism-goerli.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:zora": "mustache config/zora.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:zora-goerli": "mustache config/zora-goerli.json subgraph.yaml.mustache > subgraph.yaml",
"deploy:goerli": "pnpm clean && pnpm prepare:goerli && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-goerli-testnet/1.0.2",
"deploy:mainnet": "pnpm clean && pnpm prepare:mainnet && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-ethereum-mainnet/1.0.2",
"deploy:base": "pnpm clean && pnpm prepare:base && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-base-mainnet/1.0.2",
"deploy:base-goerli": "pnpm clean && pnpm prepare:base-goerli && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-base-testnet/1.0.2",
"deploy:optimism": "pnpm clean && pnpm prepare:optimism && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-optimism-mainnet/1.0.2",
"deploy:optimism-goerli": "pnpm clean && pnpm prepare:optimism-goerli && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-optimism-testnet/1.0.2",
"deploy:zora": "pnpm clean && pnpm prepare:zora && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-zora-mainnet/1.0.2",
"deploy:zora-goerli": "pnpm clean && pnpm prepare:zora-goerli && pnpm codegen && graph build && goldsky subgraph deploy nouns-builder-zora-testnet/1.0.2",
"create:local": "graph create --node http://localhost:8020/ nouns-builder",
"remove:local": "graph remove --node http://localhost:8020/ nouns-builder",
"deploy:local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 --network goerli nouns-builder"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.50.1",
"@graphprotocol/graph-ts": "0.30.0"
},
"devDependencies": {
"matchstick-as": "0.5.0"
"matchstick-as": "0.5.0",
"mustache": "^4.2.0"
}
}
9 changes: 8 additions & 1 deletion apps/subgraph/src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ export function handleTransfer(event: TransferEvent): void {
token = new Token(tokenId)

token.name = `${tokenContract.name()} #${event.params.tokenId.toString()}`
token.image = `${metadataContract.rendererBase()}${attributes.value1}`

// Replace zora renderer with our own until a redirect is setup
const rendererBase = metadataContract
.rendererBase()
.replace('https://api.zora.co', 'https://nouns.build/api')

token.image = `${rendererBase}${attributes.value1}`

token.tokenContract = event.address
token.tokenId = event.params.tokenId
token.mintedAt = event.block.timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ schema:
dataSources:
- kind: ethereum
name: Manager
network: goerli
network: {{network}}
source:
abi: Manager
address: '0x0E9F3382Cf2508E3bc83248B5b4707FbA86D7Ee0'
startBlock: 7810600
address: '{{manager.address}}'
startBlock: {{manager.startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -32,7 +32,7 @@ dataSources:
templates:
- kind: ethereum
name: Token
network: goerli
network: {{network}}
source:
abi: Token
mapping:
Expand All @@ -54,7 +54,7 @@ templates:
file: ./src/token.ts
- kind: ethereum
name: Governor
network: goerli
network: {{network}}
source:
abi: Governor
mapping:
Expand Down Expand Up @@ -85,7 +85,7 @@ templates:
file: ./src/governor.ts
- kind: ethereum
name: MetadataRenderer
network: goerli
network: {{network}}
source:
abi: MetadataRenderer
mapping:
Expand All @@ -107,7 +107,7 @@ templates:
file: ./src/metadata.ts
- kind: ethereum
name: Auction
network: goerli
network: {{network}}
source:
abi: Auction
mapping:
Expand Down
1 change: 1 addition & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const nextConfig = {
'zora-dev.mypinata.cloud',
'ipfs.zora.co',
'ipfs.decentralized-content.com',
'nouns.build',
],
},
async redirects() {
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/constants/cacheTimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ export const CACHE_TIMES = {
maxAge: ONE_DAY,
swr: ONE_WEEK,
},
RENDERER: {
maxAge: ONE_DAY,
swr: ONE_WEEK,
},
}
12 changes: 12 additions & 0 deletions apps/web/src/pages/api/renderer/stack-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ import { getFetchableUrl } from 'ipfs-service'
import { NextApiRequest, NextApiResponse } from 'next'
import sharp from 'sharp'

import { CACHE_TIMES } from 'src/constants/cacheTimes'

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const images = req.query.images

if (!images || !images.length)
return res.status(400).json({ error: 'No images provided' })

const { maxAge, swr } = CACHE_TIMES.DAO_FEED

// Handle single image
if (typeof images === 'string') {
const data = await getImageData(images)

res.setHeader(
'Cache-Control',
`public, s-maxage=${maxAge}, stale-while-revalidate=${swr}`
)
res.setHeader('Content-Type', 'image/webp')
return res.send(data)
}
Expand All @@ -30,6 +38,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
.webp({ quality: 100 })
.toBuffer()

res.setHeader(
'Cache-Control',
`public, s-maxage=${maxAge}, stale-while-revalidate=${swr}`
)
res.setHeader('Content-Type', 'image/webp')
res.send(compositeRes)
}
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 comments on commit 7f7dd49

@vercel
Copy link

@vercel vercel bot commented on 7f7dd49 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

testnet-nouns-builder – ./apps/web

testnet-nouns-builder-nouns-builder.vercel.app
testnet-nouns-builder-git-main-nouns-builder.vercel.app
testnet.nouns.build

@vercel
Copy link

@vercel vercel bot commented on 7f7dd49 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.