diff --git a/packages/nextjs/components/AccountAbstractionAttestations.tsx b/packages/nextjs/components/AccountAbstractionAttestations.tsx index fc0642a..70cf34d 100644 --- a/packages/nextjs/components/AccountAbstractionAttestations.tsx +++ b/packages/nextjs/components/AccountAbstractionAttestations.tsx @@ -19,11 +19,9 @@ const AccountAbstractionAttestations: React.FC = props => { return (
- {/* {data.map(attestation => ( + {data.map(attestation => (
{attestation.args!.uid ? attestation.args!.uid.slice(0, 10) : ""}
- ))} */} - - Att here + ))}
); }; diff --git a/packages/nextjs/contracts/externalContracts.ts b/packages/nextjs/contracts/externalContracts.ts index c800df5..168554c 100644 --- a/packages/nextjs/contracts/externalContracts.ts +++ b/packages/nextjs/contracts/externalContracts.ts @@ -13,8 +13,8 @@ import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract"; const externalContracts = { 1: { EAS: { - address: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e", - deployedAt: 4717894, + address: "0x4200000000000000000000000000000000000021", + deployedAt: 12565960, abi: [ { inputs: [{ internalType: "contract ISchemaRegistry", name: "registry", type: "address" }], @@ -464,7 +464,7 @@ const externalContracts = { ], }, SchemaRegistry: { - address: "0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0", + address: "0x4200000000000000000000000000000000000020", abi: [ { inputs: [], name: "AlreadyExists", type: "error" }, { diff --git a/packages/nextjs/scaffold.config.ts b/packages/nextjs/scaffold.config.ts index 2f22d04..c6a07ac 100644 --- a/packages/nextjs/scaffold.config.ts +++ b/packages/nextjs/scaffold.config.ts @@ -11,7 +11,7 @@ export type ScaffoldConfig = { const scaffoldConfig = { // The network where your DApp lives in - targetNetwork: chains.sepolia, + targetNetwork: chains.baseGoerli, // The interval at which your front-end polls the RPC servers for new data // it has no effect on the local network diff --git a/packages/nextjs/services/web3/attestationService.ts b/packages/nextjs/services/web3/attestationService.ts index 3719c28..df4d304 100644 --- a/packages/nextjs/services/web3/attestationService.ts +++ b/packages/nextjs/services/web3/attestationService.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { getSigner } from "./ethersSigner"; +import { getProvider, getSigner } from "./ethersSigner"; import { Attestation, EAS, SchemaEncoder, SchemaRecord, SchemaRegistry } from "@ethereum-attestation-service/eas-sdk"; import { Contract } from "ethers"; import externalContracts from "~~/contracts/externalContracts"; -const EASContractAddress = "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"; // Sepolia v0.26 -const schemaRegistryContractAddress = "0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0"; -const resolverAddress = "0x0000000000000000000000000000000000000000"; // Sepolia 0.26 +const EASContractAddress = "0x4200000000000000000000000000000000000021"; +const schemaRegistryContractAddress = "0x4200000000000000000000000000000000000020"; +const resolverAddress = "0x0000000000000000000000000000000000000000"; const schemaUID = "0x95e10aa7a515d68dafbfd739b4c9ed7afb40e1fbe8f7a1468501de02fc334c28"; const createAttendeeSchemaData = ({ eventId, eventName }: { eventId: string; eventName: string }): any => { @@ -91,12 +91,12 @@ export const createMultiAttestation = async (addresses: string[], attestation: s }; export const getAttestationsForAddress = async (userAddress: string) => { - const signer = await getSigner(); + const provider = await getProvider(); const address = externalContracts[1].EAS.address; const abi = externalContracts[1].EAS.abi; const fromBlock = externalContracts[1].EAS.deployedAt; - const EASInstance = new Contract(address, abi, signer); + const EASInstance = new Contract(address, abi, provider); const attested = await EASInstance.queryFilter("Attested", fromBlock); @@ -105,6 +105,27 @@ export const getAttestationsForAddress = async (userAddress: string) => { }); }; +// Return all the attestations where you are the organizer +export const getOrganizerAttestationsForAddress = async (userAddress: string) => { + const provider = await getProvider(); + + const address = externalContracts[1].EAS.address; + const abi = externalContracts[1].EAS.abi; + const fromBlock = externalContracts[1].EAS.deployedAt; + const EASInstance = new Contract(address, abi, provider); + + const attested = await EASInstance.queryFilter("Attested", fromBlock); + + // Events for which you self attested are the ones where you are the organizer + const res = attested.filter(event => { + return ( + event.args!.recipient === userAddress && event.args!.schema === schemaUID && event.args!.attester === userAddress + ); + }); + + return res; +}; + const createAttestationSchema = async () => { const signer = await getSigner(); const schemaRegistry = new SchemaRegistry(schemaRegistryContractAddress); diff --git a/packages/nextjs/services/web3/ethersSigner.ts b/packages/nextjs/services/web3/ethersSigner.ts index 9f7f3d2..be11925 100644 --- a/packages/nextjs/services/web3/ethersSigner.ts +++ b/packages/nextjs/services/web3/ethersSigner.ts @@ -1,13 +1,13 @@ -import { type WalletClient, getWalletClient } from "@wagmi/core"; +import { type PublicClient, type WalletClient, getPublicClient, getWalletClient } from "@wagmi/core"; import { providers } from "ethers"; -import { sepolia } from "wagmi/chains"; +import { type HttpTransport } from "viem"; +import { baseGoerli } from "wagmi/chains"; export function walletClientToSigner(walletClient: WalletClient) { - const { account, chain = sepolia, transport } = walletClient; + const { account, chain = baseGoerli, transport } = walletClient; const network = { chainId: chain.id, name: chain.name, - ensAddress: chain.contracts?.ensRegistry?.address, }; const provider = new providers.Web3Provider(transport, network); const signer = provider.getSigner(account.address); @@ -15,6 +15,22 @@ export function walletClientToSigner(walletClient: WalletClient) { return signer; } +export function publicClientToProvider(publicClient: PublicClient) { + const { chain, transport } = publicClient; + const network = { + chainId: chain.id, + name: chain.name, + ensAddress: chain.contracts?.ensRegistry?.address, + }; + if (transport.type === "fallback") + return new providers.FallbackProvider( + (transport.transports as ReturnType[]).map( + ({ value }) => new providers.JsonRpcProvider(value?.url, network), + ), + ); + return new providers.JsonRpcProvider(transport.url, network); +} + export const getSigner = async () => { const walletClient = await getWalletClient(); @@ -23,3 +39,10 @@ export const getSigner = async () => { return signer; }; + +export const getProvider = async () => { + const publicClient = await getPublicClient(); + const provider = publicClientToProvider(publicClient); + + return provider; +};