Skip to content

Commit

Permalink
feat: calling attestation_listener where it wasn't being called
Browse files Browse the repository at this point in the history
  • Loading branch information
amaurymagalhaes committed Nov 1, 2024
1 parent 38cd56e commit d88cdae
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
12 changes: 11 additions & 1 deletion components/Forms/GrantUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { errorManager } from "../Utilities/errorManager";
import { urlRegex } from "@/utilities/regexs/urlRegex";
import { sanitizeObject } from "@/utilities/sanitize";
import { useGrantStore } from "@/store/grant";
import fetchData from "@/utilities/fetchData";
import { INDEXER } from "@/utilities/indexer";

const updateSchema = z.object({
title: z
Expand Down Expand Up @@ -134,8 +136,16 @@ export const GrantUpdateForm: FC<GrantUpdateFormProps> = ({

await grantUpdate
.attest(walletSigner as any, changeStepperStep)
.then(async () => {
.then(async (res) => {
let retries = 1000;
const txHash = res?.tx[0]?.hash;
if (txHash) {
await fetchData(
INDEXER.ATTESTATION_LISTENER(txHash, grantToUpdate.chainID),
"POST",
{}
);
}
changeStepperStep("indexing");
while (retries > 0) {
await refreshProject()
Expand Down
12 changes: 11 additions & 1 deletion components/Forms/Milestone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { useRouter } from "next/navigation";
import { PAGES } from "@/utilities/pages";
import { errorManager } from "../Utilities/errorManager";
import { sanitizeObject } from "@/utilities/sanitize";
import fetchData from "@/utilities/fetchData";
import { INDEXER } from "@/utilities/indexer";

const milestoneSchema = z.object({
title: z
Expand Down Expand Up @@ -147,8 +149,16 @@ export const MilestoneForm: FC<MilestoneFormProps> = ({
const walletSigner = await walletClientToSigner(walletClient);
await milestoneToAttest
.attest(walletSigner as any, changeStepperStep)
.then(async () => {
.then(async (res) => {
let retries = 1000;
const txHash = res?.tx[0]?.hash;
if (txHash) {
await fetchData(
INDEXER.ATTESTATION_LISTENER(txHash, milestoneToAttest.chainID),
"POST",
{}
);
}
changeStepperStep("indexing");
while (retries > 0) {
await refreshProject()
Expand Down
28 changes: 26 additions & 2 deletions components/Forms/MilestoneUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { cn } from "@/utilities/tailwind";
import { useRouter } from "next/navigation";
import { PAGES } from "@/utilities/pages";
import fetchData from "@/utilities/fetchData";
import { INDEXER } from "@/utilities/indexer";

interface MilestoneUpdateFormProps {
milestone: IMilestoneResponse;
Expand Down Expand Up @@ -143,9 +145,20 @@ export const MilestoneUpdateForm: FC<MilestoneUpdateFormProps> = ({
}),
changeStepperStep
)
.then(async () => {
.then(async (res) => {
let retries = 1000;
changeStepperStep("indexing");
const txHash = res?.tx[0]?.hash;
if (txHash) {
await fetchData(
INDEXER.ATTESTATION_LISTENER(
txHash,
milestoneInstance?.chainID as number
),
"POST",
{}
);
}
while (retries > 0) {
await refreshProject()
.then(async (fetchedProject) => {
Expand Down Expand Up @@ -238,9 +251,20 @@ export const MilestoneUpdateForm: FC<MilestoneUpdateFormProps> = ({
}),
changeStepperStep
)
.then(async () => {
.then(async (res) => {
let retries = 1000;
changeStepperStep("indexing");
const txHash = res?.tx[0]?.hash;
if (txHash) {
await fetchData(
INDEXER.ATTESTATION_LISTENER(
txHash,
milestoneInstance?.chainID as number
),
"POST",
{}
);
}
while (retries > 0) {
await refreshProject()
.then(async (fetchedProject) => {
Expand Down
12 changes: 11 additions & 1 deletion components/Forms/ProjectUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { useAccount, useSwitchChain } from "wagmi";
import { z } from "zod";
import { errorManager } from "../Utilities/errorManager";
import { sanitizeObject } from "@/utilities/sanitize";
import fetchData from "@/utilities/fetchData";
import { INDEXER } from "@/utilities/indexer";

const updateSchema = z.object({
title: z
Expand Down Expand Up @@ -93,9 +95,17 @@ export const ProjectUpdateForm: FC<ProjectUpdateFormProps> = ({

await projectUpdate
.attest(walletSigner as any, changeStepperStep)
.then(async () => {
.then(async (res) => {
let retries = 1000;
changeStepperStep("indexing");
const txHash = res?.tx[0]?.hash;
if (txHash) {
await fetchData(
INDEXER.ATTESTATION_LISTENER(txHash, projectUpdate.chainID),
"POST",
{}
);
}
while (retries > 0) {
await refreshProject()
.then(async (fetchedProject) => {
Expand Down

0 comments on commit d88cdae

Please sign in to comment.