mirror of
https://github.com/placeholder-soft/web.git
synced 2026-01-12 22:45:00 +08:00
Add buildathon participant SBT badge (#833)
This commit is contained in:
9
apps/web/src/abis/BuildathonSBT.ts
Normal file
9
apps/web/src/abis/BuildathonSBT.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default [
|
||||
{
|
||||
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
||||
name: 'balanceOf',
|
||||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
] as const;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CoinbaseVerifications } from 'apps/web/src/hooks/useCoinbaseVerifications';
|
||||
import { CoinbaseVerifications } from '../hooks/useCoinbaseVerifications';
|
||||
import { StaticImageData } from 'next/dist/shared/lib/get-img-props';
|
||||
import { GuildBadges } from 'apps/web/src/hooks/useBaseGuild';
|
||||
import { GuildBadges } from '../hooks/useBaseGuild';
|
||||
|
||||
// image imports
|
||||
import verifiedIdentity from './images/verifiedIdentity.webp';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useReadContract } from 'wagmi';
|
||||
import BuildathonSBT from 'apps/web/src/abis/BuildathonSBT';
|
||||
|
||||
const PARTICIPANT_SBT_ADDRESS = '0x59ca61566C03a7Fb8e4280d97bFA2e8e691DA3a6';
|
||||
|
||||
export default function useBuildathonParticipant(address?: `0x${string}`): boolean {
|
||||
const { data: balanceOf } = useReadContract({
|
||||
address: PARTICIPANT_SBT_ADDRESS,
|
||||
abi: BuildathonSBT,
|
||||
functionName: 'balanceOf',
|
||||
args: [address ?? '0x'],
|
||||
query: {
|
||||
enabled: !!address,
|
||||
},
|
||||
});
|
||||
|
||||
if (!balanceOf) return false;
|
||||
return balanceOf > 0;
|
||||
}
|
||||
@@ -5,9 +5,10 @@ import {
|
||||
BadgeNames,
|
||||
} from 'apps/web/src/components/Basenames/UsernameProfileSectionBadges/Badges';
|
||||
import UsernameProfileSectionTitle from 'apps/web/src/components/Basenames/UsernameProfileSectionTitle';
|
||||
import { useBaseGuild } from 'apps/web/src/hooks/useBaseGuild';
|
||||
import { useCoinbaseVerification } from 'apps/web/src/hooks/useCoinbaseVerifications';
|
||||
import { useTalentProtocol } from 'apps/web/src/hooks/useTalentProtocol';
|
||||
import { useBaseGuild } from './hooks/useBaseGuild';
|
||||
import { useCoinbaseVerification } from './hooks/useCoinbaseVerifications';
|
||||
import { useTalentProtocol } from './hooks/useTalentProtocol';
|
||||
import useBuildathonParticipant from './hooks/useBuildathonParticipant';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
function BadgesLoop({
|
||||
@@ -68,10 +69,11 @@ function BuilderSection() {
|
||||
const { profileAddress, currentWalletIsOwner } = useUsernameProfile();
|
||||
const { badges, empty } = useBaseGuild(profileAddress);
|
||||
const talentScore = useTalentProtocol(profileAddress);
|
||||
const buildathonParticipant = useBuildathonParticipant(profileAddress);
|
||||
|
||||
const combinedBadges = useMemo(
|
||||
() => ({ ...badges, TALENT_SCORE: talentScore }),
|
||||
[badges, talentScore],
|
||||
() => ({ ...badges, TALENT_SCORE: talentScore, BUILDATHON_PARTICIPANT: buildathonParticipant }),
|
||||
[badges, talentScore, buildathonParticipant],
|
||||
);
|
||||
const combinedEmpty = empty && !talentScore;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user