Skip to content

Commit

Permalink
Remove Cannoli + (#88)
Browse files Browse the repository at this point in the history
* Remove Cannoli +
leave in a good state to add back chains in fture
basic section in readme
abstract out the link to other network

* ignore dynamic type mixup for now

* Apply formatting to readme updates

Co-authored-by: 0xarthurxyz <[email protected]>

* Move adding chains section to root readme
move token data to chain config file

---------

Co-authored-by: Aaron <[email protected]>
Co-authored-by: 0xarthurxyz <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2023
1 parent b38fe86 commit ad95d5f
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 66 deletions.
1 change: 1 addition & 0 deletions apps/web/components/request-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const RequestForm: FC<Props> = ({ isOutOfCELO, network }) => {
/>
<small className={inter.className}> CELO Only</small>
</label>
{/* @ts-ignore */}
<FaucetStatus
network={network}
reset={reset}
Expand Down
59 changes: 5 additions & 54 deletions apps/web/components/setup-button.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { FC } from 'react'
import detectEthereumProvider from '@metamask/detect-provider'
import { useAsyncCallback } from 'react-use-async-callback'
import Image from 'next/image'
import { inter } from 'utils/inter'
import { FC } from 'react'
import { useAsyncCallback } from 'react-use-async-callback'
import { CHAIN_PARAMS, tokens } from '../config/chains'
import styles from 'styles/Home.module.css'
import { Network, ChainId } from 'types'
import { ChainId, Network } from 'types'
import { inter } from 'utils/inter'

interface Props {
network: Network
Expand Down Expand Up @@ -69,37 +70,6 @@ function delay(time: number) {
return new Promise((resolve) => setTimeout(resolve, time))
}

const tokens = {
alfajores: [
{
symbol: 'cEUR',
address: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
},
{
symbol: 'cREAL',
address: '0xE4D517785D091D3c54818832dB6094bcc2744545',
},
{
symbol: 'cUSD',
address: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
},
],
cannoli: [
{
symbol: 'cEUR',
address: '0x6ede0baedEb76CdF45B40f79bb466759B9EfF1a0',
},
{
symbol: 'cREAL',
address: '0xAa6ba7cFB47C2FC36Cc842eEf67889519ebEF9a7',
},
{
symbol: 'cUSD',
address: '0x2Bece2F1e31237085A0da4BB12F091D38d832431',
},
],
}

interface TokenParams {
type: 'ERC20'
options: {
Expand Down Expand Up @@ -143,22 +113,3 @@ interface EthProvider {
): this
removeAllListeners(event?: string | symbol): this
}

const CHAIN_PARAMS = {
alfajores: {
chainId: '0xaef3',
chainName: 'Alfajores Testnet',
nativeCurrency: { name: 'Alfajores Celo', symbol: 'A-CELO', decimals: 18 },
rpcUrls: ['https://alfajores-forno.celo-testnet.org'],
blockExplorerUrls: ['https://explorer.celo.org/alfajores'],
iconUrls: ['future'],
},
cannoli: {
chainId: '0x43ab',
chainName: 'Cannoli Testnet',
nativeCurrency: { name: 'Cannoli Celo', symbol: 'C-CELO', decimals: 18 },
rpcUrls: ['https://forno.cannoli.celo-testnet.org'],
blockExplorerUrls: ['https://explorer.celo.org/cannoli'],
iconUrls: ['future'],
},
}
47 changes: 47 additions & 0 deletions apps/web/config/chains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Network } from 'types'

interface ChainParams {
chainId: `0x${string}`
chainName: string
nativeCurrency: {
name: string
symbol: string
decimals: number
}
rpcUrls: string[]
blockExplorerUrls: string[]
iconUrls: string[]
}

export const CHAIN_PARAMS: Record<Network, ChainParams> = {
alfajores: {
chainId: '0xaef3',
chainName: 'Alfajores Testnet',
nativeCurrency: { name: 'Alfajores Celo', symbol: 'A-CELO', decimals: 18 },
rpcUrls: ['https://alfajores-forno.celo-testnet.org'],
blockExplorerUrls: ['https://explorer.celo.org/alfajores'],
iconUrls: ['future'],
},
}

interface Token {
symbol: string
address: `0x${string}`
}

export const tokens: Record<Network, Token[]> = {
alfajores: [
{
symbol: 'cEUR',
address: '0x10c892A6EC43a53E45D0B916B4b7D383B1b78C0F',
},
{
symbol: 'cREAL',
address: '0xE4D517785D091D3c54818832dB6094bcc2744545',
},
{
symbol: 'cUSD',
address: '0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1',
},
],
}
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"setup": "vercel env pull",
"dev": "next dev",
"build": "next build",
"start": "next start",
Expand Down
11 changes: 7 additions & 4 deletions apps/web/pages/[chain].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ interface Props {
const Home: NextPage<Props> = ({ isOutOfCELO, network }: Props) => {
const networkCapitalized = capitalize(network)

const otherNetwork = network === 'alfajores' ? 'cannoli' : 'alfajores'
const otherNetwork =
networks.indexOf(network) === 0 ? networks[1] : networks[0]
return (
<>
<Head>
Expand All @@ -36,9 +37,11 @@ const Home: NextPage<Props> = ({ isOutOfCELO, network }: Props) => {
<h1 className={`${inter.className} ${styles.title}`}>
{networkCapitalized} Token Faucet
</h1>
<Link className={styles.switchNetwork} href={`/${otherNetwork}`}>
Switch to {capitalize(otherNetwork)}
</Link>
{networks.length > 1 && (
<Link className={styles.switchNetwork} href={`/${otherNetwork}`}>
Switch to {capitalize(otherNetwork)}
</Link>
)}
</header>
<div className={styles.center}>
<RequestForm network={network} isOutOfCELO={isOutOfCELO} />
Expand Down
6 changes: 2 additions & 4 deletions apps/web/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
export type Address = string
export type E164Number = string

export const networks = ['alfajores', 'cannoli']
export type Network = 'alfajores' | 'cannoli'
export const networks = ['alfajores']
export type Network = 'alfajores'

export enum FaucetAddress {
alfajores = '0x22579CA45eE22E2E16dDF72D955D6cf4c767B0eF',
cannoli = '0x29954EC661f0c829587ac4527825B7E8C663d0b6',
}

export enum ChainId {
alfajores = 44787,
cannoli = 17323,
}

export enum RequestStatus {
Expand Down
17 changes: 13 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@

# Welcome to Alfajores Faucet app

This Repo contains the code for the alfajores faucet. This is contained in 2 apps.

* The firebase app contains functions which do the actual fauceting.
- The firebase app contains functions which do the actual fauceting.

* The web app contains a UI for making requests.
- The web app contains a UI for making requests.

The web app deploys automatically to vercel.

To setup the web app to run locally set the vercel project to clabs/faucet and the env variables from vercel with `vercel env pull` then run `yarn dev`
To setup the web app to run locally set the vercel project to clabs/faucet and the env variables from vercel with `vercel env pull` then run `yarn dev`

## Adding chains

### Web

- Add the chain config and token info to `config/chains.ts`.

- Add chain name to the networks array, and `ChainId` and `FaucetAddress` to enums in `types/index.ts`.

### Firebase

In the `apps/firebase` project run `yarn cli config:set` with the relevant params.

1 comment on commit ad95d5f

@vercel
Copy link

@vercel vercel bot commented on ad95d5f Oct 31, 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.