Skip to content

Commit

Permalink
Merge branch 'main' into remove-ethers
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed May 10, 2024
2 parents e9b60e0 + cf88f47 commit 8ea0a6b
Show file tree
Hide file tree
Showing 33 changed files with 2,238 additions and 812 deletions.
65 changes: 32 additions & 33 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["typescript", "typescriptreact"],
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/node_modules": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["typescript", "typescriptreact"],
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/node_modules": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Add the following variables to `apps/web/.env.local`:

```
#alchemy
NEXT_PUBLIC_ALCHEMY_ID=<ALCHEMY_API_KEY>
NEXT_PUBLIC_TENDERLY_RPC_KEY=<ALCHEMY_API_KEY>
#tenderly
Expand Down
3 changes: 1 addition & 2 deletions apps/web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

NEXT_PUBLIC_UPLOAD_API=https://upload-api.zora.co
NEXT_PUBLIC_IPFS_GATEWAY=https://ipfs.decentralized-content.com
NEXT_PUBLIC_CHAIN_ID=5
NEXT_PUBLIC_NETWORK_TYPE=mainnet
NEXT_PUBLIC_NETWORK_TYPE=testnet
10 changes: 5 additions & 5 deletions apps/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Nouns Builder currently only supports two networks: `mainnet` and `goerli testne
You can swap out the environment variables as defined below to run against mainnnet or testnet locally.

```
# the default chain id defined in .env, to run against testnet
NEXT_PUBLIC_ALCHEMY_ID=<TESTNET_ALCHEMY_API_KEY>
NEXT_PUBLIC_CHAIN_ID=5
# the default network type is defined in .env, to run against testnet
NEXT_PUBLIC_TENDERLY_RPC_KEY=<TENDERLY_RPC_API_KEY>
NEXT_PUBLIC_NETWORK_TYPE="testnet"
# to run against mainnet locally
NEXT_PUBLIC_ALCHEMY_ID=<MAINNET_ALCHEMY_API_KEY>
NEXT_PUBLIC_CHAIN_ID=1
NEXT_PUBLIC_TENDERLY_RPC_KEY=<TENDERLY_RPC_API_KEY>
NEXT_PUBLIC_NETWORK_TYPE="mainnet"
```

### Writing Tests
Expand Down
1 change: 1 addition & 0 deletions apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
14 changes: 8 additions & 6 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@fontsource/inter": "4.5.10",
"@fontsource/londrina-solid": "^4.5.9",
"@rainbow-me/rainbowkit": "^1.3.1",
"@sentry/nextjs": "^7.15.0",
"@sentry/nextjs": "^7.105.0",
"@types/lodash": "^4.14.186",
"@types/react-portal": "^4.0.4",
"@types/tinycolor2": "^1.4.3",
Expand All @@ -36,28 +36,30 @@
"flatpickr": "^4.6.13",
"formik": "^2.2.9",
"framer-motion": "^6.3.3",
"frog": "^0.5.5",
"graphql": "^16.6.0",
"graphql-request": "^4.3.0",
"graphql-tag": "^2.12.6",
"hono": "^4.0.9",
"html-react-parser": "^3.0.9",
"ioredis": "^5.2.3",
"ipfs-http-client": "^59.0.0",
"ipfs-service": "workspace:*",
"lanyard": "^1.1.2",
"lodash": "^4.17.21",
"multiformats": "9.9.0",
"next": "^13.0.3",
"next": "^14.1.2",
"nextjs-progressbar": "^0.0.16",
"raw-loader": "^4.0.2",
"react": "^18.2.0",
"react-content-loader": "^6.0.2",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.5",
"react-markdown": "^9.0.1",
"react-mde": "^11.5.0",
"react-portal": "^4.2.2",
"rehype-raw": "^6.1.1",
"rehype-sanitize": "^5.0.1",
"remark-gfm": "^3.0.1",
"rehype-raw": "^7.0.0",
"rehype-sanitize": "^6.0.0",
"remark-gfm": "^4.0.0",
"sharp": "^0.32.6",
"swr": "^1.3.0",
"tinycolor2": "^1.4.2",
Expand Down
113 changes: 113 additions & 0 deletions apps/web/src/app/api/frames/[[...routes]]/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/** @jsxImportSource frog/jsx */
import { Frog } from 'frog'
import { handle } from 'frog/next'
import { isAddress, parseEther } from 'viem'

import { auctionAbi, governorAbi } from 'src/data/contract/abis'
import { AddressType, BytesType, CHAIN_ID } from 'src/typings'

const app = new Frog({
basePath: '/api/frames',
})

app.transaction('/bid', async (c) => {
try {
const { inputText, req } = c
const { chainId, auctionContract, tokenId, amount, referral } = req.query()

if (!tokenId) return new Response('Invalid tokenId', { status: 400 })

const tokenIdParsed = BigInt(tokenId)
const chainIdParsed = parseInt(chainId)

let bidAmount: bigint | undefined

if (amount) bidAmount = parseEther(amount)
else if (inputText) bidAmount = parseEther(inputText)

if (!bidAmount) return new Response('Invalid bid amount', { status: 400 })

if (
chainIdParsed !== CHAIN_ID.OPTIMISM &&
chainIdParsed !== CHAIN_ID.ZORA &&
chainIdParsed !== CHAIN_ID.BASE
)
return new Response('Invalid chain id', { status: 400 })

const contract = {
abi: auctionAbi,
chainId: `eip155:${chainIdParsed}`,
to: auctionContract as AddressType,
} as const

if (referral) {
if (!isAddress(referral)) return new Response('Invalid referral', { status: 400 })

return c.contract({
...contract,
functionName: 'createBidWithReferral',
value: bidAmount,
args: [tokenIdParsed, referral as AddressType],
})
}

return c.contract({
...contract,
functionName: 'createBid',
value: bidAmount,
args: [tokenIdParsed],
})
} catch (err) {
return new Response((err as Error).message, { status: 500 })
}
})

app.transaction('/vote', async (c) => {
try {
const { inputText, req } = c
const { chainId, governorContract, support, proposalId, reason } = req.query()
const chainIdParsed = parseInt(chainId)

let reasonText
if (reason) reasonText = reason
else if (inputText) reasonText = inputText

const supportParsed = BigInt(support)

// 0 = Against, 1 = For, 2 = Abstain
if (supportParsed !== 0n && supportParsed !== 1n && supportParsed !== 2n)
return new Response('Invalid support value', { status: 400 })

if (
chainIdParsed !== CHAIN_ID.OPTIMISM &&
chainIdParsed !== CHAIN_ID.ZORA &&
chainIdParsed !== CHAIN_ID.BASE
)
return new Response('Invalid chain id', { status: 400 })

const contract = {
abi: governorAbi,
chainId: `eip155:${chainIdParsed}`,
to: governorContract as AddressType,
} as const

if (reasonText) {
return c.contract({
...contract,
functionName: 'castVoteWithReason',
args: [proposalId as BytesType, supportParsed, reasonText],
})
}

return c.contract({
...contract,
functionName: 'castVote',
args: [proposalId as BytesType, supportParsed],
})
} catch (err) {
return new Response((err as Error).message, { status: 500 })
}
})

export const GET = handle(app)
export const POST = handle(app)
3 changes: 3 additions & 0 deletions apps/web/src/components/Icon/assets/share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/web/src/components/Icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Play from './assets/play.svg'
import Plus from './assets/plus.svg'
import Refresh from './assets/refresh.svg'
import ResumeTemplate from './assets/resume-template.svg'
import Share from './assets/share.svg'
import Trash from './assets/trash.svg'
import Twitter from './assets/twitter.svg'
import Warning16 from './assets/warning-16.svg'
Expand Down Expand Up @@ -80,6 +81,7 @@ export const icons = {
resumeTemplate: ResumeTemplate,
trash: Trash,
twitter: Twitter,
share: Share,
warning: Warning,
'warning-16': Warning16,
}
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ export const L1_CROSS_DOMAIN_MESSENGER = {
export const ALLOWED_MIGRATION_DAOS: AddressType[] = [
'0xf3b8f2ef0933f601c2cceada242fc3948a6ba757',
'0xc0a2527d25ad9c7dee3f47e3497ca0093def26bc',
'0xa45662638e9f3bbb7a6fecb4b17853b7ba0f3a60',
'0x96e396e66087b2b9dcad36fd473e1b049df18998',
'0xdf9b7d26c8fc806b1ae6273684556761ff02d422',
'0x795D300855069F602862c5e23814Bdeeb25DCa6b',
]
11 changes: 6 additions & 5 deletions apps/web/src/constants/etherscan.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { CHAIN_ID } from 'src/typings'

// URLs should not include a trailing forward slash
export const ETHERSCAN_BASE_URL = {
[CHAIN_ID.ETHEREUM]: 'https://etherscan.io',
[CHAIN_ID.OPTIMISM]: 'https://optimistic.etherscan.io',
[CHAIN_ID.SEPOLIA]: 'https://sepolia.etherscan.io',
[CHAIN_ID.OPTIMISM_SEPOLIA]: 'https://sepolia-optimism.etherscan.io/',
[CHAIN_ID.BASE]: 'https://basescan.org/',
[CHAIN_ID.BASE_SEPOLIA]: 'https://sepolia.basescan.org/',
[CHAIN_ID.ZORA]: 'https://explorer.zora.energy/',
[CHAIN_ID.ZORA_SEPOLIA]: 'https://sepolia.explorer.zora.energy/',
[CHAIN_ID.OPTIMISM_SEPOLIA]: 'https://sepolia-optimism.etherscan.io',
[CHAIN_ID.BASE]: 'https://basescan.org',
[CHAIN_ID.BASE_SEPOLIA]: 'https://sepolia.basescan.org',
[CHAIN_ID.ZORA]: 'https://explorer.zora.energy',
[CHAIN_ID.ZORA_SEPOLIA]: 'https://sepolia.explorer.zora.energy',
[CHAIN_ID.FOUNDRY]: '',
}
12 changes: 6 additions & 6 deletions apps/web/src/constants/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { foundry } from 'wagmi/chains'
import { CHAIN_ID } from 'src/typings'

export const RPC_URL = {
[CHAIN_ID.ETHEREUM]: `https://eth-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`,
[CHAIN_ID.OPTIMISM]: `https://opt-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`,
[CHAIN_ID.SEPOLIA]: `https://eth-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`,
[CHAIN_ID.OPTIMISM_SEPOLIA]: `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`,
[CHAIN_ID.BASE]: `https://hardworking-wild-arm.base-mainnet.discover.quiknode.pro/${process.env.NEXT_PUBLIC_QUICKNODE_ID}`,
[CHAIN_ID.BASE_SEPOLIA]: 'https://sepolia.base.org',
[CHAIN_ID.ETHEREUM]: ` https://mainnet.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`,
[CHAIN_ID.OPTIMISM]: `https://optimism.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`,
[CHAIN_ID.SEPOLIA]: ` https://sepolia.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`,
[CHAIN_ID.OPTIMISM_SEPOLIA]: `https://optimism-sepolia.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`,
[CHAIN_ID.BASE]: `https://base.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`,
[CHAIN_ID.BASE_SEPOLIA]: `https://base-sepolia.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_RPC_KEY}`,
[CHAIN_ID.ZORA]: 'https://rpc.zora.energy',
[CHAIN_ID.ZORA_SEPOLIA]: 'https://sepolia.rpc.zora.energy',
[CHAIN_ID.FOUNDRY]: foundry.rpcUrls.default.http[0],
Expand Down
4 changes: 0 additions & 4 deletions apps/web/src/data/contract/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
zora,
zoraSepolia,
} from 'wagmi/chains'
import { alchemyProvider } from 'wagmi/providers/alchemy'
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc'

import { PUBLIC_IS_TESTNET } from 'src/constants/defaultChains'
Expand All @@ -29,9 +28,6 @@ export const L2_CHAINS = PUBLIC_IS_TESTNET
const { chains, publicClient } = configureChains(
[...TESTNET_CHAINS, ...MAINNET_CHAINS],
[
alchemyProvider({
apiKey: process.env.NEXT_PUBLIC_ALCHEMY_ID as string,
}),
jsonRpcProvider({
rpc: (chain) => ({
http: RPC_URL[chain.id as CHAIN_ID],
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/data/subgraph/requests/daoMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const encodedDaoMetadataRequest = async (
if (!L1_CHAINS.find((x) => x === chain)) throw new Error('Only L1 Chains are supported')

const res = await SDK.connect(chain)
.daoMetadata({ tokenAddress, first: 1000 })
.daoMetadata({ tokenAddress: tokenAddress.toLowerCase(), first: 1000 })
.then((x) => x.dao?.metadataProperties)

if (!res) throw new Error('No metadata found')
Expand Down
14 changes: 13 additions & 1 deletion apps/web/src/hooks/useDelayedGovernance.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useContractRead } from 'wagmi'

import { governorAbi } from 'src/data/contract/abis'
import { governorAbi, tokenAbi } from 'src/data/contract/abis'
import { AddressType, CHAIN_ID } from 'src/typings'

export const useDelayedGovernance = ({
tokenAddress,
governorAddress,
chainId,
}: {
tokenAddress?: AddressType
governorAddress?: AddressType
chainId: CHAIN_ID
}) => {
Expand All @@ -17,6 +19,16 @@ export const useDelayedGovernance = ({
functionName: 'delayedGovernanceExpirationTimestamp',
})

const { data: remainingTokensInReserve } = useContractRead({
abi: tokenAbi,
address: tokenAddress,
chainId,
functionName: 'remainingTokensInReserve',
})

if (remainingTokensInReserve === 0n)
return { delayedUntilTimestamp: 0, isGovernanceDelayed: false }

const isGovernanceDelayed = delayedUntilTimestamp
? new Date().getTime() < Number(delayedUntilTimestamp) * 1000
: false
Expand Down
Loading

0 comments on commit 8ea0a6b

Please sign in to comment.