Skip to content

Commit

Permalink
making attestations non-conditional 🚤
Browse files Browse the repository at this point in the history
  • Loading branch information
dysbulic committed Aug 13, 2024
1 parent 7cde476 commit c509513
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 94 deletions.
145 changes: 72 additions & 73 deletions packages/web/components/Player/Section/Attestations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export const Attestations: React.FC<{ player: Player }> = ({ player }) => {

return (
<div>
{player?.ethereumAddress.toLocaleLowerCase === address?.toLocaleLowerCase && (
{player?.ethereumAddress.toLowerCase() === address?.toLowerCase() && (
<div>
<h3>Your Attestations: ({attestations?.length})</h3>
<VStack mt={4} mb={4} w="full">
{attestations?.map((att, i) => {
const attestor = att[3].value;
const timeCreated = att[1].value.value;

const attestationVal = att[0].value;

return (
<Flex
direction="column"
Expand Down Expand Up @@ -108,81 +108,80 @@ export const Attestations: React.FC<{ player: Player }> = ({ player }) => {
{player?.ethereumAddress.toLocaleLowerCase() !== address?.toLocaleLowerCase() && (
<>
<div>
<h3>Your Attestations: ({attestations?.length})</h3>
<VStack mt={4} mb={4} w="full">
{attestations?.map((att, i) => {
const attestor = att[3].value;
const timeCreated = att[1].value.value;
<h3>Your Attestations: ({attestations?.length})</h3>
<VStack mt={4} mb={4} w="full">
{attestations?.map((att, i) => {
const attestor = att[3].value;
const timeCreated = att[1].value.value;
const attestationVal = att[0].value;

const attestationVal = att[0].value;
return (
<Flex
direction="column"
key={i}
justifyContent="start"
alignContent="center"
color={'violet'}
width={'full'}
px={4}
py={3}
background={'blackAlpha.300'}
transition={'ease-in-out'}
transitionDuration={'300'}
_hover={{
background: 'blackAlpha.500',
}}
_active={{
background: 'blackAlpha.700',
}}
borderRadius={20}
borderColor={'rgba(255,255,255,0.1)'}
borderLeftWidth={1}
borderTopWidth={1}
dropShadow={`0 4 4px rgba(0,0,0,0.25)`}
>
<Text
fontSize="md"
fontWeight={700}
noOfLines={4}
my={2}
color="white"
return (
<Flex
direction="column"
key={i}
justifyContent="start"
alignContent="center"
color={'violet'}
width={'full'}
px={4}
py={3}
background={'blackAlpha.300'}
transition={'ease-in-out'}
transitionDuration={'300'}
_hover={{
background: 'blackAlpha.500',
}}
_active={{
background: 'blackAlpha.700',
}}
borderRadius={20}
borderColor={'rgba(255,255,255,0.1)'}
borderLeftWidth={1}
borderTopWidth={1}
dropShadow={`0 4 4px rgba(0,0,0,0.25)`}
>
{attestationVal.value}
</Text>
<Text fontSize="sm" color="white">
By {attestor}
</Text>
<Text fontSize="sm">{timeCreated}</Text>
</Flex>
);
})}
</VStack>
</div>
<div>
<Textarea
placeholder="Attest."
minW="min(18em, calc(100vw - 2rem))"
color="white"
bg="dark"
onChange={(e) => {
if (e.target.value.length > MAX_DESC_LEN) {
return;
}
setAttestion(e.target.value);
}}
value={attestation}
/>
<MetaButton
onClick={handleAttest}
disabled={isAttesting}
style={{ marginTop: '1em' }}
>
Attest
</MetaButton>
</div>
<Text
fontSize="md"
fontWeight={700}
noOfLines={4}
my={2}
color="white"
>
{attestationVal.value}
</Text>
<Text fontSize="sm" color="white">
By {attestor}
</Text>
<Text fontSize="sm">{timeCreated}</Text>
</Flex>
);
})}
</VStack>
</div>
</>

)}
<div>
<Textarea
placeholder="Attest."
minW="min(18em, calc(100vw - 2rem))"
color="white"
bg="dark"
onChange={(e) => {
if (e.target.value.length > MAX_DESC_LEN) {
return;
}
setAttestion(e.target.value);
}}
value={attestation}
/>
<MetaButton
onClick={handleAttest}
disabled={isAttesting}
style={{ marginTop: '1em' }}
>
Attest
</MetaButton>
</div>
</div>
);
};
40 changes: 20 additions & 20 deletions packages/web/lib/hooks/useEAS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const useEAS = () => {
const encodedData = schemaEncoder.encodeData([
{ name: 'attestation', value: message, type: 'string' },
{ name: 'timeCreated', value: timeRightNow, type: 'string' },
{ name: 'xp', value: xp ?? '0', type: 'string' },
{ name: 'xp', value: xp ?? '¿?', type: 'string' },
]);
const tx = await eas.attest({
schema: schemaUID,
Expand All @@ -82,27 +82,27 @@ export const useEAS = () => {
async function fetchData() {
// Define the GraphQL query
const query = `
query Attestations($recipient: String!) {
attestations(
where: {
schemaId: { equals: "0xd4c0003240401da8b17fbe710a41e4c8e690a0afef796ab6d5871b69ac15b0d1" }
recipient: { equals: $recipient }
query Attestations($recipient: String!) {
attestations(
where: {
schemaId: { equals: "0xd4c0003240401da8b17fbe710a41e4c8e690a0afef796ab6d5871b69ac15b0d1" }
recipient: { equals: $recipient }
}
take: 25
) {
id
attester
recipient
refUID
revocable
revocationTime
expirationTime
data
schemaId
timeCreated
}
take: 25
) {
id
attester
recipient
refUID
revocable
revocationTime
expirationTime
data
schemaId
timeCreated
}
}
`;
`;
const checkSumAddress = ethers.getAddress(recipient);

// Define the GraphQL endpoint
Expand Down
1 change: 0 additions & 1 deletion packages/web/lib/hooks/useEthersProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export function useViemClients({
return clients;
}


export function useEthersProvider({
chain = optimism,
}: { chain?: Chain } = {}) {
Expand Down

0 comments on commit c509513

Please sign in to comment.