Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Testnet Rewards Section in Astral Explorer #850

Merged
merged 68 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
289716d
add testnet-rewards route
marc-aurele-besner Sep 1, 2024
aad29eb
add the testnet icons pack
marc-aurele-besner Sep 1, 2024
2feb021
add header with no links
marc-aurele-besner Sep 1, 2024
b779803
add dummy FAQ components
marc-aurele-besner Sep 1, 2024
2e0b160
add static reward history
marc-aurele-besner Sep 1, 2024
bc18700
add base page component
marc-aurele-besner Sep 1, 2024
be50a53
add rewards tables static mock data
marc-aurele-besner Sep 1, 2024
54c3097
add testnetRewards squid and query
marc-aurele-besner Sep 3, 2024
0329cd7
add ga events
marc-aurele-besner Sep 4, 2024
1ad1d61
add new section in header
marc-aurele-besner Sep 4, 2024
50fea6b
add some of the db logic (wip)
marc-aurele-besner Sep 4, 2024
83f67eb
update testnet icons
marc-aurele-besner Sep 5, 2024
dcd4a91
improve dark theme
marc-aurele-besner Sep 5, 2024
fa62db6
Merge branch 'main' into ft/addTestnetRewards
marc-aurele-besner Sep 19, 2024
4267035
fix connect wallet on rewards history
marc-aurele-besner Sep 19, 2024
98cf2f7
improve reward history block to support multiple wallets selection
marc-aurele-besner Sep 19, 2024
e212625
add account name and improve memoization in RewardsHistory component
marc-aurele-besner Sep 19, 2024
7427945
adjust testnet rewards table to fit more with ux/ui
marc-aurele-besner Sep 19, 2024
d2104fb
adding previous data and fixing issue with previous rewards account
marc-aurele-besner Sep 19, 2024
c9228fb
Merge branch 'feat/migrate-to-sub-query' into ft/addTestnetRewards
marc-aurele-besner Sep 19, 2024
be3d539
improve docker setup
marc-aurele-besner Sep 19, 2024
ef757d0
improve docker setup with profile
marc-aurele-besner Sep 19, 2024
6bc7e1f
remove inexistent service from docker compose prod
marc-aurele-besner Sep 19, 2024
24f36a0
Merge branch 'feat/improve-docker-compose' into ft/addTestnetRewards
marc-aurele-besner Sep 19, 2024
5070313
fix bad merge
marc-aurele-besner Sep 19, 2024
dbb7a09
Merge branch 'feat/improve-docker-compose' into ft/addTestnetRewards
marc-aurele-besner Sep 19, 2024
32941d8
remove unneded env
marc-aurele-besner Sep 19, 2024
c713a05
Merge branch 'feat/improve-docker-compose' into ft/addTestnetRewards
marc-aurele-besner Sep 19, 2024
c96aef4
cleanup mapping and project
marc-aurele-besner Sep 19, 2024
bc4ac8c
expose console command and centralize env
marc-aurele-besner Sep 19, 2024
9207660
remove extra mapping
marc-aurele-besner Sep 19, 2024
14bb12c
improve consensus mapping package script and docker setup
marc-aurele-besner Sep 20, 2024
64b6b32
remove old typegen
marc-aurele-besner Sep 20, 2024
dcb6bc1
improve consensus sub query utils and helper mapping
marc-aurele-besner Sep 20, 2024
29ee3a8
improve consensus sub query mapping logic
marc-aurele-besner Sep 20, 2024
f2417be
improve schema
marc-aurele-besner Sep 20, 2024
6ad6f5d
remove account logic from consensus sub query
marc-aurele-besner Sep 20, 2024
b1fc540
improve consensus metadata
marc-aurele-besner Sep 21, 2024
1c44d6a
Merge branch 'main' into ft/addTestnetRewards
marc-aurele-besner Sep 25, 2024
66414ca
add some of the testnet rewards csv
marc-aurele-besner Sep 25, 2024
72102b8
improve testnet rewards
marc-aurele-besner Sep 25, 2024
3fd1614
Merge branch 'main' into ft/addTestnetRewards
marc-aurele-besner Sep 25, 2024
9019033
fix build error
marc-aurele-besner Sep 25, 2024
82ba246
improve consistency for number precision
marc-aurele-besner Sep 25, 2024
a7015b5
fix most date ranges
marc-aurele-besner Sep 30, 2024
2aa7f68
add question/answers to FAQ
marc-aurele-besner Sep 30, 2024
5903f46
fix stake wars 1 portionOfMainnet
marc-aurele-besner Sep 30, 2024
7dd4ef4
hide how it's calculated for now
marc-aurele-besner Sep 30, 2024
3efcfd1
remove testnet reward squid
marc-aurele-besner Oct 8, 2024
fcc39f6
update testnet rewards
marc-aurele-besner Oct 10, 2024
6ffa12f
fix stake wars 1 phased date
marc-aurele-besner Oct 10, 2024
6c7634b
simplify logic and remove log
marc-aurele-besner Oct 10, 2024
96a44ae
update csv with missing stake wars address and remove unused columns
marc-aurele-besner Oct 10, 2024
f6d211d
update logic
marc-aurele-besner Oct 10, 2024
d61cd95
Merge branch 'main' into ft/addTestnetRewards
marc-aurele-besner Oct 10, 2024
5818bda
fix label
marc-aurele-besner Oct 10, 2024
933d6b9
fix bad merge issue
marc-aurele-besner Oct 10, 2024
4cd33dd
add total alloc per phase
marc-aurele-besner Oct 10, 2024
ea69284
fix data (missing gemini 2 phase 2)
marc-aurele-besner Oct 10, 2024
ef499ee
move table before FAQ
marc-aurele-besner Oct 10, 2024
d2007a6
improve UX
marc-aurele-besner Oct 10, 2024
16f5529
add open graph image for testnet rewards page
marc-aurele-besner Oct 10, 2024
68aa7e2
fix reduce bug by using deep copy
marc-aurele-besner Oct 10, 2024
c50a6c2
add Aries Stress Test
marc-aurele-besner Oct 10, 2024
9a793a2
improve date formatting and number formatting
marc-aurele-besner Oct 11, 2024
f059d30
update rewards (aries)
marc-aurele-besner Oct 11, 2024
459d6ca
update csv for fix gemini1 and gemini2 sheet and improve precision
marc-aurele-besner Oct 12, 2024
c0d5522
Merge branch 'main' into ft/addTestnetRewards
marc-aurele-besner Oct 13, 2024
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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ REDIS_PORT=6379

BULL_USERNAME=bull
BULL_PASSWORD=board
BULL_PORT=3020
BULL_PORT=3020
8,251 changes: 8,251 additions & 0 deletions explorer/public/data/gemini-3f-rewards.csv

Large diffs are not rendered by default.

141,558 changes: 141,558 additions & 0 deletions explorer/public/data/rewards.csv

Large diffs are not rendered by default.

108,403 changes: 108,403 additions & 0 deletions explorer/public/data/testnet/astralTestnetRewardsMainnetAllocations-12oct2024.csv

Large diffs are not rendered by default.

Binary file added explorer/public/images/share-testnet-rewards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions explorer/src/app/[chain]/testnet-rewards/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { EmptyHeader } from 'components/layout/EmptyHeader'
import { MainLayout } from 'components/layout/Layout'
import type { ChildrenPageProps } from 'types/app'

export default async function Layout({ children }: ChildrenPageProps) {
return <MainLayout subHeader={<EmptyHeader />}>{children}</MainLayout>
}
38 changes: 38 additions & 0 deletions explorer/src/app/[chain]/testnet-rewards/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { TestnetRewardsPage } from '@/components/TestnetRewards'
import { indexers } from 'constants/indexers'
import { metadata, url } from 'constants/metadata'
import { Metadata } from 'next'
import { FC } from 'react'
import type { ChainPageProps } from 'types/app'

export async function generateMetadata({ params: { chain } }: ChainPageProps): Promise<Metadata> {
const chainTitle = indexers.find((c) => c.network === chain)?.title || 'Unknown chain'
const title = `${metadata.title} - ${chainTitle} - Testnet Rewards`
const images = {
url: url + '/images/share-testnet-rewards.png',
secureUrl: url + 'image/png',
width: 900,
height: 600,
alt: title,
}
return {
...metadata,
title,
openGraph: {
...metadata.openGraph,
title,
images,
},
twitter: {
...metadata.twitter,
title,
images,
},
}
}

const Page: FC = () => {
return <TestnetRewardsPage />
}

export default Page
55 changes: 55 additions & 0 deletions explorer/src/components/TestnetRewards/FAQ.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use client'

import { FC, useState } from 'react'

export const FAQ: FC = () => {
const [openIndex, setOpenIndex] = useState<number | null>(null)

const toggleFAQ = (index: number) => {
setOpenIndex(openIndex === index ? null : index)
}

return (
<div className='mt-8 w-full max-w-xl'>
<h2 className='text-center text-xl font-bold text-gray-900 dark:text-white '>FAQ</h2>
<div className='mt-4'>
{[
{
question: 'How will testnet rewards be distributed?',
answer:
'Testnet rewards will be minted into the genesis block of the Autonomys Network Mainnet.\n\nThis will happen at the launch of Phase-1, and testnet farmers will be able to query the balances of their wallets immediately.',
},
{
question: 'What are the phases of the mainnet launch?',
answer:
'What has been referred to previously as Mainnet Beta will be deployed in two distinct phases.\n\n- Phase-1 will launch the consensus chain.\nThis allows us to establish the farmer network and secure the PoAS consensus with a healthy amount of space pledged. Consensus chain token transfers will be disabled at the protocol level in Phase-1.\n\n- Phase-2 will introduce our decoupled execution environments which are known as domains. Consensus chain token transfers will be enabled.',
},
{
question: 'What can I do with my mainnet rewards?',
answer:
'During Mainnet Phase-1 it will be possible to use them as gas to submit transactions on the consensus chain.\n\nFor example a testnet farmer could pay to store data on-chain using the system.remark extrinsic.\nThings get exciting at Phase-2 as token holders will be able to transfer them, convert them to domain tokens using XDM (Cross Domain Messaging) and stake them to run an operator and earn transaction fees.\n\nIf the commitment of running operator infrastructure is not practical, it is also possible to nominate operators to receive a share of the transaction fees being earned by the operators. Transferring consensus tokens to a domain opens up the possibilities afforded by the ecosystem of dApps that live and operate within them.',
},
].map((question, index) => (
<div key={index} className='m-4'>
<button
className='w-full rounded-lg bg-white p-8 text-left text-gray-900 shadow-md dark:border-none dark:bg-gray-800 dark:bg-gradient-to-r dark:from-gradientFrom dark:via-gradientVia dark:to-gradientTo dark:text-white'
onClick={() => toggleFAQ(index)}
>
<span className='font-semibold'>
{index + 1}. {question.question}
</span>
<span className='float-right'>{openIndex === index ? '▲' : '▼'}</span>
</button>
{openIndex === index && (
<div className='mt-2 rounded-lg bg-gray-100 p-4 dark:bg-gray-700'>
<p className='whitespace-pre-line text-gray-700 dark:text-white'>
{question.answer}
</p>
</div>
)}
</div>
))}
</div>
</div>
)
}
144 changes: 144 additions & 0 deletions explorer/src/components/TestnetRewards/RewardHistory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
'use client'

import { formatAddress } from '@/utils/formatAddress'
import { shortString } from '@/utils/string'
import { TrashIcon } from '@heroicons/react/24/outline'
import { WalletButton } from 'components/WalletButton'
import AccountListDropdown from 'components/WalletButton/AccountListDropdown'
import { INTERNAL_ROUTES, Routes } from 'constants/routes'
import { WalletType } from 'constants/wallet'
import useChains from 'hooks/useChains'
import useWallet from 'hooks/useWallet'
import Link from 'next/link'
import { FC, useCallback, useMemo } from 'react'
import { useViewStates } from 'states/view'
import { AccountIcon } from '../common/AccountIcon'

export const RewardHistory: FC = () => {
const { network } = useChains()
const { actingAccount, subspaceAccount, accounts } = useWallet()
const { mySubspaceWallets, addSubspaceWallet, removeSubspaceWallet } = useViewStates()

const isSubspaceWalletConnected = useMemo(
() => (subspaceAccount ? mySubspaceWallets.includes(subspaceAccount) : false),
[subspaceAccount, mySubspaceWallets],
)

const handleAddSubspaceWallet = useCallback(() => {
if (subspaceAccount && !isSubspaceWalletConnected) {
addSubspaceWallet(subspaceAccount)
}
}, [addSubspaceWallet, subspaceAccount, isSubspaceWalletConnected])

const handleRemoveSubspaceWallet = useCallback(() => {
if (subspaceAccount && isSubspaceWalletConnected) {
removeSubspaceWallet(subspaceAccount)
}
}, [removeSubspaceWallet, subspaceAccount, isSubspaceWalletConnected])

const connectedWallets = useMemo(
() => (
<div className='mt-4 w-full px-4 py-2'>
<h2 className='pb-4 text-center text-xl font-semibold text-gray-800 dark:text-gray-200'>
Connected Wallets
</h2>
<ul className='mt-2 list-inside list-disc space-y-4 text-gray-700 dark:text-gray-300'>
{mySubspaceWallets.map((wallet) => (
<div key={`${wallet}-account-id`} className='flex items-center justify-between gap-3'>
<div className='flex items-center gap-3'>
<AccountIcon address={wallet} size={26} theme='beachball' />
<Link
data-testid={`account-link-${wallet}`}
href={INTERNAL_ROUTES.accounts.id.page(network, Routes.consensus, wallet)}
className='hover:text-primaryAccent'
>
<div>
{shortString(wallet)}{' '}
{
accounts?.find((account) =>
account.type === WalletType.subspace ||
(account as { type: string }).type === 'sr25519'
? formatAddress(account.address) === wallet
: account.address === wallet,
)?.name
}
</div>
</Link>
</div>
<button
onClick={() => removeSubspaceWallet(wallet)}
className='ml-2 text-red-500 hover:text-red-700'
aria-label={`Remove ${wallet}`}
>
<TrashIcon className='h-5 w-5' />
</button>
</div>
))}
</ul>
</div>
),
[accounts, mySubspaceWallets, network, removeSubspaceWallet],
)

return (
<div className='w-full max-w-xl'>
<div className='mb-4 w-full rounded-[20px] border border-slate-100 bg-white px-3 py-4 shadow dark:border-none dark:bg-gradient-to-r dark:from-gradientFrom dark:via-gradientVia dark:to-gradientTo sm:p-6'>
<div className='mb-6 flex flex-col items-center justify-center'>
<h1 className='mb-2 text-center text-2xl font-bold text-gray-900 dark:text-white'>
Reward History
</h1>
</div>
<div className='m-4 flow-root text-gray-900 dark:text-white'>
<div className='mb-8 flex w-full flex-col items-center gap-3'>
<p className='mb-1 text-center text-lg font-semibold text-gray-700 dark:text-gray-300'>
Congratulations!
</p>
<p className='mb-2 text-center text-gray-600 dark:text-gray-400'>
We sincerely appreciate your continued support and belief in the Network throughout
the years.
</p>
<p className='mb-4 text-center text-gray-600 dark:text-gray-400'>
Please review your Subspace Network rewards for the testnet phases.
</p>
<div className='flex justify-center'>
{!actingAccount ? <WalletButton /> : <AccountListDropdown />}
</div>
{actingAccount && !subspaceAccount && (
<div className='flex justify-center'>
<span className='py-4 text-red-500'>
Please connect a substrate-compatible wallet to view your rewards.
</span>
</div>
)}
{actingAccount && (
<div className='flex justify-center'>
<button
className={`rounded-full px-6 py-2 font-semibold text-white ${
isSubspaceWalletConnected
? 'cursor-not-allowed bg-blue-300'
: 'bg-blue-600 hover:bg-blue-700'
}`}
onClick={handleAddSubspaceWallet}
disabled={isSubspaceWalletConnected}
>
⚡ Connect more Wallets ⚡
</button>
</div>
)}
{isSubspaceWalletConnected && (
<div className='flex justify-center'>
<button
className='rounded-full bg-red-600 px-6 py-2 font-semibold text-white hover:bg-red-700'
onClick={handleRemoveSubspaceWallet}
>
⚡ Remove Wallet ⚡
</button>
</div>
)}
{mySubspaceWallets.length > 0 && connectedWallets}
</div>
</div>
</div>
</div>
)
}
Loading
Loading